context: add foreach function
authorWim Taymans <wim.taymans@collabora.co.uk>
Thu, 5 May 2011 08:40:14 +0000 (10:40 +0200)
committerWim Taymans <wim.taymans@collabora.co.uk>
Thu, 5 May 2011 11:17:08 +0000 (13:17 +0200)
Add a function to iterate over all stored events.

gst/gstcontext.c
gst/gstcontext.h

index 7f610b6..d6ca462 100644 (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);
+}
index b292b5d..34e0d49 100644 (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__ */