/* no need to unset, it's just a pointer */
return g_value_get_pointer (&ret);
}
+
+typedef struct
+{
+ GstIterator parent;
+ gpointer object;
+ GstCopyFunction copy;
+ GFreeFunc free;
+ gboolean visited;
+} GstSingleObjectIterator;
+
+static guint32 _single_object_dummy_cookie = 0;
+
+static GstIteratorResult
+gst_single_object_iterator_iterator_next (GstSingleObjectIterator * it,
+ gpointer * result)
+{
+ if (it->visited) {
+ *result = NULL;
+ return GST_ITERATOR_DONE;
+ }
+
+ *result = it->copy (it->object);
+ return GST_ITERATOR_OK;
+}
+
+static void
+gst_single_object_iterator_resync (GstSingleObjectIterator * it)
+{
+ it->visited = FALSE;
+}
+
+static void
+gst_single_object_iterator_free (GstSingleObjectIterator * it)
+{
+ it->free (it->object);
+ g_free (it);
+}
+
+/**
+ * gst_iterator_new:
+ * @type: #GType of the passed object
+ * @object: object that this iterator should return
+ * @copy: Function that returns a copy of @object or increases it's refcount
+ * @free: Function to be called for freeing @object
+ *
+ * This #GstIterator is a convenient iterator for the common
+ * case where a #GstIterator needs to be returned but only
+ * a single object has the be considered. This happens often
+ * for the #GstPadIterIntLinkFunction.
+ *
+ * Since: 0.10.25
+ *
+ */
+GstIterator *
+gst_iterator_new_single (GType type, gpointer object, GstCopyFunction copy,
+ GFreeFunc free)
+{
+ GstSingleObjectIterator *result;
+
+ g_return_val_if_fail (object != NULL, NULL);
+ g_return_val_if_fail (copy != NULL, NULL);
+ g_return_val_if_fail (free != NULL, NULL);
+
+ result = (GstSingleObjectIterator *)
+ gst_iterator_new (sizeof (GstSingleObjectIterator),
+ G_TYPE_FROM_INSTANCE (object), NULL, &_single_object_dummy_cookie,
+ (GstIteratorNextFunction) gst_single_object_iterator_iterator_next, NULL,
+ (GstIteratorResyncFunction) gst_single_object_iterator_resync,
+ (GstIteratorFreeFunction) gst_single_object_iterator_free);
+
+ result->object = copy (object);
+ result->copy = copy;
+ result->free = free;
+ result->visited = FALSE;
+
+ return (GstIterator *) result;
+}
typedef gboolean (*GstIteratorFoldFunction) (gpointer item, GValue *ret, gpointer user_data);
/**
+ * GstCopyFunction:
+ * @object: The object to copy
+ *
+ * A function to create a copy of some object or
+ * increase it's reference count.
+ *
+ * Returns: a copy of the object or the same object with increased reference count
+ *
+ * Since: 0.10.25
+ */
+typedef gpointer (*GstCopyFunction) (gpointer object);
+
+/**
* GST_ITERATOR:
* @it: the #GstIterator value
*
GstIteratorItemFunction item,
GstIteratorDisposeFunction free);
+GstIterator* gst_iterator_new_single (GType type,
+ gpointer object,
+ GstCopyFunction copy,
+ GFreeFunc free);
+
/* using iterators */
GstIteratorResult gst_iterator_next (GstIterator *it, gpointer *elem);
void gst_iterator_resync (GstIterator *it);