multipartdemux: Add property to assume a single stream and emit no-more-pads
authorDavid Hoyt <dhoyt@llnl.gov>
Wed, 25 May 2011 19:12:12 +0000 (21:12 +0200)
committerSebastian Dröge <sebastian.droege@collabora.co.uk>
Wed, 25 May 2011 19:12:12 +0000 (21:12 +0200)
Fixes bug #616686.

gst/multipart/multipartdemux.c
gst/multipart/multipartdemux.h

index a5a51a2..b8c6e1c 100644 (file)
@@ -62,14 +62,16 @@ enum
   LAST_SIGNAL
 };
 
-#define DEFAULT_AUTOSCAN       FALSE
-#define DEFAULT_BOUNDARY       NULL
+#define DEFAULT_AUTOSCAN               FALSE
+#define DEFAULT_BOUNDARY               NULL
+#define DEFAULT_SINGLE_STREAM  FALSE
 
 enum
 {
   PROP_0,
   PROP_AUTOSCAN,
-  PROP_BOUNDARY
+  PROP_BOUNDARY,
+  PROP_SINGLE_STREAM
 };
 
 static GstStaticPadTemplate multipart_demux_src_template_factory =
@@ -165,6 +167,20 @@ gst_multipart_demux_class_init (GstMultipartDemuxClass * klass)
           "Try to autofind the prefix (deprecated unused, see boundary)",
           DEFAULT_AUTOSCAN, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
 
+  /**
+   * GstMultipartDemux::single-stream:
+   *
+   * Assume that there is only one stream whose content-type will
+   * not change and emit no-more-pads as soon as the first boundary
+   * content is parsed, decoded, and pads are linked.
+   *
+   * Since: 0.10.30
+   */
+  g_object_class_install_property (gobject_class, PROP_SINGLE_STREAM,
+      g_param_spec_boolean ("single-stream", "Single Stream",
+          "Assume that there is only one stream whose content-type will not change and emit no-more-pads as soon as the first boundary content is parsed, decoded, and pads are linked",
+          DEFAULT_SINGLE_STREAM, G_PARAM_READWRITE));
+
   /* populate gst names and mime types pairs */
   klass->gstnames = g_hash_table_new (g_str_hash, g_str_equal);
   for (i = 0; gstnames[i].key; i++) {
@@ -194,6 +210,7 @@ gst_multipart_demux_init (GstMultipartDemux * multipart,
   multipart->header_completed = FALSE;
   multipart->scanpos = 0;
   multipart->autoscan = DEFAULT_AUTOSCAN;
+  multipart->singleStream = DEFAULT_SINGLE_STREAM;
 }
 
 static void
@@ -324,6 +341,10 @@ gst_multipart_find_pad_by_mime (GstMultipartDemux * demux, gchar * mime,
       *created = TRUE;
     }
 
+    if (demux->singleStream) {
+      gst_element_no_more_pads (GST_ELEMENT_CAST (demux));
+    }
+
     return mppad;
   }
 }
@@ -664,6 +685,9 @@ gst_multipart_set_property (GObject * object, guint prop_id,
     case PROP_AUTOSCAN:
       filter->autoscan = g_value_get_boolean (value);
       break;
+    case PROP_SINGLE_STREAM:
+      filter->singleStream = g_value_get_boolean (value);
+      break;
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
       break;
@@ -686,6 +710,9 @@ gst_multipart_get_property (GObject * object, guint prop_id,
     case PROP_AUTOSCAN:
       g_value_set_boolean (value, filter->autoscan);
       break;
+    case PROP_SINGLE_STREAM:
+      g_value_set_boolean (value, filter->singleStream);
+      break;
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
       break;
index 36f935d..5d37bc9 100644 (file)
@@ -84,6 +84,8 @@ struct _GstMultipartDemux
 
   /* Index inside the current data when manually looking for the boundary */
   gint scanpos;
+
+  gboolean singleStream;
 };
 
 struct _GstMultipartDemuxClass