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.h" | 11 #include "webrtc/modules/audio_coding/acm2/acm_receive_test.h" |
12 | 12 |
13 #include <assert.h> | 13 #include <assert.h> |
14 #include <stdio.h> | 14 #include <stdio.h> |
15 | 15 |
16 #include <memory> | 16 #include <memory> |
17 | 17 |
| 18 #include "webrtc/modules/audio_coding/codecs/audio_format_conversion.h" |
18 #include "webrtc/modules/audio_coding/codecs/builtin_audio_decoder_factory.h" | 19 #include "webrtc/modules/audio_coding/codecs/builtin_audio_decoder_factory.h" |
19 #include "webrtc/modules/audio_coding/include/audio_coding_module.h" | 20 #include "webrtc/modules/audio_coding/include/audio_coding_module.h" |
20 #include "webrtc/modules/audio_coding/neteq/tools/audio_sink.h" | 21 #include "webrtc/modules/audio_coding/neteq/tools/audio_sink.h" |
21 #include "webrtc/modules/audio_coding/neteq/tools/packet.h" | 22 #include "webrtc/modules/audio_coding/neteq/tools/packet.h" |
22 #include "webrtc/modules/audio_coding/neteq/tools/packet_source.h" | 23 #include "webrtc/modules/audio_coding/neteq/tools/packet_source.h" |
23 #include "webrtc/test/gtest.h" | 24 #include "webrtc/test/gtest.h" |
24 | 25 |
25 namespace webrtc { | 26 namespace webrtc { |
26 namespace test { | 27 namespace test { |
27 | 28 |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 output_freq_hz_(output_freq_hz), | 126 output_freq_hz_(output_freq_hz), |
126 exptected_output_channels_(exptected_output_channels) {} | 127 exptected_output_channels_(exptected_output_channels) {} |
127 | 128 |
128 AcmReceiveTestOldApi::~AcmReceiveTestOldApi() = default; | 129 AcmReceiveTestOldApi::~AcmReceiveTestOldApi() = default; |
129 | 130 |
130 void AcmReceiveTestOldApi::RegisterDefaultCodecs() { | 131 void AcmReceiveTestOldApi::RegisterDefaultCodecs() { |
131 CodecInst my_codec_param; | 132 CodecInst my_codec_param; |
132 for (int n = 0; n < acm_->NumberOfCodecs(); n++) { | 133 for (int n = 0; n < acm_->NumberOfCodecs(); n++) { |
133 ASSERT_EQ(0, acm_->Codec(n, &my_codec_param)) << "Failed to get codec."; | 134 ASSERT_EQ(0, acm_->Codec(n, &my_codec_param)) << "Failed to get codec."; |
134 if (ModifyAndUseThisCodec(&my_codec_param)) { | 135 if (ModifyAndUseThisCodec(&my_codec_param)) { |
135 ASSERT_EQ(0, acm_->RegisterReceiveCodec(my_codec_param)) | 136 ASSERT_EQ(true, |
| 137 acm_->RegisterReceiveCodec(my_codec_param.pltype, |
| 138 CodecInstToSdp(my_codec_param))) |
136 << "Couldn't register receive codec.\n"; | 139 << "Couldn't register receive codec.\n"; |
137 } | 140 } |
138 } | 141 } |
139 } | 142 } |
140 | 143 |
141 void AcmReceiveTestOldApi::RegisterNetEqTestCodecs() { | 144 void AcmReceiveTestOldApi::RegisterNetEqTestCodecs() { |
142 CodecInst my_codec_param; | 145 CodecInst my_codec_param; |
143 for (int n = 0; n < acm_->NumberOfCodecs(); n++) { | 146 for (int n = 0; n < acm_->NumberOfCodecs(); n++) { |
144 ASSERT_EQ(0, acm_->Codec(n, &my_codec_param)) << "Failed to get codec."; | 147 ASSERT_EQ(0, acm_->Codec(n, &my_codec_param)) << "Failed to get codec."; |
145 if (!ModifyAndUseThisCodec(&my_codec_param)) { | 148 if (!ModifyAndUseThisCodec(&my_codec_param)) { |
146 // Skip this codec. | 149 // Skip this codec. |
147 continue; | 150 continue; |
148 } | 151 } |
149 | 152 |
150 if (RemapPltypeAndUseThisCodec(my_codec_param.plname, | 153 if (RemapPltypeAndUseThisCodec(my_codec_param.plname, |
151 my_codec_param.plfreq, | 154 my_codec_param.plfreq, |
152 my_codec_param.channels, | 155 my_codec_param.channels, |
153 &my_codec_param.pltype)) { | 156 &my_codec_param.pltype)) { |
154 ASSERT_EQ(0, acm_->RegisterReceiveCodec(my_codec_param)) | 157 ASSERT_EQ(true, |
| 158 acm_->RegisterReceiveCodec(my_codec_param.pltype, |
| 159 CodecInstToSdp(my_codec_param))) |
155 << "Couldn't register receive codec.\n"; | 160 << "Couldn't register receive codec.\n"; |
156 } | 161 } |
157 } | 162 } |
158 } | 163 } |
159 | 164 |
160 int AcmReceiveTestOldApi::RegisterExternalReceiveCodec( | |
161 int rtp_payload_type, | |
162 AudioDecoder* external_decoder, | |
163 int sample_rate_hz, | |
164 int num_channels, | |
165 const std::string& name) { | |
166 return acm_->RegisterExternalReceiveCodec(rtp_payload_type, external_decoder, | |
167 sample_rate_hz, num_channels, name); | |
168 } | |
169 | |
170 void AcmReceiveTestOldApi::Run() { | 165 void AcmReceiveTestOldApi::Run() { |
171 for (std::unique_ptr<Packet> packet(packet_source_->NextPacket()); packet; | 166 for (std::unique_ptr<Packet> packet(packet_source_->NextPacket()); packet; |
172 packet = packet_source_->NextPacket()) { | 167 packet = packet_source_->NextPacket()) { |
173 // Pull audio until time to insert packet. | 168 // Pull audio until time to insert packet. |
174 while (clock_.TimeInMilliseconds() < packet->time_ms()) { | 169 while (clock_.TimeInMilliseconds() < packet->time_ms()) { |
175 AudioFrame output_frame; | 170 AudioFrame output_frame; |
176 bool muted; | 171 bool muted; |
177 EXPECT_EQ(0, | 172 EXPECT_EQ(0, |
178 acm_->PlayoutData10Ms(output_freq_hz_, &output_frame, &muted)); | 173 acm_->PlayoutData10Ms(output_freq_hz_, &output_frame, &muted)); |
179 ASSERT_EQ(output_freq_hz_, output_frame.sample_rate_hz_); | 174 ASSERT_EQ(output_freq_hz_, output_frame.sample_rate_hz_); |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
233 if (clock_.TimeInMilliseconds() >= last_toggle_time_ms_ + toggle_period_ms_) { | 228 if (clock_.TimeInMilliseconds() >= last_toggle_time_ms_ + toggle_period_ms_) { |
234 output_freq_hz_ = (output_freq_hz_ == output_freq_hz_1_) | 229 output_freq_hz_ = (output_freq_hz_ == output_freq_hz_1_) |
235 ? output_freq_hz_2_ | 230 ? output_freq_hz_2_ |
236 : output_freq_hz_1_; | 231 : output_freq_hz_1_; |
237 last_toggle_time_ms_ = clock_.TimeInMilliseconds(); | 232 last_toggle_time_ms_ = clock_.TimeInMilliseconds(); |
238 } | 233 } |
239 } | 234 } |
240 | 235 |
241 } // namespace test | 236 } // namespace test |
242 } // namespace webrtc | 237 } // namespace webrtc |
OLD | NEW |