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

Side by Side Diff: webrtc/modules/audio_coding/codecs/cng/audio_encoder_cng_unittest.cc

Issue 1418423010: Pass audio to AudioEncoder::Encode() in an ArrayView (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: disconvert to bool Created 5 years, 1 month 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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 // it is smaller than 10. 68 // it is smaller than 10.
69 EXPECT_CALL(mock_encoder_, Max10MsFramesInAPacket()).WillOnce(Return(1u)); 69 EXPECT_CALL(mock_encoder_, Max10MsFramesInAPacket()).WillOnce(Return(1u));
70 EXPECT_CALL(mock_encoder_, MaxEncodedBytes()) 70 EXPECT_CALL(mock_encoder_, MaxEncodedBytes())
71 .WillRepeatedly(Return(kMockMaxEncodedBytes)); 71 .WillRepeatedly(Return(kMockMaxEncodedBytes));
72 cng_.reset(new AudioEncoderCng(config_)); 72 cng_.reset(new AudioEncoderCng(config_));
73 encoded_.resize(cng_->MaxEncodedBytes(), 0); 73 encoded_.resize(cng_->MaxEncodedBytes(), 0);
74 } 74 }
75 75
76 void Encode() { 76 void Encode() {
77 ASSERT_TRUE(cng_) << "Must call CreateCng() first."; 77 ASSERT_TRUE(cng_) << "Must call CreateCng() first.";
78 encoded_info_ = cng_->Encode(timestamp_, audio_, num_audio_samples_10ms_, 78 encoded_info_ = cng_->Encode(
79 encoded_.size(), &encoded_[0]); 79 timestamp_,
80 rtc::ArrayView<const int16_t>(audio_, num_audio_samples_10ms_),
81 encoded_.size(), &encoded_[0]);
80 timestamp_ += static_cast<uint32_t>(num_audio_samples_10ms_); 82 timestamp_ += static_cast<uint32_t>(num_audio_samples_10ms_);
81 } 83 }
82 84
83 // Expect |num_calls| calls to the encoder, all successful. The last call 85 // Expect |num_calls| calls to the encoder, all successful. The last call
84 // claims to have encoded |kMockMaxEncodedBytes| bytes, and all the preceding 86 // claims to have encoded |kMockMaxEncodedBytes| bytes, and all the preceding
85 // ones 0 bytes. 87 // ones 0 bytes.
86 void ExpectEncodeCalls(size_t num_calls) { 88 void ExpectEncodeCalls(size_t num_calls) {
87 InSequence s; 89 InSequence s;
88 AudioEncoder::EncodedInfo info; 90 AudioEncoder::EncodedInfo info;
89 for (size_t j = 0; j < num_calls - 1; ++j) { 91 for (size_t j = 0; j < num_calls - 1; ++j) {
(...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after
455 .WillRepeatedly(Return(7U)); 457 .WillRepeatedly(Return(7U));
456 for (int i = 0; i < 6; ++i) 458 for (int i = 0; i < 6; ++i)
457 Encode(); 459 Encode();
458 EXPECT_DEATH(Encode(), 460 EXPECT_DEATH(Encode(),
459 "Frame size cannot be larger than 60 ms when using VAD/CNG."); 461 "Frame size cannot be larger than 60 ms when using VAD/CNG.");
460 } 462 }
461 463
462 #endif // GTEST_HAS_DEATH_TEST 464 #endif // GTEST_HAS_DEATH_TEST
463 465
464 } // namespace webrtc 466 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698