pngparse: Proxy upstream framerate on srcpad if avalaible
authorThibault Saunier <thibault.saunier@collabora.com>
Wed, 13 Nov 2013 20:16:04 +0000 (17:16 -0300)
committerThibault Saunier <thibault.saunier@collabora.com>
Wed, 13 Nov 2013 21:14:27 +0000 (18:14 -0300)
If the user sets it himself with capsfilter, the information should be
kept and transmitted downstream.

gst/videoparsers/gstpngparse.c

index 06b42500f5c628dbc29db8cc3aa1edbb95673b27..7c53f156662b16468a844abb527536cb7813e445 100644 (file)
@@ -161,13 +161,28 @@ gst_png_parse_handle_frame (GstBaseParse * parse,
 
     if (code == GST_MAKE_FOURCC ('I', 'E', 'N', 'D')) {
       if (pngparse->width != width || pngparse->height != height) {
-        GstCaps *caps;
+        GstStructure *st = NULL;
+        GstCaps *caps, *sink_caps;
+        gint fr_num, fr_denom;
 
         pngparse->height = height;
         pngparse->width = width;
 
+        sink_caps =
+            gst_pad_get_current_caps (GST_BASE_PARSE_SINK_PAD (pngparse));
+        if (sink_caps && (st = gst_caps_get_structure (sink_caps, 0))
+            && gst_structure_get_fraction (st, "framerate", &fr_num, &fr_denom)) {
+          /* Got it in caps - nothing more to do */
+          GST_DEBUG_OBJECT (pngparse,
+              "sink caps override framerate from headers");
+        } else {
+          GST_INFO_OBJECT (pngparse, "No framerate set");
+        }
+
         caps = gst_caps_new_simple ("image/png",
-            "width", G_TYPE_INT, width, "height", G_TYPE_INT, height, NULL);
+            "width", G_TYPE_INT, width, "height", G_TYPE_INT, height,
+            "framerate", GST_TYPE_FRACTION, fr_num, fr_denom, NULL);
+
         if (!gst_pad_set_caps (GST_BASE_PARSE_SRC_PAD (parse), caps)) {
           ret = GST_FLOW_NOT_NEGOTIATED;
         }