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