mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 05:11:16 +00:00
Bug 1764846 - Extend the return value of PDM's support methods to allow distinguishing between HW/SW support. r=alwu
Differential Revision: https://phabricator.services.mozilla.com/D143800
This commit is contained in:
parent
2607db324d
commit
77c47db916
@ -400,7 +400,8 @@ static nsTArray<KeySystemConfig> GetSupportedKeySystems() {
|
||||
for (const auto& data : validationList) {
|
||||
if (java::MediaDrmProxy::IsCryptoSchemeSupported(kWidevineKeySystemName,
|
||||
data.mMimeType)) {
|
||||
if (AndroidDecoderModule::SupportsMimeType(data.mMimeType)) {
|
||||
if (AndroidDecoderModule::SupportsMimeType(data.mMimeType) !=
|
||||
media::DecodeSupport::Unsupported) {
|
||||
data.mSupportType->SetCanDecryptAndDecode(data.mEMECodecType);
|
||||
} else {
|
||||
data.mSupportType->SetCanDecrypt(data.mEMECodecType);
|
||||
|
@ -38,12 +38,12 @@ already_AddRefed<PlatformDecoderModule> RemoteDecoderModule::Create(
|
||||
RemoteDecoderModule::RemoteDecoderModule(RemoteDecodeIn aLocation)
|
||||
: mLocation(aLocation) {}
|
||||
|
||||
bool RemoteDecoderModule::SupportsMimeType(
|
||||
media::DecodeSupportSet RemoteDecoderModule::SupportsMimeType(
|
||||
const nsACString& aMimeType, DecoderDoctorDiagnostics* aDiagnostics) const {
|
||||
MOZ_CRASH("Deprecated: Use RemoteDecoderModule::Supports");
|
||||
} // namespace mozilla
|
||||
|
||||
bool RemoteDecoderModule::Supports(
|
||||
media::DecodeSupportSet RemoteDecoderModule::Supports(
|
||||
const SupportDecoderParams& aParams,
|
||||
DecoderDoctorDiagnostics* aDiagnostics) const {
|
||||
bool supports =
|
||||
@ -54,7 +54,12 @@ bool RemoteDecoderModule::Supports(
|
||||
? "GPU"
|
||||
: (mLocation == RemoteDecodeIn::RddProcess ? "RDD" : "Utility"),
|
||||
supports ? "supports" : "rejects"));
|
||||
return supports;
|
||||
if (supports) {
|
||||
// TODO: Note that we do not yet distinguish between SW/HW decode support.
|
||||
// Will be done in bug 1754239.
|
||||
return media::DecodeSupport::SoftwareDecode;
|
||||
}
|
||||
return media::DecodeSupport::Unsupported;
|
||||
}
|
||||
|
||||
RefPtr<RemoteDecoderModule::CreateDecoderPromise>
|
||||
|
@ -20,11 +20,13 @@ class RemoteDecoderModule : public PlatformDecoderModule {
|
||||
static already_AddRefed<PlatformDecoderModule> Create(
|
||||
RemoteDecodeIn aLocation);
|
||||
|
||||
bool SupportsMimeType(const nsACString& aMimeType,
|
||||
DecoderDoctorDiagnostics* aDiagnostics) const override;
|
||||
media::DecodeSupportSet SupportsMimeType(
|
||||
const nsACString& aMimeType,
|
||||
DecoderDoctorDiagnostics* aDiagnostics) const override;
|
||||
|
||||
bool Supports(const SupportDecoderParams& aParams,
|
||||
DecoderDoctorDiagnostics* aDiagnostics) const override;
|
||||
media::DecodeSupportSet Supports(
|
||||
const SupportDecoderParams& aParams,
|
||||
DecoderDoctorDiagnostics* aDiagnostics) const override;
|
||||
|
||||
RefPtr<CreateDecoderPromise> AsyncCreateDecoder(
|
||||
const CreateDecoderParams& aParams) override;
|
||||
|
22
dom/media/platforms/MediaCodecsSupport.h
Normal file
22
dom/media/platforms/MediaCodecsSupport.h
Normal file
@ -0,0 +1,22 @@
|
||||
/* -*- 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/. */
|
||||
#ifndef DOM_MEDIA_PLATFORMS_MEDIACODECSSUPPORT_H_
|
||||
#define DOM_MEDIA_PLATFORMS_MEDIACODECSSUPPORT_H_
|
||||
#include "mozilla/EnumSet.h"
|
||||
#include "nsString.h"
|
||||
|
||||
namespace mozilla::media {
|
||||
|
||||
enum class DecodeSupport {
|
||||
Unsupported = 0,
|
||||
SoftwareDecode,
|
||||
HardwareDecode,
|
||||
};
|
||||
|
||||
using DecodeSupportSet = EnumSet<DecodeSupport, uint64_t>;
|
||||
} // namespace mozilla::media
|
||||
|
||||
#endif /* MediaCodecsSupport_h_ */
|
@ -336,7 +336,8 @@ PDMFactory::CheckAndMaybeCreateDecoder(CreateDecoderParamsForAsync&& aParams,
|
||||
uint32_t i = aIndex;
|
||||
auto params = SupportDecoderParams(aParams);
|
||||
for (; i < mCurrentPDMs.Length(); i++) {
|
||||
if (!mCurrentPDMs[i]->Supports(params, nullptr /* diagnostic */)) {
|
||||
if (mCurrentPDMs[i]->Supports(params, nullptr /* diagnostic */) ==
|
||||
media::DecodeSupport::Unsupported) {
|
||||
continue;
|
||||
}
|
||||
RefPtr<PlatformDecoderModule::CreateDecoderPromise> p =
|
||||
@ -440,7 +441,8 @@ bool PDMFactory::SupportsMimeType(const nsACString& aMimeType) const {
|
||||
bool PDMFactory::Supports(const SupportDecoderParams& aParams,
|
||||
DecoderDoctorDiagnostics* aDiagnostics) const {
|
||||
if (mEMEPDM) {
|
||||
return mEMEPDM->Supports(aParams, aDiagnostics);
|
||||
return mEMEPDM->Supports(aParams, aDiagnostics) !=
|
||||
media::DecodeSupport::Unsupported;
|
||||
}
|
||||
|
||||
RefPtr<PlatformDecoderModule> current =
|
||||
@ -697,8 +699,9 @@ already_AddRefed<PlatformDecoderModule> PDMFactory::GetDecoderModule(
|
||||
}
|
||||
|
||||
RefPtr<PlatformDecoderModule> pdm;
|
||||
for (auto& current : mCurrentPDMs) {
|
||||
if (current->Supports(aParams, aDiagnostics)) {
|
||||
for (const auto& current : mCurrentPDMs) {
|
||||
if (current->Supports(aParams, aDiagnostics) !=
|
||||
media::DecodeSupport::Unsupported) {
|
||||
pdm = current;
|
||||
break;
|
||||
}
|
||||
|
@ -7,8 +7,8 @@
|
||||
#if !defined(PDMFactory_h_)
|
||||
# define PDMFactory_h_
|
||||
|
||||
# include <utility>
|
||||
# include "DecoderDoctorDiagnostics.h"
|
||||
# include "MediaCodecsSupport.h"
|
||||
# include "PlatformDecoderModule.h"
|
||||
# include "mozilla/AlreadyAddRefed.h"
|
||||
# include "mozilla/EnumSet.h"
|
||||
@ -17,6 +17,7 @@
|
||||
# include "nsISupports.h"
|
||||
# include "nsStringFwd.h"
|
||||
# include "nsTArray.h"
|
||||
# include <utility>
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
|
@ -11,6 +11,7 @@
|
||||
|
||||
# include "DecoderDoctorLogger.h"
|
||||
# include "GMPCrashHelper.h"
|
||||
# include "MediaCodecsSupport.h"
|
||||
# include "MediaEventSource.h"
|
||||
# include "MediaInfo.h"
|
||||
# include "MediaResult.h"
|
||||
@ -313,22 +314,38 @@ class PlatformDecoderModule {
|
||||
// This is called on the decode task queue.
|
||||
virtual nsresult Startup() { return NS_OK; }
|
||||
|
||||
// Indicates if the PlatformDecoderModule supports decoding of aMimeType.
|
||||
// Indicates if the PlatformDecoderModule supports decoding of aMimeType,
|
||||
// and whether or not hardware-accelerated decoding is supported.
|
||||
// The answer to both SupportsMimeType and Supports doesn't guarantee that
|
||||
// creation of a decoder will actually succeed.
|
||||
virtual bool SupportsMimeType(
|
||||
virtual media::DecodeSupportSet SupportsMimeType(
|
||||
const nsACString& aMimeType,
|
||||
DecoderDoctorDiagnostics* aDiagnostics) const = 0;
|
||||
|
||||
virtual bool Supports(const SupportDecoderParams& aParams,
|
||||
DecoderDoctorDiagnostics* aDiagnostics) const {
|
||||
virtual media::DecodeSupportSet Supports(
|
||||
const SupportDecoderParams& aParams,
|
||||
DecoderDoctorDiagnostics* aDiagnostics) const {
|
||||
const TrackInfo& trackInfo = aParams.mConfig;
|
||||
if (!SupportsMimeType(trackInfo.mMimeType, aDiagnostics)) {
|
||||
return false;
|
||||
const media::DecodeSupportSet support =
|
||||
SupportsMimeType(trackInfo.mMimeType, aDiagnostics);
|
||||
|
||||
// Bail early if we don't support this format at all
|
||||
if (support == media::DecodeSupport::Unsupported) {
|
||||
return support;
|
||||
}
|
||||
|
||||
const auto* videoInfo = trackInfo.GetAsVideoInfo();
|
||||
return !videoInfo ||
|
||||
SupportsColorDepth(videoInfo->mColorDepth, aDiagnostics);
|
||||
|
||||
if (!videoInfo) {
|
||||
// No video stream = software decode only
|
||||
return media::DecodeSupport::SoftwareDecode;
|
||||
}
|
||||
|
||||
// Check whether we support the desired color depth
|
||||
if (!SupportsColorDepth(videoInfo->mColorDepth, aDiagnostics)) {
|
||||
return media::DecodeSupport::Unsupported;
|
||||
}
|
||||
return support;
|
||||
}
|
||||
|
||||
using CreateDecoderPromise = MozPromise<RefPtr<MediaDataDecoder>, MediaResult,
|
||||
|
@ -115,16 +115,16 @@ static bool IsAvailable(DecoderType type) {
|
||||
: IsAvailableInDefault(type);
|
||||
}
|
||||
|
||||
bool AgnosticDecoderModule::SupportsMimeType(
|
||||
media::DecodeSupportSet AgnosticDecoderModule::SupportsMimeType(
|
||||
const nsACString& aMimeType, DecoderDoctorDiagnostics* aDiagnostics) const {
|
||||
UniquePtr<TrackInfo> trackInfo = CreateTrackInfoWithMIMEType(aMimeType);
|
||||
if (!trackInfo) {
|
||||
return false;
|
||||
return media::DecodeSupport::Unsupported;
|
||||
}
|
||||
return Supports(SupportDecoderParams(*trackInfo), aDiagnostics);
|
||||
}
|
||||
|
||||
bool AgnosticDecoderModule::Supports(
|
||||
media::DecodeSupportSet AgnosticDecoderModule::Supports(
|
||||
const SupportDecoderParams& aParams,
|
||||
DecoderDoctorDiagnostics* aDiagnostics) const {
|
||||
const auto& trackInfo = aParams.mConfig;
|
||||
@ -146,12 +146,16 @@ bool AgnosticDecoderModule::Supports(
|
||||
MOZ_LOG(sPDMLog, LogLevel::Debug,
|
||||
("Agnostic decoder %s requested type '%s'",
|
||||
supports ? "supports" : "rejects", mimeType.BeginReading()));
|
||||
return supports;
|
||||
if (supports) {
|
||||
return media::DecodeSupport::SoftwareDecode;
|
||||
}
|
||||
return media::DecodeSupport::Unsupported;
|
||||
}
|
||||
|
||||
already_AddRefed<MediaDataDecoder> AgnosticDecoderModule::CreateVideoDecoder(
|
||||
const CreateDecoderParams& aParams) {
|
||||
if (!Supports(SupportDecoderParams(aParams), nullptr /* diagnostic */)) {
|
||||
if (Supports(SupportDecoderParams(aParams), nullptr /* diagnostic */) ==
|
||||
media::DecodeSupport::Unsupported) {
|
||||
return nullptr;
|
||||
}
|
||||
RefPtr<MediaDataDecoder> m;
|
||||
@ -182,7 +186,8 @@ already_AddRefed<MediaDataDecoder> AgnosticDecoderModule::CreateVideoDecoder(
|
||||
|
||||
already_AddRefed<MediaDataDecoder> AgnosticDecoderModule::CreateAudioDecoder(
|
||||
const CreateDecoderParams& aParams) {
|
||||
if (!Supports(SupportDecoderParams(aParams), nullptr /* diagnostic */)) {
|
||||
if (Supports(SupportDecoderParams(aParams), nullptr /* diagnostic */) ==
|
||||
media::DecodeSupport::Unsupported) {
|
||||
return nullptr;
|
||||
}
|
||||
RefPtr<MediaDataDecoder> m;
|
||||
|
@ -15,10 +15,12 @@ class AgnosticDecoderModule : public PlatformDecoderModule {
|
||||
public:
|
||||
static already_AddRefed<PlatformDecoderModule> Create();
|
||||
|
||||
bool SupportsMimeType(const nsACString& aMimeType,
|
||||
DecoderDoctorDiagnostics* aDiagnostics) const override;
|
||||
bool Supports(const SupportDecoderParams& aParams,
|
||||
DecoderDoctorDiagnostics* aDiagnostics) const override;
|
||||
media::DecodeSupportSet SupportsMimeType(
|
||||
const nsACString& aMimeType,
|
||||
DecoderDoctorDiagnostics* aDiagnostics) const override;
|
||||
media::DecodeSupportSet Supports(
|
||||
const SupportDecoderParams& aParams,
|
||||
DecoderDoctorDiagnostics* aDiagnostics) const override;
|
||||
|
||||
protected:
|
||||
AgnosticDecoderModule() = default;
|
||||
|
@ -130,9 +130,9 @@ already_AddRefed<MediaDataDecoder> BlankDecoderModule::CreateAudioDecoder(
|
||||
return decoder.forget();
|
||||
}
|
||||
|
||||
bool BlankDecoderModule::SupportsMimeType(
|
||||
media::DecodeSupportSet BlankDecoderModule::SupportsMimeType(
|
||||
const nsACString& aMimeType, DecoderDoctorDiagnostics* aDiagnostics) const {
|
||||
return true;
|
||||
return media::DecodeSupport::SoftwareDecode;
|
||||
}
|
||||
|
||||
/* static */
|
||||
|
@ -58,8 +58,9 @@ class BlankDecoderModule : public PlatformDecoderModule {
|
||||
already_AddRefed<MediaDataDecoder> CreateAudioDecoder(
|
||||
const CreateDecoderParams& aParams) override;
|
||||
|
||||
bool SupportsMimeType(const nsACString& aMimeType,
|
||||
DecoderDoctorDiagnostics* aDiagnostics) const override;
|
||||
media::DecodeSupportSet SupportsMimeType(
|
||||
const nsACString& aMimeType,
|
||||
DecoderDoctorDiagnostics* aDiagnostics) const override;
|
||||
};
|
||||
|
||||
} // namespace mozilla
|
||||
|
@ -42,9 +42,10 @@ class NullDecoderModule : public PlatformDecoderModule {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool SupportsMimeType(const nsACString& aMimeType,
|
||||
DecoderDoctorDiagnostics* aDiagnostics) const override {
|
||||
return true;
|
||||
media::DecodeSupportSet SupportsMimeType(
|
||||
const nsACString& aMimeType,
|
||||
DecoderDoctorDiagnostics* aDiagnostics) const override {
|
||||
return media::DecodeSupport::SoftwareDecode;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -395,7 +395,8 @@ EMEDecoderModule::AsyncCreateDecoder(const CreateDecoderParams& aParams) {
|
||||
__func__);
|
||||
}
|
||||
|
||||
if (SupportsMimeType(aParams.mConfig.mMimeType, nullptr)) {
|
||||
if (SupportsMimeType(aParams.mConfig.mMimeType, nullptr) !=
|
||||
media::DecodeSupport::Unsupported) {
|
||||
// GMP decodes. Assume that means it can decrypt too.
|
||||
return EMEDecoderModule::CreateDecoderPromise::CreateAndResolve(
|
||||
CreateDecoderWrapper(mProxy, aParams), __func__);
|
||||
@ -423,7 +424,8 @@ EMEDecoderModule::AsyncCreateDecoder(const CreateDecoderParams& aParams) {
|
||||
MOZ_ASSERT(aParams.mConfig.IsAudio());
|
||||
|
||||
// We don't support using the GMP to decode audio.
|
||||
MOZ_ASSERT(!SupportsMimeType(aParams.mConfig.mMimeType, nullptr));
|
||||
MOZ_ASSERT(SupportsMimeType(aParams.mConfig.mMimeType, nullptr) ==
|
||||
media::DecodeSupport::Unsupported);
|
||||
MOZ_ASSERT(mPDM);
|
||||
|
||||
if (StaticPrefs::media_eme_audio_blank()) {
|
||||
@ -460,7 +462,7 @@ EMEDecoderModule::AsyncCreateDecoder(const CreateDecoderParams& aParams) {
|
||||
return p;
|
||||
}
|
||||
|
||||
bool EMEDecoderModule::SupportsMimeType(
|
||||
media::DecodeSupportSet EMEDecoderModule::SupportsMimeType(
|
||||
const nsACString& aMimeType, DecoderDoctorDiagnostics* aDiagnostics) const {
|
||||
Maybe<nsCString> gmp;
|
||||
gmp.emplace(NS_ConvertUTF16toUTF8(mProxy->KeySystem()));
|
||||
|
@ -36,8 +36,9 @@ class EMEDecoderModule : public PlatformDecoderModule {
|
||||
MOZ_CRASH("Not used");
|
||||
}
|
||||
|
||||
bool SupportsMimeType(const nsACString& aMimeType,
|
||||
DecoderDoctorDiagnostics* aDiagnostics) const override;
|
||||
media::DecodeSupportSet SupportsMimeType(
|
||||
const nsACString& aMimeType,
|
||||
DecoderDoctorDiagnostics* aDiagnostics) const override;
|
||||
|
||||
private:
|
||||
virtual ~EMEDecoderModule();
|
||||
|
@ -57,32 +57,34 @@ already_AddRefed<MediaDataDecoder> GMPDecoderModule::CreateAudioDecoder(
|
||||
}
|
||||
|
||||
/* static */
|
||||
bool GMPDecoderModule::SupportsMimeType(const nsACString& aMimeType,
|
||||
const Maybe<nsCString>& aGMP) {
|
||||
media::DecodeSupportSet GMPDecoderModule::SupportsMimeType(
|
||||
const nsACString& aMimeType, const Maybe<nsCString>& aGMP) {
|
||||
bool isSupported = false;
|
||||
if (aGMP.isNothing()) {
|
||||
return false;
|
||||
return media::DecodeSupport::Unsupported;
|
||||
}
|
||||
|
||||
nsCString api = nsLiteralCString(CHROMIUM_CDM_API);
|
||||
|
||||
if (MP4Decoder::IsH264(aMimeType)) {
|
||||
return HaveGMPFor(api, {"h264"_ns, aGMP.value()});
|
||||
isSupported = HaveGMPFor(api, {"h264"_ns, aGMP.value()});
|
||||
} else if (VPXDecoder::IsVP9(aMimeType)) {
|
||||
isSupported = HaveGMPFor(api, {"vp9"_ns, aGMP.value()});
|
||||
} else if (VPXDecoder::IsVP8(aMimeType)) {
|
||||
isSupported = HaveGMPFor(api, {"vp8"_ns, aGMP.value()});
|
||||
}
|
||||
|
||||
if (VPXDecoder::IsVP9(aMimeType)) {
|
||||
return HaveGMPFor(api, {"vp9"_ns, aGMP.value()});
|
||||
// TODO: Note that we do not yet distinguish between SW/HW decode support.
|
||||
// Will be done in bug 1754239.
|
||||
if (isSupported) {
|
||||
return media::DecodeSupport::SoftwareDecode;
|
||||
}
|
||||
|
||||
if (VPXDecoder::IsVP8(aMimeType)) {
|
||||
return HaveGMPFor(api, {"vp8"_ns, aGMP.value()});
|
||||
}
|
||||
|
||||
return false;
|
||||
return media::DecodeSupport::Unsupported;
|
||||
}
|
||||
|
||||
bool GMPDecoderModule::SupportsMimeType(
|
||||
media::DecodeSupportSet GMPDecoderModule::SupportsMimeType(
|
||||
const nsACString& aMimeType, DecoderDoctorDiagnostics* aDiagnostics) const {
|
||||
return false;
|
||||
return media::DecodeSupport::Unsupported;
|
||||
}
|
||||
|
||||
/* static */
|
||||
|
@ -40,11 +40,12 @@ class GMPDecoderModule : public PlatformDecoderModule {
|
||||
already_AddRefed<MediaDataDecoder> CreateAudioDecoder(
|
||||
const CreateDecoderParams& aParams) override;
|
||||
|
||||
bool SupportsMimeType(const nsACString& aMimeType,
|
||||
DecoderDoctorDiagnostics* aDiagnostics) const override;
|
||||
media::DecodeSupportSet SupportsMimeType(
|
||||
const nsACString& aMimeType,
|
||||
DecoderDoctorDiagnostics* aDiagnostics) const override;
|
||||
|
||||
static bool SupportsMimeType(const nsACString& aMimeType,
|
||||
const Maybe<nsCString>& aGMP);
|
||||
static media::DecodeSupportSet SupportsMimeType(const nsACString& aMimeType,
|
||||
const Maybe<nsCString>& aGMP);
|
||||
|
||||
private:
|
||||
GMPDecoderModule() = default;
|
||||
|
@ -52,14 +52,17 @@ AndroidDecoderModule::AndroidDecoderModule(CDMProxy* aProxy) {
|
||||
|
||||
StaticAutoPtr<nsTArray<nsCString>> AndroidDecoderModule::sSupportedMimeTypes;
|
||||
|
||||
bool AndroidDecoderModule::SupportsMimeType(const nsACString& aMimeType) {
|
||||
media::DecodeSupportSet AndroidDecoderModule::SupportsMimeType(
|
||||
const nsACString& aMimeType) {
|
||||
if (jni::GetAPIVersion() < 16) {
|
||||
return false;
|
||||
return media::DecodeSupport::Unsupported;
|
||||
}
|
||||
|
||||
if (aMimeType.EqualsLiteral("video/mp4") ||
|
||||
aMimeType.EqualsLiteral("video/avc")) {
|
||||
return true;
|
||||
// TODO: Note that we do not yet distinguish between SW/HW decode support.
|
||||
// Will be done in bug 1754239.
|
||||
return media::DecodeSupport::SoftwareDecode;
|
||||
}
|
||||
|
||||
// When checking "audio/x-wav", CreateDecoder can cause a JNI ERROR by
|
||||
@ -71,14 +74,14 @@ bool AndroidDecoderModule::SupportsMimeType(const nsACString& aMimeType) {
|
||||
aMimeType.EqualsLiteral("audio/wave; codecs=6") ||
|
||||
aMimeType.EqualsLiteral("audio/wave; codecs=7") ||
|
||||
aMimeType.EqualsLiteral("audio/wave; codecs=65534")) {
|
||||
return false;
|
||||
return media::DecodeSupport::Unsupported;
|
||||
}
|
||||
|
||||
if ((VPXDecoder::IsVPX(aMimeType, VPXDecoder::VP8) &&
|
||||
!gfx::gfxVars::UseVP8HwDecode()) ||
|
||||
(VPXDecoder::IsVPX(aMimeType, VPXDecoder::VP9) &&
|
||||
!gfx::gfxVars::UseVP9HwDecode())) {
|
||||
return false;
|
||||
return media::DecodeSupport::Unsupported;
|
||||
}
|
||||
|
||||
// Prefer the gecko decoder for opus and vorbis; stagefright crashes
|
||||
@ -88,27 +91,31 @@ bool AndroidDecoderModule::SupportsMimeType(const nsACString& aMimeType) {
|
||||
VorbisDataDecoder::IsVorbis(aMimeType) ||
|
||||
aMimeType.EqualsLiteral("audio/flac")) {
|
||||
SLOG("Rejecting audio of type %s", aMimeType.Data());
|
||||
return false;
|
||||
return media::DecodeSupport::Unsupported;
|
||||
}
|
||||
|
||||
// Prefer the gecko decoder for Theora.
|
||||
// Not all android devices support Theora even when they say they do.
|
||||
if (TheoraDecoder::IsTheora(aMimeType)) {
|
||||
SLOG("Rejecting video of type %s", aMimeType.Data());
|
||||
return false;
|
||||
return media::DecodeSupport::Unsupported;
|
||||
}
|
||||
|
||||
if (aMimeType.EqualsLiteral("audio/mpeg") &&
|
||||
StaticPrefs::media_ffvpx_mp3_enabled()) {
|
||||
// Prefer the ffvpx mp3 software decoder if available.
|
||||
return false;
|
||||
return media::DecodeSupport::Unsupported;
|
||||
}
|
||||
|
||||
if (sSupportedMimeTypes) {
|
||||
return sSupportedMimeTypes->Contains(TranslateMimeType(aMimeType));
|
||||
if (sSupportedMimeTypes->Contains(TranslateMimeType(aMimeType))) {
|
||||
// TODO: Note that we do not yet distinguish between SW/HW decode support.
|
||||
// Will be done in bug 1754239.
|
||||
return media::DecodeSupport::SoftwareDecode;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
return media::DecodeSupport::Unsupported;
|
||||
}
|
||||
|
||||
nsTArray<nsCString> AndroidDecoderModule::GetSupportedMimeTypes() {
|
||||
@ -132,7 +139,7 @@ void AndroidDecoderModule::SetSupportedMimeTypes(
|
||||
}
|
||||
}
|
||||
|
||||
bool AndroidDecoderModule::SupportsMimeType(
|
||||
media::DecodeSupportSet AndroidDecoderModule::SupportsMimeType(
|
||||
const nsACString& aMimeType, DecoderDoctorDiagnostics* aDiagnostics) const {
|
||||
return AndroidDecoderModule::SupportsMimeType(aMimeType);
|
||||
}
|
||||
|
@ -25,10 +25,11 @@ class AndroidDecoderModule : public PlatformDecoderModule {
|
||||
already_AddRefed<MediaDataDecoder> CreateAudioDecoder(
|
||||
const CreateDecoderParams& aParams) override;
|
||||
|
||||
bool SupportsMimeType(const nsACString& aMimeType,
|
||||
DecoderDoctorDiagnostics* aDiagnostics) const override;
|
||||
media::DecodeSupportSet SupportsMimeType(
|
||||
const nsACString& aMimeType,
|
||||
DecoderDoctorDiagnostics* aDiagnostics) const override;
|
||||
|
||||
static bool SupportsMimeType(const nsACString& aMimeType);
|
||||
static media::DecodeSupportSet SupportsMimeType(const nsACString& aMimeType);
|
||||
|
||||
static nsTArray<nsCString> GetSupportedMimeTypes();
|
||||
|
||||
|
@ -54,7 +54,8 @@ nsresult AppleDecoderModule::Startup() {
|
||||
|
||||
already_AddRefed<MediaDataDecoder> AppleDecoderModule::CreateVideoDecoder(
|
||||
const CreateDecoderParams& aParams) {
|
||||
if (!Supports(SupportDecoderParams(aParams), nullptr /* diagnostics */)) {
|
||||
if (Supports(SupportDecoderParams(aParams), nullptr /* diagnostics */) ==
|
||||
media::DecodeSupport::Unsupported) {
|
||||
return nullptr;
|
||||
}
|
||||
RefPtr<MediaDataDecoder> decoder;
|
||||
@ -67,14 +68,15 @@ already_AddRefed<MediaDataDecoder> AppleDecoderModule::CreateVideoDecoder(
|
||||
|
||||
already_AddRefed<MediaDataDecoder> AppleDecoderModule::CreateAudioDecoder(
|
||||
const CreateDecoderParams& aParams) {
|
||||
if (!Supports(SupportDecoderParams(aParams), nullptr /* diagnostics */)) {
|
||||
if (Supports(SupportDecoderParams(aParams), nullptr /* diagnostics */) ==
|
||||
media::DecodeSupport::Unsupported) {
|
||||
return nullptr;
|
||||
}
|
||||
RefPtr<MediaDataDecoder> decoder = new AppleATDecoder(aParams.AudioConfig());
|
||||
return decoder.forget();
|
||||
}
|
||||
|
||||
bool AppleDecoderModule::SupportsMimeType(
|
||||
media::DecodeSupportSet AppleDecoderModule::SupportsMimeType(
|
||||
const nsACString& aMimeType, DecoderDoctorDiagnostics* aDiagnostics) const {
|
||||
bool supports = (aMimeType.EqualsLiteral("audio/mpeg") &&
|
||||
!StaticPrefs::media_ffvpx_mp3_enabled()) ||
|
||||
@ -83,18 +85,29 @@ bool AppleDecoderModule::SupportsMimeType(
|
||||
MOZ_LOG(sPDMLog, LogLevel::Debug,
|
||||
("Apple decoder %s requested type '%s'",
|
||||
supports ? "supports" : "rejects", aMimeType.BeginReading()));
|
||||
return supports;
|
||||
if (supports) {
|
||||
// TODO: Note that we do not yet distinguish between SW/HW decode support.
|
||||
// Will be done in bug 1754239.
|
||||
return media::DecodeSupport::SoftwareDecode;
|
||||
}
|
||||
return media::DecodeSupport::Unsupported;
|
||||
}
|
||||
|
||||
bool AppleDecoderModule::Supports(
|
||||
media::DecodeSupportSet AppleDecoderModule::Supports(
|
||||
const SupportDecoderParams& aParams,
|
||||
DecoderDoctorDiagnostics* aDiagnostics) const {
|
||||
const auto& trackInfo = aParams.mConfig;
|
||||
if (trackInfo.IsAudio()) {
|
||||
return SupportsMimeType(trackInfo.mMimeType, aDiagnostics);
|
||||
}
|
||||
return trackInfo.GetAsVideoInfo() &&
|
||||
IsVideoSupported(*trackInfo.GetAsVideoInfo());
|
||||
bool supports = trackInfo.GetAsVideoInfo() &&
|
||||
IsVideoSupported(*trackInfo.GetAsVideoInfo());
|
||||
if (supports) {
|
||||
// TODO: Note that we do not yet distinguish between SW/HW decode support.
|
||||
// Will be done in bug 1754239.
|
||||
return media::DecodeSupport::SoftwareDecode;
|
||||
}
|
||||
return media::DecodeSupport::Unsupported;
|
||||
}
|
||||
|
||||
bool AppleDecoderModule::IsVideoSupported(
|
||||
|
@ -28,11 +28,13 @@ class AppleDecoderModule : public PlatformDecoderModule {
|
||||
already_AddRefed<MediaDataDecoder> CreateAudioDecoder(
|
||||
const CreateDecoderParams& aParams) override;
|
||||
|
||||
bool SupportsMimeType(const nsACString& aMimeType,
|
||||
DecoderDoctorDiagnostics* aDiagnostics) const override;
|
||||
media::DecodeSupportSet SupportsMimeType(
|
||||
const nsACString& aMimeType,
|
||||
DecoderDoctorDiagnostics* aDiagnostics) const override;
|
||||
|
||||
bool Supports(const SupportDecoderParams& aParams,
|
||||
DecoderDoctorDiagnostics* aDiagnostics) const override;
|
||||
media::DecodeSupportSet Supports(
|
||||
const SupportDecoderParams& aParams,
|
||||
DecoderDoctorDiagnostics* aDiagnostics) const override;
|
||||
|
||||
static void Init();
|
||||
|
||||
|
@ -32,7 +32,8 @@ class FFmpegDecoderModule : public PlatformDecoderModule {
|
||||
|
||||
already_AddRefed<MediaDataDecoder> CreateVideoDecoder(
|
||||
const CreateDecoderParams& aParams) override {
|
||||
if (!Supports(SupportDecoderParams(aParams), nullptr)) {
|
||||
if (Supports(SupportDecoderParams(aParams), nullptr) ==
|
||||
media::DecodeSupport::Unsupported) {
|
||||
return nullptr;
|
||||
}
|
||||
RefPtr<MediaDataDecoder> decoder = new FFmpegVideoDecoder<V>(
|
||||
@ -46,7 +47,8 @@ class FFmpegDecoderModule : public PlatformDecoderModule {
|
||||
|
||||
already_AddRefed<MediaDataDecoder> CreateAudioDecoder(
|
||||
const CreateDecoderParams& aParams) override {
|
||||
if (!Supports(SupportDecoderParams(aParams), nullptr)) {
|
||||
if (Supports(SupportDecoderParams(aParams), nullptr) ==
|
||||
media::DecodeSupport::Unsupported) {
|
||||
return nullptr;
|
||||
}
|
||||
RefPtr<MediaDataDecoder> decoder =
|
||||
@ -54,17 +56,19 @@ class FFmpegDecoderModule : public PlatformDecoderModule {
|
||||
return decoder.forget();
|
||||
}
|
||||
|
||||
bool SupportsMimeType(const nsACString& aMimeType,
|
||||
DecoderDoctorDiagnostics* aDiagnostics) const override {
|
||||
media::DecodeSupportSet SupportsMimeType(
|
||||
const nsACString& aMimeType,
|
||||
DecoderDoctorDiagnostics* aDiagnostics) const override {
|
||||
UniquePtr<TrackInfo> trackInfo = CreateTrackInfoWithMIMEType(aMimeType);
|
||||
if (!trackInfo) {
|
||||
return false;
|
||||
return media::DecodeSupport::Unsupported;
|
||||
}
|
||||
return Supports(SupportDecoderParams(*trackInfo), aDiagnostics);
|
||||
}
|
||||
|
||||
bool Supports(const SupportDecoderParams& aParams,
|
||||
DecoderDoctorDiagnostics* aDiagnostics) const override {
|
||||
media::DecodeSupportSet Supports(
|
||||
const SupportDecoderParams& aParams,
|
||||
DecoderDoctorDiagnostics* aDiagnostics) const override {
|
||||
const auto& trackInfo = aParams.mConfig;
|
||||
const nsACString& mimeType = trackInfo.mMimeType;
|
||||
|
||||
@ -76,7 +80,7 @@ class FFmpegDecoderModule : public PlatformDecoderModule {
|
||||
MOZ_LOG(sPDMLog, LogLevel::Debug,
|
||||
("FFmpeg decoder rejects requested type '%s'",
|
||||
mimeType.BeginReading()));
|
||||
return false;
|
||||
return media::DecodeSupport::Unsupported;
|
||||
}
|
||||
|
||||
AVCodecID videoCodec = FFmpegVideoDecoder<V>::GetCodecId(mimeType);
|
||||
@ -85,14 +89,19 @@ class FFmpegDecoderModule : public PlatformDecoderModule {
|
||||
MOZ_LOG(sPDMLog, LogLevel::Debug,
|
||||
("FFmpeg decoder rejects requested type '%s'",
|
||||
mimeType.BeginReading()));
|
||||
return false;
|
||||
return media::DecodeSupport::Unsupported;
|
||||
}
|
||||
AVCodecID codec = audioCodec != AV_CODEC_ID_NONE ? audioCodec : videoCodec;
|
||||
bool supports = !!FFmpegDataDecoder<V>::FindAVCodec(mLib, codec);
|
||||
MOZ_LOG(sPDMLog, LogLevel::Debug,
|
||||
("FFmpeg decoder %s requested type '%s'",
|
||||
supports ? "supports" : "rejects", mimeType.BeginReading()));
|
||||
return supports;
|
||||
if (supports) {
|
||||
// TODO: Note that we do not yet distinguish between SW/HW decode support.
|
||||
// Will be done in bug 1754239.
|
||||
return media::DecodeSupport::SoftwareDecode;
|
||||
}
|
||||
return media::DecodeSupport::Unsupported;
|
||||
}
|
||||
|
||||
protected:
|
||||
|
@ -14,6 +14,7 @@ EXPORTS += [
|
||||
"agnostic/VPXDecoder.h",
|
||||
"agnostic/WAVDecoder.h",
|
||||
"AllocationPolicy.h",
|
||||
"MediaCodecsSupport.h",
|
||||
"MediaTelemetryConstants.h",
|
||||
"PDMFactory.h",
|
||||
"PEMFactory.h",
|
||||
|
@ -45,9 +45,14 @@ already_AddRefed<MediaDataDecoder> OmxDecoderModule::CreateAudioDecoder(
|
||||
return decoder.forget();
|
||||
}
|
||||
|
||||
bool OmxDecoderModule::SupportsMimeType(
|
||||
media::DecodeSupportSet OmxDecoderModule::SupportsMimeType(
|
||||
const nsACString& aMimeType, DecoderDoctorDiagnostics* aDiagnostics) const {
|
||||
return OmxPlatformLayer::SupportsMimeType(aMimeType);
|
||||
if (OmxPlatformLayer::SupportsMimeType(aMimeType)) {
|
||||
// TODO: Note that we do not yet distinguish between SW/HW decode support.
|
||||
// Will be done in bug 1754239.
|
||||
return media::DecodeSupport::SoftwareDecode;
|
||||
}
|
||||
return media::DecodeSupport::Unsupported;
|
||||
}
|
||||
|
||||
} // namespace mozilla
|
||||
|
@ -23,8 +23,9 @@ class OmxDecoderModule : public PlatformDecoderModule {
|
||||
already_AddRefed<MediaDataDecoder> CreateAudioDecoder(
|
||||
const CreateDecoderParams& aParams) override;
|
||||
|
||||
bool SupportsMimeType(const nsACString& aMimeType,
|
||||
DecoderDoctorDiagnostics* aDiagnostics) const override;
|
||||
media::DecodeSupportSet SupportsMimeType(
|
||||
const nsACString& aMimeType,
|
||||
DecoderDoctorDiagnostics* aDiagnostics) const override;
|
||||
};
|
||||
|
||||
} // namespace mozilla
|
||||
|
@ -301,14 +301,15 @@ WMFStreamType WMFDecoderModule::GetStreamTypeFromMimeType(
|
||||
return WMFStreamType::Unknown;
|
||||
}
|
||||
|
||||
bool WMFDecoderModule::Supports(const SupportDecoderParams& aParams,
|
||||
DecoderDoctorDiagnostics* aDiagnostics) const {
|
||||
media::DecodeSupportSet WMFDecoderModule::Supports(
|
||||
const SupportDecoderParams& aParams,
|
||||
DecoderDoctorDiagnostics* aDiagnostics) const {
|
||||
// In GPU process, only support decoding if video. This only gives a hint of
|
||||
// what the GPU decoder *may* support. The actual check will occur in
|
||||
// CreateVideoDecoder.
|
||||
const auto& trackInfo = aParams.mConfig;
|
||||
if (XRE_IsGPUProcess() && !trackInfo.GetAsVideoInfo()) {
|
||||
return false;
|
||||
return media::DecodeSupport::Unsupported;
|
||||
}
|
||||
|
||||
const auto* videoInfo = trackInfo.GetAsVideoInfo();
|
||||
@ -318,14 +319,21 @@ bool WMFDecoderModule::Supports(const SupportDecoderParams& aParams,
|
||||
// check.
|
||||
if (videoInfo && (!SupportsColorDepth(videoInfo->mColorDepth, aDiagnostics) ||
|
||||
videoInfo->HasAlpha())) {
|
||||
return false;
|
||||
return media::DecodeSupport::Unsupported;
|
||||
}
|
||||
|
||||
WMFStreamType type = GetStreamTypeFromMimeType(aParams.MimeType());
|
||||
if (type == WMFStreamType::Unknown) {
|
||||
return false;
|
||||
return media::DecodeSupport::Unsupported;
|
||||
}
|
||||
return CanCreateMFTDecoder(type);
|
||||
|
||||
if (CanCreateMFTDecoder(type)) {
|
||||
// TODO: Note that we do not yet distinguish between SW/HW decode support.
|
||||
// Will be done in bug 1754239.
|
||||
return media::DecodeSupport::SoftwareDecode;
|
||||
}
|
||||
|
||||
return media::DecodeSupport::Unsupported;
|
||||
}
|
||||
|
||||
nsresult WMFDecoderModule::Startup() {
|
||||
@ -409,17 +417,23 @@ already_AddRefed<MediaDataDecoder> WMFDecoderModule::CreateAudioDecoder(
|
||||
return decoder.forget();
|
||||
}
|
||||
|
||||
bool WMFDecoderModule::SupportsMimeType(
|
||||
media::DecodeSupportSet WMFDecoderModule::SupportsMimeType(
|
||||
const nsACString& aMimeType, DecoderDoctorDiagnostics* aDiagnostics) const {
|
||||
UniquePtr<TrackInfo> trackInfo = CreateTrackInfoWithMIMEType(aMimeType);
|
||||
if (!trackInfo) {
|
||||
return false;
|
||||
return media::DecodeSupport::Unsupported;
|
||||
}
|
||||
bool supports = Supports(SupportDecoderParams(*trackInfo), aDiagnostics);
|
||||
bool supports = Supports(SupportDecoderParams(*trackInfo), aDiagnostics) !=
|
||||
media::DecodeSupport::Unsupported;
|
||||
MOZ_LOG(sPDMLog, LogLevel::Debug,
|
||||
("WMF decoder %s requested type '%s'",
|
||||
supports ? "supports" : "rejects", aMimeType.BeginReading()));
|
||||
return supports;
|
||||
if (!supports) {
|
||||
return media::DecodeSupport::Unsupported;
|
||||
}
|
||||
// TODO: Note that we do not yet distinguish between SW/HW decode support.
|
||||
// Will be done in bug 1754239.
|
||||
return media::DecodeSupport::SoftwareDecode;
|
||||
}
|
||||
|
||||
} // namespace mozilla
|
||||
|
@ -29,10 +29,12 @@ class WMFDecoderModule : public PlatformDecoderModule {
|
||||
already_AddRefed<MediaDataDecoder> CreateAudioDecoder(
|
||||
const CreateDecoderParams& aParams) override;
|
||||
|
||||
bool SupportsMimeType(const nsACString& aMimeType,
|
||||
DecoderDoctorDiagnostics* aDiagnostics) const override;
|
||||
bool Supports(const SupportDecoderParams& aParams,
|
||||
DecoderDoctorDiagnostics* aDiagnostics) const override;
|
||||
media::DecodeSupportSet SupportsMimeType(
|
||||
const nsACString& aMimeType,
|
||||
DecoderDoctorDiagnostics* aDiagnostics) const override;
|
||||
media::DecodeSupportSet Supports(
|
||||
const SupportDecoderParams& aParams,
|
||||
DecoderDoctorDiagnostics* aDiagnostics) const override;
|
||||
|
||||
// Called on main thread.
|
||||
static void Init();
|
||||
|
Loading…
Reference in New Issue
Block a user