rtp: port some pay/depayloaders
authorWim Taymans <wim.taymans@collabora.co.uk>
Thu, 7 Apr 2011 17:04:33 +0000 (19:04 +0200)
committerWim Taymans <wim.taymans@collabora.co.uk>
Thu, 7 Apr 2011 17:04:33 +0000 (19:04 +0200)
gst/rtp/gstrtpac3depay.c
gst/rtp/gstrtpac3pay.c
gst/rtp/gstrtpbvdepay.c
gst/rtp/gstrtpceltdepay.c
gst/rtp/gstrtpceltpay.c
gst/rtp/gstrtpdvdepay.c
gst/rtp/gstrtpdvpay.c

index 2ba4cef..ba622ff 100644 (file)
@@ -165,47 +165,48 @@ 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);
 
-    GST_DEBUG_OBJECT (rtpac3depay, "pushing buffer of size %d",
-        GST_BUFFER_SIZE (outbuf));
+  gst_rtp_buffer_unmap (&rtp);
 
-    return 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;
   }
 }
index fddea38..f474a8c 100644 (file)
@@ -247,6 +247,7 @@ gst_rtp_ac3_pay_flush (GstRtpAC3Pay * rtpac3pay)
     guint8 *payload;
     guint payload_len;
     guint packet_len;
+    GstRTPBuffer rtp = { NULL, };
 
     /* this will be the total length of the packet */
     packet_len = gst_rtp_buffer_calc_packet_len (2 + avail, 0, 0);
@@ -294,8 +295,9 @@ gst_rtp_ac3_pay_flush (GstRtpAC3Pay * rtpac3pay)
      *     3: other fragment
      * NF: amount of frames if FT = 0, else number of fragments.
      */
+    gst_rtp_buffer_map (outbuf, GST_MAP_WRITE, &rtp);
     GST_LOG_OBJECT (rtpac3pay, "FT %u, NF %u", FT, NF);
-    payload = gst_rtp_buffer_get_payload (outbuf);
+    payload = gst_rtp_buffer_get_payload (&rtp);
     payload[0] = (FT & 3);
     payload[1] = NF;
     payload_len -= 2;
@@ -305,7 +307,8 @@ gst_rtp_ac3_pay_flush (GstRtpAC3Pay * rtpac3pay)
 
     avail -= payload_len;
     if (avail == 0)
-      gst_rtp_buffer_set_marker (outbuf, TRUE);
+      gst_rtp_buffer_set_marker (&rtp, TRUE);
+    gst_rtp_buffer_unmap (&rtp);
 
     GST_BUFFER_TIMESTAMP (outbuf) = rtpac3pay->first_ts;
     GST_BUFFER_DURATION (outbuf) = rtpac3pay->duration;
