rtph264pay: push single buffer directly, no need to wrap it in a bufferlist
authorTim-Philipp Müller <tim@centricular.com>
Mon, 16 Jun 2014 19:15:43 +0000 (20:15 +0100)
committerTim-Philipp Müller <tim@centricular.com>
Wed, 18 Jun 2014 13:54:58 +0000 (14:54 +0100)
No point in a buffer list if we just have one single
buffer to push. Fix up unit test to handle that case
as well.

gst/rtp/gstrtph264pay.c
tests/check/elements/rtp-payloading.c

index 5fb15ce..1ad7668 100644 (file)
@@ -824,12 +824,11 @@ gst_rtp_h264_pay_payload_nal (GstRTPBasePayload * basepayload,
   packet_len = gst_rtp_buffer_calc_packet_len (size, 0, 0);
 
   if (packet_len < mtu) {
+    /* will fit in one packet */
     GST_DEBUG_OBJECT (basepayload,
         "NAL Unit fit in one packet datasize=%d mtu=%d", size, mtu);
-    /* will fit in one packet */
 
-    /* use buffer lists
-     * create buffer without payload containing only the RTP header
+    /* create buffer without payload containing only the RTP header
      * (memory block at index 0) */
     outbuf = gst_rtp_buffer_new_allocate (0, 0, 0);
 
@@ -844,18 +843,13 @@ gst_rtp_h264_pay_payload_nal (GstRTPBasePayload * basepayload,
     GST_BUFFER_PTS (outbuf) = pts;
     GST_BUFFER_DTS (outbuf) = dts;
 
+    gst_rtp_buffer_unmap (&rtp);
+
     /* insert payload memory block */
     outbuf = gst_buffer_append (outbuf, paybuf);
 
-    list = gst_buffer_list_new ();
-
-    /* add the buffer to the buffer list */
-    gst_buffer_list_add (list, outbuf);
-
-    gst_rtp_buffer_unmap (&rtp);
-
-    /* push the list to the next element in the pipe */
-    ret = gst_rtp_base_payload_push_list (basepayload, list);
+    /* push the buffer to the next element */
+    ret = gst_rtp_base_payload_push (basepayload, outbuf);
   } else {
     /* fragmentation Units FU-A */
     guint limitedSize;
index 32d785f..2ce7a5c 100644 (file)
@@ -79,6 +79,16 @@ rtp_pipeline_chain_list (GstPad * pad, GstObject * parent, GstBufferList * list)
   return GST_FLOW_OK;
 }
 
+static GstFlowReturn
+rtp_pipeline_chain (GstPad * pad, GstObject * parent, GstBuffer * buf)
+{
+  GstBufferList *list;
+
+  list = gst_buffer_list_new_sized (1);
+  gst_buffer_list_add (list, buf);
+  return rtp_pipeline_chain_list (pad, parent, list);
+}
+
 /*
  * RTP bus callback.
  */
@@ -303,6 +313,8 @@ rtp_pipeline_enable_lists (rtp_pipeline * p, guint mtu_size)
   pad = gst_element_get_static_pad (p->rtpdepay, "sink");
   gst_pad_set_chain_list_function (pad,
       GST_DEBUG_FUNCPTR (rtp_pipeline_chain_list));
+  /* .. to satisfy this silly test code in case someone dares push a buffer */
+  gst_pad_set_chain_function (pad, GST_DEBUG_FUNCPTR (rtp_pipeline_chain));
   gst_object_unref (pad);
 }