blob: ce159ef94a61e5e53143f3f41f555be90cb3b68c [file] [log] [blame]
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001/*
kjellander1afca732016-02-07 20:46:45 -08002 * Copyright (c) 2009 The WebRTC project authors. All Rights Reserved.
henrike@webrtc.org28e20752013-07-10 00:45:36 +00003 *
kjellander1afca732016-02-07 20:46:45 -08004 * 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.
henrike@webrtc.org28e20752013-07-10 00:45:36 +00009 */
10
buildbot@webrtc.orga09a9992014-08-13 17:26:08 +000011#include "webrtc/base/gunit.h"
kjellandera96e2d72016-02-04 23:52:28 -080012#include "webrtc/media/base/codec.h"
henrike@webrtc.org28e20752013-07-10 00:45:36 +000013
14using cricket::AudioCodec;
15using cricket::Codec;
16using cricket::DataCodec;
17using cricket::FeedbackParam;
18using cricket::VideoCodec;
pbos@webrtc.orgb5a22b12014-05-13 11:07:01 +000019using cricket::kCodecParamAssociatedPayloadType;
20using cricket::kCodecParamMaxBitrate;
21using cricket::kCodecParamMinBitrate;
henrike@webrtc.org28e20752013-07-10 00:45:36 +000022
magjed68979ab2016-10-06 02:15:49 -070023TEST(CodecTest, TestCodecOperators) {
deadbeef67cf2c12016-04-13 10:07:16 -070024 Codec c0(96, "D", 1000);
jiayl@webrtc.org9c16c392014-05-01 18:30:30 +000025 c0.SetParam("a", 1);
26
27 Codec c1 = c0;
28 EXPECT_TRUE(c1 == c0);
29
30 int param_value0;
31 int param_value1;
32 EXPECT_TRUE(c0.GetParam("a", &param_value0));
33 EXPECT_TRUE(c1.GetParam("a", &param_value1));
34 EXPECT_EQ(param_value0, param_value1);
35
36 c1.id = 86;
37 EXPECT_TRUE(c0 != c1);
38
39 c1 = c0;
40 c1.name = "x";
41 EXPECT_TRUE(c0 != c1);
42
43 c1 = c0;
44 c1.clockrate = 2000;
45 EXPECT_TRUE(c0 != c1);
46
47 c1 = c0;
jiayl@webrtc.org9c16c392014-05-01 18:30:30 +000048 c1.SetParam("a", 2);
49 EXPECT_TRUE(c0 != c1);
50
51 Codec c5;
deadbeef67cf2c12016-04-13 10:07:16 -070052 Codec c6(0, "", 0);
jiayl@webrtc.org9c16c392014-05-01 18:30:30 +000053 EXPECT_TRUE(c5 == c6);
54}
55
magjed68979ab2016-10-06 02:15:49 -070056TEST(CodecTest, TestAudioCodecOperators) {
deadbeef67cf2c12016-04-13 10:07:16 -070057 AudioCodec c0(96, "A", 44100, 20000, 2);
58 AudioCodec c1(95, "A", 44100, 20000, 2);
59 AudioCodec c2(96, "x", 44100, 20000, 2);
60 AudioCodec c3(96, "A", 48000, 20000, 2);
61 AudioCodec c4(96, "A", 44100, 10000, 2);
62 AudioCodec c5(96, "A", 44100, 20000, 1);
henrike@webrtc.org28e20752013-07-10 00:45:36 +000063 EXPECT_TRUE(c0 != c1);
64 EXPECT_TRUE(c0 != c2);
65 EXPECT_TRUE(c0 != c3);
66 EXPECT_TRUE(c0 != c4);
67 EXPECT_TRUE(c0 != c5);
henrike@webrtc.org28e20752013-07-10 00:45:36 +000068
69 AudioCodec c7;
deadbeef67cf2c12016-04-13 10:07:16 -070070 AudioCodec c8(0, "", 0, 0, 0);
henrike@webrtc.org28e20752013-07-10 00:45:36 +000071 AudioCodec c9 = c0;
72 EXPECT_TRUE(c8 == c7);
73 EXPECT_TRUE(c9 != c7);
74 EXPECT_TRUE(c9 == c0);
75
76 AudioCodec c10(c0);
77 AudioCodec c11(c0);
78 AudioCodec c12(c0);
79 AudioCodec c13(c0);
80 c10.params["x"] = "abc";
81 c11.params["x"] = "def";
82 c12.params["y"] = "abc";
83 c13.params["x"] = "abc";
84 EXPECT_TRUE(c10 != c0);
85 EXPECT_TRUE(c11 != c0);
86 EXPECT_TRUE(c11 != c10);
87 EXPECT_TRUE(c12 != c0);
88 EXPECT_TRUE(c12 != c10);
89 EXPECT_TRUE(c12 != c11);
90 EXPECT_TRUE(c13 == c10);
91}
92
magjed68979ab2016-10-06 02:15:49 -070093TEST(CodecTest, TestAudioCodecMatches) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +000094 // Test a codec with a static payload type.
deadbeef67cf2c12016-04-13 10:07:16 -070095 AudioCodec c0(95, "A", 44100, 20000, 1);
96 EXPECT_TRUE(c0.Matches(AudioCodec(95, "", 44100, 20000, 1)));
97 EXPECT_TRUE(c0.Matches(AudioCodec(95, "", 44100, 20000, 0)));
98 EXPECT_TRUE(c0.Matches(AudioCodec(95, "", 44100, 0, 0)));
99 EXPECT_TRUE(c0.Matches(AudioCodec(95, "", 0, 0, 0)));
100 EXPECT_FALSE(c0.Matches(AudioCodec(96, "", 44100, 20000, 1)));
101 EXPECT_FALSE(c0.Matches(AudioCodec(95, "", 55100, 20000, 1)));
102 EXPECT_FALSE(c0.Matches(AudioCodec(95, "", 44100, 30000, 1)));
103 EXPECT_FALSE(c0.Matches(AudioCodec(95, "", 44100, 20000, 2)));
104 EXPECT_FALSE(c0.Matches(AudioCodec(95, "", 55100, 30000, 2)));
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000105
106 // Test a codec with a dynamic payload type.
deadbeef67cf2c12016-04-13 10:07:16 -0700107 AudioCodec c1(96, "A", 44100, 20000, 1);
108 EXPECT_TRUE(c1.Matches(AudioCodec(96, "A", 0, 0, 0)));
109 EXPECT_TRUE(c1.Matches(AudioCodec(97, "A", 0, 0, 0)));
110 EXPECT_TRUE(c1.Matches(AudioCodec(96, "a", 0, 0, 0)));
111 EXPECT_TRUE(c1.Matches(AudioCodec(97, "a", 0, 0, 0)));
112 EXPECT_FALSE(c1.Matches(AudioCodec(95, "A", 0, 0, 0)));
113 EXPECT_FALSE(c1.Matches(AudioCodec(96, "", 44100, 20000, 2)));
114 EXPECT_FALSE(c1.Matches(AudioCodec(96, "A", 55100, 30000, 1)));
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000115
116 // Test a codec with a dynamic payload type, and auto bitrate.
deadbeef67cf2c12016-04-13 10:07:16 -0700117 AudioCodec c2(97, "A", 16000, 0, 1);
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000118 // Use default bitrate.
deadbeef67cf2c12016-04-13 10:07:16 -0700119 EXPECT_TRUE(c2.Matches(AudioCodec(97, "A", 16000, 0, 1)));
120 EXPECT_TRUE(c2.Matches(AudioCodec(97, "A", 16000, 0, 0)));
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000121 // Use explicit bitrate.
deadbeef67cf2c12016-04-13 10:07:16 -0700122 EXPECT_TRUE(c2.Matches(AudioCodec(97, "A", 16000, 32000, 1)));
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000123 // Backward compatibility with clients that might send "-1" (for default).
deadbeef67cf2c12016-04-13 10:07:16 -0700124 EXPECT_TRUE(c2.Matches(AudioCodec(97, "A", 16000, -1, 1)));
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000125
126 // Stereo doesn't match channels = 0.
deadbeef67cf2c12016-04-13 10:07:16 -0700127 AudioCodec c3(96, "A", 44100, 20000, 2);
128 EXPECT_TRUE(c3.Matches(AudioCodec(96, "A", 44100, 20000, 2)));
129 EXPECT_FALSE(c3.Matches(AudioCodec(96, "A", 44100, 20000, 1)));
130 EXPECT_FALSE(c3.Matches(AudioCodec(96, "A", 44100, 20000, 0)));
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000131}
132
magjed68979ab2016-10-06 02:15:49 -0700133TEST(CodecTest, TestVideoCodecOperators) {
deadbeef67cf2c12016-04-13 10:07:16 -0700134 VideoCodec c0(96, "V", 320, 200, 30);
135 VideoCodec c1(95, "V", 320, 200, 30);
136 VideoCodec c2(96, "x", 320, 200, 30);
137 VideoCodec c3(96, "V", 120, 200, 30);
138 VideoCodec c4(96, "V", 320, 100, 30);
139 VideoCodec c5(96, "V", 320, 200, 10);
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000140 EXPECT_TRUE(c0 != c1);
141 EXPECT_TRUE(c0 != c2);
142 EXPECT_TRUE(c0 != c3);
143 EXPECT_TRUE(c0 != c4);
144 EXPECT_TRUE(c0 != c5);
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000145
146 VideoCodec c7;
deadbeef67cf2c12016-04-13 10:07:16 -0700147 VideoCodec c8(0, "", 0, 0, 0);
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000148 VideoCodec c9 = c0;
149 EXPECT_TRUE(c8 == c7);
150 EXPECT_TRUE(c9 != c7);
151 EXPECT_TRUE(c9 == c0);
152
153 VideoCodec c10(c0);
154 VideoCodec c11(c0);
155 VideoCodec c12(c0);
156 VideoCodec c13(c0);
157 c10.params["x"] = "abc";
158 c11.params["x"] = "def";
159 c12.params["y"] = "abc";
160 c13.params["x"] = "abc";
161 EXPECT_TRUE(c10 != c0);
162 EXPECT_TRUE(c11 != c0);
163 EXPECT_TRUE(c11 != c10);
164 EXPECT_TRUE(c12 != c0);
165 EXPECT_TRUE(c12 != c10);
166 EXPECT_TRUE(c12 != c11);
167 EXPECT_TRUE(c13 == c10);
168}
169
magjed68979ab2016-10-06 02:15:49 -0700170TEST(CodecTest, TestVideoCodecMatches) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000171 // Test a codec with a static payload type.
deadbeef67cf2c12016-04-13 10:07:16 -0700172 VideoCodec c0(95, "V", 320, 200, 30);
173 EXPECT_TRUE(c0.Matches(VideoCodec(95, "", 640, 400, 15)));
174 EXPECT_FALSE(c0.Matches(VideoCodec(96, "", 320, 200, 30)));
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000175
176 // Test a codec with a dynamic payload type.
deadbeef67cf2c12016-04-13 10:07:16 -0700177 VideoCodec c1(96, "V", 320, 200, 30);
178 EXPECT_TRUE(c1.Matches(VideoCodec(96, "V", 640, 400, 15)));
179 EXPECT_TRUE(c1.Matches(VideoCodec(97, "V", 640, 400, 15)));
180 EXPECT_TRUE(c1.Matches(VideoCodec(96, "v", 640, 400, 15)));
181 EXPECT_TRUE(c1.Matches(VideoCodec(97, "v", 640, 400, 15)));
182 EXPECT_FALSE(c1.Matches(VideoCodec(96, "", 320, 200, 30)));
183 EXPECT_FALSE(c1.Matches(VideoCodec(95, "V", 640, 400, 15)));
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000184}
185
magjed68979ab2016-10-06 02:15:49 -0700186TEST(CodecTest, TestVideoCodecMatchesH264Baseline) {
187 const VideoCodec no_params(96, cricket::kH264CodecName, 640, 480, 30);
188
189 VideoCodec baseline(96, cricket::kH264CodecName, 640, 480, 30);
190 baseline.SetParam(cricket::kH264FmtpProfileLevelId,
191 cricket::kH264FmtpDefaultProfileLevelId);
192
193 EXPECT_TRUE(baseline.Matches(baseline));
194 EXPECT_TRUE(baseline.Matches(no_params));
195 EXPECT_TRUE(no_params.Matches(baseline));
196 EXPECT_TRUE(no_params.Matches(no_params));
197}
198
199TEST(CodecTest, TestVideoCodecMatchesH264Profiles) {
200 VideoCodec baseline(96, cricket::kH264CodecName, 640, 480, 30);
201 baseline.SetParam(cricket::kH264FmtpProfileLevelId,
202 cricket::kH264FmtpDefaultProfileLevelId);
203 baseline.SetParam(cricket::kH264FmtpLevelAsymmetryAllowed, "1");
204
205 VideoCodec constrained_baseline(96, cricket::kH264CodecName, 640, 480, 30);
206 constrained_baseline.SetParam(cricket::kH264FmtpProfileLevelId,
207 cricket::kH264ProfileLevelConstrainedBaseline);
208 constrained_baseline.SetParam(cricket::kH264FmtpLevelAsymmetryAllowed, "1");
209
210 EXPECT_TRUE(baseline.Matches(baseline));
211 EXPECT_FALSE(baseline.Matches(constrained_baseline));
212 EXPECT_FALSE(constrained_baseline.Matches(baseline));
213 EXPECT_TRUE(constrained_baseline.Matches(constrained_baseline));
214}
215
216TEST(CodecTest, TestVideoCodecMatchesH264LevelAsymmetry) {
217 // Constrained Baseline Profile Level 1.0.
218 VideoCodec cbp_1_0(96, cricket::kH264CodecName, 640, 480, 30);
219 cbp_1_0.SetParam(cricket::kH264FmtpProfileLevelId,
220 "42e00a");
221
222 VideoCodec cbp_1_0_asymmetry_allowed = cbp_1_0;
223 cbp_1_0_asymmetry_allowed.SetParam(cricket::kH264FmtpLevelAsymmetryAllowed,
224 "1");
225
226 // Constrained Baseline Profile Level 3.1.
227 VideoCodec cbp_3_1(96, cricket::kH264CodecName, 640, 480, 30);
228 cbp_3_1.SetParam(cricket::kH264FmtpProfileLevelId, "42e01f");
229
230 VideoCodec cbp_3_1_asymmetry_allowed = cbp_3_1;
231 cbp_3_1_asymmetry_allowed.SetParam(cricket::kH264FmtpLevelAsymmetryAllowed,
232 "1");
233
234 // It's ok to differ in level-asymmetry-allowed param as long as the level is
235 // the same.
236 EXPECT_TRUE(cbp_1_0.Matches(cbp_1_0_asymmetry_allowed));
237 EXPECT_TRUE(cbp_3_1.Matches(cbp_3_1_asymmetry_allowed));
238
239 // Both codecs need to accept level asymmetry if levels differ.
240 EXPECT_FALSE(cbp_1_0.Matches(cbp_3_1_asymmetry_allowed));
241 EXPECT_FALSE(cbp_1_0_asymmetry_allowed.Matches(cbp_3_1));
242 EXPECT_TRUE(cbp_1_0_asymmetry_allowed.Matches(cbp_3_1_asymmetry_allowed));
243
244 // Test explicitly disabling level asymmetry. It should have the same behavior
245 // as missing the param.
246 cbp_1_0.SetParam(cricket::kH264FmtpLevelAsymmetryAllowed, "0");
247 EXPECT_TRUE(cbp_1_0.Matches(cbp_1_0_asymmetry_allowed));
248 EXPECT_FALSE(cbp_1_0.Matches(cbp_3_1_asymmetry_allowed));
249}
250
251TEST(CodecTest, TestDataCodecMatches) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000252 // Test a codec with a static payload type.
deadbeef67cf2c12016-04-13 10:07:16 -0700253 DataCodec c0(95, "D");
254 EXPECT_TRUE(c0.Matches(DataCodec(95, "")));
255 EXPECT_FALSE(c0.Matches(DataCodec(96, "")));
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000256
257 // Test a codec with a dynamic payload type.
deadbeef67cf2c12016-04-13 10:07:16 -0700258 DataCodec c1(96, "D");
259 EXPECT_TRUE(c1.Matches(DataCodec(96, "D")));
260 EXPECT_TRUE(c1.Matches(DataCodec(97, "D")));
261 EXPECT_TRUE(c1.Matches(DataCodec(96, "d")));
262 EXPECT_TRUE(c1.Matches(DataCodec(97, "d")));
263 EXPECT_FALSE(c1.Matches(DataCodec(96, "")));
264 EXPECT_FALSE(c1.Matches(DataCodec(95, "D")));
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000265}
266
magjed68979ab2016-10-06 02:15:49 -0700267TEST(CodecTest, TestSetParamGetParamAndRemoveParam) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000268 AudioCodec codec;
269 codec.SetParam("a", "1");
270 codec.SetParam("b", "x");
271
272 int int_value = 0;
273 EXPECT_TRUE(codec.GetParam("a", &int_value));
274 EXPECT_EQ(1, int_value);
275 EXPECT_FALSE(codec.GetParam("b", &int_value));
276 EXPECT_FALSE(codec.GetParam("c", &int_value));
277
278 std::string str_value;
279 EXPECT_TRUE(codec.GetParam("a", &str_value));
280 EXPECT_EQ("1", str_value);
281 EXPECT_TRUE(codec.GetParam("b", &str_value));
282 EXPECT_EQ("x", str_value);
283 EXPECT_FALSE(codec.GetParam("c", &str_value));
buildbot@webrtc.orgfbd13282014-06-19 19:50:55 +0000284 EXPECT_TRUE(codec.RemoveParam("a"));
285 EXPECT_FALSE(codec.RemoveParam("c"));
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000286}
287
magjed68979ab2016-10-06 02:15:49 -0700288TEST(CodecTest, TestIntersectFeedbackParams) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000289 const FeedbackParam a1("a", "1");
290 const FeedbackParam b2("b", "2");
291 const FeedbackParam b3("b", "3");
292 const FeedbackParam c3("c", "3");
293 Codec c1;
294 c1.AddFeedbackParam(a1); // Only match with c2.
295 c1.AddFeedbackParam(b2); // Same param different values.
296 c1.AddFeedbackParam(c3); // Not in c2.
297 Codec c2;
298 c2.AddFeedbackParam(a1);
299 c2.AddFeedbackParam(b3);
300
301 c1.IntersectFeedbackParams(c2);
302 EXPECT_TRUE(c1.HasFeedbackParam(a1));
303 EXPECT_FALSE(c1.HasFeedbackParam(b2));
304 EXPECT_FALSE(c1.HasFeedbackParam(c3));
305}
pbos@webrtc.orgb5a22b12014-05-13 11:07:01 +0000306
magjed68979ab2016-10-06 02:15:49 -0700307TEST(CodecTest, TestGetCodecType) {
pbos@webrtc.orgb5a22b12014-05-13 11:07:01 +0000308 // Codec type comparison should be case insenstive on names.
deadbeef67cf2c12016-04-13 10:07:16 -0700309 const VideoCodec codec(96, "V", 320, 200, 30);
310 const VideoCodec rtx_codec(96, "rTx", 320, 200, 30);
311 const VideoCodec ulpfec_codec(96, "ulpFeC", 320, 200, 30);
312 const VideoCodec red_codec(96, "ReD", 320, 200, 30);
pbos@webrtc.orgb5a22b12014-05-13 11:07:01 +0000313 EXPECT_EQ(VideoCodec::CODEC_VIDEO, codec.GetCodecType());
314 EXPECT_EQ(VideoCodec::CODEC_RTX, rtx_codec.GetCodecType());
315 EXPECT_EQ(VideoCodec::CODEC_ULPFEC, ulpfec_codec.GetCodecType());
316 EXPECT_EQ(VideoCodec::CODEC_RED, red_codec.GetCodecType());
317}
318
magjed68979ab2016-10-06 02:15:49 -0700319TEST(CodecTest, TestCreateRtxCodec) {
pbos@webrtc.orgb5a22b12014-05-13 11:07:01 +0000320 VideoCodec rtx_codec = VideoCodec::CreateRtxCodec(96, 120);
321 EXPECT_EQ(96, rtx_codec.id);
322 EXPECT_EQ(VideoCodec::CODEC_RTX, rtx_codec.GetCodecType());
323 int associated_payload_type;
324 ASSERT_TRUE(rtx_codec.GetParam(kCodecParamAssociatedPayloadType,
325 &associated_payload_type));
326 EXPECT_EQ(120, associated_payload_type);
327}
328
magjed68979ab2016-10-06 02:15:49 -0700329TEST(CodecTest, TestValidateCodecFormat) {
deadbeef67cf2c12016-04-13 10:07:16 -0700330 const VideoCodec codec(96, "V", 320, 200, 30);
pbos@webrtc.orgb5a22b12014-05-13 11:07:01 +0000331 ASSERT_TRUE(codec.ValidateCodecFormat());
332
333 // Accept 0-127 as payload types.
334 VideoCodec low_payload_type = codec;
335 low_payload_type.id = 0;
336 VideoCodec high_payload_type = codec;
337 high_payload_type.id = 127;
338 ASSERT_TRUE(low_payload_type.ValidateCodecFormat());
339 EXPECT_TRUE(high_payload_type.ValidateCodecFormat());
340
341 // Reject negative payloads.
342 VideoCodec negative_payload_type = codec;
343 negative_payload_type.id = -1;
344 EXPECT_FALSE(negative_payload_type.ValidateCodecFormat());
345
346 // Reject too-high payloads.
347 VideoCodec too_high_payload_type = codec;
348 too_high_payload_type.id = 128;
349 EXPECT_FALSE(too_high_payload_type.ValidateCodecFormat());
350
351 // Reject zero-width codecs.
352 VideoCodec zero_width = codec;
353 zero_width.width = 0;
354 EXPECT_FALSE(zero_width.ValidateCodecFormat());
355
356 // Reject zero-height codecs.
357 VideoCodec zero_height = codec;
358 zero_height.height = 0;
359 EXPECT_FALSE(zero_height.ValidateCodecFormat());
360
361 // Accept non-video codecs with zero dimensions.
362 VideoCodec zero_width_rtx_codec = VideoCodec::CreateRtxCodec(96, 120);
363 zero_width_rtx_codec.width = 0;
364 EXPECT_TRUE(zero_width_rtx_codec.ValidateCodecFormat());
365
366 // Reject codecs with min bitrate > max bitrate.
367 VideoCodec incorrect_bitrates = codec;
368 incorrect_bitrates.params[kCodecParamMinBitrate] = "100";
369 incorrect_bitrates.params[kCodecParamMaxBitrate] = "80";
370 EXPECT_FALSE(incorrect_bitrates.ValidateCodecFormat());
371
372 // Accept min bitrate == max bitrate.
373 VideoCodec equal_bitrates = codec;
374 equal_bitrates.params[kCodecParamMinBitrate] = "100";
375 equal_bitrates.params[kCodecParamMaxBitrate] = "100";
376 EXPECT_TRUE(equal_bitrates.ValidateCodecFormat());
377
378 // Accept min bitrate < max bitrate.
379 VideoCodec different_bitrates = codec;
380 different_bitrates.params[kCodecParamMinBitrate] = "99";
381 different_bitrates.params[kCodecParamMaxBitrate] = "100";
382 EXPECT_TRUE(different_bitrates.ValidateCodecFormat());
383}
Taylor Brandstetterdb0cd9e2016-05-16 11:40:30 -0700384
magjed68979ab2016-10-06 02:15:49 -0700385TEST(CodecTest, TestToCodecParameters) {
Taylor Brandstetterdb0cd9e2016-05-16 11:40:30 -0700386 const VideoCodec v(96, "V", 320, 200, 30);
387 webrtc::RtpCodecParameters codec_params_1 = v.ToCodecParameters();
388 EXPECT_EQ(96, codec_params_1.payload_type);
389 EXPECT_EQ("V", codec_params_1.mime_type);
390 EXPECT_EQ(cricket::kVideoCodecClockrate, codec_params_1.clock_rate);
391 EXPECT_EQ(1, codec_params_1.channels);
392
393 const AudioCodec a(97, "A", 44100, 20000, 2);
394 webrtc::RtpCodecParameters codec_params_2 = a.ToCodecParameters();
395 EXPECT_EQ(97, codec_params_2.payload_type);
396 EXPECT_EQ("A", codec_params_2.mime_type);
397 EXPECT_EQ(44100, codec_params_2.clock_rate);
398 EXPECT_EQ(2, codec_params_2.channels);
399}