Bug 1133634 - Fix CanPlayType in GStreamer backend. r=kinetik, a=lmandel
authorEdwin Flores <eflores@mozilla.com>
Wed, 18 Feb 2015 15:33:42 +1300
changeset 250321 2c20766b4493
parent 250320 fc7893265f9d
child 250322 89b593b91e5e
push id4545
push userryanvm@gmail.com
push date2015-03-09 20:28 +0000
treeherdermozilla-beta@2c20766b4493 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskinetik, lmandel
bugs1133634
milestone37.0
Bug 1133634 - Fix CanPlayType in GStreamer backend. r=kinetik, a=lmandel
dom/media/gstreamer/GStreamerFormatHelper.cpp
dom/media/gstreamer/GStreamerFormatHelper.h
--- a/dom/media/gstreamer/GStreamerFormatHelper.cpp
+++ b/dom/media/gstreamer/GStreamerFormatHelper.cpp
@@ -219,52 +219,50 @@ GStreamerFormatHelper::IsBlacklistEnable
                                  "media.gstreamer.enable-blacklist", true);
     sBlacklistEnabledCached = true;
   }
 
   return sBlacklistEnabled;
 }
 
 /* static */ bool
-GStreamerFormatHelper::IsPluginFeatureBlacklisted(GstPluginFeature *aFeature,
-                                                  FactoryType aTypes)
+GStreamerFormatHelper::IsPluginFeatureBlacklisted(GstPluginFeature *aFeature)
 {
   if (!IsBlacklistEnabled()) {
     return false;
   }
 
-  const gchar *className =
-    gst_element_factory_get_klass(GST_ELEMENT_FACTORY_CAST(aFeature));
-
   const gchar *factoryName =
     gst_plugin_feature_get_name(aFeature);
 
-  if ((!(aTypes & FactoryTypeDecoder) && strstr(className, "Decoder")) ||
-      (!(aTypes & FactoryTypeDemuxer) && strstr(className, "Demuxer")) ||
-      (!(aTypes & FactoryTypeParser) && strstr(className, "Parser"))) {
-    return false;
-  }
-
   for (unsigned int i = 0; i < G_N_ELEMENTS(sPluginBlacklist); i++) {
     if (!strcmp(factoryName, sPluginBlacklist[i])) {
       return true;
     }
   }
 
   return false;
 }
 
 static gboolean FactoryFilter(GstPluginFeature *aFeature, gpointer)
 {
   if (!GST_IS_ELEMENT_FACTORY(aFeature)) {
     return FALSE;
   }
 
-  return !GStreamerFormatHelper::IsPluginFeatureBlacklisted(aFeature,
-                                                            (FactoryType)(FactoryTypeDecoder|FactoryTypeDemuxer));
+  const gchar *className =
+    gst_element_factory_get_klass(GST_ELEMENT_FACTORY_CAST(aFeature));
+
+  if (!strstr(className, "Decoder") && !strstr(className, "Demux")) {
+    return FALSE;
+  }
+
+  return
+    gst_plugin_feature_get_rank(aFeature) >= GST_RANK_MARGINAL &&
+    !GStreamerFormatHelper::IsPluginFeatureBlacklisted(aFeature);
 }
 
 /**
  * Returns true if any |aFactory| caps intersect with |aCaps|
  */
 static bool SupportsCaps(GstElementFactory *aFactory, GstCaps *aCaps)
 {
   for (const GList *iter = gst_element_factory_get_static_pad_templates(aFactory); iter; iter = iter->next) {
--- a/dom/media/gstreamer/GStreamerFormatHelper.h
+++ b/dom/media/gstreamer/GStreamerFormatHelper.h
@@ -8,23 +8,16 @@
 #define GStreamerFormatHelper_h_
 
 #include <gst/gst.h>
 #include <mozilla/Types.h>
 #include "nsXPCOMStrings.h"
 
 namespace mozilla {
 
-enum FactoryType {
-  FactoryTypeDecoder  = 1 << 0,
-  FactoryTypeDemuxer  = 1 << 1,
-  FactoryTypeParser   = 1 << 2,
-  FactoryTypeAll      = FactoryTypeDecoder|FactoryTypeDemuxer|FactoryTypeParser
-};
-
 class GStreamerFormatHelper {
   /* This class can be used to query the GStreamer registry for the required
    * demuxers/decoders from nsHTMLMediaElement::CanPlayType.
    * It implements looking at the GstRegistry to check if elements to
    * demux/decode the formats passed to CanPlayType() are actually installed.
    */
   public:
     static GStreamerFormatHelper* Instance();
@@ -32,18 +25,17 @@ class GStreamerFormatHelper {
 
     bool CanHandleMediaType(const nsACString& aMIMEType,
                             const nsAString* aCodecs);
 
     bool CanHandleContainerCaps(GstCaps* aCaps);
     bool CanHandleCodecCaps(GstCaps* aCaps);
 
     static bool IsBlacklistEnabled();
-    static bool IsPluginFeatureBlacklisted(GstPluginFeature *aFeature,
-                                           FactoryType aTypes = FactoryTypeAll);
+    static bool IsPluginFeatureBlacklisted(GstPluginFeature *aFeature);
 
     static GstCaps* ConvertFormatsToCaps(const char* aMIMEType,
                                          const nsAString* aCodecs);
 
     static void Shutdown();
 
   private:
     GStreamerFormatHelper();