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

Side by Side Diff: net/base/mime_util.cc

Issue 816353010: Implemented HEVC video demuxing and parsing (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added hevc handling in media/base/android/media_codec_bridge.cc Created 5 years, 9 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 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 <algorithm> 5 #include <algorithm>
6 #include <iterator> 6 #include <iterator>
7 #include <map> 7 #include <map>
8 #include <string> 8 #include <string>
9 9
10 #include "base/containers/hash_tables.h" 10 #include "base/containers/hash_tables.h"
(...skipping 27 matching lines...) Expand all
38 MPEG2_AAC_MAIN, 38 MPEG2_AAC_MAIN,
39 MPEG2_AAC_SSR, 39 MPEG2_AAC_SSR,
40 MPEG4_AAC_LC, 40 MPEG4_AAC_LC,
41 MPEG4_AAC_SBR_v1, 41 MPEG4_AAC_SBR_v1,
42 MPEG4_AAC_SBR_PS_v2, 42 MPEG4_AAC_SBR_PS_v2,
43 VORBIS, 43 VORBIS,
44 OPUS, 44 OPUS,
45 H264_BASELINE, 45 H264_BASELINE,
46 H264_MAIN, 46 H264_MAIN,
47 H264_HIGH, 47 H264_HIGH,
48 HEVC_MAIN,
48 VP8, 49 VP8,
49 VP9, 50 VP9,
50 THEORA 51 THEORA
51 }; 52 };
52 53
53 bool GetMimeTypeFromExtension(const base::FilePath::StringType& ext, 54 bool GetMimeTypeFromExtension(const base::FilePath::StringType& ext,
54 std::string* mime_type) const; 55 std::string* mime_type) const;
55 56
56 bool GetMimeTypeFromFile(const base::FilePath& file_path, 57 bool GetMimeTypeFromFile(const base::FilePath& file_path,
57 std::string* mime_type) const; 58 std::string* mime_type) const;
(...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after
459 case MimeUtil::MPEG4_AAC_LC: 460 case MimeUtil::MPEG4_AAC_LC:
460 case MimeUtil::MPEG4_AAC_SBR_v1: 461 case MimeUtil::MPEG4_AAC_SBR_v1:
461 case MimeUtil::MPEG4_AAC_SBR_PS_v2: 462 case MimeUtil::MPEG4_AAC_SBR_PS_v2:
462 case MimeUtil::H264_BASELINE: 463 case MimeUtil::H264_BASELINE:
463 case MimeUtil::H264_MAIN: 464 case MimeUtil::H264_MAIN:
464 case MimeUtil::H264_HIGH: 465 case MimeUtil::H264_HIGH:
465 case MimeUtil::VP8: 466 case MimeUtil::VP8:
466 case MimeUtil::VORBIS: 467 case MimeUtil::VORBIS:
467 return true; 468 return true;
468 469
470 case MimeUtil::HEVC_MAIN:
471 // HEVC/H.265 is supported only in Lollipop+ (API Level 21). According to
ddorwin 2015/03/25 01:21:59 #if defined(ENABLE_HEVC_DEMUXING) ... #else retu
servolk 2015/03/25 02:20:21 Done.
472 // http://developer.android.com/reference/android/media/MediaFormat.html
473 return base::android::BuildInfo::GetInstance()->sdk_int() >= 21;
474
469 case MimeUtil::MPEG2_AAC_LC: 475 case MimeUtil::MPEG2_AAC_LC:
470 case MimeUtil::MPEG2_AAC_MAIN: 476 case MimeUtil::MPEG2_AAC_MAIN:
471 case MimeUtil::MPEG2_AAC_SSR: 477 case MimeUtil::MPEG2_AAC_SSR:
472 // MPEG-2 variants of AAC are not supported on Android. 478 // MPEG-2 variants of AAC are not supported on Android.
473 return false; 479 return false;
474 480
475 case MimeUtil::VP9: 481 case MimeUtil::VP9:
476 // VP9 is supported only in KitKat+ (API Level 19). 482 // VP9 is supported only in KitKat+ (API Level 19).
477 return base::android::BuildInfo::GetInstance()->sdk_int() >= 19; 483 return base::android::BuildInfo::GetInstance()->sdk_int() >= 19;
478 484
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
513 "mp4a.66,mp4a.67,mp4a.68,mp4a.69,mp4a.6B,mp4a.40.2,mp4a.40.02,mp4a.40.5," 519 "mp4a.66,mp4a.67,mp4a.68,mp4a.69,mp4a.6B,mp4a.40.2,mp4a.40.02,mp4a.40.5,"
514 "mp4a.40.05,mp4a.40.29"; 520 "mp4a.40.05,mp4a.40.29";
515 static const char kMP4VideoCodecsExpression[] = 521 static const char kMP4VideoCodecsExpression[] =
516 // This is not a complete list of supported avc1 codecs. It is simply used 522 // This is not a complete list of supported avc1 codecs. It is simply used
517 // to register support for the corresponding Codec enum. Instead of using 523 // to register support for the corresponding Codec enum. Instead of using
518 // strings in these three arrays, we should use the Codec enum values. 524 // strings in these three arrays, we should use the Codec enum values.
519 // This will avoid confusion and unnecessary parsing at runtime. 525 // This will avoid confusion and unnecessary parsing at runtime.
520 // kUnambiguousCodecStringMap/kAmbiguousCodecStringMap should be the only 526 // kUnambiguousCodecStringMap/kAmbiguousCodecStringMap should be the only
521 // mapping from strings to codecs. See crbug.com/461009. 527 // mapping from strings to codecs. See crbug.com/461009.
522 "avc1.42E00A,avc1.4D400A,avc1.64000A," 528 "avc1.42E00A,avc1.4D400A,avc1.64000A,"
529 #if defined(ENABLE_HEVC_DEMUXING)
530 // Any valid-looking HEVC string will work here, since these strings are
531 // parsed and mapped to MimeUtil::Codec enum values.
532 "hvc1.1.L0.0,"
533 #endif
523 "mp4a.66,mp4a.67,mp4a.68,mp4a.69,mp4a.6B,mp4a.40.2,mp4a.40.02,mp4a.40.5," 534 "mp4a.66,mp4a.67,mp4a.68,mp4a.69,mp4a.6B,mp4a.40.2,mp4a.40.02,mp4a.40.5,"
524 "mp4a.40.05,mp4a.40.29"; 535 "mp4a.40.05,mp4a.40.29";
525 536
526 // These containers are also included in 537 // These containers are also included in
527 // common_media_types/proprietary_media_types. See crbug.com/461012. 538 // common_media_types/proprietary_media_types. See crbug.com/461012.
528 static const MediaFormatStrict format_codec_mappings[] = { 539 static const MediaFormatStrict format_codec_mappings[] = {
529 {"video/webm", "opus,vorbis,vp8,vp8.0,vp9,vp9.0"}, 540 {"video/webm", "opus,vorbis,vp8,vp8.0,vp9,vp9.0"},
530 {"audio/webm", "opus,vorbis"}, 541 {"audio/webm", "opus,vorbis"},
531 {"audio/wav", "1"}, 542 {"audio/wav", "1"},
532 {"audio/x-wav", "1"}, 543 {"audio/x-wav", "1"},
(...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after
1030 bool* is_ambiguous) const { 1041 bool* is_ambiguous) const {
1031 StringToCodecMappings::const_iterator itr = 1042 StringToCodecMappings::const_iterator itr =
1032 string_to_codec_map_.find(codec_id); 1043 string_to_codec_map_.find(codec_id);
1033 if (itr != string_to_codec_map_.end()) { 1044 if (itr != string_to_codec_map_.end()) {
1034 *codec = itr->second.codec; 1045 *codec = itr->second.codec;
1035 *is_ambiguous = itr->second.is_ambiguous; 1046 *is_ambiguous = itr->second.is_ambiguous;
1036 return true; 1047 return true;
1037 } 1048 }
1038 1049
1039 // If |codec_id| is not in |string_to_codec_map_|, then we assume that it is 1050 // If |codec_id| is not in |string_to_codec_map_|, then we assume that it is
1040 // an H.264 codec ID because currently those are the only ones that can't be 1051 // either H.264 or HEVC/H.265 codec ID because currently those are the only
1041 // stored in the |string_to_codec_map_| and require parsing. 1052 // ones that can't be added to the |string_to_codec_map_| and require parsing.
ddorwin 2015/03/25 01:21:59 nit: "can't be"? are not?
servolk 2015/03/25 02:20:20 Done.
1053
1054 #if defined(ENABLE_HEVC_DEMUXING)
ddorwin 2015/03/25 01:21:59 Move this code to ParseHEVCCodecID or something li
servolk 2015/03/25 02:20:20 Done.
1055 if (StartsWithASCII(codec_id, "hev1.", true) ||
1056 StartsWithASCII(codec_id, "hvc1.", true)) {
1057 // TODO(servolk): Implement parsing of hevc codec ids as described in
1058 // ETSI TS 126 244 standard section A.2.2, but for now allow any
1059 // HEVC tiers/profiles and let decoder decide if it can handle that.
1060 *codec = MimeUtil::HEVC_MAIN;
1061 *is_ambiguous = false;
ddorwin 2015/03/25 01:21:59 This should be true since you do no verification.
servolk 2015/03/25 02:20:20 Done.
1062 return true;
1063 }
1064 #endif
1065
1042 return ParseH264CodecID(codec_id, codec, is_ambiguous); 1066 return ParseH264CodecID(codec_id, codec, is_ambiguous);
1043 } 1067 }
1044 1068
1045 bool MimeUtil::IsCodecSupported(Codec codec) const { 1069 bool MimeUtil::IsCodecSupported(Codec codec) const {
1046 DCHECK_NE(codec, INVALID_CODEC); 1070 DCHECK_NE(codec, INVALID_CODEC);
1047 1071
1048 #if defined(OS_ANDROID) 1072 #if defined(OS_ANDROID)
1049 if (!IsCodecSupportedOnAndroid(codec)) 1073 if (!IsCodecSupportedOnAndroid(codec))
1050 return false; 1074 return false;
1051 #endif 1075 #endif
1052 1076
1053 return allow_proprietary_codecs_ || !IsCodecProprietary(codec); 1077 return allow_proprietary_codecs_ || !IsCodecProprietary(codec);
1054 } 1078 }
1055 1079
1056 bool MimeUtil::IsCodecProprietary(Codec codec) const { 1080 bool MimeUtil::IsCodecProprietary(Codec codec) const {
1057 switch (codec) { 1081 switch (codec) {
1058 case INVALID_CODEC: 1082 case INVALID_CODEC:
1059 case MP3: 1083 case MP3:
1060 case MPEG2_AAC_LC: 1084 case MPEG2_AAC_LC:
1061 case MPEG2_AAC_MAIN: 1085 case MPEG2_AAC_MAIN:
1062 case MPEG2_AAC_SSR: 1086 case MPEG2_AAC_SSR:
1063 case MPEG4_AAC_LC: 1087 case MPEG4_AAC_LC:
1064 case MPEG4_AAC_SBR_v1: 1088 case MPEG4_AAC_SBR_v1:
1065 case MPEG4_AAC_SBR_PS_v2: 1089 case MPEG4_AAC_SBR_PS_v2:
1066 case H264_BASELINE: 1090 case H264_BASELINE:
1067 case H264_MAIN: 1091 case H264_MAIN:
1068 case H264_HIGH: 1092 case H264_HIGH:
1093 case HEVC_MAIN:
1069 return true; 1094 return true;
1070 1095
1071 case PCM: 1096 case PCM:
1072 case VORBIS: 1097 case VORBIS:
1073 case OPUS: 1098 case OPUS:
1074 case VP8: 1099 case VP8:
1075 case VP9: 1100 case VP9:
1076 case THEORA: 1101 case THEORA:
1077 return false; 1102 return false;
1078 } 1103 }
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after
1409 post_data->append("\r\n" + value + "\r\n"); 1434 post_data->append("\r\n" + value + "\r\n");
1410 } 1435 }
1411 1436
1412 void AddMultipartFinalDelimiterForUpload(const std::string& mime_boundary, 1437 void AddMultipartFinalDelimiterForUpload(const std::string& mime_boundary,
1413 std::string* post_data) { 1438 std::string* post_data) {
1414 DCHECK(post_data); 1439 DCHECK(post_data);
1415 post_data->append("--" + mime_boundary + "--\r\n"); 1440 post_data->append("--" + mime_boundary + "--\r\n");
1416 } 1441 }
1417 1442
1418 } // namespace net 1443 } // namespace net
OLDNEW
« media/filters/stream_parser_factory.cc ('K') | « media/test/data/bear-hevc-frag.mp4 ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698