Chromium Code Reviews| 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 |
| 11 #include "webrtc/modules/audio_coding/acm2/acm_receive_test_oldapi.h" | 11 #include "webrtc/modules/audio_coding/acm2/acm_receive_test_oldapi.h" |
| 12 | 12 |
| 13 #include <assert.h> | 13 #include <assert.h> |
| 14 #include <stdio.h> | 14 #include <stdio.h> |
| 15 | 15 |
| 16 #include <memory> | |
|
hlundin-webrtc
2016/02/15 11:18:15
You do not have to repeat the same include in both
kwiberg-webrtc
2016/02/15 11:42:50
Yeah, the script I whipped up for automating this
| |
| 17 | |
| 16 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
| 17 #include "webrtc/modules/audio_coding/include/audio_coding_module.h" | 19 #include "webrtc/modules/audio_coding/include/audio_coding_module.h" |
| 18 #include "webrtc/modules/audio_coding/neteq/tools/audio_sink.h" | 20 #include "webrtc/modules/audio_coding/neteq/tools/audio_sink.h" |
| 19 #include "webrtc/modules/audio_coding/neteq/tools/packet.h" | 21 #include "webrtc/modules/audio_coding/neteq/tools/packet.h" |
| 20 #include "webrtc/modules/audio_coding/neteq/tools/packet_source.h" | 22 #include "webrtc/modules/audio_coding/neteq/tools/packet_source.h" |
| 21 | 23 |
| 22 namespace webrtc { | 24 namespace webrtc { |
| 23 namespace test { | 25 namespace test { |
| 24 | 26 |
| 25 namespace { | 27 namespace { |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 144 int rtp_payload_type, | 146 int rtp_payload_type, |
| 145 AudioDecoder* external_decoder, | 147 AudioDecoder* external_decoder, |
| 146 int sample_rate_hz, | 148 int sample_rate_hz, |
| 147 int num_channels, | 149 int num_channels, |
| 148 const std::string& name) { | 150 const std::string& name) { |
| 149 return acm_->RegisterExternalReceiveCodec(rtp_payload_type, external_decoder, | 151 return acm_->RegisterExternalReceiveCodec(rtp_payload_type, external_decoder, |
| 150 sample_rate_hz, num_channels, name); | 152 sample_rate_hz, num_channels, name); |
| 151 } | 153 } |
| 152 | 154 |
| 153 void AcmReceiveTestOldApi::Run() { | 155 void AcmReceiveTestOldApi::Run() { |
| 154 for (rtc::scoped_ptr<Packet> packet(packet_source_->NextPacket()); packet; | 156 for (std::unique_ptr<Packet> packet(packet_source_->NextPacket()); packet; |
| 155 packet.reset(packet_source_->NextPacket())) { | 157 packet.reset(packet_source_->NextPacket())) { |
| 156 // Pull audio until time to insert packet. | 158 // Pull audio until time to insert packet. |
| 157 while (clock_.TimeInMilliseconds() < packet->time_ms()) { | 159 while (clock_.TimeInMilliseconds() < packet->time_ms()) { |
| 158 AudioFrame output_frame; | 160 AudioFrame output_frame; |
| 159 EXPECT_EQ(0, acm_->PlayoutData10Ms(output_freq_hz_, &output_frame)); | 161 EXPECT_EQ(0, acm_->PlayoutData10Ms(output_freq_hz_, &output_frame)); |
| 160 EXPECT_EQ(output_freq_hz_, output_frame.sample_rate_hz_); | 162 EXPECT_EQ(output_freq_hz_, output_frame.sample_rate_hz_); |
| 161 const size_t samples_per_block = | 163 const size_t samples_per_block = |
| 162 static_cast<size_t>(output_freq_hz_ * 10 / 1000); | 164 static_cast<size_t>(output_freq_hz_ * 10 / 1000); |
| 163 EXPECT_EQ(samples_per_block, output_frame.samples_per_channel_); | 165 EXPECT_EQ(samples_per_block, output_frame.samples_per_channel_); |
| 164 if (exptected_output_channels_ != kArbitraryChannels) { | 166 if (exptected_output_channels_ != kArbitraryChannels) { |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 213 if (clock_.TimeInMilliseconds() >= last_toggle_time_ms_ + toggle_period_ms_) { | 215 if (clock_.TimeInMilliseconds() >= last_toggle_time_ms_ + toggle_period_ms_) { |
| 214 output_freq_hz_ = (output_freq_hz_ == output_freq_hz_1_) | 216 output_freq_hz_ = (output_freq_hz_ == output_freq_hz_1_) |
| 215 ? output_freq_hz_2_ | 217 ? output_freq_hz_2_ |
| 216 : output_freq_hz_1_; | 218 : output_freq_hz_1_; |
| 217 last_toggle_time_ms_ = clock_.TimeInMilliseconds(); | 219 last_toggle_time_ms_ = clock_.TimeInMilliseconds(); |
| 218 } | 220 } |
| 219 } | 221 } |
| 220 | 222 |
| 221 } // namespace test | 223 } // namespace test |
| 222 } // namespace webrtc | 224 } // namespace webrtc |
| OLD | NEW |