| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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 "media/base/mime_util_internal.h" | 5 #include "media/base/mime_util_internal.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/strings/string_number_conversions.h" | 8 #include "base/strings/string_number_conversions.h" |
| 9 #include "base/strings/string_split.h" | 9 #include "base/strings/string_split.h" |
| 10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 // multiplied by ten, e.g. level_idc==32 corresponds to level==3.2 | 115 // multiplied by ten, e.g. level_idc==32 corresponds to level==3.2 |
| 116 return ((level_idc >= 10 && level_idc <= 13) || | 116 return ((level_idc >= 10 && level_idc <= 13) || |
| 117 (level_idc >= 20 && level_idc <= 22) || | 117 (level_idc >= 20 && level_idc <= 22) || |
| 118 (level_idc >= 30 && level_idc <= 32) || | 118 (level_idc >= 30 && level_idc <= 32) || |
| 119 (level_idc >= 40 && level_idc <= 42) || | 119 (level_idc >= 40 && level_idc <= 42) || |
| 120 (level_idc >= 50 && level_idc <= 51)); | 120 (level_idc >= 50 && level_idc <= 51)); |
| 121 } | 121 } |
| 122 | 122 |
| 123 MimeUtil::MimeUtil() : allow_proprietary_codecs_(false) { | 123 MimeUtil::MimeUtil() : allow_proprietary_codecs_(false) { |
| 124 #if defined(OS_ANDROID) | 124 #if defined(OS_ANDROID) |
| 125 platform_info_.is_unified_media_pipeline_enabled = | |
| 126 IsUnifiedMediaPipelineEnabled(); | |
| 127 // When the unified media pipeline is enabled, we need support for both GPU | 125 // When the unified media pipeline is enabled, we need support for both GPU |
| 128 // video decoders and MediaCodec; indicated by HasPlatformDecoderSupport(). | 126 // video decoders and MediaCodec; indicated by HasPlatformDecoderSupport(). |
| 129 // When the Android pipeline is used, we only need access to MediaCodec. | 127 // When the Android pipeline is used, we only need access to MediaCodec. |
| 130 platform_info_.has_platform_decoders = ArePlatformDecodersAvailable(); | 128 platform_info_.has_platform_decoders = HasPlatformDecoderSupport(); |
| 131 platform_info_.has_platform_vp8_decoder = | 129 platform_info_.has_platform_vp8_decoder = |
| 132 MediaCodecUtil::IsVp8DecoderAvailable(); | 130 MediaCodecUtil::IsVp8DecoderAvailable(); |
| 133 platform_info_.has_platform_vp9_decoder = | 131 platform_info_.has_platform_vp9_decoder = |
| 134 MediaCodecUtil::IsVp9DecoderAvailable(); | 132 MediaCodecUtil::IsVp9DecoderAvailable(); |
| 135 platform_info_.supports_opus = PlatformHasOpusSupport(); | 133 platform_info_.supports_opus = PlatformHasOpusSupport(); |
| 136 #endif | 134 #endif |
| 137 | 135 |
| 138 InitializeMimeTypeMaps(); | 136 InitializeMimeTypeMaps(); |
| 139 } | 137 } |
| 140 | 138 |
| (...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 457 return true; | 455 return true; |
| 458 | 456 |
| 459 case MPEG2_AAC: | 457 case MPEG2_AAC: |
| 460 // MPEG-2 variants of AAC are not supported on Android unless the unified | 458 // MPEG-2 variants of AAC are not supported on Android unless the unified |
| 461 // media pipeline can be used and the container is not HLS. These codecs | 459 // media pipeline can be used and the container is not HLS. These codecs |
| 462 // will be decoded in software. See https://crbug.com/544268 for details. | 460 // will be decoded in software. See https://crbug.com/544268 for details. |
| 463 if (base::EndsWith(mime_type_lower_case, "mpegurl", | 461 if (base::EndsWith(mime_type_lower_case, "mpegurl", |
| 464 base::CompareCase::SENSITIVE)) { | 462 base::CompareCase::SENSITIVE)) { |
| 465 return false; | 463 return false; |
| 466 } | 464 } |
| 467 return !is_encrypted && platform_info.is_unified_media_pipeline_enabled; | 465 return !is_encrypted; |
| 468 | 466 |
| 469 case OPUS: | 467 case OPUS: |
| 470 // If clear, the unified pipeline can always decode Opus in software. | 468 // If clear, the unified pipeline can always decode Opus in software. |
| 471 if (!is_encrypted && platform_info.is_unified_media_pipeline_enabled) | 469 if (!is_encrypted) |
| 472 return true; | 470 return true; |
| 473 | 471 |
| 474 // Otherwise, platform support is required. | 472 // Otherwise, platform support is required. |
| 475 if (!platform_info.supports_opus) | 473 if (!platform_info.supports_opus) |
| 476 return false; | 474 return false; |
| 477 | 475 |
| 478 // MediaPlayer does not support Opus in ogg containers. | 476 // MediaPlayer does not support Opus in ogg containers. |
| 479 if (base::EndsWith(mime_type_lower_case, "ogg", | 477 if (base::EndsWith(mime_type_lower_case, "ogg", |
| 480 base::CompareCase::SENSITIVE)) { | 478 base::CompareCase::SENSITIVE)) { |
| 481 return false; | 479 return false; |
| 482 } | 480 } |
| 483 | 481 |
| 484 DCHECK(!is_encrypted || platform_info.has_platform_decoders); | 482 DCHECK(!is_encrypted || platform_info.has_platform_decoders); |
| 485 return true; | 483 return true; |
| 486 | 484 |
| 487 case H264: | 485 case H264: |
| 488 // When content is not encrypted we fall back to MediaPlayer, thus we | 486 // When content is not encrypted we fall back to MediaPlayer, thus we |
| 489 // always support H264. For EME we need MediaCodec. | 487 // always support H264. For EME we need MediaCodec. |
| 490 return !is_encrypted || platform_info.has_platform_decoders; | 488 return !is_encrypted || platform_info.has_platform_decoders; |
| 491 | 489 |
| 492 case HEVC: | 490 case HEVC: |
| 493 #if BUILDFLAG(ENABLE_HEVC_DEMUXING) | 491 #if BUILDFLAG(ENABLE_HEVC_DEMUXING) |
| 494 if (platform_info.is_unified_media_pipeline_enabled && | 492 if (!platform_info.has_platform_decoders) |
| 495 !platform_info.has_platform_decoders) { | |
| 496 return false; | 493 return false; |
| 497 } | |
| 498 | 494 |
| 499 #if defined(OS_ANDROID) | 495 #if defined(OS_ANDROID) |
| 500 // HEVC/H.265 is supported in Lollipop+ (API Level 21), according to | 496 // HEVC/H.265 is supported in Lollipop+ (API Level 21), according to |
| 501 // http://developer.android.com/reference/android/media/MediaFormat.html | 497 // http://developer.android.com/reference/android/media/MediaFormat.html |
| 502 return base::android::BuildInfo::GetInstance()->sdk_int() >= 21; | 498 return base::android::BuildInfo::GetInstance()->sdk_int() >= 21; |
| 503 #else | 499 #else |
| 504 return true; | 500 return true; |
| 505 #endif // defined(OS_ANDROID) | 501 #endif // defined(OS_ANDROID) |
| 506 #else | 502 #else |
| 507 return false; | 503 return false; |
| 508 #endif // BUILDFLAG(ENABLE_HEVC_DEMUXING) | 504 #endif // BUILDFLAG(ENABLE_HEVC_DEMUXING) |
| 509 | 505 |
| 510 case VP8: | 506 case VP8: |
| 511 // If clear, the unified pipeline can always decode VP8 in software. | 507 // If clear, the unified pipeline can always decode VP8 in software. |
| 512 if (!is_encrypted && platform_info.is_unified_media_pipeline_enabled) | 508 if (!is_encrypted) |
| 513 return true; | 509 return true; |
| 514 | 510 |
| 515 if (is_encrypted) | 511 if (is_encrypted) |
| 516 return platform_info.has_platform_vp8_decoder; | 512 return platform_info.has_platform_vp8_decoder; |
| 517 | 513 |
| 518 // MediaPlayer can always play VP8. Note: This is incorrect for MSE, but | 514 // MediaPlayer can always play VP8. Note: This is incorrect for MSE, but |
| 519 // MSE does not use this code. http://crbug.com/587303. | 515 // MSE does not use this code. http://crbug.com/587303. |
| 520 return true; | 516 return true; |
| 521 | 517 |
| 522 case VP9: { | 518 case VP9: { |
| 523 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 519 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 524 switches::kReportVp9AsAnUnsupportedMimeType)) { | 520 switches::kReportVp9AsAnUnsupportedMimeType)) { |
| 525 return false; | 521 return false; |
| 526 } | 522 } |
| 527 | 523 |
| 528 // If clear, the unified pipeline can always decode VP9 in software. | 524 // If clear, the unified pipeline can always decode VP9 in software. |
| 529 if (!is_encrypted && platform_info.is_unified_media_pipeline_enabled) | 525 if (!is_encrypted) |
| 530 return true; | 526 return true; |
| 531 | 527 |
| 532 if (!platform_info.has_platform_vp9_decoder) | 528 if (!platform_info.has_platform_vp9_decoder) |
| 533 return false; | 529 return false; |
| 534 | 530 |
| 535 // Encrypted content is demuxed so the container is irrelevant. | 531 // Encrypted content is demuxed so the container is irrelevant. |
| 536 if (is_encrypted) | 532 if (is_encrypted) |
| 537 return true; | 533 return true; |
| 538 | 534 |
| 539 // MediaPlayer only supports VP9 in WebM. | 535 // MediaPlayer only supports VP9 in WebM. |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 690 const std::string& mime_type_lower_case, | 686 const std::string& mime_type_lower_case, |
| 691 bool is_encrypted) const { | 687 bool is_encrypted) const { |
| 692 Codec default_codec = Codec::INVALID_CODEC; | 688 Codec default_codec = Codec::INVALID_CODEC; |
| 693 if (!GetDefaultCodecLowerCase(mime_type_lower_case, &default_codec)) | 689 if (!GetDefaultCodecLowerCase(mime_type_lower_case, &default_codec)) |
| 694 return false; | 690 return false; |
| 695 return IsCodecSupported(default_codec, mime_type_lower_case, is_encrypted); | 691 return IsCodecSupported(default_codec, mime_type_lower_case, is_encrypted); |
| 696 } | 692 } |
| 697 | 693 |
| 698 } // namespace internal | 694 } // namespace internal |
| 699 } // namespace media | 695 } // namespace media |
| OLD | NEW |