@@ -322,15 +325,14 @@ gst_rtp_ac3_pay_handle_buffer (GstBaseRTPPayload * basepayload,
 {
   GstRtpAC3Pay *rtpac3pay;
   GstFlowReturn ret;
-  guint size, avail, left, NF;
+  gsize size, avail, left, NF;
   guint8 *data, *p;
   guint packet_len;
   GstClockTime duration, timestamp;
 
   rtpac3pay = GST_RTP_AC3_PAY (basepayload);
 
-  size = GST_BUFFER_SIZE (buffer);
-  data = GST_BUFFER_DATA (buffer);
+  data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
   duration = GST_BUFFER_DURATION (buffer);
   timestamp = GST_BUFFER_TIMESTAMP (buffer);
 
@@ -374,6 +376,7 @@ gst_rtp_ac3_pay_handle_buffer (GstBaseRTPPayload * basepayload,
     p += frame_size;
     left -= frame_size;
   }
+  gst_buffer_unmap (buffer, data, size);
   if (NF == 0)
     goto no_frames;
 
index 00c1452..7d5cdf3 100644 (file)
@@ -158,14 +158,18 @@ gst_rtp_bv_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
 {
   GstBuffer *outbuf;
   gboolean marker;
+  GstRTPBuffer rtp = { NULL, };
 
-  marker = gst_rtp_buffer_get_marker (buf);
+  gst_rtp_buffer_map (buf, GST_MAP_READ, &rtp);
+
+  marker = gst_rtp_buffer_get_marker (&rtp);
 
   GST_DEBUG ("process : got %d bytes, mark %d ts %u seqn %d",
-      GST_BUFFER_SIZE (buf), marker,
-      gst_rtp_buffer_get_timestamp (buf), gst_rtp_buffer_get_seq (buf));
+      gst_buffer_get_size (buf), marker,
+      gst_rtp_buffer_get_timestamp (&rtp), gst_rtp_buffer_get_seq (&rtp));
 
-  outbuf = gst_rtp_buffer_get_payload_buffer (buf);
+  outbuf = gst_rtp_buffer_get_payload_buffer (&rtp);
+  gst_rtp_buffer_unmap (&rtp);
 
   if (marker) {
     /* mark start of talkspurt with DISCONT */
index c03a5b4..e1fc4c5 100644 (file)
@@ -122,7 +122,8 @@ gst_rtp_celt_depay_setcaps (GstBaseRTPDepayload * depayload, GstCaps * caps)
   GstRtpCELTDepay *rtpceltdepay;
   gint clock_rate, nb_channels = 0, frame_size = 0;
   GstBuffer *buf;
-  guint8 *data;
+  guint8 *data, *ptr;
+  gsize size;
   const gchar *params;
   GstCaps *srccaps;
   gboolean res;
@@ -151,26 +152,27 @@ gst_rtp_celt_depay_setcaps (GstBaseRTPDepayload * depayload, GstCaps * caps)
 
   /* construct minimal header and comment packet for the decoder */
   buf = gst_buffer_new_and_alloc (60);
-  data = GST_BUFFER_DATA (buf);
-  memcpy (data, "CELT    ", 8);
-  data += 8;
-  memcpy (data, "1.1.12", 7);
-  data += 20;
-  GST_WRITE_UINT32_LE (data, 0x80000006);       /* version */
-  data += 4;
-  GST_WRITE_UINT32_LE (data, 56);       /* header_size */
-  data += 4;
-  GST_WRITE_UINT32_LE (data, clock_rate);       /* rate */
-  data += 4;
-  GST_WRITE_UINT32_LE (data, nb_channels);      /* channels */
-  data += 4;
-  GST_WRITE_UINT32_LE (data, frame_size);       /* frame-size */
-  data += 4;
-  GST_WRITE_UINT32_LE (data, -1);       /* overlap */
-  data += 4;
-  GST_WRITE_UINT32_LE (data, -1);       /* bytes_per_packet */
-  data += 4;
-  GST_WRITE_UINT32_LE (data, 0);        /* extra headers */
+  ptr = data = gst_buffer_map (buf, &size, NULL, GST_MAP_WRITE);
+  memcpy (ptr, "CELT    ", 8);
+  ptr += 8;
+  memcpy (ptr, "1.1.12", 7);
+  ptr += 20;
+  GST_WRITE_UINT32_LE (ptr, 0x80000006);        /* version */
+  ptr += 4;
+  GST_WRITE_UINT32_LE (ptr, 56);        /* header_size */
+  ptr += 4;
+  GST_WRITE_UINT32_LE (ptr, clock_rate);        /* rate */
+  ptr += 4;
+  GST_WRITE_UINT32_LE (ptr, nb_channels);       /* channels */
+  ptr += 4;
+  GST_WRITE_UINT32_LE (ptr, frame_size);        /* frame-size */
+  ptr += 4;
+  GST_WRITE_UINT32_LE (ptr, -1);        /* overlap */
+  ptr += 4;
+  GST_WRITE_UINT32_LE (ptr, -1);        /* bytes_per_packet */
+  ptr += 4;
+  GST_WRITE_UINT32_LE (ptr, 0); /* extra headers */
+  gst_buffer_unmap (buf, data, size);
 
   srccaps = gst_caps_new_simple ("audio/x-celt", NULL);
   res = gst_pad_set_caps (depayload->srcpad, srccaps);
@@ -180,8 +182,7 @@ gst_rtp_celt_depay_setcaps (GstBaseRTPDepayload * depayload, GstCaps * caps)
   gst_base_rtp_depayload_push (GST_BASE_RTP_DEPAYLOAD (rtpceltdepay), buf);
 
   buf = gst_buffer_new_and_alloc (sizeof (gst_rtp_celt_comment));
-  memcpy (GST_BUFFER_DATA (buf), gst_rtp_celt_comment,
-      sizeof (gst_rtp_celt_comment));
+  gst_buffer_fill (buf, 0, gst_rtp_celt_comment, sizeof (gst_rtp_celt_comment));
 
   gst_buffer_set_caps (buf, GST_PAD_CAPS (depayload->srcpad));
   gst_base_rtp_depayload_push (GST_BASE_RTP_DEPAYLOAD (rtpceltdepay), buf);
@@ -207,6 +208,7 @@ gst_rtp_celt_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
   GstClockTime framesize_ns = 0, timestamp;
   guint n = 0;
   GstRtpCELTDepay *rtpceltdepay;
+  GstRTPBuffer rtp = { NULL, };
 
   rtpceltdepay = GST_RTP_CELT_DEPAY (depayload);
   clock_rate = depayload->clock_rate;
@@ -215,17 +217,19 @@ gst_rtp_celt_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
 
   timestamp = GST_BUFFER_TIMESTAMP (buf);
 
+  gst_rtp_buffer_map (buf, GST_MAP_READ, &rtp);
+
   GST_LOG_OBJECT (depayload, "got %d bytes, mark %d ts %u seqn %d",
-      GST_BUFFER_SIZE (buf),
-      gst_rtp_buffer_get_marker (buf),
-      gst_rtp_buffer_get_timestamp (buf), gst_rtp_buffer_get_seq (buf));
+      gst_buffer_get_size (buf),
+      gst_rtp_buffer_get_marker (&rtp),
+      gst_rtp_buffer_get_timestamp (&rtp), gst_rtp_buffer_get_seq (&rtp));
 
   GST_LOG_OBJECT (depayload, "got clock-rate=%d, frame_size=%d, "
       "_ns=%" GST_TIME_FORMAT ", timestamp=%" GST_TIME_FORMAT, clock_rate,
       frame_size, GST_TIME_ARGS (framesize_ns), GST_TIME_ARGS (timestamp));
 
-  payload = gst_rtp_buffer_get_payload (buf);
-  payload_len = gst_rtp_buffer_get_payload_len (buf);
+  payload = gst_rtp_buffer_get_payload (&rtp);
+  payload_len = gst_rtp_buffer_get_payload_len (&rtp);
 
   /* first count how many bytes are consumed by the size headers and make offset
    * point to the first data byte */
@@ -250,7 +254,7 @@ gst_rtp_celt_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
       total_size += size + 1;
     } while (s == 0xff);
 
-    outbuf = gst_rtp_buffer_get_payload_subbuffer (buf, offset, size);
+    outbuf = gst_rtp_buffer_get_payload_subbuffer (&rtp, offset, size);
     offset += size;
 
     if (frame_size != -1 && clock_rate != -1) {
@@ -264,6 +268,8 @@ gst_rtp_celt_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
 
     gst_base_rtp_depayload_push (depayload, outbuf);
   }
+  gst_rtp_buffer_unmap (&rtp);
+
   return NULL;
 }
 
