OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2012 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/TestStereo.h" | 11 #include "webrtc/modules/audio_coding/test/TestStereo.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/include/audio_coding_module_typedefs.h" | 19 #include "webrtc/modules/audio_coding/include/audio_coding_module_typedefs.h" |
19 #include "webrtc/modules/audio_coding/test/utility.h" | 20 #include "webrtc/modules/audio_coding/test/utility.h" |
20 #include "webrtc/system_wrappers/include/trace.h" | 21 #include "webrtc/system_wrappers/include/trace.h" |
21 #include "webrtc/test/gtest.h" | 22 #include "webrtc/test/gtest.h" |
22 #include "webrtc/test/testsupport/fileutils.h" | 23 #include "webrtc/test/testsupport/fileutils.h" |
23 #include "webrtc/voice_engine_configurations.h" | 24 #include "webrtc/voice_engine_configurations.h" |
24 | 25 |
25 namespace webrtc { | 26 namespace webrtc { |
26 | 27 |
27 // Class for simulating packet handling | 28 // Class for simulating packet handling |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 // Create and initialize two ACMs, one for each side of a one-to-one call. | 165 // Create and initialize two ACMs, one for each side of a one-to-one call. |
165 ASSERT_TRUE((acm_a_.get() != NULL) && (acm_b_.get() != NULL)); | 166 ASSERT_TRUE((acm_a_.get() != NULL) && (acm_b_.get() != NULL)); |
166 EXPECT_EQ(0, acm_a_->InitializeReceiver()); | 167 EXPECT_EQ(0, acm_a_->InitializeReceiver()); |
167 EXPECT_EQ(0, acm_b_->InitializeReceiver()); | 168 EXPECT_EQ(0, acm_b_->InitializeReceiver()); |
168 | 169 |
169 // Register all available codes as receiving codecs. | 170 // Register all available codes as receiving codecs. |
170 uint8_t num_encoders = acm_a_->NumberOfCodecs(); | 171 uint8_t num_encoders = acm_a_->NumberOfCodecs(); |
171 CodecInst my_codec_param; | 172 CodecInst my_codec_param; |
172 for (uint8_t n = 0; n < num_encoders; n++) { | 173 for (uint8_t n = 0; n < num_encoders; n++) { |
173 EXPECT_EQ(0, acm_b_->Codec(n, &my_codec_param)); | 174 EXPECT_EQ(0, acm_b_->Codec(n, &my_codec_param)); |
174 EXPECT_EQ(0, acm_b_->RegisterReceiveCodec(my_codec_param)); | 175 EXPECT_EQ(true, acm_b_->RegisterReceiveCodec( |
| 176 my_codec_param.pltype, CodecInstToSdp(my_codec_param))); |
175 } | 177 } |
176 | 178 |
177 // Test that unregister all receive codecs works. | 179 // Test that unregister all receive codecs works. |
178 for (uint8_t n = 0; n < num_encoders; n++) { | 180 for (uint8_t n = 0; n < num_encoders; n++) { |
179 EXPECT_EQ(0, acm_b_->Codec(n, &my_codec_param)); | 181 EXPECT_EQ(0, acm_b_->Codec(n, &my_codec_param)); |
180 EXPECT_EQ(0, acm_b_->UnregisterReceiveCodec(my_codec_param.pltype)); | 182 EXPECT_EQ(0, acm_b_->UnregisterReceiveCodec(my_codec_param.pltype)); |
181 } | 183 } |
182 | 184 |
183 // Register all available codes as receiving codecs once more. | 185 // Register all available codes as receiving codecs once more. |
184 for (uint8_t n = 0; n < num_encoders; n++) { | 186 for (uint8_t n = 0; n < num_encoders; n++) { |
185 EXPECT_EQ(0, acm_b_->Codec(n, &my_codec_param)); | 187 EXPECT_EQ(0, acm_b_->Codec(n, &my_codec_param)); |
186 EXPECT_EQ(0, acm_b_->RegisterReceiveCodec(my_codec_param)); | 188 EXPECT_EQ(true, acm_b_->RegisterReceiveCodec( |
| 189 my_codec_param.pltype, CodecInstToSdp(my_codec_param))); |
187 } | 190 } |
188 | 191 |
189 // Create and connect the channel. | 192 // Create and connect the channel. |
190 channel_a2b_ = new TestPackStereo; | 193 channel_a2b_ = new TestPackStereo; |
191 EXPECT_EQ(0, acm_a_->RegisterTransportCallback(channel_a2b_)); | 194 EXPECT_EQ(0, acm_a_->RegisterTransportCallback(channel_a2b_)); |
192 channel_a2b_->RegisterReceiverACM(acm_b_.get()); | 195 channel_a2b_->RegisterReceiverACM(acm_b_.get()); |
193 | 196 |
194 // Start with setting VAD/DTX, before we know we will send stereo. | 197 // Start with setting VAD/DTX, before we know we will send stereo. |
195 // Continue with setting a stereo codec as send codec and verify that | 198 // Continue with setting a stereo codec as send codec and verify that |
196 // VAD/DTX gets turned off. | 199 // VAD/DTX gets turned off. |
(...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
590 test_cntr_++; | 593 test_cntr_++; |
591 OpenOutFile(test_cntr_); | 594 OpenOutFile(test_cntr_); |
592 // Encode and decode in mono. | 595 // Encode and decode in mono. |
593 RegisterSendCodec('A', codec_opus, 48000, 32000, 960, codec_channels, | 596 RegisterSendCodec('A', codec_opus, 48000, 32000, 960, codec_channels, |
594 opus_pltype_); | 597 opus_pltype_); |
595 CodecInst opus_codec_param; | 598 CodecInst opus_codec_param; |
596 for (uint8_t n = 0; n < num_encoders; n++) { | 599 for (uint8_t n = 0; n < num_encoders; n++) { |
597 EXPECT_EQ(0, acm_b_->Codec(n, &opus_codec_param)); | 600 EXPECT_EQ(0, acm_b_->Codec(n, &opus_codec_param)); |
598 if (!strcmp(opus_codec_param.plname, "opus")) { | 601 if (!strcmp(opus_codec_param.plname, "opus")) { |
599 opus_codec_param.channels = 1; | 602 opus_codec_param.channels = 1; |
600 EXPECT_EQ(0, acm_b_->RegisterReceiveCodec(opus_codec_param)); | 603 EXPECT_EQ(true, |
| 604 acm_b_->RegisterReceiveCodec(opus_codec_param.pltype, |
| 605 CodecInstToSdp(opus_codec_param))); |
601 break; | 606 break; |
602 } | 607 } |
603 } | 608 } |
604 Run(channel_a2b_, audio_channels, codec_channels); | 609 Run(channel_a2b_, audio_channels, codec_channels); |
605 | 610 |
606 // Encode in stereo, decode in mono. | 611 // Encode in stereo, decode in mono. |
607 RegisterSendCodec('A', codec_opus, 48000, 32000, 960, 2, opus_pltype_); | 612 RegisterSendCodec('A', codec_opus, 48000, 32000, 960, 2, opus_pltype_); |
608 Run(channel_a2b_, audio_channels, codec_channels); | 613 Run(channel_a2b_, audio_channels, codec_channels); |
609 | 614 |
610 out_file_.Close(); | 615 out_file_.Close(); |
(...skipping 12 matching lines...) Expand all Loading... |
623 out_file_.Close(); | 628 out_file_.Close(); |
624 // Decode in stereo. | 629 // Decode in stereo. |
625 test_cntr_++; | 630 test_cntr_++; |
626 OpenOutFile(test_cntr_); | 631 OpenOutFile(test_cntr_); |
627 if (test_mode_ != 0) { | 632 if (test_mode_ != 0) { |
628 // Print out codec and settings | 633 // Print out codec and settings |
629 printf("Test number: %d\nCodec: Opus Freq: 48000 Rate :32000 PackSize: 960" | 634 printf("Test number: %d\nCodec: Opus Freq: 48000 Rate :32000 PackSize: 960" |
630 " Decode: stereo\n", test_cntr_); | 635 " Decode: stereo\n", test_cntr_); |
631 } | 636 } |
632 opus_codec_param.channels = 2; | 637 opus_codec_param.channels = 2; |
633 EXPECT_EQ(0, acm_b_->RegisterReceiveCodec(opus_codec_param)); | 638 EXPECT_EQ(true, |
| 639 acm_b_->RegisterReceiveCodec(opus_codec_param.pltype, |
| 640 CodecInstToSdp(opus_codec_param))); |
634 Run(channel_a2b_, audio_channels, 2); | 641 Run(channel_a2b_, audio_channels, 2); |
635 out_file_.Close(); | 642 out_file_.Close(); |
636 // Decode in mono. | 643 // Decode in mono. |
637 test_cntr_++; | 644 test_cntr_++; |
638 OpenOutFile(test_cntr_); | 645 OpenOutFile(test_cntr_); |
639 if (test_mode_ != 0) { | 646 if (test_mode_ != 0) { |
640 // Print out codec and settings | 647 // Print out codec and settings |
641 printf("Test number: %d\nCodec: Opus Freq: 48000 Rate :32000 PackSize: 960" | 648 printf("Test number: %d\nCodec: Opus Freq: 48000 Rate :32000 PackSize: 960" |
642 " Decode: mono\n", test_cntr_); | 649 " Decode: mono\n", test_cntr_); |
643 } | 650 } |
644 opus_codec_param.channels = 1; | 651 opus_codec_param.channels = 1; |
645 EXPECT_EQ(0, acm_b_->RegisterReceiveCodec(opus_codec_param)); | 652 EXPECT_EQ(true, |
| 653 acm_b_->RegisterReceiveCodec(opus_codec_param.pltype, |
| 654 CodecInstToSdp(opus_codec_param))); |
646 Run(channel_a2b_, audio_channels, codec_channels); | 655 Run(channel_a2b_, audio_channels, codec_channels); |
647 out_file_.Close(); | 656 out_file_.Close(); |
648 | 657 |
649 #endif | 658 #endif |
650 | 659 |
651 // Print out which codecs were tested, and which were not, in the run. | 660 // Print out which codecs were tested, and which were not, in the run. |
652 if (test_mode_ != 0) { | 661 if (test_mode_ != 0) { |
653 printf("\nThe following codecs was INCLUDED in the test:\n"); | 662 printf("\nThe following codecs was INCLUDED in the test:\n"); |
654 #ifdef WEBRTC_CODEC_G722 | 663 #ifdef WEBRTC_CODEC_G722 |
655 printf(" G.722\n"); | 664 printf(" G.722\n"); |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
837 printf("%s -> ", send_codec->plname); | 846 printf("%s -> ", send_codec->plname); |
838 } | 847 } |
839 CodecInst receive_codec; | 848 CodecInst receive_codec; |
840 acm_b_->ReceiveCodec(&receive_codec); | 849 acm_b_->ReceiveCodec(&receive_codec); |
841 if (test_mode_ != 0) { | 850 if (test_mode_ != 0) { |
842 printf("%s\n", receive_codec.plname); | 851 printf("%s\n", receive_codec.plname); |
843 } | 852 } |
844 } | 853 } |
845 | 854 |
846 } // namespace webrtc | 855 } // namespace webrtc |
OLD | NEW |