mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-18 20:25:25 +00:00
basesrc: provide fallback in case a create function doesn't know about provided buffers
In 0.11 the caller may provide a buffer to be filled by the source to pull_range/get_range/create, but it's easy to miss this new case when porting code from 0.10. Provide fallback that copies the created data into the provided buffer for now. This makes oggdemux in pull-mode work with dataurisrc.
This commit is contained in:
parent
82eb275ef9
commit
ebcfd0ce05
1 changed files with 21 additions and 1 deletions
|
@ -2280,6 +2280,7 @@ gst_base_src_get_range (GstBaseSrc * src, guint64 offset, guint length,
|
|||
GstBaseSrcClass *bclass;
|
||||
GstClockReturn status;
|
||||
GstBuffer *res_buf;
|
||||
GstBuffer *in_buf;
|
||||
|
||||
bclass = GST_BASE_SRC_GET_CLASS (src);
|
||||
|
||||
|
@ -2325,7 +2326,7 @@ again:
|
|||
"calling create offset %" G_GUINT64_FORMAT " length %u, time %"
|
||||
G_GINT64_FORMAT, offset, length, src->segment.time);
|
||||
|
||||
res_buf = *buf;
|
||||
res_buf = in_buf = *buf;
|
||||
|
||||
ret = bclass->create (src, offset, length, &res_buf);
|
||||
|
||||
|
@ -2343,6 +2344,25 @@ again:
|
|||
if (G_UNLIKELY (ret != GST_FLOW_OK))
|
||||
goto not_ok;
|
||||
|
||||
/* fallback in case the create function didn't fill a provided buffer */
|
||||
if (in_buf != NULL && res_buf != in_buf) {
|
||||
GstMapInfo info;
|
||||
gsize copied_size;
|
||||
|
||||
GST_CAT_DEBUG_OBJECT (GST_CAT_PERFORMANCE, src, "create function didn't "
|
||||
"fill the provided buffer, copying");
|
||||
|
||||
gst_buffer_map (in_buf, &info, GST_MAP_WRITE);
|
||||
copied_size = gst_buffer_extract (res_buf, 0, info.data, info.size);
|
||||
gst_buffer_unmap (in_buf, &info);
|
||||
gst_buffer_set_size (in_buf, copied_size);
|
||||
|
||||
gst_buffer_copy_into (in_buf, res_buf, GST_BUFFER_COPY_METADATA, 0, -1);
|
||||
|
||||
gst_buffer_unref (res_buf);
|
||||
res_buf = in_buf;
|
||||
}
|
||||
|
||||
/* no timestamp set and we are at offset 0, we can timestamp with 0 */
|
||||
if (offset == 0 && src->segment.time == 0
|
||||
&& GST_BUFFER_DTS (res_buf) == -1 && !src->is_live) {
|
||||
|
|
Loading…
Reference in a new issue