mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-24 10:45:42 +00:00
Bug 1330284 - Use MediaContentType in MP3Decoder - r=jya
MozReview-Commit-ID: eahpZyDfgH --HG-- extra : rebase_source : 55d188aadcf0cd25b8dc512cf9eaefc996a82940
This commit is contained in:
parent
f3a92fa0a6
commit
f1181d5b1b
@ -112,13 +112,6 @@ DecoderTraits::IsMP4SupportedType(const MediaContentType& aType,
|
||||
#endif
|
||||
}
|
||||
|
||||
static bool
|
||||
IsMP3SupportedType(const nsACString& aType,
|
||||
const nsAString& aCodecs = EmptyString())
|
||||
{
|
||||
return MP3Decoder::CanHandleMediaType(aType, aCodecs);
|
||||
}
|
||||
|
||||
static bool
|
||||
IsAACSupportedType(const nsACString& aType,
|
||||
const nsAString& aCodecs = EmptyString())
|
||||
@ -194,8 +187,7 @@ CanHandleCodecsType(const MediaContentType& aType,
|
||||
}
|
||||
}
|
||||
#endif
|
||||
if (IsMP3SupportedType(mimeType.Type().AsString(),
|
||||
aType.ExtendedType().Codecs().AsString())) {
|
||||
if (MP3Decoder::IsSupportedType(aType)) {
|
||||
return CANPLAY_YES;
|
||||
}
|
||||
if (IsAACSupportedType(mimeType.Type().AsString(),
|
||||
@ -278,7 +270,7 @@ CanHandleMediaType(const MediaContentType& aType,
|
||||
return CANPLAY_MAYBE;
|
||||
}
|
||||
#endif
|
||||
if (IsMP3SupportedType(mimeType.Type().AsString())) {
|
||||
if (MP3Decoder::IsSupportedType(mimeType)) {
|
||||
return CANPLAY_MAYBE;
|
||||
}
|
||||
if (IsAACSupportedType(mimeType.Type().AsString())) {
|
||||
@ -357,7 +349,7 @@ InstantiateDecoder(const MediaContentType& aType,
|
||||
return decoder.forget();
|
||||
}
|
||||
#endif
|
||||
if (IsMP3SupportedType(aType.Type().AsString())) {
|
||||
if (MP3Decoder::IsSupportedType(aType)) {
|
||||
decoder = new MP3Decoder(aOwner);
|
||||
return decoder.forget();
|
||||
}
|
||||
@ -442,7 +434,7 @@ MediaDecoderReader* DecoderTraits::CreateReader(const nsACString& aType, Abstrac
|
||||
decoderReader = new MediaFormatReader(aDecoder, new MP4Demuxer(aDecoder->GetResource()));
|
||||
} else
|
||||
#endif
|
||||
if (IsMP3SupportedType(aType)) {
|
||||
if (MP3Decoder::IsSupportedType(*type)) {
|
||||
decoderReader = new MediaFormatReader(aDecoder, new mp3::MP3Demuxer(aDecoder->GetResource()));
|
||||
} else
|
||||
if (IsAACSupportedType(aType)) {
|
||||
@ -502,7 +494,7 @@ bool DecoderTraits::IsSupportedInVideoDocument(const nsACString& aType)
|
||||
#ifdef MOZ_FMP4
|
||||
MP4Decoder::IsSupportedType(*type, /* DecoderDoctorDiagnostics* */ nullptr) ||
|
||||
#endif
|
||||
IsMP3SupportedType(aType) ||
|
||||
MP3Decoder::IsSupportedType(*type) ||
|
||||
IsAACSupportedType(aType) ||
|
||||
IsFlacSupportedType(aType) ||
|
||||
#ifdef MOZ_DIRECTSHOW
|
||||
|
@ -6,6 +6,7 @@
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "MP3Decoder.h"
|
||||
#include "MediaContentType.h"
|
||||
#include "MediaDecoderStateMachine.h"
|
||||
#include "MediaFormatReader.h"
|
||||
#include "MP3Demuxer.h"
|
||||
@ -37,12 +38,14 @@ MP3Decoder::IsEnabled() {
|
||||
}
|
||||
|
||||
/* static */
|
||||
bool MP3Decoder::CanHandleMediaType(const nsACString& aType,
|
||||
const nsAString& aCodecs)
|
||||
bool MP3Decoder::IsSupportedType(const MediaContentType& aContentType)
|
||||
{
|
||||
if (aType.EqualsASCII("audio/mp3") || aType.EqualsASCII("audio/mpeg")) {
|
||||
return IsEnabled() &&
|
||||
(aCodecs.IsEmpty() || aCodecs.EqualsASCII("mp3"));
|
||||
if (aContentType.Type() == MEDIAMIMETYPE("audio/mp3")
|
||||
|| aContentType.Type() == MEDIAMIMETYPE("audio/mpeg")) {
|
||||
return
|
||||
IsEnabled()
|
||||
&& (aContentType.ExtendedType().Codecs().IsEmpty()
|
||||
|| aContentType.ExtendedType().Codecs().AsString().EqualsASCII("mp3"));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -10,7 +10,10 @@
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
class MP3Decoder : public MediaDecoder {
|
||||
class MediaContentType;
|
||||
|
||||
class MP3Decoder : public MediaDecoder
|
||||
{
|
||||
public:
|
||||
// MediaDecoder interface.
|
||||
explicit MP3Decoder(MediaDecoderOwner* aOwner) : MediaDecoder(aOwner) {}
|
||||
@ -20,8 +23,7 @@ public:
|
||||
// Returns true if the MP3 backend is preffed 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
|
||||
|
Loading…
Reference in New Issue
Block a user