Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 62 MPEG4_AAC_SBR_v1, | 62 MPEG4_AAC_SBR_v1, |
| 63 MPEG4_AAC_SBR_PS_v2, | 63 MPEG4_AAC_SBR_PS_v2, |
| 64 VORBIS, | 64 VORBIS, |
| 65 OPUS, | 65 OPUS, |
| 66 H264_BASELINE, | 66 H264_BASELINE, |
| 67 H264_MAIN, | 67 H264_MAIN, |
| 68 H264_HIGH, | 68 H264_HIGH, |
| 69 VP8, | 69 VP8, |
| 70 VP9, | 70 VP9, |
| 71 THEORA | 71 THEORA |
| 72 #if defined(ENABLE_AC3_EAC3_AUDIO_DEMUXING) | |
| 73 , | |
| 74 AC3, | |
| 75 EAC3 | |
| 76 #endif | |
| 72 }; | 77 }; |
| 73 | 78 |
| 74 bool GetMimeTypeFromExtension(const base::FilePath::StringType& ext, | 79 bool GetMimeTypeFromExtension(const base::FilePath::StringType& ext, |
| 75 std::string* mime_type) const; | 80 std::string* mime_type) const; |
| 76 | 81 |
| 77 bool GetMimeTypeFromFile(const base::FilePath& file_path, | 82 bool GetMimeTypeFromFile(const base::FilePath& file_path, |
| 78 std::string* mime_type) const; | 83 std::string* mime_type) const; |
| 79 | 84 |
| 80 bool GetWellKnownMimeTypeFromExtension(const base::FilePath::StringType& ext, | 85 bool GetWellKnownMimeTypeFromExtension(const base::FilePath::StringType& ext, |
| 81 std::string* mime_type) const; | 86 std::string* mime_type) const; |
| (...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 484 case MimeUtil::VP8: | 489 case MimeUtil::VP8: |
| 485 case MimeUtil::VORBIS: | 490 case MimeUtil::VORBIS: |
| 486 return true; | 491 return true; |
| 487 | 492 |
| 488 case MimeUtil::MPEG2_AAC_LC: | 493 case MimeUtil::MPEG2_AAC_LC: |
| 489 case MimeUtil::MPEG2_AAC_MAIN: | 494 case MimeUtil::MPEG2_AAC_MAIN: |
| 490 case MimeUtil::MPEG2_AAC_SSR: | 495 case MimeUtil::MPEG2_AAC_SSR: |
| 491 // MPEG-2 variants of AAC are not supported on Android. | 496 // MPEG-2 variants of AAC are not supported on Android. |
| 492 return false; | 497 return false; |
| 493 | 498 |
| 499 #if defined(ENABLE_AC3_EAC3_AUDIO_DEMUXING) | |
| 500 case MimeUtil::AC3: | |
| 501 case MimeUtil::EAC3: | |
| 502 return false; | |
| 503 #endif | |
| 504 | |
| 494 case MimeUtil::VP9: | 505 case MimeUtil::VP9: |
| 495 // VP9 is supported only in KitKat+ (API Level 19). | 506 // VP9 is supported only in KitKat+ (API Level 19). |
| 496 return base::android::BuildInfo::GetInstance()->sdk_int() >= 19; | 507 return base::android::BuildInfo::GetInstance()->sdk_int() >= 19; |
| 497 | 508 |
| 498 case MimeUtil::OPUS: | 509 case MimeUtil::OPUS: |
| 499 // TODO(vigneshv): Change this similar to the VP9 check once Opus is | 510 // TODO(vigneshv): Change this similar to the VP9 check once Opus is |
| 500 // supported on Android (http://crbug.com/318436). | 511 // supported on Android (http://crbug.com/318436). |
| 501 return false; | 512 return false; |
| 502 | 513 |
| 503 case MimeUtil::THEORA: | 514 case MimeUtil::THEORA: |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 534 // mp4a.40.5 - MPEG-4 HE-AAC v1 (AAC LC + SBR) | 545 // mp4a.40.5 - MPEG-4 HE-AAC v1 (AAC LC + SBR) |
| 535 // mp4a.40.05 - MPEG-4 HE-AAC v1 (AAC LC + SBR) (leading 0 in aud-oti for | 546 // mp4a.40.05 - MPEG-4 HE-AAC v1 (AAC LC + SBR) (leading 0 in aud-oti for |
| 536 // compatibility) | 547 // compatibility) |
| 537 // mp4a.40.29 - MPEG-4 HE-AAC v2 (AAC LC + SBR + PS) | 548 // mp4a.40.29 - MPEG-4 HE-AAC v2 (AAC LC + SBR + PS) |
| 538 // | 549 // |
| 539 // avc1.42E0xx - H.264 Baseline | 550 // avc1.42E0xx - H.264 Baseline |
| 540 // avc1.4D40xx - H.264 Main | 551 // avc1.4D40xx - H.264 Main |
| 541 // avc1.6400xx - H.264 High | 552 // avc1.6400xx - H.264 High |
| 542 static const char kMP4AudioCodecsExpression[] = | 553 static const char kMP4AudioCodecsExpression[] = |
| 543 "mp4a.66,mp4a.67,mp4a.68,mp4a.69,mp4a.6B,mp4a.40.2,mp4a.40.02,mp4a.40.5," | 554 "mp4a.66,mp4a.67,mp4a.68,mp4a.69,mp4a.6B,mp4a.40.2,mp4a.40.02,mp4a.40.5," |
| 555 #if defined(ENABLE_AC3_EAC3_AUDIO_DEMUXING) | |
| 556 "ac-3,ec-3,mp4a.a5,mp4a.a6," | |
|
ddorwin
2015/02/26 20:49:32
You only need one each for AC3 and EAC3.
servolk
2015/02/26 22:00:59
Why? I believe these are just two different ways t
ddorwin
2015/02/26 22:06:18
Because this doesn't do what you think it does. (T
servolk
2015/02/26 22:29:20
Could you elaborate? As far as I can see this adds
ddorwin
2015/02/26 22:34:15
Yes, but format_codec_mappings is converted to enu
servolk
2015/02/26 22:43:54
Ah, ok, you are right, I missed the fact that they
| |
| 557 #endif | |
| 544 "mp4a.40.05,mp4a.40.29"; | 558 "mp4a.40.05,mp4a.40.29"; |
| 545 static const char kMP4VideoCodecsExpression[] = | 559 static const char kMP4VideoCodecsExpression[] = |
| 546 "avc1.42E00A,avc1.4D400A,avc1.64000A," | 560 "avc1.42E00A,avc1.4D400A,avc1.64000A," |
| 547 "mp4a.66,mp4a.67,mp4a.68,mp4a.69,mp4a.6B,mp4a.40.2,mp4a.40.02,mp4a.40.5," | 561 "mp4a.66,mp4a.67,mp4a.68,mp4a.69,mp4a.6B,mp4a.40.2,mp4a.40.02,mp4a.40.5," |
|
ddorwin
2015/02/26 22:06:18
You probably need to add those strings here too if
servolk
2015/02/26 22:29:20
Yes, that's probably a good idea, I'll do this. Bu
ddorwin
2015/02/26 22:34:15
Same as above: 2,
BTW, aac51 is not part of this C
| |
| 548 "mp4a.40.05,mp4a.40.29"; | 562 "mp4a.40.05,mp4a.40.29"; |
| 549 | 563 |
| 550 static const MediaFormatStrict format_codec_mappings[] = { | 564 static const MediaFormatStrict format_codec_mappings[] = { |
| 551 { "video/webm", "opus,vorbis,vp8,vp8.0,vp9,vp9.0" }, | 565 { "video/webm", "opus,vorbis,vp8,vp8.0,vp9,vp9.0" }, |
| 552 { "audio/webm", "opus,vorbis" }, | 566 { "audio/webm", "opus,vorbis" }, |
| 553 { "audio/wav", "1" }, | 567 { "audio/wav", "1" }, |
| 554 { "audio/x-wav", "1" }, | 568 { "audio/x-wav", "1" }, |
| 555 { "video/ogg", "opus,theora,vorbis" }, | 569 { "video/ogg", "opus,theora,vorbis" }, |
| 556 { "audio/ogg", "opus,vorbis" }, | 570 { "audio/ogg", "opus,vorbis" }, |
| 557 { "application/ogg", "opus,theora,vorbis" }, | 571 { "application/ogg", "opus,theora,vorbis" }, |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 581 {"mp4a.66", MimeUtil::MPEG2_AAC_MAIN}, | 595 {"mp4a.66", MimeUtil::MPEG2_AAC_MAIN}, |
| 582 {"mp4a.67", MimeUtil::MPEG2_AAC_LC}, | 596 {"mp4a.67", MimeUtil::MPEG2_AAC_LC}, |
| 583 {"mp4a.68", MimeUtil::MPEG2_AAC_SSR}, | 597 {"mp4a.68", MimeUtil::MPEG2_AAC_SSR}, |
| 584 {"mp4a.69", MimeUtil::MP3}, | 598 {"mp4a.69", MimeUtil::MP3}, |
| 585 {"mp4a.6B", MimeUtil::MP3}, | 599 {"mp4a.6B", MimeUtil::MP3}, |
| 586 {"mp4a.40.2", MimeUtil::MPEG4_AAC_LC}, | 600 {"mp4a.40.2", MimeUtil::MPEG4_AAC_LC}, |
| 587 {"mp4a.40.02", MimeUtil::MPEG4_AAC_LC}, | 601 {"mp4a.40.02", MimeUtil::MPEG4_AAC_LC}, |
| 588 {"mp4a.40.5", MimeUtil::MPEG4_AAC_SBR_v1}, | 602 {"mp4a.40.5", MimeUtil::MPEG4_AAC_SBR_v1}, |
| 589 {"mp4a.40.05", MimeUtil::MPEG4_AAC_SBR_v1}, | 603 {"mp4a.40.05", MimeUtil::MPEG4_AAC_SBR_v1}, |
| 590 {"mp4a.40.29", MimeUtil::MPEG4_AAC_SBR_PS_v2}, | 604 {"mp4a.40.29", MimeUtil::MPEG4_AAC_SBR_PS_v2}, |
| 605 #if defined(ENABLE_AC3_EAC3_AUDIO_DEMUXING) | |
| 606 {"ac-3", MimeUtil::AC3}, | |
|
ddorwin
2015/02/26 20:49:32
Please add browser tests.
servolk
2015/02/27 01:21:14
Done.
| |
| 607 {"ec-3", MimeUtil::EAC3}, | |
| 608 {"mp4a.a5", MimeUtil::AC3}, | |
| 609 {"mp4a.a6", MimeUtil::EAC3}, | |
| 610 #endif | |
| 591 {"vorbis", MimeUtil::VORBIS}, | 611 {"vorbis", MimeUtil::VORBIS}, |
| 592 {"opus", MimeUtil::OPUS}, | 612 {"opus", MimeUtil::OPUS}, |
| 593 {"vp8", MimeUtil::VP8}, | 613 {"vp8", MimeUtil::VP8}, |
| 594 {"vp8.0", MimeUtil::VP8}, | 614 {"vp8.0", MimeUtil::VP8}, |
| 595 {"vp9", MimeUtil::VP9}, | 615 {"vp9", MimeUtil::VP9}, |
| 596 {"vp9.0", MimeUtil::VP9}, | 616 {"vp9.0", MimeUtil::VP9}, |
| 597 {"theora", MimeUtil::THEORA}}; | 617 {"theora", MimeUtil::THEORA}}; |
| 598 | 618 |
| 599 // List of codec IDs that are ambiguous and don't provide | 619 // List of codec IDs that are ambiguous and don't provide |
| 600 // enough information to determine the codec and profile. | 620 // enough information to determine the codec and profile. |
| (...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 880 base::TrimString(codecs, "\"", &no_quote_codecs); | 900 base::TrimString(codecs, "\"", &no_quote_codecs); |
| 881 base::SplitString(no_quote_codecs, ',', codecs_out); | 901 base::SplitString(no_quote_codecs, ',', codecs_out); |
| 882 | 902 |
| 883 if (!strip) | 903 if (!strip) |
| 884 return; | 904 return; |
| 885 | 905 |
| 886 // Strip everything past the first '.' | 906 // Strip everything past the first '.' |
| 887 for (std::vector<std::string>::iterator it = codecs_out->begin(); | 907 for (std::vector<std::string>::iterator it = codecs_out->begin(); |
| 888 it != codecs_out->end(); | 908 it != codecs_out->end(); |
| 889 ++it) { | 909 ++it) { |
| 910 #if defined(ENABLE_AC3_EAC3_AUDIO_DEMUXING) | |
| 911 // We need to know the codec subtype to properly support AC3/EAC3. | |
|
ddorwin
2015/02/26 20:49:32
Why is stripping okay? I don't think that is the i
servolk
2015/02/26 22:00:59
Actually I'm not sure about that myself, that just
| |
| 912 // Do not strip the first '.' for mp4a.a5 and mp4a.a6. | |
| 913 if (it->compare("mp4a.a5") == 0 || it->compare("mp4a.a6") == 0) { | |
| 914 continue; | |
| 915 } | |
| 916 #endif | |
| 890 size_t found = it->find_first_of('.'); | 917 size_t found = it->find_first_of('.'); |
| 891 if (found != std::string::npos) | 918 if (found != std::string::npos) |
| 892 it->resize(found); | 919 it->resize(found); |
| 893 } | 920 } |
| 894 } | 921 } |
| 895 | 922 |
| 896 bool MimeUtil::IsStrictMediaMimeType(const std::string& mime_type) const { | 923 bool MimeUtil::IsStrictMediaMimeType(const std::string& mime_type) const { |
| 897 return strict_format_map_.find(mime_type) != strict_format_map_.end(); | 924 return strict_format_map_.find(mime_type) != strict_format_map_.end(); |
| 898 } | 925 } |
| 899 | 926 |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1052 case MP3: | 1079 case MP3: |
| 1053 case MPEG2_AAC_LC: | 1080 case MPEG2_AAC_LC: |
| 1054 case MPEG2_AAC_MAIN: | 1081 case MPEG2_AAC_MAIN: |
| 1055 case MPEG2_AAC_SSR: | 1082 case MPEG2_AAC_SSR: |
| 1056 case MPEG4_AAC_LC: | 1083 case MPEG4_AAC_LC: |
| 1057 case MPEG4_AAC_SBR_v1: | 1084 case MPEG4_AAC_SBR_v1: |
| 1058 case MPEG4_AAC_SBR_PS_v2: | 1085 case MPEG4_AAC_SBR_PS_v2: |
| 1059 case H264_BASELINE: | 1086 case H264_BASELINE: |
| 1060 case H264_MAIN: | 1087 case H264_MAIN: |
| 1061 case H264_HIGH: | 1088 case H264_HIGH: |
| 1089 #if defined(ENABLE_AC3_EAC3_AUDIO_DEMUXING) | |
| 1090 case AC3: | |
| 1091 case EAC3: | |
| 1092 #endif | |
| 1062 return true; | 1093 return true; |
| 1063 | 1094 |
| 1064 case PCM: | 1095 case PCM: |
| 1065 case VORBIS: | 1096 case VORBIS: |
| 1066 case OPUS: | 1097 case OPUS: |
| 1067 case VP8: | 1098 case VP8: |
| 1068 case VP9: | 1099 case VP9: |
| 1069 case THEORA: | 1100 case THEORA: |
| 1070 return false; | 1101 return false; |
| 1071 } | 1102 } |
| (...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1409 post_data->append("\r\n" + value + "\r\n"); | 1440 post_data->append("\r\n" + value + "\r\n"); |
| 1410 } | 1441 } |
| 1411 | 1442 |
| 1412 void AddMultipartFinalDelimiterForUpload(const std::string& mime_boundary, | 1443 void AddMultipartFinalDelimiterForUpload(const std::string& mime_boundary, |
| 1413 std::string* post_data) { | 1444 std::string* post_data) { |
| 1414 DCHECK(post_data); | 1445 DCHECK(post_data); |
| 1415 post_data->append("--" + mime_boundary + "--\r\n"); | 1446 post_data->append("--" + mime_boundary + "--\r\n"); |
| 1416 } | 1447 } |
| 1417 | 1448 |
| 1418 } // namespace net | 1449 } // namespace net |
| OLD | NEW |