summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWim Taymans <wim.taymans@collabora.co.uk>2009-09-03 14:13:44 +0200
committerWim Taymans <wim.taymans@collabora.co.uk>2009-09-03 17:59:00 +0200
commit3a3c6f309c6b4da41a8e752310cdde8cfa80573c (patch)
tree68a5988c4332782058a2d7cbaefd24be20382f6e
parentbfc19462bb16e3d6542caa8c5db91668315693d9 (diff)
audiortppay: fix frame duration calculations
Fix the calculation of the frame duration and rtp timestamps. Add some debugging
-rw-r--r--gst-libs/gst/rtp/gstbasertpaudiopayload.c25
1 files changed, 18 insertions, 7 deletions
diff --git a/gst-libs/gst/rtp/gstbasertpaudiopayload.c b/gst-libs/gst/rtp/gstbasertpaudiopayload.c
index f19552ab6..d6458a0e6 100644
--- a/gst-libs/gst/rtp/gstbasertpaudiopayload.c
+++ b/gst-libs/gst/rtp/gstbasertpaudiopayload.c
@@ -258,10 +258,13 @@ gst_base_rtp_audio_payload_set_frame_options (GstBaseRTPAudioPayload
{
g_return_if_fail (basertpaudiopayload != NULL);
- basertpaudiopayload->frame_size = frame_size;
basertpaudiopayload->frame_duration = frame_duration;
+ basertpaudiopayload->frame_size = frame_size;
gst_adapter_clear (basertpaudiopayload->priv->adapter);
+
+ GST_DEBUG_OBJECT (basertpaudiopayload, "frame set to %d ms and size %d",
+ frame_duration, frame_size);
}
/**
@@ -308,6 +311,9 @@ gst_base_rtp_audio_payload_set_samplebits_options (GstBaseRTPAudioPayload
basertpaudiopayload->priv->fragment_size = fragment_size / 8;
gst_adapter_clear (basertpaudiopayload->priv->adapter);
+
+ GST_DEBUG_OBJECT (basertpaudiopayload,
+ "Samplebits set to sample size %d bits", sample_size);
}
static void
@@ -514,16 +520,21 @@ static GstClockTime
gst_base_rtp_audio_payload_get_frame_duration (GstBaseRTPAudioPayload *
payload, guint64 bytes)
{
- return gst_util_uint64_scale (bytes, payload->frame_duration * GST_MSECOND,
- payload->frame_size);
+ return (bytes / payload->frame_size) * (payload->frame_duration *
+ GST_MSECOND);
}
static guint32
gst_base_rtp_audio_payload_get_frame_rtptime (GstBaseRTPAudioPayload * payload,
guint64 bytes)
{
- return gst_util_uint64_scale (bytes, payload->frame_duration * GST_MSECOND,
- payload->frame_size * GST_BASE_RTP_PAYLOAD_CAST (payload)->clock_rate);
+ GstClockTime duration;
+
+ duration =
+ (bytes / payload->frame_size) * (payload->frame_duration * GST_MSECOND);
+
+ return gst_util_uint64_scale_int (duration,
+ GST_BASE_RTP_PAYLOAD_CAST (payload)->clock_rate, GST_SECOND);
}
static gboolean
@@ -575,8 +586,8 @@ static GstClockTime
gst_base_rtp_audio_payload_get_sample_duration (GstBaseRTPAudioPayload *
payload, guint64 bytes)
{
- return (bytes * 8 * GST_SECOND) /
- (GST_BASE_RTP_PAYLOAD (payload)->clock_rate * payload->sample_size);
+ return gst_util_uint64_scale (bytes * 8, GST_SECOND,
+ GST_BASE_RTP_PAYLOAD (payload)->clock_rate * payload->sample_size);
}
static guint32