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