| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include <stddef.h> | 5 #include <stddef.h> |
| 6 | 6 |
| 7 #include "base/macros.h" | 7 #include "base/macros.h" |
| 8 #include "base/strings/string_split.h" | 8 #include "base/strings/string_split.h" |
| 9 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
| 10 #include "base/test/scoped_command_line.h" | 10 #include "base/test/scoped_command_line.h" |
| (...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 259 &out_colorspace)); | 259 &out_colorspace)); |
| 260 if (kUsePropCodecs) { | 260 if (kUsePropCodecs) { |
| 261 EXPECT_FALSE(out_is_ambiguous); | 261 EXPECT_FALSE(out_is_ambiguous); |
| 262 EXPECT_EQ(kCodecH264, out_codec); | 262 EXPECT_EQ(kCodecH264, out_codec); |
| 263 EXPECT_EQ(H264PROFILE_BASELINE, out_profile); | 263 EXPECT_EQ(H264PROFILE_BASELINE, out_profile); |
| 264 EXPECT_EQ(30, out_level); | 264 EXPECT_EQ(30, out_level); |
| 265 EXPECT_EQ(VideoColorSpace::REC709(), out_colorspace); | 265 EXPECT_EQ(VideoColorSpace::REC709(), out_colorspace); |
| 266 } | 266 } |
| 267 | 267 |
| 268 // Valid VP9 string. | 268 // Valid VP9 string. |
| 269 EnableNewVp9CodecStringSupport(); | |
| 270 EXPECT_TRUE(ParseVideoCodecString("video/webm", "vp09.00.10.08", | 269 EXPECT_TRUE(ParseVideoCodecString("video/webm", "vp09.00.10.08", |
| 271 &out_is_ambiguous, &out_codec, &out_profile, | 270 &out_is_ambiguous, &out_codec, &out_profile, |
| 272 &out_level, &out_colorspace)); | 271 &out_level, &out_colorspace)); |
| 273 EXPECT_FALSE(out_is_ambiguous); | 272 EXPECT_FALSE(out_is_ambiguous); |
| 274 EXPECT_EQ(kCodecVP9, out_codec); | 273 EXPECT_EQ(kCodecVP9, out_codec); |
| 275 EXPECT_EQ(VP9PROFILE_PROFILE0, out_profile); | 274 EXPECT_EQ(VP9PROFILE_PROFILE0, out_profile); |
| 276 EXPECT_EQ(10, out_level); | 275 EXPECT_EQ(10, out_level); |
| 277 EXPECT_EQ(VideoColorSpace::REC709(), out_colorspace); | 276 EXPECT_EQ(VideoColorSpace::REC709(), out_colorspace); |
| 278 | 277 |
| 279 // Valid VP9 string with REC601 color space. | 278 // Valid VP9 string with REC601 color space. |
| 280 EXPECT_TRUE(ParseVideoCodecString("video/webm", "vp09.02.10.10.01.06.06.06", | 279 EXPECT_TRUE(ParseVideoCodecString("video/webm", "vp09.02.10.10.01.06.06.06", |
| 281 &out_is_ambiguous, &out_codec, &out_profile, | 280 &out_is_ambiguous, &out_codec, &out_profile, |
| 282 &out_level, &out_colorspace)); | 281 &out_level, &out_colorspace)); |
| 283 EXPECT_FALSE(out_is_ambiguous); | 282 EXPECT_FALSE(out_is_ambiguous); |
| 284 EXPECT_EQ(kCodecVP9, out_codec); | 283 EXPECT_EQ(kCodecVP9, out_codec); |
| 285 EXPECT_EQ(VP9PROFILE_PROFILE2, out_profile); | 284 EXPECT_EQ(VP9PROFILE_PROFILE2, out_profile); |
| 286 EXPECT_EQ(10, out_level); | 285 EXPECT_EQ(10, out_level); |
| 287 EXPECT_EQ(VideoColorSpace::REC601(), out_colorspace); | 286 EXPECT_EQ(VideoColorSpace::REC601(), out_colorspace); |
| 288 | 287 |
| 289 // Restore to avoid polluting other tests. | |
| 290 DisableNewVp9CodecStringSupport_ForTesting(); | |
| 291 | |
| 292 // Ambiguous AVC string (when proprietary codecs are supported). | 288 // Ambiguous AVC string (when proprietary codecs are supported). |
| 293 EXPECT_EQ( | 289 EXPECT_EQ( |
| 294 kUsePropCodecs, | 290 kUsePropCodecs, |
| 295 ParseVideoCodecString("video/mp4", "avc3", &out_is_ambiguous, &out_codec, | 291 ParseVideoCodecString("video/mp4", "avc3", &out_is_ambiguous, &out_codec, |
| 296 &out_profile, &out_level, &out_colorspace)); | 292 &out_profile, &out_level, &out_colorspace)); |
| 297 if (kUsePropCodecs) { | 293 if (kUsePropCodecs) { |
| 298 EXPECT_TRUE(out_is_ambiguous); | 294 EXPECT_TRUE(out_is_ambiguous); |
| 299 EXPECT_EQ(kCodecH264, out_codec); | 295 EXPECT_EQ(kCodecH264, out_codec); |
| 300 EXPECT_EQ(VIDEO_CODEC_PROFILE_UNKNOWN, out_profile); | 296 EXPECT_EQ(VIDEO_CODEC_PROFILE_UNKNOWN, out_profile); |
| 301 EXPECT_EQ(0, out_level); | 297 EXPECT_EQ(0, out_level); |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 357 | 353 |
| 358 // Video codec is not valid for audio API. | 354 // Video codec is not valid for audio API. |
| 359 EXPECT_FALSE(ParseAudioCodecString("audio/webm", "vp09.00.10.08", | 355 EXPECT_FALSE(ParseAudioCodecString("audio/webm", "vp09.00.10.08", |
| 360 &out_is_ambiguous, &out_codec)); | 356 &out_is_ambiguous, &out_codec)); |
| 361 | 357 |
| 362 // Made up codec is also not valid. | 358 // Made up codec is also not valid. |
| 363 EXPECT_FALSE(ParseAudioCodecString("audio/webm", "bogus", &out_is_ambiguous, | 359 EXPECT_FALSE(ParseAudioCodecString("audio/webm", "bogus", &out_is_ambiguous, |
| 364 &out_codec)); | 360 &out_codec)); |
| 365 } | 361 } |
| 366 | 362 |
| 367 // See deeper string parsing testing in video_codecs_unittests.cc. | |
| 368 TEST(MimeUtilTest, ExperimentalMultiPartVp9) { | |
| 369 | |
| 370 // Multi-part VP9 string not enabled by default. | |
| 371 EXPECT_FALSE(IsSupportedMediaFormat("video/webm", {"vp09.00.10.08"})); | |
| 372 | |
| 373 // Should work if enabled. | |
| 374 EnableNewVp9CodecStringSupport(); | |
| 375 EXPECT_TRUE(IsSupportedMediaFormat("video/webm", {"vp09.00.10.08"})); | |
| 376 // Restore to avoid polluting other tests. | |
| 377 DisableNewVp9CodecStringSupport_ForTesting(); | |
| 378 } | |
| 379 | |
| 380 TEST(IsCodecSupportedOnAndroidTest, EncryptedCodecsFailWithoutPlatformSupport) { | 363 TEST(IsCodecSupportedOnAndroidTest, EncryptedCodecsFailWithoutPlatformSupport) { |
| 381 // Vary all parameters except |has_platform_decoders|. | 364 // Vary all parameters except |has_platform_decoders|. |
| 382 MimeUtil::PlatformInfo states_to_vary = VaryAllFields(); | 365 MimeUtil::PlatformInfo states_to_vary = VaryAllFields(); |
| 383 states_to_vary.has_platform_decoders = false; | 366 states_to_vary.has_platform_decoders = false; |
| 384 | 367 |
| 385 // Disable platform decoders. | 368 // Disable platform decoders. |
| 386 MimeUtil::PlatformInfo test_states; | 369 MimeUtil::PlatformInfo test_states; |
| 387 test_states.has_platform_decoders = false; | 370 test_states.has_platform_decoders = false; |
| 388 | 371 |
| 389 // Every codec should fail since platform support is missing and we've | 372 // Every codec should fail since platform support is missing and we've |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 550 } | 533 } |
| 551 | 534 |
| 552 // NOTE | 535 // NOTE |
| 553 // We do not call IsCodecSupportedOnAndroid because the following checks | 536 // We do not call IsCodecSupportedOnAndroid because the following checks |
| 554 // are made at a higher level in mime code (parsing rather than checks for | 537 // are made at a higher level in mime code (parsing rather than checks for |
| 555 // platform support). | 538 // platform support). |
| 556 } | 539 } |
| 557 | 540 |
| 558 } // namespace internal | 541 } // namespace internal |
| 559 } // namespace media | 542 } // namespace media |
| OLD | NEW |