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

Side by Side Diff: modules/audio_coding/acm2/audio_coding_module_unittest.cc

Issue 3014683002: Revert of Remove various IDs (Closed)
Patch Set: Created 3 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 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 FrameType last_frame_type_ RTC_GUARDED_BY(crit_sect_); 150 FrameType last_frame_type_ RTC_GUARDED_BY(crit_sect_);
151 int last_payload_type_ RTC_GUARDED_BY(crit_sect_); 151 int last_payload_type_ RTC_GUARDED_BY(crit_sect_);
152 uint32_t last_timestamp_ RTC_GUARDED_BY(crit_sect_); 152 uint32_t last_timestamp_ RTC_GUARDED_BY(crit_sect_);
153 std::vector<uint8_t> last_payload_vec_ RTC_GUARDED_BY(crit_sect_); 153 std::vector<uint8_t> last_payload_vec_ RTC_GUARDED_BY(crit_sect_);
154 rtc::CriticalSection crit_sect_; 154 rtc::CriticalSection crit_sect_;
155 }; 155 };
156 156
157 class AudioCodingModuleTestOldApi : public ::testing::Test { 157 class AudioCodingModuleTestOldApi : public ::testing::Test {
158 protected: 158 protected:
159 AudioCodingModuleTestOldApi() 159 AudioCodingModuleTestOldApi()
160 : rtp_utility_(new RtpUtility(kFrameSizeSamples, kPayloadType)), 160 : id_(1),
161 rtp_utility_(new RtpUtility(kFrameSizeSamples, kPayloadType)),
161 clock_(Clock::GetRealTimeClock()) {} 162 clock_(Clock::GetRealTimeClock()) {}
162 163
163 ~AudioCodingModuleTestOldApi() {} 164 ~AudioCodingModuleTestOldApi() {}
164 165
165 void TearDown() {} 166 void TearDown() {}
166 167
167 void SetUp() { 168 void SetUp() {
168 acm_.reset(AudioCodingModule::Create(clock_)); 169 acm_.reset(AudioCodingModule::Create(id_, clock_));
169 170
170 rtp_utility_->Populate(&rtp_header_); 171 rtp_utility_->Populate(&rtp_header_);
171 172
172 input_frame_.sample_rate_hz_ = kSampleRateHz; 173 input_frame_.sample_rate_hz_ = kSampleRateHz;
173 input_frame_.num_channels_ = 1; 174 input_frame_.num_channels_ = 1;
174 input_frame_.samples_per_channel_ = kSampleRateHz * 10 / 1000; // 10 ms. 175 input_frame_.samples_per_channel_ = kSampleRateHz * 10 / 1000; // 10 ms.
175 static_assert(kSampleRateHz * 10 / 1000 <= AudioFrame::kMaxDataSizeSamples, 176 static_assert(kSampleRateHz * 10 / 1000 <= AudioFrame::kMaxDataSizeSamples,
176 "audio frame too small"); 177 "audio frame too small");
177 input_frame_.Mute(); 178 input_frame_.Mute();
178 179
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 int last_length = packet_cb_.last_payload_len_bytes(); 223 int last_length = packet_cb_.last_payload_len_bytes();
223 EXPECT_TRUE(last_length == 2 * codec_.pacsize || last_length == 0) 224 EXPECT_TRUE(last_length == 2 * codec_.pacsize || last_length == 0)
224 << "Last encoded packet was " << last_length << " bytes."; 225 << "Last encoded packet was " << last_length << " bytes.";
225 } 226 }
226 227
227 virtual void InsertAudioAndVerifyEncoding() { 228 virtual void InsertAudioAndVerifyEncoding() {
228 InsertAudio(); 229 InsertAudio();
229 VerifyEncoding(); 230 VerifyEncoding();
230 } 231 }
231 232
233 const int id_;
232 std::unique_ptr<RtpUtility> rtp_utility_; 234 std::unique_ptr<RtpUtility> rtp_utility_;
233 std::unique_ptr<AudioCodingModule> acm_; 235 std::unique_ptr<AudioCodingModule> acm_;
234 PacketizationCallbackStubOldApi packet_cb_; 236 PacketizationCallbackStubOldApi packet_cb_;
235 WebRtcRTPHeader rtp_header_; 237 WebRtcRTPHeader rtp_header_;
236 AudioFrame input_frame_; 238 AudioFrame input_frame_;
237 239
238 // These two have to be kept in sync for now. In the future, we'll be able to 240 // These two have to be kept in sync for now. In the future, we'll be able to
239 // eliminate the CodecInst and keep only the SdpAudioFormat. 241 // eliminate the CodecInst and keep only the SdpAudioFormat.
240 rtc::Optional<SdpAudioFormat> audio_format_; 242 rtc::Optional<SdpAudioFormat> audio_format_;
241 CodecInst codec_; 243 CodecInst codec_;
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
305 EXPECT_EQ(0, stats.decoded_muted_output); 307 EXPECT_EQ(0, stats.decoded_muted_output);
306 // TODO(henrik.lundin) Add a test with muted state enabled. 308 // TODO(henrik.lundin) Add a test with muted state enabled.
307 } 309 }
308 310
309 TEST_F(AudioCodingModuleTestOldApi, VerifyOutputFrame) { 311 TEST_F(AudioCodingModuleTestOldApi, VerifyOutputFrame) {
310 AudioFrame audio_frame; 312 AudioFrame audio_frame;
311 const int kSampleRateHz = 32000; 313 const int kSampleRateHz = 32000;
312 bool muted; 314 bool muted;
313 EXPECT_EQ(0, acm_->PlayoutData10Ms(kSampleRateHz, &audio_frame, &muted)); 315 EXPECT_EQ(0, acm_->PlayoutData10Ms(kSampleRateHz, &audio_frame, &muted));
314 ASSERT_FALSE(muted); 316 ASSERT_FALSE(muted);
317 EXPECT_EQ(id_, audio_frame.id_);
315 EXPECT_EQ(0u, audio_frame.timestamp_); 318 EXPECT_EQ(0u, audio_frame.timestamp_);
316 EXPECT_GT(audio_frame.num_channels_, 0u); 319 EXPECT_GT(audio_frame.num_channels_, 0u);
317 EXPECT_EQ(static_cast<size_t>(kSampleRateHz / 100), 320 EXPECT_EQ(static_cast<size_t>(kSampleRateHz / 100),
318 audio_frame.samples_per_channel_); 321 audio_frame.samples_per_channel_);
319 EXPECT_EQ(kSampleRateHz, audio_frame.sample_rate_hz_); 322 EXPECT_EQ(kSampleRateHz, audio_frame.sample_rate_hz_);
320 } 323 }
321 324
322 // The below test is temporarily disabled on Windows due to problems 325 // The below test is temporarily disabled on Windows due to problems
323 // with clang debug builds. 326 // with clang debug builds.
324 // TODO(tommi): Re-enable when we've figured out what the problem is. 327 // TODO(tommi): Re-enable when we've figured out what the problem is.
(...skipping 1628 matching lines...) Expand 10 before | Expand all | Expand 10 after
1953 Run(16000, 8000, 1000); 1956 Run(16000, 8000, 1000);
1954 } 1957 }
1955 1958
1956 TEST_F(AcmSwitchingOutputFrequencyOldApi, Toggle8KhzTo16Khz) { 1959 TEST_F(AcmSwitchingOutputFrequencyOldApi, Toggle8KhzTo16Khz) {
1957 Run(8000, 16000, 1000); 1960 Run(8000, 16000, 1000);
1958 } 1961 }
1959 1962
1960 #endif 1963 #endif
1961 1964
1962 } // namespace webrtc 1965 } // namespace webrtc
OLDNEW
« no previous file with comments | « modules/audio_coding/acm2/audio_coding_module.cc ('k') | modules/audio_coding/include/audio_coding_module.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698