OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2009 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2009 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/base/gunit.h" | 11 #include "webrtc/base/gunit.h" |
12 #include "webrtc/media/base/codec.h" | 12 #include "webrtc/media/base/codec.h" |
13 | 13 |
14 using cricket::AudioCodec; | 14 using cricket::AudioCodec; |
15 using cricket::Codec; | 15 using cricket::Codec; |
16 using cricket::DataCodec; | 16 using cricket::DataCodec; |
17 using cricket::FeedbackParam; | 17 using cricket::FeedbackParam; |
18 using cricket::VideoCodec; | 18 using cricket::VideoCodec; |
19 using cricket::kCodecParamAssociatedPayloadType; | 19 using cricket::kCodecParamAssociatedPayloadType; |
20 using cricket::kCodecParamMaxBitrate; | 20 using cricket::kCodecParamMaxBitrate; |
21 using cricket::kCodecParamMinBitrate; | 21 using cricket::kCodecParamMinBitrate; |
22 | 22 |
23 TEST(CodecTest, TestCodecOperators) { | 23 class CodecTest : public testing::Test { |
| 24 public: |
| 25 CodecTest() {} |
| 26 }; |
| 27 |
| 28 TEST_F(CodecTest, TestCodecOperators) { |
24 Codec c0(96, "D", 1000); | 29 Codec c0(96, "D", 1000); |
25 c0.SetParam("a", 1); | 30 c0.SetParam("a", 1); |
26 | 31 |
27 Codec c1 = c0; | 32 Codec c1 = c0; |
28 EXPECT_TRUE(c1 == c0); | 33 EXPECT_TRUE(c1 == c0); |
29 | 34 |
30 int param_value0; | 35 int param_value0; |
31 int param_value1; | 36 int param_value1; |
32 EXPECT_TRUE(c0.GetParam("a", ¶m_value0)); | 37 EXPECT_TRUE(c0.GetParam("a", ¶m_value0)); |
33 EXPECT_TRUE(c1.GetParam("a", ¶m_value1)); | 38 EXPECT_TRUE(c1.GetParam("a", ¶m_value1)); |
(...skipping 12 matching lines...) Expand all Loading... |
46 | 51 |
47 c1 = c0; | 52 c1 = c0; |
48 c1.SetParam("a", 2); | 53 c1.SetParam("a", 2); |
49 EXPECT_TRUE(c0 != c1); | 54 EXPECT_TRUE(c0 != c1); |
50 | 55 |
51 Codec c5; | 56 Codec c5; |
52 Codec c6(0, "", 0); | 57 Codec c6(0, "", 0); |
53 EXPECT_TRUE(c5 == c6); | 58 EXPECT_TRUE(c5 == c6); |
54 } | 59 } |
55 | 60 |
56 TEST(CodecTest, TestAudioCodecOperators) { | 61 TEST_F(CodecTest, TestAudioCodecOperators) { |
57 AudioCodec c0(96, "A", 44100, 20000, 2); | 62 AudioCodec c0(96, "A", 44100, 20000, 2); |
58 AudioCodec c1(95, "A", 44100, 20000, 2); | 63 AudioCodec c1(95, "A", 44100, 20000, 2); |
59 AudioCodec c2(96, "x", 44100, 20000, 2); | 64 AudioCodec c2(96, "x", 44100, 20000, 2); |
60 AudioCodec c3(96, "A", 48000, 20000, 2); | 65 AudioCodec c3(96, "A", 48000, 20000, 2); |
61 AudioCodec c4(96, "A", 44100, 10000, 2); | 66 AudioCodec c4(96, "A", 44100, 10000, 2); |
62 AudioCodec c5(96, "A", 44100, 20000, 1); | 67 AudioCodec c5(96, "A", 44100, 20000, 1); |
63 EXPECT_TRUE(c0 != c1); | 68 EXPECT_TRUE(c0 != c1); |
64 EXPECT_TRUE(c0 != c2); | 69 EXPECT_TRUE(c0 != c2); |
65 EXPECT_TRUE(c0 != c3); | 70 EXPECT_TRUE(c0 != c3); |
66 EXPECT_TRUE(c0 != c4); | 71 EXPECT_TRUE(c0 != c4); |
(...skipping 16 matching lines...) Expand all Loading... |
83 c13.params["x"] = "abc"; | 88 c13.params["x"] = "abc"; |
84 EXPECT_TRUE(c10 != c0); | 89 EXPECT_TRUE(c10 != c0); |
85 EXPECT_TRUE(c11 != c0); | 90 EXPECT_TRUE(c11 != c0); |
86 EXPECT_TRUE(c11 != c10); | 91 EXPECT_TRUE(c11 != c10); |
87 EXPECT_TRUE(c12 != c0); | 92 EXPECT_TRUE(c12 != c0); |
88 EXPECT_TRUE(c12 != c10); | 93 EXPECT_TRUE(c12 != c10); |
89 EXPECT_TRUE(c12 != c11); | 94 EXPECT_TRUE(c12 != c11); |
90 EXPECT_TRUE(c13 == c10); | 95 EXPECT_TRUE(c13 == c10); |
91 } | 96 } |
92 | 97 |
93 TEST(CodecTest, TestAudioCodecMatches) { | 98 TEST_F(CodecTest, TestAudioCodecMatches) { |
94 // Test a codec with a static payload type. | 99 // Test a codec with a static payload type. |
95 AudioCodec c0(95, "A", 44100, 20000, 1); | 100 AudioCodec c0(95, "A", 44100, 20000, 1); |
96 EXPECT_TRUE(c0.Matches(AudioCodec(95, "", 44100, 20000, 1))); | 101 EXPECT_TRUE(c0.Matches(AudioCodec(95, "", 44100, 20000, 1))); |
97 EXPECT_TRUE(c0.Matches(AudioCodec(95, "", 44100, 20000, 0))); | 102 EXPECT_TRUE(c0.Matches(AudioCodec(95, "", 44100, 20000, 0))); |
98 EXPECT_TRUE(c0.Matches(AudioCodec(95, "", 44100, 0, 0))); | 103 EXPECT_TRUE(c0.Matches(AudioCodec(95, "", 44100, 0, 0))); |
99 EXPECT_TRUE(c0.Matches(AudioCodec(95, "", 0, 0, 0))); | 104 EXPECT_TRUE(c0.Matches(AudioCodec(95, "", 0, 0, 0))); |
100 EXPECT_FALSE(c0.Matches(AudioCodec(96, "", 44100, 20000, 1))); | 105 EXPECT_FALSE(c0.Matches(AudioCodec(96, "", 44100, 20000, 1))); |
101 EXPECT_FALSE(c0.Matches(AudioCodec(95, "", 55100, 20000, 1))); | 106 EXPECT_FALSE(c0.Matches(AudioCodec(95, "", 55100, 20000, 1))); |
102 EXPECT_FALSE(c0.Matches(AudioCodec(95, "", 44100, 30000, 1))); | 107 EXPECT_FALSE(c0.Matches(AudioCodec(95, "", 44100, 30000, 1))); |
103 EXPECT_FALSE(c0.Matches(AudioCodec(95, "", 44100, 20000, 2))); | 108 EXPECT_FALSE(c0.Matches(AudioCodec(95, "", 44100, 20000, 2))); |
(...skipping 19 matching lines...) Expand all Loading... |
123 // Backward compatibility with clients that might send "-1" (for default). | 128 // Backward compatibility with clients that might send "-1" (for default). |
124 EXPECT_TRUE(c2.Matches(AudioCodec(97, "A", 16000, -1, 1))); | 129 EXPECT_TRUE(c2.Matches(AudioCodec(97, "A", 16000, -1, 1))); |
125 | 130 |
126 // Stereo doesn't match channels = 0. | 131 // Stereo doesn't match channels = 0. |
127 AudioCodec c3(96, "A", 44100, 20000, 2); | 132 AudioCodec c3(96, "A", 44100, 20000, 2); |
128 EXPECT_TRUE(c3.Matches(AudioCodec(96, "A", 44100, 20000, 2))); | 133 EXPECT_TRUE(c3.Matches(AudioCodec(96, "A", 44100, 20000, 2))); |
129 EXPECT_FALSE(c3.Matches(AudioCodec(96, "A", 44100, 20000, 1))); | 134 EXPECT_FALSE(c3.Matches(AudioCodec(96, "A", 44100, 20000, 1))); |
130 EXPECT_FALSE(c3.Matches(AudioCodec(96, "A", 44100, 20000, 0))); | 135 EXPECT_FALSE(c3.Matches(AudioCodec(96, "A", 44100, 20000, 0))); |
131 } | 136 } |
132 | 137 |
133 TEST(CodecTest, TestVideoCodecOperators) { | 138 TEST_F(CodecTest, TestVideoCodecOperators) { |
134 VideoCodec c0(96, "V"); | 139 VideoCodec c0(96, "V"); |
135 VideoCodec c1(95, "V"); | 140 VideoCodec c1(95, "V"); |
136 VideoCodec c2(96, "x"); | 141 VideoCodec c2(96, "x"); |
137 | 142 |
138 EXPECT_TRUE(c0 != c1); | 143 EXPECT_TRUE(c0 != c1); |
139 EXPECT_TRUE(c0 != c2); | 144 EXPECT_TRUE(c0 != c2); |
140 | 145 |
141 VideoCodec c7; | 146 VideoCodec c7; |
142 VideoCodec c8(0, ""); | 147 VideoCodec c8(0, ""); |
143 VideoCodec c9 = c0; | 148 VideoCodec c9 = c0; |
(...skipping 11 matching lines...) Expand all Loading... |
155 c13.params["x"] = "abc"; | 160 c13.params["x"] = "abc"; |
156 EXPECT_TRUE(c10 != c0); | 161 EXPECT_TRUE(c10 != c0); |
157 EXPECT_TRUE(c11 != c0); | 162 EXPECT_TRUE(c11 != c0); |
158 EXPECT_TRUE(c11 != c10); | 163 EXPECT_TRUE(c11 != c10); |
159 EXPECT_TRUE(c12 != c0); | 164 EXPECT_TRUE(c12 != c0); |
160 EXPECT_TRUE(c12 != c10); | 165 EXPECT_TRUE(c12 != c10); |
161 EXPECT_TRUE(c12 != c11); | 166 EXPECT_TRUE(c12 != c11); |
162 EXPECT_TRUE(c13 == c10); | 167 EXPECT_TRUE(c13 == c10); |
163 } | 168 } |
164 | 169 |
165 TEST(CodecTest, TestVideoCodecMatches) { | 170 TEST_F(CodecTest, TestVideoCodecMatches) { |
166 // Test a codec with a static payload type. | 171 // Test a codec with a static payload type. |
167 VideoCodec c0(95, "V"); | 172 VideoCodec c0(95, "V"); |
168 EXPECT_TRUE(c0.Matches(VideoCodec(95, ""))); | 173 EXPECT_TRUE(c0.Matches(VideoCodec(95, ""))); |
169 EXPECT_FALSE(c0.Matches(VideoCodec(96, ""))); | 174 EXPECT_FALSE(c0.Matches(VideoCodec(96, ""))); |
170 | 175 |
171 // Test a codec with a dynamic payload type. | 176 // Test a codec with a dynamic payload type. |
172 VideoCodec c1(96, "V"); | 177 VideoCodec c1(96, "V"); |
173 EXPECT_TRUE(c1.Matches(VideoCodec(96, "V"))); | 178 EXPECT_TRUE(c1.Matches(VideoCodec(96, "V"))); |
174 EXPECT_TRUE(c1.Matches(VideoCodec(97, "V"))); | 179 EXPECT_TRUE(c1.Matches(VideoCodec(97, "V"))); |
175 EXPECT_TRUE(c1.Matches(VideoCodec(96, "v"))); | 180 EXPECT_TRUE(c1.Matches(VideoCodec(96, "v"))); |
176 EXPECT_TRUE(c1.Matches(VideoCodec(97, "v"))); | 181 EXPECT_TRUE(c1.Matches(VideoCodec(97, "v"))); |
177 EXPECT_FALSE(c1.Matches(VideoCodec(96, ""))); | 182 EXPECT_FALSE(c1.Matches(VideoCodec(96, ""))); |
178 EXPECT_FALSE(c1.Matches(VideoCodec(95, "V"))); | 183 EXPECT_FALSE(c1.Matches(VideoCodec(95, "V"))); |
179 } | 184 } |
180 | 185 |
181 TEST(CodecTest, TestVideoCodecMatchesH264Baseline) { | |
182 const VideoCodec no_params(96, cricket::kH264CodecName); | |
183 | |
184 VideoCodec baseline(96, cricket::kH264CodecName); | |
185 baseline.SetParam(cricket::kH264FmtpProfileLevelId, | |
186 cricket::kH264FmtpDefaultProfileLevelId); | |
187 | |
188 EXPECT_TRUE(baseline.Matches(baseline)); | |
189 EXPECT_TRUE(baseline.Matches(no_params)); | |
190 EXPECT_TRUE(no_params.Matches(baseline)); | |
191 EXPECT_TRUE(no_params.Matches(no_params)); | |
192 } | |
193 | |
194 TEST(CodecTest, TestVideoCodecMatchesH264Profiles) { | |
195 VideoCodec baseline(96, cricket::kH264CodecName); | |
196 baseline.SetParam(cricket::kH264FmtpProfileLevelId, | |
197 cricket::kH264FmtpDefaultProfileLevelId); | |
198 baseline.SetParam(cricket::kH264FmtpLevelAsymmetryAllowed, "1"); | |
199 | |
200 VideoCodec constrained_baseline(96, cricket::kH264CodecName); | |
201 constrained_baseline.SetParam(cricket::kH264FmtpProfileLevelId, | |
202 cricket::kH264ProfileLevelConstrainedBaseline); | |
203 constrained_baseline.SetParam(cricket::kH264FmtpLevelAsymmetryAllowed, "1"); | |
204 | |
205 EXPECT_TRUE(baseline.Matches(baseline)); | |
206 EXPECT_FALSE(baseline.Matches(constrained_baseline)); | |
207 EXPECT_FALSE(constrained_baseline.Matches(baseline)); | |
208 EXPECT_TRUE(constrained_baseline.Matches(constrained_baseline)); | |
209 } | |
210 | |
211 TEST(CodecTest, TestVideoCodecMatchesH264LevelAsymmetry) { | |
212 // Constrained Baseline Profile Level 1.0. | |
213 VideoCodec cbp_1_0(96, cricket::kH264CodecName); | |
214 cbp_1_0.SetParam(cricket::kH264FmtpProfileLevelId, | |
215 "42e00a"); | |
216 | |
217 VideoCodec cbp_1_0_asymmetry_allowed = cbp_1_0; | |
218 cbp_1_0_asymmetry_allowed.SetParam(cricket::kH264FmtpLevelAsymmetryAllowed, | |
219 "1"); | |
220 | |
221 // Constrained Baseline Profile Level 3.1. | |
222 VideoCodec cbp_3_1(96, cricket::kH264CodecName); | |
223 cbp_3_1.SetParam(cricket::kH264FmtpProfileLevelId, "42e01f"); | |
224 | |
225 VideoCodec cbp_3_1_asymmetry_allowed = cbp_3_1; | |
226 cbp_3_1_asymmetry_allowed.SetParam(cricket::kH264FmtpLevelAsymmetryAllowed, | |
227 "1"); | |
228 | |
229 // It's ok to differ in level-asymmetry-allowed param as long as the level is | |
230 // the same. | |
231 EXPECT_TRUE(cbp_1_0.Matches(cbp_1_0_asymmetry_allowed)); | |
232 EXPECT_TRUE(cbp_3_1.Matches(cbp_3_1_asymmetry_allowed)); | |
233 | |
234 // Both codecs need to accept level asymmetry if levels differ. | |
235 EXPECT_FALSE(cbp_1_0.Matches(cbp_3_1_asymmetry_allowed)); | |
236 EXPECT_FALSE(cbp_1_0_asymmetry_allowed.Matches(cbp_3_1)); | |
237 EXPECT_TRUE(cbp_1_0_asymmetry_allowed.Matches(cbp_3_1_asymmetry_allowed)); | |
238 | |
239 // Test explicitly disabling level asymmetry. It should have the same behavior | |
240 // as missing the param. | |
241 cbp_1_0.SetParam(cricket::kH264FmtpLevelAsymmetryAllowed, "0"); | |
242 EXPECT_TRUE(cbp_1_0.Matches(cbp_1_0_asymmetry_allowed)); | |
243 EXPECT_FALSE(cbp_1_0.Matches(cbp_3_1_asymmetry_allowed)); | |
244 } | |
245 | |
246 TEST(CodecTest, TestDataCodecMatches) { | 186 TEST(CodecTest, TestDataCodecMatches) { |
247 // Test a codec with a static payload type. | 187 // Test a codec with a static payload type. |
248 DataCodec c0(95, "D"); | 188 DataCodec c0(95, "D"); |
249 EXPECT_TRUE(c0.Matches(DataCodec(95, ""))); | 189 EXPECT_TRUE(c0.Matches(DataCodec(95, ""))); |
250 EXPECT_FALSE(c0.Matches(DataCodec(96, ""))); | 190 EXPECT_FALSE(c0.Matches(DataCodec(96, ""))); |
251 | 191 |
252 // Test a codec with a dynamic payload type. | 192 // Test a codec with a dynamic payload type. |
253 DataCodec c1(96, "D"); | 193 DataCodec c1(96, "D"); |
254 EXPECT_TRUE(c1.Matches(DataCodec(96, "D"))); | 194 EXPECT_TRUE(c1.Matches(DataCodec(96, "D"))); |
255 EXPECT_TRUE(c1.Matches(DataCodec(97, "D"))); | 195 EXPECT_TRUE(c1.Matches(DataCodec(97, "D"))); |
256 EXPECT_TRUE(c1.Matches(DataCodec(96, "d"))); | 196 EXPECT_TRUE(c1.Matches(DataCodec(96, "d"))); |
257 EXPECT_TRUE(c1.Matches(DataCodec(97, "d"))); | 197 EXPECT_TRUE(c1.Matches(DataCodec(97, "d"))); |
258 EXPECT_FALSE(c1.Matches(DataCodec(96, ""))); | 198 EXPECT_FALSE(c1.Matches(DataCodec(96, ""))); |
259 EXPECT_FALSE(c1.Matches(DataCodec(95, "D"))); | 199 EXPECT_FALSE(c1.Matches(DataCodec(95, "D"))); |
260 } | 200 } |
261 | 201 |
262 TEST(CodecTest, TestSetParamGetParamAndRemoveParam) { | 202 TEST_F(CodecTest, TestSetParamGetParamAndRemoveParam) { |
263 AudioCodec codec; | 203 AudioCodec codec; |
264 codec.SetParam("a", "1"); | 204 codec.SetParam("a", "1"); |
265 codec.SetParam("b", "x"); | 205 codec.SetParam("b", "x"); |
266 | 206 |
267 int int_value = 0; | 207 int int_value = 0; |
268 EXPECT_TRUE(codec.GetParam("a", &int_value)); | 208 EXPECT_TRUE(codec.GetParam("a", &int_value)); |
269 EXPECT_EQ(1, int_value); | 209 EXPECT_EQ(1, int_value); |
270 EXPECT_FALSE(codec.GetParam("b", &int_value)); | 210 EXPECT_FALSE(codec.GetParam("b", &int_value)); |
271 EXPECT_FALSE(codec.GetParam("c", &int_value)); | 211 EXPECT_FALSE(codec.GetParam("c", &int_value)); |
272 | 212 |
273 std::string str_value; | 213 std::string str_value; |
274 EXPECT_TRUE(codec.GetParam("a", &str_value)); | 214 EXPECT_TRUE(codec.GetParam("a", &str_value)); |
275 EXPECT_EQ("1", str_value); | 215 EXPECT_EQ("1", str_value); |
276 EXPECT_TRUE(codec.GetParam("b", &str_value)); | 216 EXPECT_TRUE(codec.GetParam("b", &str_value)); |
277 EXPECT_EQ("x", str_value); | 217 EXPECT_EQ("x", str_value); |
278 EXPECT_FALSE(codec.GetParam("c", &str_value)); | 218 EXPECT_FALSE(codec.GetParam("c", &str_value)); |
279 EXPECT_TRUE(codec.RemoveParam("a")); | 219 EXPECT_TRUE(codec.RemoveParam("a")); |
280 EXPECT_FALSE(codec.RemoveParam("c")); | 220 EXPECT_FALSE(codec.RemoveParam("c")); |
281 } | 221 } |
282 | 222 |
283 TEST(CodecTest, TestIntersectFeedbackParams) { | 223 TEST_F(CodecTest, TestIntersectFeedbackParams) { |
284 const FeedbackParam a1("a", "1"); | 224 const FeedbackParam a1("a", "1"); |
285 const FeedbackParam b2("b", "2"); | 225 const FeedbackParam b2("b", "2"); |
286 const FeedbackParam b3("b", "3"); | 226 const FeedbackParam b3("b", "3"); |
287 const FeedbackParam c3("c", "3"); | 227 const FeedbackParam c3("c", "3"); |
288 Codec c1; | 228 Codec c1; |
289 c1.AddFeedbackParam(a1); // Only match with c2. | 229 c1.AddFeedbackParam(a1); // Only match with c2. |
290 c1.AddFeedbackParam(b2); // Same param different values. | 230 c1.AddFeedbackParam(b2); // Same param different values. |
291 c1.AddFeedbackParam(c3); // Not in c2. | 231 c1.AddFeedbackParam(c3); // Not in c2. |
292 Codec c2; | 232 Codec c2; |
293 c2.AddFeedbackParam(a1); | 233 c2.AddFeedbackParam(a1); |
294 c2.AddFeedbackParam(b3); | 234 c2.AddFeedbackParam(b3); |
295 | 235 |
296 c1.IntersectFeedbackParams(c2); | 236 c1.IntersectFeedbackParams(c2); |
297 EXPECT_TRUE(c1.HasFeedbackParam(a1)); | 237 EXPECT_TRUE(c1.HasFeedbackParam(a1)); |
298 EXPECT_FALSE(c1.HasFeedbackParam(b2)); | 238 EXPECT_FALSE(c1.HasFeedbackParam(b2)); |
299 EXPECT_FALSE(c1.HasFeedbackParam(c3)); | 239 EXPECT_FALSE(c1.HasFeedbackParam(c3)); |
300 } | 240 } |
301 | 241 |
302 TEST(CodecTest, TestGetCodecType) { | 242 TEST_F(CodecTest, TestGetCodecType) { |
303 // Codec type comparison should be case insenstive on names. | 243 // Codec type comparison should be case insenstive on names. |
304 const VideoCodec codec(96, "V"); | 244 const VideoCodec codec(96, "V"); |
305 const VideoCodec rtx_codec(96, "rTx"); | 245 const VideoCodec rtx_codec(96, "rTx"); |
306 const VideoCodec ulpfec_codec(96, "ulpFeC"); | 246 const VideoCodec ulpfec_codec(96, "ulpFeC"); |
307 const VideoCodec red_codec(96, "ReD"); | 247 const VideoCodec red_codec(96, "ReD"); |
308 EXPECT_EQ(VideoCodec::CODEC_VIDEO, codec.GetCodecType()); | 248 EXPECT_EQ(VideoCodec::CODEC_VIDEO, codec.GetCodecType()); |
309 EXPECT_EQ(VideoCodec::CODEC_RTX, rtx_codec.GetCodecType()); | 249 EXPECT_EQ(VideoCodec::CODEC_RTX, rtx_codec.GetCodecType()); |
310 EXPECT_EQ(VideoCodec::CODEC_ULPFEC, ulpfec_codec.GetCodecType()); | 250 EXPECT_EQ(VideoCodec::CODEC_ULPFEC, ulpfec_codec.GetCodecType()); |
311 EXPECT_EQ(VideoCodec::CODEC_RED, red_codec.GetCodecType()); | 251 EXPECT_EQ(VideoCodec::CODEC_RED, red_codec.GetCodecType()); |
312 } | 252 } |
313 | 253 |
314 TEST(CodecTest, TestCreateRtxCodec) { | 254 TEST_F(CodecTest, TestCreateRtxCodec) { |
315 VideoCodec rtx_codec = VideoCodec::CreateRtxCodec(96, 120); | 255 VideoCodec rtx_codec = VideoCodec::CreateRtxCodec(96, 120); |
316 EXPECT_EQ(96, rtx_codec.id); | 256 EXPECT_EQ(96, rtx_codec.id); |
317 EXPECT_EQ(VideoCodec::CODEC_RTX, rtx_codec.GetCodecType()); | 257 EXPECT_EQ(VideoCodec::CODEC_RTX, rtx_codec.GetCodecType()); |
318 int associated_payload_type; | 258 int associated_payload_type; |
319 ASSERT_TRUE(rtx_codec.GetParam(kCodecParamAssociatedPayloadType, | 259 ASSERT_TRUE(rtx_codec.GetParam(kCodecParamAssociatedPayloadType, |
320 &associated_payload_type)); | 260 &associated_payload_type)); |
321 EXPECT_EQ(120, associated_payload_type); | 261 EXPECT_EQ(120, associated_payload_type); |
322 } | 262 } |
323 | 263 |
324 TEST(CodecTest, TestValidateCodecFormat) { | 264 TEST_F(CodecTest, TestValidateCodecFormat) { |
325 const VideoCodec codec(96, "V"); | 265 const VideoCodec codec(96, "V"); |
326 ASSERT_TRUE(codec.ValidateCodecFormat()); | 266 ASSERT_TRUE(codec.ValidateCodecFormat()); |
327 | 267 |
328 // Accept 0-127 as payload types. | 268 // Accept 0-127 as payload types. |
329 VideoCodec low_payload_type = codec; | 269 VideoCodec low_payload_type = codec; |
330 low_payload_type.id = 0; | 270 low_payload_type.id = 0; |
331 VideoCodec high_payload_type = codec; | 271 VideoCodec high_payload_type = codec; |
332 high_payload_type.id = 127; | 272 high_payload_type.id = 127; |
333 ASSERT_TRUE(low_payload_type.ValidateCodecFormat()); | 273 ASSERT_TRUE(low_payload_type.ValidateCodecFormat()); |
334 EXPECT_TRUE(high_payload_type.ValidateCodecFormat()); | 274 EXPECT_TRUE(high_payload_type.ValidateCodecFormat()); |
(...skipping 20 matching lines...) Expand all Loading... |
355 equal_bitrates.params[kCodecParamMaxBitrate] = "100"; | 295 equal_bitrates.params[kCodecParamMaxBitrate] = "100"; |
356 EXPECT_TRUE(equal_bitrates.ValidateCodecFormat()); | 296 EXPECT_TRUE(equal_bitrates.ValidateCodecFormat()); |
357 | 297 |
358 // Accept min bitrate < max bitrate. | 298 // Accept min bitrate < max bitrate. |
359 VideoCodec different_bitrates = codec; | 299 VideoCodec different_bitrates = codec; |
360 different_bitrates.params[kCodecParamMinBitrate] = "99"; | 300 different_bitrates.params[kCodecParamMinBitrate] = "99"; |
361 different_bitrates.params[kCodecParamMaxBitrate] = "100"; | 301 different_bitrates.params[kCodecParamMaxBitrate] = "100"; |
362 EXPECT_TRUE(different_bitrates.ValidateCodecFormat()); | 302 EXPECT_TRUE(different_bitrates.ValidateCodecFormat()); |
363 } | 303 } |
364 | 304 |
365 TEST(CodecTest, TestToCodecParameters) { | 305 TEST_F(CodecTest, TestToCodecParameters) { |
366 const VideoCodec v(96, "V"); | 306 const VideoCodec v(96, "V"); |
367 webrtc::RtpCodecParameters codec_params_1 = v.ToCodecParameters(); | 307 webrtc::RtpCodecParameters codec_params_1 = v.ToCodecParameters(); |
368 EXPECT_EQ(96, codec_params_1.payload_type); | 308 EXPECT_EQ(96, codec_params_1.payload_type); |
369 EXPECT_EQ("V", codec_params_1.mime_type); | 309 EXPECT_EQ("V", codec_params_1.mime_type); |
370 EXPECT_EQ(cricket::kVideoCodecClockrate, codec_params_1.clock_rate); | 310 EXPECT_EQ(cricket::kVideoCodecClockrate, codec_params_1.clock_rate); |
371 EXPECT_EQ(1, codec_params_1.channels); | 311 EXPECT_EQ(1, codec_params_1.channels); |
372 | 312 |
373 const AudioCodec a(97, "A", 44100, 20000, 2); | 313 const AudioCodec a(97, "A", 44100, 20000, 2); |
374 webrtc::RtpCodecParameters codec_params_2 = a.ToCodecParameters(); | 314 webrtc::RtpCodecParameters codec_params_2 = a.ToCodecParameters(); |
375 EXPECT_EQ(97, codec_params_2.payload_type); | 315 EXPECT_EQ(97, codec_params_2.payload_type); |
376 EXPECT_EQ("A", codec_params_2.mime_type); | 316 EXPECT_EQ("A", codec_params_2.mime_type); |
377 EXPECT_EQ(44100, codec_params_2.clock_rate); | 317 EXPECT_EQ(44100, codec_params_2.clock_rate); |
378 EXPECT_EQ(2, codec_params_2.channels); | 318 EXPECT_EQ(2, codec_params_2.channels); |
379 } | 319 } |
OLD | NEW |