--- a/dom/html/HTMLMediaElement.cpp
+++ b/dom/html/HTMLMediaElement.cpp
@@ -3660,17 +3660,19 @@ void HTMLMediaElement::UnbindFromTree(bo
}
/* static */
CanPlayStatus
HTMLMediaElement::GetCanPlay(const nsAString& aType,
DecoderDoctorDiagnostics* aDiagnostics)
{
MediaContentType contentType{aType};
- return DecoderTraits::CanHandleContentType(contentType, aDiagnostics);
+ return DecoderTraits::CanHandleContentType(contentType,
+ /* nsIDocument* */ nullptr,
+ aDiagnostics);
}
NS_IMETHODIMP
HTMLMediaElement::CanPlayType(const nsAString& aType, nsAString& aResult)
{
DecoderDoctorDiagnostics diagnostics;
CanPlayStatus canPlay = GetCanPlay(aType, &diagnostics);
diagnostics.StoreFormatDiagnostics(
--- a/dom/media/DecoderTraits.cpp
+++ b/dom/media/DecoderTraits.cpp
@@ -161,35 +161,38 @@ IsDirectShowSupportedType(const nsACStri
{
return DirectShowDecoder::GetSupportedCodecs(aType, nullptr);
}
#endif
#ifdef MOZ_FMP4
static bool
IsMP4SupportedType(const MediaContentType& aParsedType,
+ nsIDocument* aDoc,
DecoderDoctorDiagnostics* aDiagnostics)
{
- return MP4Decoder::CanHandleMediaType(aParsedType, aDiagnostics);
+ return MP4Decoder::CanHandleMediaType(aParsedType, aDoc, aDiagnostics);
}
static bool
IsMP4SupportedType(const nsACString& aType,
+ nsIDocument* aDoc,
DecoderDoctorDiagnostics* aDiagnostics)
{
MediaContentType contentType{aType};
- return IsMP4SupportedType(contentType, aDiagnostics);
+ return IsMP4SupportedType(contentType, aDoc, aDiagnostics);
}
#endif
/* static */ bool
DecoderTraits::IsMP4TypeAndEnabled(const nsACString& aType,
+ nsIDocument* aDoc,
DecoderDoctorDiagnostics* aDiagnostics)
{
#ifdef MOZ_FMP4
- return IsMP4SupportedType(aType, aDiagnostics);
+ return IsMP4SupportedType(aType, aDoc, aDiagnostics);
#else
return false;
#endif
}
static bool
IsMP3SupportedType(const nsACString& aType,
const nsAString& aCodecs = EmptyString())
@@ -216,16 +219,17 @@ IsFlacSupportedType(const nsACString& aT
const nsAString& aCodecs = EmptyString())
{
return FlacDecoder::CanHandleMediaType(aType, aCodecs);
}
static
CanPlayStatus
CanHandleCodecsType(const MediaContentType& aType,
+ nsIDocument* aDoc,
DecoderDoctorDiagnostics* aDiagnostics)
{
MOZ_ASSERT(aType.IsValid());
// We should have been given a codecs string, though it may be empty.
MOZ_ASSERT(aType.HaveCodecs());
char const* const* codecList = nullptr;
if (IsOggTypeAndEnabled(aType.GetMIMEType())) {
@@ -247,18 +251,20 @@ CanHandleCodecsType(const MediaContentTy
} else {
// We can only reach this position if a particular codec was requested,
// webm is supported and working: the codec must be invalid.
return CANPLAY_NO;
}
}
#endif
#ifdef MOZ_FMP4
- if (DecoderTraits::IsMP4TypeAndEnabled(aType.GetMIMEType(), aDiagnostics)) {
- if (IsMP4SupportedType(aType, aDiagnostics)) {
+ if (DecoderTraits::IsMP4TypeAndEnabled(aType.GetMIMEType(),
+ aDoc,
+ aDiagnostics)) {
+ if (IsMP4SupportedType(aType, aDoc, aDiagnostics)) {
return CANPLAY_YES;
} else {
// We can only reach this position if a particular codec was requested,
// fmp4 is supported and working: the codec must be invalid.
return CANPLAY_NO;
}
}
#endif
@@ -302,37 +308,38 @@ CanHandleCodecsType(const MediaContentTy
}
return CANPLAY_YES;
}
static
CanPlayStatus
CanHandleMediaType(const MediaContentType& aType,
+ nsIDocument* aDoc,
DecoderDoctorDiagnostics* aDiagnostics)
{
MOZ_ASSERT(NS_IsMainThread());
if (IsHttpLiveStreamingType(aType.GetMIMEType())) {
Telemetry::Accumulate(Telemetry::MEDIA_HLS_CANPLAY_REQUESTED, true);
}
if (aType.HaveCodecs()) {
- CanPlayStatus result = CanHandleCodecsType(aType, aDiagnostics);
+ CanPlayStatus result = CanHandleCodecsType(aType, aDoc, aDiagnostics);
if (result == CANPLAY_NO || result == CANPLAY_YES) {
return result;
}
}
if (IsOggTypeAndEnabled(aType.GetMIMEType())) {
return CANPLAY_MAYBE;
}
if (IsWaveType(aType.GetMIMEType())) {
return CANPLAY_MAYBE;
}
- if (DecoderTraits::IsMP4TypeAndEnabled(aType.GetMIMEType(), aDiagnostics)) {
+ if (DecoderTraits::IsMP4TypeAndEnabled(aType.GetMIMEType(), aDoc, aDiagnostics)) {
return CANPLAY_MAYBE;
}
#if !defined(MOZ_OMX_WEBM_DECODER)
if (DecoderTraits::IsWebMTypeAndEnabled(aType.GetMIMEType())) {
return CANPLAY_MAYBE;
}
#endif
if (IsMP3SupportedType(aType.GetMIMEType())) {
@@ -356,23 +363,24 @@ CanHandleMediaType(const MediaContentTyp
}
#endif
return CANPLAY_NO;
}
/* static */
CanPlayStatus
DecoderTraits::CanHandleContentType(const MediaContentType& aContentType,
+ nsIDocument* aDoc,
DecoderDoctorDiagnostics* aDiagnostics)
{
if (!aContentType.IsValid()) {
return CANPLAY_NO;
}
- return CanHandleMediaType(aContentType, aDiagnostics);
+ return CanHandleMediaType(aContentType, aDoc, aDiagnostics);
}
/* static */
bool DecoderTraits::ShouldHandleMediaType(const char* aMIMEType,
DecoderDoctorDiagnostics* aDiagnostics)
{
if (IsWaveType(nsDependentCString(aMIMEType))) {
// We should not return true for Wave types, since there are some
@@ -390,32 +398,32 @@ bool DecoderTraits::ShouldHandleMediaTyp
RefPtr<nsPluginHost> pluginHost = nsPluginHost::GetInst();
if (pluginHost &&
pluginHost->HavePluginForType(nsDependentCString(aMIMEType))) {
return false;
}
}
MediaContentType parsed{nsDependentCString(aMIMEType)};
- return CanHandleMediaType(parsed, aDiagnostics)
+ return CanHandleMediaType(parsed, /* nsIDocument* */ nullptr, aDiagnostics)
!= CANPLAY_NO;
}
// Instantiates but does not initialize decoder.
static
already_AddRefed<MediaDecoder>
InstantiateDecoder(const nsACString& aType,
MediaDecoderOwner* aOwner,
DecoderDoctorDiagnostics* aDiagnostics)
{
MOZ_ASSERT(NS_IsMainThread());
RefPtr<MediaDecoder> decoder;
#ifdef MOZ_FMP4
- if (IsMP4SupportedType(aType, aDiagnostics)) {
+ if (IsMP4SupportedType(aType, /* nsIDocument* */ nullptr, aDiagnostics)) {
decoder = new MP4Decoder(aOwner);
return decoder.forget();
}
#endif
if (IsMP3SupportedType(aType)) {
decoder = new MP3Decoder(aOwner);
return decoder.forget();
}
@@ -480,17 +488,19 @@ MediaDecoderReader* DecoderTraits::Creat
{
MOZ_ASSERT(NS_IsMainThread());
MediaDecoderReader* decoderReader = nullptr;
if (!aDecoder) {
return decoderReader;
}
#ifdef MOZ_FMP4
- if (IsMP4SupportedType(aType, /* DecoderDoctorDiagnostics* */ nullptr)) {
+ if (IsMP4SupportedType(aType,
+ /* nsIDocument* */ nullptr,
+ /* DecoderDoctorDiagnostics* */ nullptr)) {
decoderReader = new MediaFormatReader(aDecoder, new MP4Demuxer(aDecoder->GetResource()));
} else
#endif
if (IsMP3SupportedType(aType)) {
decoderReader = new MediaFormatReader(aDecoder, new mp3::MP3Demuxer(aDecoder->GetResource()));
} else
if (IsAACSupportedType(aType)) {
decoderReader = new MediaFormatReader(aDecoder, new ADTSDemuxer(aDecoder->GetResource()));
@@ -542,17 +552,19 @@ bool DecoderTraits::IsSupportedInVideoDo
return
IsOggSupportedType(aType) ||
IsWebMSupportedType(aType) ||
#ifdef MOZ_ANDROID_OMX
(MediaDecoder::IsAndroidMediaPluginEnabled() && IsAndroidMediaType(aType)) ||
#endif
#ifdef MOZ_FMP4
- IsMP4SupportedType(aType, /* DecoderDoctorDiagnostics* */ nullptr) ||
+ IsMP4SupportedType(aType,
+ /* nsIDocument* */ nullptr,
+ /* DecoderDoctorDiagnostics* */ nullptr) ||
#endif
IsMP3SupportedType(aType) ||
IsAACSupportedType(aType) ||
IsFlacSupportedType(aType) ||
#ifdef MOZ_DIRECTSHOW
IsDirectShowSupportedType(aType) ||
#endif
false;
--- a/dom/media/DecoderTraits.h
+++ b/dom/media/DecoderTraits.h
@@ -6,16 +6,17 @@
#ifndef DecoderTraits_h_
#define DecoderTraits_h_
#include "nsCOMPtr.h"
class nsAString;
class nsACString;
+class nsIDocument;
namespace mozilla {
class AbstractMediaDecoder;
class DecoderDoctorDiagnostics;
class MediaContentType;
class MediaDecoder;
class MediaDecoderOwner;
@@ -26,16 +27,17 @@ enum CanPlayStatus {
CANPLAY_MAYBE,
CANPLAY_YES
};
class DecoderTraits {
public:
// Returns the CanPlayStatus indicating if we can handle this content type.
static CanPlayStatus CanHandleContentType(const MediaContentType& aContentType,
+ nsIDocument* aDoc,
DecoderDoctorDiagnostics* aDiagnostics);
// Returns true if we should handle this MIME type when it appears
// as an <object> or as a toplevel page. If, in practice, our support
// for the type is more limited than appears in the wild, we should return
// false here even if CanHandleMediaType would return true.
static bool ShouldHandleMediaType(const char* aMIMEType,
DecoderDoctorDiagnostics* aDiagnostics);
@@ -54,15 +56,16 @@ public:
// Returns true if MIME type aType is supported in video documents,
// or false otherwise. Not all platforms support all MIME types, and
// vice versa.
static bool IsSupportedInVideoDocument(const nsACString& aType);
static bool IsWebMTypeAndEnabled(const nsACString& aType);
static bool IsWebMAudioType(const nsACString& aType);
static bool IsMP4TypeAndEnabled(const nsACString& aType,
+ nsIDocument* aDoc,
DecoderDoctorDiagnostics* aDiagnostics);
};
} // namespace mozilla
#endif
--- a/dom/media/eme/MediaKeySystemAccess.cpp
+++ b/dom/media/eme/MediaKeySystemAccess.cpp
@@ -552,17 +552,19 @@ CanDecryptAndDecode(mozIGeckoMediaPlugin
NS_ConvertUTF16toUTF8(aKeySystem),
api,
codec)) {
// GMP can decrypt-and-decode this codec.
continue;
}
if (aContainerSupport.Decrypts(codec) &&
- NS_SUCCEEDED(MediaSource::IsTypeSupported(aContentType, aDiagnostics))) {
+ NS_SUCCEEDED(MediaSource::IsTypeSupported(aContentType,
+ /* nsIDocument* */ nullptr,
+ aDiagnostics))) {
// GMP can decrypt and is allowed to return compressed samples to
// Gecko to decode, and Gecko has a decoder.
continue;
}
// Neither the GMP nor Gecko can both decrypt and decode. We don't
// support this codec.
@@ -751,17 +753,19 @@ GetSupportedCapabilities(const CodecType
}
// If the user agent does not support container, continue to the next iteration.
// The case-sensitivity of string comparisons is determined by the appropriate RFC.
// (Note: Per RFC 6838 [RFC6838], "Both top-level type and subtype names are
// case-insensitive."'. We're using nsContentTypeParser and that is
// case-insensitive and converts all its parameter outputs to lower case.)
NS_ConvertUTF16toUTF8 container_utf8(container);
- const bool isMP4 = DecoderTraits::IsMP4TypeAndEnabled(container_utf8, aDiagnostics);
+ const bool isMP4 = DecoderTraits::IsMP4TypeAndEnabled(container_utf8,
+ /* nsIDocument* */ nullptr,
+ aDiagnostics);
if (isMP4 && !aKeySystem.mMP4.IsSupported()) {
EME_LOG("MediaKeySystemConfiguration (label='%s') "
"MediaKeySystemMediaCapability('%s','%s') unsupported; "
"MP4 requested but unsupported.",
NS_ConvertUTF16toUTF8(aPartialConfig.mLabel).get(),
NS_ConvertUTF16toUTF8(contentType).get(),
NS_ConvertUTF16toUTF8(robustness).get());
continue;
--- a/dom/media/fmp4/MP4Decoder.cpp
+++ b/dom/media/fmp4/MP4Decoder.cpp
@@ -75,16 +75,17 @@ IsWhitelistedH264Codec(const nsAString&
profile == H264_PROFILE_MAIN ||
profile == H264_PROFILE_EXTENDED ||
profile == H264_PROFILE_HIGH);
}
/* static */
bool
MP4Decoder::CanHandleMediaType(const MediaContentType& aType,
+ nsIDocument* aDoc,
DecoderDoctorDiagnostics* aDiagnostics)
{
if (!IsEnabled()) {
return false;
}
// Whitelist MP4 types, so they explicitly match what we encounter on
// the web, as opposed to what we use internally (i.e. what our demuxers
@@ -148,17 +149,17 @@ MP4Decoder::CanHandleMediaType(const Med
// Some unsupported codec.
return false;
}
}
// Verify that we have a PDM that supports the whitelisted types.
RefPtr<PDMFactory> platform = new PDMFactory();
for (const auto& trackInfo : trackInfos) {
- if (!trackInfo || !platform->Supports(*trackInfo, aDiagnostics)) {
+ if (!trackInfo || !platform->Supports(*trackInfo, aDoc, aDiagnostics)) {
return false;
}
}
return true;
}
/* static */
--- a/dom/media/fmp4/MP4Decoder.h
+++ b/dom/media/fmp4/MP4Decoder.h
@@ -28,16 +28,17 @@ public:
return new MP4Decoder(aOwner);
}
MediaDecoderStateMachine* CreateStateMachine() override;
// Returns true if aType is a type that we think we can render with the
// a MP4 platform decoder backend.
static bool CanHandleMediaType(const MediaContentType& aType,
+ nsIDocument* aDoc,
DecoderDoctorDiagnostics* aDiagnostics);
// Return true if aMimeType is a one of the strings used by our demuxers to
// identify H264. Does not parse general content type strings, i.e. white
// space matters.
static bool IsH264(const nsACString& aMimeType);
// Returns true if the MP4 backend is preffed on.
--- a/dom/media/gtest/TestMediaDataDecoder.cpp
+++ b/dom/media/gtest/TestMediaDataDecoder.cpp
@@ -37,18 +37,20 @@ public:
}
private:
RefPtr<Benchmark> mBenchmark;
};
TEST(MediaDataDecoder, H264)
{
- if (!DecoderTraits::IsMP4TypeAndEnabled(NS_LITERAL_CSTRING("video/mp4")
- , /* DecoderDoctorDiagnostics* */ nullptr)) {
+ if (!DecoderTraits::IsMP4TypeAndEnabled(
+ NS_LITERAL_CSTRING("video/mp4"),
+ /* nsIDocument* */ nullptr,
+ /* DecoderDoctorDiagnostics* */ nullptr)) {
EXPECT_TRUE(true);
} else {
RefPtr<MediaResource> resource =
new MockMediaResource("gizmo.mp4", NS_LITERAL_CSTRING("video/mp4"));
nsresult rv = resource->Open(nullptr);
EXPECT_TRUE(NS_SUCCEEDED(rv));
BenchmarkRunner runner(new Benchmark(new MP4Demuxer(resource)));
--- a/dom/media/mediasource/MediaSource.cpp
+++ b/dom/media/mediasource/MediaSource.cpp
@@ -64,37 +64,38 @@ namespace mozilla {
// optional "Windows Media Feature Pack"
// 2. If H264 hardware acceleration is not available.
// 3. The CPU is considered to be fast enough
static bool
IsWebMForced(DecoderDoctorDiagnostics* aDiagnostics)
{
bool mp4supported =
DecoderTraits::IsMP4TypeAndEnabled(NS_LITERAL_CSTRING("video/mp4"),
+ /* nsIDocument* */ nullptr,
aDiagnostics);
bool hwsupported = gfx::gfxVars::CanUseHardwareVideoDecoding();
return !mp4supported || !hwsupported || VP9Benchmark::IsVP9DecodeFast();
}
namespace dom {
/* static */
nsresult
-MediaSource::IsTypeSupported(const nsAString& aType, DecoderDoctorDiagnostics* aDiagnostics)
+MediaSource::IsTypeSupported(const nsAString& aType, nsIDocument* aDoc, DecoderDoctorDiagnostics* aDiagnostics)
{
if (aType.IsEmpty()) {
return NS_ERROR_DOM_TYPE_ERR;
}
MediaContentType contentType{aType};
if (!contentType.IsValid()) {
return NS_ERROR_DOM_TYPE_ERR;
}
- if (DecoderTraits::CanHandleContentType(contentType, aDiagnostics)
+ if (DecoderTraits::CanHandleContentType(contentType, aDoc, aDiagnostics)
== CANPLAY_NO) {
return NS_ERROR_DOM_NOT_SUPPORTED_ERR;
}
// Now we know that this media type could be played.
// MediaSource imposes extra restrictions, and some prefs.
const nsACString& mimeType = contentType.GetMIMEType();
if (mimeType.EqualsASCII("video/mp4") || mimeType.EqualsASCII("audio/mp4")) {
@@ -204,17 +205,17 @@ MediaSource::SetDuration(double aDuratio
mDecoder->SetMediaSourceDuration(aDuration);
}
already_AddRefed<SourceBuffer>
MediaSource::AddSourceBuffer(const nsAString& aType, ErrorResult& aRv)
{
MOZ_ASSERT(NS_IsMainThread());
DecoderDoctorDiagnostics diagnostics;
- nsresult rv = IsTypeSupported(aType, &diagnostics);
+ nsresult rv = IsTypeSupported(aType, /* nsIDocument* */ nullptr, &diagnostics);
diagnostics.StoreFormatDiagnostics(GetOwner()
? GetOwner()->GetExtantDoc()
: nullptr,
aType, NS_SUCCEEDED(rv), __func__);
MSE_API("AddSourceBuffer(aType=%s)%s",
NS_ConvertUTF16toUTF8(aType).get(),
rv == NS_OK ? "" : " [not supported]");
if (NS_FAILED(rv)) {
@@ -333,21 +334,21 @@ MediaSource::EndOfStream(const MediaResu
mSourceBuffers->Ended();
mDecoder->DecodeError(aError);
}
/* static */ bool
MediaSource::IsTypeSupported(const GlobalObject& aOwner, const nsAString& aType)
{
MOZ_ASSERT(NS_IsMainThread());
+ nsCOMPtr<nsPIDOMWindowInner> window = do_QueryInterface(aOwner.GetAsSupports());
+ nsIDocument* doc = window ? window->GetExtantDoc() : nullptr;
DecoderDoctorDiagnostics diagnostics;
- nsresult rv = IsTypeSupported(aType, &diagnostics);
- nsCOMPtr<nsPIDOMWindowInner> window = do_QueryInterface(aOwner.GetAsSupports());
- diagnostics.StoreFormatDiagnostics(window ? window->GetExtantDoc() : nullptr,
- aType, NS_SUCCEEDED(rv), __func__);
+ nsresult rv = IsTypeSupported(aType, doc, &diagnostics);
+ diagnostics.StoreFormatDiagnostics(doc, aType, NS_SUCCEEDED(rv), __func__);
#define this nullptr
MSE_API("IsTypeSupported(aType=%s)%s ",
NS_ConvertUTF16toUTF8(aType).get(), rv == NS_OK ? "OK" : "[not supported]");
#undef this // don't ever remove this line !
return NS_SUCCEEDED(rv);
}
/* static */ bool
--- a/dom/media/mediasource/MediaSource.h
+++ b/dom/media/mediasource/MediaSource.h
@@ -62,17 +62,17 @@ public:
void EndOfStream(const Optional<MediaSourceEndOfStreamError>& aError, ErrorResult& aRv);
void EndOfStream(const MediaResult& aError);
void SetLiveSeekableRange(double aStart, double aEnd, ErrorResult& aRv);
void ClearLiveSeekableRange(ErrorResult& aRv);
static bool IsTypeSupported(const GlobalObject&, const nsAString& aType);
- static nsresult IsTypeSupported(const nsAString& aType, DecoderDoctorDiagnostics* aDiagnostics);
+ static nsresult IsTypeSupported(const nsAString& aType, nsIDocument* aDoc, DecoderDoctorDiagnostics* aDiagnostics);
static bool Enabled(JSContext* cx, JSObject* aGlobal);
IMPL_EVENT_HANDLER(sourceopen);
IMPL_EVENT_HANDLER(sourceended);
IMPL_EVENT_HANDLER(sourceclosed);
/** End WebIDL Methods. */
--- a/dom/media/platforms/PDMFactory.cpp
+++ b/dom/media/platforms/PDMFactory.cpp
@@ -323,27 +323,28 @@ PDMFactory::CreateDecoderWithPDM(Platfor
bool
PDMFactory::SupportsMimeType(const nsACString& aMimeType,
DecoderDoctorDiagnostics* aDiagnostics) const
{
UniquePtr<TrackInfo> trackInfo = CreateTrackInfoWithMIMEType(aMimeType);
if (!trackInfo) {
return false;
}
- return Supports(*trackInfo, aDiagnostics);
+ return Supports(*trackInfo, /* nsIDocument* */ nullptr, aDiagnostics);
}
bool
PDMFactory::Supports(const TrackInfo& aTrackInfo,
+ nsIDocument* aDoc,
DecoderDoctorDiagnostics* aDiagnostics) const
{
if (mEMEPDM) {
- return mEMEPDM->Supports(aTrackInfo, aDiagnostics);
+ return mEMEPDM->Supports(aTrackInfo, aDoc, aDiagnostics);
}
- RefPtr<PlatformDecoderModule> current = GetDecoder(aTrackInfo, aDiagnostics);
+ RefPtr<PlatformDecoderModule> current = GetDecoder(aTrackInfo, aDoc, aDiagnostics);
return !!current;
}
void
PDMFactory::CreatePDMs()
{
RefPtr<PlatformDecoderModule> m;
@@ -438,16 +439,17 @@ PDMFactory::StartupPDM(PlatformDecoderMo
mCurrentPDMs.AppendElement(aPDM);
return true;
}
return false;
}
already_AddRefed<PlatformDecoderModule>
PDMFactory::GetDecoder(const TrackInfo& aTrackInfo,
+ nsIDocument* aDoc,
DecoderDoctorDiagnostics* aDiagnostics) const
{
if (aDiagnostics) {
// If libraries failed to load, the following loop over mCurrentPDMs
// will not even try to use them. So we record failures now.
if (mWMFFailedToLoad) {
aDiagnostics->SetWMFFailedToLoad();
}
@@ -456,17 +458,17 @@ PDMFactory::GetDecoder(const TrackInfo&
}
if (mGMPPDMFailedToStartup) {
aDiagnostics->SetGMPPDMFailedToStartup();
}
}
RefPtr<PlatformDecoderModule> pdm;
for (auto& current : mCurrentPDMs) {
- if (current->Supports(aTrackInfo, aDiagnostics)) {
+ if (current->Supports(aTrackInfo, aDoc, aDiagnostics)) {
pdm = current;
break;
}
}
return pdm.forget();
}
void
--- a/dom/media/platforms/PDMFactory.h
+++ b/dom/media/platforms/PDMFactory.h
@@ -31,16 +31,17 @@ public:
// PlatformDecoderModules alive at the same time.
// This is called on the decode task queue.
already_AddRefed<MediaDataDecoder>
CreateDecoder(const CreateDecoderParams& aParams);
bool SupportsMimeType(const nsACString& aMimeType,
DecoderDoctorDiagnostics* aDiagnostics) const;
bool Supports(const TrackInfo& aTrackInfo,
+ nsIDocument* aDoc,
DecoderDoctorDiagnostics* aDiagnostics) const;
// Creates a PlatformDecoderModule that uses a CDMProxy to decrypt or
// decrypt-and-decode EME encrypted content. If the CDM only decrypts and
// does not decode, we create a PDM and use that to create MediaDataDecoders
// that we use on on aTaskQueue to decode the decrypted stream.
// This is called on the decode task queue.
void SetCDMProxy(CDMProxy* aProxy);
@@ -54,16 +55,17 @@ private:
virtual ~PDMFactory();
void CreatePDMs();
void CreateBlankPDM();
// Startup the provided PDM and add it to our list if successful.
bool StartupPDM(PlatformDecoderModule* aPDM);
// Returns the first PDM in our list supporting the mimetype.
already_AddRefed<PlatformDecoderModule>
GetDecoder(const TrackInfo& aTrackInfo,
+ nsIDocument* aDoc,
DecoderDoctorDiagnostics* aDiagnostics) const;
already_AddRefed<MediaDataDecoder>
CreateDecoderWithPDM(PlatformDecoderModule* aPDM,
const CreateDecoderParams& aParams);
nsTArray<RefPtr<PlatformDecoderModule>> mCurrentPDMs;
RefPtr<PlatformDecoderModule> mEMEPDM;
--- a/dom/media/platforms/PlatformDecoderModule.h
+++ b/dom/media/platforms/PlatformDecoderModule.h
@@ -116,16 +116,17 @@ public:
// Perform any per-instance initialization.
// This is called on the decode task queue.
virtual nsresult Startup() { return NS_OK; };
// Indicates if the PlatformDecoderModule supports decoding of aMimeType.
virtual bool SupportsMimeType(const nsACString& aMimeType,
DecoderDoctorDiagnostics* aDiagnostics) const = 0;
virtual bool Supports(const TrackInfo& aTrackInfo,
+ nsIDocument* aDoc,
DecoderDoctorDiagnostics* aDiagnostics) const
{
// By default, fall back to SupportsMimeType with just the MIME string.
// (So PDMs do not need to override this method -- yet.)
return SupportsMimeType(aTrackInfo.mMimeType, aDiagnostics);
}
enum class ConversionRequired : uint8_t {
--- a/dom/media/platforms/wmf/WMFDecoderModule.cpp
+++ b/dom/media/platforms/wmf/WMFDecoderModule.cpp
@@ -193,21 +193,22 @@ WMFDecoderModule::HasAAC()
bool
WMFDecoderModule::SupportsMimeType(const nsACString& aMimeType,
DecoderDoctorDiagnostics* aDiagnostics) const
{
UniquePtr<TrackInfo> trackInfo = CreateTrackInfoWithMIMEType(aMimeType);
if (!trackInfo) {
return false;
}
- return Supports(*trackInfo, aDiagnostics);
+ return Supports(*trackInfo, /* nsIDocument* */ nullptr, aDiagnostics);
}
bool
WMFDecoderModule::Supports(const TrackInfo& aTrackInfo,
+ nsIDocument* aDoc,
DecoderDoctorDiagnostics* aDiagnostics) const
{
if ((aTrackInfo.mMimeType.EqualsLiteral("audio/mp4a-latm") ||
aTrackInfo.mMimeType.EqualsLiteral("audio/mp4")) &&
WMFDecoderModule::HasAAC()) {
return true;
}
if (MP4Decoder::IsH264(aTrackInfo.mMimeType) && WMFDecoderModule::HasH264()) {
--- a/dom/media/platforms/wmf/WMFDecoderModule.h
+++ b/dom/media/platforms/wmf/WMFDecoderModule.h
@@ -23,16 +23,17 @@ public:
CreateVideoDecoder(const CreateDecoderParams& aParams) override;
already_AddRefed<MediaDataDecoder>
CreateAudioDecoder(const CreateDecoderParams& aParams) override;
bool SupportsMimeType(const nsACString& aMimeType,
DecoderDoctorDiagnostics* aDiagnostics) const override;
bool Supports(const TrackInfo& aTrackInfo,
+ nsIDocument* aDoc,
DecoderDoctorDiagnostics* aDiagnostics) const override;
ConversionRequired
DecoderNeedsConversion(const TrackInfo& aConfig) const override;
// Called on main thread.
static void Init();