| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2017 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/api/audio_codecs/audio_encoder_factory_template.h" | 11 #include "webrtc/api/audio_codecs/audio_encoder_factory_template.h" |
| 12 #include "webrtc/api/audio_codecs/g711/audio_encoder_g711.h" |
| 12 #include "webrtc/api/audio_codecs/g722/audio_encoder_g722.h" | 13 #include "webrtc/api/audio_codecs/g722/audio_encoder_g722.h" |
| 13 #include "webrtc/api/audio_codecs/ilbc/audio_encoder_ilbc.h" | 14 #include "webrtc/api/audio_codecs/ilbc/audio_encoder_ilbc.h" |
| 14 #include "webrtc/api/audio_codecs/opus/audio_encoder_opus.h" | 15 #include "webrtc/api/audio_codecs/opus/audio_encoder_opus.h" |
| 15 #include "webrtc/rtc_base/ptr_util.h" | 16 #include "webrtc/rtc_base/ptr_util.h" |
| 16 #include "webrtc/test/gmock.h" | 17 #include "webrtc/test/gmock.h" |
| 17 #include "webrtc/test/gtest.h" | 18 #include "webrtc/test/gtest.h" |
| 18 #include "webrtc/test/mock_audio_encoder.h" | 19 #include "webrtc/test/mock_audio_encoder.h" |
| 19 | 20 |
| 20 namespace webrtc { | 21 namespace webrtc { |
| 21 | 22 |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 auto enc1 = factory->MakeAudioEncoder(17, {"bogus", 8000, 1}); | 114 auto enc1 = factory->MakeAudioEncoder(17, {"bogus", 8000, 1}); |
| 114 ASSERT_NE(nullptr, enc1); | 115 ASSERT_NE(nullptr, enc1); |
| 115 EXPECT_EQ(8000, enc1->SampleRateHz()); | 116 EXPECT_EQ(8000, enc1->SampleRateHz()); |
| 116 EXPECT_EQ(nullptr, factory->MakeAudioEncoder(17, {"sham", 16000, 2})); | 117 EXPECT_EQ(nullptr, factory->MakeAudioEncoder(17, {"sham", 16000, 2})); |
| 117 auto enc2 = | 118 auto enc2 = |
| 118 factory->MakeAudioEncoder(17, {"sham", 16000, 2, {{"param", "value"}}}); | 119 factory->MakeAudioEncoder(17, {"sham", 16000, 2, {{"param", "value"}}}); |
| 119 ASSERT_NE(nullptr, enc2); | 120 ASSERT_NE(nullptr, enc2); |
| 120 EXPECT_EQ(16000, enc2->SampleRateHz()); | 121 EXPECT_EQ(16000, enc2->SampleRateHz()); |
| 121 } | 122 } |
| 122 | 123 |
| 124 TEST(AudioEncoderFactoryTemplateTest, G711) { |
| 125 auto factory = CreateAudioEncoderFactory<AudioEncoderG711>(); |
| 126 EXPECT_THAT(factory->GetSupportedEncoders(), |
| 127 testing::ElementsAre( |
| 128 AudioCodecSpec{{"PCMU", 8000, 1}, {8000, 1, 64000}}, |
| 129 AudioCodecSpec{{"PCMA", 8000, 1}, {8000, 1, 64000}})); |
| 130 EXPECT_EQ(rtc::Optional<AudioCodecInfo>(), |
| 131 factory->QueryAudioEncoder({"PCMA", 16000, 1})); |
| 132 EXPECT_EQ(rtc::Optional<AudioCodecInfo>({8000, 1, 64000}), |
| 133 factory->QueryAudioEncoder({"PCMA", 8000, 1})); |
| 134 EXPECT_EQ(nullptr, factory->MakeAudioEncoder(17, {"PCMU", 16000, 1})); |
| 135 auto enc1 = factory->MakeAudioEncoder(17, {"PCMU", 8000, 1}); |
| 136 ASSERT_NE(nullptr, enc1); |
| 137 EXPECT_EQ(8000, enc1->SampleRateHz()); |
| 138 auto enc2 = factory->MakeAudioEncoder(17, {"PCMA", 8000, 1}); |
| 139 ASSERT_NE(nullptr, enc2); |
| 140 EXPECT_EQ(8000, enc2->SampleRateHz()); |
| 141 } |
| 142 |
| 123 TEST(AudioEncoderFactoryTemplateTest, G722) { | 143 TEST(AudioEncoderFactoryTemplateTest, G722) { |
| 124 auto factory = CreateAudioEncoderFactory<AudioEncoderG722>(); | 144 auto factory = CreateAudioEncoderFactory<AudioEncoderG722>(); |
| 125 EXPECT_THAT(factory->GetSupportedEncoders(), | 145 EXPECT_THAT(factory->GetSupportedEncoders(), |
| 126 testing::ElementsAre( | 146 testing::ElementsAre( |
| 127 AudioCodecSpec{{"g722", 8000, 1}, {16000, 1, 64000}})); | 147 AudioCodecSpec{{"g722", 8000, 1}, {16000, 1, 64000}})); |
| 128 EXPECT_EQ(rtc::Optional<AudioCodecInfo>(), | 148 EXPECT_EQ(rtc::Optional<AudioCodecInfo>(), |
| 129 factory->QueryAudioEncoder({"foo", 8000, 1})); | 149 factory->QueryAudioEncoder({"foo", 8000, 1})); |
| 130 EXPECT_EQ(rtc::Optional<AudioCodecInfo>({16000, 1, 64000}), | 150 EXPECT_EQ(rtc::Optional<AudioCodecInfo>({16000, 1, 64000}), |
| 131 factory->QueryAudioEncoder({"g722", 8000, 1})); | 151 factory->QueryAudioEncoder({"g722", 8000, 1})); |
| 132 EXPECT_EQ(nullptr, factory->MakeAudioEncoder(17, {"bar", 16000, 1})); | 152 EXPECT_EQ(nullptr, factory->MakeAudioEncoder(17, {"bar", 16000, 1})); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 rtc::Optional<AudioCodecInfo>(info), | 186 rtc::Optional<AudioCodecInfo>(info), |
| 167 factory->QueryAudioEncoder( | 187 factory->QueryAudioEncoder( |
| 168 {"opus", 48000, 2, {{"minptime", "10"}, {"useinbandfec", "1"}}})); | 188 {"opus", 48000, 2, {{"minptime", "10"}, {"useinbandfec", "1"}}})); |
| 169 EXPECT_EQ(nullptr, factory->MakeAudioEncoder(17, {"bar", 16000, 1})); | 189 EXPECT_EQ(nullptr, factory->MakeAudioEncoder(17, {"bar", 16000, 1})); |
| 170 auto enc = factory->MakeAudioEncoder(17, {"opus", 48000, 2}); | 190 auto enc = factory->MakeAudioEncoder(17, {"opus", 48000, 2}); |
| 171 ASSERT_NE(nullptr, enc); | 191 ASSERT_NE(nullptr, enc); |
| 172 EXPECT_EQ(48000, enc->SampleRateHz()); | 192 EXPECT_EQ(48000, enc->SampleRateHz()); |
| 173 } | 193 } |
| 174 | 194 |
| 175 } // namespace webrtc | 195 } // namespace webrtc |
| OLD | NEW |