Bug 1330284 - Use MediaContentType in DirectShowDecoder - r?jya
MozReview-Commit-ID: JKBAUVH49If
--- a/dom/media/DecoderTraits.cpp
+++ b/dom/media/DecoderTraits.cpp
@@ -88,24 +88,16 @@ IsAndroidMediaType(const nsACString& aTy
static const char* supportedTypes[] = {
"audio/mpeg", "audio/mp4", "video/mp4", "video/x-m4v", nullptr
};
return CodecListContains(supportedTypes, aType);
}
#endif
-#ifdef MOZ_DIRECTSHOW
-static bool
-IsDirectShowSupportedType(const nsACString& aType)
-{
- return DirectShowDecoder::GetSupportedCodecs(aType, nullptr);
-}
-#endif
-
/* static */ bool
DecoderTraits::IsMP4SupportedType(const MediaContentType& aType,
DecoderDoctorDiagnostics* aDiagnostics)
{
#ifdef MOZ_FMP4
return MP4Decoder::IsSupportedType(aType, aDiagnostics);
#else
return false;
@@ -170,17 +162,17 @@ CanHandleCodecsType(const MediaContentTy
}
if (ADTSDecoder::IsSupportedType(aType)) {
return CANPLAY_YES;
}
if (FlacDecoder::IsSupportedType(aType)) {
return CANPLAY_YES;
}
#ifdef MOZ_DIRECTSHOW
- DirectShowDecoder::GetSupportedCodecs(aType.Type().AsString(), &codecList);
+ DirectShowDecoder::GetSupportedCodecs(aType, &codecList);
#endif
#ifdef MOZ_ANDROID_OMX
if (MediaDecoder::IsAndroidMediaPluginEnabled()) {
EnsureAndroidMediaPluginHost()->FindDecoder(aType.Type().AsString(),
&codecList);
}
#endif
if (!codecList) {
@@ -251,17 +243,17 @@ CanHandleMediaType(const MediaContentTyp
}
if (ADTSDecoder::IsSupportedType(mimeType)) {
return CANPLAY_MAYBE;
}
if (FlacDecoder::IsSupportedType(mimeType)) {
return CANPLAY_MAYBE;
}
#ifdef MOZ_DIRECTSHOW
- if (DirectShowDecoder::GetSupportedCodecs(mimeType.Type().AsString(), nullptr)) {
+ if (DirectShowDecoder::GetSupportedCodecs(mimeType, nullptr)) {
return CANPLAY_MAYBE;
}
#endif
#ifdef MOZ_ANDROID_OMX
if (MediaDecoder::IsAndroidMediaPluginEnabled() &&
EnsureAndroidMediaPluginHost()->FindDecoder(mimeType.Type().AsString(), nullptr)) {
return CANPLAY_MAYBE;
}
@@ -357,17 +349,17 @@ InstantiateDecoder(const MediaContentTyp
if (WebMDecoder::IsSupportedType(aType)) {
decoder = new WebMDecoder(aOwner);
return decoder.forget();
}
#ifdef MOZ_DIRECTSHOW
// Note: DirectShow should come before WMF, so that we prefer DirectShow's
// MP3 support over WMF's.
- if (IsDirectShowSupportedType(aType.Type().AsString())) {
+ if (DirectShowDecoder::GetSupportedCodecs(aType, nullptr)) {
decoder = new DirectShowDecoder(aOwner);
return decoder.forget();
}
#endif
if (IsHttpLiveStreamingType(aType.Type().AsString())) {
// We don't have an HLS decoder.
Telemetry::Accumulate(Telemetry::MEDIA_HLS_DECODER_SUCCESS, false);
@@ -431,17 +423,17 @@ MediaDecoderReader* DecoderTraits::Creat
decoderReader = new AndroidMediaReader(aDecoder, aType);
} else
#endif
if (WebMDecoder::IsSupportedType(*type)) {
decoderReader =
new MediaFormatReader(aDecoder, new WebMDemuxer(aDecoder->GetResource()));
} else
#ifdef MOZ_DIRECTSHOW
- if (IsDirectShowSupportedType(aType)) {
+ if (DirectShowDecoder::GetSupportedCodecs(*type, nullptr)) {
decoderReader = new DirectShowReader(aDecoder);
} else
#endif
if (false) {} // dummy if to take care of the dangling else
return decoderReader;
}
@@ -469,14 +461,14 @@ bool DecoderTraits::IsSupportedInVideoDo
#endif
#ifdef MOZ_FMP4
MP4Decoder::IsSupportedType(*type, /* DecoderDoctorDiagnostics* */ nullptr) ||
#endif
MP3Decoder::IsSupportedType(*type) ||
ADTSDecoder::IsSupportedType(*type) ||
FlacDecoder::IsSupportedType(*type) ||
#ifdef MOZ_DIRECTSHOW
- IsDirectShowSupportedType(aType) ||
+ DirectShowDecoder::GetSupportedCodecs(*type, nullptr) ||
#endif
false;
}
} // namespace mozilla
--- a/dom/media/directshow/DirectShowDecoder.cpp
+++ b/dom/media/directshow/DirectShowDecoder.cpp
@@ -2,42 +2,43 @@
/* 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/. */
#include "DirectShowDecoder.h"
#include "DirectShowReader.h"
#include "DirectShowUtils.h"
+#include "MediaContentType.h"
#include "MediaDecoderStateMachine.h"
#include "mozilla/Preferences.h"
#include "mozilla/WindowsVersion.h"
namespace mozilla {
MediaDecoderStateMachine* DirectShowDecoder::CreateStateMachine()
{
return new MediaDecoderStateMachine(this, new DirectShowReader(this));
}
/* static */
bool
-DirectShowDecoder::GetSupportedCodecs(const nsACString& aType,
+DirectShowDecoder::GetSupportedCodecs(const MediaContentType& aType,
char const *const ** aCodecList)
{
if (!IsEnabled()) {
return false;
}
static char const *const mp3AudioCodecs[] = {
"mp3",
nullptr
};
- if (aType.EqualsASCII("audio/mpeg") ||
- aType.EqualsASCII("audio/mp3")) {
+ if (aType.Type() == MEDIAMIMETYPE("audio/mpeg")
+ || aType.Type() == MEDIAMIMETYPE("audio/mp3")) {
if (aCodecList) {
*aCodecList = mp3AudioCodecs;
}
return true;
}
return false;
}
--- a/dom/media/directshow/DirectShowDecoder.h
+++ b/dom/media/directshow/DirectShowDecoder.h
@@ -6,16 +6,18 @@
#if !defined(DirectShowDecoder_h_)
#define DirectShowDecoder_h_
#include "MediaDecoder.h"
namespace mozilla {
+class MediaContentType;
+
// Decoder that uses DirectShow to playback MP3 files only.
class DirectShowDecoder : public MediaDecoder
{
public:
explicit DirectShowDecoder(MediaDecoderOwner* aOwner);
virtual ~DirectShowDecoder();
@@ -28,17 +30,17 @@ public:
MediaDecoderStateMachine* CreateStateMachine() override;
// Returns true if aType is a MIME type that we render with the
// DirectShow backend. If aCodecList is non null,
// it is filled with a (static const) null-terminated list of strings
// denoting the codecs we'll playback. Note that playback is strictly
// limited to MP3 only.
- static bool GetSupportedCodecs(const nsACString& aType,
+ static bool GetSupportedCodecs(const MediaContentType& aType,
char const *const ** aCodecList);
// Returns true if the DirectShow backend is preffed on.
static bool IsEnabled();
};
} // namespace mozilla