mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-23 16:50:47 +00:00
collectpads2: Merge the clip and prepare_buffer function into one
This commit is contained in:
parent
415f3dd808
commit
2f100e86f6
4 changed files with 24 additions and 71 deletions
|
@ -754,11 +754,10 @@ GstCollectData2DestroyNotify
|
|||
GstCollectPads2BufferFunction
|
||||
GstCollectPads2CompareFunction
|
||||
GstCollectPads2EventFunction
|
||||
GstCollectPads2ClipFunction
|
||||
GstCollectPads2Function
|
||||
GstCollectPads2StateFlags
|
||||
|
||||
GST_COLLECT_PADS2_FLOW_DROP
|
||||
|
||||
GST_COLLECT_PADS2_STATE
|
||||
GST_COLLECT_PADS2_STATE_IS_SET
|
||||
GST_COLLECT_PADS2_STATE_SET
|
||||
|
@ -794,9 +793,9 @@ gst_collect_pads2_take_buffer
|
|||
gst_collect_pads2_set_buffer_function
|
||||
gst_collect_pads2_set_compare_function
|
||||
gst_collect_pads2_set_event_function
|
||||
gst_collect_pads2_set_clip_function
|
||||
gst_collect_pads2_set_flushing
|
||||
gst_collect_pads2_set_function
|
||||
gst_collect_pads2_set_prepare_buffer_function
|
||||
gst_collect_pads2_set_waiting
|
||||
<SUBSECTION Standard>
|
||||
GstCollectPads2Class
|
||||
|
|
|
@ -176,9 +176,6 @@ gst_collect_pads2_init (GstCollectPads2 * pads)
|
|||
pads->event_func = NULL;
|
||||
pads->event_user_data = NULL;
|
||||
|
||||
pads->prepare_buffer_func = NULL;
|
||||
pads->prepare_buffer_user_data = NULL;
|
||||
|
||||
/* members for default muxing */
|
||||
pads->buffer_func = NULL;
|
||||
pads->buffer_user_data = NULL;
|
||||
|
@ -239,32 +236,6 @@ gst_collect_pads2_new (void)
|
|||
return newcoll;
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_collect_pads2_set_prepare_buffer_function:
|
||||
* @pads: the collectpads to use
|
||||
* @func: the function to set
|
||||
* @user_data: user data passed to the function
|
||||
*
|
||||
* Set the callback function and user data that will be called
|
||||
* for every buffer that arrives.
|
||||
*
|
||||
* MT safe.
|
||||
*
|
||||
* Since: 0.10.36
|
||||
*/
|
||||
void
|
||||
gst_collect_pads2_set_prepare_buffer_function (GstCollectPads2 * pads,
|
||||
GstCollectPads2BufferFunction func, gpointer user_data)
|
||||
{
|
||||
g_return_if_fail (pads != NULL);
|
||||
g_return_if_fail (GST_IS_COLLECT_PADS2 (pads));
|
||||
|
||||
GST_OBJECT_LOCK (pads);
|
||||
pads->prepare_buffer_func = func;
|
||||
pads->prepare_buffer_user_data = user_data;
|
||||
GST_OBJECT_UNLOCK (pads);
|
||||
}
|
||||
|
||||
/* Must be called with GstObject lock! */
|
||||
static void
|
||||
gst_collect_pads2_set_buffer_function_locked (GstCollectPads2 * pads,
|
||||
|
@ -1826,8 +1797,6 @@ gst_collect_pads2_chain (GstPad * pad, GstBuffer * buffer)
|
|||
GstFlowReturn ret;
|
||||
GstBuffer **buffer_p;
|
||||
guint32 cookie;
|
||||
GstCollectPads2BufferFunction prepare_buffer_func;
|
||||
gpointer prepare_buffer_user_data;
|
||||
|
||||
GST_DEBUG ("Got buffer for pad %s:%s", GST_DEBUG_PAD_NAME (pad));
|
||||
|
||||
|
@ -1840,10 +1809,6 @@ gst_collect_pads2_chain (GstPad * pad, GstBuffer * buffer)
|
|||
GST_OBJECT_UNLOCK (pad);
|
||||
|
||||
pads = data->collect;
|
||||
GST_OBJECT_LOCK (pads);
|
||||
prepare_buffer_func = pads->prepare_buffer_func;
|
||||
prepare_buffer_user_data = pads->prepare_buffer_user_data;
|
||||
GST_OBJECT_UNLOCK (pads);
|
||||
|
||||
GST_COLLECT_PADS2_STREAM_LOCK (pads);
|
||||
/* if not started, bail out */
|
||||
|
@ -1860,28 +1825,22 @@ gst_collect_pads2_chain (GstPad * pad, GstBuffer * buffer)
|
|||
|
||||
/* see if we need to clip */
|
||||
if (pads->clip_func) {
|
||||
buffer = pads->clip_func (pads, data, buffer, pads->clip_user_data);
|
||||
GstBuffer *outbuf = NULL;
|
||||
ret = pads->clip_func (pads, data, buffer, &outbuf, pads->clip_user_data);
|
||||
|
||||
if (G_UNLIKELY (buffer == NULL))
|
||||
if (G_UNLIKELY (outbuf == NULL))
|
||||
goto clipped;
|
||||
|
||||
buffer = outbuf;
|
||||
if (G_UNLIKELY (ret == GST_FLOW_UNEXPECTED))
|
||||
goto unexpected;
|
||||
else if (G_UNLIKELY (ret != GST_FLOW_OK))
|
||||
goto error;
|
||||
}
|
||||
|
||||
GST_DEBUG_OBJECT (pads, "Queuing buffer %p for pad %s:%s", buffer,
|
||||
GST_DEBUG_PAD_NAME (pad));
|
||||
|
||||
if (prepare_buffer_func) {
|
||||
ret = prepare_buffer_func (pads, data, buffer, prepare_buffer_user_data);
|
||||
if (ret == GST_COLLECT_PADS2_FLOW_DROP) {
|
||||
GST_DEBUG_OBJECT (pads, "Dropping buffer as requested");
|
||||
ret = GST_FLOW_OK;
|
||||
goto unlock_done;
|
||||
} else if (ret == GST_FLOW_UNEXPECTED) {
|
||||
goto unexpected;
|
||||
} else if (ret != GST_FLOW_OK) {
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
|
||||
/* One more pad has data queued */
|
||||
if (GST_COLLECT_PADS2_STATE_IS_SET (data, GST_COLLECT_PADS2_STATE_WAITING))
|
||||
pads->queuedpads++;
|
||||
|
@ -1996,9 +1955,8 @@ unexpected:
|
|||
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;
|
||||
ret = GST_FLOW_OK;
|
||||
goto unlock_done;
|
||||
}
|
||||
error:
|
||||
{
|
||||
|
|
|
@ -113,8 +113,6 @@ typedef enum {
|
|||
*/
|
||||
#define GST_COLLECT_PADS2_STATE_UNSET(data,flag) (GST_COLLECT_PADS2_STATE (data) &= ~(flag))
|
||||
|
||||
#define GST_COLLECT_PADS2_FLOW_DROP GST_FLOW_CUSTOM_SUCCESS
|
||||
|
||||
/**
|
||||
* GstCollectData2:
|
||||
* @collect: owner #GstCollectPads2
|
||||
|
@ -222,24 +220,26 @@ typedef gboolean (*GstCollectPads2EventFunction) (GstCollectPads2 *pads, GstColl
|
|||
* GstCollectPads2ClipFunction:
|
||||
* @pads: a #GstCollectPads2
|
||||
* @data: a #GstCollectData2
|
||||
* @buffer: a #GstBuffer
|
||||
* @inbuffer: the input #GstBuffer
|
||||
* @outbuffer: the output #GstBuffer
|
||||
* @user_data: user data
|
||||
*
|
||||
* A function that will be called when @buffer is received on the pad managed
|
||||
* A function that will be called when @inbuffer 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.
|
||||
* the pad to perform clipping of @inbuffer.
|
||||
*
|
||||
* This function takes ownership of @buffer.
|
||||
* This function takes ownership of @inbuffer and should output a buffer in
|
||||
* @outbuffer or return %NULL in @outbuffer if the buffer should be dropped.
|
||||
*
|
||||
* Returns: a #GstBuffer that contains the clipped data of @buffer or NULL when
|
||||
* the buffer has been clipped completely.
|
||||
* Returns: a #GstFlowReturn that corresponds to the result of clipping.
|
||||
*
|
||||
* Since: 0.10.36
|
||||
*/
|
||||
typedef GstBuffer * (*GstCollectPads2ClipFunction) (GstCollectPads2 *pads, GstCollectData2 *data,
|
||||
GstBuffer *buffer, gpointer user_data);
|
||||
typedef GstFlowReturn (*GstCollectPads2ClipFunction) (GstCollectPads2 *pads, GstCollectData2 *data,
|
||||
GstBuffer *inbuffer, GstBuffer **outbuffer,
|
||||
gpointer user_data);
|
||||
|
||||
/**
|
||||
* GST_COLLECT_PADS2_GET_STREAM_LOCK:
|
||||
|
@ -304,8 +304,6 @@ struct _GstCollectPads2 {
|
|||
|
||||
GstCollectPads2Function func; /* function and user_data for callback */
|
||||
gpointer user_data;
|
||||
GstCollectPads2BufferFunction prepare_buffer_func; /* function and user_data for prepare buffer callback */
|
||||
gpointer prepare_buffer_user_data;
|
||||
GstCollectPads2BufferFunction buffer_func; /* function and user_data for buffer callback */
|
||||
gpointer buffer_user_data;
|
||||
GstCollectPads2CompareFunction compare_func;
|
||||
|
@ -339,8 +337,6 @@ GstCollectPads2* gst_collect_pads2_new (void);
|
|||
/* set the callbacks */
|
||||
void gst_collect_pads2_set_function (GstCollectPads2 *pads, GstCollectPads2Function func,
|
||||
gpointer user_data);
|
||||
void gst_collect_pads2_set_prepare_buffer_function (GstCollectPads2 *pads,
|
||||
GstCollectPads2BufferFunction func, gpointer user_data);
|
||||
void gst_collect_pads2_set_buffer_function (GstCollectPads2 *pads,
|
||||
GstCollectPads2BufferFunction func, gpointer user_data);
|
||||
void gst_collect_pads2_set_event_function (GstCollectPads2 *pads,
|
||||
|
|
|
@ -222,11 +222,11 @@ EXPORTS
|
|||
gst_collect_pads2_read_buffer
|
||||
gst_collect_pads2_remove_pad
|
||||
gst_collect_pads2_set_buffer_function
|
||||
gst_collect_pads2_set_clip_function
|
||||
gst_collect_pads2_set_compare_function
|
||||
gst_collect_pads2_set_event_function
|
||||
gst_collect_pads2_set_flushing
|
||||
gst_collect_pads2_set_function
|
||||
gst_collect_pads2_set_prepare_buffer_function
|
||||
gst_collect_pads2_set_waiting
|
||||
gst_collect_pads2_start
|
||||
gst_collect_pads2_stop
|
||||
|
|
Loading…
Reference in a new issue