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

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

Issue 952673002: Document some quirks of media MIME type code and reference related bugs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@cpt-tests
Patch Set: Created 5 years, 10 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 505 matching lines...) Expand 10 before | Expand all | Expand 10 after
516 // compatibility) 516 // compatibility)
517 // mp4a.40.29 - MPEG-4 HE-AAC v2 (AAC LC + SBR + PS) 517 // mp4a.40.29 - MPEG-4 HE-AAC v2 (AAC LC + SBR + PS)
518 // 518 //
519 // avc1.42E0xx - H.264 Baseline 519 // avc1.42E0xx - H.264 Baseline
520 // avc1.4D40xx - H.264 Main 520 // avc1.4D40xx - H.264 Main
521 // avc1.6400xx - H.264 High 521 // avc1.6400xx - H.264 High
522 static const char kMP4AudioCodecsExpression[] = 522 static const char kMP4AudioCodecsExpression[] =
523 "mp4a.66,mp4a.67,mp4a.68,mp4a.69,mp4a.6B,mp4a.40.2,mp4a.40.02,mp4a.40.5," 523 "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"; 524 "mp4a.40.05,mp4a.40.29";
525 static const char kMP4VideoCodecsExpression[] = 525 static const char kMP4VideoCodecsExpression[] =
526 // This is not a complete list of supported avc1 codecs. It is simply used
527 // to register support for the corresponding Codec enum. Instead of using
528 // strings in these three arrays, we should use the Codec enum values.
529 // This will avoid confusion and unnecessary parsing at runtime.
530 // kUnambiguousCodecStringMap/kAmbiguousCodecStringMap should be the only
531 // mapping from strings to codecs. See crbug.com/461009.
526 "avc1.42E00A,avc1.4D400A,avc1.64000A," 532 "avc1.42E00A,avc1.4D400A,avc1.64000A,"
527 "mp4a.66,mp4a.67,mp4a.68,mp4a.69,mp4a.6B,mp4a.40.2,mp4a.40.02,mp4a.40.5," 533 "mp4a.66,mp4a.67,mp4a.68,mp4a.69,mp4a.6B,mp4a.40.2,mp4a.40.02,mp4a.40.5,"
528 "mp4a.40.05,mp4a.40.29"; 534 "mp4a.40.05,mp4a.40.29";
529 535
536 // These containers are also included in
537 // common_media_types/proprietary_media_types. See crbug.com/461012.
530 static const MediaFormatStrict format_codec_mappings[] = { 538 static const MediaFormatStrict format_codec_mappings[] = {
531 {"video/webm", "opus,vorbis,vp8,vp8.0,vp9,vp9.0"}, 539 {"video/webm", "opus,vorbis,vp8,vp8.0,vp9,vp9.0"},
532 {"audio/webm", "opus,vorbis"}, 540 {"audio/webm", "opus,vorbis"},
533 {"audio/wav", "1"}, 541 {"audio/wav", "1"},
534 {"audio/x-wav", "1"}, 542 {"audio/x-wav", "1"},
535 // Android does not support Opus in Ogg container. 543 // Android does not support Opus in Ogg container.
536 #if defined(OS_ANDROID) 544 #if defined(OS_ANDROID)
537 {"video/ogg", "theora,vorbis"}, 545 {"video/ogg", "theora,vorbis"},
538 {"audio/ogg", "vorbis"}, 546 {"audio/ogg", "vorbis"},
539 {"application/ogg", "theora,vorbis"}, 547 {"application/ogg", "theora,vorbis"},
(...skipping 14 matching lines...) Expand all
554 562
555 struct CodecIDMappings { 563 struct CodecIDMappings {
556 const char* const codec_id; 564 const char* const codec_id;
557 MimeUtil::Codec codec; 565 MimeUtil::Codec codec;
558 }; 566 };
559 567
560 // List of codec IDs that provide enough information to determine the 568 // List of codec IDs that provide enough information to determine the
561 // codec and profile being requested. 569 // codec and profile being requested.
562 // 570 //
563 // The "mp4a" strings come from RFC 6381. 571 // The "mp4a" strings come from RFC 6381.
564 static const CodecIDMappings kUnambiguousCodecIDs[] = { 572 static const CodecIDMappings kUnambiguousCodecStringMap[] = {
565 {"1", MimeUtil::PCM}, // We only allow this for WAV so it isn't ambiguous. 573 {"1", MimeUtil::PCM}, // We only allow this for WAV so it isn't ambiguous.
574 // avc1/avc3.XXXXXX may be unambiguous; handled by ParseH264CodecID().
566 {"mp3", MimeUtil::MP3}, 575 {"mp3", MimeUtil::MP3},
567 {"mp4a.66", MimeUtil::MPEG2_AAC_MAIN}, 576 {"mp4a.66", MimeUtil::MPEG2_AAC_MAIN},
568 {"mp4a.67", MimeUtil::MPEG2_AAC_LC}, 577 {"mp4a.67", MimeUtil::MPEG2_AAC_LC},
569 {"mp4a.68", MimeUtil::MPEG2_AAC_SSR}, 578 {"mp4a.68", MimeUtil::MPEG2_AAC_SSR},
570 {"mp4a.69", MimeUtil::MP3}, 579 {"mp4a.69", MimeUtil::MP3},
571 {"mp4a.6B", MimeUtil::MP3}, 580 {"mp4a.6B", MimeUtil::MP3},
572 {"mp4a.40.2", MimeUtil::MPEG4_AAC_LC}, 581 {"mp4a.40.2", MimeUtil::MPEG4_AAC_LC},
573 {"mp4a.40.02", MimeUtil::MPEG4_AAC_LC}, 582 {"mp4a.40.02", MimeUtil::MPEG4_AAC_LC},
574 {"mp4a.40.5", MimeUtil::MPEG4_AAC_SBR_v1}, 583 {"mp4a.40.5", MimeUtil::MPEG4_AAC_SBR_v1},
575 {"mp4a.40.05", MimeUtil::MPEG4_AAC_SBR_v1}, 584 {"mp4a.40.05", MimeUtil::MPEG4_AAC_SBR_v1},
576 {"mp4a.40.29", MimeUtil::MPEG4_AAC_SBR_PS_v2}, 585 {"mp4a.40.29", MimeUtil::MPEG4_AAC_SBR_PS_v2},
577 {"vorbis", MimeUtil::VORBIS}, 586 {"vorbis", MimeUtil::VORBIS},
578 {"opus", MimeUtil::OPUS}, 587 {"opus", MimeUtil::OPUS},
579 {"vp8", MimeUtil::VP8}, 588 {"vp8", MimeUtil::VP8},
580 {"vp8.0", MimeUtil::VP8}, 589 {"vp8.0", MimeUtil::VP8},
581 {"vp9", MimeUtil::VP9}, 590 {"vp9", MimeUtil::VP9},
582 {"vp9.0", MimeUtil::VP9}, 591 {"vp9.0", MimeUtil::VP9},
583 {"theora", MimeUtil::THEORA}}; 592 {"theora", MimeUtil::THEORA}};
584 593
585 // List of codec IDs that are ambiguous and don't provide 594 // List of codec IDs that are ambiguous and don't provide
586 // enough information to determine the codec and profile. 595 // enough information to determine the codec and profile.
587 // The codec in these entries indicate the codec and profile 596 // The codec in these entries indicate the codec and profile
588 // we assume the user is trying to indicate. 597 // we assume the user is trying to indicate.
589 static const CodecIDMappings kAmbiguousCodecIDs[] = { 598 static const CodecIDMappings kAmbiguousCodecStringMap[] = {
590 { "mp4a.40", MimeUtil::MPEG4_AAC_LC }, 599 {"mp4a.40", MimeUtil::MPEG4_AAC_LC},
591 { "avc1", MimeUtil::H264_BASELINE }, 600 {"avc1", MimeUtil::H264_BASELINE},
592 { "avc3", MimeUtil::H264_BASELINE }, 601 {"avc3", MimeUtil::H264_BASELINE},
602 // avc1/avc3.XXXXXX may be ambiguous; handled by ParseH264CodecID().
593 }; 603 };
594 604
595 MimeUtil::MimeUtil() : allow_proprietary_codecs_(false) { 605 MimeUtil::MimeUtil() : allow_proprietary_codecs_(false) {
596 InitializeMimeTypeMaps(); 606 InitializeMimeTypeMaps();
597 } 607 }
598 608
599 SupportsType MimeUtil::AreSupportedCodecs( 609 SupportsType MimeUtil::AreSupportedCodecs(
600 const CodecSet& supported_codecs, 610 const CodecSet& supported_codecs,
601 const std::vector<std::string>& codecs) const { 611 const std::vector<std::string>& codecs) const {
602 DCHECK(!supported_codecs.empty()); 612 DCHECK(!supported_codecs.empty());
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
657 media_map_.insert(common_media_types[i]); 667 media_map_.insert(common_media_types[i]);
658 } 668 }
659 #if defined(USE_PROPRIETARY_CODECS) 669 #if defined(USE_PROPRIETARY_CODECS)
660 for (size_t i = 0; i < arraysize(proprietary_media_types); ++i) 670 for (size_t i = 0; i < arraysize(proprietary_media_types); ++i)
661 media_map_.insert(proprietary_media_types[i]); 671 media_map_.insert(proprietary_media_types[i]);
662 #endif 672 #endif
663 673
664 for (size_t i = 0; i < arraysize(supported_javascript_types); ++i) 674 for (size_t i = 0; i < arraysize(supported_javascript_types); ++i)
665 javascript_map_.insert(supported_javascript_types[i]); 675 javascript_map_.insert(supported_javascript_types[i]);
666 676
667 for (size_t i = 0; i < arraysize(kUnambiguousCodecIDs); ++i) { 677 for (size_t i = 0; i < arraysize(kUnambiguousCodecStringMap); ++i) {
668 string_to_codec_map_[kUnambiguousCodecIDs[i].codec_id] = 678 string_to_codec_map_[kUnambiguousCodecStringMap[i].codec_id] =
669 CodecEntry(kUnambiguousCodecIDs[i].codec, false); 679 CodecEntry(kUnambiguousCodecStringMap[i].codec, false);
670 } 680 }
671 681
672 for (size_t i = 0; i < arraysize(kAmbiguousCodecIDs); ++i) { 682 for (size_t i = 0; i < arraysize(kAmbiguousCodecStringMap); ++i) {
673 string_to_codec_map_[kAmbiguousCodecIDs[i].codec_id] = 683 string_to_codec_map_[kAmbiguousCodecStringMap[i].codec_id] =
674 CodecEntry(kAmbiguousCodecIDs[i].codec, true); 684 CodecEntry(kAmbiguousCodecStringMap[i].codec, true);
675 } 685 }
676 686
677 // Initialize the strict supported media types. 687 // Initialize the strict supported media types.
678 for (size_t i = 0; i < arraysize(format_codec_mappings); ++i) { 688 for (size_t i = 0; i < arraysize(format_codec_mappings); ++i) {
679 std::vector<std::string> mime_type_codecs; 689 std::vector<std::string> mime_type_codecs;
680 ParseCodecString(format_codec_mappings[i].codecs_list, 690 ParseCodecString(format_codec_mappings[i].codecs_list,
681 &mime_type_codecs, 691 &mime_type_codecs,
682 false); 692 false);
683 693
684 CodecSet codecs; 694 CodecSet codecs;
(...skipping 733 matching lines...) Expand 10 before | Expand all | Expand 10 after
1418 post_data->append("\r\n" + value + "\r\n"); 1428 post_data->append("\r\n" + value + "\r\n");
1419 } 1429 }
1420 1430
1421 void AddMultipartFinalDelimiterForUpload(const std::string& mime_boundary, 1431 void AddMultipartFinalDelimiterForUpload(const std::string& mime_boundary,
1422 std::string* post_data) { 1432 std::string* post_data) {
1423 DCHECK(post_data); 1433 DCHECK(post_data);
1424 post_data->append("--" + mime_boundary + "--\r\n"); 1434 post_data->append("--" + mime_boundary + "--\r\n");
1425 } 1435 }
1426 1436
1427 } // namespace net 1437 } // namespace net
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698