/src/mozilla-central/dom/media/platforms/ffmpeg/FFmpegDecoderModule.h
Line | Count | Source (jump to first uncovered line) |
1 | | /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
2 | | /* vim:set ts=2 sw=2 sts=2 et cindent: */ |
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 | | |
7 | | #ifndef __FFmpegDecoderModule_h__ |
8 | | #define __FFmpegDecoderModule_h__ |
9 | | |
10 | | #include "PlatformDecoderModule.h" |
11 | | #include "FFmpegLibWrapper.h" |
12 | | #include "FFmpegAudioDecoder.h" |
13 | | #include "FFmpegVideoDecoder.h" |
14 | | #include "mozilla/StaticPrefs.h" |
15 | | |
16 | | namespace mozilla { |
17 | | |
18 | | template <int V> |
19 | | class FFmpegDecoderModule : public PlatformDecoderModule |
20 | | { |
21 | | public: |
22 | | static already_AddRefed<PlatformDecoderModule> |
23 | | Create(FFmpegLibWrapper* aLib) |
24 | 0 | { |
25 | 0 | RefPtr<PlatformDecoderModule> pdm = new FFmpegDecoderModule(aLib); |
26 | 0 |
|
27 | 0 | return pdm.forget(); |
28 | 0 | } Unexecuted instantiation: mozilla::FFmpegDecoderModule<46465650>::Create(mozilla::FFmpegLibWrapper*) Unexecuted instantiation: mozilla::FFmpegDecoderModule<53>::Create(mozilla::FFmpegLibWrapper*) Unexecuted instantiation: mozilla::FFmpegDecoderModule<54>::Create(mozilla::FFmpegLibWrapper*) Unexecuted instantiation: mozilla::FFmpegDecoderModule<55>::Create(mozilla::FFmpegLibWrapper*) Unexecuted instantiation: mozilla::FFmpegDecoderModule<57>::Create(mozilla::FFmpegLibWrapper*) Unexecuted instantiation: mozilla::FFmpegDecoderModule<58>::Create(mozilla::FFmpegLibWrapper*) |
29 | | |
30 | 0 | explicit FFmpegDecoderModule(FFmpegLibWrapper* aLib) : mLib(aLib) { } Unexecuted instantiation: mozilla::FFmpegDecoderModule<46465650>::FFmpegDecoderModule(mozilla::FFmpegLibWrapper*) Unexecuted instantiation: mozilla::FFmpegDecoderModule<53>::FFmpegDecoderModule(mozilla::FFmpegLibWrapper*) Unexecuted instantiation: mozilla::FFmpegDecoderModule<54>::FFmpegDecoderModule(mozilla::FFmpegLibWrapper*) Unexecuted instantiation: mozilla::FFmpegDecoderModule<55>::FFmpegDecoderModule(mozilla::FFmpegLibWrapper*) Unexecuted instantiation: mozilla::FFmpegDecoderModule<57>::FFmpegDecoderModule(mozilla::FFmpegLibWrapper*) Unexecuted instantiation: mozilla::FFmpegDecoderModule<58>::FFmpegDecoderModule(mozilla::FFmpegLibWrapper*) |
31 | 0 | virtual ~FFmpegDecoderModule() { } Unexecuted instantiation: mozilla::FFmpegDecoderModule<46465650>::~FFmpegDecoderModule() Unexecuted instantiation: mozilla::FFmpegDecoderModule<53>::~FFmpegDecoderModule() Unexecuted instantiation: mozilla::FFmpegDecoderModule<54>::~FFmpegDecoderModule() Unexecuted instantiation: mozilla::FFmpegDecoderModule<55>::~FFmpegDecoderModule() Unexecuted instantiation: mozilla::FFmpegDecoderModule<57>::~FFmpegDecoderModule() Unexecuted instantiation: mozilla::FFmpegDecoderModule<58>::~FFmpegDecoderModule() |
32 | | |
33 | | already_AddRefed<MediaDataDecoder> |
34 | | CreateVideoDecoder(const CreateDecoderParams& aParams) override |
35 | 0 | { |
36 | 0 | // Temporary - forces use of VPXDecoder when alpha is present. |
37 | 0 | // Bug 1263836 will handle alpha scenario once implemented. It will shift |
38 | 0 | // the check for alpha to PDMFactory but not itself remove the need for a |
39 | 0 | // check. |
40 | 0 | if (aParams.VideoConfig().HasAlpha()) { |
41 | 0 | return nullptr; |
42 | 0 | } |
43 | 0 | if (aParams.mOptions.contains( |
44 | 0 | CreateDecoderParams::Option::LowLatency) && |
45 | 0 | !StaticPrefs::MediaFfmpegLowLatencyEnabled()) { |
46 | 0 | return nullptr; |
47 | 0 | } |
48 | 0 | RefPtr<MediaDataDecoder> decoder = new FFmpegVideoDecoder<V>( |
49 | 0 | mLib, |
50 | 0 | aParams.mTaskQueue, |
51 | 0 | aParams.VideoConfig(), |
52 | 0 | aParams.mKnowsCompositor, |
53 | 0 | aParams.mImageContainer, |
54 | 0 | aParams.mOptions.contains(CreateDecoderParams::Option::LowLatency)); |
55 | 0 | return decoder.forget(); |
56 | 0 | } Unexecuted instantiation: mozilla::FFmpegDecoderModule<46465650>::CreateVideoDecoder(mozilla::CreateDecoderParams const&) Unexecuted instantiation: mozilla::FFmpegDecoderModule<53>::CreateVideoDecoder(mozilla::CreateDecoderParams const&) Unexecuted instantiation: mozilla::FFmpegDecoderModule<54>::CreateVideoDecoder(mozilla::CreateDecoderParams const&) Unexecuted instantiation: mozilla::FFmpegDecoderModule<55>::CreateVideoDecoder(mozilla::CreateDecoderParams const&) Unexecuted instantiation: mozilla::FFmpegDecoderModule<57>::CreateVideoDecoder(mozilla::CreateDecoderParams const&) Unexecuted instantiation: mozilla::FFmpegDecoderModule<58>::CreateVideoDecoder(mozilla::CreateDecoderParams const&) |
57 | | |
58 | | already_AddRefed<MediaDataDecoder> |
59 | | CreateAudioDecoder(const CreateDecoderParams& aParams) override |
60 | 0 | { |
61 | 0 | RefPtr<MediaDataDecoder> decoder = |
62 | 0 | new FFmpegAudioDecoder<V>(mLib, |
63 | 0 | aParams.mTaskQueue, |
64 | 0 | aParams.AudioConfig()); |
65 | 0 | return decoder.forget(); |
66 | 0 | } Unexecuted instantiation: mozilla::FFmpegDecoderModule<46465650>::CreateAudioDecoder(mozilla::CreateDecoderParams const&) Unexecuted instantiation: mozilla::FFmpegDecoderModule<53>::CreateAudioDecoder(mozilla::CreateDecoderParams const&) Unexecuted instantiation: mozilla::FFmpegDecoderModule<54>::CreateAudioDecoder(mozilla::CreateDecoderParams const&) Unexecuted instantiation: mozilla::FFmpegDecoderModule<55>::CreateAudioDecoder(mozilla::CreateDecoderParams const&) Unexecuted instantiation: mozilla::FFmpegDecoderModule<57>::CreateAudioDecoder(mozilla::CreateDecoderParams const&) Unexecuted instantiation: mozilla::FFmpegDecoderModule<58>::CreateAudioDecoder(mozilla::CreateDecoderParams const&) |
67 | | |
68 | | bool SupportsMimeType(const nsACString& aMimeType, |
69 | | DecoderDoctorDiagnostics* aDiagnostics) const override |
70 | 0 | { |
71 | 0 | AVCodecID videoCodec = FFmpegVideoDecoder<V>::GetCodecId(aMimeType); |
72 | 0 | AVCodecID audioCodec = FFmpegAudioDecoder<V>::GetCodecId(aMimeType); |
73 | 0 | if (audioCodec == AV_CODEC_ID_NONE && videoCodec == AV_CODEC_ID_NONE) { |
74 | 0 | return false; |
75 | 0 | } |
76 | 0 | AVCodecID codec = audioCodec != AV_CODEC_ID_NONE ? audioCodec : videoCodec; |
77 | 0 | return !!FFmpegDataDecoder<V>::FindAVCodec(mLib, codec); |
78 | 0 | } Unexecuted instantiation: mozilla::FFmpegDecoderModule<46465650>::SupportsMimeType(nsTSubstring<char> const&, mozilla::DecoderDoctorDiagnostics*) const Unexecuted instantiation: mozilla::FFmpegDecoderModule<53>::SupportsMimeType(nsTSubstring<char> const&, mozilla::DecoderDoctorDiagnostics*) const Unexecuted instantiation: mozilla::FFmpegDecoderModule<54>::SupportsMimeType(nsTSubstring<char> const&, mozilla::DecoderDoctorDiagnostics*) const Unexecuted instantiation: mozilla::FFmpegDecoderModule<55>::SupportsMimeType(nsTSubstring<char> const&, mozilla::DecoderDoctorDiagnostics*) const Unexecuted instantiation: mozilla::FFmpegDecoderModule<57>::SupportsMimeType(nsTSubstring<char> const&, mozilla::DecoderDoctorDiagnostics*) const Unexecuted instantiation: mozilla::FFmpegDecoderModule<58>::SupportsMimeType(nsTSubstring<char> const&, mozilla::DecoderDoctorDiagnostics*) const |
79 | | |
80 | | protected: |
81 | | bool SupportsBitDepth(const uint8_t aBitDepth, |
82 | | DecoderDoctorDiagnostics* aDiagnostics) const override |
83 | 0 | { |
84 | 0 | // We don't support bitDepth > 8 when compositor backend is D3D11. |
85 | 0 | // But we don't have KnowsCompositor or any object |
86 | 0 | // that we can ask for the layersbackend type. |
87 | 0 | // We should remove this restriction until |
88 | 0 | // we solve the D3D11 compositor backend issue. |
89 | 0 | #if defined(XP_LINUX) || defined(XP_MACOSX) |
90 | 0 | return true; |
91 | 0 | #endif |
92 | 0 | return aBitDepth == 8; |
93 | 0 | } Unexecuted instantiation: mozilla::FFmpegDecoderModule<46465650>::SupportsBitDepth(unsigned char, mozilla::DecoderDoctorDiagnostics*) const Unexecuted instantiation: mozilla::FFmpegDecoderModule<53>::SupportsBitDepth(unsigned char, mozilla::DecoderDoctorDiagnostics*) const Unexecuted instantiation: mozilla::FFmpegDecoderModule<54>::SupportsBitDepth(unsigned char, mozilla::DecoderDoctorDiagnostics*) const Unexecuted instantiation: mozilla::FFmpegDecoderModule<55>::SupportsBitDepth(unsigned char, mozilla::DecoderDoctorDiagnostics*) const Unexecuted instantiation: mozilla::FFmpegDecoderModule<57>::SupportsBitDepth(unsigned char, mozilla::DecoderDoctorDiagnostics*) const Unexecuted instantiation: mozilla::FFmpegDecoderModule<58>::SupportsBitDepth(unsigned char, mozilla::DecoderDoctorDiagnostics*) const |
94 | | |
95 | | private: |
96 | | FFmpegLibWrapper* mLib; |
97 | | }; |
98 | | |
99 | | } // namespace mozilla |
100 | | |
101 | | #endif // __FFmpegDecoderModule_h__ |