From 8d0055e185645ca038146344e3a4f9285ad781a1 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sebastian=20Dr=C3=B6ge?= Date: Wed, 1 Jul 2020 19:15:42 +0300 Subject: [PATCH] event: Add optional flags to the GAP event This allows to signal the reason for the gap, for example missing data like packet loss. Based on a patch by Mikhail Fludkov Part-of: --- gst/gstevent.c | 41 +++++++++++++++++++++++++++++++++++++++++ gst/gstevent.h | 21 +++++++++++++++++++++ gst/gstquark.c | 1 + gst/gstquark.h | 3 ++- 4 files changed, 65 insertions(+), 1 deletion(-) diff --git a/gst/gstevent.c b/gst/gstevent.c index d61c722..1f94744 100644 --- a/gst/gstevent.c +++ b/gst/gstevent.c @@ -827,6 +827,47 @@ gst_event_parse_gap (GstEvent * event, GstClockTime * timestamp, } /** + * gst_event_set_gap_flags: + * @event: a #GstEvent of type #GST_EVENT_GAP + * @flags: a #GstGapFlags + * + * Sets @flags on @event to give additional information about the reason for + * the #GST_EVENT_GAP. + * + * Since: 1.20 + */ +void +gst_event_set_gap_flags (GstEvent * event, GstGapFlags flags) +{ + g_return_if_fail (event != NULL); + g_return_if_fail (GST_EVENT_TYPE (event) == GST_EVENT_GAP); + g_return_if_fail (gst_event_is_writable (event)); + + gst_structure_id_set (GST_EVENT_STRUCTURE (event), + GST_QUARK (GAP_FLAGS), GST_TYPE_GAP_FLAGS, flags, NULL); +} + +/** + * gst_event_parse_gap_flags: + * @event: a #GstEvent of type #GST_EVENT_GAP + * @flags: (out): a #GstGapFlags or %NULL + * + * Retrieve the gap flags that may have been set on a gap event with + * gst_event_set_gap_flags(). + * + * Since: 1.20 + */ +void +gst_event_parse_gap_flags (GstEvent * event, GstGapFlags * flags) +{ + g_return_if_fail (event != NULL); + g_return_if_fail (GST_EVENT_TYPE (event) == GST_EVENT_GAP); + + gst_structure_id_get (GST_EVENT_STRUCTURE (event), + GST_QUARK (GAP_FLAGS), GST_TYPE_GAP_FLAGS, flags, NULL); +} + +/** * gst_event_new_caps: * @caps: (transfer none): a #GstCaps * diff --git a/gst/gstevent.h b/gst/gstevent.h index 6e6280a..603d684 100644 --- a/gst/gstevent.h +++ b/gst/gstevent.h @@ -404,6 +404,19 @@ typedef enum { GST_QOS_TYPE_THROTTLE = 2 } GstQOSType; +/** + * GstGapFlags: + * @GST_GAP_FLAG_MISSING_DATA: The #GST_EVENT_GAP signals missing data, + * for example because of packet loss. + * + * The different flags that can be set on #GST_EVENT_GAP events. See + * gst_event_set_gap_flags() for details. + * + * Since: 1.20 + */ +typedef enum { + GST_GAP_FLAG_MISSING_DATA = (1<<0), +} GstGapFlags; /** * GstEvent: @@ -612,6 +625,14 @@ void gst_event_parse_gap (GstEvent * event, GstClockTime * timestamp, GstClockTime * duration); +GST_API +void gst_event_set_gap_flags (GstEvent * event, + GstGapFlags flags); + +GST_API +void gst_event_parse_gap_flags (GstEvent * event, + GstGapFlags * flags); + /* Caps events */ GST_API diff --git a/gst/gstquark.c b/gst/gstquark.c index daf6a51..dd9f1c1 100644 --- a/gst/gstquark.c +++ b/gst/gstquark.c @@ -80,6 +80,7 @@ static const gchar *_quark_strings[] = { "GstEventInstantRateChange", "GstEventInstantRateSyncTime", "GstMessageInstantRateRequest", "upstream-running-time", "base", "offset", "plugin-api", "plugin-api-flags", + "gap-flags" }; GQuark _priv_gst_quark_table[GST_QUARK_MAX]; diff --git a/gst/gstquark.h b/gst/gstquark.h index cc796bc..df2e585 100644 --- a/gst/gstquark.h +++ b/gst/gstquark.h @@ -230,7 +230,8 @@ typedef enum _GstQuarkId GST_QUARK_OFFSET = 199, GST_QUARK_PLUGIN_API = 200, GST_QUARK_PLUGIN_API_FLAGS = 201, - GST_QUARK_MAX = 202 + GST_QUARK_GAP_FLAGS = 202, + GST_QUARK_MAX = 203 } GstQuarkId; extern GQuark _priv_gst_quark_table[GST_QUARK_MAX]; -- 2.7.4