Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(97)

Side by Side Diff: webrtc/modules/audio_coding/neteq/packet_buffer_unittest.cc

Issue 2355503002: Stopped using the NetEqDecoder enum internally in NetEq. (Closed)
Patch Set: Clarified comments. Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 const int payload_len = 10; 167 const int payload_len = 10;
168 168
169 // Insert 10 small packets. 169 // Insert 10 small packets.
170 for (int i = 0; i < 10; ++i) { 170 for (int i = 0; i < 10; ++i) {
171 Packet* packet = gen.NextPacket(payload_len); 171 Packet* packet = gen.NextPacket(payload_len);
172 list.push_back(packet); 172 list.push_back(packet);
173 } 173 }
174 174
175 MockDecoderDatabase decoder_database; 175 MockDecoderDatabase decoder_database;
176 auto factory = CreateBuiltinAudioDecoderFactory(); 176 auto factory = CreateBuiltinAudioDecoderFactory();
177 const DecoderDatabase::DecoderInfo info(NetEqDecoder::kDecoderPCMu, "", 177 const DecoderDatabase::DecoderInfo info(NetEqDecoder::kDecoderPCMu, factory);
178 factory);
179 EXPECT_CALL(decoder_database, GetDecoderInfo(0)) 178 EXPECT_CALL(decoder_database, GetDecoderInfo(0))
180 .WillRepeatedly(Return(&info)); 179 .WillRepeatedly(Return(&info));
181 rtc::Optional<uint8_t> current_pt; 180 rtc::Optional<uint8_t> current_pt;
182 rtc::Optional<uint8_t> current_cng_pt; 181 rtc::Optional<uint8_t> current_cng_pt;
183 EXPECT_EQ(PacketBuffer::kOK, buffer.InsertPacketList(&list, 182 EXPECT_EQ(PacketBuffer::kOK, buffer.InsertPacketList(&list,
184 decoder_database, 183 decoder_database,
185 &current_pt, 184 &current_pt,
186 &current_cng_pt)); 185 &current_cng_pt));
187 EXPECT_TRUE(list.empty()); // The PacketBuffer should have depleted the list. 186 EXPECT_TRUE(list.empty()); // The PacketBuffer should have depleted the list.
188 EXPECT_EQ(10u, buffer.NumPacketsInBuffer()); 187 EXPECT_EQ(10u, buffer.NumPacketsInBuffer());
(...skipping 22 matching lines...) Expand all
211 list.push_back(packet); 210 list.push_back(packet);
212 } 211 }
213 // Insert 11th packet of another payload type (not CNG). 212 // Insert 11th packet of another payload type (not CNG).
214 Packet* packet = gen.NextPacket(payload_len); 213 Packet* packet = gen.NextPacket(payload_len);
215 packet->header.payloadType = 1; 214 packet->header.payloadType = 1;
216 list.push_back(packet); 215 list.push_back(packet);
217 216
218 217
219 MockDecoderDatabase decoder_database; 218 MockDecoderDatabase decoder_database;
220 auto factory = CreateBuiltinAudioDecoderFactory(); 219 auto factory = CreateBuiltinAudioDecoderFactory();
221 const DecoderDatabase::DecoderInfo info0(NetEqDecoder::kDecoderPCMu, "", 220 const DecoderDatabase::DecoderInfo info0(NetEqDecoder::kDecoderPCMu, factory);
222 factory);
223 EXPECT_CALL(decoder_database, GetDecoderInfo(0)) 221 EXPECT_CALL(decoder_database, GetDecoderInfo(0))
224 .WillRepeatedly(Return(&info0)); 222 .WillRepeatedly(Return(&info0));
225 const DecoderDatabase::DecoderInfo info1(NetEqDecoder::kDecoderPCMa, "", 223 const DecoderDatabase::DecoderInfo info1(NetEqDecoder::kDecoderPCMa, factory);
226 factory);
227 EXPECT_CALL(decoder_database, GetDecoderInfo(1)) 224 EXPECT_CALL(decoder_database, GetDecoderInfo(1))
228 .WillRepeatedly(Return(&info1)); 225 .WillRepeatedly(Return(&info1));
229 rtc::Optional<uint8_t> current_pt; 226 rtc::Optional<uint8_t> current_pt;
230 rtc::Optional<uint8_t> current_cng_pt; 227 rtc::Optional<uint8_t> current_cng_pt;
231 EXPECT_EQ(PacketBuffer::kFlushed, buffer.InsertPacketList(&list, 228 EXPECT_EQ(PacketBuffer::kFlushed, buffer.InsertPacketList(&list,
232 decoder_database, 229 decoder_database,
233 &current_pt, 230 &current_pt,
234 &current_cng_pt)); 231 &current_cng_pt));
235 EXPECT_TRUE(list.empty()); // The PacketBuffer should have depleted the list. 232 EXPECT_TRUE(list.empty()); // The PacketBuffer should have depleted the list.
236 EXPECT_EQ(1u, buffer.NumPacketsInBuffer()); // Only the last packet. 233 EXPECT_EQ(1u, buffer.NumPacketsInBuffer()); // Only the last packet.
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 Packet* packet = gen.NextPacket(payload_len); 346 Packet* packet = gen.NextPacket(payload_len);
350 if (i % 2) { 347 if (i % 2) {
351 list.push_front(packet); 348 list.push_front(packet);
352 } else { 349 } else {
353 list.push_back(packet); 350 list.push_back(packet);
354 } 351 }
355 } 352 }
356 353
357 MockDecoderDatabase decoder_database; 354 MockDecoderDatabase decoder_database;
358 auto factory = CreateBuiltinAudioDecoderFactory(); 355 auto factory = CreateBuiltinAudioDecoderFactory();
359 const DecoderDatabase::DecoderInfo info(NetEqDecoder::kDecoderPCMu, "", 356 const DecoderDatabase::DecoderInfo info(NetEqDecoder::kDecoderPCMu, factory);
360 factory);
361 EXPECT_CALL(decoder_database, GetDecoderInfo(0)) 357 EXPECT_CALL(decoder_database, GetDecoderInfo(0))
362 .WillRepeatedly(Return(&info)); 358 .WillRepeatedly(Return(&info));
363 rtc::Optional<uint8_t> current_pt; 359 rtc::Optional<uint8_t> current_pt;
364 rtc::Optional<uint8_t> current_cng_pt; 360 rtc::Optional<uint8_t> current_cng_pt;
365 361
366 EXPECT_EQ(PacketBuffer::kOK, buffer.InsertPacketList(&list, 362 EXPECT_EQ(PacketBuffer::kOK, buffer.InsertPacketList(&list,
367 decoder_database, 363 decoder_database,
368 &current_pt, 364 &current_pt,
369 &current_cng_pt)); 365 &current_cng_pt));
370 EXPECT_EQ(10u, buffer.NumPacketsInBuffer()); 366 EXPECT_EQ(10u, buffer.NumPacketsInBuffer());
(...skipping 18 matching lines...) Expand all
389 // and flush out the CNG packet. 385 // and flush out the CNG packet.
390 TEST(PacketBuffer, CngFirstThenSpeechWithNewSampleRate) { 386 TEST(PacketBuffer, CngFirstThenSpeechWithNewSampleRate) {
391 TickTimer tick_timer; 387 TickTimer tick_timer;
392 PacketBuffer buffer(10, &tick_timer); // 10 packets. 388 PacketBuffer buffer(10, &tick_timer); // 10 packets.
393 const uint8_t kCngPt = 13; 389 const uint8_t kCngPt = 13;
394 const int kPayloadLen = 10; 390 const int kPayloadLen = 10;
395 const uint8_t kSpeechPt = 100; 391 const uint8_t kSpeechPt = 100;
396 392
397 MockDecoderDatabase decoder_database; 393 MockDecoderDatabase decoder_database;
398 auto factory = CreateBuiltinAudioDecoderFactory(); 394 auto factory = CreateBuiltinAudioDecoderFactory();
399 const DecoderDatabase::DecoderInfo info_cng(NetEqDecoder::kDecoderCNGnb, "", 395 const DecoderDatabase::DecoderInfo info_cng(NetEqDecoder::kDecoderCNGnb,
400 factory); 396 factory);
401 EXPECT_CALL(decoder_database, GetDecoderInfo(kCngPt)) 397 EXPECT_CALL(decoder_database, GetDecoderInfo(kCngPt))
402 .WillRepeatedly(Return(&info_cng)); 398 .WillRepeatedly(Return(&info_cng));
403 const DecoderDatabase::DecoderInfo info_speech(NetEqDecoder::kDecoderPCM16Bwb, 399 const DecoderDatabase::DecoderInfo info_speech(NetEqDecoder::kDecoderPCM16Bwb,
404 "", factory); 400 factory);
405 EXPECT_CALL(decoder_database, GetDecoderInfo(kSpeechPt)) 401 EXPECT_CALL(decoder_database, GetDecoderInfo(kSpeechPt))
406 .WillRepeatedly(Return(&info_speech)); 402 .WillRepeatedly(Return(&info_speech));
407 403
408 // Insert first packet, which is narrow-band CNG. 404 // Insert first packet, which is narrow-band CNG.
409 PacketGenerator gen(0, 0, kCngPt, 10); 405 PacketGenerator gen(0, 0, kCngPt, 10);
410 PacketList list; 406 PacketList list;
411 list.push_back(gen.NextPacket(kPayloadLen)); 407 list.push_back(gen.NextPacket(kPayloadLen));
412 rtc::Optional<uint8_t> current_pt; 408 rtc::Optional<uint8_t> current_pt;
413 rtc::Optional<uint8_t> current_cng_pt; 409 rtc::Optional<uint8_t> current_cng_pt;
414 EXPECT_EQ(PacketBuffer::kOK, 410 EXPECT_EQ(PacketBuffer::kOK,
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
483 // discarded. 479 // discarded.
484 buffer = new PacketBuffer(100, &tick_timer); // 100 packets. 480 buffer = new PacketBuffer(100, &tick_timer); // 100 packets.
485 PacketList list; 481 PacketList list;
486 list.push_back(gen.NextPacket(payload_len)); // Valid packet. 482 list.push_back(gen.NextPacket(payload_len)); // Valid packet.
487 packet = gen.NextPacket(payload_len); 483 packet = gen.NextPacket(payload_len);
488 packet->payload.Clear(); // Invalid. 484 packet->payload.Clear(); // Invalid.
489 list.push_back(packet); 485 list.push_back(packet);
490 list.push_back(gen.NextPacket(payload_len)); // Valid packet. 486 list.push_back(gen.NextPacket(payload_len)); // Valid packet.
491 MockDecoderDatabase decoder_database; 487 MockDecoderDatabase decoder_database;
492 auto factory = CreateBuiltinAudioDecoderFactory(); 488 auto factory = CreateBuiltinAudioDecoderFactory();
493 const DecoderDatabase::DecoderInfo info(NetEqDecoder::kDecoderPCMu, "", 489 const DecoderDatabase::DecoderInfo info(NetEqDecoder::kDecoderPCMu, factory);
494 factory);
495 EXPECT_CALL(decoder_database, GetDecoderInfo(0)) 490 EXPECT_CALL(decoder_database, GetDecoderInfo(0))
496 .WillRepeatedly(Return(&info)); 491 .WillRepeatedly(Return(&info));
497 rtc::Optional<uint8_t> current_pt; 492 rtc::Optional<uint8_t> current_pt;
498 rtc::Optional<uint8_t> current_cng_pt; 493 rtc::Optional<uint8_t> current_cng_pt;
499 EXPECT_EQ(PacketBuffer::kInvalidPacket, 494 EXPECT_EQ(PacketBuffer::kInvalidPacket,
500 buffer->InsertPacketList(&list, 495 buffer->InsertPacketList(&list,
501 decoder_database, 496 decoder_database,
502 &current_pt, 497 &current_pt,
503 &current_cng_pt)); 498 &current_cng_pt));
504 EXPECT_TRUE(list.empty()); // The PacketBuffer should have depleted the list. 499 EXPECT_TRUE(list.empty()); // The PacketBuffer should have depleted the list.
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
690 // Test the IsObsoleteTimestamp method with different limit timestamps. 685 // Test the IsObsoleteTimestamp method with different limit timestamps.
691 TEST(PacketBuffer, IsObsoleteTimestamp) { 686 TEST(PacketBuffer, IsObsoleteTimestamp) {
692 TestIsObsoleteTimestamp(0); 687 TestIsObsoleteTimestamp(0);
693 TestIsObsoleteTimestamp(1); 688 TestIsObsoleteTimestamp(1);
694 TestIsObsoleteTimestamp(0xFFFFFFFF); // -1 in uint32_t. 689 TestIsObsoleteTimestamp(0xFFFFFFFF); // -1 in uint32_t.
695 TestIsObsoleteTimestamp(0x80000000); // 2^31. 690 TestIsObsoleteTimestamp(0x80000000); // 2^31.
696 TestIsObsoleteTimestamp(0x80000001); // 2^31 + 1. 691 TestIsObsoleteTimestamp(0x80000001); // 2^31 + 1.
697 TestIsObsoleteTimestamp(0x7FFFFFFF); // 2^31 - 1. 692 TestIsObsoleteTimestamp(0x7FFFFFFF); // 2^31 - 1.
698 } 693 }
699 } // namespace webrtc 694 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/audio_coding/neteq/neteq_impl_unittest.cc ('k') | webrtc/modules/audio_coding/neteq/timestamp_scaler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698