Bug 876305 - Pass the media mimetype on to the gstreamer backend r=alessandro.d
authorEdwin Flores <eflores@mozilla.com>
Tue, 11 Jun 2013 14:13:10 +1200
changeset 146099 8395ce584ddcfe6e1aa9a494b01bfffe50d5ed3a
parent 146098 1b59b25f6464218410d3c133f93a771892794fb4
child 146100 81b227f1a5226182d72b624d8b2c5336b230eb3b
push id2697
push userbbajaj@mozilla.com
push dateMon, 05 Aug 2013 18:49:53 +0000
treeherdermozilla-beta@dfec938c7b63 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersalessandro
bugs876305
milestone24.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 876305 - Pass the media mimetype on to the gstreamer backend r=alessandro.d
content/media/gstreamer/GStreamerFormatHelper.cpp
content/media/gstreamer/GStreamerFormatHelper.h
content/media/gstreamer/GStreamerFunctionList.h
content/media/gstreamer/GStreamerReader.cpp
--- a/content/media/gstreamer/GStreamerFormatHelper.cpp
+++ b/content/media/gstreamer/GStreamerFormatHelper.cpp
@@ -34,17 +34,17 @@ void GStreamerFormatHelper::Shutdown() {
     delete gInstance;
     gInstance = nullptr;
   }
 }
 
 char const *const GStreamerFormatHelper::mContainers[6][2] = {
   {"video/mp4", "video/quicktime"},
   {"video/quicktime", "video/quicktime"},
-  {"audio/mp4", "audio/mpeg, mpegversion=(int)4"},
+  {"audio/mp4", "audio/x-m4a"},
   {"audio/x-m4a", "audio/x-m4a"},
   {"audio/mpeg", "audio/mpeg, mpegversion=(int)1"},
   {"audio/mp3", "audio/mpeg, mpegversion=(int)1"},
 };
 
 char const *const GStreamerFormatHelper::mCodecs[9][2] = {
   {"avc1.42E01E", "video/x-h264"},
   {"avc1.42001E", "video/x-h264"},
--- a/content/media/gstreamer/GStreamerFormatHelper.h
+++ b/content/media/gstreamer/GStreamerFormatHelper.h
@@ -24,22 +24,23 @@ class GStreamerFormatHelper {
     ~GStreamerFormatHelper();
 
     bool CanHandleMediaType(const nsACString& aMIMEType,
                             const nsAString* aCodecs);
 
     bool CanHandleContainerCaps(GstCaps* aCaps);
     bool CanHandleCodecCaps(GstCaps* aCaps);
 
-   static void Shutdown();
+    static GstCaps* ConvertFormatsToCaps(const char* aMIMEType,
+                                         const nsAString* aCodecs);
+
+    static void Shutdown();
 
   private:
     GStreamerFormatHelper();
-    GstCaps* ConvertFormatsToCaps(const char* aMIMEType,
-                                  const nsAString* aCodecs);
     char* const *CodecListFromCaps(GstCaps* aCaps);
     bool HaveElementsToProcessCaps(GstCaps* aCaps);
     GList* GetFactories();
 
     static GStreamerFormatHelper* gInstance;
 
     /* table to convert from container MIME types to GStreamer caps */
     static char const *const mContainers[6][2];
--- a/content/media/gstreamer/GStreamerFunctionList.h
+++ b/content/media/gstreamer/GStreamerFunctionList.h
@@ -11,16 +11,17 @@
 GST_FUNC(LIBGSTAPP, gst_app_sink_get_type)
 GST_FUNC(LIBGSTAPP, gst_app_sink_pull_buffer)
 GST_FUNC(LIBGSTAPP, gst_app_sink_set_callbacks)
 GST_FUNC(LIBGSTAPP, gst_app_src_end_of_stream)
 GST_FUNC(LIBGSTAPP, gst_app_src_get_size)
 GST_FUNC(LIBGSTAPP, gst_app_src_get_type)
 GST_FUNC(LIBGSTAPP, gst_app_src_push_buffer)
 GST_FUNC(LIBGSTAPP, gst_app_src_set_callbacks)
+GST_FUNC(LIBGSTAPP, gst_app_src_set_caps)
 GST_FUNC(LIBGSTAPP, gst_app_src_set_size)
 GST_FUNC(LIBGSTAPP, gst_app_src_set_stream_type)
 GST_FUNC(LIBGSTREAMER, gst_bin_get_by_name)
 GST_FUNC(LIBGSTREAMER, gst_bin_get_type)
 GST_FUNC(LIBGSTREAMER, gst_bin_iterate_recurse)
 GST_FUNC(LIBGSTREAMER, gst_buffer_copy_metadata)
 GST_FUNC(LIBGSTREAMER, gst_buffer_get_type)
 GST_FUNC(LIBGSTREAMER, gst_buffer_new)
--- a/content/media/gstreamer/GStreamerReader.cpp
+++ b/content/media/gstreamer/GStreamerReader.cpp
@@ -214,16 +214,24 @@ void GStreamerReader::PlayBinSourceSetup
     LOG(PR_LOG_DEBUG, ("configuring random access, len %lld", resourceLength));
     gst_app_src_set_stream_type(mSource, GST_APP_STREAM_TYPE_RANDOM_ACCESS);
   } else {
     /* make the demuxer work in push mode so that seeking is kept to a minimum
      */
     LOG(PR_LOG_DEBUG, ("configuring push mode, len %lld", resourceLength));
     gst_app_src_set_stream_type(mSource, GST_APP_STREAM_TYPE_SEEKABLE);
   }
+
+  // Set the source MIME type to stop typefind trying every. single. format.
+  GstCaps *caps =
+    GStreamerFormatHelper::ConvertFormatsToCaps(mDecoder->GetResource()->GetContentType().get(),
+                                                nullptr);
+
+  gst_app_src_set_caps(aSource, caps);
+  gst_caps_unref(caps);
 }
 
 nsresult GStreamerReader::ReadMetadata(VideoInfo* aInfo,
                                        MetadataTags** aTags)
 {
   NS_ASSERTION(mDecoder->OnDecodeThread(), "Should be on decode thread.");
   nsresult ret = NS_OK;
 
@@ -364,17 +372,17 @@ nsresult GStreamerReader::CheckSupported
           GstPad* pad = gst_element_get_pad(element, "sink");
           if (pad) {
             GstCaps* caps = gst_pad_get_negotiated_caps(pad);
 
             if (caps) {
               /* check for demuxers but ignore elements like id3demux */
               if (strstr (klass, "Demuxer") && !strstr(klass, "Metadata"))
                 unsupported = !GStreamerFormatHelper::Instance()->CanHandleContainerCaps(caps);
-              else if (strstr (klass, "Decoder"))
+              else if (strstr (klass, "Decoder") && !strstr(klass, "Generic"))
                 unsupported = !GStreamerFormatHelper::Instance()->CanHandleCodecCaps(caps);
 
               gst_caps_unref(caps);
             }
             gst_object_unref(pad);
           }
         }