From: Olivier CrĂȘte Date: Mon, 10 May 2010 23:09:28 +0000 (-0400) Subject: basertpaudiopayload: Add extra frame for non-complete frame lengths X-Git-Tag: RELEASE-0.10.30~202 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=0a24137100ab3a0c2d4986337b2a29e1a7d37bd1;p=platform%2Fupstream%2Fgst-plugins-base.git 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 --- 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);