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

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

Issue 230413003: Adding platform specific checks for VP9 codecs and HLS mime types (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Adding comments Created 6 years, 7 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 | « content/browser/media/media_canplaytype_browsertest.cc ('k') | net/base/mime_util_unittest.cc » ('j') | 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 393 matching lines...) Expand 10 before | Expand all | Expand 10 after
404 "application/x-javascript", 404 "application/x-javascript",
405 "text/javascript1.1", 405 "text/javascript1.1",
406 "text/javascript1.2", 406 "text/javascript1.2",
407 "text/javascript1.3", 407 "text/javascript1.3",
408 "text/jscript", 408 "text/jscript",
409 "text/livescript" 409 "text/livescript"
410 }; 410 };
411 411
412 #if defined(OS_ANDROID) 412 #if defined(OS_ANDROID)
413 static bool IsCodecSupportedOnAndroid(const std::string& codec) { 413 static bool IsCodecSupportedOnAndroid(const std::string& codec) {
414 // Theora is not supported in Android
415 if (!codec.compare("theora"))
416 return false;
417
414 // VP9 is supported only in KitKat+ (API Level 19). 418 // VP9 is supported only in KitKat+ (API Level 19).
415 if ((!codec.compare("vp9") || !codec.compare("vp9.0")) && 419 if ((!codec.compare("vp9") || !codec.compare("vp9.0")) &&
416 base::android::BuildInfo::GetInstance()->sdk_int() < 19) { 420 base::android::BuildInfo::GetInstance()->sdk_int() < 19) {
417 return false; 421 return false;
418 } 422 }
419 423
420 // TODO(vigneshv): Change this similar to the VP9 check once Opus is 424 // TODO(vigneshv): Change this similar to the VP9 check once Opus is
421 // supported on Android (http://crbug.com/318436). 425 // supported on Android (http://crbug.com/318436).
422 if (!codec.compare("opus")) { 426 if (!codec.compare("opus")) {
423 return false; 427 return false;
424 } 428 }
425 return true; 429 return true;
426 } 430 }
431
432 static bool IsMimeTypeSupportedOnAndroid(const std::string& mimeType) {
433 // HLS codecs are supported in ICS and above (API level 14)
434 if ((!mimeType.compare("application/vnd.apple.mpegurl") ||
435 !mimeType.compare("application/x-mpegurl")) &&
436 base::android::BuildInfo::GetInstance()->sdk_int() < 14) {
437 return false;
438 }
439 return true;
440 }
427 #endif 441 #endif
428 442
429 struct MediaFormatStrict { 443 struct MediaFormatStrict {
430 const char* mime_type; 444 const char* mime_type;
431 const char* codecs_list; 445 const char* codecs_list;
432 }; 446 };
433 447
434 static const MediaFormatStrict format_codec_mappings[] = { 448 static const MediaFormatStrict format_codec_mappings[] = {
435 { "video/webm", "opus,vorbis,vp8,vp8.0,vp9,vp9.0" }, 449 { "video/webm", "opus,vorbis,vp8,vp8.0,vp9,vp9.0" },
436 { "audio/webm", "opus,vorbis" }, 450 { "audio/webm", "opus,vorbis" },
(...skipping 30 matching lines...) Expand all
467 481
468 // Initialize the supported non-image types. 482 // Initialize the supported non-image types.
469 for (size_t i = 0; i < arraysize(supported_non_image_types); ++i) 483 for (size_t i = 0; i < arraysize(supported_non_image_types); ++i)
470 non_image_map_.insert(supported_non_image_types[i]); 484 non_image_map_.insert(supported_non_image_types[i]);
471 for (size_t i = 0; i < arraysize(supported_certificate_types); ++i) 485 for (size_t i = 0; i < arraysize(supported_certificate_types); ++i)
472 non_image_map_.insert(supported_certificate_types[i].mime_type); 486 non_image_map_.insert(supported_certificate_types[i].mime_type);
473 for (size_t i = 0; i < arraysize(unsupported_text_types); ++i) 487 for (size_t i = 0; i < arraysize(unsupported_text_types); ++i)
474 unsupported_text_map_.insert(unsupported_text_types[i]); 488 unsupported_text_map_.insert(unsupported_text_types[i]);
475 for (size_t i = 0; i < arraysize(supported_javascript_types); ++i) 489 for (size_t i = 0; i < arraysize(supported_javascript_types); ++i)
476 non_image_map_.insert(supported_javascript_types[i]); 490 non_image_map_.insert(supported_javascript_types[i]);
477 for (size_t i = 0; i < arraysize(common_media_types); ++i) 491 for (size_t i = 0; i < arraysize(common_media_types); ++i) {
492 #if defined(OS_ANDROID)
493 if (!IsMimeTypeSupportedOnAndroid(common_media_types[i]))
494 continue;
495 #endif
478 non_image_map_.insert(common_media_types[i]); 496 non_image_map_.insert(common_media_types[i]);
497 }
479 #if defined(USE_PROPRIETARY_CODECS) 498 #if defined(USE_PROPRIETARY_CODECS)
480 for (size_t i = 0; i < arraysize(proprietary_media_types); ++i) 499 for (size_t i = 0; i < arraysize(proprietary_media_types); ++i)
481 non_image_map_.insert(proprietary_media_types[i]); 500 non_image_map_.insert(proprietary_media_types[i]);
482 #endif 501 #endif
483 502
484 // Initialize the supported media types. 503 // Initialize the supported media types.
485 for (size_t i = 0; i < arraysize(common_media_types); ++i) 504 for (size_t i = 0; i < arraysize(common_media_types); ++i) {
505 #if defined(OS_ANDROID)
506 if (!IsMimeTypeSupportedOnAndroid(common_media_types[i]))
507 continue;
508 #endif
486 media_map_.insert(common_media_types[i]); 509 media_map_.insert(common_media_types[i]);
510 }
487 #if defined(USE_PROPRIETARY_CODECS) 511 #if defined(USE_PROPRIETARY_CODECS)
488 for (size_t i = 0; i < arraysize(proprietary_media_types); ++i) 512 for (size_t i = 0; i < arraysize(proprietary_media_types); ++i)
489 media_map_.insert(proprietary_media_types[i]); 513 media_map_.insert(proprietary_media_types[i]);
490 #endif 514 #endif
491 515
492 for (size_t i = 0; i < arraysize(supported_javascript_types); ++i) 516 for (size_t i = 0; i < arraysize(supported_javascript_types); ++i)
493 javascript_map_.insert(supported_javascript_types[i]); 517 javascript_map_.insert(supported_javascript_types[i]);
494 518
495 for (size_t i = 0; i < arraysize(common_media_codecs); ++i) { 519 for (size_t i = 0; i < arraysize(common_media_codecs); ++i) {
496 #if defined(OS_ANDROID) 520 #if defined(OS_ANDROID)
(...skipping 537 matching lines...) Expand 10 before | Expand all | Expand 10 after
1034 post_data->append("\r\n" + value + "\r\n"); 1058 post_data->append("\r\n" + value + "\r\n");
1035 } 1059 }
1036 1060
1037 void AddMultipartFinalDelimiterForUpload(const std::string& mime_boundary, 1061 void AddMultipartFinalDelimiterForUpload(const std::string& mime_boundary,
1038 std::string* post_data) { 1062 std::string* post_data) {
1039 DCHECK(post_data); 1063 DCHECK(post_data);
1040 post_data->append("--" + mime_boundary + "--\r\n"); 1064 post_data->append("--" + mime_boundary + "--\r\n");
1041 } 1065 }
1042 1066
1043 } // namespace net 1067 } // namespace net
OLDNEW
« no previous file with comments | « content/browser/media/media_canplaytype_browsertest.cc ('k') | net/base/mime_util_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698