GST_OBJECT_UNLOCK (pads);
}
+ /**
+ * gst_collect_pads2_set_clip_function:
+ * @pads: the collectspads to use
+ * @clipfunc: clip function to install
+ * @user_data: user data to pass to @clip_func
+ *
+ * Install a clipping function that is called right after a buffer is received
+ * on a pad managed by @pads. See #GstCollectPad2ClipFunction for more info.
+ *
+ * Since: 0.10.36
+ */
+void
+gst_collect_pads2_set_clip_function (GstCollectPads2 * pads,
+ GstCollectPads2ClipFunction clipfunc, gpointer user_data)
+{
+ g_return_if_fail (pads != NULL);
+ g_return_if_fail (GST_IS_COLLECT_PADS2 (pads));
+
+ pads->clip_func = clipfunc;
+ pads->clip_user_data = user_data;
+}
+
/**
* gst_collect_pads2_add_pad:
* @pads: the collectspads to use
GST_COLLECT_PADS2_STATE_EOS)))
goto unexpected;
+ /* see if we need to clip */
+ if (pads->clip_func) {
+ buffer = pads->clip_func (pads, data, buffer, pads->clip_user_data);
+
+ if (G_UNLIKELY (buffer == NULL))
+ goto clipped;
+ }
+
GST_DEBUG_OBJECT (pads, "Queuing buffer %p for pad %s:%s", buffer,
GST_DEBUG_PAD_NAME (pad));
ret = GST_FLOW_UNEXPECTED;
goto unlock_done;
}
+clipped:
+ {
+ GST_DEBUG ("clipped buffer on pad %s:%s", GST_DEBUG_PAD_NAME (pad));
+ GST_OBJECT_UNLOCK (pads);
+ unref_data (data);
+ return GST_FLOW_OK;
+ }
error:
{
/* we print the error, the element should post a reasonable error
typedef gboolean (*GstCollectPads2EventFunction) (GstCollectPads2 *pads, GstCollectData2 * pad,
GstEvent * event, gpointer user_data);
+
+/**
+ * GstCollectPads2ClipFunction:
+ * @pads: a #GstCollectPads2
+ * @data: a #GstCollectData2
+ * @buffer: a #GstBuffer
+ * @user_data: user data
+ *
+ * A function that will be called when @buffer is received on the pad managed
+ * by @data in the collecpad object @pads.
+ *
+ * The function should use the segment of @data and the negotiated media type on
+ * the pad to perform clipping of @buffer.
+ *
+ * This function takes ownership of @buffer.
+ *
+ * Returns: a #GstBuffer that contains the clipped data of @buffer or NULL when
+ * the buffer has been clipped completely.
+ *
+ * Since: 0.10.36
+ */
+typedef GstBuffer * (*GstCollectPads2ClipFunction) (GstCollectPads2 *pads, GstCollectData2 *data,
+ GstBuffer *buffer, gpointer user_data);
+
/**
* GST_COLLECT_PADS2_GET_STREAM_LOCK:
* @pads: a #GstCollectPads2
gpointer compare_user_data;
GstCollectPads2EventFunction event_func; /* function and data for event callback */
gpointer event_user_data;
+ GstCollectPads2ClipFunction clip_func;
+ gpointer clip_user_data;
/* no other lock needed */
GMutex *evt_lock; /* these make up sort of poor man's event signaling */
GstCollectPads2EventFunction func, gpointer user_data);
void gst_collect_pads2_set_compare_function (GstCollectPads2 *pads,
GstCollectPads2CompareFunction func, gpointer user_data);
+void gst_collect_pads2_set_clip_function (GstCollectPads2 *pads, GstCollectPads2ClipFunction clipfunc,
+ gpointer user_data);
/* pad management */
GstCollectData2* gst_collect_pads2_add_pad (GstCollectPads2 *pads, GstPad *pad, guint size);