[prev in list] [next in list] [prev in thread] [next in thread] 

List:       gstreamer-cvs
Subject:    gstreamer: filesink: implement ::render_list() function that uses writev()
From:       tpm () kemper ! freedesktop ! org (Tim Müller)
Date:       2014-11-30 15:01:22
Message-ID: 20141130150122.D33BB7633B () kemper ! freedesktop ! org
[Download RAW message or body]

Module: gstreamer
Branch: master
Commit: 5a4fb5c314a4c02e31f5716426ba57b2fe6a73e2
URL:    http://cgit.freedesktop.org/gstreamer/gstreamer/commit/?id=5a4fb5c314a4c02e31f5716426ba57b2fe6a73e2


Author: Tim-Philipp Müller <tim@centricular.com>
Date:   Fri Nov 28 15:04:27 2014 +0000

filesink: implement ::render_list() function that uses writev()

---

 plugins/elements/gstfilesink.c |   52 ++++++++++++++++++++++++++++++++++++++++
 plugins/elements/gstfilesink.h |    1 +
 2 files changed, 53 insertions(+)

diff --git a/plugins/elements/gstfilesink.c b/plugins/elements/gstfilesink.c
index 470ad5e..1a717c5 100644
--- a/plugins/elements/gstfilesink.c
+++ b/plugins/elements/gstfilesink.c
@@ -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) {
@@ -647,6 +653,52 @@ gst_file_sink_get_current_offset (GstFileSink * filesink, \
guint64 * p_pos)  }
 
 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)
 {
   GstFileSink *filesink;
diff --git a/plugins/elements/gstfilesink.h b/plugins/elements/gstfilesink.h
index 72a9a47..33517ab 100644
--- a/plugins/elements/gstfilesink.h
+++ b/plugins/elements/gstfilesink.h
@@ -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;


[Attachment #3 (text/plain)]

_______________________________________________
gstreamer-commits mailing list
gstreamer-commits@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/gstreamer-commits


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic