rtp: Update codes based on 1.18.4
[platform/upstream/gst-plugins-good.git] / gst / rtp / gstrtpdvdepay.c
index 7d81a95..12297f0 100644 (file)
@@ -14,8 +14,8 @@
  *
  * You should have received a copy of the GNU Library General Public
  * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
  */
 
 /*
@@ -33,6 +33,7 @@
 #include <gst/gst.h>
 
 #include "gstrtpdvdepay.h"
+#include "gstrtputils.h"
 
 GST_DEBUG_CATEGORY (rtpdvdepay_debug);
 #define GST_CAT_DEFAULT (rtpdvdepay_debug)
@@ -45,7 +46,7 @@ enum
 
 enum
 {
-  ARG_0,
+  PROP_0,
 };
 
 static GstStaticPadTemplate src_factory = GST_STATIC_PAD_TEMPLATE ("src",
@@ -59,7 +60,6 @@ static GstStaticPadTemplate sink_factory = GST_STATIC_PAD_TEMPLATE ("sink",
     GST_PAD_ALWAYS,
     GST_STATIC_CAPS ("application/x-rtp, "
         "media = (string) { \"video\", \"audio\" },"
-        "payload = (int) " GST_RTP_PAYLOAD_DYNAMIC_STRING ", "
         "encoding-name = (string) \"DV\", "
         "clock-rate = (int) 90000,"
         "encode = (string) { \"SD-VCR/525-60\", \"SD-VCR/625-50\", \"HD-VCR/1125-60\","
@@ -76,7 +76,7 @@ static GstStateChangeReturn
 gst_rtp_dv_depay_change_state (GstElement * element, GstStateChange transition);
 
 static GstBuffer *gst_rtp_dv_depay_process (GstRTPBaseDepayload * base,
-    GstBuffer * in);
+    GstRTPBuffer * rtp);
 static gboolean gst_rtp_dv_depay_setcaps (GstRTPBaseDepayload * depayload,
     GstCaps * caps);
 
@@ -97,17 +97,15 @@ gst_rtp_dv_depay_class_init (GstRTPDVDepayClass * klass)
   gstelement_class->change_state =
       GST_DEBUG_FUNCPTR (gst_rtp_dv_depay_change_state);
 
-  gst_element_class_add_pad_template (gstelement_class,
-      gst_static_pad_template_get (&src_factory));
-  gst_element_class_add_pad_template (gstelement_class,
-      gst_static_pad_template_get (&sink_factory));
+  gst_element_class_add_static_pad_template (gstelement_class, &src_factory);
+  gst_element_class_add_static_pad_template (gstelement_class, &sink_factory);
 
-  gst_element_class_set_details_simple (gstelement_class, "RTP DV Depayloader",
+  gst_element_class_set_static_metadata (gstelement_class, "RTP DV Depayloader",
       "Codec/Depayloader/Network/RTP",
       "Depayloads DV from RTP packets (RFC 3189)",
       "Marcel Moreaux <marcelm@spacelabs.nl>, Wim Taymans <wim.taymans@gmail.com>");
 
-  gstrtpbasedepayload_class->process =
+  gstrtpbasedepayload_class->process_rtp_packet =
       GST_DEBUG_FUNCPTR (gst_rtp_dv_depay_process);
   gstrtpbasedepayload_class->set_caps =
       GST_DEBUG_FUNCPTR (gst_rtp_dv_depay_setcaps);
@@ -281,13 +279,20 @@ calculate_difblock_location (guint8 * block)
   return location;
 }
 
+static gboolean
+foreach_metadata_drop (GstBuffer * inbuf, GstMeta ** meta, gpointer user_data)
+{
+  *meta = NULL;
+  return TRUE;
+}
+
 /* Process one RTP packet. Accumulate RTP payload in the proper place in a DV
  * frame, and return that frame if we detect a new frame, or NULL otherwise.
- * We assume a DV frame is 144000 bytes. That should accomodate PAL as well as
+ * We assume a DV frame is 144000 bytes. That should accommodate PAL as well as
  * NTSC.
  */
 static GstBuffer *
-gst_rtp_dv_depay_process (GstRTPBaseDepayload * base, GstBuffer * in)
+gst_rtp_dv_depay_process (GstRTPBaseDepayload * base, GstRTPBuffer * rtp)
 {
   GstBuffer *out = NULL;
   guint8 *payload;
@@ -295,15 +300,13 @@ gst_rtp_dv_depay_process (GstRTPBaseDepayload * base, GstBuffer * in)
   guint payload_len, location;
   GstRTPDVDepay *dvdepay = GST_RTP_DV_DEPAY (base);
   gboolean marker;
-  GstRTPBuffer rtp = { NULL, };
-
-  gst_rtp_buffer_map (in, GST_MAP_READ, &rtp);
+  GstMapInfo map;
 
-  marker = gst_rtp_buffer_get_marker (&rtp);
+  marker = gst_rtp_buffer_get_marker (rtp);
 
   /* Check if the received packet contains (the start of) a new frame, we do
    * this by checking the RTP timestamp. */
-  rtp_ts = gst_rtp_buffer_get_timestamp (&rtp);
+  rtp_ts = gst_rtp_buffer_get_timestamp (rtp);
 
   /* we cannot copy the packet yet if the marker is set, we will do that below
    * after taking out the data */
@@ -314,13 +317,15 @@ gst_rtp_dv_depay_process (GstRTPBaseDepayload * base, GstBuffer * in)
 
     /* return copy of accumulator. */
     out = gst_buffer_copy (dvdepay->acc);
+    gst_buffer_foreach_meta (dvdepay->acc, foreach_metadata_drop, NULL);
   }
 
   /* Extract the payload */
-  payload_len = gst_rtp_buffer_get_payload_len (&rtp);
-  payload = gst_rtp_buffer_get_payload (&rtp);
+  payload_len = gst_rtp_buffer_get_payload_len (rtp);
+  payload = gst_rtp_buffer_get_payload (rtp);
 
   /* copy all DIF chunks in their place. */
+  gst_buffer_map (dvdepay->acc, &map, GST_MAP_READWRITE);
   while (payload_len >= 80) {
     guint offset;
 
@@ -341,14 +346,17 @@ gst_rtp_dv_depay_process (GstRTPBaseDepayload * base, GstBuffer * in)
       offset = location * 80;
 
       /* And copy it in, provided the location is sane. */
-      if (offset <= dvdepay->frame_size - 80)
-        gst_buffer_fill (dvdepay->acc, offset, payload, 80);
+      if (offset <= dvdepay->frame_size - 80) {
+        memcpy (map.data + offset, payload, 80);
+        gst_rtp_copy_meta (GST_ELEMENT_CAST (dvdepay), dvdepay->acc,
+            rtp->buffer, 0);
+      }
     }
 
     payload += 80;
     payload_len -= 80;
   }
-  gst_rtp_buffer_unmap (&rtp);
+  gst_buffer_unmap (dvdepay->acc, &map);
 
   if (marker) {
     GST_DEBUG_OBJECT (dvdepay, "marker bit complete frame %u", rtp_ts);
@@ -358,6 +366,7 @@ gst_rtp_dv_depay_process (GstRTPBaseDepayload * base, GstBuffer * in)
        * will change the timestamp but we won't copy the accumulator again because
        * we set the prev_ts to -1. */
       out = gst_buffer_copy (dvdepay->acc);
+      gst_buffer_foreach_meta (dvdepay->acc, foreach_metadata_drop, NULL);
     } else {
       GST_WARNING_OBJECT (dvdepay, "waiting for frame headers %02x",
           dvdepay->header_mask);