mpeg4videoparse: Use sinkpad caps as base for srcpad caps
authorArun Raghavan <arun.raghavan@collabora.co.uk>
Thu, 18 Nov 2010 17:59:51 +0000 (23:29 +0530)
committerEdward Hervey <edward.hervey@collabora.co.uk>
Wed, 8 Dec 2010 15:30:12 +0000 (16:30 +0100)
This way, we don't lose additional fields that come from upstream (like
profile/level for now).

https://bugzilla.gnome.org/show_bug.cgi?id=635202

gst/mpeg4videoparse/mpeg4videoparse.c
gst/mpeg4videoparse/mpeg4videoparse.h

index 7dfa556..969ca7e 100644 (file)
@@ -65,9 +65,15 @@ gst_mpeg4vparse_set_new_caps (GstMpeg4VParse * parse,
     gint aspect_ratio_width, gint aspect_ratio_height, gint width, gint height)
 {
   gboolean res;
-  GstCaps *out_caps = gst_caps_new_simple ("video/mpeg",
-      "mpegversion", G_TYPE_INT, 4,
-      "systemstream", G_TYPE_BOOLEAN, FALSE,
+  GstCaps *out_caps;
+
+  if (parse->sink_caps) {
+    out_caps = gst_caps_copy (parse->sink_caps);
+  } else {
+    out_caps = gst_caps_new_simple ("video/mpeg",
+        "mpegversion", G_TYPE_INT, 4, NULL);
+  }
+  gst_caps_set_simple (out_caps, "systemstream", G_TYPE_BOOLEAN, FALSE,
       "parsed", G_TYPE_BOOLEAN, TRUE, NULL);
 
   if (parse->profile != 0) {
@@ -710,6 +716,7 @@ gst_mpeg4vparse_sink_setcaps (GstPad * pad, GstCaps * caps)
   const GValue *value;
 
   GST_DEBUG_OBJECT (parse, "setcaps called with %" GST_PTR_FORMAT, caps);
+  parse->sink_caps = gst_caps_ref (caps);
 
   s = gst_caps_get_structure (caps, 0);
 
@@ -860,6 +867,10 @@ gst_mpeg4vparse_src_query (GstPad * pad, GstQuery * query)
 static void
 gst_mpeg4vparse_cleanup (GstMpeg4VParse * parse)
 {
+  if (parse->sink_caps) {
+    gst_caps_unref (parse->sink_caps);
+    parse->sink_caps = NULL;
+  }
   if (parse->adapter) {
     gst_adapter_clear (parse->adapter);
   }
index f5ce3f3..3c114ca 100644 (file)
@@ -54,6 +54,8 @@ struct _GstMpeg4VParse {
   GstPad * sinkpad;
   GstPad * srcpad;
 
+  GstCaps *sink_caps;
+
   guint interval;
   GstClockTime last_report;