mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-11 01:45:33 +00:00
rtpgsmpay: Attach payload to the output buffer instead of copying it
This commit is contained in:
parent
cb0232ba4e
commit
137672ff18
1 changed files with 5 additions and 18 deletions
|
@ -25,8 +25,10 @@
|
|||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <gst/rtp/gstrtpbuffer.h>
|
||||
#include <gst/audio/audio.h>
|
||||
|
||||
#include "gstrtpgsmpay.h"
|
||||
#include "gstrtputils.h"
|
||||
|
||||
GST_DEBUG_CATEGORY_STATIC (rtpgsmpay_debug);
|
||||
#define GST_CAT_DEFAULT (rtpgsmpay_debug)
|
||||
|
@ -127,21 +129,16 @@ gst_rtp_gsm_pay_handle_buffer (GstRTPBasePayload * basepayload,
|
|||
GstRTPGSMPay *rtpgsmpay;
|
||||
guint payload_len;
|
||||
GstBuffer *outbuf;
|
||||
GstMapInfo map;
|
||||
guint8 *payload;
|
||||
GstClockTime timestamp, duration;
|
||||
GstFlowReturn ret;
|
||||
GstRTPBuffer rtp = { NULL };
|
||||
|
||||
rtpgsmpay = GST_RTP_GSM_PAY (basepayload);
|
||||
|
||||
gst_buffer_map (buffer, &map, GST_MAP_READ);
|
||||
|
||||
timestamp = GST_BUFFER_PTS (buffer);
|
||||
duration = GST_BUFFER_DURATION (buffer);
|
||||
|
||||
/* FIXME, only one GSM frame per RTP packet for now */
|
||||
payload_len = map.size;
|
||||
payload_len = gst_buffer_get_size (buffer);
|
||||
|
||||
/* FIXME, just error out for now */
|
||||
if (payload_len > GST_RTP_BASE_PAYLOAD_MTU (rtpgsmpay))
|
||||
|
@ -153,17 +150,8 @@ gst_rtp_gsm_pay_handle_buffer (GstRTPBasePayload * basepayload,
|
|||
GST_BUFFER_PTS (outbuf) = timestamp;
|
||||
GST_BUFFER_DURATION (outbuf) = duration;
|
||||
|
||||
/* get payload */
|
||||
gst_rtp_buffer_map (outbuf, GST_MAP_WRITE, &rtp);
|
||||
|
||||
/* copy data in payload */
|
||||
payload = gst_rtp_buffer_get_payload (&rtp);
|
||||
memcpy (payload, map.data, map.size);
|
||||
|
||||
gst_rtp_buffer_unmap (&rtp);
|
||||
|
||||
gst_buffer_unmap (buffer, &map);
|
||||
gst_buffer_unref (buffer);
|
||||
/* append payload */
|
||||
outbuf = gst_buffer_append (outbuf, buffer);
|
||||
|
||||
GST_DEBUG ("gst_rtp_gsm_pay_chain: pushing buffer of size %" G_GSIZE_FORMAT,
|
||||
gst_buffer_get_size (outbuf));
|
||||
|
@ -178,7 +166,6 @@ too_big:
|
|||
GST_ELEMENT_ERROR (rtpgsmpay, STREAM, ENCODE, (NULL),
|
||||
("payload_len %u > mtu %u", payload_len,
|
||||
GST_RTP_BASE_PAYLOAD_MTU (rtpgsmpay)));
|
||||
gst_buffer_unmap (buffer, &map);
|
||||
return GST_FLOW_ERROR;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue