Line data Source code
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_VideoDecoderChild_h
7 : #define include_dom_ipc_VideoDecoderChild_h
8 :
9 : #include "PlatformDecoderModule.h"
10 : #include "mozilla/Atomics.h"
11 : #include "mozilla/dom/PVideoDecoderChild.h"
12 :
13 : namespace mozilla {
14 : namespace dom {
15 :
16 : class RemoteVideoDecoder;
17 : class RemoteDecoderModule;
18 : class VideoDecoderManagerChild;
19 :
20 : class VideoDecoderChild final : public PVideoDecoderChild
21 : {
22 : public:
23 : explicit VideoDecoderChild();
24 :
25 0 : NS_INLINE_DECL_THREADSAFE_REFCOUNTING(VideoDecoderChild)
26 :
27 : // PVideoDecoderChild
28 : mozilla::ipc::IPCResult RecvOutput(const VideoDataIPDL& aData) override;
29 : mozilla::ipc::IPCResult RecvInputExhausted() override;
30 : mozilla::ipc::IPCResult RecvDrainComplete() override;
31 : mozilla::ipc::IPCResult RecvError(const nsresult& aError) override;
32 : mozilla::ipc::IPCResult RecvInitComplete(const bool& aHardware,
33 : const nsCString& aHardwareReason,
34 : const uint32_t& aConversion) override;
35 : mozilla::ipc::IPCResult RecvInitFailed(const nsresult& aReason) override;
36 : mozilla::ipc::IPCResult RecvFlushComplete() override;
37 :
38 : void ActorDestroy(ActorDestroyReason aWhy) override;
39 :
40 : RefPtr<MediaDataDecoder::InitPromise> Init();
41 : RefPtr<MediaDataDecoder::DecodePromise> Decode(MediaRawData* aSample);
42 : RefPtr<MediaDataDecoder::DecodePromise> Drain();
43 : RefPtr<MediaDataDecoder::FlushPromise> Flush();
44 : void Shutdown();
45 : bool IsHardwareAccelerated(nsACString& aFailureReason) const;
46 : void SetSeekThreshold(const media::TimeUnit& aTime);
47 : MediaDataDecoder::ConversionRequired NeedsConversion() const;
48 :
49 : MOZ_IS_CLASS_INIT
50 : bool InitIPDL(const VideoInfo& aVideoInfo,
51 : const layers::TextureFactoryIdentifier& aIdentifier);
52 : void DestroyIPDL();
53 :
54 : // Called from IPDL when our actor has been destroyed
55 : void IPDLActorDestroyed();
56 :
57 : VideoDecoderManagerChild* GetManager();
58 :
59 : private:
60 : ~VideoDecoderChild();
61 :
62 : void AssertOnManagerThread() const;
63 :
64 : RefPtr<VideoDecoderChild> mIPDLSelfRef;
65 : RefPtr<nsIThread> mThread;
66 :
67 : MozPromiseHolder<MediaDataDecoder::InitPromise> mInitPromise;
68 : MozPromiseHolder<MediaDataDecoder::DecodePromise> mDecodePromise;
69 : MozPromiseHolder<MediaDataDecoder::DecodePromise> mDrainPromise;
70 : MozPromiseHolder<MediaDataDecoder::FlushPromise> mFlushPromise;
71 :
72 : nsCString mHardwareAcceleratedReason;
73 : bool mCanSend;
74 : bool mInitialized;
75 : Atomic<bool> mIsHardwareAccelerated;
76 : Atomic<MediaDataDecoder::ConversionRequired> mConversion;
77 :
78 : // Set to true if the actor got destroyed and we haven't yet notified the
79 : // caller.
80 : bool mNeedNewDecoder;
81 : MediaDataDecoder::DecodedData mDecodedData;
82 : };
83 :
84 : } // namespace dom
85 : } // namespace mozilla
86 :
87 : #endif // include_dom_ipc_VideoDecoderChild_h
|