From e3ad8eeb37a01a952b415bcd05b6682afa5e2a8a Mon Sep 17 00:00:00 2001 From: Daniil Gentili Date: Wed, 29 Jan 2020 20:11:39 +0100 Subject: [PATCH] Save --- VoIPController.h | 1 + controller/audio/OpusDecoder.cpp | 6 ++++-- controller/net/JitterBuffer.cpp | 6 +++--- controller/protocol/Reliable.cpp | 12 ++++++------ controller/protocol/Tick.cpp | 6 ++++-- 5 files changed, 18 insertions(+), 13 deletions(-) diff --git a/VoIPController.h b/VoIPController.h index 9ff6509..ee6de0c 100755 --- a/VoIPController.h +++ b/VoIPController.h @@ -585,6 +585,7 @@ private: // Acks now handled in Ack HistoricBuffer sendLossCountHistory; + HistoricBuffer packetCountHistory; uint32_t audioTimestampIn = 0; std::shared_ptr encoder; diff --git a/controller/audio/OpusDecoder.cpp b/controller/audio/OpusDecoder.cpp index cfad975..81cb182 100755 --- a/controller/audio/OpusDecoder.cpp +++ b/controller/audio/OpusDecoder.cpp @@ -232,8 +232,8 @@ int tgvoip::OpusDecoder::DecodeNextFrame() { fec = true; len = jitterBuffer->HandleOutput(buffer, 8192, 0, false, playbackDuration, isEC); - //if(len) - // LOGV("Trying FEC..."); + /*if (len) + LOGV("Trying FEC...");*/ } int size; if (len) @@ -280,11 +280,13 @@ int tgvoip::OpusDecoder::DecodeNextFrame() remainingDataLen = size; if (playbackDuration == 80) { + //LOGW("Rescaling to 80"); processedBuffer = buffer; audio::Resampler::Rescale60To80((int16_t *)decodeBuffer, (int16_t *)processedBuffer); } else if (playbackDuration == 40) { + //LOGW("Rescaling to 40"); processedBuffer = buffer; audio::Resampler::Rescale60To40((int16_t *)decodeBuffer, (int16_t *)processedBuffer); } diff --git a/controller/net/JitterBuffer.cpp b/controller/net/JitterBuffer.cpp index ddcbec2..18be2b9 100755 --- a/controller/net/JitterBuffer.cpp +++ b/controller/net/JitterBuffer.cpp @@ -142,7 +142,7 @@ void JitterBuffer::PutInternal(jitter_packet_t *pkt, bool overwriteExisting) if (expectNextAtTime != 0) { double dev = expectNextAtTime - time; - LOGV("packet dev %f", dev); + //LOGV("packet dev %f", dev); deviationHistory.Add(dev); expectNextAtTime += step / 1000.0; } @@ -154,13 +154,13 @@ void JitterBuffer::PutInternal(jitter_packet_t *pkt, bool overwriteExisting) // Late packet check if (pkt->timestamp < nextFetchTimestamp) { - LOGW("jitter: would drop packet with timestamp %d because it is late but not hopelessly", pkt->timestamp); + //LOGW("jitter: would drop packet with timestamp %d because it is late but not hopelessly", pkt->timestamp); latePacketCount++; lostPackets--; } else if (pkt->timestamp < nextFetchTimestamp - 1) { - LOGW("jitter: dropping packet with timestamp %d because it is too late", pkt->timestamp); + //LOGW("jitter: dropping packet with timestamp %d because it is too late", pkt->timestamp); latePacketCount++; return; } diff --git a/controller/protocol/Reliable.cpp b/controller/protocol/Reliable.cpp index 5a4b02a..10e5422 100644 --- a/controller/protocol/Reliable.cpp +++ b/controller/protocol/Reliable.cpp @@ -37,17 +37,17 @@ void VoIPController::UpdateReliablePackets() { if (qp->timeout > 0 && qp->firstSentTime > 0 && GetCurrentTime() - qp->firstSentTime >= qp->timeout) { -//#ifdef LOG_PACKETS +#ifdef LOG_PACKETS LOGD("Removing queued packet because of timeout"); -//#endif +#endif qp = reliablePackets.erase(qp); continue; } if (!qp->tries--) { -//#ifdef LOG_PACKETS +#ifdef LOG_PACKETS LOGD("Removing queued packet because of no more tries"); -//#endif +#endif qp = reliablePackets.erase(qp); continue; } @@ -57,9 +57,9 @@ void VoIPController::UpdateReliablePackets() uint32_t seq = packetManager.nextLocalSeq(); qp->seqs.Add(seq); qp->lastSentTime = GetCurrentTime(); -//#ifdef LOG_PACKETS +#ifdef LOG_PACKETS LOGD("Sending reliable queued packet, seq=%u, type=%u, len=%lu", seq, qp->type, qp->data.Length()); -//#endif +#endif Buffer buf(qp->data.Length()); if (qp->firstSentTime == 0) qp->firstSentTime = qp->lastSentTime; diff --git a/controller/protocol/Tick.cpp b/controller/protocol/Tick.cpp index 1e8da6e..8e749f9 100644 --- a/controller/protocol/Tick.cpp +++ b/controller/protocol/Tick.cpp @@ -187,11 +187,13 @@ void VoIPController::UpdateCongestion() uint32_t sendLossCount = conctl.GetSendLossCount(); sendLossCountHistory.Add(sendLossCount - prevSendLossCount); prevSendLossCount = sendLossCount; + uint32_t lastSentSeq = getBestPacketManager().getLastSentSeq(); - double packetsPerSec = 1000 / (lastSentSeq - prevSeq); + packetCountHistory.Add(lastSentSeq - prevSeq); prevSeq = lastSentSeq; + //double packetsPerSec = 1000 / (double)outgoingStreams[0]->frameDuration; - double avgSendLossCount = sendLossCountHistory.Average() / packetsPerSec; + double avgSendLossCount = sendLossCountHistory.Average() / packetCountHistory.Average(); LOGE("avg send loss: %.3f%%", avgSendLossCount*100); AudioPacketSender *sender = dynamic_cast(GetStreamByType(STREAM_TYPE_AUDIO, true)->packetSender.get());