mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 20:21:24 +00:00
collectpads2: add convenience clipping function
... which also converts to running time; useful for typical muxer.
This commit is contained in:
parent
78565da18b
commit
28e9d735bb
2 changed files with 47 additions and 0 deletions
|
@ -401,6 +401,48 @@ gst_collect_pads2_set_event_function (GstCollectPads2 * pads,
|
||||||
GST_OBJECT_UNLOCK (pads);
|
GST_OBJECT_UNLOCK (pads);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gst_collect_pads2_clip_running:
|
||||||
|
* @pads: the collectspads to use
|
||||||
|
* @cdata: collect data of corrsponding pad
|
||||||
|
* @buf: buffer being clipped
|
||||||
|
* @outbuf: output buffer with running time, or NULL if clipped
|
||||||
|
* @user_data: user data (unused)
|
||||||
|
*
|
||||||
|
* Convenience clipping function that converts incoming buffer's timestamp
|
||||||
|
* to running time, or clips the buffer if outside configured segment.
|
||||||
|
*
|
||||||
|
* Since: 0.10.37
|
||||||
|
*/
|
||||||
|
GstFlowReturn
|
||||||
|
gst_collect_pads2_clip_running_time (GstCollectPads2 * pads,
|
||||||
|
GstCollectData2 * cdata, GstBuffer * buf, GstBuffer ** outbuf,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
GstClockTime time;
|
||||||
|
|
||||||
|
*outbuf = buf;
|
||||||
|
time = GST_BUFFER_TIMESTAMP (buf);
|
||||||
|
|
||||||
|
/* invalid left alone and passed */
|
||||||
|
if (G_LIKELY (GST_CLOCK_TIME_IS_VALID (time))) {
|
||||||
|
time = gst_segment_to_running_time (&cdata->segment, GST_FORMAT_TIME, time);
|
||||||
|
if (G_UNLIKELY (!GST_CLOCK_TIME_IS_VALID (time))) {
|
||||||
|
GST_DEBUG_OBJECT (cdata->pad, "clipping buffer on pad outside segment");
|
||||||
|
gst_buffer_unref (buf);
|
||||||
|
*outbuf = NULL;
|
||||||
|
} else {
|
||||||
|
GST_LOG_OBJECT (cdata->pad, "buffer ts %" GST_TIME_FORMAT " -> %"
|
||||||
|
GST_TIME_FORMAT " running time",
|
||||||
|
GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (buf)), GST_TIME_ARGS (time));
|
||||||
|
*outbuf = gst_buffer_make_metadata_writable (buf);
|
||||||
|
GST_BUFFER_TIMESTAMP (*outbuf) = time;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return GST_FLOW_OK;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* gst_collect_pads2_set_clip_function:
|
* gst_collect_pads2_set_clip_function:
|
||||||
* @pads: the collectspads to use
|
* @pads: the collectspads to use
|
||||||
|
|
|
@ -380,6 +380,11 @@ GstBuffer* gst_collect_pads2_take_buffer (GstCollectPads2 * pads, GstCollectData
|
||||||
void gst_collect_pads2_set_waiting (GstCollectPads2 *pads, GstCollectData2 *data,
|
void gst_collect_pads2_set_waiting (GstCollectPads2 *pads, GstCollectData2 *data,
|
||||||
gboolean waiting);
|
gboolean waiting);
|
||||||
|
|
||||||
|
/* convenience helper */
|
||||||
|
GstFlowReturn gst_collect_pads2_clip_running_time (GstCollectPads2 * pads,
|
||||||
|
GstCollectData2 * cdata, GstBuffer * buf, GstBuffer ** outbuf,
|
||||||
|
gpointer user_data);
|
||||||
|
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue