- better information about decoding results

This commit is contained in:
Dmytro Bogovych 2022-11-03 17:32:44 +03:00
parent 83dd8f88b7
commit 5bbdec8452
3 changed files with 30 additions and 18 deletions

View File

@ -484,9 +484,10 @@ void AudioReceiver::processDecoded(Audio::DataWindow& output, int options)
output.add(mResampledFrame, mResampledLength);
}
bool AudioReceiver::getAudio(Audio::DataWindow& output, int options, int* rate)
AudioReceiver::DecodeResult AudioReceiver::getAudio(Audio::DataWindow& output, int options, int* rate)
{
bool result = false, /*had_cng = false, */had_decode = false;
DecodeResult result = DecodeResult_Skip;
bool had_decode = false;
// Get next packet from buffer
RtpBuffer::ResultList rl;
@ -505,19 +506,19 @@ bool AudioReceiver::getAudio(Audio::DataWindow& output, int options, int* rate)
reinterpret_cast<short*>(mDecodedFrame), false);
}
else
if (mCodec && mFrameCount && !mCodecSettings.mSkipDecode)
{
// Do PLC to mDecodedFrame/mDecodedLength
if (options & DecodeOptions_SkipDecode)
mDecodedLength = 0;
else
mDecodedLength = mCodec->plc(mFrameCount, mDecodedFrame, sizeof mDecodedFrame);
}
if (mCodec && mFrameCount && !mCodecSettings.mSkipDecode)
{
// Do PLC to mDecodedFrame/mDecodedLength
if (options & DecodeOptions_SkipDecode)
mDecodedLength = 0;
else
mDecodedLength = mCodec->plc(mFrameCount, mDecodedFrame, sizeof mDecodedFrame);
}
if (mDecodedLength)
{
processDecoded(output, options);
result = true;
result = DecodeResult_Ok;
}
break;
@ -569,7 +570,7 @@ bool AudioReceiver::getAudio(Audio::DataWindow& output, int options, int* rate)
if (mDecodedLength)
processDecoded(output, options);
}
result = true;
result = DecodeResult_Ok;
}
}
@ -603,7 +604,7 @@ bool AudioReceiver::getAudio(Audio::DataWindow& output, int options, int* rate)
if (mDecodedLength)
processDecoded(output, options);
}
result = true;
result = DecodeResult_Ok;
}
else
{
@ -644,14 +645,16 @@ bool AudioReceiver::getAudio(Audio::DataWindow& output, int options, int* rate)
processDecoded(output, options);
}
}
result = mFrameCount > 0;
result = mFrameCount > 0 ? DecodeResult_Ok : DecodeResult_Skip;
// Check for bitrate counter
processStatisticsWithAmrCodec(mCodec.get());
}
else
ICELogMedia(<< "RTP packet with tail.");
{
result = DecodeResult_BadPacket;
// ICELogMedia(<< "RTP packet with tail.");
}
}
}
}

View File

@ -138,7 +138,14 @@ namespace MT
DecodeOptions_SkipDecode = 4
};
bool getAudio(Audio::DataWindow& output, int options = DecodeOptions_ResampleToMainRate, int* rate = nullptr);
enum DecodeResult
{
DecodeResult_Ok,
DecodeResult_Skip,
DecodeResult_BadPacket
};
DecodeResult getAudio(Audio::DataWindow& output, int options = DecodeOptions_ResampleToMainRate, int* rate = nullptr);
// Looks for codec by payload type
Codec* findCodec(int payloadType);

View File

@ -34,8 +34,10 @@ void SingleAudioStream::process(const std::shared_ptr<jrtplib::RTPPacket>& packe
void SingleAudioStream::copyPcmTo(Audio::DataWindow& output, int needed)
{
while (output.filled() < needed)
if (!mReceiver.getAudio(output))
{
if (mReceiver.getAudio(output) != AudioReceiver::DecodeResult_Ok)
break;
}
if (output.filled() < needed)
ICELogError(<< "Not enough data for speaker's mixer");