mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-03 04:52:28 +00:00
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:
parent
1adb9122d7
commit
ca00f98eb5
3 changed files with 45 additions and 14 deletions
11
ChangeLog
11
ChangeLog
|
@ -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>
|
2006-07-26 Tim-Philipp Müller <tim at centricular dot net>
|
||||||
|
|
||||||
* ext/taglib/gstid3v2mux.cc:
|
* ext/taglib/gstid3v2mux.cc:
|
||||||
|
|
|
@ -129,7 +129,7 @@ gst_rtp_pcma_pay_setcaps (GstBaseRTPPayload * payload, GstCaps * caps)
|
||||||
}
|
}
|
||||||
|
|
||||||
static GstFlowReturn
|
static GstFlowReturn
|
||||||
gst_rtp_pcma_pay_flush (GstRtpPmcaPay * rtppcmapay)
|
gst_rtp_pcma_pay_flush (GstRtpPmcaPay * rtppcmapay, guint32 clock_rate)
|
||||||
{
|
{
|
||||||
guint avail;
|
guint avail;
|
||||||
GstBuffer *outbuf;
|
GstBuffer *outbuf;
|
||||||
|
@ -141,8 +141,8 @@ gst_rtp_pcma_pay_flush (GstRtpPmcaPay * rtppcmapay)
|
||||||
/* calculate octet count with:
|
/* calculate octet count with:
|
||||||
maxptime-nsec * samples-per-sec / nsecs-per-sec * octets-per-sample */
|
maxptime-nsec * samples-per-sec / nsecs-per-sec * octets-per-sample */
|
||||||
maxptime_octets =
|
maxptime_octets =
|
||||||
GST_BASE_RTP_PAYLOAD (rtppcmapay)->max_ptime *
|
gst_util_uint64_scale_int (GST_BASE_RTP_PAYLOAD (rtppcmapay)->max_ptime,
|
||||||
GST_BASE_RTP_PAYLOAD (rtppcmapay)->clock_rate / GST_SECOND;
|
clock_rate, GST_SECOND);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* the data available in the adapter is either smaller
|
/* 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;
|
GST_BUFFER_TIMESTAMP (outbuf) = rtppcmapay->first_ts;
|
||||||
ret = gst_basertppayload_push (GST_BASE_RTP_PAYLOAD (rtppcmapay), outbuf);
|
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;
|
return ret;
|
||||||
|
@ -194,11 +202,14 @@ gst_rtp_pcma_pay_handle_buffer (GstBaseRTPPayload * basepayload,
|
||||||
guint size, packet_len, avail;
|
guint size, packet_len, avail;
|
||||||
GstFlowReturn ret;
|
GstFlowReturn ret;
|
||||||
GstClockTime duration;
|
GstClockTime duration;
|
||||||
|
guint32 clock_rate;
|
||||||
|
|
||||||
rtppcmapay = GST_RTP_PCMA_PAY (basepayload);
|
rtppcmapay = GST_RTP_PCMA_PAY (basepayload);
|
||||||
|
|
||||||
|
clock_rate = basepayload->clock_rate;
|
||||||
|
|
||||||
size = GST_BUFFER_SIZE (buffer);
|
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);
|
avail = gst_adapter_available (rtppcmapay->adapter);
|
||||||
if (avail == 0) {
|
if (avail == 0) {
|
||||||
|
@ -213,9 +224,8 @@ gst_rtp_pcma_pay_handle_buffer (GstBaseRTPPayload * basepayload,
|
||||||
* have. */
|
* have. */
|
||||||
if (gst_basertppayload_is_filled (basepayload,
|
if (gst_basertppayload_is_filled (basepayload,
|
||||||
packet_len, rtppcmapay->duration + duration)) {
|
packet_len, rtppcmapay->duration + duration)) {
|
||||||
ret = gst_rtp_pcma_pay_flush (rtppcmapay);
|
ret = gst_rtp_pcma_pay_flush (rtppcmapay, clock_rate);
|
||||||
rtppcmapay->first_ts = GST_BUFFER_TIMESTAMP (buffer);
|
/* note: first_ts and duration updated in ...pay_flush() */
|
||||||
rtppcmapay->duration = 0;
|
|
||||||
} else {
|
} else {
|
||||||
ret = GST_FLOW_OK;
|
ret = GST_FLOW_OK;
|
||||||
}
|
}
|
||||||
|
|
|
@ -129,7 +129,7 @@ gst_rtp_pcmu_pay_setcaps (GstBaseRTPPayload * payload, GstCaps * caps)
|
||||||
}
|
}
|
||||||
|
|
||||||
static GstFlowReturn
|
static GstFlowReturn
|
||||||
gst_rtp_pcmu_pay_flush (GstRtpPcmuPay * rtppcmupay)
|
gst_rtp_pcmu_pay_flush (GstRtpPcmuPay * rtppcmupay, guint32 clock_rate)
|
||||||
{
|
{
|
||||||
guint avail;
|
guint avail;
|
||||||
GstBuffer *outbuf;
|
GstBuffer *outbuf;
|
||||||
|
@ -141,8 +141,8 @@ gst_rtp_pcmu_pay_flush (GstRtpPcmuPay * rtppcmupay)
|
||||||
/* calculate octet count with:
|
/* calculate octet count with:
|
||||||
maxptime-nsec * samples-per-sec / nsecs-per-sec * octets-per-sample */
|
maxptime-nsec * samples-per-sec / nsecs-per-sec * octets-per-sample */
|
||||||
maxptime_octets =
|
maxptime_octets =
|
||||||
GST_BASE_RTP_PAYLOAD (rtppcmupay)->max_ptime *
|
gst_util_uint64_scale_int (GST_BASE_RTP_PAYLOAD (rtppcmupay)->max_ptime,
|
||||||
GST_BASE_RTP_PAYLOAD (rtppcmupay)->clock_rate / GST_SECOND;
|
clock_rate, GST_SECOND);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* the data available in the adapter is either smaller
|
/* 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;
|
GST_BUFFER_TIMESTAMP (outbuf) = rtppcmupay->first_ts;
|
||||||
ret = gst_basertppayload_push (GST_BASE_RTP_PAYLOAD (rtppcmupay), outbuf);
|
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;
|
return ret;
|
||||||
|
@ -194,11 +202,14 @@ gst_rtp_pcmu_pay_handle_buffer (GstBaseRTPPayload * basepayload,
|
||||||
guint size, packet_len, avail;
|
guint size, packet_len, avail;
|
||||||
GstFlowReturn ret;
|
GstFlowReturn ret;
|
||||||
GstClockTime duration;
|
GstClockTime duration;
|
||||||
|
guint32 clock_rate;
|
||||||
|
|
||||||
rtppcmupay = GST_RTP_PCMU_PAY (basepayload);
|
rtppcmupay = GST_RTP_PCMU_PAY (basepayload);
|
||||||
|
|
||||||
|
clock_rate = basepayload->clock_rate;
|
||||||
|
|
||||||
size = GST_BUFFER_SIZE (buffer);
|
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);
|
avail = gst_adapter_available (rtppcmupay->adapter);
|
||||||
if (avail == 0) {
|
if (avail == 0) {
|
||||||
|
@ -213,9 +224,8 @@ gst_rtp_pcmu_pay_handle_buffer (GstBaseRTPPayload * basepayload,
|
||||||
* have. */
|
* have. */
|
||||||
if (gst_basertppayload_is_filled (basepayload,
|
if (gst_basertppayload_is_filled (basepayload,
|
||||||
packet_len, rtppcmupay->duration + duration)) {
|
packet_len, rtppcmupay->duration + duration)) {
|
||||||
ret = gst_rtp_pcmu_pay_flush (rtppcmupay);
|
/* note: first_ts and duration updated in ...pay_flush() */
|
||||||
rtppcmupay->first_ts = GST_BUFFER_TIMESTAMP (buffer);
|
ret = gst_rtp_pcmu_pay_flush (rtppcmupay, clock_rate);
|
||||||
rtppcmupay->duration = 0;
|
|
||||||
} else {
|
} else {
|
||||||
ret = GST_FLOW_OK;
|
ret = GST_FLOW_OK;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue