From 0a24137100ab3a0c2d4986337b2a29e1a7d37bd1 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Olivier=20Cr=C3=AAte?= Date: Mon, 10 May 2010 19:09:28 -0400 Subject: [PATCH] basertpaudiopayload: Add extra frame for non-complete frame lengths Some payloaders like rtpg729pay can add a shorter frame at the end of a RTP packet. We need to count it like a full frame for timestamps. https://bugzilla.gnome.org/show_bug.cgi?id=618324 --- gst-libs/gst/rtp/gstbasertpaudiopayload.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/gst-libs/gst/rtp/gstbasertpaudiopayload.c b/gst-libs/gst/rtp/gstbasertpaudiopayload.c index 1596962..512455a 100644 --- a/gst-libs/gst/rtp/gstbasertpaudiopayload.c +++ b/gst-libs/gst/rtp/gstbasertpaudiopayload.c @@ -722,16 +722,27 @@ static GstClockTime gst_base_rtp_audio_payload_frame_bytes_to_time (GstBaseRTPAudioPayload * payload, guint64 bytes) { - return (bytes / payload->frame_size) * (payload->priv->frame_duration_ns); + guint64 framecount; + + framecount = bytes / payload->frame_size; + if (G_UNLIKELY (bytes % payload->frame_size)) + framecount++; + + return framecount * payload->priv->frame_duration_ns; } static guint32 gst_base_rtp_audio_payload_frame_bytes_to_rtptime (GstBaseRTPAudioPayload * payload, guint64 bytes) { + guint64 framecount; guint64 time; - time = (bytes / payload->frame_size) * (payload->priv->frame_duration_ns); + framecount = bytes / payload->frame_size; + if (G_UNLIKELY (bytes % payload->frame_size)) + framecount++; + + time = framecount * payload->priv->frame_duration_ns; return gst_util_uint64_scale_int (time, GST_BASE_RTP_PAYLOAD (payload)->clock_rate, GST_SECOND); -- 2.7.4