mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-04-05 23:59:55 +00:00
filesink: implement ::render_list() function that uses writev()
This commit is contained in:
parent
ad3e12b006
commit
5a4fb5c314
2 changed files with 53 additions and 0 deletions
plugins/elements
|
@ -68,6 +68,8 @@
|
|||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#include "gstelements_private.h"
|
||||
|
||||
static GstStaticPadTemplate sinktemplate = GST_STATIC_PAD_TEMPLATE ("sink",
|
||||
GST_PAD_SINK,
|
||||
GST_PAD_ALWAYS,
|
||||
|
@ -164,6 +166,8 @@ static gboolean gst_file_sink_stop (GstBaseSink * sink);
|
|||
static gboolean gst_file_sink_event (GstBaseSink * sink, GstEvent * event);
|
||||
static GstFlowReturn gst_file_sink_render (GstBaseSink * sink,
|
||||
GstBuffer * buffer);
|
||||
static GstFlowReturn gst_file_sink_render_list (GstBaseSink * sink,
|
||||
GstBufferList * list);
|
||||
|
||||
static gboolean gst_file_sink_do_seek (GstFileSink * filesink,
|
||||
guint64 new_offset);
|
||||
|
@ -231,6 +235,8 @@ gst_file_sink_class_init (GstFileSinkClass * klass)
|
|||
gstbasesink_class->stop = GST_DEBUG_FUNCPTR (gst_file_sink_stop);
|
||||
gstbasesink_class->query = GST_DEBUG_FUNCPTR (gst_file_sink_query);
|
||||
gstbasesink_class->render = GST_DEBUG_FUNCPTR (gst_file_sink_render);
|
||||
gstbasesink_class->render_list =
|
||||
GST_DEBUG_FUNCPTR (gst_file_sink_render_list);
|
||||
gstbasesink_class->event = GST_DEBUG_FUNCPTR (gst_file_sink_event);
|
||||
|
||||
if (sizeof (off_t) < 8) {
|
||||
|
@ -646,6 +652,52 @@ gst_file_sink_get_current_offset (GstFileSink * filesink, guint64 * p_pos)
|
|||
return (ret != (off_t) - 1);
|
||||
}
|
||||
|
||||
static GstFlowReturn
|
||||
gst_file_sink_render_buffers (GstFileSink * sink, GstBuffer ** buffers,
|
||||
guint num_buffers, guint8 * mem_nums, guint total_mems)
|
||||
{
|
||||
return gst_writev_buffers (GST_OBJECT_CAST (sink), fileno (sink->file), NULL,
|
||||
buffers, num_buffers, mem_nums, total_mems, NULL, &sink->current_pos);
|
||||
}
|
||||
|
||||
static GstFlowReturn
|
||||
gst_file_sink_render_list (GstBaseSink * bsink, GstBufferList * buffer_list)
|
||||
{
|
||||
GstFlowReturn flow;
|
||||
GstBuffer **buffers;
|
||||
GstFileSink *sink;
|
||||
guint8 *mem_nums;
|
||||
guint total_mems;
|
||||
guint i, num_buffers;
|
||||
|
||||
sink = GST_FILE_SINK_CAST (bsink);
|
||||
|
||||
num_buffers = gst_buffer_list_length (buffer_list);
|
||||
if (num_buffers == 0)
|
||||
goto no_data;
|
||||
|
||||
/* extract buffers from list and count memories */
|
||||
buffers = g_newa (GstBuffer *, num_buffers);
|
||||
mem_nums = g_newa (guint8, num_buffers);
|
||||
for (i = 0, total_mems = 0; i < num_buffers; ++i) {
|
||||
buffers[i] = gst_buffer_list_get (buffer_list, i);
|
||||
mem_nums[i] = gst_buffer_n_memory (buffers[i]);
|
||||
total_mems += mem_nums[i];
|
||||
}
|
||||
|
||||
flow =
|
||||
gst_file_sink_render_buffers (sink, buffers, num_buffers, mem_nums,
|
||||
total_mems);
|
||||
|
||||
return flow;
|
||||
|
||||
no_data:
|
||||
{
|
||||
GST_LOG_OBJECT (sink, "empty buffer list");
|
||||
return GST_FLOW_OK;
|
||||
}
|
||||
}
|
||||
|
||||
static GstFlowReturn
|
||||
gst_file_sink_render (GstBaseSink * sink, GstBuffer * buffer)
|
||||
{
|
||||
|
|
|
@ -41,6 +41,7 @@ G_BEGIN_DECLS
|
|||
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_FILE_SINK))
|
||||
#define GST_IS_FILE_SINK_CLASS(klass) \
|
||||
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_FILE_SINK))
|
||||
#define GST_FILE_SINK_CAST(obj) ((GstFileSink *)(obj))
|
||||
|
||||
typedef struct _GstFileSink GstFileSink;
|
||||
typedef struct _GstFileSinkClass GstFileSinkClass;
|
||||
|
|
Loading…
Reference in a new issue