Bug 1229605: [MSE] Allow webm/audio independently of video. r=kentuckyfriedtakahe a=ritu
authorJean-Yves Avenard <jyavenard@mozilla.com>
Thu, 03 Dec 2015 19:57:13 +1100
changeset 301409 ec766a40f7e3852f93a13bb854c54b81d4f81a4c
parent 301407 023e4f16666b6e2356e94b856d4bc532f8609c17
child 301410 f606e47c712a4ed86f476f2f6eee064cb1d4ceb0
push idunknown
push userunknown
push dateunknown
reviewerskentuckyfriedtakahe, ritu
bugs1229605
milestone44.0
Bug 1229605: [MSE] Allow webm/audio independently of video. r=kentuckyfriedtakahe a=ritu This adds a media.mediasource.webm.audio.enabled preference (true by default) to disable opus or vorbis audio in webm mediasource.
dom/media/DecoderTraits.cpp
dom/media/DecoderTraits.h
dom/media/mediasource/MediaSource.cpp
modules/libpref/init/all.js
--- a/dom/media/DecoderTraits.cpp
+++ b/dom/media/DecoderTraits.cpp
@@ -191,16 +191,25 @@ DecoderTraits::IsWebMTypeAndEnabled(cons
     return false;
   }
 
   return CodecListContains(gWebMTypes, aType);
 #endif
   return false;
 }
 
+/* static */ bool
+DecoderTraits::IsWebMAudioType(const nsACString& aType)
+{
+#ifdef MOZ_WEBM
+  return aType.EqualsASCII("audio/webm");
+#endif
+  return false;
+}
+
 #ifdef MOZ_GSTREAMER
 static bool
 IsGStreamerSupportedType(const nsACString& aMimeType)
 {
   if (DecoderTraits::IsWebMTypeAndEnabled(aMimeType))
     return false;
 
   if (!MediaDecoder::IsGStreamerEnabled())
--- a/dom/media/DecoderTraits.h
+++ b/dom/media/DecoderTraits.h
@@ -66,15 +66,16 @@ public:
   // vice versa.
   static bool IsSupportedInVideoDocument(const nsACString& aType);
 
   // Returns true if we should not start decoder until we receive
   // OnConnected signal. (currently RTSP only)
   static bool DecoderWaitsForOnConnected(const nsACString& aType);
 
   static bool IsWebMTypeAndEnabled(const nsACString& aType);
+  static bool IsWebMAudioType(const nsACString& aType);
   static bool IsMP4TypeAndEnabled(const nsACString& aType);
 };
 
 } // namespace mozilla
 
 #endif
 
--- a/dom/media/mediasource/MediaSource.cpp
+++ b/dom/media/mediasource/MediaSource.cpp
@@ -112,16 +112,18 @@ IsTypeSupported(const nsAString& aType)
         if (hasCodecs &&
             DecoderTraits::CanHandleCodecsType(mimeTypeUTF8.get(),
                                                codecs) == CANPLAY_NO) {
           return NS_ERROR_DOM_INVALID_STATE_ERR;
         }
         return NS_OK;
       } else if (DecoderTraits::IsWebMTypeAndEnabled(mimeTypeUTF8)) {
         if (!(Preferences::GetBool("media.mediasource.webm.enabled", false) ||
+              (Preferences::GetBool("media.mediasource.webm.audio.enabled", true) &&
+               DecoderTraits::IsWebMAudioType(mimeTypeUTF8)) ||
               IsWebMForced())) {
           return NS_ERROR_DOM_NOT_SUPPORTED_ERR;
         }
         if (hasCodecs &&
             DecoderTraits::CanHandleCodecsType(mimeTypeUTF8.get(),
                                                codecs) == CANPLAY_NO) {
           return NS_ERROR_DOM_INVALID_STATE_ERR;
         }
--- a/modules/libpref/init/all.js
+++ b/modules/libpref/init/all.js
@@ -493,16 +493,17 @@ pref("media.mediasource.enabled", true);
 
 pref("media.mediasource.mp4.enabled", true);
 
 #if defined(XP_WIN) || defined(XP_MACOSX) || defined(MOZ_WIDGET_GONK) || defined(MOZ_WIDGET_ANDROID)
 pref("media.mediasource.webm.enabled", false);
 #else
 pref("media.mediasource.webm.enabled", true);
 #endif
+pref("media.mediasource.webm.audio.enabled", true);
 
 // Enable new MediaFormatReader architecture for plain webm.
 pref("media.format-reader.webm", true);
 
 #ifdef MOZ_WEBSPEECH
 pref("media.webspeech.recognition.enable", false);
 pref("media.webspeech.synth.enabled", false);
 #endif