Changeset 184916 in webkit
- Timestamp:
- May 27, 2015, 1:33:09 PM (11 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 2 edited
-
ChangeLog (modified) (1 diff)
-
platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r184910 r184916 1 2015-05-27 Eric Carlson <eric.carlson@apple.com> 2 3 [Mac] short-circuit MIME type lookup when possible 4 https://bugs.webkit.org/show_bug.cgi?id=145362 5 6 Reviewed by Jer Noble. 7 8 * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm: 9 (WebCore::isUnsupportedMIMEType): Renamed from unsupportedMIMEType. Convert type to lower case 10 once instead of calling equalIgnoringCase many times. 11 (WebCore::staticMIMETypeList): Renamed from staticMimeTypeCache. Initialize static set in a lambda, 12 using an array of C strings in a loop. 13 (WebCore::avfMIMETypes): Renamed from avfMimeTypeCache. Initialize static set in a lambda. 14 (WebCore::MediaPlayerPrivateAVFoundationObjC::getSupportedTypes): avfMimeTypeCache -> avfMIMETypes. 15 (WebCore::keySystemIsSupported): equalIgnoringCase -> equalIgnoringASCIICase. 16 (WebCore::MediaPlayerPrivateAVFoundationObjC::supportsType): Ditto. 17 (WebCore::MediaPlayerPrivateAVFoundationObjC::supportsKeySystem): unsupportedMIMEType -> 18 isUnsupportedMIMEType, equalIgnoringCase -> equalIgnoringASCIICase, staticMimeTypeCache -> 19 staticMIMETypeList, avfMimeTypeCache -> avfMIMETypes. 20 (WebCore::unsupportedMIMEType): Deleted. 21 (WebCore::staticMimeTypeCache): Deleted. 22 (WebCore::avfMimeTypeCache): Deleted. 23 1 24 2015-05-27 Eric Carlson <eric.carlson@apple.com> 2 25 -
trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm
r184910 r184916 1546 1546 } 1547 1547 1548 static bool unsupportedMIMEType(const String& type) 1549 { 1548 static bool isUnsupportedMIMEType(const String& type) 1549 { 1550 String lowerCaseType = type.convertToASCIILowercase(); 1551 1550 1552 // AVFoundation will return non-video MIME types which it claims to support, but which we 1551 1553 // do not support in the <video> element. Reject all non video/, audio/, and application/ types. 1552 if (! type.startsWith("video/", false) && !type.startsWith("audio/", false) && !type.startsWith("application/", false))1554 if (!lowerCaseType.startsWith("video/") && !lowerCaseType.startsWith("audio/") && !lowerCaseType.startsWith("application/")) 1553 1555 return true; 1554 1556 1555 1557 // Reject types we know AVFoundation does not support that sites commonly ask about. 1556 if ( equalIgnoringCase(type, "video/webm") || equalIgnoringCase(type, "audio/webm") || equalIgnoringCase(type, "video/x-webm"))1558 if (lowerCaseType == "video/webm" || lowerCaseType == "audio/webm" || lowerCaseType == "video/x-webm") 1557 1559 return true; 1558 1560 1559 if ( equalIgnoringCase(type, "video/x-flv"))1561 if (lowerCaseType == "video/x-flv") 1560 1562 return true; 1561 1563 1562 if ( equalIgnoringCase(type, "audio/ogg") || equalIgnoringCase(type, "video/ogg") || equalIgnoringCase(type, "application/ogg"))1564 if (lowerCaseType == "audio/ogg" || lowerCaseType == "video/ogg" || lowerCaseType == "application/ogg") 1563 1565 return true; 1564 1566 1565 if ( equalIgnoringCase(type, "video/h264"))1567 if (lowerCaseType == "video/h264") 1566 1568 return true; 1567 1569 … … 1569 1571 } 1570 1572 1571 static HashSet<String>& staticMimeTypeCache() 1572 { 1573 static NeverDestroyed<HashSet<String>> cache; 1574 static bool typeListInitialized = false; 1575 1576 if (typeListInitialized) 1577 return cache; 1578 typeListInitialized = true; 1579 1580 cache.get().add("application/vnd.apple.mpegurl"); 1581 cache.get().add("application/x-mpegurl"); 1582 cache.get().add("audio/3gpp"); 1583 cache.get().add("audio/aac"); 1584 cache.get().add("audio/aacp"); 1585 cache.get().add("audio/aiff"); 1586 cache.get().add("audio/basic"); 1587 cache.get().add("audio/mp3"); 1588 cache.get().add("audio/mp4"); 1589 cache.get().add("audio/mpeg"); 1590 cache.get().add("audio/mpeg3"); 1591 cache.get().add("audio/mpegurl"); 1592 cache.get().add("audio/mpg"); 1593 cache.get().add("audio/wav"); 1594 cache.get().add("audio/wave"); 1595 cache.get().add("audio/x-aac"); 1596 cache.get().add("audio/x-aiff"); 1597 cache.get().add("audio/x-m4a"); 1598 cache.get().add("audio/x-mpegurl"); 1599 cache.get().add("audio/x-wav"); 1600 cache.get().add("video/3gpp"); 1601 cache.get().add("video/3gpp2"); 1602 cache.get().add("video/mp4"); 1603 cache.get().add("video/mpeg"); 1604 cache.get().add("video/mpeg2"); 1605 cache.get().add("video/mpg"); 1606 cache.get().add("video/quicktime"); 1607 cache.get().add("video/x-m4v"); 1608 cache.get().add("video/x-mpeg"); 1609 cache.get().add("video/x-mpg"); 1573 static const HashSet<String>& staticMIMETypeList() 1574 { 1575 static NeverDestroyed<HashSet<String>> cache = [] () { 1576 HashSet<String> types; 1577 1578 static const char* typeNames[] = { 1579 "application/vnd.apple.mpegurl", 1580 "application/x-mpegurl", 1581 "audio/3gpp", 1582 "audio/aac", 1583 "audio/aacp", 1584 "audio/aiff", 1585 "audio/basic", 1586 "audio/mp3", 1587 "audio/mp4", 1588 "audio/mpeg", 1589 "audio/mpeg3", 1590 "audio/mpegurl", 1591 "audio/mpg", 1592 "audio/wav", 1593 "audio/wave", 1594 "audio/x-aac", 1595 "audio/x-aiff", 1596 "audio/x-m4a", 1597 "audio/x-mpegurl", 1598 "audio/x-wav", 1599 "video/3gpp", 1600 "video/3gpp2", 1601 "video/mp4", 1602 "video/mpeg", 1603 "video/mpeg2", 1604 "video/mpg", 1605 "video/quicktime", 1606 "video/x-m4v", 1607 "video/x-mpeg", 1608 "video/x-mpg", 1609 }; 1610 for (size_t i = 0; i < WTF_ARRAY_LENGTH(typeNames); ++i) 1611 types.add(typeNames[i]); 1612 1613 return types; 1614 }(); 1610 1615 1611 1616 return cache; 1612 } 1613 1614 static HashSet<String>& avfMimeTypeCache()1615 { 1616 static NeverDestroyed<HashSet<String>> cache ;1617 static bool typeListInitialized = false;1618 1619 if (typeListInitialized)1620 return cache;1621 typeListInitialized = true;1622 1623 NSArray *types = [AVURLAsset audiovisualMIMETypes];1624 for (NSString *mimeType in types)1625 cache.get().add([mimeType lowercaseString]); 1626 1617 } 1618 1619 static const HashSet<String>& avfMIMETypes() 1620 { 1621 static NeverDestroyed<HashSet<String>> cache = [] () { 1622 HashSet<String> types; 1623 1624 NSArray *nsTypes = [AVURLAsset audiovisualMIMETypes]; 1625 for (NSString *mimeType in nsTypes) 1626 types.add([mimeType lowercaseString]); 1627 1628 return types; 1629 }(); 1630 1631 1627 1632 return cache; 1628 } 1633 } 1629 1634 1630 1635 RetainPtr<CGImageRef> MediaPlayerPrivateAVFoundationObjC::createImageForTimeInRect(float time, const FloatRect& rect) … … 1652 1657 void MediaPlayerPrivateAVFoundationObjC::getSupportedTypes(HashSet<String>& supportedTypes) 1653 1658 { 1654 supportedTypes = avfM imeTypeCache();1659 supportedTypes = avfMIMETypes(); 1655 1660 } 1656 1661 … … 1658 1663 static bool keySystemIsSupported(const String& keySystem) 1659 1664 { 1660 if (equalIgnoring Case(keySystem, "com.apple.fps") || equalIgnoringCase(keySystem, "com.apple.fps.1_0") || equalIgnoringCase(keySystem, "org.w3c.clearkey"))1665 if (equalIgnoringASCIICase(keySystem, "com.apple.fps") || equalIgnoringASCIICase(keySystem, "com.apple.fps.1_0") || equalIgnoringASCIICase(keySystem, "org.w3c.clearkey")) 1661 1666 return true; 1662 1667 return false; … … 1674 1679 if (!parameters.keySystem.isNull() && !parameters.keySystem.isEmpty()) { 1675 1680 // "Clear Key" is only supported with HLS: 1676 if (equalIgnoring Case(parameters.keySystem, "org.w3c.clearkey") && !parameters.type.isEmpty() && !equalIgnoringCase(parameters.type, "application/x-mpegurl"))1681 if (equalIgnoringASCIICase(parameters.keySystem, "org.w3c.clearkey") && !parameters.type.isEmpty() && !equalIgnoringASCIICase(parameters.type, "application/x-mpegurl")) 1677 1682 return MediaPlayer::IsNotSupported; 1678 1683 … … 1693 1698 #endif 1694 1699 1695 if ( unsupportedMIMEType(parameters.type))1700 if (isUnsupportedMIMEType(parameters.type)) 1696 1701 return MediaPlayer::IsNotSupported; 1697 1702 1698 if (!staticM imeTypeCache().contains(parameters.type) && !avfMimeTypeCache().contains(parameters.type))1703 if (!staticMIMETypeList().contains(parameters.type) && !avfMIMETypes().contains(parameters.type)) 1699 1704 return MediaPlayer::IsNotSupported; 1700 1705 … … 1713 1718 if (!keySystem.isEmpty()) { 1714 1719 // "Clear Key" is only supported with HLS: 1715 if (equalIgnoring Case(keySystem, "org.w3c.clearkey") && !mimeType.isEmpty() && !equalIgnoringCase(mimeType, "application/x-mpegurl"))1720 if (equalIgnoringASCIICase(keySystem, "org.w3c.clearkey") && !mimeType.isEmpty() && !equalIgnoringASCIICase(mimeType, "application/x-mpegurl")) 1716 1721 return MediaPlayer::IsNotSupported; 1717 1722 … … 1719 1724 return false; 1720 1725 1721 if (!mimeType.isEmpty() && unsupportedMIMEType(mimeType))1726 if (!mimeType.isEmpty() && isUnsupportedMIMEType(mimeType)) 1722 1727 return false; 1723 1728 1724 if (!mimeType.isEmpty() && !staticM imeTypeCache().contains(mimeType) && !avfMimeTypeCache().contains(mimeType))1729 if (!mimeType.isEmpty() && !staticMIMETypeList().contains(mimeType) && !avfMIMETypes().contains(mimeType)) 1725 1730 return false; 1726 1731
Note:
See TracChangeset
for help on using the changeset viewer.