tor-browser

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

GMPVideoEncoderParent.h (3414B)


      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 GMPVideoEncoderParent_h_
      7 #define GMPVideoEncoderParent_h_
      8 
      9 #include "GMPCrashHelperHolder.h"
     10 #include "GMPMessageUtils.h"
     11 #include "GMPSharedMemManager.h"
     12 #include "GMPUtils.h"
     13 #include "GMPVideoEncoderProxy.h"
     14 #include "GMPVideoHost.h"
     15 #include "gmp-video-encode.h"
     16 #include "mozilla/RefPtr.h"
     17 #include "mozilla/gmp/PGMPVideoEncoderParent.h"
     18 
     19 namespace mozilla::gmp {
     20 
     21 class GMPContentParent;
     22 
     23 class GMPVideoEncoderParent final : public GMPVideoEncoderProxy,
     24                                    public PGMPVideoEncoderParent,
     25                                    public GMPSharedMemManager,
     26                                    public GMPCrashHelperHolder {
     27  friend class PGMPVideoEncoderParent;
     28 
     29 public:
     30  // Mark AddRef and Release as `final`, as they overload pure virtual
     31  // implementations in PGMPVideoEncoderParent.
     32  NS_INLINE_DECL_REFCOUNTING(GMPVideoEncoderParent, final)
     33 
     34  explicit GMPVideoEncoderParent(GMPContentParent* aPlugin);
     35 
     36  GMPVideoHostImpl& Host();
     37  void Shutdown();
     38 
     39  // GMPVideoEncoderProxy
     40  void Close() override;
     41  GMPErr InitEncode(const GMPVideoCodec& aCodecSettings,
     42                    const nsTArray<uint8_t>& aCodecSpecific,
     43                    GMPVideoEncoderCallbackProxy* aCallback,
     44                    int32_t aNumberOfCores, uint32_t aMaxPayloadSize) override;
     45  GMPErr Encode(GMPUniquePtr<GMPVideoi420Frame> aInputFrame,
     46                const nsTArray<uint8_t>& aCodecSpecificInfo,
     47                const nsTArray<GMPVideoFrameType>& aFrameTypes) override;
     48  GMPErr SetChannelParameters(uint32_t aPacketLoss, uint32_t aRTT) override;
     49  GMPErr SetRates(uint32_t aNewBitRate, uint32_t aFrameRate) override;
     50  GMPErr SetPeriodicKeyFrames(bool aEnable) override;
     51  uint32_t GetPluginId() const override { return mPluginId; }
     52 
     53  // GMPSharedMemManager
     54  bool MgrAllocShmem(size_t aSize, Shmem* aMem) override {
     55    return AllocShmem(aSize, aMem);
     56  }
     57 
     58  void MgrDeallocShmem(Shmem& aMem) override { DeallocShmem(aMem); }
     59 
     60 protected:
     61  bool MgrIsOnOwningThread() const override;
     62 
     63 private:
     64  virtual ~GMPVideoEncoderParent() = default;
     65 
     66  // PGMPVideoEncoderParent
     67  void ActorDestroy(ActorDestroyReason aWhy) override;
     68  mozilla::ipc::IPCResult RecvReturnShmem(ipc::Shmem&& aInputShmem) override;
     69  mozilla::ipc::IPCResult RecvEncodedShmem(
     70      const GMPVideoEncodedFrameData& aEncodedFrame, ipc::Shmem&& aEncodedShmem,
     71      nsTArray<uint8_t>&& aCodecSpecificInfo) override;
     72  mozilla::ipc::IPCResult RecvEncodedData(
     73      const GMPVideoEncodedFrameData& aEncodedFrame,
     74      nsTArray<uint8_t>&& aEncodedData,
     75      nsTArray<uint8_t>&& aCodecSpecificInfo) override;
     76  mozilla::ipc::IPCResult RecvDroppedFrame(const uint64_t& aTimestamp) override;
     77  mozilla::ipc::IPCResult RecvError(const GMPErr& aError) override;
     78  mozilla::ipc::IPCResult RecvShutdown() override;
     79 
     80  size_t mEncodedShmemSize = 0;
     81  bool mIsOpen;
     82  bool mShuttingDown;
     83  bool mActorDestroyed;
     84  RefPtr<GMPContentParent> mPlugin;
     85  RefPtr<GMPVideoEncoderCallbackProxy> mCallback;
     86  GMPVideoHostImpl mVideoHost;
     87  const uint32_t mPluginId;
     88 };
     89 
     90 }  // namespace mozilla::gmp
     91 
     92 #endif  // GMPVideoEncoderParent_h_