Bug 1350246 - [Part6] Use DecoderTraits::IsHttpLiveStreamingType to implement HLSDecoder::IsSupportedType and use HLSDecoder::IsSupportedType to implement the following APIs for mimetype of HLS. draft
authorJames Cheng <jacheng@mozilla.com>
Wed, 31 May 2017 18:37:23 +0800
changeset 592558 5b20044cb06dafb2064d19f151e5d20ed8a20986
parent 592557 a2e46ed434e90ffc3f41eb907cd5283684cf1483
child 592559 bcb1f3426052aa24ddd031cb1e12b363bb3727dd
push id63431
push userbmo:jacheng@mozilla.com
push dateMon, 12 Jun 2017 12:38:14 +0000
bugs1350246
milestone55.0a1
Bug 1350246 - [Part6] Use DecoderTraits::IsHttpLiveStreamingType to implement HLSDecoder::IsSupportedType and use HLSDecoder::IsSupportedType to implement the following APIs for mimetype of HLS. (1) Check if we should instantiate HLSDecoder in DecoderTraits::InstantiateDecoder. (2) Reply CANPLAY_MAYBE in CanHandleMediaType on Fennec. MozReview-Commit-ID: 4Y6Ju5yk6ha
dom/media/DecoderTraits.cpp
dom/media/hls/HLSDecoder.cpp
--- a/dom/media/DecoderTraits.cpp
+++ b/dom/media/DecoderTraits.cpp
@@ -17,16 +17,19 @@
 #include "WebMDecoder.h"
 #include "WebMDemuxer.h"
 
 #ifdef MOZ_ANDROID_OMX
 #include "AndroidMediaDecoder.h"
 #include "AndroidMediaReader.h"
 #include "AndroidMediaPluginHost.h"
 #endif
+#ifdef MOZ_ANDROID_HLS_SUPPORT
+#include "HLSDecoder.h"
+#endif
 #ifdef MOZ_FMP4
 #include "MP4Decoder.h"
 #include "MP4Demuxer.h"
 #endif
 #include "MediaFormatReader.h"
 
 #include "MP3Decoder.h"
 #include "MP3Demuxer.h"
@@ -160,16 +163,22 @@ CanHandleCodecsType(const MediaContainer
 
 static
 CanPlayStatus
 CanHandleMediaType(const MediaContainerType& aType,
                    DecoderDoctorDiagnostics* aDiagnostics)
 {
   MOZ_ASSERT(NS_IsMainThread());
 
+#ifdef MOZ_ANDROID_HLS_SUPPORT
+  if (HLSDecoder::IsSupportedType(aType)) {
+    return CANPLAY_MAYBE;
+  }
+#endif
+
   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;
@@ -258,16 +267,22 @@ static
 already_AddRefed<MediaDecoder>
 InstantiateDecoder(const MediaContainerType& aType,
                    MediaDecoderInit& aInit,
                    DecoderDoctorDiagnostics* aDiagnostics)
 {
   MOZ_ASSERT(NS_IsMainThread());
   RefPtr<MediaDecoder> decoder;
 
+#ifdef MOZ_ANDROID_HLS_SUPPORT
+  if (HLSDecoder::IsSupportedType(aType)) {
+    decoder = new HLSDecoder(aInit);
+    return decoder.forget();
+  }
+#endif
 #ifdef MOZ_FMP4
   if (MP4Decoder::IsSupportedType(aType, aDiagnostics)) {
     decoder = new MP4Decoder(aInit);
     return decoder.forget();
   }
 #endif
   if (MP3Decoder::IsSupportedType(aType)) {
     decoder = new MP3Decoder(aInit);
--- a/dom/media/hls/HLSDecoder.cpp
+++ b/dom/media/hls/HLSDecoder.cpp
@@ -42,12 +42,13 @@ bool
 HLSDecoder::IsEnabled()
 {
   return MediaPrefs::HLSEnabled() && (jni::GetAPIVersion() >= 16);
 }
 
 bool
 HLSDecoder::IsSupportedType(const MediaContainerType& aContainerType)
 {
-  return false;
+  return IsEnabled() &&
+         DecoderTraits::IsHttpLiveStreamingType(aContainerType);
 }
 
 } // namespace mozilla