Bug 747257 - Part 1: Load .mp4 files in a document wrapper. r=rillian
authorShawn Landden <shawnlandden@gmail.com>
Thu, 17 May 2012 17:19:21 -0700
changeset 96732 45118cc6518bbe29688877983c32acf92fd1834d
parent 96731 9a684c3344a5fdd75b6295d4de0a8e31bd792c91
child 96733 a19f0356c09d336418b97c1be4b90ce89ebe0db2
push id1439
push userlsblakk@mozilla.com
push dateMon, 04 Jun 2012 20:19:22 +0000
treeherdermozilla-aurora@ea74834dccd3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersrillian
bugs747257, 422540
milestone15.0a1
Bug 747257 - Part 1: Load .mp4 files in a document wrapper. r=rillian When compiled with --enable-gstreamer, use a document loader for video/mp4, and associate that type with the decoder in nsHTMLMediaElement. Bug 422540 fix lets gstreamer render h.264 videos from within webpages with <video>, however to view these files when loaded directly we need to recognize their Content-Type.
content/base/src/nsContentUtils.cpp
content/html/content/src/nsHTMLMediaElement.cpp
--- a/content/base/src/nsContentUtils.cpp
+++ b/content/base/src/nsContentUtils.cpp
@@ -6388,16 +6388,31 @@ nsContentUtils::FindInternalContentViewe
         if (docFactory && aLoaderType) {
           *aLoaderType = TYPE_CONTENT;
         }
         return docFactory.forget();
       }
     }
   }
 #endif
+
+#ifdef MOZ_GSTREAMER
+  if (nsHTMLMediaElement::IsH264Enabled()) {
+    for (unsigned int i = 0; i < ArrayLength(nsHTMLMediaElement::gH264Types); ++i) {
+      const char* type = nsHTMLMediaElement::gH264Types[i];
+      if (!strcmp(aType, type)) {
+        docFactory = do_GetService("@mozilla.org/content/document-loader-factory;1");
+        if (docFactory && aLoaderType) {
+          *aLoaderType = TYPE_CONTENT;
+        }
+        return docFactory.forget();
+      }
+    }
+  }
+#endif
 #endif // MOZ_MEDIA
 
   return NULL;
 }
 
 // static
 bool
 nsContentUtils::IsPatternMatching(nsAString& aValue, nsAString& aPattern,
--- a/content/html/content/src/nsHTMLMediaElement.cpp
+++ b/content/html/content/src/nsHTMLMediaElement.cpp
@@ -2189,16 +2189,20 @@ bool nsHTMLMediaElement::ShouldHandleMed
 #ifdef MOZ_OGG
   if (IsOggType(nsDependentCString(aMIMEType)))
     return true;
 #endif
 #ifdef MOZ_WEBM
   if (IsWebMType(nsDependentCString(aMIMEType)))
     return true;
 #endif
+#ifdef MOZ_GSTREAMER
+  if (IsH264Type(nsDependentCString(aMIMEType)))
+    return true;
+#endif
   // We should not return true for Wave types, since there are some
   // Wave codecs actually in use in the wild that we don't support, and
   // we should allow those to be handled by plugins or helper apps.
   // Furthermore people can play Wave files on most platforms by other
   // means.
   return false;
 }