Commit 23b5a346 authored by Ramiro Polla's avatar Ramiro Polla Committed by George Kiagiadakis

rtpmp4gdepay: fix timestamps for RTP packets with multiple AUs

Use constantDuration to calculate the timestamp of non-first AU in the
RTP packet.

If constantDuration is not present in the MIME parameters, its value
must be calculated based on the timing information from two consecutive
RTP packets with AU-Index equal to 0.

https://bugzilla.gnome.org/show_bug.cgi?id=747881
parent cb852cd1
...@@ -560,6 +560,15 @@ gst_rtp_mp4g_depay_process (GstRTPBaseDepayload * depayload, GstRTPBuffer * rtp) ...@@ -560,6 +560,15 @@ gst_rtp_mp4g_depay_process (GstRTPBaseDepayload * depayload, GstRTPBuffer * rtp)
/* use number of packets and of previous frame */ /* use number of packets and of previous frame */
cd = diff / rtpmp4gdepay->prev_AU_num; cd = diff / rtpmp4gdepay->prev_AU_num;
GST_DEBUG_OBJECT (depayload, "guessing constantDuration %d", cd); GST_DEBUG_OBJECT (depayload, "guessing constantDuration %d", cd);
if (!GST_BUFFER_IS_DISCONT (rtp->buffer)) {
/* rfc3640 - 3.2.3.2
* if we see two consecutive packets with AU_index of 0 and
* there has been no discontinuity, we must conclude that this
* value of constantDuration is correct from now on. */
GST_DEBUG_OBJECT (depayload,
"constantDuration of %d detected", cd);
rtpmp4gdepay->constantDuration = cd;
}
} else { } else {
/* assume this frame has the same number of packets as the /* assume this frame has the same number of packets as the
* previous one */ * previous one */
...@@ -668,9 +677,16 @@ gst_rtp_mp4g_depay_process (GstRTPBaseDepayload * depayload, GstRTPBuffer * rtp) ...@@ -668,9 +677,16 @@ gst_rtp_mp4g_depay_process (GstRTPBaseDepayload * depayload, GstRTPBuffer * rtp)
GST_BUFFER_PTS (outbuf) = timestamp; GST_BUFFER_PTS (outbuf) = timestamp;
GST_BUFFER_OFFSET (outbuf) = AU_index; GST_BUFFER_OFFSET (outbuf) = AU_index;
/* make sure we don't use the timestamp again for other AUs in this if (rtpmp4gdepay->constantDuration != 0) {
* RTP packet. */ /* if we have constantDuration, calculate timestamp for next AU
timestamp = -1; * in this RTP packet. */
timestamp += (rtpmp4gdepay->constantDuration * GST_SECOND) /
depayload->clock_rate;
} else {
/* otherwise, make sure we don't use the timestamp again for other
* AUs. */
timestamp = GST_CLOCK_TIME_NONE;
}
GST_DEBUG_OBJECT (depayload, GST_DEBUG_OBJECT (depayload,
"pushing buffer of size %" G_GSIZE_FORMAT, "pushing buffer of size %" G_GSIZE_FORMAT,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment