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

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: Created 4 years, 8 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 EXPECT_FALSE(adf->MakeAudioDecoder(SdpAudioFormat("pcmu", 8000, 0)));
the sun 2016/04/27 20:34:14 It would be good to have documentation along the l
kwiberg-webrtc 2016/04/28 12:35:51 Right. I'll add that.
26 EXPECT_TRUE(adf->MakeAudioDecoder(SdpAudioFormat("pcmu", 8000, 1)));
27 EXPECT_TRUE(adf->MakeAudioDecoder(SdpAudioFormat("pcmu", 8000, 2)));
28 EXPECT_TRUE(adf->MakeAudioDecoder(SdpAudioFormat("pcmu", 8000, 3)));
29 EXPECT_FALSE(adf->MakeAudioDecoder(SdpAudioFormat("pcmu", 16000, 1)));
30 }
31
32 TEST(AudioDecoderFactoryTest, CreatePcma) {
33 std::unique_ptr<AudioDecoderFactory> adf = CreateBuiltinAudioDecoderFactory();
34 ASSERT_TRUE(adf);
35 EXPECT_FALSE(adf->MakeAudioDecoder(SdpAudioFormat("pcma", 8000, 0)));
36 EXPECT_TRUE(adf->MakeAudioDecoder(SdpAudioFormat("pcma", 8000, 1)));
37 EXPECT_TRUE(adf->MakeAudioDecoder(SdpAudioFormat("pcma", 8000, 2)));
38 EXPECT_TRUE(adf->MakeAudioDecoder(SdpAudioFormat("pcma", 8000, 3)));
39 EXPECT_FALSE(adf->MakeAudioDecoder(SdpAudioFormat("pcma", 16000, 1)));
40 }
41
42 TEST(AudioDecoderFactoryTest, CreateIlbc) {
43 std::unique_ptr<AudioDecoderFactory> adf = CreateBuiltinAudioDecoderFactory();
44 ASSERT_TRUE(adf);
45 EXPECT_FALSE(adf->MakeAudioDecoder(SdpAudioFormat("ilbc", 8000, 0)));
46 EXPECT_TRUE(adf->MakeAudioDecoder(SdpAudioFormat("ilbc", 8000, 1)));
47 EXPECT_FALSE(adf->MakeAudioDecoder(SdpAudioFormat("ilbc", 8000, 2)));
48 EXPECT_FALSE(adf->MakeAudioDecoder(SdpAudioFormat("ilbc", 16000, 1)));
49 }
50
51 TEST(AudioDecoderFactoryTest, CreateIsac) {
52 std::unique_ptr<AudioDecoderFactory> adf = CreateBuiltinAudioDecoderFactory();
53 ASSERT_TRUE(adf);
54 EXPECT_FALSE(adf->MakeAudioDecoder(SdpAudioFormat("isac", 16000, 0)));
55 EXPECT_TRUE(adf->MakeAudioDecoder(SdpAudioFormat("isac", 16000, 1)));
56 EXPECT_FALSE(adf->MakeAudioDecoder(SdpAudioFormat("isac", 16000, 2)));
57 EXPECT_FALSE(adf->MakeAudioDecoder(SdpAudioFormat("isac", 8000, 1)));
58 EXPECT_FALSE(adf->MakeAudioDecoder(SdpAudioFormat("isac", 48000, 1)));
the sun 2016/04/27 20:34:14 ch count 3?
kwiberg-webrtc 2016/04/28 12:35:51 I already test that 2 doesn't work. If I'm gonna t
59 #ifdef WEBRTC_ARCH_ARM
60 EXPECT_FALSE(adf->MakeAudioDecoder(SdpAudioFormat("isac", 32000, 1)));
61 #else
62 EXPECT_TRUE(adf->MakeAudioDecoder(SdpAudioFormat("isac", 32000, 1)));
63 #endif
64 }
65
66 TEST(AudioDecoderFactoryTest, CreateL16) {
67 std::unique_ptr<AudioDecoderFactory> adf = CreateBuiltinAudioDecoderFactory();
68 ASSERT_TRUE(adf);
69 const int clockrates[] = {8000, 16000, 32000, 48000};
70 for (int clockrate : clockrates) {
71 EXPECT_FALSE(adf->MakeAudioDecoder(SdpAudioFormat("l16", clockrate, 0)));
72 for (int channels = 1; channels < 10; ++channels) {
the sun 2016/04/27 20:34:14 Do we really need to test all channel counts? Can
kwiberg-webrtc 2016/04/28 12:35:51 Sure, that's probably fine. Will do.
73 EXPECT_TRUE(
74 adf->MakeAudioDecoder(SdpAudioFormat("l16", clockrate, channels)));
75 }
76 }
77 }
78
79 TEST(AudioDecoderFactoryTest, CreateG722) {
80 std::unique_ptr<AudioDecoderFactory> adf = CreateBuiltinAudioDecoderFactory();
81 ASSERT_TRUE(adf);
82 EXPECT_FALSE(adf->MakeAudioDecoder(SdpAudioFormat("g722", 8000, 0)));
83 EXPECT_TRUE(adf->MakeAudioDecoder(SdpAudioFormat("g722", 8000, 1)));
84 EXPECT_TRUE(adf->MakeAudioDecoder(SdpAudioFormat("g722", 8000, 2)));
85 EXPECT_FALSE(adf->MakeAudioDecoder(SdpAudioFormat("g722", 8000, 3)));
86 EXPECT_FALSE(adf->MakeAudioDecoder(SdpAudioFormat("g722", 16000, 1)));
87 EXPECT_FALSE(adf->MakeAudioDecoder(SdpAudioFormat("g722", 32000, 1)));
88 }
89
90 TEST(AudioDecoderFactoryTest, CreateOpus) {
91 std::unique_ptr<AudioDecoderFactory> adf = CreateBuiltinAudioDecoderFactory();
92 ASSERT_TRUE(adf);
93 EXPECT_FALSE(adf->MakeAudioDecoder(SdpAudioFormat("opus", 48000, 0)));
94 EXPECT_TRUE(adf->MakeAudioDecoder(SdpAudioFormat("opus", 48000, 1)));
95 EXPECT_TRUE(adf->MakeAudioDecoder(SdpAudioFormat("opus", 48000, 2)));
96 EXPECT_FALSE(adf->MakeAudioDecoder(SdpAudioFormat("opus", 48000, 3)));
97 EXPECT_FALSE(adf->MakeAudioDecoder(SdpAudioFormat("opus", 8000, 1)));
98 EXPECT_FALSE(adf->MakeAudioDecoder(SdpAudioFormat("opus", 16000, 1)));
99 EXPECT_FALSE(adf->MakeAudioDecoder(SdpAudioFormat("opus", 32000, 1)));
100 }
101
102 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698