From d445027ec17954820c60379b5aadd16274ad683f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Fri, 4 Apr 2014 17:06:18 +0200 Subject: [PATCH] event: Add running-time-offset field to all events Events passing through #GstPads that have a running time offset set via gst_pad_set_offset() will get their offset adjusted according to the pad's offset. If the event contains any information that related to the running time, this information will need to be updated before usage with this offset. --- docs/gst/gstreamer-sections.txt | 3 ++ gst/gstevent.c | 54 +++++++++++++++++++++++++++++++++ gst/gstevent.h | 4 +++ win32/common/libgstreamer.def | 2 ++ 4 files changed, 63 insertions(+) diff --git a/docs/gst/gstreamer-sections.txt b/docs/gst/gstreamer-sections.txt index 814894ba91..f197fad1f1 100644 --- a/docs/gst/gstreamer-sections.txt +++ b/docs/gst/gstreamer-sections.txt @@ -1055,6 +1055,9 @@ gst_event_has_name gst_event_get_seqnum gst_event_set_seqnum +gst_event_get_running_time_offset +gst_event_set_running_time_offset + gst_event_new_flush_start gst_event_new_flush_stop gst_event_parse_flush_stop diff --git a/gst/gstevent.c b/gst/gstevent.c index 6be7d6291e..f31d3ed9df 100644 --- a/gst/gstevent.c +++ b/gst/gstevent.c @@ -90,6 +90,7 @@ typedef struct GstEvent event; GstStructure *structure; + gint64 running_time_offset; } GstEventImpl; #define GST_EVENT_STRUCTURE(e) (((GstEventImpl *)(e))->structure) @@ -251,6 +252,10 @@ _gst_event_copy (GstEvent * event) } else { GST_EVENT_STRUCTURE (copy) = NULL; } + + ((GstEventImpl *) copy)->running_time_offset = + ((GstEventImpl *) event)->running_time_offset; + return GST_EVENT_CAST (copy); } @@ -264,6 +269,7 @@ gst_event_init (GstEventImpl * event, GstEventType type) GST_EVENT_TYPE (event) = type; GST_EVENT_TIMESTAMP (event) = GST_CLOCK_TIME_NONE; GST_EVENT_SEQNUM (event) = gst_util_seqnum_next (); + event->running_time_offset = 0; } @@ -442,6 +448,54 @@ gst_event_set_seqnum (GstEvent * event, guint32 seqnum) GST_EVENT_SEQNUM (event) = seqnum; } +/** + * gst_event_get_running_time_offset: + * @event: A #GstEvent. + * + * Retrieve the accumulated running time offset of the event. + * + * Events passing through #GstPads that have a running time + * offset set via gst_pad_set_offset() will get their offset + * adjusted according to the pad's offset. + * + * If the event contains any information that related to the + * running time, this information will need to be updated + * before usage with this offset. + * + * Returns: The event's running time offset + * + * MT safe. + * + * Since: 1.4 + */ +gint64 +gst_event_get_running_time_offset (GstEvent * event) +{ + g_return_val_if_fail (GST_IS_EVENT (event), 0); + + return ((GstEventImpl *) event)->running_time_offset; +} + +/** + * gst_event_set_running_time_offset: + * @event: A #GstEvent. + * @offset: A the new running time offset + * + * Set the running time offset of a event. See + * gst_event_get_running_time_offset() for more information. + * + * MT safe. + * + * Since: 1.4 + */ +void +gst_event_set_running_time_offset (GstEvent * event, gint64 offset) +{ + g_return_if_fail (GST_IS_EVENT (event)); + + ((GstEventImpl *) event)->running_time_offset = offset; +} + /** * gst_event_new_flush_start: * diff --git a/gst/gstevent.h b/gst/gstevent.h index 0d1f58d113..a61f08054c 100644 --- a/gst/gstevent.h +++ b/gst/gstevent.h @@ -482,6 +482,10 @@ gboolean gst_event_has_name (GstEvent *event, const gchar *n guint32 gst_event_get_seqnum (GstEvent *event); void gst_event_set_seqnum (GstEvent *event, guint32 seqnum); +/* accumulated pad offsets for the event */ +gint64 gst_event_get_running_time_offset (GstEvent *event); +void gst_event_set_running_time_offset (GstEvent *event, gint64 offset); + /* Stream start event */ GstEvent * gst_event_new_stream_start (const gchar *stream_id) G_GNUC_MALLOC; void gst_event_parse_stream_start (GstEvent *event, const gchar **stream_id); diff --git a/win32/common/libgstreamer.def b/win32/common/libgstreamer.def index c59e855018..1e00b01ab4 100644 --- a/win32/common/libgstreamer.def +++ b/win32/common/libgstreamer.def @@ -510,6 +510,7 @@ EXPORTS gst_element_unlink_pads gst_error_get_message gst_event_copy_segment + gst_event_get_running_time_offset gst_event_get_seqnum gst_event_get_structure gst_event_get_type @@ -552,6 +553,7 @@ EXPORTS gst_event_parse_toc gst_event_parse_toc_select gst_event_set_group_id + gst_event_set_running_time_offset gst_event_set_seqnum gst_event_set_stream_flags gst_event_type_flags_get_type