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

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: 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_(kSkipFrame),
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 295 matching lines...) Expand 10 before | Expand all | Expand 10 after
401 401
402 void DoTest(int blocks_per_packet, int cng_pt) { 402 void DoTest(int blocks_per_packet, int cng_pt) {
403 const int kLoops = 40; 403 const int kLoops = 40;
404 // This array defines the expected frame types, and when they should arrive. 404 // This array defines the expected frame types, and when they should arrive.
405 // We expect a frame to arrive each time the speech encoder would have 405 // We expect a frame to arrive each time the speech encoder would have
406 // produced a packet, and once every 100 ms the frame should be non-empty, 406 // produced a packet, and once every 100 ms the frame should be non-empty,
407 // that is contain comfort noise. 407 // that is contain comfort noise.
408 const struct { 408 const struct {
409 int ix; 409 int ix;
410 FrameType type; 410 FrameType type;
411 } expectation[] = {{2, kAudioFrameCN}, 411 } expectation[] = {
hlundin-webrtc 2015/10/01 08:54:04 I'd rather you didn't reformat this.
pbos-webrtc 2015/10/06 15:42:45 Done. But clang-format is awesome. :(
412 {5, kFrameEmpty}, 412 {2, kAudioFrameCN}, {5, kSkipFrame}, {8, kSkipFrame},
413 {8, kFrameEmpty}, 413 {11, kAudioFrameCN}, {14, kSkipFrame}, {17, kSkipFrame},
414 {11, kAudioFrameCN}, 414 {20, kAudioFrameCN}, {23, kSkipFrame}, {26, kSkipFrame},
415 {14, kFrameEmpty}, 415 {29, kSkipFrame}, {32, kAudioFrameCN}, {35, kSkipFrame},
416 {17, kFrameEmpty}, 416 {38, kSkipFrame}};
417 {20, kAudioFrameCN},
418 {23, kFrameEmpty},
419 {26, kFrameEmpty},
420 {29, kFrameEmpty},
421 {32, kAudioFrameCN},
422 {35, kFrameEmpty},
423 {38, kFrameEmpty}};
424 for (int i = 0; i < kLoops; ++i) { 417 for (int i = 0; i < kLoops; ++i) {
425 int num_calls_before = packet_cb_.num_calls(); 418 int num_calls_before = packet_cb_.num_calls();
426 EXPECT_EQ(i / blocks_per_packet, num_calls_before); 419 EXPECT_EQ(i / blocks_per_packet, num_calls_before);
427 InsertAudioAndVerifyEncoding(); 420 InsertAudioAndVerifyEncoding();
428 int num_calls = packet_cb_.num_calls(); 421 int num_calls = packet_cb_.num_calls();
429 if (num_calls == num_calls_before + 1) { 422 if (num_calls == num_calls_before + 1) {
430 EXPECT_EQ(expectation[num_calls - 1].ix, i); 423 EXPECT_EQ(expectation[num_calls - 1].ix, i);
431 EXPECT_EQ(expectation[num_calls - 1].type, packet_cb_.last_frame_type()) 424 EXPECT_EQ(expectation[num_calls - 1].type, packet_cb_.last_frame_type())
432 << "Wrong frame type for lap " << i; 425 << "Wrong frame type for lap " << i;
433 EXPECT_EQ(cng_pt, packet_cb_.last_payload_type()); 426 EXPECT_EQ(cng_pt, packet_cb_.last_payload_type());
434 } else { 427 } else {
435 EXPECT_EQ(num_calls, num_calls_before); 428 EXPECT_EQ(num_calls, num_calls_before);
436 } 429 }
437 } 430 }
438 } 431 }
439 }; 432 };
440 433
441 // Checks that the transport callback is invoked once per frame period of the 434 // Checks that the transport callback is invoked once per frame period of the
442 // underlying speech encoder, even when comfort noise is produced. 435 // underlying speech encoder, even when comfort noise is produced.
443 // Also checks that the frame type is kAudioFrameCN or kFrameEmpty. 436 // Also checks that the frame type is kAudioFrameCN or kSkipFrame.
444 // This test and the next check the same thing, but differ in the order of 437 // This test and the next check the same thing, but differ in the order of
445 // speech codec and CNG registration. 438 // speech codec and CNG registration.
446 TEST_F(AudioCodingModuleTestWithComfortNoiseOldApi, 439 TEST_F(AudioCodingModuleTestWithComfortNoiseOldApi,
447 TransportCallbackTestForComfortNoiseRegisterCngLast) { 440 TransportCallbackTestForComfortNoiseRegisterCngLast) {
448 const int k10MsBlocksPerPacket = 3; 441 const int k10MsBlocksPerPacket = 3;
449 codec_.pacsize = k10MsBlocksPerPacket * kSampleRateHz / 100; 442 codec_.pacsize = k10MsBlocksPerPacket * kSampleRateHz / 100;
450 RegisterCodec(); 443 RegisterCodec();
451 const int kCngPayloadType = 105; 444 const int kCngPayloadType = 105;
452 RegisterCngCodec(kCngPayloadType); 445 RegisterCngCodec(kCngPayloadType);
453 ASSERT_EQ(0, acm_->SetVAD(true, true)); 446 ASSERT_EQ(0, acm_->SetVAD(true, true));
(...skipping 1294 matching lines...) Expand 10 before | Expand all | Expand 10 after
1748 Run(16000, 8000, 1000); 1741 Run(16000, 8000, 1000);
1749 } 1742 }
1750 1743
1751 TEST_F(AcmSwitchingOutputFrequencyOldApi, Toggle8KhzTo16Khz) { 1744 TEST_F(AcmSwitchingOutputFrequencyOldApi, Toggle8KhzTo16Khz) {
1752 Run(8000, 16000, 1000); 1745 Run(8000, 16000, 1000);
1753 } 1746 }
1754 1747
1755 #endif 1748 #endif
1756 1749
1757 } // namespace webrtc 1750 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698