index 05715c1..5d32be9 100644 (file)
@@ -310,6 +310,7 @@ gst_rtp_celt_pay_flush_queued (GstRtpCELTPay * rtpceltpay)
   guint8 *payload, *spayload;
   guint payload_len;
   GstClockTime duration;
+  GstRTPBuffer rtp = { NULL, };
 
   payload_len = rtpceltpay->bytes + rtpceltpay->sbytes;
   duration = rtpceltpay->qduration;
@@ -322,8 +323,10 @@ gst_rtp_celt_pay_flush_queued (GstRtpCELTPay * rtpceltpay)
 
   GST_BUFFER_DURATION (outbuf) = duration;
 
+  gst_rtp_buffer_map (outbuf, GST_MAP_WRITE, &rtp);
+
   /* point to the payload for size headers and data */
-  spayload = gst_rtp_buffer_get_payload (outbuf);
+  spayload = gst_rtp_buffer_get_payload (&rtp);
   payload = spayload + rtpceltpay->sbytes;
 
   while ((buf = g_queue_pop_head (rtpceltpay->queue))) {
@@ -334,20 +337,21 @@ gst_rtp_celt_pay_flush_queued (GstRtpCELTPay * rtpceltpay)
       GST_BUFFER_TIMESTAMP (outbuf) = GST_BUFFER_TIMESTAMP (buf);
 
     /* write the size to the header */
-    size = GST_BUFFER_SIZE (buf);
+    size = gst_buffer_get_size (buf);
     while (size > 0xff) {
       *spayload++ = 0xff;
       size -= 0xff;
     }
     *spayload++ = size;
 
-    size = GST_BUFFER_SIZE (buf);
     /* copy payload */
-    memcpy (payload, GST_BUFFER_DATA (buf), size);
+    size = gst_buffer_get_size (buf);
+    gst_buffer_extract (buf, 0, payload, size);
     payload += size;
 
     gst_buffer_unref (buf);
   }
