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 <map> | 5 #include <map> |
| 6 #include <string> | 6 #include <string> |
| 7 | 7 |
| 8 #include "net/base/mime_util.h" | 8 #include "net/base/mime_util.h" |
| 9 #include "net/base/platform_mime_util.h" | 9 #include "net/base/platform_mime_util.h" |
| 10 | 10 |
| (...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 227 "image/webp", | 227 "image/webp", |
| 228 "image/png", | 228 "image/png", |
| 229 "image/gif", | 229 "image/gif", |
| 230 "image/bmp", | 230 "image/bmp", |
| 231 "image/x-icon", // ico | 231 "image/x-icon", // ico |
| 232 "image/x-xbitmap" // xbm | 232 "image/x-xbitmap" // xbm |
| 233 }; | 233 }; |
| 234 | 234 |
| 235 // A list of media types: http://en.wikipedia.org/wiki/Internet_media_type | 235 // A list of media types: http://en.wikipedia.org/wiki/Internet_media_type |
| 236 // A comprehensive mime type list: http://plugindoc.mozdev.org/winmime.php | 236 // A comprehensive mime type list: http://plugindoc.mozdev.org/winmime.php |
| 237 static const char* const supported_media_types[] = { | 237 // This set of codecs is supported by all variations of Chromium. |
| 238 static const char* const common_media_types[] = { | |
| 238 // Ogg. | 239 // Ogg. |
| 239 "audio/ogg", | 240 "audio/ogg", |
| 240 "application/ogg", | 241 "application/ogg", |
| 241 #if defined(ENABLE_MEDIA_CODEC_THEORA) | 242 #if defined(ENABLE_MEDIA_CODEC_THEORA) |
| 242 "video/ogg", | 243 "video/ogg", |
| 243 #endif | 244 #endif |
| 244 | 245 |
| 245 // WebM. | 246 // WebM. |
| 246 "video/webm", | 247 "video/webm", |
| 247 "audio/webm", | 248 "audio/webm", |
| 248 "audio/wav", | 249 "audio/wav", |
| 249 "audio/x-wav", | 250 "audio/x-wav", |
| 251 }; | |
| 250 | 252 |
| 251 #if defined(GOOGLE_CHROME_BUILD) || defined(USE_PROPRIETARY_CODECS) | 253 // List of proprietary types only supported by Google Chrome. |
| 254 static const char* const proprietary_media_types[] = { | |
| 252 // MPEG-4. | 255 // MPEG-4. |
| 253 "video/mp4", | 256 "video/mp4", |
| 254 "video/x-m4v", | 257 "video/x-m4v", |
| 255 "audio/mp4", | 258 "audio/mp4", |
| 256 "audio/x-m4a", | 259 "audio/x-m4a", |
| 257 | 260 |
| 258 // MP3. | 261 // MP3. |
| 259 "audio/mp3", | 262 "audio/mp3", |
| 260 "audio/x-mp3", | 263 "audio/x-mp3", |
| 261 "audio/mpeg", | 264 "audio/mpeg", |
| 262 #endif | |
| 263 }; | 265 }; |
| 264 | 266 |
| 265 // List of supported codecs when passed in with <source type="...">. | 267 // List of supported codecs when passed in with <source type="...">. |
| 268 // This set of codecs is supported by all variations of Chromium. | |
| 266 // | 269 // |
| 267 // Refer to http://wiki.whatwg.org/wiki/Video_type_parameters#Browser_Support | 270 // Refer to http://wiki.whatwg.org/wiki/Video_type_parameters#Browser_Support |
| 268 // for more information. | 271 // for more information. |
| 269 // | 272 // |
| 270 // The codecs for WAV are integers as defined in Appendix A of RFC2361: | 273 // The codecs for WAV are integers as defined in Appendix A of RFC2361: |
| 271 // http://tools.ietf.org/html/rfc2361 | 274 // http://tools.ietf.org/html/rfc2361 |
| 272 static const char* const supported_media_codecs[] = { | 275 static const char* const common_media_codecs[] = { |
| 273 #if defined(GOOGLE_CHROME_BUILD) || defined(USE_PROPRIETARY_CODECS) | |
| 274 "avc1", | |
| 275 "mp4a", | |
| 276 #endif | |
| 277 #if defined(ENABLE_MEDIA_CODEC_THEORA) | 276 #if defined(ENABLE_MEDIA_CODEC_THEORA) |
| 278 "theora", | 277 "theora", |
| 279 #endif | 278 #endif |
| 280 "vorbis", | 279 "vorbis", |
| 281 "vp8", | 280 "vp8", |
| 282 "1" // WAVE_FORMAT_PCM. | 281 "1" // WAVE_FORMAT_PCM. |
| 283 }; | 282 }; |
| 284 | 283 |
| 284 // List of proprietary codecs only supported by Google Chrome. | |
| 285 static const char* const proprietary_media_codecs[] = { | |
| 286 "avc1", | |
| 287 "mp4a" | |
| 288 }; | |
| 289 | |
| 285 // Note: does not include javascript types list (see supported_javascript_types) | 290 // Note: does not include javascript types list (see supported_javascript_types) |
| 286 static const char* const supported_non_image_types[] = { | 291 static const char* const supported_non_image_types[] = { |
| 287 "text/cache-manifest", | 292 "text/cache-manifest", |
| 288 "text/html", | 293 "text/html", |
| 289 "text/xml", | 294 "text/xml", |
| 290 "text/xsl", | 295 "text/xsl", |
| 291 "text/plain", | 296 "text/plain", |
| 292 // Many users complained about css files served for | 297 // Many users complained about css files served for |
| 293 // download instead of displaying in the browser: | 298 // download instead of displaying in the browser: |
| 294 // http://code.google.com/p/chromium/issues/detail?id=7192 | 299 // http://code.google.com/p/chromium/issues/detail?id=7192 |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 369 | 374 |
| 370 void MimeUtil::InitializeMimeTypeMaps() { | 375 void MimeUtil::InitializeMimeTypeMaps() { |
| 371 for (size_t i = 0; i < arraysize(supported_image_types); ++i) | 376 for (size_t i = 0; i < arraysize(supported_image_types); ++i) |
| 372 image_map_.insert(supported_image_types[i]); | 377 image_map_.insert(supported_image_types[i]); |
| 373 | 378 |
| 374 // Initialize the supported non-image types. | 379 // Initialize the supported non-image types. |
| 375 for (size_t i = 0; i < arraysize(supported_non_image_types); ++i) | 380 for (size_t i = 0; i < arraysize(supported_non_image_types); ++i) |
| 376 non_image_map_.insert(supported_non_image_types[i]); | 381 non_image_map_.insert(supported_non_image_types[i]); |
| 377 for (size_t i = 0; i < arraysize(supported_javascript_types); ++i) | 382 for (size_t i = 0; i < arraysize(supported_javascript_types); ++i) |
| 378 non_image_map_.insert(supported_javascript_types[i]); | 383 non_image_map_.insert(supported_javascript_types[i]); |
| 379 for (size_t i = 0; i < arraysize(supported_media_types); ++i) | 384 for (size_t i = 0; i < arraysize(common_media_types); ++i) |
| 380 non_image_map_.insert(supported_media_types[i]); | 385 non_image_map_.insert(common_media_types[i]); |
| 386 #if defined(GOOGLE_CHROME_BUILD) || defined(USE_PROPRIETARY_CODECS) | |
| 387 for (size_t i = 0; i < arraysize(proprietary_media_types); ++i) | |
| 388 non_image_map_.insert(proprietary_media_types[i]); | |
| 389 #endif | |
| 381 | 390 |
| 382 // Initialize the supported media types. | 391 // Initialize the supported media types. |
| 383 for (size_t i = 0; i < arraysize(supported_media_types); ++i) | 392 for (size_t i = 0; i < arraysize(common_media_types); ++i) |
| 384 media_map_.insert(supported_media_types[i]); | 393 media_map_.insert(common_media_types[i]); |
| 394 #if defined(GOOGLE_CHROME_BUILD) || defined(USE_PROPRIETARY_CODECS) | |
| 395 for (size_t i = 0; i < arraysize(proprietary_media_types); ++i) | |
| 396 media_map_.insert(proprietary_media_types[i]); | |
| 397 #endif | |
| 385 | 398 |
| 386 for (size_t i = 0; i < arraysize(supported_javascript_types); ++i) | 399 for (size_t i = 0; i < arraysize(supported_javascript_types); ++i) |
| 387 javascript_map_.insert(supported_javascript_types[i]); | 400 javascript_map_.insert(supported_javascript_types[i]); |
| 388 | 401 |
| 389 for (size_t i = 0; i < arraysize(view_source_types); ++i) | 402 for (size_t i = 0; i < arraysize(view_source_types); ++i) |
| 390 view_source_map_.insert(view_source_types[i]); | 403 view_source_map_.insert(view_source_types[i]); |
| 391 | 404 |
| 392 for (size_t i = 0; i < arraysize(supported_media_codecs); ++i) | 405 for (size_t i = 0; i < arraysize(common_media_codecs); ++i) |
| 393 codecs_map_.insert(supported_media_codecs[i]); | 406 codecs_map_.insert(common_media_codecs[i]); |
| 407 #if defined(GOOGLE_CHROME_BUILD) || defined(USE_PROPRIETARY_CODECS) | |
| 408 for (size_t i = 0; i < arraysize(proprietary_media_codecs); ++i) | |
| 409 codecs_map_.insert(proprietary_media_codecs[i]); | |
| 410 #endif | |
| 394 | 411 |
| 395 // Initialize the strict supported media types. | 412 // Initialize the strict supported media types. |
| 396 for (size_t i = 0; i < arraysize(format_codec_mappings); ++i) { | 413 for (size_t i = 0; i < arraysize(format_codec_mappings); ++i) { |
| 397 std::vector<std::string> mime_type_codecs; | 414 std::vector<std::string> mime_type_codecs; |
| 398 ParseCodecString(format_codec_mappings[i].codecs_list, | 415 ParseCodecString(format_codec_mappings[i].codecs_list, |
| 399 &mime_type_codecs, | 416 &mime_type_codecs, |
| 400 false); | 417 false); |
| 401 | 418 |
| 402 MimeMappings codecs; | 419 MimeMappings codecs; |
| 403 for (size_t j = 0; j < mime_type_codecs.size(); ++j) | 420 for (size_t j = 0; j < mime_type_codecs.size(); ++j) |
| (...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 741 &unique_extensions); | 758 &unique_extensions); |
| 742 | 759 |
| 743 GetExtensionsFromHardCodedMappings(secondary_mappings, | 760 GetExtensionsFromHardCodedMappings(secondary_mappings, |
| 744 arraysize(secondary_mappings), | 761 arraysize(secondary_mappings), |
| 745 mime_type, | 762 mime_type, |
| 746 &unique_extensions); | 763 &unique_extensions); |
| 747 | 764 |
| 748 HashSetToVector(&unique_extensions, extensions); | 765 HashSetToVector(&unique_extensions, extensions); |
| 749 } | 766 } |
| 750 | 767 |
| 768 std::vector<std::string> GetProprietaryMediaTypes() { | |
| 769 std::vector<std::string> proprietary_types; | |
| 770 // Unless/until WebM files are added to the media layout tests, we need to avoid | |
| 771 // blacklisting mp4 and H.264 when Theora is not supported (and proprietary | |
| 772 // codecs are) so that the media tests can still run. | |
| 773 #if defined(ENABLE_MEDIA_CODEC_THEORA) || !defined(USE_PROPRIETARY_CODECS) | |
| 774 for (size_t i = 0; i < arraysize(proprietary_media_types); ++i) | |
| 775 proprietary_types.push_back(proprietary_media_types[i]); | |
| 776 #endif | |
| 777 return proprietary_types; | |
|
qinmin
2012/04/06 23:36:59
if we do this, does that mean video/ogg is not bla
ddorwin
2012/04/07 02:40:41
It is not blacklisted for layout tests. In the #el
qinmin
2012/04/07 02:46:53
Is it possible this will cause some layout test to
ddorwin
2012/04/07 03:15:31
No. The layout test will have nothing blacklisted
| |
| 778 } | |
| 779 | |
| 780 std::vector<std::string> GetProprietaryMediaCodecs() { | |
| 781 std::vector<std::string> proprietary_codecs; | |
| 782 // Unless/until WebM files are added to the media layout tests, we need to avoid | |
| 783 // blacklisting mp4 and H.264 when Theora is not supported (and proprietary | |
| 784 // codecs are) so that the media tests can still run. | |
| 785 #if defined(ENABLE_MEDIA_CODEC_THEORA) || !defined(USE_PROPRIETARY_CODECS) | |
| 786 for (size_t i = 0; i < arraysize(proprietary_media_codecs); ++i) | |
| 787 proprietary_codecs.push_back(proprietary_media_codecs[i]); | |
| 788 #endif | |
| 789 return proprietary_codecs; | |
|
qinmin
2012/04/06 23:36:59
same here, what about theora for android.
ddorwin
2012/04/07 02:40:41
Same.
| |
| 790 } | |
| 791 | |
| 751 } // namespace net | 792 } // namespace net |
| OLD | NEW |