context: add foreach function

Add a function to iterate over all stored events.
This commit is contained in:
Wim Taymans 2011-05-05 10:40:14 +02:00
parent c4751ec8c1
commit 08dbe37f6f
2 changed files with 23 additions and 0 deletions

View file

@ -181,3 +181,22 @@ gst_context_clear (GstContext * context)
for (i = 0; i < GST_EVENT_MAX_STICKY; i++)
gst_event_replace (&context->events[i], NULL);
}
/**
* gst_context_foreach:
* @context: a #GstContext
* @func: a #GFunc
* @user_data: user data
*
* Call @func with the non NULL event and @user_data.
*/
void
gst_context_foreach (GstContext * context, GFunc func, gpointer user_data)
{
guint i;
GstEvent *event;
for (i = 0; i < GST_EVENT_MAX_STICKY; i++)
if ((event = context->events[i]))
func (event, user_data);
}

View file

@ -134,11 +134,15 @@ gst_context_copy (const GstContext * context)
GstContext * gst_context_new (void);
/* updating and setting events */
void gst_context_update (GstContext *context, GstEvent *event);
GstEvent * gst_context_get (GstContext *context, GstEventType type);
void gst_context_clear (GstContext *context);
/* foreach */
void gst_context_foreach (GstContext *context, GFunc func, gpointer user_data);
G_END_DECLS
#endif /* __GST_CONTEXT_H__ */