kmssink: Factor out copying to dump buffer

This will be used to copy any upstream memory in order to return it on
resolution change, allocation query or drain query.

https://bugzilla.gnome.org/show_bug.cgi?id=782774
This commit is contained in:
Nicolas Dufresne 2017-07-05 16:51:12 -04:00
parent 8a070cf9af
commit 6e3fe4eaab

View file

@ -1136,26 +1136,12 @@ wrap_mem:
}
static GstBuffer *
gst_kms_sink_get_input_buffer (GstKMSSink * self, GstBuffer * inbuf)
gst_kms_sink_copy_to_dumb_buffer (GstKMSSink * self, GstBuffer * inbuf)
{
GstMemory *mem;
GstBuffer *buf;
GstFlowReturn ret;
GstVideoFrame inframe, outframe;
gboolean success;
mem = gst_buffer_peek_memory (inbuf, 0);
if (!mem)
return NULL;
if (gst_is_kms_memory (mem))
return gst_buffer_ref (inbuf);
buf = NULL;
if (gst_kms_sink_import_dmabuf (self, inbuf, &buf))
return buf;
GST_CAT_INFO_OBJECT (CAT_PERFORMANCE, self, "frame copy");
GstBuffer *buf;
if (!gst_buffer_pool_set_active (self->pool, TRUE))
goto activate_pool_failed;
@ -1215,6 +1201,27 @@ error_map_src_buffer:
}
}
static GstBuffer *
gst_kms_sink_get_input_buffer (GstKMSSink * self, GstBuffer * inbuf)
{
GstMemory *mem;
GstBuffer *buf = NULL;
mem = gst_buffer_peek_memory (inbuf, 0);
if (!mem)
return NULL;
if (gst_is_kms_memory (mem))
return gst_buffer_ref (inbuf);
if (gst_kms_sink_import_dmabuf (self, inbuf, &buf))
return buf;
GST_CAT_INFO_OBJECT (CAT_PERFORMANCE, self, "frame copy");
return gst_kms_sink_copy_to_dumb_buffer (self, inbuf);
}
static GstFlowReturn
gst_kms_sink_show_frame (GstVideoSink * vsink, GstBuffer * buf)
{