GMPVideoDecoderChild.h (2617B)
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 GMPVideoDecoderChild_h_ 7 #define GMPVideoDecoderChild_h_ 8 9 #include "GMPSharedMemManager.h" 10 #include "GMPVideoHost.h" 11 #include "gmp-video-decode.h" 12 #include "mozilla/gmp/GMPTypes.h" 13 #include "mozilla/gmp/PGMPVideoDecoderChild.h" 14 #include "nsString.h" 15 16 namespace mozilla::gmp { 17 18 class GMPContentChild; 19 20 class GMPVideoDecoderChild final : public PGMPVideoDecoderChild, 21 public GMPVideoDecoderCallback, 22 public GMPSharedMemManager { 23 friend class PGMPVideoDecoderChild; 24 25 public: 26 // Mark AddRef and Release as `final`, as they overload pure virtual 27 // implementations in PGMPVideoDecoderChild. 28 NS_INLINE_DECL_THREADSAFE_REFCOUNTING(GMPVideoDecoderChild, final); 29 30 explicit GMPVideoDecoderChild(GMPContentChild* aPlugin); 31 32 void Init(GMPVideoDecoder* aDecoder); 33 GMPVideoHostImpl& Host(); 34 35 // GMPVideoDecoderCallback 36 void Decoded(GMPVideoi420Frame* decodedFrame) override; 37 void ReceivedDecodedReferenceFrame(const uint64_t pictureId) override; 38 void ReceivedDecodedFrame(const uint64_t pictureId) override; 39 void InputDataExhausted() override; 40 void DrainComplete() override; 41 void ResetComplete() override; 42 void Error(GMPErr aError) override; 43 44 // GMPSharedMemManager 45 bool MgrIsOnOwningThread() const override; 46 void MgrDeallocShmem(Shmem& aMem) override { DeallocShmem(aMem); } 47 48 private: 49 virtual ~GMPVideoDecoderChild(); 50 51 // PGMPVideoDecoderChild 52 mozilla::ipc::IPCResult RecvInitDecode(const GMPVideoCodec& aCodecSettings, 53 nsTArray<uint8_t>&& aCodecSpecific, 54 const int32_t& aCoreCount); 55 mozilla::ipc::IPCResult RecvGiveShmem(ipc::Shmem&& aOutputShmem); 56 mozilla::ipc::IPCResult RecvDecode( 57 const GMPVideoEncodedFrameData& aInputFrame, ipc::Shmem&& aInputShmem, 58 const bool& aMissingFrames, nsTArray<uint8_t>&& aCodecSpecificInfo, 59 const int64_t& aRenderTimeMs); 60 mozilla::ipc::IPCResult RecvReset(); 61 mozilla::ipc::IPCResult RecvDrain(); 62 void ActorDestroy(ActorDestroyReason why) override; 63 64 GMPContentChild* mPlugin; 65 GMPVideoDecoder* mVideoDecoder; 66 GMPVideoHostImpl mVideoHost; 67 bool mOutstandingDrain = false; 68 bool mOutstandingReset = false; 69 }; 70 71 } // namespace mozilla::gmp 72 73 #endif // GMPVideoDecoderChild_h_