mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-26 00:58:12 +00:00
celtpay: fix queue duration calculations
Don't blindly add the durations of incomming buffers to the total queued duration because it might be invalid. Mark the total queued duration invalid when we receive an invalid incomming timestamp because that's when we lose track of the total queued duration. Fixes #618324
This commit is contained in:
parent
4cff2e2c67
commit
3e4bc043a5
1 changed files with 15 additions and 3 deletions
|
@ -141,7 +141,16 @@ gst_rtp_celt_pay_add_queued (GstRtpCELTPay * rtpceltpay, GstBuffer * buffer,
|
|||
g_queue_push_tail (rtpceltpay->queue, buffer);
|
||||
rtpceltpay->sbytes += ssize;
|
||||
rtpceltpay->bytes += size;
|
||||
rtpceltpay->qduration += duration;
|
||||
/* only add durations when we have a valid previous duration */
|
||||
if (rtpceltpay->qduration != -1) {
|
||||
if (duration != -1)
|
||||
/* only add valid durations */
|
||||
rtpceltpay->qduration += duration;
|
||||
else
|
||||
/* if we add a buffer without valid duration, our total queued duration
|
||||
* becomes unknown */
|
||||
rtpceltpay->qduration = -1;
|
||||
}
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
@ -396,9 +405,12 @@ gst_rtp_celt_pay_handle_buffer (GstBaseRTPPayload * basepayload,
|
|||
|
||||
GST_DEBUG_OBJECT (rtpceltpay, "bytes for size %u", ssize);
|
||||
|
||||
/* calculate the size and duration of the packet */
|
||||
/* calculate what the new size and duration would be of the packet */
|
||||
payload_len = ssize + size + rtpceltpay->bytes + rtpceltpay->sbytes;
|
||||
packet_dur = rtpceltpay->qduration + duration;
|
||||
if (rtpceltpay->qduration != -1 && duration != -1)
|
||||
packet_dur = rtpceltpay->qduration + duration;
|
||||
else
|
||||
packet_dur = 0;
|
||||
|
||||
packet_len = gst_rtp_buffer_calc_packet_len (payload_len, 0, 0);
|
||||
|
||||
|
|
Loading…
Reference in a new issue