Line data Source code
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 "mozilla/RefPtr.h"
10 : #include "gmp-video-decode.h"
11 : #include "mozilla/gmp/PGMPVideoDecoderParent.h"
12 : #include "GMPMessageUtils.h"
13 : #include "GMPSharedMemManager.h"
14 : #include "GMPUtils.h"
15 : #include "GMPVideoHost.h"
16 : #include "GMPVideoDecoderProxy.h"
17 : #include "VideoUtils.h"
18 : #include "GMPCrashHelperHolder.h"
19 :
20 : namespace mozilla {
21 : namespace gmp {
22 :
23 : class GMPContentParent;
24 :
25 : class GMPVideoDecoderParent final : public PGMPVideoDecoderParent
26 : , public GMPVideoDecoderProxy
27 : , public GMPSharedMemManager
28 : , public GMPCrashHelperHolder
29 : {
30 : public:
31 0 : NS_INLINE_DECL_REFCOUNTING(GMPVideoDecoderParent)
32 :
33 : explicit GMPVideoDecoderParent(GMPContentParent *aPlugin);
34 :
35 : GMPVideoHostImpl& Host();
36 : nsresult Shutdown();
37 :
38 : // GMPVideoDecoder
39 : void Close() override;
40 : nsresult InitDecode(const GMPVideoCodec& aCodecSettings,
41 : const nsTArray<uint8_t>& aCodecSpecific,
42 : GMPVideoDecoderCallbackProxy* aCallback,
43 : int32_t aCoreCount) override;
44 : nsresult Decode(GMPUniquePtr<GMPVideoEncodedFrame> aInputFrame,
45 : bool aMissingFrames,
46 : const nsTArray<uint8_t>& aCodecSpecificInfo,
47 : int64_t aRenderTimeMs = -1) override;
48 : nsresult Reset() override;
49 : nsresult Drain() override;
50 0 : uint32_t GetPluginId() const override { return mPluginId; }
51 : const nsCString& GetDisplayName() const override;
52 :
53 : // GMPSharedMemManager
54 0 : bool Alloc(size_t aSize, Shmem::SharedMemory::SharedMemoryType aType, Shmem* aMem) override
55 : {
56 : #ifdef GMP_SAFE_SHMEM
57 0 : return AllocShmem(aSize, aType, aMem);
58 : #else
59 : return AllocUnsafeShmem(aSize, aType, aMem);
60 : #endif
61 : }
62 0 : void Dealloc(Shmem& aMem) override
63 : {
64 0 : DeallocShmem(aMem);
65 0 : }
66 :
67 : private:
68 : ~GMPVideoDecoderParent();
69 :
70 : // PGMPVideoDecoderParent
71 : void ActorDestroy(ActorDestroyReason aWhy) override;
72 : mozilla::ipc::IPCResult RecvDecoded(const GMPVideoi420FrameData& aDecodedFrame) override;
73 : mozilla::ipc::IPCResult RecvReceivedDecodedReferenceFrame(const uint64_t& aPictureId) override;
74 : mozilla::ipc::IPCResult RecvReceivedDecodedFrame(const uint64_t& aPictureId) override;
75 : mozilla::ipc::IPCResult RecvInputDataExhausted() override;
76 : mozilla::ipc::IPCResult RecvDrainComplete() override;
77 : mozilla::ipc::IPCResult RecvResetComplete() override;
78 : mozilla::ipc::IPCResult RecvError(const GMPErr& aError) override;
79 : mozilla::ipc::IPCResult RecvShutdown() override;
80 : mozilla::ipc::IPCResult RecvParentShmemForPool(Shmem&& aEncodedBuffer) override;
81 : mozilla::ipc::IPCResult AnswerNeedShmem(const uint32_t& aFrameBufferSize,
82 : Shmem* aMem) override;
83 : mozilla::ipc::IPCResult Recv__delete__() override;
84 :
85 : void UnblockResetAndDrain();
86 : void CancelResetCompleteTimeout();
87 :
88 : bool mIsOpen;
89 : bool mShuttingDown;
90 : bool mActorDestroyed;
91 : bool mIsAwaitingResetComplete;
92 : bool mIsAwaitingDrainComplete;
93 : RefPtr<GMPContentParent> mPlugin;
94 : GMPVideoDecoderCallbackProxy* mCallback;
95 : GMPVideoHostImpl mVideoHost;
96 : const uint32_t mPluginId;
97 : int32_t mFrameCount;
98 : RefPtr<SimpleTimer> mResetCompleteTimeout;
99 : };
100 :
101 : } // namespace gmp
102 : } // namespace mozilla
103 :
104 : #endif // GMPVideoDecoderParent_h_
|