+2007-03-29 Wim Taymans <wim@fluendo.com>
+
+ * gst/rtp/gstrtpL16depay.c: (gst_rtp_L16_depay_process):
+ * gst/rtp/gstrtpgsmdepay.c: (gst_rtp_gsm_depay_process):
+ * gst/rtp/gstrtpilbcdepay.c: (gst_rtp_ilbc_depay_process):
+ * gst/rtp/gstrtpmp2tdepay.c: (gst_rtp_mp2t_depay_process):
+ * gst/rtp/gstrtpmp4gdepay.c: (gst_rtp_mp4g_depay_process):
+ * gst/rtp/gstrtpmp4gpay.c: (gst_rtp_mp4g_pay_flush):
+ * gst/rtp/gstrtpmp4vdepay.c: (gst_rtp_mp4v_depay_setcaps),
+ (gst_rtp_mp4v_depay_process):
+ * gst/rtp/gstrtpmp4vpay.c: (gst_rtp_mp4v_pay_flush):
+ * gst/rtp/gstrtpmpadepay.c: (gst_rtp_mpa_depay_process):
+ * gst/rtp/gstrtpmpapay.c: (gst_rtp_mpa_pay_flush):
+ * gst/rtp/gstrtpmpvdepay.c: (gst_rtp_mpv_depay_process):
+ * gst/rtp/gstrtppcmadepay.c: (gst_rtp_pcma_depay_process):
+ * gst/rtp/gstrtppcmudepay.c: (gst_rtp_pcmu_depay_process):
+ * gst/rtp/gstrtpsv3vdepay.c: (gst_rtp_sv3v_depay_process):
+ Use more efficient adapter and rtpbuffer methods when possible.
+
2007-03-29 Sebastian Dröge <slomo@circular-chaos.org>
* gst/wavenc/gstwavenc.c: (gst_wavenc_create_header_buf),
{
gint payload_len;
- guint8 *payload;
payload_len = gst_rtp_buffer_get_payload_len (buf);
- payload = gst_rtp_buffer_get_payload (buf);
if (payload_len <= 0)
goto empty_packet;
gst_rtp_gsm_depay_process (GstBaseRTPDepayload * _depayload, GstBuffer * buf)
{
GstBuffer *outbuf = NULL;
- gint payload_len;
- guint8 *payload;
GST_DEBUG ("process : 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));
- payload_len = gst_rtp_buffer_get_payload_len (buf);
- payload = gst_rtp_buffer_get_payload (buf);
+ outbuf = gst_rtp_buffer_get_payload_buffer (buf);
- outbuf = gst_buffer_new_and_alloc (payload_len);
- memcpy (GST_BUFFER_DATA (outbuf), payload, payload_len);
return outbuf;
}
gst_rtp_ilbc_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
{
GstBuffer *outbuf = NULL;
- gint payload_len;
- gint header_len;
GST_DEBUG ("process : 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));
- payload_len = gst_rtp_buffer_get_payload_len (buf);
- header_len = gst_rtp_buffer_calc_header_len (0);
-
- outbuf = gst_buffer_create_sub (buf, header_len, payload_len);
+ outbuf = gst_rtp_buffer_get_payload_buffer (buf);
return outbuf;
}
GstRtpMP2TDepay *rtpmp2tdepay;
GstBuffer *outbuf;
gint payload_len;
- guint32 timestamp;
rtpmp2tdepay = GST_RTP_MP2T_DEPAY (depayload);
if (G_UNLIKELY (payload_len <= rtpmp2tdepay->skip_first_bytes))
goto empty_packet;
- timestamp = gst_rtp_buffer_get_timestamp (buf);
-
outbuf =
gst_rtp_buffer_get_payload_subbuffer (buf, rtpmp2tdepay->skip_first_bytes,
-1);
-
gst_buffer_set_caps (outbuf, GST_PAD_CAPS (depayload->srcpad));
- GST_BUFFER_TIMESTAMP (outbuf) =
- gst_util_uint64_scale_int (timestamp, GST_SECOND, depayload->clock_rate);
GST_DEBUG ("gst_rtp_mp2t_depay_chain: pushing buffer of size %d",
GST_BUFFER_SIZE (outbuf));
goto bad_packet;
{
- gint payload_len;
+ gint payload_len, payload_header;
guint8 *payload;
guint32 timestamp;
guint AU_headers_len;
payload_len = gst_rtp_buffer_get_payload_len (buf);
payload = gst_rtp_buffer_get_payload (buf);
+ payload_header = 0;
if (rtpmp4gdepay->sizelength > 0) {
/* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+- .. -+-+-+-+-+-+-+-+-+-+
/* skip header */
payload += 2;
+ payload_header += 2;
payload_len -= 2;
/* FIXME, use bits */
/* skip special headers */
payload += (AU_headers_len + 7) / 8;
+ payload_header += (AU_headers_len + 7) / 8;
payload_len = AU_size;
}
timestamp = gst_rtp_buffer_get_timestamp (buf);
- outbuf = gst_buffer_new_and_alloc (payload_len);
- memcpy (GST_BUFFER_DATA (outbuf), payload, payload_len);
-
+ /* strip header from payload and push in the adapter */
+ outbuf =
+ gst_rtp_buffer_get_payload_subbuffer (buf, payload_header, payload_len);
gst_adapter_push (rtpmp4gdepay->adapter, outbuf);
/* if this was the last packet of the VOP, create and push a buffer */
avail = gst_adapter_available (rtpmp4gdepay->adapter);
- outbuf = gst_buffer_new ();
- GST_BUFFER_SIZE (outbuf) = avail;
- GST_BUFFER_MALLOCDATA (outbuf) =
- gst_adapter_take (rtpmp4gdepay->adapter, avail);
- GST_BUFFER_DATA (outbuf) = GST_BUFFER_MALLOCDATA (outbuf);
+ outbuf = gst_adapter_take_buffer (rtpmp4gdepay->adapter, avail);
gst_buffer_set_caps (outbuf, GST_PAD_CAPS (depayload->srcpad));
GST_BUFFER_TIMESTAMP (outbuf) = gst_util_uint64_scale_int
(timestamp, GST_SECOND, depayload->clock_rate);
while (avail > 0) {
guint towrite;
guint8 *payload;
- guint8 *data;
guint payload_len;
guint packet_len;
payload[2] = (total & 0x1fe0) >> 5;
payload[3] = (total & 0x1f) << 3; /* we use 13 bits for the size, 3 bits index */
- data = (guint8 *) gst_adapter_peek (rtpmp4gpay->adapter, payload_len);
- memcpy (&payload[4], data, payload_len);
-
+ /* copy stuff from adapter to payload */
+ gst_adapter_copy (rtpmp4gpay->adapter, &payload[4], 0, payload_len);
gst_adapter_flush (rtpmp4gpay->adapter, payload_len);
/* marker only if the packet is complete */
gst_adapter_clear (rtpmp4vdepay->adapter);
outbuf = gst_rtp_buffer_get_payload_buffer (buf);
-
gst_adapter_push (rtpmp4vdepay->adapter, outbuf);
/* if this was the last packet of the VOP, create and push a buffer */
avail = gst_adapter_available (rtpmp4vdepay->adapter);
outbuf = gst_adapter_take_buffer (rtpmp4vdepay->adapter, avail);
-
gst_buffer_set_caps (outbuf, GST_PAD_CAPS (depayload->srcpad));
GST_DEBUG ("gst_rtp_mp4v_depay_chain: pushing buffer of size %d",
while (avail > 0) {
guint towrite;
guint8 *payload;
- guint8 *data;
guint payload_len;
guint packet_len;
/* copy payload */
payload = gst_rtp_buffer_get_payload (outbuf);
- data = (guint8 *) gst_adapter_peek (rtpmp4vpay->adapter, payload_len);
- memcpy (payload, data, payload_len);
+ gst_adapter_copy (rtpmp4vpay->adapter, payload, 0, payload_len);
gst_adapter_flush (rtpmp4vpay->adapter, payload_len);
avail -= payload_len;
gint payload_len;
guint8 *payload;
guint16 frag_offset;
- guint32 timestamp;
payload_len = gst_rtp_buffer_get_payload_len (buf);
payload = gst_rtp_buffer_get_payload (buf);
*/
frag_offset = (payload[2] << 8) | payload[3];
- payload_len -= 4;
- payload += 4;
-
- timestamp = gst_rtp_buffer_get_timestamp (buf);
-
- outbuf = gst_buffer_new_and_alloc (payload_len);
-
- //GST_BUFFER_TIMESTAMP (outbuf) = timestamp * GST_SECOND / 90000;
-
- memcpy (GST_BUFFER_DATA (outbuf), payload, payload_len);
+ /* subbuffer skipping the 4 header bytes */
+ outbuf = gst_rtp_buffer_get_payload_subbuffer (buf, 4, -1);
GST_DEBUG_OBJECT (rtpmpadepay,
"gst_rtp_mpa_depay_chain: pushing buffer of size %d",
while (avail > 0) {
guint towrite;
guint8 *payload;
- guint8 *data;
guint payload_len;
guint packet_len;
payload[2] = frag_offset >> 8;
payload[3] = frag_offset & 0xff;
- data = (guint8 *) gst_adapter_peek (rtpmpapay->adapter, payload_len);
- memcpy (&payload[4], data, payload_len);
+ gst_adapter_copy (rtpmpapay->adapter, &payload[4], 0, payload_len);
gst_adapter_flush (rtpmpapay->adapter, payload_len);
avail -= payload_len;
goto bad_packet;
{
- gint payload_len;
+ gint payload_len, payload_header;
guint8 *payload;
guint8 T;
- guint32 timestamp;
payload_len = gst_rtp_buffer_get_payload_len (buf);
payload = gst_rtp_buffer_get_payload (buf);
+ payload_header = 0;
if (payload_len <= 4)
goto empty_packet;
T = (payload[0] & 0x04);
payload_len -= 4;
+ payload_header += 4;
payload += 4;
if (T) {
goto empty_packet;
payload_len -= 4;
+ payload_header += 4;
payload += 4;
}
- timestamp = gst_rtp_buffer_get_timestamp (buf);
-
- outbuf = gst_buffer_new_and_alloc (payload_len);
- memcpy (GST_BUFFER_DATA (outbuf), payload, payload_len);
+ outbuf = gst_rtp_buffer_get_payload_subbuffer (buf, payload_header, -1);
GST_DEBUG_OBJECT (rtpmpvdepay,
"gst_rtp_mpv_depay_chain: pushing buffer of size %d",
{
GstCaps *srccaps;
GstBuffer *outbuf = NULL;
- gint payload_len;
- guint8 *payload;
GST_DEBUG ("process : got %d bytes, mark %d ts %u seqn %d",
GST_BUFFER_SIZE (buf),
gst_caps_unref (srccaps);
}
- payload_len = gst_rtp_buffer_get_payload_len (buf);
- payload = gst_rtp_buffer_get_payload (buf);
+ outbuf = gst_rtp_buffer_get_payload_buffer (buf);
- outbuf = gst_buffer_new_and_alloc (payload_len);
- memcpy (GST_BUFFER_DATA (outbuf), payload, payload_len);
return outbuf;
}
{
GstCaps *srccaps;
GstBuffer *outbuf = NULL;
- gint payload_len;
- guint8 *payload;
GST_DEBUG ("process : got %d bytes, mark %d ts %u seqn %d",
GST_BUFFER_SIZE (buf),
gst_caps_unref (srccaps);
}
- payload_len = gst_rtp_buffer_get_payload_len (buf);
- payload = gst_rtp_buffer_get_payload (buf);
+ outbuf = gst_rtp_buffer_get_payload_buffer (buf);
- outbuf = gst_buffer_new_and_alloc (payload_len);
- memcpy (GST_BUFFER_DATA (outbuf), payload, payload_len);
return outbuf;
}
if (M) {
/* frame is completed: push contents of adapter */
guint avail;
- guint8 *data;
guint32 timestamp;
avail = gst_adapter_available (rtpsv3vdepay->adapter);
- data = gst_adapter_take (rtpsv3vdepay->adapter, avail);
-
- /* create buffer with data */
- outbuf = gst_rtp_buffer_new_take_data (data, avail);
+ outbuf = gst_adapter_take_buffer (rtpsv3vdepay->adapter, avail);
/* timestamp for complete buffer is that of last buffer as well */
timestamp = gst_rtp_buffer_get_timestamp (buf);