gdkpixbufsink: Add timestamp/running-time/stream-time to the emited message
authorThibault Saunier <thibault.saunier@collabora.com>
Sat, 6 Apr 2013 15:45:28 +0000 (12:45 -0300)
committerThibault Saunier <thibault.saunier@collabora.com>
Sat, 6 Apr 2013 18:10:06 +0000 (15:10 -0300)
ext/gdk_pixbuf/gstgdkpixbufsink.c

index 1d036ef..5a8305d 100644 (file)
@@ -339,6 +339,16 @@ gst_gdk_pixbuf_sink_handle_buffer (GstBaseSink * basesink, GstBuffer * buf,
   if (do_post) {
     GstStructure *s;
     GstMessage *msg;
+    GstFormat format;
+    GstClockTime timestamp;
+    GstClockTime running_time, stream_time;
+
+    GstSegment *segment = &basesink->segment;
+    format = segment->format;
+
+    timestamp = GST_BUFFER_PTS (buf);
+    running_time = gst_segment_to_running_time (segment, format, timestamp);
+    stream_time = gst_segment_to_stream_time (segment, format, timestamp);
 
     /* it's okay to keep using pixbuf here, we can be sure no one is going to
      * unref or change sink->last_pixbuf before we return from this function.
@@ -346,7 +356,9 @@ gst_gdk_pixbuf_sink_handle_buffer (GstBaseSink * basesink, GstBuffer * buf,
     s = gst_structure_new (msg_name,
         "pixbuf", GDK_TYPE_PIXBUF, pixbuf,
         "pixel-aspect-ratio", GST_TYPE_FRACTION, sink->par_n, sink->par_d,
-        NULL);
+        "timestamp", G_TYPE_UINT64, timestamp,
+        "stream-time", G_TYPE_UINT64, stream_time,
+        "running-time", G_TYPE_UINT64, running_time, NULL);
 
     msg = gst_message_new_element (GST_OBJECT_CAST (sink), s);
     gst_element_post_message (GST_ELEMENT_CAST (sink), msg);