diff --git a/docs/gst/gstreamer-sections.txt b/docs/gst/gstreamer-sections.txt index 41971d10d4..33a2c61ce8 100644 --- a/docs/gst/gstreamer-sections.txt +++ b/docs/gst/gstreamer-sections.txt @@ -1003,6 +1003,8 @@ gst_event_parse_gap gst_event_new_stream_start gst_event_parse_stream_start +gst_event_set_stream_flags +gst_event_parse_stream_flags gst_event_new_segment gst_event_parse_segment diff --git a/gst/gstevent.c b/gst/gstevent.c index 1993eceecc..5517ecfb48 100644 --- a/gst/gstevent.c +++ b/gst/gstevent.c @@ -1404,7 +1404,8 @@ gst_event_new_stream_start (const gchar * stream_id) g_return_val_if_fail (stream_id != NULL, NULL); s = gst_structure_new_id (GST_QUARK (EVENT_STREAM_START), - GST_QUARK (STREAM_ID), G_TYPE_STRING, stream_id, NULL); + GST_QUARK (STREAM_ID), G_TYPE_STRING, stream_id, + GST_QUARK (FLAGS), GST_TYPE_STREAM_FLAGS, GST_STREAM_FLAG_NONE, NULL); return gst_event_new_custom (GST_EVENT_STREAM_START, s); } @@ -1435,6 +1436,43 @@ gst_event_parse_stream_start (GstEvent * event, const gchar ** stream_id) *stream_id = g_value_get_string (val); } +/** + * gst_event_set_stream_flags: + * @event: a stream-start event + * @flags: the stream flags to set + * + * Since: 1.2 + */ +void +gst_event_set_stream_flags (GstEvent * event, GstStreamFlags flags) +{ + g_return_if_fail (event != NULL); + g_return_if_fail (GST_EVENT_TYPE (event) == GST_EVENT_STREAM_START); + g_return_if_fail (gst_event_is_writable (event)); + + gst_structure_id_set (GST_EVENT_STRUCTURE (event), + GST_QUARK (FLAGS), GST_TYPE_STREAM_FLAGS, flags, NULL); +} + +/** + * gst_event_parse_stream_flags: + * @event: a stream-start event + * @flags: (out): address of variable where to store the stream flags + * + * Since: 1.2 + */ +void +gst_event_parse_stream_flags (GstEvent * event, GstStreamFlags * flags) +{ + g_return_if_fail (event != NULL); + g_return_if_fail (GST_EVENT_TYPE (event) == GST_EVENT_STREAM_START); + + if (flags) { + gst_structure_id_get (GST_EVENT_STRUCTURE (event), + GST_QUARK (FLAGS), GST_TYPE_STREAM_FLAGS, flags, NULL); + } +} + /** * gst_event_new_toc: * @toc: (transfer none): #GstToc structure. diff --git a/gst/gstevent.h b/gst/gstevent.h index f0de0adb23..cecbae04d3 100644 --- a/gst/gstevent.h +++ b/gst/gstevent.h @@ -366,6 +366,20 @@ typedef enum { GST_QOS_TYPE_THROTTLE = 2 } GstQOSType; +/** + * GstStreamFlags: + * @GST_STREAM_FLAG_NONE: This stream has no special attributes + * @GST_STREAM_FLAG_SPARSE: This stream is a sparse stream (e.g. a subtitle + * stream), data may flow only in irregular intervals with large gaps in + * between. + * + * Since: 1.2 + */ +typedef enum { + GST_STREAM_FLAG_NONE, + GST_STREAM_FLAG_SPARSE = (1 << 0) +} GstStreamFlags; + /** * GstEvent: * @mini_object: the parent structure @@ -463,6 +477,9 @@ void gst_event_set_seqnum (GstEvent *event, guint32 seqnum 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); +void gst_event_set_stream_flags (GstEvent *event, GstStreamFlags flags); +void gst_event_parse_stream_flags (GstEvent *event, GstStreamFlags *flags); + /* flush events */ GstEvent * gst_event_new_flush_start (void) G_GNUC_MALLOC; diff --git a/tests/check/gst/gstevent.c b/tests/check/gst/gstevent.c index 7b3393b2e5..7aae693ccd 100644 --- a/tests/check/gst/gstevent.c +++ b/tests/check/gst/gstevent.c @@ -198,6 +198,27 @@ GST_START_TEST (create_events) gst_event_unref (event); } + /* STREAM_START */ + { + GstStreamFlags flags = ~GST_STREAM_FLAG_NONE; + + event = gst_event_new_stream_start ("7f4b2f0/audio_02"); + fail_if (event == NULL); + fail_unless (GST_EVENT_TYPE (event) == GST_EVENT_STREAM_START); + fail_if (GST_EVENT_IS_UPSTREAM (event)); + fail_unless (GST_EVENT_IS_DOWNSTREAM (event)); + fail_unless (GST_EVENT_IS_SERIALIZED (event)); + gst_event_parse_stream_flags (event, &flags); + fail_unless_equals_int (flags, GST_STREAM_FLAG_NONE); + gst_event_set_stream_flags (event, GST_STREAM_FLAG_SPARSE); + gst_event_parse_stream_flags (event, &flags); + fail_unless_equals_int (flags, GST_STREAM_FLAG_SPARSE); + gst_event_ref (event); + ASSERT_CRITICAL (gst_event_set_stream_flags (event, GST_STREAM_FLAG_NONE)); + gst_event_unref (event); + gst_event_unref (event); + } + /* NAVIGATION */ { structure = gst_structure_new ("application/x-gst-navigation", "event", diff --git a/win32/common/libgstreamer.def b/win32/common/libgstreamer.def index 8ee5e74c7f..3712007d3e 100644 --- a/win32/common/libgstreamer.def +++ b/win32/common/libgstreamer.def @@ -473,11 +473,13 @@ EXPORTS gst_event_parse_segment_done gst_event_parse_sink_message gst_event_parse_step + gst_event_parse_stream_flags gst_event_parse_stream_start gst_event_parse_tag gst_event_parse_toc gst_event_parse_toc_select gst_event_set_seqnum + gst_event_set_stream_flags gst_event_type_flags_get_type gst_event_type_get_flags gst_event_type_get_name @@ -1014,6 +1016,7 @@ EXPORTS gst_static_pad_template_get_type gst_stream_error_get_type gst_stream_error_quark + gst_stream_flags_get_type gst_stream_status_type_get_type gst_structure_can_intersect gst_structure_change_type_get_type