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

Side by Side Diff: webrtc/modules/audio_coding/main/acm2/audio_coding_module_unittest_oldapi.cc

Issue 1371043003: Unify FrameType and VideoFrameType. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: rebase Created 5 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) 2014 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2014 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 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 85
86 private: 86 private:
87 int samples_per_packet_; 87 int samples_per_packet_;
88 uint8_t payload_type_; 88 uint8_t payload_type_;
89 }; 89 };
90 90
91 class PacketizationCallbackStubOldApi : public AudioPacketizationCallback { 91 class PacketizationCallbackStubOldApi : public AudioPacketizationCallback {
92 public: 92 public:
93 PacketizationCallbackStubOldApi() 93 PacketizationCallbackStubOldApi()
94 : num_calls_(0), 94 : num_calls_(0),
95 last_frame_type_(kFrameEmpty), 95 last_frame_type_(kEmptyFrame),
96 last_payload_type_(-1), 96 last_payload_type_(-1),
97 last_timestamp_(0), 97 last_timestamp_(0),
98 crit_sect_(CriticalSectionWrapper::CreateCriticalSection()) {} 98 crit_sect_(CriticalSectionWrapper::CreateCriticalSection()) {}
99 99
100 int32_t SendData(FrameType frame_type, 100 int32_t SendData(FrameType frame_type,
101 uint8_t payload_type, 101 uint8_t payload_type,
102 uint32_t timestamp, 102 uint32_t timestamp,
103 const uint8_t* payload_data, 103 const uint8_t* payload_data,
104 size_t payload_len_bytes, 104 size_t payload_len_bytes,
105 const RTPFragmentationHeader* fragmentation) override { 105 const RTPFragmentationHeader* fragmentation) override {
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after
409 void DoTest(int blocks_per_packet, int cng_pt) { 409 void DoTest(int blocks_per_packet, int cng_pt) {
410 const int kLoops = 40; 410 const int kLoops = 40;
411 // This array defines the expected frame types, and when they should arrive. 411 // This array defines the expected frame types, and when they should arrive.
412 // We expect a frame to arrive each time the speech encoder would have 412 // We expect a frame to arrive each time the speech encoder would have
413 // produced a packet, and once every 100 ms the frame should be non-empty, 413 // produced a packet, and once every 100 ms the frame should be non-empty,
414 // that is contain comfort noise. 414 // that is contain comfort noise.
415 const struct { 415 const struct {
416 int ix; 416 int ix;
417 FrameType type; 417 FrameType type;
418 } expectation[] = {{2, kAudioFrameCN}, 418 } expectation[] = {{2, kAudioFrameCN},
419 {5, kFrameEmpty}, 419 {5, kEmptyFrame},
420 {8, kFrameEmpty}, 420 {8, kEmptyFrame},
421 {11, kAudioFrameCN}, 421 {11, kAudioFrameCN},
422 {14, kFrameEmpty}, 422 {14, kEmptyFrame},
423 {17, kFrameEmpty}, 423 {17, kEmptyFrame},
424 {20, kAudioFrameCN}, 424 {20, kAudioFrameCN},
425 {23, kFrameEmpty}, 425 {23, kEmptyFrame},
426 {26, kFrameEmpty}, 426 {26, kEmptyFrame},
427 {29, kFrameEmpty}, 427 {29, kEmptyFrame},
428 {32, kAudioFrameCN}, 428 {32, kAudioFrameCN},
429 {35, kFrameEmpty}, 429 {35, kEmptyFrame},
430 {38, kFrameEmpty}}; 430 {38, kEmptyFrame}};
431 for (int i = 0; i < kLoops; ++i) { 431 for (int i = 0; i < kLoops; ++i) {
432 int num_calls_before = packet_cb_.num_calls(); 432 int num_calls_before = packet_cb_.num_calls();
433 EXPECT_EQ(i / blocks_per_packet, num_calls_before); 433 EXPECT_EQ(i / blocks_per_packet, num_calls_before);
434 InsertAudioAndVerifyEncoding(); 434 InsertAudioAndVerifyEncoding();
435 int num_calls = packet_cb_.num_calls(); 435 int num_calls = packet_cb_.num_calls();
436 if (num_calls == num_calls_before + 1) { 436 if (num_calls == num_calls_before + 1) {
437 EXPECT_EQ(expectation[num_calls - 1].ix, i); 437 EXPECT_EQ(expectation[num_calls - 1].ix, i);
438 EXPECT_EQ(expectation[num_calls - 1].type, packet_cb_.last_frame_type()) 438 EXPECT_EQ(expectation[num_calls - 1].type, packet_cb_.last_frame_type())
439 << "Wrong frame type for lap " << i; 439 << "Wrong frame type for lap " << i;
440 EXPECT_EQ(cng_pt, packet_cb_.last_payload_type()); 440 EXPECT_EQ(cng_pt, packet_cb_.last_payload_type());
441 } else { 441 } else {
442 EXPECT_EQ(num_calls, num_calls_before); 442 EXPECT_EQ(num_calls, num_calls_before);
443 } 443 }
444 } 444 }
445 } 445 }
446 }; 446 };
447 447
448 // Checks that the transport callback is invoked once per frame period of the 448 // Checks that the transport callback is invoked once per frame period of the
449 // underlying speech encoder, even when comfort noise is produced. 449 // underlying speech encoder, even when comfort noise is produced.
450 // Also checks that the frame type is kAudioFrameCN or kFrameEmpty. 450 // Also checks that the frame type is kAudioFrameCN or kEmptyFrame.
451 // This test and the next check the same thing, but differ in the order of 451 // This test and the next check the same thing, but differ in the order of
452 // speech codec and CNG registration. 452 // speech codec and CNG registration.
453 TEST_F(AudioCodingModuleTestWithComfortNoiseOldApi, 453 TEST_F(AudioCodingModuleTestWithComfortNoiseOldApi,
454 TransportCallbackTestForComfortNoiseRegisterCngLast) { 454 TransportCallbackTestForComfortNoiseRegisterCngLast) {
455 const int k10MsBlocksPerPacket = 3; 455 const int k10MsBlocksPerPacket = 3;
456 codec_.pacsize = k10MsBlocksPerPacket * kSampleRateHz / 100; 456 codec_.pacsize = k10MsBlocksPerPacket * kSampleRateHz / 100;
457 RegisterCodec(); 457 RegisterCodec();
458 const int kCngPayloadType = 105; 458 const int kCngPayloadType = 105;
459 RegisterCngCodec(kCngPayloadType); 459 RegisterCngCodec(kCngPayloadType);
460 ASSERT_EQ(0, acm_->SetVAD(true, true)); 460 ASSERT_EQ(0, acm_->SetVAD(true, true));
(...skipping 1322 matching lines...) Expand 10 before | Expand all | Expand 10 after
1783 Run(16000, 8000, 1000); 1783 Run(16000, 8000, 1000);
1784 } 1784 }
1785 1785
1786 TEST_F(AcmSwitchingOutputFrequencyOldApi, Toggle8KhzTo16Khz) { 1786 TEST_F(AcmSwitchingOutputFrequencyOldApi, Toggle8KhzTo16Khz) {
1787 Run(8000, 16000, 1000); 1787 Run(8000, 16000, 1000);
1788 } 1788 }
1789 1789
1790 #endif 1790 #endif
1791 1791
1792 } // namespace webrtc 1792 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/audio_coding/main/acm2/audio_coding_module_impl.cc ('k') | webrtc/modules/audio_coding/main/test/Channel.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698