Merge branch 'master' into 0.11
[platform/upstream/gstreamer.git] / gst / rtp / gstrtpac3depay.c
index cb6304e..17da501 100644 (file)
@@ -47,8 +47,7 @@ GST_STATIC_PAD_TEMPLATE ("sink",
         "encoding-name = (string) \"AC3\"")
     );
 
-GST_BOILERPLATE (GstRtpAC3Depay, gst_rtp_ac3_depay, GstBaseRTPDepayload,
-    GST_TYPE_BASE_RTP_DEPAYLOAD);
+G_DEFINE_TYPE (GstRtpAC3Depay, gst_rtp_ac3_depay, GST_TYPE_BASE_RTP_DEPAYLOAD);
 
 static gboolean gst_rtp_ac3_depay_setcaps (GstBaseRTPDepayload * depayload,
     GstCaps * caps);
@@ -56,27 +55,23 @@ static GstBuffer *gst_rtp_ac3_depay_process (GstBaseRTPDepayload * depayload,
     GstBuffer * buf);
 
 static void
-gst_rtp_ac3_depay_base_init (gpointer klass)
+gst_rtp_ac3_depay_class_init (GstRtpAC3DepayClass * klass)
 {
-  GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
+  GstElementClass *gstelement_class;
+  GstBaseRTPDepayloadClass *gstbasertpdepayload_class;
+
+  gstelement_class = (GstElementClass *) klass;
+  gstbasertpdepayload_class = (GstBaseRTPDepayloadClass *) klass;
 
-  gst_element_class_add_pad_template (element_class,
+  gst_element_class_add_pad_template (gstelement_class,
       gst_static_pad_template_get (&gst_rtp_ac3_depay_src_template));
-  gst_element_class_add_pad_template (element_class,
+  gst_element_class_add_pad_template (gstelement_class,
       gst_static_pad_template_get (&gst_rtp_ac3_depay_sink_template));
 
-  gst_element_class_set_details_simple (element_class, "RTP AC3 depayloader",
+  gst_element_class_set_details_simple (gstelement_class, "RTP AC3 depayloader",
       "Codec/Depayloader/Network/RTP",
       "Extracts AC3 audio from RTP packets (RFC 4184)",
       "Wim Taymans <wim.taymans@gmail.com>");
-}
-
-static void
-gst_rtp_ac3_depay_class_init (GstRtpAC3DepayClass * klass)
-{
-  GstBaseRTPDepayloadClass *gstbasertpdepayload_class;
-
-  gstbasertpdepayload_class = (GstBaseRTPDepayloadClass *) klass;
 
   gstbasertpdepayload_class->set_caps = gst_rtp_ac3_depay_setcaps;
   gstbasertpdepayload_class->process = gst_rtp_ac3_depay_process;
@@ -86,10 +81,9 @@ gst_rtp_ac3_depay_class_init (GstRtpAC3DepayClass * klass)
 }
 
 static void
-gst_rtp_ac3_depay_init (GstRtpAC3Depay * rtpac3depay,
-    GstRtpAC3DepayClass * klass)
+gst_rtp_ac3_depay_init (GstRtpAC3Depay * rtpac3depay)
 {
-  /* needed because of GST_BOILERPLATE */
+  /* needed because of G_DEFINE_TYPE */
 }
 
 static gboolean
@@ -165,48 +159,49 @@ gst_rtp_ac3_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
 {
   GstRtpAC3Depay *rtpac3depay;
   GstBuffer *outbuf;
+  GstRTPBuffer rtp = { NULL, };
+  guint8 *payload;
+  guint16 FT, NF;
 
   rtpac3depay = GST_RTP_AC3_DEPAY (depayload);
 
-  {
-    guint8 *payload;
-    guint16 FT, NF;
+  gst_rtp_buffer_map (buf, GST_MAP_READ, &rtp);
 
-    if (gst_rtp_buffer_get_payload_len (buf) < 2)
-      goto empty_packet;
+  if (gst_rtp_buffer_get_payload_len (&rtp) < 2)
+    goto empty_packet;
 
-    payload = gst_rtp_buffer_get_payload (buf);
+  payload = gst_rtp_buffer_get_payload (&rtp);
 
-    /* strip off header
-     *
-     *  0                   1
-     *  0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
-     * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-     * |    MBZ    | FT|       NF      |
-     * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-     */
-    FT = payload[0] & 0x3;
-    NF = payload[1];
+  /* strip off header
+   *
+   *  0                   1
+   *  0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
+   * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+   * |    MBZ    | FT|       NF      |
+   * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+   */
+  FT = payload[0] & 0x3;
+  NF = payload[1];
 
-    GST_DEBUG_OBJECT (rtpac3depay, "FT: %d, NF: %d", FT, NF);
+  GST_DEBUG_OBJECT (rtpac3depay, "FT: %d, NF: %d", FT, NF);
 
-    /* We don't bother with fragmented packets yet */
-    outbuf = gst_rtp_buffer_get_payload_subbuffer (buf, 2, -1);
+  /* We don't bother with fragmented packets yet */
+  outbuf = gst_rtp_buffer_get_payload_subbuffer (&rtp, 2, -1);
 
-    if (outbuf)
-        GST_DEBUG_OBJECT (rtpac3depay, "pushing buffer of size %d",
-            GST_BUFFER_SIZE (outbuf));
+  gst_rtp_buffer_unmap (&rtp);
 
-    return outbuf;
-  }
+  if (outbuf)
+    GST_DEBUG_OBJECT (rtpac3depay, "pushing buffer of size %d",
+        gst_buffer_get_size (outbuf));
 
-  return NULL;
+  return outbuf;
 
   /* ERRORS */
 empty_packet:
   {
     GST_ELEMENT_WARNING (rtpac3depay, STREAM, DECODE,
         ("Empty Payload."), (NULL));
+    gst_rtp_buffer_unmap (&rtp);
     return NULL;
   }
 }