GMPVideoHost.h (2017B)
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 GMPVideoHost_h_ 7 #define GMPVideoHost_h_ 8 9 #include "gmp-video-frame.h" 10 #include "gmp-video-host.h" 11 #include "gmp-video-plane.h" 12 #include "nsTArray.h" 13 14 namespace mozilla::gmp { 15 16 class GMPSharedMemManager; 17 class GMPVideoEncodedFrameImpl; 18 class GMPVideoi420FrameImpl; 19 20 class GMPVideoHostImpl : public GMPVideoHost { 21 public: 22 explicit GMPVideoHostImpl(GMPSharedMemManager* aSharedMemMgr); 23 virtual ~GMPVideoHostImpl(); 24 25 // Used for shared memory allocation and deallocation. 26 GMPSharedMemManager* SharedMemMgr(); 27 void DoneWithAPI(); 28 void ActorDestroyed(); 29 void EncodedFrameCreated(GMPVideoEncodedFrameImpl* aEncodedFrame); 30 void EncodedFrameDestroyed(GMPVideoEncodedFrameImpl* aFrame); 31 void DecodedFrameCreated(GMPVideoi420FrameImpl* aDecodedFrame); 32 void DecodedFrameDestroyed(GMPVideoi420FrameImpl* aFrame); 33 34 bool IsEncodedFramesEmpty() const { return mEncodedFrames.IsEmpty(); } 35 36 bool IsDecodedFramesEmpty() const { return mDecodedFrames.IsEmpty(); } 37 38 // GMPVideoHost 39 GMPErr CreateFrame(GMPVideoFrameFormat aFormat, 40 GMPVideoFrame** aFrame) override; 41 GMPErr CreatePlane(GMPPlane** aPlane) override; 42 43 private: 44 // All shared memory allocations have to be made by an IPDL actor. 45 // This is a reference to the owning actor. If this reference is 46 // null then the actor has died and all allocations must fail. 47 GMPSharedMemManager* mSharedMemMgr; 48 49 // We track all of these things because they need to handle further 50 // allocations through us and we need to notify them when they 51 // can't use us any more. 52 nsTArray<GMPVideoEncodedFrameImpl*> mEncodedFrames; 53 nsTArray<GMPVideoi420FrameImpl*> mDecodedFrames; 54 }; 55 56 } // namespace mozilla::gmp 57 58 #endif // GMPVideoHost_h_