Bug 1390748 - Create DecoderTraits::IsSupportedType(const MediaContainerType&). r=jwwang

Most ChannelMediaDecoder::CloneImpl() functions just check to see whether
their "is enabled" pref is still true, and then clone their true type.

If we had a function to check whether the decoder for an arbitrary type
was still enabled, we'd not need the "is enabled" checks in the CloneImpl()
implementations. We'd then have removed the last custom behaviour in the
ChannelMediaDecoder subclasses.


MozReview-Commit-ID: D7kW6kb6ztW

--HG--
extra : rebase_source : f463785d2975adceffd62037315d169736effbc0
This commit is contained in:
Chris Pearce 2017-08-15 17:38:16 +12:00
Родитель a0917579b4
Коммит fa780c5329
4 изменённых файлов: 37 добавлений и 0 удалений

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

@ -323,6 +323,30 @@ 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)
{

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

@ -65,6 +65,8 @@ public:
// Returns true if aType is MIME type of hls.
static bool IsHttpLiveStreamingType(const MediaContainerType& aType);
static bool IsSupportedType(const MediaContainerType& aType);
};
} // namespace mozilla

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

@ -55,6 +55,14 @@ IsWhitelistedH264Codec(const nsAString& aCodec)
profile == H264_PROFILE_HIGH);
}
/* static */
bool
MP4Decoder::IsSupportedTypeWithoutDiagnostics(
const MediaContainerType& aContainerType)
{
return IsSupportedType(aContainerType, nullptr);
}
/* static */
bool
MP4Decoder::IsSupportedType(const MediaContainerType& aType,

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

@ -26,6 +26,9 @@ public:
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.