Skip to content

Commit

Permalink
Reland (rev 7259) "Convert AcmReceiverTest to new AudioCoding interface"
Browse files Browse the repository at this point in the history
Was reverted by mistake in 7260. Actual culprit was 7258.

BUG=3520
R=henrik.lundin@webrtc.org

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

git-svn-id: http://webrtc.googlecode.com/svn/trunk@7272 4adac7df-926f-26a2-2b94-8c16560cd09d
  • Loading branch information
andresusanopinto committed Sep 23, 2014
1 parent ea29787 commit 4f6f22f
Show file tree
Hide file tree
Showing 6 changed files with 431 additions and 24 deletions.
34 changes: 15 additions & 19 deletions webrtc/modules/audio_coding/main/acm2/acm_receiver_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,10 @@ class AcmReceiverTest : public AudioPacketizationCallback,
packet_sent_(false),
last_packet_send_timestamp_(timestamp_),
last_frame_type_(kFrameEmpty) {
AudioCodingModule::Config config;
acm_.reset(new AudioCodingModuleImpl(config));
receiver_.reset(new AcmReceiver(config));
AudioCoding::Config config;
config.transport = this;
acm_.reset(new AudioCodingImpl(config));
receiver_.reset(new AcmReceiver(config.ToOldConfig()));
}

~AcmReceiverTest() {}
Expand All @@ -61,10 +62,6 @@ class AcmReceiverTest : public AudioPacketizationCallback,
ASSERT_EQ(0, ACMCodecDB::Codec(n, &codecs_[n]));
}

acm_->InitializeReceiver();
acm_->InitializeSender();
acm_->RegisterTransportCallback(this);

rtp_header_.header.sequenceNumber = 0;
rtp_header_.header.timestamp = 0;
rtp_header_.header.markerBit = false;
Expand All @@ -82,12 +79,12 @@ class AcmReceiverTest : public AudioPacketizationCallback,
CodecInst codec;
ACMCodecDB::Codec(codec_id, &codec);
if (timestamp_ == 0) { // This is the first time inserting audio.
ASSERT_EQ(0, acm_->RegisterSendCodec(codec));
ASSERT_TRUE(acm_->RegisterSendCodec(codec_id, codec.pltype));
} else {
CodecInst current_codec;
ASSERT_EQ(0, acm_->SendCodec(&current_codec));
if (!CodecsEqual(codec, current_codec))
ASSERT_EQ(0, acm_->RegisterSendCodec(codec));
const CodecInst* current_codec = acm_->GetSenderCodecInst();
ASSERT_TRUE(current_codec);
if (!CodecsEqual(codec, *current_codec))
ASSERT_TRUE(acm_->RegisterSendCodec(codec_id, codec.pltype));
}
AudioFrame frame;
// Frame setup according to the codec.
Expand All @@ -102,8 +99,7 @@ class AcmReceiverTest : public AudioPacketizationCallback,
while (num_bytes == 0) {
frame.timestamp_ = timestamp_;
timestamp_ += frame.samples_per_channel_;
ASSERT_EQ(0, acm_->Add10MsData(frame));
num_bytes = acm_->Process();
num_bytes = acm_->Add10MsAudio(frame);
ASSERT_GE(num_bytes, 0);
}
ASSERT_TRUE(packet_sent_); // Sanity check.
Expand Down Expand Up @@ -151,7 +147,7 @@ class AcmReceiverTest : public AudioPacketizationCallback,

scoped_ptr<AcmReceiver> receiver_;
CodecInst codecs_[ACMCodecDB::kMaxNumCodecs];
scoped_ptr<AudioCodingModule> acm_;
scoped_ptr<AudioCoding> acm_;
WebRtcRTPHeader rtp_header_;
uint32_t timestamp_;
bool packet_sent_; // Set when SendData is called reset when inserting audio.
Expand Down Expand Up @@ -307,7 +303,7 @@ TEST_F(AcmReceiverTest, DISABLED_ON_ANDROID(LastAudioCodec)) {
// Register CNG at sender side.
int n = 0;
while (kCngId[n] > 0) {
ASSERT_EQ(0, acm_->RegisterSendCodec(codecs_[kCngId[n]]));
ASSERT_TRUE(acm_->RegisterSendCodec(kCngId[n], codecs_[kCngId[n]].pltype));
++n;
}

Expand All @@ -316,7 +312,7 @@ TEST_F(AcmReceiverTest, DISABLED_ON_ANDROID(LastAudioCodec)) {
EXPECT_EQ(-1, receiver_->LastAudioCodec(&codec));

// Start with sending DTX.
ASSERT_EQ(0, acm_->SetVAD(true, true, VADVeryAggr));
ASSERT_TRUE(acm_->SetVad(true, true, VADVeryAggr));
packet_sent_ = false;
InsertOnePacketOfSilence(kCodecId[0]); // Enough to test with one codec.
ASSERT_TRUE(packet_sent_);
Expand All @@ -330,7 +326,7 @@ TEST_F(AcmReceiverTest, DISABLED_ON_ANDROID(LastAudioCodec)) {
n = 0;
while (kCodecId[n] >= 0) { // Loop over codecs.
// Set DTX off to send audio payload.
acm_->SetVAD(false, false, VADAggr);
acm_->SetVad(false, false, VADAggr);
packet_sent_ = false;
InsertOnePacketOfSilence(kCodecId[n]);

Expand All @@ -342,7 +338,7 @@ TEST_F(AcmReceiverTest, DISABLED_ON_ANDROID(LastAudioCodec)) {

// Set VAD on to send DTX. Then check if the "Last Audio codec" returns
// the expected codec.
acm_->SetVAD(true, true, VADAggr);
acm_->SetVad(true, true, VADAggr);

// Do as many encoding until a DTX is sent.
while (last_frame_type_ != kAudioFrameCN) {
Expand Down
Loading

0 comments on commit 4f6f22f

Please sign in to comment.