tor-browser

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

GMPVideoEncoderChild.h (2976B)


      1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
      2 /* This Source Code Form is subject to the terms of the Mozilla Public
      3 * License, v. 2.0. If a copy of the MPL was not distributed with this
      4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
      5 
      6 #ifndef GMPVideoEncoderChild_h_
      7 #define GMPVideoEncoderChild_h_
      8 
      9 #include "GMPSharedMemManager.h"
     10 #include "GMPVideoHost.h"
     11 #include "GMPVideoi420FrameImpl.h"
     12 #include "gmp-video-encode.h"
     13 #include "mozilla/gmp/PGMPVideoEncoderChild.h"
     14 #include "nsString.h"
     15 
     16 namespace mozilla::gmp {
     17 
     18 class GMPContentChild;
     19 
     20 class GMPVideoEncoderChild final : public PGMPVideoEncoderChild,
     21                                   public GMPVideoEncoderCallback,
     22                                   public GMPSharedMemManager {
     23  friend class PGMPVideoEncoderChild;
     24 
     25 public:
     26  // Mark AddRef and Release as `final`, as they overload pure virtual
     27  // implementations in PGMPVideoEncoderChild.
     28  NS_INLINE_DECL_THREADSAFE_REFCOUNTING(GMPVideoEncoderChild, final);
     29 
     30  explicit GMPVideoEncoderChild(GMPContentChild* aPlugin);
     31 
     32  void Init(GMPVideoEncoder* aEncoder);
     33  GMPVideoHostImpl& Host();
     34 
     35  // GMPVideoEncoderCallback
     36  void Encoded(GMPVideoEncodedFrame* aEncodedFrame,
     37               const uint8_t* aCodecSpecificInfo,
     38               uint32_t aCodecSpecificInfoLength) override;
     39  void Error(GMPErr aError) override;
     40 
     41  // GMPSharedMemManager
     42  void MgrDeallocShmem(Shmem& aMem) override { DeallocShmem(aMem); }
     43  void MgrDecodedFrameDestroyed(GMPVideoi420FrameImpl* aFrame) override;
     44 
     45 protected:
     46  bool MgrIsOnOwningThread() const override;
     47 
     48 private:
     49  virtual ~GMPVideoEncoderChild();
     50 
     51  // PGMPVideoEncoderChild
     52  mozilla::ipc::IPCResult RecvInitEncode(const GMPVideoCodec& aCodecSettings,
     53                                         nsTArray<uint8_t>&& aCodecSpecific,
     54                                         const int32_t& aNumberOfCores,
     55                                         const uint32_t& aMaxPayloadSize);
     56  mozilla::ipc::IPCResult RecvGiveShmem(ipc::Shmem&& aOutputShmem);
     57  mozilla::ipc::IPCResult RecvEncode(const GMPVideoi420FrameData& aInputFrame,
     58                                     ipc::Shmem&& aInputShmem,
     59                                     nsTArray<uint8_t>&& aCodecSpecificInfo,
     60                                     nsTArray<GMPVideoFrameType>&& aFrameTypes);
     61  mozilla::ipc::IPCResult RecvSetChannelParameters(const uint32_t& aPacketLoss,
     62                                                   const uint32_t& aRTT);
     63  mozilla::ipc::IPCResult RecvSetRates(const uint32_t& aNewBitRate,
     64                                       const uint32_t& aFrameRate);
     65  mozilla::ipc::IPCResult RecvSetPeriodicKeyFrames(const bool& aEnable);
     66  void ActorDestroy(ActorDestroyReason why) override;
     67 
     68  GMPContentChild* mPlugin;
     69  GMPVideoEncoder* mVideoEncoder;
     70  GMPVideoHostImpl mVideoHost;
     71  uint64_t mLatestEncodedTimestamp = 0;
     72 };
     73 
     74 }  // namespace mozilla::gmp
     75 
     76 #endif  // GMPVideoEncoderChild_h_