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

Side by Side Diff: webrtc/media/base/codec_unittest.cc

Issue 2347863003: H264 codec: Check profile-level-id when matching (Closed)
Patch Set: Created 4 years, 3 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
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 class CodecTest : public testing::Test { 23 TEST(CodecTest, TestCodecOperators) {
24 public:
25 CodecTest() {}
26 };
27
28 TEST_F(CodecTest, TestCodecOperators) {
29 Codec c0(96, "D", 1000); 24 Codec c0(96, "D", 1000);
30 c0.SetParam("a", 1); 25 c0.SetParam("a", 1);
31 26
32 Codec c1 = c0; 27 Codec c1 = c0;
33 EXPECT_TRUE(c1 == c0); 28 EXPECT_TRUE(c1 == c0);
34 29
35 int param_value0; 30 int param_value0;
36 int param_value1; 31 int param_value1;
37 EXPECT_TRUE(c0.GetParam("a", &param_value0)); 32 EXPECT_TRUE(c0.GetParam("a", &param_value0));
38 EXPECT_TRUE(c1.GetParam("a", &param_value1)); 33 EXPECT_TRUE(c1.GetParam("a", &param_value1));
(...skipping 12 matching lines...) Expand all
51 46
52 c1 = c0; 47 c1 = c0;
53 c1.SetParam("a", 2); 48 c1.SetParam("a", 2);
54 EXPECT_TRUE(c0 != c1); 49 EXPECT_TRUE(c0 != c1);
55 50
56 Codec c5; 51 Codec c5;
57 Codec c6(0, "", 0); 52 Codec c6(0, "", 0);
58 EXPECT_TRUE(c5 == c6); 53 EXPECT_TRUE(c5 == c6);
59 } 54 }
60 55
61 TEST_F(CodecTest, TestAudioCodecOperators) { 56 TEST(CodecTest, TestAudioCodecOperators) {
62 AudioCodec c0(96, "A", 44100, 20000, 2); 57 AudioCodec c0(96, "A", 44100, 20000, 2);
63 AudioCodec c1(95, "A", 44100, 20000, 2); 58 AudioCodec c1(95, "A", 44100, 20000, 2);
64 AudioCodec c2(96, "x", 44100, 20000, 2); 59 AudioCodec c2(96, "x", 44100, 20000, 2);
65 AudioCodec c3(96, "A", 48000, 20000, 2); 60 AudioCodec c3(96, "A", 48000, 20000, 2);
66 AudioCodec c4(96, "A", 44100, 10000, 2); 61 AudioCodec c4(96, "A", 44100, 10000, 2);
67 AudioCodec c5(96, "A", 44100, 20000, 1); 62 AudioCodec c5(96, "A", 44100, 20000, 1);
68 EXPECT_TRUE(c0 != c1); 63 EXPECT_TRUE(c0 != c1);
69 EXPECT_TRUE(c0 != c2); 64 EXPECT_TRUE(c0 != c2);
70 EXPECT_TRUE(c0 != c3); 65 EXPECT_TRUE(c0 != c3);
71 EXPECT_TRUE(c0 != c4); 66 EXPECT_TRUE(c0 != c4);
(...skipping 16 matching lines...) Expand all
88 c13.params["x"] = "abc"; 83 c13.params["x"] = "abc";
89 EXPECT_TRUE(c10 != c0); 84 EXPECT_TRUE(c10 != c0);
90 EXPECT_TRUE(c11 != c0); 85 EXPECT_TRUE(c11 != c0);
91 EXPECT_TRUE(c11 != c10); 86 EXPECT_TRUE(c11 != c10);
92 EXPECT_TRUE(c12 != c0); 87 EXPECT_TRUE(c12 != c0);
93 EXPECT_TRUE(c12 != c10); 88 EXPECT_TRUE(c12 != c10);
94 EXPECT_TRUE(c12 != c11); 89 EXPECT_TRUE(c12 != c11);
95 EXPECT_TRUE(c13 == c10); 90 EXPECT_TRUE(c13 == c10);
96 } 91 }
97 92
98 TEST_F(CodecTest, TestAudioCodecMatches) { 93 TEST(CodecTest, TestAudioCodecMatches) {
99 // Test a codec with a static payload type. 94 // Test a codec with a static payload type.
100 AudioCodec c0(95, "A", 44100, 20000, 1); 95 AudioCodec c0(95, "A", 44100, 20000, 1);
101 EXPECT_TRUE(c0.Matches(AudioCodec(95, "", 44100, 20000, 1))); 96 EXPECT_TRUE(c0.Matches(AudioCodec(95, "", 44100, 20000, 1)));
102 EXPECT_TRUE(c0.Matches(AudioCodec(95, "", 44100, 20000, 0))); 97 EXPECT_TRUE(c0.Matches(AudioCodec(95, "", 44100, 20000, 0)));
103 EXPECT_TRUE(c0.Matches(AudioCodec(95, "", 44100, 0, 0))); 98 EXPECT_TRUE(c0.Matches(AudioCodec(95, "", 44100, 0, 0)));
104 EXPECT_TRUE(c0.Matches(AudioCodec(95, "", 0, 0, 0))); 99 EXPECT_TRUE(c0.Matches(AudioCodec(95, "", 0, 0, 0)));
105 EXPECT_FALSE(c0.Matches(AudioCodec(96, "", 44100, 20000, 1))); 100 EXPECT_FALSE(c0.Matches(AudioCodec(96, "", 44100, 20000, 1)));
106 EXPECT_FALSE(c0.Matches(AudioCodec(95, "", 55100, 20000, 1))); 101 EXPECT_FALSE(c0.Matches(AudioCodec(95, "", 55100, 20000, 1)));
107 EXPECT_FALSE(c0.Matches(AudioCodec(95, "", 44100, 30000, 1))); 102 EXPECT_FALSE(c0.Matches(AudioCodec(95, "", 44100, 30000, 1)));
108 EXPECT_FALSE(c0.Matches(AudioCodec(95, "", 44100, 20000, 2))); 103 EXPECT_FALSE(c0.Matches(AudioCodec(95, "", 44100, 20000, 2)));
(...skipping 19 matching lines...) Expand all
128 // Backward compatibility with clients that might send "-1" (for default). 123 // Backward compatibility with clients that might send "-1" (for default).
129 EXPECT_TRUE(c2.Matches(AudioCodec(97, "A", 16000, -1, 1))); 124 EXPECT_TRUE(c2.Matches(AudioCodec(97, "A", 16000, -1, 1)));
130 125
131 // Stereo doesn't match channels = 0. 126 // Stereo doesn't match channels = 0.
132 AudioCodec c3(96, "A", 44100, 20000, 2); 127 AudioCodec c3(96, "A", 44100, 20000, 2);
133 EXPECT_TRUE(c3.Matches(AudioCodec(96, "A", 44100, 20000, 2))); 128 EXPECT_TRUE(c3.Matches(AudioCodec(96, "A", 44100, 20000, 2)));
134 EXPECT_FALSE(c3.Matches(AudioCodec(96, "A", 44100, 20000, 1))); 129 EXPECT_FALSE(c3.Matches(AudioCodec(96, "A", 44100, 20000, 1)));
135 EXPECT_FALSE(c3.Matches(AudioCodec(96, "A", 44100, 20000, 0))); 130 EXPECT_FALSE(c3.Matches(AudioCodec(96, "A", 44100, 20000, 0)));
136 } 131 }
137 132
138 TEST_F(CodecTest, TestVideoCodecOperators) { 133 TEST(CodecTest, TestVideoCodecOperators) {
139 VideoCodec c0(96, "V", 320, 200, 30); 134 VideoCodec c0(96, "V", 320, 200, 30);
140 VideoCodec c1(95, "V", 320, 200, 30); 135 VideoCodec c1(95, "V", 320, 200, 30);
141 VideoCodec c2(96, "x", 320, 200, 30); 136 VideoCodec c2(96, "x", 320, 200, 30);
142 VideoCodec c3(96, "V", 120, 200, 30); 137 VideoCodec c3(96, "V", 120, 200, 30);
143 VideoCodec c4(96, "V", 320, 100, 30); 138 VideoCodec c4(96, "V", 320, 100, 30);
144 VideoCodec c5(96, "V", 320, 200, 10); 139 VideoCodec c5(96, "V", 320, 200, 10);
145 EXPECT_TRUE(c0 != c1); 140 EXPECT_TRUE(c0 != c1);
146 EXPECT_TRUE(c0 != c2); 141 EXPECT_TRUE(c0 != c2);
147 EXPECT_TRUE(c0 != c3); 142 EXPECT_TRUE(c0 != c3);
148 EXPECT_TRUE(c0 != c4); 143 EXPECT_TRUE(c0 != c4);
(...skipping 16 matching lines...) Expand all
165 c13.params["x"] = "abc"; 160 c13.params["x"] = "abc";
166 EXPECT_TRUE(c10 != c0); 161 EXPECT_TRUE(c10 != c0);
167 EXPECT_TRUE(c11 != c0); 162 EXPECT_TRUE(c11 != c0);
168 EXPECT_TRUE(c11 != c10); 163 EXPECT_TRUE(c11 != c10);
169 EXPECT_TRUE(c12 != c0); 164 EXPECT_TRUE(c12 != c0);
170 EXPECT_TRUE(c12 != c10); 165 EXPECT_TRUE(c12 != c10);
171 EXPECT_TRUE(c12 != c11); 166 EXPECT_TRUE(c12 != c11);
172 EXPECT_TRUE(c13 == c10); 167 EXPECT_TRUE(c13 == c10);
173 } 168 }
174 169
175 TEST_F(CodecTest, TestVideoCodecMatches) { 170 TEST(CodecTest, TestVideoCodecMatches) {
176 // Test a codec with a static payload type. 171 // Test a codec with a static payload type.
177 VideoCodec c0(95, "V", 320, 200, 30); 172 VideoCodec c0(95, "V", 320, 200, 30);
178 EXPECT_TRUE(c0.Matches(VideoCodec(95, "", 640, 400, 15))); 173 EXPECT_TRUE(c0.Matches(VideoCodec(95, "", 640, 400, 15)));
179 EXPECT_FALSE(c0.Matches(VideoCodec(96, "", 320, 200, 30))); 174 EXPECT_FALSE(c0.Matches(VideoCodec(96, "", 320, 200, 30)));
180 175
181 // Test a codec with a dynamic payload type. 176 // Test a codec with a dynamic payload type.
182 VideoCodec c1(96, "V", 320, 200, 30); 177 VideoCodec c1(96, "V", 320, 200, 30);
183 EXPECT_TRUE(c1.Matches(VideoCodec(96, "V", 640, 400, 15))); 178 EXPECT_TRUE(c1.Matches(VideoCodec(96, "V", 640, 400, 15)));
184 EXPECT_TRUE(c1.Matches(VideoCodec(97, "V", 640, 400, 15))); 179 EXPECT_TRUE(c1.Matches(VideoCodec(97, "V", 640, 400, 15)));
185 EXPECT_TRUE(c1.Matches(VideoCodec(96, "v", 640, 400, 15))); 180 EXPECT_TRUE(c1.Matches(VideoCodec(96, "v", 640, 400, 15)));
186 EXPECT_TRUE(c1.Matches(VideoCodec(97, "v", 640, 400, 15))); 181 EXPECT_TRUE(c1.Matches(VideoCodec(97, "v", 640, 400, 15)));
187 EXPECT_FALSE(c1.Matches(VideoCodec(96, "", 320, 200, 30))); 182 EXPECT_FALSE(c1.Matches(VideoCodec(96, "", 320, 200, 30)));
188 EXPECT_FALSE(c1.Matches(VideoCodec(95, "V", 640, 400, 15))); 183 EXPECT_FALSE(c1.Matches(VideoCodec(95, "V", 640, 400, 15)));
189 } 184 }
190 185
191 TEST_F(CodecTest, TestDataCodecMatches) { 186 TEST(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
199 TEST(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
216 TEST(CodecTest, TestVideoCodecMatchesH264LevelAsymmetry) {
217 VideoCodec baseline_level1(96, cricket::kH264CodecName, 640, 480, 30);
218 baseline_level1.SetParam(cricket::kH264FmtpProfileLevelId,
219 cricket::kH264FmtpDefaultProfileLevelId);
220
221 VideoCodec baseline_level1_asymmetry_allowed = baseline_level1;
222 baseline_level1_asymmetry_allowed.SetParam(
223 cricket::kH264FmtpLevelAsymmetryAllowed, "1");
224
225 VideoCodec baseline_level2(96, cricket::kH264CodecName, 640, 480, 30);
226 baseline_level2.SetParam(cricket::kH264FmtpProfileLevelId, "660014");
hta-webrtc 2016/09/19 06:38:36 Are you sure about that 00 in the middle of this o
magjed_webrtc 2016/09/19 12:40:30 No, I'm not sure about the middle 00. It doesn't r
227
228 VideoCodec baseline_level2_asymmetry_allowed = baseline_level2;
229 baseline_level2_asymmetry_allowed.SetParam(
230 cricket::kH264FmtpLevelAsymmetryAllowed, "1");
231
232 // It's ok to differ in level-asymmetry-allowed param as long as the level is
233 // the same.
234 EXPECT_TRUE(baseline_level1.Matches(baseline_level1_asymmetry_allowed));
235 EXPECT_TRUE(baseline_level2.Matches(baseline_level2_asymmetry_allowed));
236
237 // Both codecs need to accept level asymmetry if levels differ.
238 EXPECT_FALSE(baseline_level1.Matches(baseline_level2_asymmetry_allowed));
239 EXPECT_FALSE(baseline_level1_asymmetry_allowed.Matches(baseline_level2));
240 EXPECT_TRUE(baseline_level1_asymmetry_allowed.Matches(
241 baseline_level2_asymmetry_allowed));
242
243 // Test explicitly disabling level asymmetry. It should have the same behavior
244 // as missing the param.
245 baseline_level1.SetParam(cricket::kH264FmtpLevelAsymmetryAllowed, "0");
246 EXPECT_TRUE(baseline_level1.Matches(baseline_level1_asymmetry_allowed));
247 EXPECT_FALSE(baseline_level1.Matches(baseline_level2_asymmetry_allowed));
248 }
249
250 TEST(CodecTest, TestDataCodecMatches) {
192 // Test a codec with a static payload type. 251 // Test a codec with a static payload type.
193 DataCodec c0(95, "D"); 252 DataCodec c0(95, "D");
194 EXPECT_TRUE(c0.Matches(DataCodec(95, ""))); 253 EXPECT_TRUE(c0.Matches(DataCodec(95, "")));
195 EXPECT_FALSE(c0.Matches(DataCodec(96, ""))); 254 EXPECT_FALSE(c0.Matches(DataCodec(96, "")));
196 255
197 // Test a codec with a dynamic payload type. 256 // Test a codec with a dynamic payload type.
198 DataCodec c1(96, "D"); 257 DataCodec c1(96, "D");
199 EXPECT_TRUE(c1.Matches(DataCodec(96, "D"))); 258 EXPECT_TRUE(c1.Matches(DataCodec(96, "D")));
200 EXPECT_TRUE(c1.Matches(DataCodec(97, "D"))); 259 EXPECT_TRUE(c1.Matches(DataCodec(97, "D")));
201 EXPECT_TRUE(c1.Matches(DataCodec(96, "d"))); 260 EXPECT_TRUE(c1.Matches(DataCodec(96, "d")));
202 EXPECT_TRUE(c1.Matches(DataCodec(97, "d"))); 261 EXPECT_TRUE(c1.Matches(DataCodec(97, "d")));
203 EXPECT_FALSE(c1.Matches(DataCodec(96, ""))); 262 EXPECT_FALSE(c1.Matches(DataCodec(96, "")));
204 EXPECT_FALSE(c1.Matches(DataCodec(95, "D"))); 263 EXPECT_FALSE(c1.Matches(DataCodec(95, "D")));
205 } 264 }
206 265
207 TEST_F(CodecTest, TestSetParamGetParamAndRemoveParam) { 266 TEST(CodecTest, TestSetParamGetParamAndRemoveParam) {
208 AudioCodec codec; 267 AudioCodec codec;
209 codec.SetParam("a", "1"); 268 codec.SetParam("a", "1");
210 codec.SetParam("b", "x"); 269 codec.SetParam("b", "x");
211 270
212 int int_value = 0; 271 int int_value = 0;
213 EXPECT_TRUE(codec.GetParam("a", &int_value)); 272 EXPECT_TRUE(codec.GetParam("a", &int_value));
214 EXPECT_EQ(1, int_value); 273 EXPECT_EQ(1, int_value);
215 EXPECT_FALSE(codec.GetParam("b", &int_value)); 274 EXPECT_FALSE(codec.GetParam("b", &int_value));
216 EXPECT_FALSE(codec.GetParam("c", &int_value)); 275 EXPECT_FALSE(codec.GetParam("c", &int_value));
217 276
218 std::string str_value; 277 std::string str_value;
219 EXPECT_TRUE(codec.GetParam("a", &str_value)); 278 EXPECT_TRUE(codec.GetParam("a", &str_value));
220 EXPECT_EQ("1", str_value); 279 EXPECT_EQ("1", str_value);
221 EXPECT_TRUE(codec.GetParam("b", &str_value)); 280 EXPECT_TRUE(codec.GetParam("b", &str_value));
222 EXPECT_EQ("x", str_value); 281 EXPECT_EQ("x", str_value);
223 EXPECT_FALSE(codec.GetParam("c", &str_value)); 282 EXPECT_FALSE(codec.GetParam("c", &str_value));
224 EXPECT_TRUE(codec.RemoveParam("a")); 283 EXPECT_TRUE(codec.RemoveParam("a"));
225 EXPECT_FALSE(codec.RemoveParam("c")); 284 EXPECT_FALSE(codec.RemoveParam("c"));
226 } 285 }
227 286
228 TEST_F(CodecTest, TestIntersectFeedbackParams) { 287 TEST(CodecTest, TestDefaultParam) {
hta-webrtc 2016/09/19 06:38:36 See other comment on this function.
magjed_webrtc 2016/09/19 12:40:30 Done, I have removed it.
288 const std::string kKey = "key";
289 const std::string kValue = "value";
290 const std::string kDefault = "default";
291 Codec c;
292 EXPECT_EQ(kDefault, c.GetParam(kKey, kDefault));
293 c.SetParam(kKey, kValue);
294 EXPECT_EQ(kValue, c.GetParam(kKey, kDefault));
295 }
296
297 TEST(CodecTest, TestIntersectFeedbackParams) {
229 const FeedbackParam a1("a", "1"); 298 const FeedbackParam a1("a", "1");
230 const FeedbackParam b2("b", "2"); 299 const FeedbackParam b2("b", "2");
231 const FeedbackParam b3("b", "3"); 300 const FeedbackParam b3("b", "3");
232 const FeedbackParam c3("c", "3"); 301 const FeedbackParam c3("c", "3");
233 Codec c1; 302 Codec c1;
234 c1.AddFeedbackParam(a1); // Only match with c2. 303 c1.AddFeedbackParam(a1); // Only match with c2.
235 c1.AddFeedbackParam(b2); // Same param different values. 304 c1.AddFeedbackParam(b2); // Same param different values.
236 c1.AddFeedbackParam(c3); // Not in c2. 305 c1.AddFeedbackParam(c3); // Not in c2.
237 Codec c2; 306 Codec c2;
238 c2.AddFeedbackParam(a1); 307 c2.AddFeedbackParam(a1);
239 c2.AddFeedbackParam(b3); 308 c2.AddFeedbackParam(b3);
240 309
241 c1.IntersectFeedbackParams(c2); 310 c1.IntersectFeedbackParams(c2);
242 EXPECT_TRUE(c1.HasFeedbackParam(a1)); 311 EXPECT_TRUE(c1.HasFeedbackParam(a1));
243 EXPECT_FALSE(c1.HasFeedbackParam(b2)); 312 EXPECT_FALSE(c1.HasFeedbackParam(b2));
244 EXPECT_FALSE(c1.HasFeedbackParam(c3)); 313 EXPECT_FALSE(c1.HasFeedbackParam(c3));
245 } 314 }
246 315
247 TEST_F(CodecTest, TestGetCodecType) { 316 TEST(CodecTest, TestGetCodecType) {
248 // Codec type comparison should be case insenstive on names. 317 // Codec type comparison should be case insenstive on names.
249 const VideoCodec codec(96, "V", 320, 200, 30); 318 const VideoCodec codec(96, "V", 320, 200, 30);
250 const VideoCodec rtx_codec(96, "rTx", 320, 200, 30); 319 const VideoCodec rtx_codec(96, "rTx", 320, 200, 30);
251 const VideoCodec ulpfec_codec(96, "ulpFeC", 320, 200, 30); 320 const VideoCodec ulpfec_codec(96, "ulpFeC", 320, 200, 30);
252 const VideoCodec red_codec(96, "ReD", 320, 200, 30); 321 const VideoCodec red_codec(96, "ReD", 320, 200, 30);
253 EXPECT_EQ(VideoCodec::CODEC_VIDEO, codec.GetCodecType()); 322 EXPECT_EQ(VideoCodec::CODEC_VIDEO, codec.GetCodecType());
254 EXPECT_EQ(VideoCodec::CODEC_RTX, rtx_codec.GetCodecType()); 323 EXPECT_EQ(VideoCodec::CODEC_RTX, rtx_codec.GetCodecType());
255 EXPECT_EQ(VideoCodec::CODEC_ULPFEC, ulpfec_codec.GetCodecType()); 324 EXPECT_EQ(VideoCodec::CODEC_ULPFEC, ulpfec_codec.GetCodecType());
256 EXPECT_EQ(VideoCodec::CODEC_RED, red_codec.GetCodecType()); 325 EXPECT_EQ(VideoCodec::CODEC_RED, red_codec.GetCodecType());
257 } 326 }
258 327
259 TEST_F(CodecTest, TestCreateRtxCodec) { 328 TEST(CodecTest, TestCreateRtxCodec) {
260 VideoCodec rtx_codec = VideoCodec::CreateRtxCodec(96, 120); 329 VideoCodec rtx_codec = VideoCodec::CreateRtxCodec(96, 120);
261 EXPECT_EQ(96, rtx_codec.id); 330 EXPECT_EQ(96, rtx_codec.id);
262 EXPECT_EQ(VideoCodec::CODEC_RTX, rtx_codec.GetCodecType()); 331 EXPECT_EQ(VideoCodec::CODEC_RTX, rtx_codec.GetCodecType());
263 int associated_payload_type; 332 int associated_payload_type;
264 ASSERT_TRUE(rtx_codec.GetParam(kCodecParamAssociatedPayloadType, 333 ASSERT_TRUE(rtx_codec.GetParam(kCodecParamAssociatedPayloadType,
265 &associated_payload_type)); 334 &associated_payload_type));
266 EXPECT_EQ(120, associated_payload_type); 335 EXPECT_EQ(120, associated_payload_type);
267 } 336 }
268 337
269 TEST_F(CodecTest, TestValidateCodecFormat) { 338 TEST(CodecTest, TestValidateCodecFormat) {
270 const VideoCodec codec(96, "V", 320, 200, 30); 339 const VideoCodec codec(96, "V", 320, 200, 30);
271 ASSERT_TRUE(codec.ValidateCodecFormat()); 340 ASSERT_TRUE(codec.ValidateCodecFormat());
272 341
273 // Accept 0-127 as payload types. 342 // Accept 0-127 as payload types.
274 VideoCodec low_payload_type = codec; 343 VideoCodec low_payload_type = codec;
275 low_payload_type.id = 0; 344 low_payload_type.id = 0;
276 VideoCodec high_payload_type = codec; 345 VideoCodec high_payload_type = codec;
277 high_payload_type.id = 127; 346 high_payload_type.id = 127;
278 ASSERT_TRUE(low_payload_type.ValidateCodecFormat()); 347 ASSERT_TRUE(low_payload_type.ValidateCodecFormat());
279 EXPECT_TRUE(high_payload_type.ValidateCodecFormat()); 348 EXPECT_TRUE(high_payload_type.ValidateCodecFormat());
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
315 equal_bitrates.params[kCodecParamMaxBitrate] = "100"; 384 equal_bitrates.params[kCodecParamMaxBitrate] = "100";
316 EXPECT_TRUE(equal_bitrates.ValidateCodecFormat()); 385 EXPECT_TRUE(equal_bitrates.ValidateCodecFormat());
317 386
318 // Accept min bitrate < max bitrate. 387 // Accept min bitrate < max bitrate.
319 VideoCodec different_bitrates = codec; 388 VideoCodec different_bitrates = codec;
320 different_bitrates.params[kCodecParamMinBitrate] = "99"; 389 different_bitrates.params[kCodecParamMinBitrate] = "99";
321 different_bitrates.params[kCodecParamMaxBitrate] = "100"; 390 different_bitrates.params[kCodecParamMaxBitrate] = "100";
322 EXPECT_TRUE(different_bitrates.ValidateCodecFormat()); 391 EXPECT_TRUE(different_bitrates.ValidateCodecFormat());
323 } 392 }
324 393
325 TEST_F(CodecTest, TestToCodecParameters) { 394 TEST(CodecTest, TestToCodecParameters) {
326 const VideoCodec v(96, "V", 320, 200, 30); 395 const VideoCodec v(96, "V", 320, 200, 30);
327 webrtc::RtpCodecParameters codec_params_1 = v.ToCodecParameters(); 396 webrtc::RtpCodecParameters codec_params_1 = v.ToCodecParameters();
328 EXPECT_EQ(96, codec_params_1.payload_type); 397 EXPECT_EQ(96, codec_params_1.payload_type);
329 EXPECT_EQ("V", codec_params_1.mime_type); 398 EXPECT_EQ("V", codec_params_1.mime_type);
330 EXPECT_EQ(cricket::kVideoCodecClockrate, codec_params_1.clock_rate); 399 EXPECT_EQ(cricket::kVideoCodecClockrate, codec_params_1.clock_rate);
331 EXPECT_EQ(1, codec_params_1.channels); 400 EXPECT_EQ(1, codec_params_1.channels);
332 401
333 const AudioCodec a(97, "A", 44100, 20000, 2); 402 const AudioCodec a(97, "A", 44100, 20000, 2);
334 webrtc::RtpCodecParameters codec_params_2 = a.ToCodecParameters(); 403 webrtc::RtpCodecParameters codec_params_2 = a.ToCodecParameters();
335 EXPECT_EQ(97, codec_params_2.payload_type); 404 EXPECT_EQ(97, codec_params_2.payload_type);
336 EXPECT_EQ("A", codec_params_2.mime_type); 405 EXPECT_EQ("A", codec_params_2.mime_type);
337 EXPECT_EQ(44100, codec_params_2.clock_rate); 406 EXPECT_EQ(44100, codec_params_2.clock_rate);
338 EXPECT_EQ(2, codec_params_2.channels); 407 EXPECT_EQ(2, codec_params_2.channels);
339 } 408 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698