tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

video_capture_fake.h (2235B)


      1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
      2 /* vim: set ts=2 et sw=2 tw=80: */
      3 /* This Source Code Form is subject to the terms of the Mozilla Public
      4 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
      5 * You can obtain one at http://mozilla.org/MPL/2.0/. */
      6 
      7 #ifndef DOM_MEDIA_SYSTEMSERVICES_FAKE_VIDEO_CAPTURE_VIDEO_CAPTURE_FAKE_H_
      8 #define DOM_MEDIA_SYSTEMSERVICES_FAKE_VIDEO_CAPTURE_VIDEO_CAPTURE_FAKE_H_
      9 
     10 #include "MediaEventSource.h"
     11 #include "modules/video_capture/video_capture_impl.h"
     12 #include "mozilla/Maybe.h"
     13 #include "mozilla/RefPtr.h"
     14 #include "mozilla/ThreadSafety.h"
     15 #include "mozilla/TimeStamp.h"
     16 #include "system_wrappers/include/clock.h"
     17 
     18 class nsISerialEventTarget;
     19 
     20 namespace mozilla {
     21 class FakeVideoSource;
     22 namespace layers {
     23 class Image;
     24 }
     25 }  // namespace mozilla
     26 
     27 namespace webrtc::videocapturemodule {
     28 class VideoCaptureFake : public webrtc::videocapturemodule::VideoCaptureImpl {
     29 public:
     30  explicit VideoCaptureFake(Clock* clock, nsISerialEventTarget* aTarget);
     31  ~VideoCaptureFake() override;
     32 
     33  static webrtc::scoped_refptr<webrtc::VideoCaptureModule> Create(
     34      nsISerialEventTarget* aTarget);
     35 
     36  // Implementation of VideoCaptureImpl.
     37 
     38  // Starts capturing synchronously. Idempotent. If an existing capture is live
     39  // and another capability is requested we'll restart the underlying backend
     40  // with the new capability.
     41  int32_t StartCapture(const VideoCaptureCapability& aCapability)
     42      MOZ_EXCLUDES(api_lock_) override;
     43  // Stops capturing synchronously. Idempotent.
     44  int32_t StopCapture() MOZ_EXCLUDES(api_lock_) override;
     45  bool CaptureStarted() MOZ_EXCLUDES(api_lock_) override;
     46  int32_t CaptureSettings(VideoCaptureCapability& aSettings) override;
     47 
     48  void SetTrackingId(uint32_t aTrackingIdProcId)
     49      MOZ_EXCLUDES(api_lock_) override;
     50 
     51 private:
     52  void OnGeneratedImage(const RefPtr<mozilla::layers::Image>& aImage,
     53                        mozilla::TimeStamp aTime);
     54 
     55  const nsCOMPtr<nsISerialEventTarget> mTarget;
     56  const RefPtr<mozilla::FakeVideoSource> mSource;
     57  mozilla::Maybe<mozilla::TimeStamp> mStart;
     58  mozilla::MediaEventListener mGeneratedImageListener;
     59 };
     60 }  // namespace webrtc::videocapturemodule
     61 
     62 #endif