| 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 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 335 | 335 |
| 336 // WebM. | 336 // WebM. |
| 337 "video/webm", | 337 "video/webm", |
| 338 "audio/webm", | 338 "audio/webm", |
| 339 | 339 |
| 340 // Wav. | 340 // Wav. |
| 341 "audio/wav", | 341 "audio/wav", |
| 342 "audio/x-wav", | 342 "audio/x-wav", |
| 343 | 343 |
| 344 #if defined(OS_ANDROID) | 344 #if defined(OS_ANDROID) |
| 345 // HLS. Supported by Android ICS and above. | 345 // HLS. |
| 346 "application/vnd.apple.mpegurl", | 346 "application/vnd.apple.mpegurl", |
| 347 "application/x-mpegurl", | 347 "application/x-mpegurl", |
| 348 #endif | 348 #endif |
| 349 }; | 349 }; |
| 350 | 350 |
| 351 // List of proprietary types only supported by Google Chrome. | 351 // List of proprietary types only supported by Google Chrome. |
| 352 static const char* const proprietary_media_types[] = { | 352 static const char* const proprietary_media_types[] = { |
| 353 // MPEG-4. | 353 // MPEG-4. |
| 354 "video/mp4", | 354 "video/mp4", |
| 355 "video/x-m4v", | 355 "video/x-m4v", |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 479 case MimeUtil::OPUS: | 479 case MimeUtil::OPUS: |
| 480 // Opus is supported only in Lollipop+ (API Level 21). | 480 // Opus is supported only in Lollipop+ (API Level 21). |
| 481 return base::android::BuildInfo::GetInstance()->sdk_int() >= 21; | 481 return base::android::BuildInfo::GetInstance()->sdk_int() >= 21; |
| 482 | 482 |
| 483 case MimeUtil::THEORA: | 483 case MimeUtil::THEORA: |
| 484 return false; | 484 return false; |
| 485 } | 485 } |
| 486 | 486 |
| 487 return false; | 487 return false; |
| 488 } | 488 } |
| 489 | |
| 490 static bool IsMimeTypeSupportedOnAndroid(const std::string& mimeType) { | |
| 491 // HLS codecs are supported in ICS and above (API level 14) | |
| 492 if ((!mimeType.compare("application/vnd.apple.mpegurl") || | |
| 493 !mimeType.compare("application/x-mpegurl")) && | |
| 494 base::android::BuildInfo::GetInstance()->sdk_int() < 14) { | |
| 495 return false; | |
| 496 } | |
| 497 return true; | |
| 498 } | |
| 499 #endif | 489 #endif |
| 500 | 490 |
| 501 struct MediaFormatStrict { | 491 struct MediaFormatStrict { |
| 502 const char* const mime_type; | 492 const char* const mime_type; |
| 503 const char* const codecs_list; | 493 const char* const codecs_list; |
| 504 }; | 494 }; |
| 505 | 495 |
| 506 // Following is the list of RFC 6381 compliant codecs: | 496 // Following is the list of RFC 6381 compliant codecs: |
| 507 // mp4a.66 - MPEG-2 AAC MAIN | 497 // mp4a.66 - MPEG-2 AAC MAIN |
| 508 // mp4a.67 - MPEG-2 AAC LC | 498 // mp4a.67 - MPEG-2 AAC LC |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 638 // Initialize the supported non-image types. | 628 // Initialize the supported non-image types. |
| 639 for (size_t i = 0; i < arraysize(supported_non_image_types); ++i) | 629 for (size_t i = 0; i < arraysize(supported_non_image_types); ++i) |
| 640 non_image_map_.insert(supported_non_image_types[i]); | 630 non_image_map_.insert(supported_non_image_types[i]); |
| 641 for (size_t i = 0; i < arraysize(supported_certificate_types); ++i) | 631 for (size_t i = 0; i < arraysize(supported_certificate_types); ++i) |
| 642 non_image_map_.insert(supported_certificate_types[i].mime_type); | 632 non_image_map_.insert(supported_certificate_types[i].mime_type); |
| 643 for (size_t i = 0; i < arraysize(unsupported_text_types); ++i) | 633 for (size_t i = 0; i < arraysize(unsupported_text_types); ++i) |
| 644 unsupported_text_map_.insert(unsupported_text_types[i]); | 634 unsupported_text_map_.insert(unsupported_text_types[i]); |
| 645 for (size_t i = 0; i < arraysize(supported_javascript_types); ++i) | 635 for (size_t i = 0; i < arraysize(supported_javascript_types); ++i) |
| 646 non_image_map_.insert(supported_javascript_types[i]); | 636 non_image_map_.insert(supported_javascript_types[i]); |
| 647 for (size_t i = 0; i < arraysize(common_media_types); ++i) { | 637 for (size_t i = 0; i < arraysize(common_media_types); ++i) { |
| 648 #if defined(OS_ANDROID) | |
| 649 if (!IsMimeTypeSupportedOnAndroid(common_media_types[i])) | |
| 650 continue; | |
| 651 #endif | |
| 652 non_image_map_.insert(common_media_types[i]); | 638 non_image_map_.insert(common_media_types[i]); |
| 653 } | 639 } |
| 654 #if defined(USE_PROPRIETARY_CODECS) | 640 #if defined(USE_PROPRIETARY_CODECS) |
| 655 allow_proprietary_codecs_ = true; | 641 allow_proprietary_codecs_ = true; |
| 656 | 642 |
| 657 for (size_t i = 0; i < arraysize(proprietary_media_types); ++i) | 643 for (size_t i = 0; i < arraysize(proprietary_media_types); ++i) |
| 658 non_image_map_.insert(proprietary_media_types[i]); | 644 non_image_map_.insert(proprietary_media_types[i]); |
| 659 #endif | 645 #endif |
| 660 | 646 |
| 661 // Initialize the supported media types. | 647 // Initialize the supported media types. |
| 662 for (size_t i = 0; i < arraysize(common_media_types); ++i) { | 648 for (size_t i = 0; i < arraysize(common_media_types); ++i) { |
| 663 #if defined(OS_ANDROID) | |
| 664 if (!IsMimeTypeSupportedOnAndroid(common_media_types[i])) | |
| 665 continue; | |
| 666 #endif | |
| 667 media_map_.insert(common_media_types[i]); | 649 media_map_.insert(common_media_types[i]); |
| 668 } | 650 } |
| 669 #if defined(USE_PROPRIETARY_CODECS) | 651 #if defined(USE_PROPRIETARY_CODECS) |
| 670 for (size_t i = 0; i < arraysize(proprietary_media_types); ++i) | 652 for (size_t i = 0; i < arraysize(proprietary_media_types); ++i) |
| 671 media_map_.insert(proprietary_media_types[i]); | 653 media_map_.insert(proprietary_media_types[i]); |
| 672 #endif | 654 #endif |
| 673 | 655 |
| 674 for (size_t i = 0; i < arraysize(supported_javascript_types); ++i) | 656 for (size_t i = 0; i < arraysize(supported_javascript_types); ++i) |
| 675 javascript_map_.insert(supported_javascript_types[i]); | 657 javascript_map_.insert(supported_javascript_types[i]); |
| 676 | 658 |
| (...skipping 750 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1427 post_data->append("\r\n" + value + "\r\n"); | 1409 post_data->append("\r\n" + value + "\r\n"); |
| 1428 } | 1410 } |
| 1429 | 1411 |
| 1430 void AddMultipartFinalDelimiterForUpload(const std::string& mime_boundary, | 1412 void AddMultipartFinalDelimiterForUpload(const std::string& mime_boundary, |
| 1431 std::string* post_data) { | 1413 std::string* post_data) { |
| 1432 DCHECK(post_data); | 1414 DCHECK(post_data); |
| 1433 post_data->append("--" + mime_boundary + "--\r\n"); | 1415 post_data->append("--" + mime_boundary + "--\r\n"); |
| 1434 } | 1416 } |
| 1435 | 1417 |
| 1436 } // namespace net | 1418 } // namespace net |
| OLD | NEW |