support for lost packets

This commit is contained in:
Brad Hefta-Gaub 2016-07-11 15:18:02 -07:00
parent 125aa6b337
commit ceffa219b3
2 changed files with 6 additions and 3 deletions

View file

@ -172,7 +172,7 @@ int InboundAudioStream::parseStreamProperties(PacketType type, const QByteArray&
return sizeof(quint16);
} else {
// mixed audio packets do not have any info between the seq num and the audio data.
numAudioSamples = packetAfterSeqNum.size() / sizeof(int16_t);
numAudioSamples = AudioConstants::NETWORK_FRAME_SAMPLES_PER_CHANNEL;
return 0;
}
}
@ -189,6 +189,10 @@ int InboundAudioStream::parseAudioData(PacketType type, const QByteArray& packet
}
int InboundAudioStream::writeDroppableSilentSamples(int silentSamples) {
if (_decoder) {
_decoder->trackLostFrames(silentSamples);
}
// calculate how many silent frames we should drop.
int samplesPerFrame = _ringBuffer.getNumFrameSamples();
int desiredJitterBufferFramesPlusPadding = _desiredJitterBufferFrames + DESIRED_JITTER_BUFFER_FRAMES_PADDING;

View file

@ -43,7 +43,6 @@ bool HiFiCodec::isSupported() const {
class HiFiEncoder : public Encoder, public AudioEncoder {
public:
HiFiEncoder(int sampleRate, int numChannels) : AudioEncoder(sampleRate, numChannels) {
qDebug() << __FUNCTION__ << "sampleRate:" << sampleRate << "numChannels:" << numChannels;
_encodedSize = (AudioConstants::NETWORK_FRAME_SAMPLES_PER_CHANNEL * sizeof(int16_t) * numChannels) / 4; // codec reduces by 1/4th
}
@ -58,7 +57,6 @@ private:
class HiFiDecoder : public Decoder, public AudioDecoder {
public:
HiFiDecoder(int sampleRate, int numChannels) : AudioDecoder(sampleRate, numChannels) {
qDebug() << __FUNCTION__ << "sampleRate:" << sampleRate << "numChannels:" << numChannels;
_decodedSize = AudioConstants::NETWORK_FRAME_SAMPLES_PER_CHANNEL * sizeof(int16_t) * numChannels;
}
@ -71,6 +69,7 @@ public:
QByteArray encodedBuffer;
QByteArray decodedBuffer;
decodedBuffer.resize(_decodedSize);
// NOTE: we don't actually use the results of this decode, we just do it to keep the state of the codec clean
AudioDecoder::process((const int16_t*)encodedBuffer.constData(), (int16_t*)decodedBuffer.data(), AudioConstants::NETWORK_FRAME_SAMPLES_PER_CHANNEL, false);
}
private: