-
Notifications
You must be signed in to change notification settings - Fork 54
/
GMPDecoderModule.cpp
92 lines (76 loc) · 2.66 KB
/
GMPDecoderModule.cpp
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
/* -*- 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 "DecoderDoctorDiagnostics.h"
#include "GMPDecoderModule.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 {
GMPDecoderModule::GMPDecoderModule() = default;
GMPDecoderModule::~GMPDecoderModule() = default;
static already_AddRefed<MediaDataDecoderProxy> CreateDecoderWrapper() {
RefPtr<gmp::GeckoMediaPluginService> s(
gmp::GeckoMediaPluginService::GetGeckoMediaPluginService());
if (!s) {
return nullptr;
}
RefPtr<AbstractThread> thread(s->GetAbstractGMPThread());
if (!thread) {
return nullptr;
}
RefPtr<MediaDataDecoderProxy> decoder(
new MediaDataDecoderProxy(thread.forget()));
return decoder.forget();
}
already_AddRefed<MediaDataDecoder> GMPDecoderModule::CreateVideoDecoder(
const CreateDecoderParams& aParams) {
if (!MP4Decoder::IsH264(aParams.mConfig.mMimeType) &&
!VPXDecoder::IsVP8(aParams.mConfig.mMimeType) &&
!VPXDecoder::IsVP9(aParams.mConfig.mMimeType)) {
return nullptr;
}
RefPtr<MediaDataDecoderProxy> wrapper = CreateDecoderWrapper();
auto params = GMPVideoDecoderParams(aParams);
wrapper->SetProxyTarget(new GMPVideoDecoder(params));
return wrapper.forget();
}
already_AddRefed<MediaDataDecoder> GMPDecoderModule::CreateAudioDecoder(
const CreateDecoderParams& aParams) {
return nullptr;
}
/* static */
bool GMPDecoderModule::SupportsMimeType(const nsACString& aMimeType,
const Maybe<nsCString>& aGMP) {
if (aGMP.isNothing()) {
return false;
}
nsCString api = NS_LITERAL_CSTRING(CHROMIUM_CDM_API);
if (MP4Decoder::IsH264(aMimeType)) {
return HaveGMPFor(api, {NS_LITERAL_CSTRING("h264"), aGMP.value()});
}
if (VPXDecoder::IsVP9(aMimeType)) {
return HaveGMPFor(api, {NS_LITERAL_CSTRING("vp9"), aGMP.value()});
}
if (VPXDecoder::IsVP8(aMimeType)) {
return HaveGMPFor(api, {NS_LITERAL_CSTRING("vp8"), aGMP.value()});
}
return false;
}
bool GMPDecoderModule::SupportsMimeType(
const nsACString& aMimeType, DecoderDoctorDiagnostics* aDiagnostics) const {
return false;
}
} // namespace mozilla