/src/mozilla-central/dom/media/ipc/RemoteVideoDecoder.h
Line | Count | Source (jump to first uncovered line) |
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_RemoteVideoDecoder_h |
7 | | #define include_dom_ipc_RemoteVideoDecoder_h |
8 | | |
9 | | #include "mozilla/RefPtr.h" |
10 | | #include "mozilla/DebugOnly.h" |
11 | | #include "MediaData.h" |
12 | | #include "PlatformDecoderModule.h" |
13 | | |
14 | | namespace mozilla { |
15 | | |
16 | | namespace dom { |
17 | | class RemoteVideoDecoder; |
18 | | } |
19 | | DDLoggedTypeCustomNameAndBase(dom::RemoteVideoDecoder, |
20 | | RemoteVideoDecoder, |
21 | | MediaDataDecoder); |
22 | | |
23 | | namespace dom { |
24 | | |
25 | | class VideoDecoderChild; |
26 | | class RemoteDecoderModule; |
27 | | |
28 | | // A MediaDataDecoder implementation that proxies through IPDL |
29 | | // to a 'real' decoder in the GPU process. |
30 | | // All requests get forwarded to a VideoDecoderChild instance that |
31 | | // operates solely on the VideoDecoderManagerChild thread. |
32 | | class RemoteVideoDecoder |
33 | | : public MediaDataDecoder |
34 | | , public DecoderDoctorLifeLogger<RemoteVideoDecoder> |
35 | | { |
36 | | public: |
37 | | friend class RemoteDecoderModule; |
38 | | |
39 | | // MediaDataDecoder |
40 | | RefPtr<InitPromise> Init() override; |
41 | | RefPtr<DecodePromise> Decode(MediaRawData* aSample) override; |
42 | | RefPtr<DecodePromise> Drain() override; |
43 | | RefPtr<FlushPromise> Flush() override; |
44 | | RefPtr<ShutdownPromise> Shutdown() override; |
45 | | bool IsHardwareAccelerated(nsACString& aFailureReason) const override; |
46 | | void SetSeekThreshold(const media::TimeUnit& aTime) override; |
47 | | nsCString GetDescriptionName() const override; |
48 | | ConversionRequired NeedsConversion() const override; |
49 | | |
50 | | private: |
51 | | RemoteVideoDecoder(); |
52 | | ~RemoteVideoDecoder(); |
53 | | |
54 | | // Only ever written to from the reader task queue (during the constructor and |
55 | | // destructor when we can guarantee no other threads are accessing it). Only |
56 | | // read from the manager thread. |
57 | | RefPtr<VideoDecoderChild> mActor; |
58 | | // Only ever written/modified during decoder initialisation. |
59 | | // As such can be accessed from any threads after that. |
60 | | nsCString mDescription; |
61 | | bool mIsHardwareAccelerated; |
62 | | nsCString mHardwareAcceleratedReason; |
63 | | MediaDataDecoder::ConversionRequired mConversion; |
64 | | }; |
65 | | |
66 | | // A PDM implementation that creates RemoteVideoDecoders. |
67 | | // We currently require a 'wrapped' PDM in order to be able to answer SupportsMimeType |
68 | | // and DecoderNeedsConversion. Ideally we'd check these over IPDL using the manager |
69 | | // protocol |
70 | | class RemoteDecoderModule : public PlatformDecoderModule |
71 | | { |
72 | | public: |
73 | | explicit RemoteDecoderModule(PlatformDecoderModule* aWrapped) |
74 | | : mWrapped(aWrapped) |
75 | 0 | {} |
76 | | |
77 | | nsresult Startup() override; |
78 | | |
79 | | bool SupportsMimeType(const nsACString& aMimeType, |
80 | | DecoderDoctorDiagnostics* aDiagnostics) const override; |
81 | | bool Supports(const TrackInfo& aTrackInfo, |
82 | | DecoderDoctorDiagnostics* aDiagnostics) const override; |
83 | | |
84 | | already_AddRefed<MediaDataDecoder> CreateVideoDecoder( |
85 | | const CreateDecoderParams& aParams) override; |
86 | | |
87 | | already_AddRefed<MediaDataDecoder> CreateAudioDecoder( |
88 | | const CreateDecoderParams& aParams) override |
89 | 0 | { |
90 | 0 | return nullptr; |
91 | 0 | } |
92 | | |
93 | | private: |
94 | | RefPtr<PlatformDecoderModule> mWrapped; |
95 | | }; |
96 | | |
97 | | } // namespace dom |
98 | | } // namespace mozilla |
99 | | |
100 | | #endif // include_dom_ipc_RemoteVideoDecoder_h |