Title: [184910] trunk/Source/WebCore
- Revision
- 184910
- Author
- [email protected]
- Date
- 2015-05-27 11:37:28 -0700 (Wed, 27 May 2015)
Log Message
[Mac] short-circuit MIME type lookup when possible
https://bugs.webkit.org/show_bug.cgi?id=145362
Reviewed by Dean Jackson.
* platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
(WebCore::unsupportedMIMEType): New, reject types known to not be supported.
(WebCore::staticMimeTypeCache): Accept MIME types known to be supported.
(WebCore::avfMimeTypeCache): Renamed from mimeTypeCache.
(WebCore::MediaPlayerPrivateAVFoundationObjC::getSupportedTypes): mimeTypeCache -> staticMimeTypeCache.
(WebCore::MediaPlayerPrivateAVFoundationObjC::supportsType): Return immediately if
unsupportedMIMEType returns true, don't call AVFoundation if staticMimeTypeCache returns true.
(WebCore::MediaPlayerPrivateAVFoundationObjC::supportsKeySystem): Ditto.
(WebCore::mimeTypeCache): Deleted.
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (184909 => 184910)
--- trunk/Source/WebCore/ChangeLog 2015-05-27 18:31:12 UTC (rev 184909)
+++ trunk/Source/WebCore/ChangeLog 2015-05-27 18:37:28 UTC (rev 184910)
@@ -1,5 +1,22 @@
2015-05-27 Eric Carlson <[email protected]>
+ [Mac] short-circuit MIME type lookup when possible
+ https://bugs.webkit.org/show_bug.cgi?id=145362
+
+ Reviewed by Dean Jackson.
+
+ * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
+ (WebCore::unsupportedMIMEType): New, reject types known to not be supported.
+ (WebCore::staticMimeTypeCache): Accept MIME types known to be supported.
+ (WebCore::avfMimeTypeCache): Renamed from mimeTypeCache.
+ (WebCore::MediaPlayerPrivateAVFoundationObjC::getSupportedTypes): mimeTypeCache -> staticMimeTypeCache.
+ (WebCore::MediaPlayerPrivateAVFoundationObjC::supportsType): Return immediately if
+ unsupportedMIMEType returns true, don't call AVFoundation if staticMimeTypeCache returns true.
+ (WebCore::MediaPlayerPrivateAVFoundationObjC::supportsKeySystem): Ditto.
+ (WebCore::mimeTypeCache): Deleted.
+
+2015-05-27 Eric Carlson <[email protected]>
+
[Mac] occasional crash in MediaPlayerPrivateAVFoundationObjC::didStopLoadingRequest
https://bugs.webkit.org/show_bug.cgi?id=145409
Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm (184909 => 184910)
--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm 2015-05-27 18:31:12 UTC (rev 184909)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm 2015-05-27 18:37:28 UTC (rev 184910)
@@ -1545,18 +1545,84 @@
}
}
-static HashSet<String> mimeTypeCache()
+static bool unsupportedMIMEType(const String& type)
{
- DEPRECATED_DEFINE_STATIC_LOCAL(HashSet<String>, cache, ());
+ // AVFoundation will return non-video MIME types which it claims to support, but which we
+ // do not support in the <video> element. Reject all non video/, audio/, and application/ types.
+ if (!type.startsWith("video/", false) && !type.startsWith("audio/", false) && !type.startsWith("application/", false))
+ return true;
+
+ // Reject types we know AVFoundation does not support that sites commonly ask about.
+ if (equalIgnoringCase(type, "video/webm") || equalIgnoringCase(type, "audio/webm") || equalIgnoringCase(type, "video/x-webm"))
+ return true;
+
+ if (equalIgnoringCase(type, "video/x-flv"))
+ return true;
+
+ if (equalIgnoringCase(type, "audio/ogg") || equalIgnoringCase(type, "video/ogg") || equalIgnoringCase(type, "application/ogg"))
+ return true;
+
+ if (equalIgnoringCase(type, "video/h264"))
+ return true;
+
+ return false;
+}
+
+static HashSet<String>& staticMimeTypeCache()
+{
+ static NeverDestroyed<HashSet<String>> cache;
static bool typeListInitialized = false;
if (typeListInitialized)
return cache;
typeListInitialized = true;
+ cache.get().add("application/vnd.apple.mpegurl");
+ cache.get().add("application/x-mpegurl");
+ cache.get().add("audio/3gpp");
+ cache.get().add("audio/aac");
+ cache.get().add("audio/aacp");
+ cache.get().add("audio/aiff");
+ cache.get().add("audio/basic");
+ cache.get().add("audio/mp3");
+ cache.get().add("audio/mp4");
+ cache.get().add("audio/mpeg");
+ cache.get().add("audio/mpeg3");
+ cache.get().add("audio/mpegurl");
+ cache.get().add("audio/mpg");
+ cache.get().add("audio/wav");
+ cache.get().add("audio/wave");
+ cache.get().add("audio/x-aac");
+ cache.get().add("audio/x-aiff");
+ cache.get().add("audio/x-m4a");
+ cache.get().add("audio/x-mpegurl");
+ cache.get().add("audio/x-wav");
+ cache.get().add("video/3gpp");
+ cache.get().add("video/3gpp2");
+ cache.get().add("video/mp4");
+ cache.get().add("video/mpeg");
+ cache.get().add("video/mpeg2");
+ cache.get().add("video/mpg");
+ cache.get().add("video/quicktime");
+ cache.get().add("video/x-m4v");
+ cache.get().add("video/x-mpeg");
+ cache.get().add("video/x-mpg");
+
+ return cache;
+}
+
+static HashSet<String>& avfMimeTypeCache()
+{
+ static NeverDestroyed<HashSet<String>> cache;
+ static bool typeListInitialized = false;
+
+ if (typeListInitialized)
+ return cache;
+ typeListInitialized = true;
+
NSArray *types = [AVURLAsset audiovisualMIMETypes];
for (NSString *mimeType in types)
- cache.add([mimeType lowercaseString]);
+ cache.get().add([mimeType lowercaseString]);
return cache;
}
@@ -1585,7 +1651,7 @@
void MediaPlayerPrivateAVFoundationObjC::getSupportedTypes(HashSet<String>& supportedTypes)
{
- supportedTypes = mimeTypeCache();
+ supportedTypes = avfMimeTypeCache();
}
#if ENABLE(ENCRYPTED_MEDIA) || ENABLE(ENCRYPTED_MEDIA_V2)
@@ -1626,9 +1692,12 @@
return MediaPlayer::IsNotSupported;
#endif
- if (!mimeTypeCache().contains(parameters.type))
+ if (unsupportedMIMEType(parameters.type))
return MediaPlayer::IsNotSupported;
+ if (!staticMimeTypeCache().contains(parameters.type) && !avfMimeTypeCache().contains(parameters.type))
+ return MediaPlayer::IsNotSupported;
+
// The spec says:
// "Implementors are encouraged to return "maybe" unless the type can be confidently established as being supported or not."
if (parameters.codecs.isEmpty())
@@ -1649,9 +1718,12 @@
if (!keySystemIsSupported(keySystem))
return false;
- if (!mimeType.isEmpty() && !mimeTypeCache().contains(mimeType))
+ if (!mimeType.isEmpty() && unsupportedMIMEType(mimeType))
return false;
+ if (!mimeType.isEmpty() && !staticMimeTypeCache().contains(mimeType) && !avfMimeTypeCache().contains(mimeType))
+ return false;
+
return true;
}
#else
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes