diff options
author | Wim Taymans <wim.taymans@collabora.co.uk> | 2010-03-17 16:23:24 +0100 |
---|---|---|
committer | Wim Taymans <wim.taymans@collabora.co.uk> | 2010-03-17 16:27:13 +0100 |
commit | 7e363149f323f745b4147aa469208bdbb8465db6 (patch) | |
tree | 650f7a19034240d1e1311779a22824a92c7f2812 | |
parent | dcb5afd351b6ad89abf93e22a43a421a1722c489 (diff) |
mp4gdepay: improve constantDuration guessing
When no constantDuration has been given in the caps, try to derive one from the
timestamp difference between packets. Also keep doing this for each packet
because some broken streams might simply provide wrong timestamps.
-rw-r--r-- | gst/rtp/gstrtpmp4gdepay.c | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/gst/rtp/gstrtpmp4gdepay.c b/gst/rtp/gstrtpmp4gdepay.c index 939e3f1a8..8a3b5486f 100644 --- a/gst/rtp/gstrtpmp4gdepay.c +++ b/gst/rtp/gstrtpmp4gdepay.c @@ -441,6 +441,8 @@ 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); + GST_DEBUG_OBJECT (rtpmp4gdepay, "received payload of %d", payload_len); + rtptime = gst_rtp_buffer_get_timestamp (buf); M = gst_rtp_buffer_get_marker (buf); @@ -526,8 +528,11 @@ gst_rtp_mp4g_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf) if (i == 0) { AU_index = gst_bs_parse_read (&bs, rtpmp4gdepay->indexlength); + GST_DEBUG_OBJECT (rtpmp4gdepay, "AU index %u", AU_index); + if (AU_index == 0 && rtpmp4gdepay->prev_AU_index == 0) { gint diff; + gint cd; /* if we see two consecutive packets with AU_index of 0, we can * assume we have constantDuration packets. Since we don't have @@ -540,15 +545,17 @@ gst_rtp_mp4g_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf) diff = -(rtpmp4gdepay->prev_rtptime - rtptime); /* if no constantDuration was given, make one */ - if (rtpmp4gdepay->constantDuration == 0) { - rtpmp4gdepay->constantDuration = diff / num_AU_headers; - GST_DEBUG_OBJECT (depayload, "guessing constantDuration %d", - rtpmp4gdepay->constantDuration); + if (rtpmp4gdepay->constantDuration != 0) { + cd = rtpmp4gdepay->constantDuration; + GST_DEBUG_OBJECT (depayload, "using constantDuration %d", cd); + } else { + cd = diff / num_AU_headers; + GST_DEBUG_OBJECT (depayload, "guessing constantDuration %d", cd); } - if (rtpmp4gdepay->constantDuration > 0) { + if (cd > 0) { /* get the number of packets by dividing with the duration */ - diff /= rtpmp4gdepay->constantDuration; + diff /= cd; } else { diff = 0; } @@ -558,6 +565,8 @@ gst_rtp_mp4g_depay_process (GstBaseRTPDepayload * depayload, GstBuffer * buf) AU_index = rtpmp4gdepay->last_AU_index; + GST_DEBUG_OBJECT (rtpmp4gdepay, "diff %d, AU index %u", diff, + AU_index); } else { rtpmp4gdepay->prev_AU_index = AU_index; rtpmp4gdepay->last_AU_index = AU_index; |