OLD | NEW |
1 /* | 1 /* |
2 * libjingle | 2 * libjingle |
3 * Copyright 2009 Google Inc. | 3 * Copyright 2009 Google Inc. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions are met: | 6 * modification, are permitted provided that the following conditions are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright notice, | 8 * 1. Redistributions of source code must retain the above copyright notice, |
9 * this list of conditions and the following disclaimer. | 9 * this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright notice, | 10 * 2. Redistributions in binary form must reproduce the above copyright notice, |
(...skipping 15 matching lines...) Expand all Loading... |
26 */ | 26 */ |
27 | 27 |
28 #include "talk/media/base/codec.h" | 28 #include "talk/media/base/codec.h" |
29 #include "webrtc/base/gunit.h" | 29 #include "webrtc/base/gunit.h" |
30 | 30 |
31 using cricket::AudioCodec; | 31 using cricket::AudioCodec; |
32 using cricket::Codec; | 32 using cricket::Codec; |
33 using cricket::DataCodec; | 33 using cricket::DataCodec; |
34 using cricket::FeedbackParam; | 34 using cricket::FeedbackParam; |
35 using cricket::VideoCodec; | 35 using cricket::VideoCodec; |
36 using cricket::VideoEncoderConfig; | |
37 using cricket::kCodecParamAssociatedPayloadType; | 36 using cricket::kCodecParamAssociatedPayloadType; |
38 using cricket::kCodecParamMaxBitrate; | 37 using cricket::kCodecParamMaxBitrate; |
39 using cricket::kCodecParamMinBitrate; | 38 using cricket::kCodecParamMinBitrate; |
40 | 39 |
41 class CodecTest : public testing::Test { | 40 class CodecTest : public testing::Test { |
42 public: | 41 public: |
43 CodecTest() {} | 42 CodecTest() {} |
44 }; | 43 }; |
45 | 44 |
46 TEST_F(CodecTest, TestCodecOperators) { | 45 TEST_F(CodecTest, TestCodecOperators) { |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
207 // Test a codec with a dynamic payload type. | 206 // Test a codec with a dynamic payload type. |
208 VideoCodec c1(96, "V", 320, 200, 30, 3); | 207 VideoCodec c1(96, "V", 320, 200, 30, 3); |
209 EXPECT_TRUE(c1.Matches(VideoCodec(96, "V", 640, 400, 15, 0))); | 208 EXPECT_TRUE(c1.Matches(VideoCodec(96, "V", 640, 400, 15, 0))); |
210 EXPECT_TRUE(c1.Matches(VideoCodec(97, "V", 640, 400, 15, 0))); | 209 EXPECT_TRUE(c1.Matches(VideoCodec(97, "V", 640, 400, 15, 0))); |
211 EXPECT_TRUE(c1.Matches(VideoCodec(96, "v", 640, 400, 15, 0))); | 210 EXPECT_TRUE(c1.Matches(VideoCodec(96, "v", 640, 400, 15, 0))); |
212 EXPECT_TRUE(c1.Matches(VideoCodec(97, "v", 640, 400, 15, 0))); | 211 EXPECT_TRUE(c1.Matches(VideoCodec(97, "v", 640, 400, 15, 0))); |
213 EXPECT_FALSE(c1.Matches(VideoCodec(96, "", 320, 200, 30, 0))); | 212 EXPECT_FALSE(c1.Matches(VideoCodec(96, "", 320, 200, 30, 0))); |
214 EXPECT_FALSE(c1.Matches(VideoCodec(95, "V", 640, 400, 15, 0))); | 213 EXPECT_FALSE(c1.Matches(VideoCodec(95, "V", 640, 400, 15, 0))); |
215 } | 214 } |
216 | 215 |
217 TEST_F(CodecTest, TestVideoEncoderConfigOperators) { | |
218 VideoEncoderConfig c1(VideoCodec( | |
219 96, "SVC", 320, 200, 30, 3), 1, 2); | |
220 VideoEncoderConfig c2(VideoCodec( | |
221 95, "SVC", 320, 200, 30, 3), 1, 2); | |
222 VideoEncoderConfig c3(VideoCodec( | |
223 96, "xxx", 320, 200, 30, 3), 1, 2); | |
224 VideoEncoderConfig c4(VideoCodec( | |
225 96, "SVC", 120, 200, 30, 3), 1, 2); | |
226 VideoEncoderConfig c5(VideoCodec( | |
227 96, "SVC", 320, 100, 30, 3), 1, 2); | |
228 VideoEncoderConfig c6(VideoCodec( | |
229 96, "SVC", 320, 200, 10, 3), 1, 2); | |
230 VideoEncoderConfig c7(VideoCodec( | |
231 96, "SVC", 320, 200, 30, 1), 1, 2); | |
232 VideoEncoderConfig c8(VideoCodec( | |
233 96, "SVC", 320, 200, 30, 3), 0, 2); | |
234 VideoEncoderConfig c9(VideoCodec( | |
235 96, "SVC", 320, 200, 30, 3), 1, 1); | |
236 EXPECT_TRUE(c1 != c2); | |
237 EXPECT_TRUE(c1 != c2); | |
238 EXPECT_TRUE(c1 != c3); | |
239 EXPECT_TRUE(c1 != c4); | |
240 EXPECT_TRUE(c1 != c5); | |
241 EXPECT_TRUE(c1 != c6); | |
242 EXPECT_TRUE(c1 != c7); | |
243 EXPECT_TRUE(c1 != c8); | |
244 EXPECT_TRUE(c1 != c9); | |
245 | |
246 VideoEncoderConfig c10; | |
247 VideoEncoderConfig c11(VideoCodec( | |
248 0, "", 0, 0, 0, 0)); | |
249 VideoEncoderConfig c12(VideoCodec( | |
250 0, "", 0, 0, 0, 0), | |
251 VideoEncoderConfig::kDefaultMaxThreads, | |
252 VideoEncoderConfig::kDefaultCpuProfile); | |
253 VideoEncoderConfig c13 = c1; | |
254 VideoEncoderConfig c14(VideoCodec( | |
255 0, "", 0, 0, 0, 0), 0, 0); | |
256 | |
257 EXPECT_TRUE(c11 == c10); | |
258 EXPECT_TRUE(c12 == c10); | |
259 EXPECT_TRUE(c13 != c10); | |
260 EXPECT_TRUE(c13 == c1); | |
261 EXPECT_TRUE(c14 != c11); | |
262 EXPECT_TRUE(c14 != c12); | |
263 } | |
264 | |
265 TEST_F(CodecTest, TestDataCodecMatches) { | 216 TEST_F(CodecTest, TestDataCodecMatches) { |
266 // Test a codec with a static payload type. | 217 // Test a codec with a static payload type. |
267 DataCodec c0(95, "D", 0); | 218 DataCodec c0(95, "D", 0); |
268 EXPECT_TRUE(c0.Matches(DataCodec(95, "", 0))); | 219 EXPECT_TRUE(c0.Matches(DataCodec(95, "", 0))); |
269 EXPECT_FALSE(c0.Matches(DataCodec(96, "", 0))); | 220 EXPECT_FALSE(c0.Matches(DataCodec(96, "", 0))); |
270 | 221 |
271 // Test a codec with a dynamic payload type. | 222 // Test a codec with a dynamic payload type. |
272 DataCodec c1(96, "D", 3); | 223 DataCodec c1(96, "D", 3); |
273 EXPECT_TRUE(c1.Matches(DataCodec(96, "D", 0))); | 224 EXPECT_TRUE(c1.Matches(DataCodec(96, "D", 0))); |
274 EXPECT_TRUE(c1.Matches(DataCodec(97, "D", 0))); | 225 EXPECT_TRUE(c1.Matches(DataCodec(97, "D", 0))); |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
388 equal_bitrates.params[kCodecParamMinBitrate] = "100"; | 339 equal_bitrates.params[kCodecParamMinBitrate] = "100"; |
389 equal_bitrates.params[kCodecParamMaxBitrate] = "100"; | 340 equal_bitrates.params[kCodecParamMaxBitrate] = "100"; |
390 EXPECT_TRUE(equal_bitrates.ValidateCodecFormat()); | 341 EXPECT_TRUE(equal_bitrates.ValidateCodecFormat()); |
391 | 342 |
392 // Accept min bitrate < max bitrate. | 343 // Accept min bitrate < max bitrate. |
393 VideoCodec different_bitrates = codec; | 344 VideoCodec different_bitrates = codec; |
394 different_bitrates.params[kCodecParamMinBitrate] = "99"; | 345 different_bitrates.params[kCodecParamMinBitrate] = "99"; |
395 different_bitrates.params[kCodecParamMaxBitrate] = "100"; | 346 different_bitrates.params[kCodecParamMaxBitrate] = "100"; |
396 EXPECT_TRUE(different_bitrates.ValidateCodecFormat()); | 347 EXPECT_TRUE(different_bitrates.ValidateCodecFormat()); |
397 } | 348 } |
OLD | NEW |