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
This commit is contained in:
Olivier Crête 2010-05-10 19:09:28 -04:00 committed by Wim Taymans
parent 8a2b81a576
commit 0a24137100

View file

@ -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);