Bug 1330284 - Use MediaContentType in FlacDecoder - r=jya

MozReview-Commit-ID: IwD2aXAmuQ4

--HG--
extra : rebase_source : 193701b54c86655568eefe01a6df10ba869494f6
This commit is contained in:
Gerald Squelart 2016-12-20 19:24:17 +11:00
parent 02d0ccb22f
commit 588d91b674
3 changed files with 18 additions and 22 deletions

View File

@ -112,13 +112,6 @@ DecoderTraits::IsMP4SupportedType(const MediaContentType& aType,
#endif
}
static bool
IsFlacSupportedType(const nsACString& aType,
const nsAString& aCodecs = EmptyString())
{
return FlacDecoder::CanHandleMediaType(aType, aCodecs);
}
static
CanPlayStatus
CanHandleCodecsType(const MediaContentType& aType,
@ -178,8 +171,7 @@ CanHandleCodecsType(const MediaContentType& aType,
if (ADTSDecoder::IsSupportedType(aType)) {
return CANPLAY_YES;
}
if (IsFlacSupportedType(mimeType.Type().AsString(),
aType.ExtendedType().Codecs().AsString())) {
if (FlacDecoder::IsSupportedType(aType)) {
return CANPLAY_YES;
}
#ifdef MOZ_DIRECTSHOW
@ -260,7 +252,7 @@ CanHandleMediaType(const MediaContentType& aType,
if (ADTSDecoder::IsSupportedType(mimeType)) {
return CANPLAY_MAYBE;
}
if (IsFlacSupportedType(mimeType.Type().AsString())) {
if (FlacDecoder::IsSupportedType(mimeType)) {
return CANPLAY_MAYBE;
}
#ifdef MOZ_DIRECTSHOW
@ -349,7 +341,7 @@ InstantiateDecoder(const MediaContentType& aType,
decoder = new WaveDecoder(aOwner);
return decoder.forget();
}
if (IsFlacSupportedType(aType.Type().AsString())) {
if (FlacDecoder::IsSupportedType(aType)) {
decoder = new FlacDecoder(aOwner);
return decoder.forget();
}
@ -427,7 +419,7 @@ MediaDecoderReader* DecoderTraits::CreateReader(const nsACString& aType, Abstrac
if (WaveDecoder::IsSupportedType(*type)) {
decoderReader = new MediaFormatReader(aDecoder, new WAVDemuxer(aDecoder->GetResource()));
} else
if (IsFlacSupportedType(aType)) {
if (FlacDecoder::IsSupportedType(*type)) {
decoderReader = new MediaFormatReader(aDecoder, new FlacDemuxer(aDecoder->GetResource()));
} else
if (OggDecoder::IsSupportedType(*type)) {
@ -480,7 +472,7 @@ bool DecoderTraits::IsSupportedInVideoDocument(const nsACString& aType)
#endif
MP3Decoder::IsSupportedType(*type) ||
ADTSDecoder::IsSupportedType(*type) ||
IsFlacSupportedType(aType) ||
FlacDecoder::IsSupportedType(*type) ||
#ifdef MOZ_DIRECTSHOW
IsDirectShowSupportedType(aType) ||
#endif

View File

@ -6,6 +6,7 @@
#include "FlacDecoder.h"
#include "FlacDemuxer.h"
#include "MediaContentType.h"
#include "MediaDecoderStateMachine.h"
#include "MediaFormatReader.h"
#include "MediaPrefs.h"
@ -15,8 +16,9 @@ namespace mozilla {
MediaDecoder*
FlacDecoder::Clone(MediaDecoderOwner* aOwner)
{
if (!IsEnabled())
if (!IsEnabled()) {
return nullptr;
}
return new FlacDecoder(aOwner);
}
@ -41,12 +43,12 @@ FlacDecoder::IsEnabled()
}
/* static */ bool
FlacDecoder::CanHandleMediaType(const nsACString& aType,
const nsAString& aCodecs)
FlacDecoder::IsSupportedType(const MediaContentType& aContentType)
{
return IsEnabled() &&
(aType.EqualsASCII("audio/flac") || aType.EqualsASCII("audio/x-flac") ||
aType.EqualsASCII("application/x-flac"));
return IsEnabled()
&& (aContentType.Type() == MEDIAMIMETYPE("audio/flac")
|| aContentType.Type() == MEDIAMIMETYPE("audio/x-flac")
|| aContentType.Type() == MEDIAMIMETYPE("application/x-flac"));
}
} // namespace mozilla

View File

@ -11,7 +11,10 @@
namespace mozilla {
class FlacDecoder : public MediaDecoder {
class MediaContentType;
class FlacDecoder : public MediaDecoder
{
public:
// MediaDecoder interface.
explicit FlacDecoder(MediaDecoderOwner* aOwner) : MediaDecoder(aOwner) {}
@ -21,8 +24,7 @@ public:
// Returns true if the Flac backend is pref'ed on, and we're running on a
// platform that is likely to have decoders for the format.
static bool IsEnabled();
static bool CanHandleMediaType(const nsACString& aType,
const nsAString& aCodecs);
static bool IsSupportedType(const MediaContentType& aContentType);
};
} // namespace mozilla