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.
This commit is contained in:
Kai Vehmanen 2006-07-26 16:36:59 +00:00 committed by Wim Taymans
parent 1adb9122d7
commit ca00f98eb5
3 changed files with 45 additions and 14 deletions

View file

@ -1,3 +1,14 @@
2006-07-26 Wim Taymans <wim@fluendo.com>
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.
2006-07-26 Tim-Philipp Müller <tim at centricular dot net>
* ext/taglib/gstid3v2mux.cc:

View file

@ -129,7 +129,7 @@ gst_rtp_pcma_pay_setcaps (GstBaseRTPPayload * payload, GstCaps * caps)
}
static GstFlowReturn
gst_rtp_pcma_pay_flush (GstRtpPmcaPay * rtppcmapay)
gst_rtp_pcma_pay_flush (GstRtpPmcaPay * rtppcmapay, guint32 clock_rate)
{
guint avail;
GstBuffer *outbuf;
@ -141,8 +141,8 @@ gst_rtp_pcma_pay_flush (GstRtpPmcaPay * rtppcmapay)
/* calculate octet count with:
maxptime-nsec * samples-per-sec / nsecs-per-sec * octets-per-sample */
maxptime_octets =
GST_BASE_RTP_PAYLOAD (rtppcmapay)->max_ptime *
GST_BASE_RTP_PAYLOAD (rtppcmapay)->clock_rate / GST_SECOND;
gst_util_uint64_scale_int (GST_BASE_RTP_PAYLOAD (rtppcmapay)->max_ptime,
clock_rate, GST_SECOND);
}
/* the data available in the adapter is either smaller
@ -181,6 +181,14 @@ gst_rtp_pcma_pay_flush (GstRtpPmcaPay * rtppcmapay)
GST_BUFFER_TIMESTAMP (outbuf) = rtppcmapay->first_ts;
ret = gst_basertppayload_push (GST_BASE_RTP_PAYLOAD (rtppcmapay), outbuf);
/* increase count (in ts) of data pushed to basertppayload */
rtppcmapay->first_ts +=
gst_util_uint64_scale_int (payload_len, GST_SECOND, clock_rate);
/* store amount of unpushed data (in ts) */
rtppcmapay->duration =
gst_util_uint64_scale_int (avail, GST_SECOND, clock_rate);
}
return ret;
@ -194,11 +202,14 @@ gst_rtp_pcma_pay_handle_buffer (GstBaseRTPPayload * basepayload,
guint size, packet_len, avail;
GstFlowReturn ret;
GstClockTime duration;
guint32 clock_rate;
rtppcmapay = GST_RTP_PCMA_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 (rtppcmapay->adapter);
if (avail == 0) {
@ -213,9 +224,8 @@ gst_rtp_pcma_pay_handle_buffer (GstBaseRTPPayload * basepayload,
* have. */
if (gst_basertppayload_is_filled (basepayload,
packet_len, rtppcmapay->duration + duration)) {
ret = gst_rtp_pcma_pay_flush (rtppcmapay);
rtppcmapay->first_ts = GST_BUFFER_TIMESTAMP (buffer);
rtppcmapay->duration = 0;
ret = gst_rtp_pcma_pay_flush (rtppcmapay, clock_rate);
/* note: first_ts and duration updated in ...pay_flush() */
} else {
ret = GST_FLOW_OK;
}

View file

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