Bug 1350246 - [Part5] Move IsHttpLiveStreamingType from DecoderTraits.cpp to its .h. and modify the callers related to this change.
MozReview-Commit-ID: 8lT9rUDmLvD
--- a/dom/media/DecoderTraits.cpp
+++ b/dom/media/DecoderTraits.cpp
@@ -40,43 +40,43 @@
#include "FlacDecoder.h"
#include "FlacDemuxer.h"
#include "nsPluginHost.h"
#include "MediaPrefs.h"
namespace mozilla
{
-
-static bool
-IsHttpLiveStreamingType(const MediaContainerType& aType)
-{
- return // For m3u8.
- // https://tools.ietf.org/html/draft-pantos-http-live-streaming-19#section-10
- aType.Type() == MEDIAMIMETYPE("application/vnd.apple.mpegurl")
- // Some sites serve these as the informal m3u type.
- || aType.Type() == MEDIAMIMETYPE("application/x-mpegurl")
- || aType.Type() == MEDIAMIMETYPE("audio/x-mpegurl");
-}
-
#ifdef MOZ_ANDROID_OMX
static bool
IsAndroidMediaType(const MediaContainerType& aType)
{
if (!MediaDecoder::IsAndroidMediaPluginEnabled()) {
return false;
}
return aType.Type() == MEDIAMIMETYPE("audio/mpeg")
|| aType.Type() == MEDIAMIMETYPE("audio/mp4")
|| aType.Type() == MEDIAMIMETYPE("video/mp4")
|| aType.Type() == MEDIAMIMETYPE("video/x-m4v");
}
#endif
+
+/* static */ bool
+DecoderTraits::IsHttpLiveStreamingType(const MediaContainerType& aType)
+{
+ return // For m3u8.
+ // https://tools.ietf.org/html/draft-pantos-http-live-streaming-19#section-10
+ aType.Type() == MEDIAMIMETYPE("application/vnd.apple.mpegurl")
+ // Some sites serve these as the informal m3u type.
+ || aType.Type() == MEDIAMIMETYPE("application/x-mpegurl")
+ || aType.Type() == MEDIAMIMETYPE("audio/x-mpegurl");
+}
+
/* static */ bool
DecoderTraits::IsMP4SupportedType(const MediaContainerType& aType,
DecoderDoctorDiagnostics* aDiagnostics)
{
#ifdef MOZ_FMP4
return MP4Decoder::IsSupportedType(aType, aDiagnostics);
#else
return false;
@@ -160,17 +160,17 @@ CanHandleCodecsType(const MediaContainer
static
CanPlayStatus
CanHandleMediaType(const MediaContainerType& aType,
DecoderDoctorDiagnostics* aDiagnostics)
{
MOZ_ASSERT(NS_IsMainThread());
- if (IsHttpLiveStreamingType(aType)) {
+ if (DecoderTraits::IsHttpLiveStreamingType(aType)) {
Telemetry::Accumulate(Telemetry::MEDIA_HLS_CANPLAY_REQUESTED, true);
}
if (aType.ExtendedType().HaveCodecs()) {
CanPlayStatus result = CanHandleCodecsType(aType, aDiagnostics);
if (result == CANPLAY_NO || result == CANPLAY_YES) {
return result;
}
@@ -297,17 +297,17 @@ InstantiateDecoder(const MediaContainerT
}
#endif
if (WebMDecoder::IsSupportedType(aType)) {
decoder = new WebMDecoder(aInit);
return decoder.forget();
}
- if (IsHttpLiveStreamingType(aType)) {
+ if (DecoderTraits::IsHttpLiveStreamingType(aType)) {
// We don't have an HLS decoder.
Telemetry::Accumulate(Telemetry::MEDIA_HLS_DECODER_SUCCESS, false);
}
return nullptr;
}
/* static */
--- a/dom/media/DecoderTraits.h
+++ b/dom/media/DecoderTraits.h
@@ -56,14 +56,17 @@ public:
// or false otherwise. Not all platforms support all MIME types, and
// vice versa.
static bool IsSupportedInVideoDocument(const nsACString& aType);
// Convenience function that returns false if MOZ_FMP4 is not defined,
// otherwise defers to MP4Decoder::IsSupportedType().
static bool IsMP4SupportedType(const MediaContainerType& aType,
DecoderDoctorDiagnostics* aDiagnostics);
+
+ // Returns true if aType is MIME type of hls.
+ static bool IsHttpLiveStreamingType(const MediaContainerType& aType);
};
} // namespace mozilla
#endif