OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2016 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 |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 | 48 |
49 TEST(AudioDecoderFactoryTest, CreateIlbc) { | 49 TEST(AudioDecoderFactoryTest, CreateIlbc) { |
50 rtc::scoped_refptr<AudioDecoderFactory> adf = | 50 rtc::scoped_refptr<AudioDecoderFactory> adf = |
51 CreateBuiltinAudioDecoderFactory(); | 51 CreateBuiltinAudioDecoderFactory(); |
52 ASSERT_TRUE(adf); | 52 ASSERT_TRUE(adf); |
53 // iLBC supports 8 kHz, 1 channel. | 53 // iLBC supports 8 kHz, 1 channel. |
54 EXPECT_FALSE(adf->MakeAudioDecoder(SdpAudioFormat("ilbc", 8000, 0))); | 54 EXPECT_FALSE(adf->MakeAudioDecoder(SdpAudioFormat("ilbc", 8000, 0))); |
55 EXPECT_TRUE(adf->MakeAudioDecoder(SdpAudioFormat("ilbc", 8000, 1))); | 55 EXPECT_TRUE(adf->MakeAudioDecoder(SdpAudioFormat("ilbc", 8000, 1))); |
56 EXPECT_FALSE(adf->MakeAudioDecoder(SdpAudioFormat("ilbc", 8000, 2))); | 56 EXPECT_FALSE(adf->MakeAudioDecoder(SdpAudioFormat("ilbc", 8000, 2))); |
57 EXPECT_FALSE(adf->MakeAudioDecoder(SdpAudioFormat("ilbc", 16000, 1))); | 57 EXPECT_FALSE(adf->MakeAudioDecoder(SdpAudioFormat("ilbc", 16000, 1))); |
58 | |
59 // iLBC actually uses a 16 kHz sample rate instead of the nominal 8 kHz. | |
60 // TODO(kwiberg): Uncomment this once AudioDecoder has a SampleRateHz method. | |
61 // std::unique_ptr<AudioDecoder> dec = | |
62 // adf->MakeAudioDecoder(SdpAudioFormat("ilbc", 8000, 1)); | |
63 // EXPECT_EQ(16000, dec->SampleRateHz()); | |
64 } | 58 } |
65 | 59 |
66 TEST(AudioDecoderFactoryTest, CreateIsac) { | 60 TEST(AudioDecoderFactoryTest, CreateIsac) { |
67 rtc::scoped_refptr<AudioDecoderFactory> adf = | 61 rtc::scoped_refptr<AudioDecoderFactory> adf = |
68 CreateBuiltinAudioDecoderFactory(); | 62 CreateBuiltinAudioDecoderFactory(); |
69 ASSERT_TRUE(adf); | 63 ASSERT_TRUE(adf); |
70 // iSAC supports 16 kHz, 1 channel. The float implementation additionally | 64 // iSAC supports 16 kHz, 1 channel. The float implementation additionally |
71 // supports 32 kHz, 1 channel. | 65 // supports 32 kHz, 1 channel. |
72 EXPECT_FALSE(adf->MakeAudioDecoder(SdpAudioFormat("isac", 16000, 0))); | 66 EXPECT_FALSE(adf->MakeAudioDecoder(SdpAudioFormat("isac", 16000, 0))); |
73 EXPECT_TRUE(adf->MakeAudioDecoder(SdpAudioFormat("isac", 16000, 1))); | 67 EXPECT_TRUE(adf->MakeAudioDecoder(SdpAudioFormat("isac", 16000, 1))); |
(...skipping 27 matching lines...) Expand all Loading... |
101 rtc::scoped_refptr<AudioDecoderFactory> adf = | 95 rtc::scoped_refptr<AudioDecoderFactory> adf = |
102 CreateBuiltinAudioDecoderFactory(); | 96 CreateBuiltinAudioDecoderFactory(); |
103 ASSERT_TRUE(adf); | 97 ASSERT_TRUE(adf); |
104 // g722 supports 8 kHz, 1-2 channels. | 98 // g722 supports 8 kHz, 1-2 channels. |
105 EXPECT_FALSE(adf->MakeAudioDecoder(SdpAudioFormat("g722", 8000, 0))); | 99 EXPECT_FALSE(adf->MakeAudioDecoder(SdpAudioFormat("g722", 8000, 0))); |
106 EXPECT_TRUE(adf->MakeAudioDecoder(SdpAudioFormat("g722", 8000, 1))); | 100 EXPECT_TRUE(adf->MakeAudioDecoder(SdpAudioFormat("g722", 8000, 1))); |
107 EXPECT_TRUE(adf->MakeAudioDecoder(SdpAudioFormat("g722", 8000, 2))); | 101 EXPECT_TRUE(adf->MakeAudioDecoder(SdpAudioFormat("g722", 8000, 2))); |
108 EXPECT_FALSE(adf->MakeAudioDecoder(SdpAudioFormat("g722", 8000, 3))); | 102 EXPECT_FALSE(adf->MakeAudioDecoder(SdpAudioFormat("g722", 8000, 3))); |
109 EXPECT_FALSE(adf->MakeAudioDecoder(SdpAudioFormat("g722", 16000, 1))); | 103 EXPECT_FALSE(adf->MakeAudioDecoder(SdpAudioFormat("g722", 16000, 1))); |
110 EXPECT_FALSE(adf->MakeAudioDecoder(SdpAudioFormat("g722", 32000, 1))); | 104 EXPECT_FALSE(adf->MakeAudioDecoder(SdpAudioFormat("g722", 32000, 1))); |
| 105 |
| 106 // g722 actually uses a 16 kHz sample rate instead of the nominal 8 kHz. |
| 107 std::unique_ptr<AudioDecoder> dec = |
| 108 adf->MakeAudioDecoder(SdpAudioFormat("g722", 8000, 1)); |
| 109 EXPECT_EQ(16000, dec->SampleRateHz()); |
111 } | 110 } |
112 | 111 |
113 TEST(AudioDecoderFactoryTest, CreateOpus) { | 112 TEST(AudioDecoderFactoryTest, CreateOpus) { |
114 rtc::scoped_refptr<AudioDecoderFactory> adf = | 113 rtc::scoped_refptr<AudioDecoderFactory> adf = |
115 CreateBuiltinAudioDecoderFactory(); | 114 CreateBuiltinAudioDecoderFactory(); |
116 ASSERT_TRUE(adf); | 115 ASSERT_TRUE(adf); |
117 // Opus supports 48 kHz, 2 channels, and wants a "stereo" parameter whose | 116 // Opus supports 48 kHz, 2 channels, and wants a "stereo" parameter whose |
118 // value is either "0" or "1". | 117 // value is either "0" or "1". |
119 for (int hz : {8000, 16000, 32000, 48000}) { | 118 for (int hz : {8000, 16000, 32000, 48000}) { |
120 for (int channels : {0, 1, 2, 3}) { | 119 for (int channels : {0, 1, 2, 3}) { |
121 for (std::string stereo : {"XX", "0", "1", "2"}) { | 120 for (std::string stereo : {"XX", "0", "1", "2"}) { |
122 std::map<std::string, std::string> params; | 121 std::map<std::string, std::string> params; |
123 if (stereo != "XX") { | 122 if (stereo != "XX") { |
124 params["stereo"] = stereo; | 123 params["stereo"] = stereo; |
125 } | 124 } |
126 bool good = | 125 bool good = |
127 (hz == 48000 && channels == 2 && (stereo == "0" || stereo == "1")); | 126 (hz == 48000 && channels == 2 && (stereo == "0" || stereo == "1")); |
128 EXPECT_EQ(good, static_cast<bool>(adf->MakeAudioDecoder(SdpAudioFormat( | 127 EXPECT_EQ(good, static_cast<bool>(adf->MakeAudioDecoder(SdpAudioFormat( |
129 "opus", hz, channels, std::move(params))))); | 128 "opus", hz, channels, std::move(params))))); |
130 } | 129 } |
131 } | 130 } |
132 } | 131 } |
133 } | 132 } |
134 | 133 |
135 } // namespace webrtc | 134 } // namespace webrtc |
OLD | NEW |