OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2013 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/test/opus_test.h" | 11 #include "webrtc/modules/audio_coding/test/opus_test.h" |
12 | 12 |
13 #include <assert.h> | 13 #include <assert.h> |
14 | 14 |
15 #include <string> | 15 #include <string> |
16 | 16 |
17 #include "webrtc/common_types.h" | 17 #include "webrtc/common_types.h" |
| 18 #include "webrtc/modules/audio_coding/codecs/audio_format_conversion.h" |
18 #include "webrtc/modules/audio_coding/codecs/opus/opus_interface.h" | 19 #include "webrtc/modules/audio_coding/codecs/opus/opus_interface.h" |
19 #include "webrtc/modules/audio_coding/include/audio_coding_module_typedefs.h" | 20 #include "webrtc/modules/audio_coding/include/audio_coding_module_typedefs.h" |
20 #include "webrtc/modules/audio_coding/test/TestStereo.h" | 21 #include "webrtc/modules/audio_coding/test/TestStereo.h" |
21 #include "webrtc/modules/audio_coding/test/utility.h" | 22 #include "webrtc/modules/audio_coding/test/utility.h" |
22 #include "webrtc/system_wrappers/include/trace.h" | 23 #include "webrtc/system_wrappers/include/trace.h" |
23 #include "webrtc/test/gtest.h" | 24 #include "webrtc/test/gtest.h" |
24 #include "webrtc/test/testsupport/fileutils.h" | 25 #include "webrtc/test/testsupport/fileutils.h" |
25 #include "webrtc/voice_engine_configurations.h" | 26 #include "webrtc/voice_engine_configurations.h" |
26 | 27 |
27 namespace webrtc { | 28 namespace webrtc { |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 WebRtcOpus_DecoderInit(opus_stereo_decoder_); | 88 WebRtcOpus_DecoderInit(opus_stereo_decoder_); |
88 | 89 |
89 ASSERT_TRUE(acm_receiver_.get() != NULL); | 90 ASSERT_TRUE(acm_receiver_.get() != NULL); |
90 EXPECT_EQ(0, acm_receiver_->InitializeReceiver()); | 91 EXPECT_EQ(0, acm_receiver_->InitializeReceiver()); |
91 | 92 |
92 // Register Opus stereo as receiving codec. | 93 // Register Opus stereo as receiving codec. |
93 CodecInst opus_codec_param; | 94 CodecInst opus_codec_param; |
94 int codec_id = acm_receiver_->Codec("opus", 48000, 2); | 95 int codec_id = acm_receiver_->Codec("opus", 48000, 2); |
95 EXPECT_EQ(0, acm_receiver_->Codec(codec_id, &opus_codec_param)); | 96 EXPECT_EQ(0, acm_receiver_->Codec(codec_id, &opus_codec_param)); |
96 payload_type_ = opus_codec_param.pltype; | 97 payload_type_ = opus_codec_param.pltype; |
97 EXPECT_EQ(0, acm_receiver_->RegisterReceiveCodec(opus_codec_param)); | 98 EXPECT_EQ(true, |
| 99 acm_receiver_->RegisterReceiveCodec( |
| 100 opus_codec_param.pltype, CodecInstToSdp(opus_codec_param))); |
98 | 101 |
99 // Create and connect the channel. | 102 // Create and connect the channel. |
100 channel_a2b_ = new TestPackStereo; | 103 channel_a2b_ = new TestPackStereo; |
101 channel_a2b_->RegisterReceiverACM(acm_receiver_.get()); | 104 channel_a2b_->RegisterReceiverACM(acm_receiver_.get()); |
102 | 105 |
103 // | 106 // |
104 // Test Stereo. | 107 // Test Stereo. |
105 // | 108 // |
106 | 109 |
107 channel_a2b_->set_codec_mode(kStereo); | 110 channel_a2b_->set_codec_mode(kStereo); |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 // | 155 // |
153 // Test Mono. | 156 // Test Mono. |
154 // | 157 // |
155 channel_a2b_->set_codec_mode(kMono); | 158 channel_a2b_->set_codec_mode(kMono); |
156 audio_channels = 1; | 159 audio_channels = 1; |
157 test_cntr++; | 160 test_cntr++; |
158 OpenOutFile(test_cntr); | 161 OpenOutFile(test_cntr); |
159 | 162 |
160 // Register Opus mono as receiving codec. | 163 // Register Opus mono as receiving codec. |
161 opus_codec_param.channels = 1; | 164 opus_codec_param.channels = 1; |
162 EXPECT_EQ(0, acm_receiver_->RegisterReceiveCodec(opus_codec_param)); | 165 EXPECT_EQ(true, |
| 166 acm_receiver_->RegisterReceiveCodec( |
| 167 opus_codec_param.pltype, CodecInstToSdp(opus_codec_param))); |
163 | 168 |
164 // Run Opus with 2.5 ms frame size. | 169 // Run Opus with 2.5 ms frame size. |
165 Run(channel_a2b_, audio_channels, 32000, 120); | 170 Run(channel_a2b_, audio_channels, 32000, 120); |
166 | 171 |
167 // Run Opus with 5 ms frame size. | 172 // Run Opus with 5 ms frame size. |
168 Run(channel_a2b_, audio_channels, 32000, 240); | 173 Run(channel_a2b_, audio_channels, 32000, 240); |
169 | 174 |
170 // Run Opus with 10 ms frame size. | 175 // Run Opus with 10 ms frame size. |
171 Run(channel_a2b_, audio_channels, 32000, 480); | 176 Run(channel_a2b_, audio_channels, 32000, 480); |
172 | 177 |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
377 out_file_.Open(file_name, 48000, "wb"); | 382 out_file_.Open(file_name, 48000, "wb"); |
378 file_stream.str(""); | 383 file_stream.str(""); |
379 file_name = file_stream.str(); | 384 file_name = file_stream.str(); |
380 file_stream << webrtc::test::OutputPath() << "opusstandalone_out_" | 385 file_stream << webrtc::test::OutputPath() << "opusstandalone_out_" |
381 << test_number << ".pcm"; | 386 << test_number << ".pcm"; |
382 file_name = file_stream.str(); | 387 file_name = file_stream.str(); |
383 out_file_standalone_.Open(file_name, 48000, "wb"); | 388 out_file_standalone_.Open(file_name, 48000, "wb"); |
384 } | 389 } |
385 | 390 |
386 } // namespace webrtc | 391 } // namespace webrtc |
OLD | NEW |