diff options
author | Wim Taymans <wim.taymans@gmail.com> | 2007-04-10 17:06:05 +0000 |
---|---|---|
committer | Wim Taymans <wim.taymans@gmail.com> | 2007-04-10 17:06:05 +0000 |
commit | acddbd83ff23d7016afdcfad5da3d3aa82b63679 (patch) | |
tree | 0a7c756fb05a0c6bfb3a1babfd85d327684b5f91 /gst/rtp/gstrtpamrdepay.c | |
parent | 497d589d56cf5e0ef758ca6c0443cdee7b3da91d (diff) |
gst/rtp/gstrtpamrdepay.c: Fix depayloader clock_rate and some cleanups.
Original commit message from CVS:
* gst/rtp/gstrtpamrdepay.c: (gst_rtp_amr_depay_setcaps),
(gst_rtp_amr_depay_process):
Fix depayloader clock_rate and some cleanups.
* gst/rtp/gstrtph264depay.c: (gst_rtp_h264_depay_finalize),
(gst_rtp_h264_depay_setcaps), (gst_rtp_h264_depay_process):
* gst/rtp/gstrtph264depay.h:
Don't push codec_data in the adapter because it might get flushed when
we get a discont.
* gst/rtp/gstrtpmp4gdepay.c: (gst_rtp_mp4g_depay_process):
Handle multiple AU per packet.
* gst/rtp/gstrtpsv3vdepay.c: (gst_rtp_sv3v_depay_process),
(gst_rtp_sv3v_depay_plugin_init):
Disable rank, this one does not work.
Remove timestamping, base class does that.
Diffstat (limited to 'gst/rtp/gstrtpamrdepay.c')
-rw-r--r-- | gst/rtp/gstrtpamrdepay.c | 88 |
1 files changed, 50 insertions, 38 deletions
diff --git a/gst/rtp/gstrtpamrdepay.c b/gst/rtp/gstrtpamrdepay.c index 06ea6cd6..f5871584 100644 --- a/gst/rtp/gstrtpamrdepay.c +++ b/gst/rtp/gstrtpamrdepay.c @@ -197,6 +197,7 @@ gst_rtp_amr_depay_setcaps (GstBaseRTPDepayload * depayload, GstCaps * caps) if (!gst_structure_get_int (structure, "clock-rate", &clock_rate)) clock_rate = 8000; + depayload->clock_rate = clock_rate; /* we require 1 channel, 8000 Hz, octet aligned, no CRC, * no robust sorting, no interleaving for now */ @@ -233,24 +234,20 @@ gst_rtp_amr_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf) { GstRtpAMRDepay *rtpamrdepay; GstBuffer *outbuf = NULL; + gint payload_len; rtpamrdepay = GST_RTP_AMR_DEPAY (depayload); if (!rtpamrdepay->negotiated) goto not_negotiated; - if (!gst_rtp_buffer_validate (buf)) { - GST_ELEMENT_WARNING (rtpamrdepay, STREAM, DECODE, - (NULL), ("AMR RTP packet did not validate")); - goto bad_packet; - } + if (!gst_rtp_buffer_validate (buf)) + goto invalid_packet; /* when we get here, 1 channel, 8000 Hz, octet aligned, no CRC, * no robust sorting, no interleaving data is to be depayloaded */ { - gint payload_len; guint8 *payload, *p, *dp; - guint32 timestamp; guint8 CMR; gint i, num_packets, num_nonempty_packets; gint amr_len; @@ -259,11 +256,8 @@ gst_rtp_amr_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf) payload_len = gst_rtp_buffer_get_payload_len (buf); /* need at least 2 bytes for the header */ - if (payload_len < 2) { - GST_ELEMENT_WARNING (rtpamrdepay, STREAM, DECODE, - (NULL), ("AMR RTP payload too small (%d)", payload_len)); - goto bad_packet; - } + if (payload_len < 2) + goto too_small; payload = gst_rtp_buffer_get_payload (buf); @@ -290,11 +284,8 @@ gst_rtp_amr_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf) payload_len -= 1; payload += 1; - if (ILP > ILL) { - GST_ELEMENT_WARNING (rtpamrdepay, STREAM, DECODE, - (NULL), ("AMR RTP wrong interleaving")); - goto bad_packet; - } + if (ILP > ILL) + goto wrong_interleaving; } /* @@ -317,11 +308,8 @@ gst_rtp_amr_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf) fr_size = frame_size[FT]; GST_DEBUG_OBJECT (rtpamrdepay, "frame size %d", fr_size); - if (fr_size == -1) { - GST_ELEMENT_WARNING (rtpamrdepay, STREAM, DECODE, - (NULL), ("AMR RTP frame size == -1")); - goto bad_packet; - } + if (fr_size == -1) + goto wrong_framesize; if (fr_size > 0) { amr_len += fr_size; @@ -335,26 +323,15 @@ gst_rtp_amr_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf) if (rtpamrdepay->crc) { /* data len + CRC len + header bytes should be smaller than payload_len */ - if (num_packets + num_nonempty_packets + amr_len > payload_len) { - GST_ELEMENT_WARNING (rtpamrdepay, STREAM, DECODE, - (NULL), ("AMR RTP wrong length 1")); - goto bad_packet; - } + if (num_packets + num_nonempty_packets + amr_len > payload_len) + goto wrong_length_1; } else { /* data len + header bytes should be smaller than payload_len */ - if (num_packets + amr_len > payload_len) { - GST_ELEMENT_WARNING (rtpamrdepay, STREAM, DECODE, - (NULL), ("AMR RTP wrong length 2")); - goto bad_packet; - } + if (num_packets + amr_len > payload_len) + goto wrong_length_2; } - timestamp = gst_rtp_buffer_get_timestamp (buf); - outbuf = gst_buffer_new_and_alloc (payload_len); - GST_BUFFER_TIMESTAMP (outbuf) = - gst_util_uint64_scale_int (timestamp, GST_SECOND, - depayload->clock_rate); /* point to destination */ p = GST_BUFFER_DATA (outbuf); @@ -386,16 +363,51 @@ gst_rtp_amr_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf) GST_DEBUG ("gst_rtp_amr_depay_chain: pushing buffer of size %d", GST_BUFFER_SIZE (outbuf)); } - return outbuf; /* ERRORS */ +invalid_packet: + { + GST_ELEMENT_WARNING (rtpamrdepay, STREAM, DECODE, + (NULL), ("AMR RTP packet did not validate")); + goto bad_packet; + } not_negotiated: { GST_ELEMENT_ERROR (rtpamrdepay, STREAM, NOT_IMPLEMENTED, (NULL), ("not negotiated")); return NULL; } +too_small: + { + GST_ELEMENT_WARNING (rtpamrdepay, STREAM, DECODE, + (NULL), ("AMR RTP payload too small (%d)", payload_len)); + goto bad_packet; + } +wrong_interleaving: + { + GST_ELEMENT_WARNING (rtpamrdepay, STREAM, DECODE, + (NULL), ("AMR RTP wrong interleaving")); + goto bad_packet; + } +wrong_framesize: + { + GST_ELEMENT_WARNING (rtpamrdepay, STREAM, DECODE, + (NULL), ("AMR RTP frame size == -1")); + goto bad_packet; + } +wrong_length_1: + { + GST_ELEMENT_WARNING (rtpamrdepay, STREAM, DECODE, + (NULL), ("AMR RTP wrong length 1")); + goto bad_packet; + } +wrong_length_2: + { + GST_ELEMENT_WARNING (rtpamrdepay, STREAM, DECODE, + (NULL), ("AMR RTP wrong length 2")); + goto bad_packet; + } bad_packet: { /* no fatal error */ |