Merge remote-tracking branch 'origin/master' into 0.11
[platform/upstream/gst-plugins-good.git] / gst / rtp / gstrtpg729depay.c
index 69799ad..a6017bb 100644 (file)
@@ -71,57 +71,53 @@ GST_STATIC_PAD_TEMPLATE ("src",
     GST_STATIC_CAPS ("audio/G729, " "channels = (int) 1," "rate = (int) 8000")
     );
 
-static gboolean gst_rtp_g729_depay_setcaps (GstBaseRTPDepayload * depayload,
+static gboolean gst_rtp_g729_depay_setcaps (GstRTPBaseDepayload * depayload,
     GstCaps * caps);
-static GstBuffer *gst_rtp_g729_depay_process (GstBaseRTPDepayload * depayload,
+static GstBuffer *gst_rtp_g729_depay_process (GstRTPBaseDepayload * depayload,
     GstBuffer * buf);
 
-GST_BOILERPLATE (GstRtpG729Depay, gst_rtp_g729_depay, GstBaseRTPDepayload,
-    GST_TYPE_BASE_RTP_DEPAYLOAD);
+#define gst_rtp_g729_depay_parent_class parent_class
+G_DEFINE_TYPE (GstRtpG729Depay, gst_rtp_g729_depay,
+    GST_TYPE_RTP_BASE_DEPAYLOAD);
 
 static void
-gst_rtp_g729_depay_base_init (gpointer klass)
+gst_rtp_g729_depay_class_init (GstRtpG729DepayClass * klass)
 {
-  GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
-
-  gst_element_class_add_static_pad_template (element_class,
-      &gst_rtp_g729_depay_src_template);
-  gst_element_class_add_static_pad_template (element_class,
-      &gst_rtp_g729_depay_sink_template);
-
-  gst_element_class_set_details_simple (element_class, "RTP G.729 depayloader",
-      "Codec/Depayloader/Network/RTP",
-      "Extracts G.729 audio from RTP packets (RFC 3551)",
-      "Laurent Glayal <spglegle@yahoo.fr>");
+  GstElementClass *gstelement_class;
+  GstRTPBaseDepayloadClass *gstrtpbasedepayload_class;
 
   GST_DEBUG_CATEGORY_INIT (rtpg729depay_debug, "rtpg729depay", 0,
       "G.729 RTP Depayloader");
-}
 
-static void
-gst_rtp_g729_depay_class_init (GstRtpG729DepayClass * klass)
-{
-  GstBaseRTPDepayloadClass *gstbasertpdepayload_class;
+  gstelement_class = (GstElementClass *) klass;
+  gstrtpbasedepayload_class = (GstRTPBaseDepayloadClass *) klass;
+
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&gst_rtp_g729_depay_src_template));
+  gst_element_class_add_pad_template (gstelement_class,
+      gst_static_pad_template_get (&gst_rtp_g729_depay_sink_template));
 
-  gstbasertpdepayload_class = (GstBaseRTPDepayloadClass *) klass;
+  gst_element_class_set_details_simple (gstelement_class,
+      "RTP G.729 depayloader", "Codec/Depayloader/Network/RTP",
+      "Extracts G.729 audio from RTP packets (RFC 3551)",
+      "Laurent Glayal <spglegle@yahoo.fr>");
 
-  gstbasertpdepayload_class->process = gst_rtp_g729_depay_process;
-  gstbasertpdepayload_class->set_caps = gst_rtp_g729_depay_setcaps;
+  gstrtpbasedepayload_class->process = gst_rtp_g729_depay_process;
+  gstrtpbasedepayload_class->set_caps = gst_rtp_g729_depay_setcaps;
 }
 
 static void
-gst_rtp_g729_depay_init (GstRtpG729Depay * rtpg729depay,
-    GstRtpG729DepayClass * klass)
+gst_rtp_g729_depay_init (GstRtpG729Depay * rtpg729depay)
 {
-  GstBaseRTPDepayload *depayload;
+  GstRTPBaseDepayload *depayload;
 
-  depayload = GST_BASE_RTP_DEPAYLOAD (rtpg729depay);
+  depayload = GST_RTP_BASE_DEPAYLOAD (rtpg729depay);
 
-  gst_pad_use_fixed_caps (GST_BASE_RTP_DEPAYLOAD_SRCPAD (depayload));
+  gst_pad_use_fixed_caps (GST_RTP_BASE_DEPAYLOAD_SRCPAD (depayload));
 }
 
 static gboolean
-gst_rtp_g729_depay_setcaps (GstBaseRTPDepayload * depayload, GstCaps * caps)
+gst_rtp_g729_depay_setcaps (GstRTPBaseDepayload * depayload, GstCaps * caps)
 {
   GstStructure *structure;
   GstCaps *srccaps;
@@ -153,7 +149,7 @@ gst_rtp_g729_depay_setcaps (GstBaseRTPDepayload * depayload, GstCaps * caps)
 
   srccaps = gst_caps_new_simple ("audio/G729",
       "channels", G_TYPE_INT, channels, "rate", G_TYPE_INT, clock_rate, NULL);
-  ret = gst_pad_set_caps (GST_BASE_RTP_DEPAYLOAD_SRCPAD (depayload), srccaps);
+  ret = gst_pad_set_caps (GST_RTP_BASE_DEPAYLOAD_SRCPAD (depayload), srccaps);
   gst_caps_unref (srccaps);
 
   return ret;
@@ -172,18 +168,20 @@ wrong_clock_rate:
   }
 }
 
-
 static GstBuffer *
-gst_rtp_g729_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
+gst_rtp_g729_depay_process (GstRTPBaseDepayload * depayload, GstBuffer * buf)
 {
   GstRtpG729Depay *rtpg729depay;
   GstBuffer *outbuf = NULL;
   gint payload_len;
   gboolean marker;
+  GstRTPBuffer rtp = { NULL };
 
   rtpg729depay = GST_RTP_G729_DEPAY (depayload);
 
-  payload_len = gst_rtp_buffer_get_payload_len (buf);
+  gst_rtp_buffer_map (buf, GST_MAP_READ, &rtp);
+
+  payload_len = gst_rtp_buffer_get_payload_len (&rtp);
 
   /* At least 2 bytes (CNG from G729 Annex B) */
   if (payload_len < 2) {
@@ -198,16 +196,18 @@ gst_rtp_g729_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
     GST_LOG_OBJECT (rtpg729depay, "G729 payload contains CNG frame");
   }
 
-  outbuf = gst_rtp_buffer_get_payload_buffer (buf);
-  marker = gst_rtp_buffer_get_marker (buf);
+  outbuf = gst_rtp_buffer_get_payload_buffer (&rtp);
+  marker = gst_rtp_buffer_get_marker (&rtp);
+
+  gst_rtp_buffer_unmap (&rtp);
 
   if (marker) {
     /* marker bit starts talkspurt */
     GST_BUFFER_FLAG_SET (outbuf, GST_BUFFER_FLAG_DISCONT);
   }
 
-  GST_LOG_OBJECT (depayload, "pushing buffer of size %d",
-      GST_BUFFER_SIZE (outbuf));
+  GST_LOG_OBJECT (depayload, "pushing buffer of size %" G_GSIZE_FORMAT,
+      gst_buffer_get_size (outbuf));
 
   return outbuf;