mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-23 18:21:04 +00:00
gst/rtp/: Use more efficient adapter and rtpbuffer methods when possible.
Original commit message from CVS: * 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.
This commit is contained in:
parent
d26cbc8c66
commit
da3e23d375
15 changed files with 43 additions and 75 deletions
19
ChangeLog
19
ChangeLog
|
@ -1,3 +1,22 @@
|
|||
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),
|
||||
|
|
|
@ -220,10 +220,8 @@ gst_rtp_L16_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * 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;
|
||||
|
|
|
@ -123,19 +123,14 @@ static GstBuffer *
|
|||
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;
|
||||
}
|
||||
|
||||
|
|
|
@ -169,18 +169,13 @@ static GstBuffer *
|
|||
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;
|
||||
}
|
||||
|
|
|
@ -173,7 +173,6 @@ gst_rtp_mp2t_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
|
|||
GstRtpMP2TDepay *rtpmp2tdepay;
|
||||
GstBuffer *outbuf;
|
||||
gint payload_len;
|
||||
guint32 timestamp;
|
||||
|
||||
rtpmp2tdepay = GST_RTP_MP2T_DEPAY (depayload);
|
||||
|
||||
|
@ -185,15 +184,10 @@ gst_rtp_mp2t_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
|
|||
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));
|
||||
|
|
|
@ -276,7 +276,7 @@ gst_rtp_mp4g_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
|
|||
goto bad_packet;
|
||||
|
||||
{
|
||||
gint payload_len;
|
||||
gint payload_len, payload_header;
|
||||
guint8 *payload;
|
||||
guint32 timestamp;
|
||||
guint AU_headers_len;
|
||||
|
@ -284,6 +284,7 @@ gst_rtp_mp4g_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
|
|||
|
||||
payload_len = gst_rtp_buffer_get_payload_len (buf);
|
||||
payload = gst_rtp_buffer_get_payload (buf);
|
||||
payload_header = 0;
|
||||
|
||||
if (rtpmp4gdepay->sizelength > 0) {
|
||||
/* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+- .. -+-+-+-+-+-+-+-+-+-+
|
||||
|
@ -298,6 +299,7 @@ gst_rtp_mp4g_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
|
|||
|
||||
/* skip header */
|
||||
payload += 2;
|
||||
payload_header += 2;
|
||||
payload_len -= 2;
|
||||
|
||||
/* FIXME, use bits */
|
||||
|
@ -309,14 +311,15 @@ gst_rtp_mp4g_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
|
|||
|
||||
/* 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 */
|
||||
|
@ -325,11 +328,7 @@ gst_rtp_mp4g_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
|
|||
|
||||
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);
|
||||
|
|
|
@ -453,7 +453,6 @@ gst_rtp_mp4g_pay_flush (GstRtpMP4GPay * rtpmp4gpay)
|
|||
while (avail > 0) {
|
||||
guint towrite;
|
||||
guint8 *payload;
|
||||
guint8 *data;
|
||||
guint payload_len;
|
||||
guint packet_len;
|
||||
|
||||
|
@ -511,9 +510,8 @@ gst_rtp_mp4g_pay_flush (GstRtpMP4GPay * rtpmp4gpay)
|
|||
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 */
|
||||
|
|
|
@ -207,7 +207,6 @@ gst_rtp_mp4v_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
|
|||
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 */
|
||||
|
@ -217,7 +216,6 @@ gst_rtp_mp4v_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
|
|||
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",
|
||||
|
|
|
@ -262,7 +262,6 @@ gst_rtp_mp4v_pay_flush (GstRtpMP4VPay * rtpmp4vpay)
|
|||
while (avail > 0) {
|
||||
guint towrite;
|
||||
guint8 *payload;
|
||||
guint8 *data;
|
||||
guint payload_len;
|
||||
guint packet_len;
|
||||
|
||||
|
@ -280,9 +279,8 @@ gst_rtp_mp4v_pay_flush (GstRtpMP4VPay * rtpmp4vpay)
|
|||
|
||||
/* 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;
|
||||
|
|
|
@ -161,7 +161,6 @@ gst_rtp_mpa_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
|
|||
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);
|
||||
|
@ -179,16 +178,8 @@ gst_rtp_mpa_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * 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",
|
||||
|
|
|
@ -174,7 +174,6 @@ gst_rtp_mpa_pay_flush (GstRtpMPAPay * rtpmpapay)
|
|||
while (avail > 0) {
|
||||
guint towrite;
|
||||
guint8 *payload;
|
||||
guint8 *data;
|
||||
guint payload_len;
|
||||
guint packet_len;
|
||||
|
||||
|
@ -207,8 +206,7 @@ gst_rtp_mpa_pay_flush (GstRtpMPAPay * rtpmpapay)
|
|||
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;
|
||||
|
|
|
@ -158,13 +158,13 @@ gst_rtp_mpv_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
|
|||
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;
|
||||
|
@ -181,6 +181,7 @@ gst_rtp_mpv_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
|
|||
T = (payload[0] & 0x04);
|
||||
|
||||
payload_len -= 4;
|
||||
payload_header += 4;
|
||||
payload += 4;
|
||||
|
||||
if (T) {
|
||||
|
@ -197,13 +198,11 @@ gst_rtp_mpv_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
|
|||
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",
|
||||
|
|
|
@ -136,8 +136,6 @@ gst_rtp_pcma_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
|
|||
{
|
||||
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),
|
||||
|
@ -153,11 +151,8 @@ gst_rtp_pcma_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * 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;
|
||||
}
|
||||
|
||||
|
|
|
@ -136,8 +136,6 @@ gst_rtp_pcmu_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
|
|||
{
|
||||
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),
|
||||
|
@ -153,11 +151,8 @@ gst_rtp_pcmu_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * 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;
|
||||
}
|
||||
|
||||
|
|
|
@ -252,14 +252,10 @@ gst_rtp_sv3v_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf)
|
|||
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);
|
||||
|
|
Loading…
Reference in a new issue