rtppayload: set standard payload type as default
authorHyunjun Ko <zzoon.ko@samsung.com>
Thu, 6 Aug 2015 02:33:37 +0000 (11:33 +0900)
committerThiago Santos <thiagoss@osg.samsung.com>
Thu, 6 Aug 2015 04:38:43 +0000 (01:38 -0300)
Initialize the PT to the default value of the codec and check if
it is still the default before declaring the pt to be dynamic or
not when setting the caps.

Also use the PT constants from the rtp lib when possible

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

13 files changed:
gst/rtp/gstrtpL16pay.c
gst/rtp/gstrtpg722pay.c
gst/rtp/gstrtpg723pay.c
gst/rtp/gstrtpg729pay.c
gst/rtp/gstrtpgsmpay.c
gst/rtp/gstrtph261pay.c
gst/rtp/gstrtph263pay.c
gst/rtp/gstrtpjpegpay.c
gst/rtp/gstrtpmp2tpay.c
gst/rtp/gstrtpmpapay.c
gst/rtp/gstrtpmpvpay.c
gst/rtp/gstrtppcmapay.c
gst/rtp/gstrtppcmupay.c

index a8ed36f..db1c7de 100644 (file)
@@ -208,16 +208,16 @@ gst_rtp_L16_pay_getcaps (GstRTPBasePayload * rtppayload, GstPad * pad,
       if (gst_structure_get_int (structure, "channels", &channels)) {
         gst_caps_set_simple (caps, "channels", G_TYPE_INT, channels, NULL);
       } else if (gst_structure_get_int (structure, "payload", &pt)) {
-        if (pt == 10)
+        if (pt == GST_RTP_PAYLOAD_L16_STEREO)
           gst_caps_set_simple (caps, "channels", G_TYPE_INT, 2, NULL);
-        else if (pt == 11)
+        else if (pt == GST_RTP_PAYLOAD_L16_MONO)
           gst_caps_set_simple (caps, "channels", G_TYPE_INT, 1, NULL);
       }
 
       if (gst_structure_get_int (structure, "clock-rate", &rate)) {
         gst_caps_set_simple (caps, "rate", G_TYPE_INT, rate, NULL);
       } else if (gst_structure_get_int (structure, "payload", &pt)) {
-        if (pt == 10 || pt == 11)
+        if (pt == GST_RTP_PAYLOAD_L16_STEREO || pt == GST_RTP_PAYLOAD_L16_MONO)
           gst_caps_set_simple (caps, "rate", G_TYPE_INT, 44100, NULL);
       }
 
index e9e625a..79194c0 100644 (file)
@@ -40,13 +40,18 @@ GST_STATIC_PAD_TEMPLATE ("sink",
     );
 
 static GstStaticPadTemplate gst_rtp_g722_pay_src_template =
-GST_STATIC_PAD_TEMPLATE ("src",
+    GST_STATIC_PAD_TEMPLATE ("src",
     GST_PAD_SRC,
     GST_PAD_ALWAYS,
     GST_STATIC_CAPS ("application/x-rtp, "
         "media = (string) \"audio\", "
         "encoding-name = (string) \"G722\", "
         "payload = (int) " GST_RTP_PAYLOAD_G722_STRING ", "
+        "clock-rate = (int) 8000; "
+        "application/x-rtp, "
+        "media = (string) \"audio\", "
+        "encoding-name = (string) \"G722\", "
+        "payload = (int) " GST_RTP_PAYLOAD_DYNAMIC_STRING ", "
         "clock-rate = (int) 8000")
     );
 
@@ -92,6 +97,8 @@ gst_rtp_g722_pay_init (GstRtpG722Pay * rtpg722pay)
 
   rtpbaseaudiopayload = GST_RTP_BASE_AUDIO_PAYLOAD (rtpg722pay);
 
+  GST_RTP_BASE_PAYLOAD (rtpg722pay)->pt = GST_RTP_PAYLOAD_G722;
+
   /* tell rtpbaseaudiopayload that this is a sample based codec */
   gst_rtp_base_audio_payload_set_sample_based (rtpbaseaudiopayload);
 }
@@ -136,8 +143,8 @@ gst_rtp_g722_pay_setcaps (GstRTPBasePayload * basepayload, GstCaps * caps)
    * RFC 3551 although the sampling rate is 16000 Hz */
   clock_rate = 8000;
 
-  gst_rtp_base_payload_set_options (basepayload, "audio", TRUE, "G722",
-      clock_rate);
+  gst_rtp_base_payload_set_options (basepayload, "audio",
+      basepayload->pt != GST_RTP_PAYLOAD_G722, "G722", clock_rate);
   params = g_strdup_printf ("%d", channels);
 
 #if 0
index 8c03a31..4122bc9 100644 (file)
@@ -29,9 +29,6 @@
 
 #include "gstrtpg723pay.h"
 
-#define GST_RTP_PAYLOAD_G723 4
-#define GST_RTP_PAYLOAD_G723_STRING "4"
-
 #define G723_FRAME_DURATION (30 * GST_MSECOND)
 
 static gboolean gst_rtp_g723_pay_set_caps (GstRTPBasePayload * payload,
@@ -107,7 +104,6 @@ gst_rtp_g723_pay_init (GstRTPG723Pay * pay)
   pay->adapter = gst_adapter_new ();
 
   payload->pt = GST_RTP_PAYLOAD_G723;
-  gst_rtp_base_payload_set_options (payload, "audio", FALSE, "G723", 8000);
 }
 
 static void
@@ -128,16 +124,9 @@ static gboolean
 gst_rtp_g723_pay_set_caps (GstRTPBasePayload * payload, GstCaps * caps)
 {
   gboolean res;
-  GstStructure *structure;
-  gint pt;
-
-  structure = gst_caps_get_structure (caps, 0);
-  if (!gst_structure_get_int (structure, "payload", &pt))
-    pt = GST_RTP_PAYLOAD_G723;
-
-  payload->pt = pt;
-  payload->dynamic = pt != GST_RTP_PAYLOAD_G723;
 
+  gst_rtp_base_payload_set_options (payload, "audio",
+      payload->pt != GST_RTP_PAYLOAD_G723, "G723", 8000);
   res = gst_rtp_base_payload_set_outcaps (payload, NULL);
 
   return res;
index 1c695bd..c11c8c1 100644 (file)
@@ -121,7 +121,6 @@ gst_rtp_g729_pay_init (GstRTPG729Pay * pay)
   GstRTPBasePayload *payload = GST_RTP_BASE_PAYLOAD (pay);
 
   payload->pt = GST_RTP_PAYLOAD_G729;
-  gst_rtp_base_payload_set_options (payload, "audio", FALSE, "G729", 8000);
 
   pay->adapter = gst_adapter_new ();
 }
@@ -140,15 +139,9 @@ static gboolean
 gst_rtp_g729_pay_set_caps (GstRTPBasePayload * payload, GstCaps * caps)
 {
   gboolean res;
-  GstStructure *structure;
-  gint pt;
 
-  structure = gst_caps_get_structure (caps, 0);
-  if (!gst_structure_get_int (structure, "payload", &pt))
-    pt = GST_RTP_PAYLOAD_G729;
-
-  payload->pt = pt;
-  payload->dynamic = pt != GST_RTP_PAYLOAD_G729;
+  gst_rtp_base_payload_set_options (payload, "audio",
+      payload->pt != GST_RTP_PAYLOAD_G729, "G729", 8000);
 
   res = gst_rtp_base_payload_set_outcaps (payload, NULL);
 
index 131a896..19cc99b 100644 (file)
@@ -107,7 +107,8 @@ gst_rtp_gsm_pay_setcaps (GstRTPBasePayload * payload, GstCaps * caps)
   if (strcmp ("audio/x-gsm", stname))
     goto invalid_type;
 
-  gst_rtp_base_payload_set_options (payload, "audio", FALSE, "GSM", 8000);
+  gst_rtp_base_payload_set_options (payload, "audio",
+      payload->pt != GST_RTP_PAYLOAD_GSM, "GSM", 8000);
   res = gst_rtp_base_payload_set_outcaps (payload, NULL);
 
   return res;
index fede7f5..653d171 100644 (file)
@@ -1018,7 +1018,8 @@ gst_rtp_h261_pay_setcaps (GstRTPBasePayload * payload, GstCaps * caps)
 {
   gboolean res;
 
-  gst_rtp_base_payload_set_options (payload, "video", TRUE, "H261", 90000);
+  gst_rtp_base_payload_set_options (payload, "video",
+      payload->pt != GST_RTP_PAYLOAD_H261, "H261", 90000);
   res = gst_rtp_base_payload_set_outcaps (payload, NULL);
 
   return res;
index c39aa70..28a0b63 100644 (file)
@@ -440,6 +440,7 @@ gst_rtp_h263_pay_class_init (GstRtpH263PayClass * klass)
 static void
 gst_rtp_h263_pay_init (GstRtpH263Pay * rtph263pay)
 {
+  GST_RTP_BASE_PAYLOAD_PT (rtph263pay) = GST_RTP_PAYLOAD_H263;
   rtph263pay->prop_payload_mode = DEFAULT_MODE_A;
 }
 
@@ -476,8 +477,8 @@ gst_rtp_h263_pay_setcaps (GstRTPBasePayload * payload, GstCaps * caps)
     framesize = g_strdup_printf ("%d-%d", width, height);
   }
 
-  payload->pt = GST_RTP_PAYLOAD_H263;
-  gst_rtp_base_payload_set_options (payload, "video", TRUE, "H263", 90000);
+  gst_rtp_base_payload_set_options (payload, "video",
+      payload->pt != GST_RTP_PAYLOAD_H263, "H263", 90000);
 
   if (framesize != NULL) {
     res = gst_rtp_base_payload_set_outcaps (payload,
index bdca220..c3ab13e 100644 (file)
@@ -49,12 +49,18 @@ static GstStaticPadTemplate gst_rtp_jpeg_pay_sink_template =
     );
 
 static GstStaticPadTemplate gst_rtp_jpeg_pay_src_template =
-GST_STATIC_PAD_TEMPLATE ("src",
+    GST_STATIC_PAD_TEMPLATE ("src",
     GST_PAD_SRC,
     GST_PAD_ALWAYS,
     GST_STATIC_CAPS ("application/x-rtp, "
         "  media = (string) \"video\", "
-        "  payload = (int) 26 ,        "
+        "  payload = (int) " GST_RTP_PAYLOAD_JPEG_STRING ", "
+        "  clock-rate = (int) 90000,   "
+        "  encoding-name = (string) \"JPEG\", "
+        "  width = (int) [ 1, 65536 ], " "  height = (int) [ 1, 65536 ]; "
+        " application/x-rtp, "
+        "  media = (string) \"video\", "
+        "  payload = (int) " GST_RTP_PAYLOAD_DYNAMIC_STRING ", "
         "  clock-rate = (int) 90000,   "
         "  encoding-name = (string) \"JPEG\", "
         "  width = (int) [ 1, 65536 ], " "  height = (int) [ 1, 65536 ]")
@@ -283,6 +289,8 @@ gst_rtp_jpeg_pay_init (GstRtpJPEGPay * pay)
   pay->type = DEFAULT_JPEG_TYPE;
   pay->width = -1;
   pay->height = -1;
+
+  GST_RTP_BASE_PAYLOAD_PT (pay) = GST_RTP_PAYLOAD_JPEG;
 }
 
 static gboolean
@@ -321,7 +329,8 @@ gst_rtp_jpeg_pay_setcaps (GstRTPBasePayload * basepayload, GstCaps * caps)
     pay->width = GST_ROUND_UP_8 (width) / 8;
   }
 
-  gst_rtp_base_payload_set_options (basepayload, "video", TRUE, "JPEG", 90000);
+  gst_rtp_base_payload_set_options (basepayload, "video",
+      basepayload->pt != GST_RTP_PAYLOAD_JPEG, "JPEG", 90000);
 
   if (num > 0) {
     gdouble framerate;
index 386e09e..089c07c 100644 (file)
@@ -112,7 +112,8 @@ gst_rtp_mp2t_pay_setcaps (GstRTPBasePayload * payload, GstCaps * caps)
 {
   gboolean res;
 
-  gst_rtp_base_payload_set_options (payload, "video", TRUE, "MP2T", 90000);
+  gst_rtp_base_payload_set_options (payload, "video",
+      payload->pt != GST_RTP_PAYLOAD_MP2T, "MP2T", 90000);
   res = gst_rtp_base_payload_set_outcaps (payload, NULL);
 
   return res;
index 9d9ae6f..b963554 100644 (file)
@@ -104,6 +104,8 @@ static void
 gst_rtp_mpa_pay_init (GstRtpMPAPay * rtpmpapay)
 {
   rtpmpapay->adapter = gst_adapter_new ();
+
+  GST_RTP_BASE_PAYLOAD (rtpmpapay)->pt = GST_RTP_PAYLOAD_MPA;
 }
 
 static void
@@ -133,7 +135,8 @@ gst_rtp_mpa_pay_setcaps (GstRTPBasePayload * payload, GstCaps * caps)
 {
   gboolean res;
 
-  gst_rtp_base_payload_set_options (payload, "audio", TRUE, "MPA", 90000);
+  gst_rtp_base_payload_set_options (payload, "audio",
+      payload->pt != GST_RTP_PAYLOAD_MPA, "MPA", 90000);
   res = gst_rtp_base_payload_set_outcaps (payload, NULL);
 
   return res;
index 9bec042..cb074fa 100644 (file)
@@ -39,12 +39,16 @@ GST_STATIC_PAD_TEMPLATE ("sink",
     );
 
 static GstStaticPadTemplate gst_rtp_mpv_pay_src_template =
-GST_STATIC_PAD_TEMPLATE ("src",
+    GST_STATIC_PAD_TEMPLATE ("src",
     GST_PAD_SRC,
     GST_PAD_ALWAYS,
     GST_STATIC_CAPS ("application/x-rtp, "
         "media = (string) \"video\", "
         "payload = (int) " GST_RTP_PAYLOAD_MPV_STRING ", "
+        "clock-rate = (int) 90000, " "encoding-name = (string) \"MPV\"; "
+        "application/x-rtp, "
+        "media = (string) \"video\", "
+        "payload = (int) " GST_RTP_PAYLOAD_DYNAMIC_STRING ", "
         "clock-rate = (int) 90000, " "encoding-name = (string) \"MPV\"")
     );
 
@@ -131,7 +135,8 @@ gst_rtp_mpv_pay_reset (GstRTPMPVPay * pay)
 static gboolean
 gst_rtp_mpv_pay_setcaps (GstRTPBasePayload * payload, GstCaps * caps)
 {
-  gst_rtp_base_payload_set_options (payload, "video", FALSE, "MPV", 90000);
+  gst_rtp_base_payload_set_options (payload, "video",
+      payload->pt != GST_RTP_PAYLOAD_MPV, "MPV", 90000);
   return gst_rtp_base_payload_set_outcaps (payload, NULL);
 }
 
index 7ec7e59..0860d76 100644 (file)
@@ -86,6 +86,7 @@ gst_rtp_pcma_pay_init (GstRtpPcmaPay * rtppcmapay)
 
   rtpbaseaudiopayload = GST_RTP_BASE_AUDIO_PAYLOAD (rtppcmapay);
 
+  GST_RTP_BASE_PAYLOAD (rtppcmapay)->pt = GST_RTP_PAYLOAD_PCMA;
   GST_RTP_BASE_PAYLOAD (rtppcmapay)->clock_rate = 8000;
 
   /* tell rtpbaseaudiopayload that this is a sample based codec */
@@ -100,9 +101,8 @@ gst_rtp_pcma_pay_setcaps (GstRTPBasePayload * payload, GstCaps * caps)
 {
   gboolean res;
 
-  payload->pt = GST_RTP_PAYLOAD_PCMA;
-
-  gst_rtp_base_payload_set_options (payload, "audio", FALSE, "PCMA", 8000);
+  gst_rtp_base_payload_set_options (payload, "audio",
+      payload->pt != GST_RTP_PAYLOAD_PCMA, "PCMA", 8000);
   res = gst_rtp_base_payload_set_outcaps (payload, NULL);
 
   return res;
index 3d69cb3..b4beb96 100644 (file)
@@ -86,6 +86,7 @@ gst_rtp_pcmu_pay_init (GstRtpPcmuPay * rtppcmupay)
 
   rtpbaseaudiopayload = GST_RTP_BASE_AUDIO_PAYLOAD (rtppcmupay);
 
+  GST_RTP_BASE_PAYLOAD (rtppcmupay)->pt = GST_RTP_PAYLOAD_PCMU;
   GST_RTP_BASE_PAYLOAD (rtppcmupay)->clock_rate = 8000;
 
   /* tell rtpbaseaudiopayload that this is a sample based codec */
@@ -100,9 +101,8 @@ gst_rtp_pcmu_pay_setcaps (GstRTPBasePayload * payload, GstCaps * caps)
 {
   gboolean res;
 
-  payload->pt = GST_RTP_PAYLOAD_PCMU;
-
-  gst_rtp_base_payload_set_options (payload, "audio", FALSE, "PCMU", 8000);
+  gst_rtp_base_payload_set_options (payload, "audio",
+      payload->pt != GST_RTP_PAYLOAD_PCMU, "PCMU", 8000);
   res = gst_rtp_base_payload_set_outcaps (payload, NULL);
 
   return res;