summaryrefslogtreecommitdiffstats
path: root/gst/rtp/gstrtppcmupay.c
diff options
context:
space:
mode:
authorKai Vehmanen <kv2004@eca.cx>2006-07-26 16:36:59 +0000
committerWim Taymans <wim.taymans@gmail.com>2006-07-26 16:36:59 +0000
commitca00f98eb521503e9e7094cdd37a553c493913ff (patch)
tree04a3297da0de19d372fa5e3a2b24b8c9f7f8b63f /gst/rtp/gstrtppcmupay.c
parent1adb9122d74ef67a6f8541b7032c2fdd8fbf48f5 (diff)
gst/rtp/: Fix timestamp calculation on outgoing RTP packets.
Original commit message from CVS: Patch by: Kai Vehmanen <kv2004 at eca dot cx> * gst/rtp/gstrtppcmapay.c: (gst_rtp_pcma_pay_flush), (gst_rtp_pcma_pay_handle_buffer): * gst/rtp/gstrtppcmupay.c: (gst_rtp_pcmu_pay_flush), (gst_rtp_pcmu_pay_handle_buffer): Fix timestamp calculation on outgoing RTP packets. Fixes #348675.
Diffstat (limited to 'gst/rtp/gstrtppcmupay.c')
-rw-r--r--gst/rtp/gstrtppcmupay.c24
1 files changed, 17 insertions, 7 deletions
diff --git a/gst/rtp/gstrtppcmupay.c b/gst/rtp/gstrtppcmupay.c
index 91115913..9a3aee30 100644
--- a/gst/rtp/gstrtppcmupay.c
+++ b/gst/rtp/gstrtppcmupay.c
@@ -129,7 +129,7 @@ gst_rtp_pcmu_pay_setcaps (GstBaseRTPPayload * payload, GstCaps * caps)
}
static GstFlowReturn
-gst_rtp_pcmu_pay_flush (GstRtpPcmuPay * rtppcmupay)
+gst_rtp_pcmu_pay_flush (GstRtpPcmuPay * rtppcmupay, guint32 clock_rate)
{
guint avail;
GstBuffer *outbuf;
@@ -141,8 +141,8 @@ gst_rtp_pcmu_pay_flush (GstRtpPcmuPay * rtppcmupay)
/* calculate octet count with:
maxptime-nsec * samples-per-sec / nsecs-per-sec * octets-per-sample */
maxptime_octets =
- GST_BASE_RTP_PAYLOAD (rtppcmupay)->max_ptime *
- GST_BASE_RTP_PAYLOAD (rtppcmupay)->clock_rate / GST_SECOND;
+ gst_util_uint64_scale_int (GST_BASE_RTP_PAYLOAD (rtppcmupay)->max_ptime,
+ clock_rate, GST_SECOND);
}
/* the data available in the adapter is either smaller
@@ -181,6 +181,14 @@ gst_rtp_pcmu_pay_flush (GstRtpPcmuPay * rtppcmupay)
GST_BUFFER_TIMESTAMP (outbuf) = rtppcmupay->first_ts;
ret = gst_basertppayload_push (GST_BASE_RTP_PAYLOAD (rtppcmupay), outbuf);
+
+ /* increase count (in ts) of data pushed to basertppayload */
+ rtppcmupay->first_ts +=
+ gst_util_uint64_scale_int (payload_len, GST_SECOND, clock_rate);
+
+ /* store amount of unpushed data (in ts) */
+ rtppcmupay->duration =
+ gst_util_uint64_scale_int (avail, GST_SECOND, clock_rate);
}
return ret;
@@ -194,11 +202,14 @@ gst_rtp_pcmu_pay_handle_buffer (GstBaseRTPPayload * basepayload,
guint size, packet_len, avail;
GstFlowReturn ret;
GstClockTime duration;
+ guint32 clock_rate;
rtppcmupay = GST_RTP_PCMU_PAY (basepayload);
+ clock_rate = basepayload->clock_rate;
+
size = GST_BUFFER_SIZE (buffer);
- duration = GST_BUFFER_TIMESTAMP (buffer);
+ duration = gst_util_uint64_scale_int (size, GST_SECOND, clock_rate);
avail = gst_adapter_available (rtppcmupay->adapter);
if (avail == 0) {
@@ -213,9 +224,8 @@ gst_rtp_pcmu_pay_handle_buffer (GstBaseRTPPayload * basepayload,
* have. */
if (gst_basertppayload_is_filled (basepayload,
packet_len, rtppcmupay->duration + duration)) {
- ret = gst_rtp_pcmu_pay_flush (rtppcmupay);
- rtppcmupay->first_ts = GST_BUFFER_TIMESTAMP (buffer);
- rtppcmupay->duration = 0;
+ /* note: first_ts and duration updated in ...pay_flush() */
+ ret = gst_rtp_pcmu_pay_flush (rtppcmupay, clock_rate);
} else {
ret = GST_FLOW_OK;
}