+  gst_rtp_buffer_unmap (&rtp);
 
   /* we consumed it all */
   rtpceltpay->bytes = 0;
@@ -365,7 +369,7 @@ gst_rtp_celt_pay_handle_buffer (GstBaseRTPPayload * basepayload,
 {
   GstFlowReturn ret;
   GstRtpCELTPay *rtpceltpay;
-  guint size, payload_len;
+  gsize size, payload_len;
   guint8 *data;
   GstClockTime duration, packet_dur;
   guint i, ssize, packet_len;
@@ -374,8 +378,7 @@ gst_rtp_celt_pay_handle_buffer (GstBaseRTPPayload * basepayload,
 
   ret = GST_FLOW_OK;
 
-  size = GST_BUFFER_SIZE (buffer);
-  data = GST_BUFFER_DATA (buffer);
+  data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
 
   switch (rtpceltpay->packet) {
     case 0:
@@ -384,14 +387,15 @@ gst_rtp_celt_pay_handle_buffer (GstBaseRTPPayload * basepayload,
       if (!gst_rtp_celt_pay_parse_ident (rtpceltpay, data, size))
         goto parse_error;
 
-      goto done;
+      goto cleanup;
     case 1:
       /* comment packet, we ignore it */
-      goto done;
+      goto cleanup;
     default:
       /* other packets go in the payload */
       break;
   }
+  gst_buffer_unmap (buffer, data, size);
 
   duration = GST_BUFFER_DURATION (buffer);
 
@@ -429,10 +433,16 @@ done:
   return ret;
 
   /* ERRORS */
+cleanup:
+  {
+    gst_buffer_unmap (buffer, data, size);
+    goto done;
+  }
 parse_error:
   {
     GST_ELEMENT_ERROR (rtpceltpay, STREAM, DECODE, (NULL),
         ("Error parsing first identification packet."));
+    gst_buffer_unmap (buffer, data, size);
     return GST_FLOW_ERROR;
   }
 }
index 883d115..25ebc1a 100644 (file)
@@ -172,6 +172,8 @@ gst_rtp_dv_depay_setcaps (GstBaseRTPDepayload * depayload, GstCaps * caps)
   gint clock_rate;
   gboolean systemstream, ret;
   const gchar *encode, *media;
+  guint8 *data;
+  gsize size;
 
   rtpdvdepay = GST_RTP_DV_DEPAY (depayload);
 
@@ -216,7 +218,9 @@ gst_rtp_dv_depay_setcaps (GstBaseRTPDepayload * depayload, GstCaps * caps)
   /* Initialize the new accumulator frame.
    * If the previous frame exists, copy that into the accumulator frame.
    * This way, missing packets in the stream won't show up badly. */
-  memset (GST_BUFFER_DATA (rtpdvdepay->acc), 0, rtpdvdepay->frame_size);
+  data = gst_buffer_map (rtpdvdepay->acc, &size, NULL, GST_MAP_WRITE);
+  memset (data, 0, rtpdvdepay->frame_size);
+  gst_buffer_unmap (rtpdvdepay->acc, data, size);
 
   srccaps = gst_caps_new_simple ("video/x-dv",
       "systemstream", G_TYPE_BOOLEAN, systemstream,
@@ -300,12 +304,15 @@ gst_rtp_dv_depay_process (GstBaseRTPDepayload * base, GstBuffer * in)
   guint payload_len, location;
   GstRTPDVDepay *dvdepay = GST_RTP_DV_DEPAY (base);
   gboolean marker;
+  GstRTPBuffer rtp = { NULL, };
 
-  marker = gst_rtp_buffer_get_marker (in);
+  gst_rtp_buffer_map (in, GST_MAP_READ, &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 (in);
+  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 */
@@ -319,8 +326,8 @@ gst_rtp_dv_depay_process (GstBaseRTPDepayload * base, GstBuffer * in)
   }
 
   /* Extract the payload */
-  payload_len = gst_rtp_buffer_get_payload_len (in);
-  payload = gst_rtp_buffer_get_payload (in);
+  payload_len = gst_rtp_buffer_get_payload_len (&rtp);
+  payload = gst_rtp_buffer_get_payload (&rtp);
 
   /* copy all DIF chunks in their place. */
   while (payload_len >= 80) {
@@ -343,11 +350,12 @@ gst_rtp_dv_depay_process (GstBaseRTPDepayload * base, GstBuffer * in)
 
     /* And copy it in, provided the location is sane. */
     if (offset >= 0 && offset <= dvdepay->frame_size - 80)
-      memcpy (GST_BUFFER_DATA (dvdepay->acc) + offset, payload, 80);
+      gst_buffer_fill (dvdepay->acc, offset, payload, 80);
 
     payload += 80;
     payload_len -= 80;
   }
+  gst_rtp_buffer_unmap (&rtp);
 
   if (marker) {
     GST_DEBUG_OBJECT (dvdepay, "marker bit complete frame %u", rtp_ts);
index 1d6230c..bd87d70 100644 (file)
@@ -183,7 +183,7 @@ gst_rtp_dv_pay_setcaps (GstBaseRTPPayload * payload, GstCaps * caps)
 }
 
 static gboolean
-gst_dv_pay_negotiate (GstRTPDVPay * rtpdvpay, guint8 * data, guint size)
+gst_dv_pay_negotiate (GstRTPDVPay * rtpdvpay, guint8 * data, gsize size)
 {
   const gchar *encode, *media;
   gboolean audio_bundled, res;
@@ -284,10 +284,11 @@ gst_rtp_dv_pay_handle_buffer (GstBaseRTPPayload * basepayload,
   GstBuffer *outbuf;
   GstFlowReturn ret = GST_FLOW_OK;
   gint hdrlen;
-  guint size;
-  guint8 *data;
+  gsize size, osize;
+  guint8 *data, *odata;
   guint8 *dest;
   guint filled;
+  GstRTPBuffer rtp = { NULL, };
 
   rtpdvpay = GST_RTP_DV_PAY (basepayload);
 
@@ -300,8 +301,10 @@ gst_rtp_dv_pay_handle_buffer (GstBaseRTPPayload * basepayload,
   max_payload_size = ((GST_BASE_RTP_PAYLOAD_MTU (rtpdvpay) - hdrlen) / 80) * 80;
 
   /* The length of the buffer to transmit. */
-  size = GST_BUFFER_SIZE (buffer);
-  data = GST_BUFFER_DATA (buffer);
+  data = gst_buffer_map (buffer, &size, NULL, GST_MAP_READ);
+
+  odata = data;
+  osize = size;
 
   GST_DEBUG_OBJECT (rtpdvpay,
       "DV RTP payloader got buffer of %u bytes, splitting in %u byte "
@@ -324,7 +327,9 @@ gst_rtp_dv_pay_handle_buffer (GstBaseRTPPayload * basepayload,
     if (outbuf == NULL) {
       outbuf = gst_rtp_buffer_new_allocate (max_payload_size, 0, 0);
       GST_BUFFER_TIMESTAMP (outbuf) = GST_BUFFER_TIMESTAMP (buffer);
-      dest = gst_rtp_buffer_get_payload (outbuf);
+
+      gst_rtp_buffer_map (outbuf, GST_MAP_WRITE, &rtp);
+      dest = gst_rtp_buffer_get_payload (&rtp);
       filled = 0;
     }
 
@@ -348,13 +353,15 @@ gst_rtp_dv_pay_handle_buffer (GstBaseRTPPayload * basepayload,
         guint hlen;
 
         /* set marker */
-        gst_rtp_buffer_set_marker (outbuf, TRUE);
+        gst_rtp_buffer_set_marker (&rtp, TRUE);
 
         /* shrink buffer to last packet */
-        hlen = gst_rtp_buffer_get_header_len (outbuf);
-        gst_rtp_buffer_set_packet_len (outbuf, hlen + filled);
+        hlen = gst_rtp_buffer_get_header_len (&rtp);
+        gst_rtp_buffer_set_packet_len (&rtp, hlen + filled);
       }
+
       /* Push out the created piece, and check for errors. */
+      gst_rtp_buffer_unmap (&rtp);
       ret = gst_basertppayload_push (basepayload, outbuf);
       if (ret != GST_FLOW_OK)
         break;
@@ -362,6 +369,7 @@ gst_rtp_dv_pay_handle_buffer (GstBaseRTPPayload * basepayload,
       outbuf = NULL;
     }
   }
+  gst_buffer_unmap (buffer, odata, osize);
   gst_buffer_unref (buffer);
 
   return ret;