tor-browser

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

GMPVideoDecoderParent.h (3965B)


      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 GMPVideoDecoderParent_h_
      7 #define GMPVideoDecoderParent_h_
      8 
      9 #include "GMPCrashHelperHolder.h"
     10 #include "GMPMessageUtils.h"
     11 #include "GMPSharedMemManager.h"
     12 #include "GMPUtils.h"
     13 #include "GMPVideoDecoderProxy.h"
     14 #include "GMPVideoHost.h"
     15 #include "VideoUtils.h"
     16 #include "gmp-video-decode.h"
     17 #include "mozilla/RefPtr.h"
     18 #include "mozilla/gmp/PGMPVideoDecoderParent.h"
     19 
     20 namespace mozilla::gmp {
     21 
     22 class GMPContentParent;
     23 
     24 class GMPVideoDecoderParent final : public PGMPVideoDecoderParent,
     25                                    public GMPVideoDecoderProxy,
     26                                    public GMPSharedMemManager,
     27                                    public GMPCrashHelperHolder {
     28  friend class PGMPVideoDecoderParent;
     29 
     30 public:
     31  // Mark AddRef and Release as `final`, as they overload pure virtual
     32  // implementations in PGMPVideoDecoderParent.
     33  NS_INLINE_DECL_REFCOUNTING(GMPVideoDecoderParent, final)
     34 
     35  explicit GMPVideoDecoderParent(GMPContentParent* aPlugin);
     36 
     37  GMPVideoHostImpl& Host();
     38  nsresult Shutdown();
     39 
     40  // GMPVideoDecoder
     41  void Close() override;
     42  nsresult InitDecode(const GMPVideoCodec& aCodecSettings,
     43                      const nsTArray<uint8_t>& aCodecSpecific,
     44                      GMPVideoDecoderCallbackProxy* aCallback,
     45                      int32_t aCoreCount) override;
     46  nsresult Decode(GMPUniquePtr<GMPVideoEncodedFrame> aInputFrame,
     47                  bool aMissingFrames,
     48                  const nsTArray<uint8_t>& aCodecSpecificInfo,
     49                  int64_t aRenderTimeMs = -1) override;
     50  nsresult Reset() override;
     51  nsresult Drain() override;
     52  uint32_t GetPluginId() const override { return mPluginId; }
     53  GMPPluginType GetPluginType() const override { return mPluginType; }
     54  nsCString GetDisplayName() const override;
     55 
     56  // GMPSharedMemManager
     57  bool MgrAllocShmem(size_t aSize, Shmem* aMem) override {
     58    return AllocShmem(aSize, aMem);
     59  }
     60 
     61  void MgrDeallocShmem(Shmem& aMem) override { DeallocShmem(aMem); }
     62 
     63 protected:
     64  bool MgrIsOnOwningThread() const override;
     65 
     66 private:
     67  ~GMPVideoDecoderParent();
     68 
     69  // PGMPVideoDecoderParent
     70  void ActorDestroy(ActorDestroyReason aWhy) override;
     71  mozilla::ipc::IPCResult RecvReturnShmem(ipc::Shmem&& aInputShmem) override;
     72  mozilla::ipc::IPCResult RecvDecodedShmem(
     73      const GMPVideoi420FrameData& aDecodedFrame,
     74      ipc::Shmem&& aDecodedShmem) override;
     75  mozilla::ipc::IPCResult RecvDecodedData(
     76      const GMPVideoi420FrameData& aDecodedFrame,
     77      nsTArray<uint8_t>&& aDecodedArray) override;
     78  mozilla::ipc::IPCResult RecvReceivedDecodedReferenceFrame(
     79      const uint64_t& aPictureId) override;
     80  mozilla::ipc::IPCResult RecvReceivedDecodedFrame(
     81      const uint64_t& aPictureId) override;
     82  mozilla::ipc::IPCResult RecvInputDataExhausted() override;
     83  mozilla::ipc::IPCResult RecvDrainComplete() override;
     84  mozilla::ipc::IPCResult RecvResetComplete() override;
     85  mozilla::ipc::IPCResult RecvError(const GMPErr& aError) override;
     86  mozilla::ipc::IPCResult RecvShutdown() override;
     87 
     88  bool HandleDecoded(const GMPVideoi420FrameData& aDecodedFrame,
     89                     size_t aDecodedSize);
     90 
     91  void UnblockResetAndDrain();
     92  void CancelResetCompleteTimeout();
     93 
     94  size_t mDecodedShmemSize = 0;
     95  bool mIsOpen;
     96  bool mShuttingDown;
     97  bool mActorDestroyed;
     98  bool mIsAwaitingResetComplete;
     99  bool mIsAwaitingDrainComplete;
    100  RefPtr<GMPContentParent> mPlugin;
    101  RefPtr<GMPVideoDecoderCallbackProxy> mCallback;
    102  GMPVideoHostImpl mVideoHost;
    103  const uint32_t mPluginId;
    104  GMPPluginType mPluginType = GMPPluginType::Unknown;
    105  int32_t mFrameCount;
    106  RefPtr<SimpleTimer> mResetCompleteTimeout;
    107 };
    108 
    109 }  // namespace mozilla::gmp
    110 
    111 #endif  // GMPVideoDecoderParent_h_