Bug 1690661 - use `CanHandleContainerType()` for asking if the container type is supported. r=bryce

Doing that allows us to accquire the error information from the `DecoderDoctorDiagnostics`.

Differential Revision: https://phabricator.services.mozilla.com/D106676
This commit is contained in:
alwu 2021-03-01 20:30:58 +00:00
Родитель c24ecdc6f5
Коммит 62fa458f40
5 изменённых файлов: 4 добавлений и 37 удалений

Просмотреть файл

@ -172,9 +172,8 @@ already_AddRefed<ChannelMediaDecoder> ChannelMediaDecoder::Create(
MediaDecoderInit& aInit, DecoderDoctorDiagnostics* aDiagnostics) {
MOZ_ASSERT(NS_IsMainThread());
RefPtr<ChannelMediaDecoder> decoder;
const MediaContainerType& type = aInit.mContainerType;
if (DecoderTraits::IsSupportedType(type)) {
if (DecoderTraits::CanHandleContainerType(aInit.mContainerType,
aDiagnostics) != CANPLAY_NO) {
decoder = new ChannelMediaDecoder(aInit);
return decoder.forget();
}
@ -189,7 +188,8 @@ bool ChannelMediaDecoder::CanClone() {
already_AddRefed<ChannelMediaDecoder> ChannelMediaDecoder::Clone(
MediaDecoderInit& aInit) {
if (!mResource || !DecoderTraits::IsSupportedType(aInit.mContainerType)) {
if (!mResource || DecoderTraits::CanHandleContainerType(
aInit.mContainerType, nullptr) == CANPLAY_NO) {
return nullptr;
}
RefPtr<ChannelMediaDecoder> decoder = new ChannelMediaDecoder(aInit);

Просмотреть файл

@ -281,28 +281,6 @@ MediaFormatReader* DecoderTraits::CreateReader(const MediaContainerType& aType,
return decoderReader;
}
/* static */
bool DecoderTraits::IsSupportedType(const MediaContainerType& aType) {
typedef bool (*IsSupportedFunction)(const MediaContainerType& aType);
static const IsSupportedFunction funcs[] = {
&ADTSDecoder::IsSupportedType,
&FlacDecoder::IsSupportedType,
&MP3Decoder::IsSupportedType,
#ifdef MOZ_FMP4
&MP4Decoder::IsSupportedTypeWithoutDiagnostics,
#endif
&OggDecoder::IsSupportedType,
&WaveDecoder::IsSupportedType,
&WebMDecoder::IsSupportedType,
};
for (IsSupportedFunction func : funcs) {
if (func(aType)) {
return true;
}
}
return false;
}
/* static */
bool DecoderTraits::IsSupportedInVideoDocument(const nsACString& aType) {
// Forbid playing media in video documents if the user has opted

Просмотреть файл

@ -63,8 +63,6 @@ class DecoderTraits {
// Returns true if aType is matroska type.
static bool IsMatroskaType(const MediaContainerType& aType);
static bool IsSupportedType(const MediaContainerType& aType);
// Returns an array of all TrackInfo objects described by this type.
static nsTArray<UniquePtr<TrackInfo>> GetTracksInfo(
const MediaContainerType& aType);

Просмотреть файл

@ -39,12 +39,6 @@ static bool IsWhitelistedH264Codec(const nsAString& aCodec) {
profile == H264_PROFILE_EXTENDED || profile == H264_PROFILE_HIGH);
}
/* static */
bool MP4Decoder::IsSupportedTypeWithoutDiagnostics(
const MediaContainerType& aContainerType) {
return IsSupportedType(aContainerType, nullptr);
}
static bool IsTypeValid(const MediaContainerType& aType) {
// 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

Просмотреть файл

@ -26,9 +26,6 @@ class MP4Decoder {
static bool IsSupportedType(const MediaContainerType& aContainerType,
DecoderDoctorDiagnostics* aDiagnostics);
static bool IsSupportedTypeWithoutDiagnostics(
const MediaContainerType& aContainerType);
// 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.