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 <misha@pexip.com>

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/551>
This commit is contained in:
Sebastian Dröge 2020-07-01 19:15:42 +03:00 committed by Sebastian Dröge
parent 1a59eeedb4
commit 8d0055e185
4 changed files with 65 additions and 1 deletions

View file

@ -826,6 +826,47 @@ gst_event_parse_gap (GstEvent * event, GstClockTime * timestamp,
GST_QUARK (DURATION), GST_TYPE_CLOCK_TIME, duration, NULL);
}
/**
* 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

View file

@ -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

View file

@ -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];

View file

@ -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];