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