rtpgstpay: Refactor the setcaps and use new method to send arbitrary caps at any...
authorYouness Alaoui <youness.alaoui@collabora.co.uk>
Fri, 26 Jul 2013 01:10:10 +0000 (21:10 -0400)
committerWim Taymans <wim.taymans@collabora.co.uk>
Wed, 21 Aug 2013 07:06:01 +0000 (09:06 +0200)
gst/rtp/gstrtpgstpay.c

index 3b3bd6d..2f5969a 100644 (file)
@@ -286,6 +286,29 @@ make_data_buffer (GstRtpGSTPay * rtpgstpay, gchar * data, guint size)
   return outbuf;
 }
 
+static void
+gst_rtp_gst_pay_send_caps (GstRtpGSTPay * rtpgstpay, guint8 cv, GstCaps * caps)
+{
+  gchar *capsstr;
+  guint capslen;
+  GstBuffer *outbuf;
+
+  capsstr = gst_caps_to_string (caps);
+  capslen = strlen (capsstr);
+  /* for 0 byte */
+  capslen++;
+
+  GST_DEBUG_OBJECT (rtpgstpay, "sending caps=%s", capsstr);
+
+  /* make a data buffer of it */
+  outbuf = make_data_buffer (rtpgstpay, capsstr, capslen);
+  g_free (capsstr);
+
+  /* store in adapter, we don't flush yet, buffer might follow */
+  rtpgstpay->flags = (1 << 7) | (cv << 4);
+  gst_adapter_push (rtpgstpay->adapter, outbuf);
+}
+
 static gboolean
 gst_rtp_gst_pay_setcaps (GstRTPBasePayload * payload, GstCaps * caps)
 {
@@ -293,29 +316,21 @@ gst_rtp_gst_pay_setcaps (GstRTPBasePayload * payload, GstCaps * caps)
   gboolean res;
   gchar *capsstr, *capsenc, *capsver;
   guint capslen;
-  GstBuffer *outbuf;
 
   rtpgstpay = GST_RTP_GST_PAY (payload);
 
   capsstr = gst_caps_to_string (caps);
   capslen = strlen (capsstr);
 
-  rtpgstpay->current_CV = rtpgstpay->next_CV;
-
   /* encode without 0 byte */
   capsenc = g_base64_encode ((guchar *) capsstr, capslen);
   GST_DEBUG_OBJECT (payload, "caps=%s, caps(base64)=%s", capsstr, capsenc);
-  /* for 0 byte */
-  capslen++;
-
-  /* make a data buffer of it */
-  outbuf = make_data_buffer (rtpgstpay, capsstr, capslen);
   g_free (capsstr);
 
-  /* store in adapter, we don't flush yet, buffer might follow */
-  rtpgstpay->flags = (1 << 7) | (rtpgstpay->current_CV << 4);
+  /* Send the new caps */
+  rtpgstpay->current_CV = rtpgstpay->next_CV;
   rtpgstpay->next_CV = (rtpgstpay->next_CV + 1) & 0x7;
-  gst_adapter_push (rtpgstpay->adapter, outbuf);
+  gst_rtp_gst_pay_send_caps (rtpgstpay, rtpgstpay->current_CV, caps);
 
   /* make caps for SDP */
   capsver = g_strdup_printf ("%d", rtpgstpay->current_CV);