| 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 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 353 DCHECK(!mp4_video_codecs.empty()); | 353 DCHECK(!mp4_video_codecs.empty()); |
| 354 AddContainerWithCodecs("video/mp2t", mp4_codecs, true); | 354 AddContainerWithCodecs("video/mp2t", mp4_codecs, true); |
| 355 #endif // BUILDFLAG(ENABLE_MSE_MPEG2TS_STREAM_PARSER) | 355 #endif // BUILDFLAG(ENABLE_MSE_MPEG2TS_STREAM_PARSER) |
| 356 #if defined(OS_ANDROID) | 356 #if defined(OS_ANDROID) |
| 357 // HTTP Live Streaming (HLS). | 357 // HTTP Live Streaming (HLS). |
| 358 // TODO(ddorwin): Is any MP3 codec string variant included in real queries? | 358 // TODO(ddorwin): Is any MP3 codec string variant included in real queries? |
| 359 CodecSet hls_codecs(avc_and_aac); | 359 CodecSet hls_codecs(avc_and_aac); |
| 360 hls_codecs.insert(MP3); | 360 hls_codecs.insert(MP3); |
| 361 AddContainerWithCodecs("application/x-mpegurl", hls_codecs, true); | 361 AddContainerWithCodecs("application/x-mpegurl", hls_codecs, true); |
| 362 AddContainerWithCodecs("application/vnd.apple.mpegurl", hls_codecs, true); | 362 AddContainerWithCodecs("application/vnd.apple.mpegurl", hls_codecs, true); |
| 363 AddContainerWithCodecs("audio/mpegurl", hls_codecs, true); |
| 364 // Not documented by Apple, but unfortunately used extensively by Apple and |
| 365 // others for both audio-only and audio+video playlists. See |
| 366 // https://crbug.com/675552 for details and examples. |
| 367 AddContainerWithCodecs("audio/x-mpegurl", hls_codecs, true); |
| 363 #endif // defined(OS_ANDROID) | 368 #endif // defined(OS_ANDROID) |
| 364 #endif // defined(USE_PROPRIETARY_CODECS) | 369 #endif // defined(USE_PROPRIETARY_CODECS) |
| 365 } | 370 } |
| 366 | 371 |
| 367 void MimeUtil::AddContainerWithCodecs(const std::string& mime_type, | 372 void MimeUtil::AddContainerWithCodecs(const std::string& mime_type, |
| 368 const CodecSet& codecs, | 373 const CodecSet& codecs, |
| 369 bool is_proprietary_mime_type) { | 374 bool is_proprietary_mime_type) { |
| 370 #if !defined(USE_PROPRIETARY_CODECS) | 375 #if !defined(USE_PROPRIETARY_CODECS) |
| 371 DCHECK(!is_proprietary_mime_type); | 376 DCHECK(!is_proprietary_mime_type); |
| 372 #endif | 377 #endif |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 495 case VORBIS: | 500 case VORBIS: |
| 496 // These codecs are always supported; via a platform decoder (when used | 501 // These codecs are always supported; via a platform decoder (when used |
| 497 // with MSE/EME), a software decoder (the unified pipeline), or with | 502 // with MSE/EME), a software decoder (the unified pipeline), or with |
| 498 // MediaPlayer. | 503 // MediaPlayer. |
| 499 DCHECK(!is_encrypted || platform_info.has_platform_decoders); | 504 DCHECK(!is_encrypted || platform_info.has_platform_decoders); |
| 500 return true; | 505 return true; |
| 501 | 506 |
| 502 case MPEG2_AAC: | 507 case MPEG2_AAC: |
| 503 // MPEG-2 variants of AAC are not supported on Android unless the unified | 508 // MPEG-2 variants of AAC are not supported on Android unless the unified |
| 504 // media pipeline can be used and the container is not HLS. These codecs | 509 // media pipeline can be used and the container is not HLS. These codecs |
| 505 // will be decoded in software. See https:crbug.com/544268 for details. | 510 // will be decoded in software. See https://crbug.com/544268 for details. |
| 506 if (mime_type_lower_case == "application/x-mpegurl" || | 511 if (base::EndsWith(mime_type_lower_case, "mpegurl", |
| 507 mime_type_lower_case == "application/vnd.apple.mpegurl") { | 512 base::CompareCase::SENSITIVE)) { |
| 508 return false; | 513 return false; |
| 509 } | 514 } |
| 510 return !is_encrypted && platform_info.is_unified_media_pipeline_enabled; | 515 return !is_encrypted && platform_info.is_unified_media_pipeline_enabled; |
| 511 | 516 |
| 512 case OPUS: | 517 case OPUS: |
| 513 // If clear, the unified pipeline can always decode Opus in software. | 518 // If clear, the unified pipeline can always decode Opus in software. |
| 514 if (!is_encrypted && platform_info.is_unified_media_pipeline_enabled) | 519 if (!is_encrypted && platform_info.is_unified_media_pipeline_enabled) |
| 515 return true; | 520 return true; |
| 516 | 521 |
| 517 // Otherwise, platform support is required. | 522 // Otherwise, platform support is required. |
| (...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 733 const std::string& mime_type_lower_case, | 738 const std::string& mime_type_lower_case, |
| 734 bool is_encrypted) const { | 739 bool is_encrypted) const { |
| 735 Codec default_codec = Codec::INVALID_CODEC; | 740 Codec default_codec = Codec::INVALID_CODEC; |
| 736 if (!GetDefaultCodecLowerCase(mime_type_lower_case, &default_codec)) | 741 if (!GetDefaultCodecLowerCase(mime_type_lower_case, &default_codec)) |
| 737 return false; | 742 return false; |
| 738 return IsCodecSupported(default_codec, mime_type_lower_case, is_encrypted); | 743 return IsCodecSupported(default_codec, mime_type_lower_case, is_encrypted); |
| 739 } | 744 } |
| 740 | 745 |
| 741 } // namespace internal | 746 } // namespace internal |
| 742 } // namespace media | 747 } // namespace media |
| OLD | NEW |