mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-04-26 06:54:49 +00:00
gstevent: Add function for checking event name by GQuark
Avoids doing string<=>quark conversions in the sticky event handling path. Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/455>
This commit is contained in:
parent
1d0bda8005
commit
7a207da733
3 changed files with 29 additions and 3 deletions
|
@ -407,6 +407,29 @@ gst_event_has_name (GstEvent * event, const gchar * name)
|
||||||
return gst_structure_has_name (GST_EVENT_STRUCTURE (event), name);
|
return gst_structure_has_name (GST_EVENT_STRUCTURE (event), name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gst_event_has_name_id:
|
||||||
|
* @event: The #GstEvent.
|
||||||
|
* @name: name to check as a GQuark
|
||||||
|
*
|
||||||
|
* Checks if @event has the given @name. This function is usually used to
|
||||||
|
* check the name of a custom event.
|
||||||
|
*
|
||||||
|
* Returns: %TRUE if @name matches the name of the event structure.
|
||||||
|
*
|
||||||
|
* Since: 1.18
|
||||||
|
*/
|
||||||
|
gboolean
|
||||||
|
gst_event_has_name_id (GstEvent * event, GQuark name)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (GST_IS_EVENT (event), FALSE);
|
||||||
|
|
||||||
|
if (GST_EVENT_STRUCTURE (event) == NULL)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
return (GST_EVENT_STRUCTURE (event)->name == name);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* gst_event_get_seqnum:
|
* gst_event_get_seqnum:
|
||||||
* @event: A #GstEvent.
|
* @event: A #GstEvent.
|
||||||
|
|
|
@ -517,6 +517,9 @@ GstStructure * gst_event_writable_structure (GstEvent *event);
|
||||||
GST_API
|
GST_API
|
||||||
gboolean gst_event_has_name (GstEvent *event, const gchar *name);
|
gboolean gst_event_has_name (GstEvent *event, const gchar *name);
|
||||||
|
|
||||||
|
GST_API
|
||||||
|
gboolean gst_event_has_name_id (GstEvent *event, GQuark name);
|
||||||
|
|
||||||
/* identifiers for events and messages */
|
/* identifiers for events and messages */
|
||||||
|
|
||||||
GST_API
|
GST_API
|
||||||
|
|
|
@ -5220,7 +5220,7 @@ store_sticky_event (GstPad * pad, GstEvent * event)
|
||||||
GstEventType type;
|
GstEventType type;
|
||||||
GArray *events;
|
GArray *events;
|
||||||
gboolean res = FALSE;
|
gboolean res = FALSE;
|
||||||
const gchar *name = NULL;
|
GQuark name_id = 0;
|
||||||
gboolean insert = TRUE;
|
gboolean insert = TRUE;
|
||||||
|
|
||||||
type = GST_EVENT_TYPE (event);
|
type = GST_EVENT_TYPE (event);
|
||||||
|
@ -5248,7 +5248,7 @@ store_sticky_event (GstPad * pad, GstEvent * event)
|
||||||
goto eos;
|
goto eos;
|
||||||
|
|
||||||
if (type & GST_EVENT_TYPE_STICKY_MULTI)
|
if (type & GST_EVENT_TYPE_STICKY_MULTI)
|
||||||
name = gst_structure_get_name (gst_event_get_structure (event));
|
name_id = gst_structure_get_name_id (gst_event_get_structure (event));
|
||||||
|
|
||||||
events = pad->priv->events;
|
events = pad->priv->events;
|
||||||
len = events->len;
|
len = events->len;
|
||||||
|
@ -5261,7 +5261,7 @@ store_sticky_event (GstPad * pad, GstEvent * event)
|
||||||
|
|
||||||
if (type == GST_EVENT_TYPE (ev->event)) {
|
if (type == GST_EVENT_TYPE (ev->event)) {
|
||||||
/* matching types, check matching name if needed */
|
/* matching types, check matching name if needed */
|
||||||
if (name && !gst_event_has_name (ev->event, name))
|
if (name_id && !gst_event_has_name_id (ev->event, name_id))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
/* overwrite */
|
/* overwrite */
|
||||||
|
|
Loading…
Reference in a new issue