1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ 2 /* vim: set ts=8 sts=2 et sw=2 tw=99: */ 3 /* This Source Code Form is subject to the terms of the Mozilla Public 4 * License, v. 2.0. If a copy of the MPL was not distributed with this 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 6 #ifndef include_dom_ipc_VideoDecoderParent_h 7 #define include_dom_ipc_VideoDecoderParent_h 8 9 #include "mozilla/RefPtr.h" 10 #include "mozilla/dom/PVideoDecoderParent.h" 11 #include "mozilla/layers/TextureForwarder.h" 12 #include "VideoDecoderManagerParent.h" 13 #include "MediaData.h" 14 #include "ImageContainer.h" 15 16 namespace mozilla { 17 namespace dom { 18 19 class KnowsCompositorVideo; 20 21 class VideoDecoderParent final : public PVideoDecoderParent, 22 public MediaDataDecoderCallback 23 { 24 public: 25 // We refcount this class since the task queue can have runnables 26 // that reference us. 27 NS_INLINE_DECL_THREADSAFE_REFCOUNTING(VideoDecoderParent) 28 29 VideoDecoderParent(VideoDecoderManagerParent* aParent, 30 TaskQueue* aManagerTaskQueue, 31 TaskQueue* aDecodeTaskQueue); 32 33 void Destroy(); 34 35 // PVideoDecoderParent 36 bool RecvInit(const VideoInfo& aVideoInfo, const layers::TextureFactoryIdentifier& aIdentifier) override; 37 bool RecvInput(const MediaRawDataIPDL& aData) override; 38 bool RecvFlush() override; 39 bool RecvDrain() override; 40 bool RecvShutdown() override; 41 bool RecvSetSeekThreshold(const int64_t& aTime) override; 42 43 void ActorDestroy(ActorDestroyReason aWhy) override; 44 45 // MediaDataDecoderCallback 46 void Output(MediaData* aData) override; 47 void Error(const MediaResult& aError) override; 48 void InputExhausted() override; 49 void DrainComplete() override; 50 bool OnReaderTaskQueue() override; 51 52 private: 53 ~VideoDecoderParent(); 54 55 RefPtr<VideoDecoderManagerParent> mParent; 56 RefPtr<VideoDecoderParent> mIPDLSelfRef; 57 RefPtr<TaskQueue> mManagerTaskQueue; 58 RefPtr<TaskQueue> mDecodeTaskQueue; 59 RefPtr<MediaDataDecoder> mDecoder; 60 RefPtr<KnowsCompositorVideo> mKnowsCompositor; 61 62 // Can only be accessed from the manager thread 63 bool mDestroyed; 64 }; 65 66 } // namespace dom 67 } // namespace mozilla 68 69 #endif // include_dom_ipc_VideoDecoderParent_h 70