videorate: factor out gst_video_rate_push_buffer()
authorGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>
Tue, 4 Apr 2017 11:16:42 +0000 (13:16 +0200)
committerOlivier CrĂȘte <olivier.crete@collabora.com>
Sat, 20 May 2017 14:35:53 +0000 (16:35 +0200)
No semantic change, just factor out this function from
gst_video_rate_flush_prev().

I'm about to use it to change the 'drop-only' code path.

https://bugzilla.gnome.org/show_bug.cgi?id=780767

gst/videorate/gstvideorate.c

index c15a893..84d8755 100644 (file)
@@ -623,25 +623,14 @@ gst_video_rate_init (GstVideoRate * videorate)
   gst_base_transform_set_gap_aware (GST_BASE_TRANSFORM (videorate), TRUE);
 }
 
-/* flush the oldest buffer */
+/* @outbuf: (transfer full) needs to be writable */
 static GstFlowReturn
-gst_video_rate_flush_prev (GstVideoRate * videorate, gboolean duplicate,
-    GstClockTime next_intime)
+gst_video_rate_push_buffer (GstVideoRate * videorate, GstBuffer * outbuf,
+    gboolean duplicate, GstClockTime next_intime)
 {
   GstFlowReturn res;
-  GstBuffer *outbuf;
   GstClockTime push_ts;
 
-  if (!videorate->prevbuf)
-    goto eos_before_buffers;
-
-  outbuf = gst_buffer_ref (videorate->prevbuf);
-  if (videorate->drop_only)
-    gst_buffer_replace (&videorate->prevbuf, NULL);
-
-  /* make sure we can write to the metadata */
-  outbuf = gst_buffer_make_writable (outbuf);
-
   GST_BUFFER_OFFSET (outbuf) = videorate->out;
   GST_BUFFER_OFFSET_END (outbuf) = videorate->out + 1;
 
@@ -710,6 +699,26 @@ gst_video_rate_flush_prev (GstVideoRate * videorate, gboolean duplicate,
   res = gst_pad_push (GST_BASE_TRANSFORM_SRC_PAD (videorate), outbuf);
 
   return res;
+}
+
+/* flush the oldest buffer */
+static GstFlowReturn
+gst_video_rate_flush_prev (GstVideoRate * videorate, gboolean duplicate,
+    GstClockTime next_intime)
+{
+  GstBuffer *outbuf;
+
+  if (!videorate->prevbuf)
+    goto eos_before_buffers;
+
+  outbuf = gst_buffer_ref (videorate->prevbuf);
+  if (videorate->drop_only)
+    gst_buffer_replace (&videorate->prevbuf, NULL);
+
+  /* make sure we can write to the metadata */
+  outbuf = gst_buffer_make_writable (outbuf);
+
+  return gst_video_rate_push_buffer (videorate, outbuf, duplicate, next_intime);
 
   /* WARNINGS */
 eos_before_buffers: