Bug 1350246 - [Part5] Move IsHttpLiveStreamingType from DecoderTraits.cpp to its .h. and modify the callers related to this change. draft
authorJames Cheng <jacheng@mozilla.com>
Thu, 18 May 2017 14:47:55 +0800
changeset 592557 a2e46ed434e90ffc3f41eb907cd5283684cf1483
parent 592556 3b8ce8f1996ac4195c400ea02d671fa482b39180
child 592558 5b20044cb06dafb2064d19f151e5d20ed8a20986
push id63431
push userbmo:jacheng@mozilla.com
push dateMon, 12 Jun 2017 12:38:14 +0000
bugs1350246
milestone55.0a1
Bug 1350246 - [Part5] Move IsHttpLiveStreamingType from DecoderTraits.cpp to its .h. and modify the callers related to this change. MozReview-Commit-ID: 8lT9rUDmLvD
dom/media/DecoderTraits.cpp
dom/media/DecoderTraits.h
--- 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