Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(555)

Side by Side Diff: webrtc/api/audio_codecs/test/audio_decoder_factory_template_unittest.cc

Issue 2962653002: G711 implementation of the Audio{En,De}coderFactoryTemplate APIs (Closed)
Patch Set: rebase Created 3 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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_decoder_factory_template.h" 11 #include "webrtc/api/audio_codecs/audio_decoder_factory_template.h"
12 #include "webrtc/api/audio_codecs/g711/audio_decoder_g711.h"
12 #include "webrtc/api/audio_codecs/g722/audio_decoder_g722.h" 13 #include "webrtc/api/audio_codecs/g722/audio_decoder_g722.h"
13 #include "webrtc/api/audio_codecs/ilbc/audio_decoder_ilbc.h" 14 #include "webrtc/api/audio_codecs/ilbc/audio_decoder_ilbc.h"
14 #include "webrtc/api/audio_codecs/opus/audio_decoder_opus.h" 15 #include "webrtc/api/audio_codecs/opus/audio_decoder_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_decoder.h" 19 #include "webrtc/test/mock_audio_decoder.h"
19 20
20 namespace webrtc { 21 namespace webrtc {
21 22
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 auto dec1 = factory->MakeAudioDecoder({"bogus", 8000, 1}); 107 auto dec1 = factory->MakeAudioDecoder({"bogus", 8000, 1});
107 ASSERT_NE(nullptr, dec1); 108 ASSERT_NE(nullptr, dec1);
108 EXPECT_EQ(8000, dec1->SampleRateHz()); 109 EXPECT_EQ(8000, dec1->SampleRateHz());
109 EXPECT_EQ(nullptr, factory->MakeAudioDecoder({"sham", 16000, 2})); 110 EXPECT_EQ(nullptr, factory->MakeAudioDecoder({"sham", 16000, 2}));
110 auto dec2 = 111 auto dec2 =
111 factory->MakeAudioDecoder({"sham", 16000, 2, {{"param", "value"}}}); 112 factory->MakeAudioDecoder({"sham", 16000, 2, {{"param", "value"}}});
112 ASSERT_NE(nullptr, dec2); 113 ASSERT_NE(nullptr, dec2);
113 EXPECT_EQ(16000, dec2->SampleRateHz()); 114 EXPECT_EQ(16000, dec2->SampleRateHz());
114 } 115 }
115 116
117 TEST(AudioDecoderFactoryTemplateTest, G711) {
118 auto factory = CreateAudioDecoderFactory<AudioDecoderG711>();
119 EXPECT_THAT(factory->GetSupportedDecoders(),
120 testing::ElementsAre(
121 AudioCodecSpec{{"PCMU", 8000, 1}, {8000, 1, 64000}},
122 AudioCodecSpec{{"PCMA", 8000, 1}, {8000, 1, 64000}}));
123 EXPECT_FALSE(factory->IsSupportedDecoder({"g711", 8000, 1}));
124 EXPECT_TRUE(factory->IsSupportedDecoder({"PCMU", 8000, 1}));
125 EXPECT_TRUE(factory->IsSupportedDecoder({"pcma", 8000, 1}));
126 EXPECT_EQ(nullptr, factory->MakeAudioDecoder({"pcmu", 16000, 1}));
127 auto dec1 = factory->MakeAudioDecoder({"pcmu", 8000, 1});
128 ASSERT_NE(nullptr, dec1);
129 EXPECT_EQ(8000, dec1->SampleRateHz());
130 auto dec2 = factory->MakeAudioDecoder({"PCMA", 8000, 1});
131 ASSERT_NE(nullptr, dec2);
132 EXPECT_EQ(8000, dec2->SampleRateHz());
133 }
134
116 TEST(AudioDecoderFactoryTemplateTest, G722) { 135 TEST(AudioDecoderFactoryTemplateTest, G722) {
117 auto factory = CreateAudioDecoderFactory<AudioDecoderG722>(); 136 auto factory = CreateAudioDecoderFactory<AudioDecoderG722>();
118 EXPECT_THAT(factory->GetSupportedDecoders(), 137 EXPECT_THAT(factory->GetSupportedDecoders(),
119 testing::ElementsAre( 138 testing::ElementsAre(
120 AudioCodecSpec{{"g722", 8000, 1}, {16000, 1, 64000}})); 139 AudioCodecSpec{{"g722", 8000, 1}, {16000, 1, 64000}}));
121 EXPECT_FALSE(factory->IsSupportedDecoder({"foo", 8000, 1})); 140 EXPECT_FALSE(factory->IsSupportedDecoder({"foo", 8000, 1}));
122 EXPECT_TRUE(factory->IsSupportedDecoder({"g722", 8000, 1})); 141 EXPECT_TRUE(factory->IsSupportedDecoder({"g722", 8000, 1}));
123 EXPECT_EQ(nullptr, factory->MakeAudioDecoder({"bar", 16000, 1})); 142 EXPECT_EQ(nullptr, factory->MakeAudioDecoder({"bar", 16000, 1}));
124 auto dec1 = factory->MakeAudioDecoder({"g722", 8000, 1}); 143 auto dec1 = factory->MakeAudioDecoder({"g722", 8000, 1});
125 ASSERT_NE(nullptr, dec1); 144 ASSERT_NE(nullptr, dec1);
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 testing::ElementsAre(AudioCodecSpec{opus_format, opus_info})); 176 testing::ElementsAre(AudioCodecSpec{opus_format, opus_info}));
158 EXPECT_FALSE(factory->IsSupportedDecoder({"opus", 48000, 1})); 177 EXPECT_FALSE(factory->IsSupportedDecoder({"opus", 48000, 1}));
159 EXPECT_TRUE(factory->IsSupportedDecoder({"opus", 48000, 2})); 178 EXPECT_TRUE(factory->IsSupportedDecoder({"opus", 48000, 2}));
160 EXPECT_EQ(nullptr, factory->MakeAudioDecoder({"bar", 16000, 1})); 179 EXPECT_EQ(nullptr, factory->MakeAudioDecoder({"bar", 16000, 1}));
161 auto dec = factory->MakeAudioDecoder({"opus", 48000, 2}); 180 auto dec = factory->MakeAudioDecoder({"opus", 48000, 2});
162 ASSERT_NE(nullptr, dec); 181 ASSERT_NE(nullptr, dec);
163 EXPECT_EQ(48000, dec->SampleRateHz()); 182 EXPECT_EQ(48000, dec->SampleRateHz());
164 } 183 }
165 184
166 } // namespace webrtc 185 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/api/audio_codecs/test/BUILD.gn ('k') | webrtc/api/audio_codecs/test/audio_encoder_factory_template_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698