tor-browser

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

FakeVideoSource.h (2167B)


      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_FAKEVIDEOSOURCE_H_
      8 #define DOM_MEDIA_SYSTEMSERVICES_FAKEVIDEOSOURCE_H_
      9 
     10 #include "MediaEventSource.h"
     11 #include "PerformanceRecorder.h"
     12 #include "mozilla/EventTargetCapability.h"
     13 #include "mozilla/Maybe.h"
     14 #include "mozilla/Mutex.h"
     15 #include "mozilla/ThreadSafety.h"
     16 
     17 class nsITimer;
     18 
     19 namespace mozilla {
     20 class TimeStamp;
     21 class TimeDurationValueCalculator;
     22 template <typename T>
     23 class BaseTimeDuration;
     24 typedef BaseTimeDuration<TimeDurationValueCalculator> TimeDuration;
     25 namespace layers {
     26 class Image;
     27 class ImageContainer;
     28 }  // namespace layers
     29 
     30 class FakeVideoSource {
     31 public:
     32  explicit FakeVideoSource(nsISerialEventTarget* aTarget);
     33 
     34  NS_INLINE_DECL_THREADSAFE_REFCOUNTING(FakeVideoSource)
     35  int32_t StartCapture(int32_t aWidth, int32_t aHeight,
     36                       const TimeDuration& aFrameInterval);
     37  int32_t StopCapture();
     38  bool CaptureStarted();
     39  void SetTrackingId(uint32_t aTrackingIdProcId);
     40 
     41  MediaEventSource<RefPtr<layers::Image>, TimeStamp>& GeneratedImageEvent() {
     42    return mGeneratedImageEvent;
     43  }
     44 
     45 private:
     46  ~FakeVideoSource();
     47 
     48  /**
     49   * Called by mTimer when it's time to generate a new image.
     50   */
     51  void GenerateImage() MOZ_REQUIRES(mTarget);
     52 
     53  Mutex mMutex{"FakeVideoSource::mMutex"};
     54  nsCOMPtr<nsITimer> mTimer MOZ_GUARDED_BY(mMutex);
     55  PerformanceRecorderMulti<CaptureStage> mCaptureRecorder;
     56  MediaEventProducer<RefPtr<layers::Image>, TimeStamp> mGeneratedImageEvent;
     57 
     58  EventTargetCapability<nsISerialEventTarget> mTarget;
     59  Maybe<TrackingId> mTrackingId MOZ_GUARDED_BY(mTarget);
     60  RefPtr<layers::ImageContainer> mImageContainer MOZ_GUARDED_BY(mTarget);
     61  int32_t mWidth MOZ_GUARDED_BY(mTarget) = -1;
     62  int32_t mHeight MOZ_GUARDED_BY(mTarget) = -1;
     63  int mCb MOZ_GUARDED_BY(mTarget) = 16;
     64  int mCr MOZ_GUARDED_BY(mTarget) = 16;
     65 };
     66 }  // namespace mozilla
     67 
     68 #endif