update neteq 4 to facilitate NACK

BUG=
R=turaj@webrtc.org, turajs@google.com

Review URL: https://webrtc-codereview.appspot.com/2008004

git-svn-id: http://webrtc.googlecode.com/svn/trunk@4637 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
minyue@webrtc.org 2013-08-29 00:58:14 +00:00
parent 8ae641edfb
commit d7301775f5
3 changed files with 33 additions and 3 deletions

View File

@ -233,6 +233,10 @@ class NetEq {
int* current_memory_size_bytes,
int* max_memory_size_bytes) const = 0;
// Get sequence number and timestamp of the latest RTP.
// This method is to facilitate NACK.
virtual int DecodedRtpInfo(int* sequence_number, uint32_t* timestamp) = 0;
protected:
NetEq() {}

View File

@ -87,7 +87,9 @@ NetEqImpl::NetEqImpl(int fs,
first_packet_(true),
error_code_(0),
decoder_error_code_(0),
crit_sect_(CriticalSectionWrapper::CreateCriticalSection()) {
crit_sect_(CriticalSectionWrapper::CreateCriticalSection()),
decoded_packet_sequence_number_(-1),
decoded_packet_timestamp_(0) {
if (fs != 8000 && fs != 16000 && fs != 32000 && fs != 48000) {
LOG(LS_ERROR) << "Sample rate " << fs << " Hz not supported. " <<
"Changing to 8000 Hz.";
@ -352,6 +354,15 @@ void NetEqImpl::FlushBuffers() {
first_packet_ = true;
}
int NetEqImpl::DecodedRtpInfo(int* sequence_number, uint32_t* timestamp) {
CriticalSectionScoped lock(crit_sect_);
if (decoded_packet_sequence_number_ < 0)
return -1;
*sequence_number = decoded_packet_sequence_number_;
*timestamp = decoded_packet_timestamp_;
return 0;
}
// Methods below this line are private.
@ -1662,8 +1673,9 @@ int NetEqImpl::ExtractPackets(int required_samples, PacketList* packet_list) {
if (first_packet) {
first_packet = false;
prev_sequence_number = packet->header.sequenceNumber;
prev_timestamp = packet->header.timestamp;
decoded_packet_sequence_number_ = prev_sequence_number =
packet->header.sequenceNumber;
decoded_packet_timestamp_ = prev_timestamp = packet->header.timestamp;
prev_payload_type = packet->header.payloadType;
}

View File

@ -167,6 +167,10 @@ class NetEqImpl : public webrtc::NetEq {
int* current_memory_size_bytes,
int* max_memory_size_bytes) const;
// Get sequence number and timestamp of the latest RTP.
// This method is to facilitate NACK.
virtual int DecodedRtpInfo(int* sequence_number, uint32_t* timestamp);
private:
static const int kOutputSizeMs = 10;
static const int kMaxFrameSize = 2880; // 60 ms @ 48 kHz.
@ -318,6 +322,16 @@ class NetEqImpl : public webrtc::NetEq {
int decoder_error_code_;
CriticalSectionWrapper* crit_sect_;
// These values are used by NACK module to estimate time-to-play of
// a missing packet. Occasionally, NetEq might decide to decode more
// than one packet. Therefore, these values store sequence number and
// timestamp of the first packet pulled from the packet buffer. In
// such cases, these values do not exactly represent the sequence number
// or timestamp associated with a 10ms audio pulled from NetEq. NACK
// module is designed to compensate for this.
int decoded_packet_sequence_number_;
uint32_t decoded_packet_timestamp_;
DISALLOW_COPY_AND_ASSIGN(NetEqImpl);
};