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

Side by Side Diff: webrtc/modules/audio_coding/codecs/audio_decoder_factory_unittest.cc

Issue 1917163002: New interface (AudioDecoderFactory), with an implementation (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: review Created 4 years, 7 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
(Empty)
1 /*
2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved.
3 *
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
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
11 #include "testing/gtest/include/gtest/gtest.h"
12 #include "webrtc/modules/audio_coding/codecs/builtin_audio_decoder_factory.h"
13
14 namespace webrtc {
15
16 TEST(AudioDecoderFactoryTest, CreateUnknownDecoder) {
17 std::unique_ptr<AudioDecoderFactory> adf = CreateBuiltinAudioDecoderFactory();
18 ASSERT_TRUE(adf);
19 EXPECT_FALSE(adf->MakeAudioDecoder(SdpAudioFormat("rey", 8000, 1)));
20 }
21
22 TEST(AudioDecoderFactoryTest, CreatePcmu) {
23 std::unique_ptr<AudioDecoderFactory> adf = CreateBuiltinAudioDecoderFactory();
24 ASSERT_TRUE(adf);
25 // PCMu supports 8 kHz, and any number of channels.
26 EXPECT_FALSE(adf->MakeAudioDecoder(SdpAudioFormat("pcmu", 8000, 0)));
27 EXPECT_TRUE(adf->MakeAudioDecoder(SdpAudioFormat("pcmu", 8000, 1)));
28 EXPECT_TRUE(adf->MakeAudioDecoder(SdpAudioFormat("pcmu", 8000, 2)));
29 EXPECT_TRUE(adf->MakeAudioDecoder(SdpAudioFormat("pcmu", 8000, 3)));
30 EXPECT_FALSE(adf->MakeAudioDecoder(SdpAudioFormat("pcmu", 16000, 1)));
31 }
32
33 TEST(AudioDecoderFactoryTest, CreatePcma) {
34 std::unique_ptr<AudioDecoderFactory> adf = CreateBuiltinAudioDecoderFactory();
35 ASSERT_TRUE(adf);
36 // PCMa supports 8 kHz, and any number of channels.
37 EXPECT_FALSE(adf->MakeAudioDecoder(SdpAudioFormat("pcma", 8000, 0)));
38 EXPECT_TRUE(adf->MakeAudioDecoder(SdpAudioFormat("pcma", 8000, 1)));
39 EXPECT_TRUE(adf->MakeAudioDecoder(SdpAudioFormat("pcma", 8000, 2)));
40 EXPECT_TRUE(adf->MakeAudioDecoder(SdpAudioFormat("pcma", 8000, 3)));
41 EXPECT_FALSE(adf->MakeAudioDecoder(SdpAudioFormat("pcma", 16000, 1)));
42 }
43
44 TEST(AudioDecoderFactoryTest, CreateIlbc) {
45 std::unique_ptr<AudioDecoderFactory> adf = CreateBuiltinAudioDecoderFactory();
46 ASSERT_TRUE(adf);
47 // iLBC supports 8 kHz, 1 channel.
48 EXPECT_FALSE(adf->MakeAudioDecoder(SdpAudioFormat("ilbc", 8000, 0)));
49 EXPECT_TRUE(adf->MakeAudioDecoder(SdpAudioFormat("ilbc", 8000, 1)));
50 EXPECT_FALSE(adf->MakeAudioDecoder(SdpAudioFormat("ilbc", 8000, 2)));
51 EXPECT_FALSE(adf->MakeAudioDecoder(SdpAudioFormat("ilbc", 16000, 1)));
52
53 // iLBC actually uses a 16 kHz sample rate instead of the nominal 8 kHz.
54 // TODO(kwiberg): Uncomment this once AudioDecoder has a SampleRateHz method.
55 // std::unique_ptr<AudioDecoder> dec =
56 // adf->MakeAudioDecoder(SdpAudioFormat("ilbc", 8000, 1));
57 // EXPECT_EQ(16000, dec->SampleRateHz());
58 }
59
60 TEST(AudioDecoderFactoryTest, CreateIsac) {
61 std::unique_ptr<AudioDecoderFactory> adf = CreateBuiltinAudioDecoderFactory();
62 ASSERT_TRUE(adf);
63 // iSAC supports 16 kHz, 1 channel. The float implementation additionally
64 // supports 32 kHz, 1 channel.
65 EXPECT_FALSE(adf->MakeAudioDecoder(SdpAudioFormat("isac", 16000, 0)));
66 EXPECT_TRUE(adf->MakeAudioDecoder(SdpAudioFormat("isac", 16000, 1)));
67 EXPECT_FALSE(adf->MakeAudioDecoder(SdpAudioFormat("isac", 16000, 2)));
68 EXPECT_FALSE(adf->MakeAudioDecoder(SdpAudioFormat("isac", 8000, 1)));
69 EXPECT_FALSE(adf->MakeAudioDecoder(SdpAudioFormat("isac", 48000, 1)));
70 #ifdef WEBRTC_ARCH_ARM
71 EXPECT_FALSE(adf->MakeAudioDecoder(SdpAudioFormat("isac", 32000, 1)));
72 #else
73 EXPECT_TRUE(adf->MakeAudioDecoder(SdpAudioFormat("isac", 32000, 1)));
74 #endif
75 }
76
77 TEST(AudioDecoderFactoryTest, CreateL16) {
78 std::unique_ptr<AudioDecoderFactory> adf = CreateBuiltinAudioDecoderFactory();
79 ASSERT_TRUE(adf);
80 // L16 supports any clock rate, any number of channels.
81 const int clockrates[] = {8000, 16000, 32000, 48000};
82 const int num_channels[] = {1, 2, 3, 4711};
83 for (int clockrate : clockrates) {
84 EXPECT_FALSE(adf->MakeAudioDecoder(SdpAudioFormat("l16", clockrate, 0)));
85 for (int channels : num_channels) {
86 EXPECT_TRUE(
87 adf->MakeAudioDecoder(SdpAudioFormat("l16", clockrate, channels)));
88 }
89 }
90 }
91
92 TEST(AudioDecoderFactoryTest, CreateG722) {
93 std::unique_ptr<AudioDecoderFactory> adf = CreateBuiltinAudioDecoderFactory();
94 ASSERT_TRUE(adf);
95 // g722 supports 8 kHz, 1-2 channels.
96 EXPECT_FALSE(adf->MakeAudioDecoder(SdpAudioFormat("g722", 8000, 0)));
97 EXPECT_TRUE(adf->MakeAudioDecoder(SdpAudioFormat("g722", 8000, 1)));
98 EXPECT_TRUE(adf->MakeAudioDecoder(SdpAudioFormat("g722", 8000, 2)));
99 EXPECT_FALSE(adf->MakeAudioDecoder(SdpAudioFormat("g722", 8000, 3)));
100 EXPECT_FALSE(adf->MakeAudioDecoder(SdpAudioFormat("g722", 16000, 1)));
101 EXPECT_FALSE(adf->MakeAudioDecoder(SdpAudioFormat("g722", 32000, 1)));
102 }
103
104 TEST(AudioDecoderFactoryTest, CreateOpus) {
105 std::unique_ptr<AudioDecoderFactory> adf = CreateBuiltinAudioDecoderFactory();
106 ASSERT_TRUE(adf);
107 // Opus supports 48 kHz, 1-2 channels.
108 EXPECT_FALSE(adf->MakeAudioDecoder(SdpAudioFormat("opus", 48000, 0)));
109 EXPECT_TRUE(adf->MakeAudioDecoder(SdpAudioFormat("opus", 48000, 1)));
110 EXPECT_TRUE(adf->MakeAudioDecoder(SdpAudioFormat("opus", 48000, 2)));
111 EXPECT_FALSE(adf->MakeAudioDecoder(SdpAudioFormat("opus", 48000, 3)));
112 EXPECT_FALSE(adf->MakeAudioDecoder(SdpAudioFormat("opus", 8000, 1)));
113 EXPECT_FALSE(adf->MakeAudioDecoder(SdpAudioFormat("opus", 16000, 1)));
114 EXPECT_FALSE(adf->MakeAudioDecoder(SdpAudioFormat("opus", 32000, 1)));
115 }
116
117 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/audio_coding/codecs/audio_decoder_factory.h ('k') | webrtc/modules/audio_coding/codecs/audio_format.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698