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 GMPVideoEncoderChild_h_
7 : #define GMPVideoEncoderChild_h_
8 :
9 : #include "nsString.h"
10 : #include "mozilla/gmp/PGMPVideoEncoderChild.h"
11 : #include "gmp-video-encode.h"
12 : #include "GMPSharedMemManager.h"
13 : #include "GMPVideoHost.h"
14 :
15 : namespace mozilla {
16 : namespace gmp {
17 :
18 : class GMPContentChild;
19 :
20 : class GMPVideoEncoderChild : public PGMPVideoEncoderChild,
21 : public GMPVideoEncoderCallback,
22 : public GMPSharedMemManager
23 : {
24 : public:
25 0 : NS_INLINE_DECL_THREADSAFE_REFCOUNTING(GMPVideoEncoderChild);
26 :
27 : explicit GMPVideoEncoderChild(GMPContentChild* aPlugin);
28 :
29 : void Init(GMPVideoEncoder* aEncoder);
30 : GMPVideoHostImpl& Host();
31 :
32 : // GMPVideoEncoderCallback
33 : void Encoded(GMPVideoEncodedFrame* aEncodedFrame,
34 : const uint8_t* aCodecSpecificInfo,
35 : uint32_t aCodecSpecificInfoLength) override;
36 : void Error(GMPErr aError) override;
37 :
38 : // GMPSharedMemManager
39 : bool Alloc(size_t aSize, Shmem::SharedMemory::SharedMemoryType aType,
40 : Shmem* aMem) override;
41 : void Dealloc(Shmem& aMem) override;
42 :
43 : private:
44 : virtual ~GMPVideoEncoderChild();
45 :
46 : // PGMPVideoEncoderChild
47 : mozilla::ipc::IPCResult RecvInitEncode(const GMPVideoCodec& aCodecSettings,
48 : InfallibleTArray<uint8_t>&& aCodecSpecific,
49 : const int32_t& aNumberOfCores,
50 : const uint32_t& aMaxPayloadSize) override;
51 : mozilla::ipc::IPCResult RecvEncode(const GMPVideoi420FrameData& aInputFrame,
52 : InfallibleTArray<uint8_t>&& aCodecSpecificInfo,
53 : InfallibleTArray<GMPVideoFrameType>&& aFrameTypes) override;
54 : mozilla::ipc::IPCResult RecvChildShmemForPool(Shmem&& aEncodedBuffer) override;
55 : mozilla::ipc::IPCResult RecvSetChannelParameters(const uint32_t& aPacketLoss,
56 : const uint32_t& aRTT) override;
57 : mozilla::ipc::IPCResult RecvSetRates(const uint32_t& aNewBitRate,
58 : const uint32_t& aFrameRate) override;
59 : mozilla::ipc::IPCResult RecvSetPeriodicKeyFrames(const bool& aEnable) override;
60 : mozilla::ipc::IPCResult RecvEncodingComplete() override;
61 :
62 : GMPContentChild* mPlugin;
63 : GMPVideoEncoder* mVideoEncoder;
64 : GMPVideoHostImpl mVideoHost;
65 :
66 : // Non-zero when a GMP is blocked spinning the IPC message loop while
67 : // waiting on an NeedShmem to complete.
68 : int mNeedShmemIntrCount;
69 : bool mPendingEncodeComplete;
70 : };
71 :
72 : } // namespace gmp
73 : } // namespace mozilla
74 :
75 : #endif // GMPVideoEncoderChild_h_
|