blob: e9c41be1f03767a69a0a6d84c7bb59ec95f8984e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim:set ts=2 sw=2 sts=2 et cindent: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "GMPDecoderModule.h"
#ifdef MOZ_AV1
# include "AOMDecoder.h"
#endif
#include "DecoderDoctorDiagnostics.h"
#include "GMPService.h"
#include "GMPUtils.h"
#include "GMPVideoDecoder.h"
#include "MP4Decoder.h"
#include "MediaDataDecoderProxy.h"
#include "VPXDecoder.h"
#include "VideoUtils.h"
#include "gmp-video-decode.h"
#include "mozilla/StaticMutex.h"
#include "nsServiceManagerUtils.h"
#ifdef XP_WIN
# include "WMFDecoderModule.h"
#endif
namespace mozilla {
static already_AddRefed<MediaDataDecoderProxy> CreateDecoderWrapper(
GMPVideoDecoderParams&& aParams) {
RefPtr<gmp::GeckoMediaPluginService> s(
gmp::GeckoMediaPluginService::GetGeckoMediaPluginService());
if (!s) {
return nullptr;
}
nsCOMPtr<nsISerialEventTarget> thread(s->GetGMPThread());
if (!thread) {
return nullptr;
}
RefPtr<MediaDataDecoderProxy> decoder(new MediaDataDecoderProxy(
do_AddRef(new GMPVideoDecoder(std::move(aParams))), thread.forget()));
return decoder.forget();
}
already_AddRefed<MediaDataDecoder> GMPDecoderModule::CreateVideoDecoder(
const CreateDecoderParams& aParams) {
if (!MP4Decoder::IsH264(aParams.mConfig.mMimeType) &&
#ifdef MOZ_AV1
!AOMDecoder::IsAV1(aParams.mConfig.mMimeType) &&
#endif
!VPXDecoder::IsVP8(aParams.mConfig.mMimeType) &&
!VPXDecoder::IsVP9(aParams.mConfig.mMimeType)) {
return nullptr;
}
return CreateDecoderWrapper(GMPVideoDecoderParams(aParams));
}
already_AddRefed<MediaDataDecoder> GMPDecoderModule::CreateAudioDecoder(
const CreateDecoderParams& aParams) {
return nullptr;
}
/* static */
media::DecodeSupportSet GMPDecoderModule::SupportsMimeType(
const nsACString& aMimeType, const nsACString& aApi,
const Maybe<nsCString>& aKeySystem) {
AutoTArray<nsCString, 2> tags;
if (MP4Decoder::IsH264(aMimeType)) {
tags.AppendElement("h264"_ns);
#ifdef MOZ_AV1
} else if (AOMDecoder::IsAV1(aMimeType)) {
tags.AppendElement("av1"_ns);
#endif
} else if (VPXDecoder::IsVP9(aMimeType)) {
tags.AppendElement("vp9"_ns);
} else if (VPXDecoder::IsVP8(aMimeType)) {
tags.AppendElement("vp8"_ns);
} else {
return media::DecodeSupportSet{};
}
// Optional tag for EME GMP plugins.
if (aKeySystem) {
tags.AppendElement(*aKeySystem);
}
// GMP plugins are always software based.
return HaveGMPFor(aApi, tags) ? media::DecodeSupport::SoftwareDecode
: media::DecodeSupportSet{};
}
media::DecodeSupportSet GMPDecoderModule::SupportsMimeType(
const nsACString& aMimeType, DecoderDoctorDiagnostics* aDiagnostics) const {
return SupportsMimeType(aMimeType, "decode-video"_ns, Nothing());
}
/* static */
already_AddRefed<PlatformDecoderModule> GMPDecoderModule::Create() {
return MakeAndAddRef<GMPDecoderModule>();
}
} // namespace mozilla
|