1
0
mirror of https://github.com/danog/libtgvoip.git synced 2024-11-26 20:24:38 +01:00
This commit is contained in:
Daniil Gentili 2020-01-29 20:11:39 +01:00
parent b6224112f0
commit e3ad8eeb37
Signed by: danog
GPG Key ID: 8C1BE3B34B230CA7
5 changed files with 18 additions and 13 deletions

View File

@ -585,6 +585,7 @@ private:
// Acks now handled in Ack
HistoricBuffer<uint32_t, 10, double> sendLossCountHistory;
HistoricBuffer<uint32_t, 10, double> packetCountHistory;
uint32_t audioTimestampIn = 0;
std::shared_ptr<OpusEncoder> encoder;

View File

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

View File

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

View File

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

View File

@ -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<AudioPacketSender *>(GetStreamByType(STREAM_TYPE_AUDIO, true)->packetSender.get());