Bug 881512 - Add hidden pref to ignore MIME type in AddSourceBuffer and IsTypeSupported. For experimental/debugging use only. r=cajbir
authorMatthew Gregan <kinetik@flim.org>
Mon, 14 Apr 2014 23:24:00 +1200
changeset 198886 18754facd070edefc3bee658e8a690136e448357
parent 198885 f8ece490919dd18b8f736e910d771ec3f7573fe3
child 198887 59ffec98e96f7ada3270aaa2cc770539f5700974
push id3624
push userasasaki@mozilla.com
push dateMon, 09 Jun 2014 21:49:01 +0000
treeherdermozilla-beta@b1a5da15899a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerscajbir
bugs881512
milestone31.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 881512 - Add hidden pref to ignore MIME type in AddSourceBuffer and IsTypeSupported. For experimental/debugging use only. r=cajbir
content/media/mediasource/MediaSource.cpp
--- a/content/media/mediasource/MediaSource.cpp
+++ b/content/media/mediasource/MediaSource.cpp
@@ -7,16 +7,17 @@
 #include "MediaSource.h"
 
 #include "AsyncEventRunner.h"
 #include "DecoderTraits.h"
 #include "SourceBuffer.h"
 #include "SourceBufferList.h"
 #include "mozilla/ErrorResult.h"
 #include "mozilla/FloatingPoint.h"
+#include "mozilla/Preferences.h"
 #include "mozilla/dom/BindingDeclarations.h"
 #include "mozilla/dom/HTMLMediaElement.h"
 #include "mozilla/mozalloc.h"
 #include "nsContentTypeParser.h"
 #include "nsDebug.h"
 #include "nsError.h"
 #include "nsIEventTarget.h"
 #include "nsIRunnable.h"
@@ -67,16 +68,19 @@ IsTypeSupported(const nsAString& aType)
     if (mimeType.EqualsASCII(gMediaSourceTypes[i])) {
       found = true;
       break;
     }
   }
   if (!found) {
     return NS_ERROR_DOM_NOT_SUPPORTED_ERR;
   }
+  if (Preferences::GetBool("media.mediasource.ignore_codecs", false)) {
+    return NS_OK;
+  }
   // Check aType against HTMLMediaElement list of MIME types.  Since we've
   // already restricted the container format, this acts as a specific check
   // of any specified "codecs" parameter of aType.
   if (dom::HTMLMediaElement::GetCanPlay(aType) == CANPLAY_NO) {
     return NS_ERROR_DOM_NOT_SUPPORTED_ERR;
   }
   return NS_OK;
 }
@@ -140,16 +144,17 @@ MediaSource::SetDuration(double aDuratio
   }
   DurationChange(aDuration, aRv);
 }
 
 already_AddRefed<SourceBuffer>
 MediaSource::AddSourceBuffer(const nsAString& aType, ErrorResult& aRv)
 {
   nsresult rv = mozilla::IsTypeSupported(aType);
+  MSE_DEBUG("MediaSource::AddSourceBuffer(Type=%s) -> %x", NS_ConvertUTF16toUTF8(aType).get(), rv);
   if (NS_FAILED(rv)) {
     aRv.Throw(rv);
     return nullptr;
   }
   if (mSourceBuffers->Length() >= MAX_SOURCE_BUFFERS) {
     aRv.Throw(NS_ERROR_DOM_QUOTA_EXCEEDED_ERR);
     return nullptr;
   }
@@ -174,16 +179,17 @@ MediaSource::AddSourceBuffer(const nsASt
             NS_ConvertUTF16toUTF8(mimeType).get(), sourceBuffer.get());
   return sourceBuffer.forget();
 }
 
 void
 MediaSource::RemoveSourceBuffer(SourceBuffer& aSourceBuffer, ErrorResult& aRv)
 {
   SourceBuffer* sourceBuffer = &aSourceBuffer;
+  MSE_DEBUG("%p RemoveSourceBuffer(Buffer=%p)", this, sourceBuffer);
   if (!mSourceBuffers->Contains(sourceBuffer)) {
     aRv.Throw(NS_ERROR_DOM_NOT_FOUND_ERR);
     return;
   }
   if (sourceBuffer->Updating()) {
     // TODO:
     // abort stream append loop (if running)
     // set updating to false
@@ -202,16 +208,17 @@ MediaSource::RemoveSourceBuffer(SourceBu
   }
   mSourceBuffers->Remove(sourceBuffer);
   // TODO: Free all resources associated with sourceBuffer
 }
 
 void
 MediaSource::EndOfStream(const Optional<MediaSourceEndOfStreamError>& aError, ErrorResult& aRv)
 {
+  MSE_DEBUG("%p EndOfStream(Error=%u)", this, aError.WasPassed() ? uint32_t(aError.Value()) : 0);
   if (mReadyState != MediaSourceReadyState::Open ||
       mSourceBuffers->AnyUpdating()) {
     aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
     return;
   }
 
   SetReadyState(MediaSourceReadyState::Ended);
   mSourceBuffers->Ended();
@@ -239,17 +246,24 @@ MediaSource::EndOfStream(const Optional<
   default:
     aRv.Throw(NS_ERROR_DOM_INVALID_ACCESS_ERR);
   }
 }
 
 /* static */ bool
 MediaSource::IsTypeSupported(const GlobalObject&, const nsAString& aType)
 {
-  return NS_SUCCEEDED(mozilla::IsTypeSupported(aType));
+#ifdef PR_LOGGING
+  if (!gMediaSourceLog) {
+    gMediaSourceLog = PR_NewLogModule("MediaSource");
+  }
+#endif
+  nsresult rv = mozilla::IsTypeSupported(aType);
+  MSE_DEBUG("MediaSource::IsTypeSupported(Type=%s) -> %x", NS_ConvertUTF16toUTF8(aType).get(), rv);
+  return NS_SUCCEEDED(rv);
 }
 
 bool
 MediaSource::Attach(MediaSourceDecoder* aDecoder)
 {
   MSE_DEBUG("%p Attaching decoder %p owner %p", this, aDecoder, aDecoder->GetOwner());
   MOZ_ASSERT(aDecoder);
   if (mReadyState != MediaSourceReadyState::Closed) {
@@ -289,16 +303,17 @@ MediaSource::MediaSource(nsPIDOMWindow* 
   }
 #endif
 }
 
 void
 MediaSource::SetReadyState(MediaSourceReadyState aState)
 {
   MOZ_ASSERT(aState != mReadyState);
+  MSE_DEBUG("%p SetReadyState old=%d new=%d", this, mReadyState, aState);
 
   MediaSourceReadyState oldState = mReadyState;
   mReadyState = aState;
 
   if (mReadyState == MediaSourceReadyState::Open &&
       (oldState == MediaSourceReadyState::Closed ||
        oldState == MediaSourceReadyState::Ended)) {
     QueueAsyncSimpleEvent("sourceopen");