video-event: Update the running times in the force-keyunit events from the pad offsets
authorSebastian Dröge <sebastian@centricular.com>
Thu, 10 Apr 2014 07:18:05 +0000 (09:18 +0200)
committerSebastian Dröge <sebastian@centricular.com>
Thu, 10 Apr 2014 07:18:05 +0000 (09:18 +0200)
gst-libs/gst/video/video-event.c

index 88d56f3..2776365 100644 (file)
@@ -202,6 +202,8 @@ gst_video_event_is_force_key_unit (GstEvent * event)
  * key unit event. See gst_video_event_new_downstream_force_key_unit() for a
  * full description of the downstream force key unit event.
  *
+ * @running_time will be adjusted for any pad offsets of pads it was passing through.
+ *
  * Returns: %TRUE if the event is a valid downstream force key unit event.
  */
 gboolean
@@ -241,8 +243,16 @@ gst_video_event_parse_downstream_force_key_unit (GstEvent * event,
   if (stream_time)
     *stream_time = ev_stream_time;
 
-  if (running_time)
+  if (running_time) {
+    gint64 offset = gst_event_get_running_time_offset (event);
+
     *running_time = ev_running_time;
+    /* Catch underflows */
+    if (*running_time > -offset)
+      *running_time += offset;
+    else
+      *running_time = 0;
+  }
 
   if (all_headers)
     *all_headers = ev_all_headers;
@@ -266,6 +276,8 @@ gst_video_event_parse_downstream_force_key_unit (GstEvent * event,
  *
  * Create an upstream force key unit event using  gst_video_event_new_upstream_force_key_unit()
  *
+ * @running_time will be adjusted for any pad offsets of pads it was passing through.
+ *
  * Returns: %TRUE if the event is a valid upstream force-key-unit event. %FALSE if not
  */
 gboolean
@@ -294,8 +306,17 @@ gst_video_event_parse_upstream_force_key_unit (GstEvent * event,
   if (!gst_structure_get_uint (s, "count", &ev_count))
     ev_count = 0;
 
-  if (running_time)
+
+  if (running_time) {
+    gint64 offset = gst_event_get_running_time_offset (event);
+
     *running_time = ev_running_time;
+    /* Catch underflows */
+    if (*running_time > -offset)
+      *running_time += offset;
+    else
+      *running_time = 0;
+  }
 
   if (all_headers)
     *all_headers = ev_all_headers;