<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[201831] trunk/Source/WebCore</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/201831">201831</a></dd>
<dt>Author</dt> <dd>eric.carlson@apple.com</dd>
<dt>Date</dt> <dd>2016-06-08 14:07:42 -0700 (Wed, 08 Jun 2016)</dd>
</dl>
<h3>Log Message</h3>
<pre>HTMLMediaElement.prototype.canPlayType accounting for 250-750ms first loading theverge.com
https://bugs.webkit.org/show_bug.cgi?id=158335
<rdar://problem/26615416>
Reviewed by Brent Fulgham.
* WebCore.xcodeproj/project.pbxproj: Add AVFoundationMIMETypeCache.
* platform/graphics/avfoundation/objc/AVFoundationMIMETypeCache.h: Added.
* platform/graphics/avfoundation/objc/AVFoundationMIMETypeCache.mm: Added.
(WebCore::AVFoundationMIMETypeCache::AVFoundationMIMETypeCache):
(WebCore::AVFoundationMIMETypeCache::loadTypes):
(WebCore::AVFoundationMIMETypeCache::types):
(WebCore::AVFoundationMIMETypeCache::singleton):
* platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
(WebCore::MediaPlayerPrivateAVFoundationObjC::registerMediaEngine): Start MIME type loading.
(WebCore::MediaPlayerPrivateAVFoundationObjC::getSupportedTypes): Use AVFoundationMIMETypeCache.
(WebCore::MediaPlayerPrivateAVFoundationObjC::supportsType): Ditto.
(WebCore::MediaPlayerPrivateAVFoundationObjC::supportsKeySystem): Ditto.
(WebCore::avfMIMETypes): Deleted.
* platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm:
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::registerMediaEngine): Start MIME type loading.
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::isAvailable): Use AVFoundationMIMETypeCache.
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::getSupportedTypes): Ditto.
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::supportsType): Ditto.
(WebCore::mimeTypeCache): Deleted.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreWebCorexcodeprojprojectpbxproj">trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsavfoundationobjcMediaPlayerPrivateAVFoundationObjCmm">trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsavfoundationobjcMediaPlayerPrivateMediaSourceAVFObjCmm">trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreplatformgraphicsavfoundationobjcAVFoundationMIMETypeCacheh">trunk/Source/WebCore/platform/graphics/avfoundation/objc/AVFoundationMIMETypeCache.h</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsavfoundationobjcAVFoundationMIMETypeCachemm">trunk/Source/WebCore/platform/graphics/avfoundation/objc/AVFoundationMIMETypeCache.mm</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (201830 => 201831)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2016-06-08 20:59:49 UTC (rev 201830)
+++ trunk/Source/WebCore/ChangeLog        2016-06-08 21:07:42 UTC (rev 201831)
</span><span class="lines">@@ -1,3 +1,34 @@
</span><ins>+2016-06-08 Eric Carlson <eric.carlson@apple.com>
+
+ HTMLMediaElement.prototype.canPlayType accounting for 250-750ms first loading theverge.com
+ https://bugs.webkit.org/show_bug.cgi?id=158335
+ <rdar://problem/26615416>
+
+ Reviewed by Brent Fulgham.
+
+ * WebCore.xcodeproj/project.pbxproj: Add AVFoundationMIMETypeCache.
+
+ * platform/graphics/avfoundation/objc/AVFoundationMIMETypeCache.h: Added.
+ * platform/graphics/avfoundation/objc/AVFoundationMIMETypeCache.mm: Added.
+ (WebCore::AVFoundationMIMETypeCache::AVFoundationMIMETypeCache):
+ (WebCore::AVFoundationMIMETypeCache::loadTypes):
+ (WebCore::AVFoundationMIMETypeCache::types):
+ (WebCore::AVFoundationMIMETypeCache::singleton):
+
+ * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
+ (WebCore::MediaPlayerPrivateAVFoundationObjC::registerMediaEngine): Start MIME type loading.
+ (WebCore::MediaPlayerPrivateAVFoundationObjC::getSupportedTypes): Use AVFoundationMIMETypeCache.
+ (WebCore::MediaPlayerPrivateAVFoundationObjC::supportsType): Ditto.
+ (WebCore::MediaPlayerPrivateAVFoundationObjC::supportsKeySystem): Ditto.
+ (WebCore::avfMIMETypes): Deleted.
+
+ * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm:
+ (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::registerMediaEngine): Start MIME type loading.
+ (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::isAvailable): Use AVFoundationMIMETypeCache.
+ (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::getSupportedTypes): Ditto.
+ (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::supportsType): Ditto.
+ (WebCore::mimeTypeCache): Deleted.
+
</ins><span class="cx"> 2016-06-07 Ryosuke Niwa <rniwa@webkit.org>
</span><span class="cx">
</span><span class="cx"> REGRESSION (r201667): ASSERTION FAILED: !m_anchorNode || !editingIgnoresContent(*m_anchorNode)
</span></span></pre></div>
<a id="trunkSourceWebCoreWebCorexcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (201830 => 201831)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj        2016-06-08 20:59:49 UTC (rev 201830)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj        2016-06-08 21:07:42 UTC (rev 201831)
</span><span class="lines">@@ -112,6 +112,7 @@
</span><span class="cx">                 070F549817F12F6B00169E04 /* MediaStreamConstraintsValidationClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 070F549717F12F6B00169E04 /* MediaStreamConstraintsValidationClient.h */; };
</span><span class="cx">                 070F549E17F2402700169E04 /* AudioDestinationConsumer.h in Headers */ = {isa = PBXBuildFile; fileRef = 070F549D17F2402700169E04 /* AudioDestinationConsumer.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">                 0711589117DF6F6600EDFE2B /* MediaStreamPrivate.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0711588F17DF633700EDFE2B /* MediaStreamPrivate.cpp */; };
</span><ins>+                0719427F1D088F21002AA51D /* AVFoundationMIMETypeCache.mm in Sources */ = {isa = PBXBuildFile; fileRef = 07C8AD111D073D630087C5CE /* AVFoundationMIMETypeCache.mm */; };
</ins><span class="cx">                 071A9EC2168FBC43002629F9 /* TextTrackCueGeneric.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 071A9EC0168FB56C002629F9 /* TextTrackCueGeneric.cpp */; };
</span><span class="cx">                 071A9EC3168FBC55002629F9 /* TextTrackCueGeneric.h in Headers */ = {isa = PBXBuildFile; fileRef = 071A9EC1168FB56C002629F9 /* TextTrackCueGeneric.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">                 071E496E1AD5AA0D008A50B4 /* MediaPlaybackTargetMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 071E496D1AD5AA0D008A50B4 /* MediaPlaybackTargetMac.mm */; };
</span><span class="lines">@@ -7721,6 +7722,8 @@
</span><span class="cx">                 07C59B6517F784BA000FBCBB /* MediaSourceSettings.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MediaSourceSettings.cpp; sourceTree = "<group>"; };
</span><span class="cx">                 07C59B6617F784BA000FBCBB /* MediaSourceSettings.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MediaSourceSettings.h; sourceTree = "<group>"; };
</span><span class="cx">                 07C59B6D17F794F6000FBCBB /* JSMediaStreamTrackCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSMediaStreamTrackCustom.cpp; sourceTree = "<group>"; };
</span><ins>+                07C8AD111D073D630087C5CE /* AVFoundationMIMETypeCache.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = AVFoundationMIMETypeCache.mm; sourceTree = "<group>"; };
+                07C8AD121D073D630087C5CE /* AVFoundationMIMETypeCache.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AVFoundationMIMETypeCache.h; sourceTree = "<group>"; };
</ins><span class="cx">                 07CA120D182D67D800D12197 /* JSRTCPeerConnectionCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSRTCPeerConnectionCustom.cpp; sourceTree = "<group>"; };
</span><span class="cx">                 07CE77D416712A6A00C55A47 /* InbandTextTrackPrivateClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InbandTextTrackPrivateClient.h; sourceTree = "<group>"; };
</span><span class="cx">                 07D6373E1BB0B11300256CE9 /* WebAudioSourceProviderAVFObjC.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebAudioSourceProviderAVFObjC.h; sourceTree = "<group>"; };
</span><span class="lines">@@ -23347,6 +23350,8 @@
</span><span class="cx">                                 CDE3A85517F6020400C5BE20 /* AudioTrackPrivateAVFObjC.mm */,
</span><span class="cx">                                 CD54A760180F9F7000B076C9 /* AudioTrackPrivateMediaSourceAVFObjC.cpp */,
</span><span class="cx">                                 CD54A761180F9F7000B076C9 /* AudioTrackPrivateMediaSourceAVFObjC.h */,
</span><ins>+                                07C8AD111D073D630087C5CE /* AVFoundationMIMETypeCache.mm */,
+                                07C8AD121D073D630087C5CE /* AVFoundationMIMETypeCache.h */,
</ins><span class="cx">                                 CDE595941BF166D100A1CBE8 /* CDMSessionAVContentKeySession.h */,
</span><span class="cx">                                 CDE595931BF166AD00A1CBE8 /* CDMSessionAVContentKeySession.mm */,
</span><span class="cx">                                 CDDE02EA18B3ED6D00CF7FF1 /* CDMSessionAVFoundationObjC.h */,
</span><span class="lines">@@ -31487,6 +31492,7 @@
</span><span class="cx">                                 073794F919F5864E00E5A045 /* RTCDataChannelHandlerMock.cpp in Sources */,
</span><span class="cx">                                 078E090717D14CEE00420AA1 /* RTCDTMFSender.cpp in Sources */,
</span><span class="cx">                                 073794FB19F5864E00E5A045 /* RTCDTMFSenderHandlerMock.cpp in Sources */,
</span><ins>+                                0719427F1D088F21002AA51D /* AVFoundationMIMETypeCache.mm in Sources */,
</ins><span class="cx">                                 078E090817D14CEE00420AA1 /* RTCDTMFToneChangeEvent.cpp in Sources */,
</span><span class="cx">                                 078E090917D14CEE00420AA1 /* RTCIceCandidate.cpp in Sources */,
</span><span class="cx">                                 073BE34F17D18183002BD431 /* RTCIceCandidateDescriptor.cpp in Sources */,
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsavfoundationobjcAVFoundationMIMETypeCacheh"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/platform/graphics/avfoundation/objc/AVFoundationMIMETypeCache.h (0 => 201831)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/AVFoundationMIMETypeCache.h         (rev 0)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/AVFoundationMIMETypeCache.h        2016-06-08 21:07:42 UTC (rev 201831)
</span><span class="lines">@@ -0,0 +1,57 @@
</span><ins>+/*
+ * Copyright (C) 2016 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef AVFoundationMIMETypeCache_h
+#define AVFoundationMIMETypeCache_h
+
+#if ENABLE(VIDEO) && USE(AVFOUNDATION)
+
+#include <wtf/Forward.h>
+#include <wtf/HashSet.h>
+#include <wtf/text/StringHash.h>
+
+namespace WebCore {
+
+class AVFoundationMIMETypeCache {
+public:
+ static AVFoundationMIMETypeCache& singleton();
+
+ AVFoundationMIMETypeCache();
+
+ void loadTypes();
+ const HashSet<String, ASCIICaseInsensitiveHash>& types();
+
+private:
+ enum MIMETypeLoadStatus { NotLoaded, Loading, Loaded };
+
+ MIMETypeLoadStatus m_status { NotLoaded };
+ dispatch_queue_t m_loaderQueue;
+ Lock m_lock;
+ HashSet<String, ASCIICaseInsensitiveHash> m_cache;
+};
+
+}
+#endif
+#endif
</ins></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsavfoundationobjcAVFoundationMIMETypeCachemm"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/platform/graphics/avfoundation/objc/AVFoundationMIMETypeCache.mm (0 => 201831)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/AVFoundationMIMETypeCache.mm         (rev 0)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/AVFoundationMIMETypeCache.mm        2016-06-08 21:07:42 UTC (rev 201831)
</span><span class="lines">@@ -0,0 +1,95 @@
</span><ins>+/*
+ * Copyright (C) 2016 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import "config.h"
+#import "AVFoundationMIMETypeCache.h"
+
+#if ENABLE(VIDEO) && USE(AVFOUNDATION)
+
+#import <AVFoundation/AVAsset.h>
+#import <wtf/HashMap.h>
+#import <wtf/Locker.h>
+#import <wtf/NeverDestroyed.h>
+
+#import "CoreMediaSoftLink.h"
+
+SOFT_LINK_FRAMEWORK_OPTIONAL(AVFoundation)
+SOFT_LINK_CLASS(AVFoundation, AVURLAsset)
+
+namespace WebCore {
+
+AVFoundationMIMETypeCache::AVFoundationMIMETypeCache()
+{
+ m_loaderQueue = dispatch_queue_create("WebCoreAudioVisualMIMETypes loader queue", DISPATCH_QUEUE_SERIAL);
+}
+
+void AVFoundationMIMETypeCache::loadTypes()
+{
+ {
+ Locker<Lock> lock(m_lock);
+
+ if (m_status != NotLoaded)
+ return;
+
+ if (!AVFoundationLibrary()) {
+ m_status = Loaded;
+ return;
+ }
+
+ m_status = Loading;
+ }
+
+ dispatch_async(m_loaderQueue, [this] {
+ for (NSString *type in [getAVURLAssetClass() audiovisualMIMETypes])
+ m_cache.add(type);
+ m_lock.lock();
+ m_status = Loaded;
+ m_lock.unlock();
+ });
+}
+
+const HashSet<String, ASCIICaseInsensitiveHash>& AVFoundationMIMETypeCache::types()
+{
+ m_lock.lock();
+ MIMETypeLoadStatus status = m_status;
+ m_lock.unlock();
+
+ if (status != Loaded) {
+ loadTypes();
+ dispatch_sync(m_loaderQueue, ^{ });
+ }
+
+ return m_cache;
+}
+
+AVFoundationMIMETypeCache& AVFoundationMIMETypeCache::singleton()
+{
+ static NeverDestroyed<AVFoundationMIMETypeCache> cache;
+ return cache.get();
+}
+
+}
+
+#endif
</ins></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsavfoundationobjcMediaPlayerPrivateAVFoundationObjCmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm (201830 => 201831)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm        2016-06-08 20:59:49 UTC (rev 201830)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm        2016-06-08 21:07:42 UTC (rev 201831)
</span><span class="lines">@@ -28,6 +28,7 @@
</span><span class="cx"> #if ENABLE(VIDEO) && USE(AVFOUNDATION)
</span><span class="cx"> #import "MediaPlayerPrivateAVFoundationObjC.h"
</span><span class="cx">
</span><ins>+#import "AVFoundationMIMETypeCache.h"
</ins><span class="cx"> #import "AVFoundationSPI.h"
</span><span class="cx"> #import "AVTrackPrivateAVFObjCImpl.h"
</span><span class="cx"> #import "AudioSourceProviderAVFObjC.h"
</span><span class="lines">@@ -45,13 +46,12 @@
</span><span class="cx"> #import "InbandMetadataTextTrackPrivateAVF.h"
</span><span class="cx"> #import "InbandTextTrackPrivateAVFObjC.h"
</span><span class="cx"> #import "InbandTextTrackPrivateLegacyAVFObjC.h"
</span><del>-#import "OutOfBandTextTrackPrivateAVF.h"
-#import "URL.h"
</del><span class="cx"> #import "Logging.h"
</span><span class="cx"> #import "MediaPlaybackTargetMac.h"
</span><span class="cx"> #import "MediaPlaybackTargetMock.h"
</span><span class="cx"> #import "MediaSelectionGroupAVFObjC.h"
</span><span class="cx"> #import "MediaTimeAVFoundation.h"
</span><ins>+#import "OutOfBandTextTrackPrivateAVF.h"
</ins><span class="cx"> #import "PixelBufferConformerCV.h"
</span><span class="cx"> #import "PlatformTimeRanges.h"
</span><span class="cx"> #import "QuartzCoreSPI.h"
</span><span class="lines">@@ -61,6 +61,7 @@
</span><span class="cx"> #import "TextEncoding.h"
</span><span class="cx"> #import "TextTrackRepresentation.h"
</span><span class="cx"> #import "TextureCacheCV.h"
</span><ins>+#import "URL.h"
</ins><span class="cx"> #import "UUID.h"
</span><span class="cx"> #import "VideoTextureCopierCV.h"
</span><span class="cx"> #import "VideoTrackPrivateAVFObjC.h"
</span><span class="lines">@@ -423,9 +424,12 @@
</span><span class="cx">
</span><span class="cx"> void MediaPlayerPrivateAVFoundationObjC::registerMediaEngine(MediaEngineRegistrar registrar)
</span><span class="cx"> {
</span><del>- if (isAvailable())
- registrar([](MediaPlayer* player) { return std::make_unique<MediaPlayerPrivateAVFoundationObjC>(player); },
</del><ins>+ if (!isAvailable())
+ return;
+
+ registrar([](MediaPlayer* player) { return std::make_unique<MediaPlayerPrivateAVFoundationObjC>(player); },
</ins><span class="cx"> getSupportedTypes, supportsType, originsInMediaCache, clearMediaCache, clearMediaCacheForOrigins, supportsKeySystem);
</span><ins>+ AVFoundationMIMETypeCache::singleton().loadTypes();
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> static AVAssetCache *assetCacheForPath(const String& path)
</span><span class="lines">@@ -1610,18 +1614,6 @@
</span><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx">
</span><del>-static const HashSet<String, ASCIICaseInsensitiveHash>& avfMIMETypes()
-{
- static NeverDestroyed<HashSet<String, ASCIICaseInsensitiveHash>> cache = []() {
- HashSet<String, ASCIICaseInsensitiveHash> types;
- for (NSString *type in [AVURLAsset audiovisualMIMETypes])
- types.add(type);
- return types;
- }();
-
- return cache;
-}
-
</del><span class="cx"> RetainPtr<CGImageRef> MediaPlayerPrivateAVFoundationObjC::createImageForTimeInRect(float time, const FloatRect& rect)
</span><span class="cx"> {
</span><span class="cx"> if (!m_imageGenerator)
</span><span class="lines">@@ -1646,7 +1638,8 @@
</span><span class="cx">
</span><span class="cx"> void MediaPlayerPrivateAVFoundationObjC::getSupportedTypes(HashSet<String, ASCIICaseInsensitiveHash>& supportedTypes)
</span><span class="cx"> {
</span><del>- supportedTypes = avfMIMETypes();
</del><ins>+ LOG(Media, "MediaPlayerPrivateAVFoundationObjC::getSupportedTypes");
+ supportedTypes = AVFoundationMIMETypeCache::singleton().types();
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> #if ENABLE(ENCRYPTED_MEDIA) || ENABLE(ENCRYPTED_MEDIA_V2)
</span><span class="lines">@@ -1693,7 +1686,7 @@
</span><span class="cx"> if (isUnsupportedMIMEType(parameters.type))
</span><span class="cx"> return MediaPlayer::IsNotSupported;
</span><span class="cx">
</span><del>- if (!staticMIMETypeList().contains(parameters.type) && !avfMIMETypes().contains(parameters.type))
</del><ins>+ if (!staticMIMETypeList().contains(parameters.type) && !AVFoundationMIMETypeCache::singleton().types().contains(parameters.type))
</ins><span class="cx"> return MediaPlayer::IsNotSupported;
</span><span class="cx">
</span><span class="cx"> // The spec says:
</span><span class="lines">@@ -1719,7 +1712,7 @@
</span><span class="cx"> if (!mimeType.isEmpty() && isUnsupportedMIMEType(mimeType))
</span><span class="cx"> return false;
</span><span class="cx">
</span><del>- if (!mimeType.isEmpty() && !staticMIMETypeList().contains(mimeType) && !avfMIMETypes().contains(mimeType))
</del><ins>+ if (!mimeType.isEmpty() && !staticMIMETypeList().contains(mimeType) && !AVFoundationMIMETypeCache::singleton().types().contains(mimeType))
</ins><span class="cx"> return false;
</span><span class="cx">
</span><span class="cx"> return true;
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsavfoundationobjcMediaPlayerPrivateMediaSourceAVFObjCmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm (201830 => 201831)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm        2016-06-08 20:59:49 UTC (rev 201830)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm        2016-06-08 21:07:42 UTC (rev 201831)
</span><span class="lines">@@ -28,6 +28,7 @@
</span><span class="cx">
</span><span class="cx"> #if ENABLE(MEDIA_SOURCE) && USE(AVFOUNDATION)
</span><span class="cx">
</span><ins>+#import "AVFoundationMIMETypeCache.h"
</ins><span class="cx"> #import "CDMSessionAVStreamSession.h"
</span><span class="cx"> #import "CDMSessionMediaSourceAVFObjC.h"
</span><span class="cx"> #import "FileSystem.h"
</span><span class="lines">@@ -202,9 +203,12 @@
</span><span class="cx">
</span><span class="cx"> void MediaPlayerPrivateMediaSourceAVFObjC::registerMediaEngine(MediaEngineRegistrar registrar)
</span><span class="cx"> {
</span><del>- if (isAvailable())
- registrar([](MediaPlayer* player) { return std::make_unique<MediaPlayerPrivateMediaSourceAVFObjC>(player); }, getSupportedTypes,
- supportsType, 0, 0, 0, 0);
</del><ins>+ if (!isAvailable())
+ return;
+
+ registrar([](MediaPlayer* player) { return std::make_unique<MediaPlayerPrivateMediaSourceAVFObjC>(player); },
+ getSupportedTypes, supportsType, 0, 0, 0, 0);
+ AVFoundationMIMETypeCache::singleton().loadTypes();
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> bool MediaPlayerPrivateMediaSourceAVFObjC::isAvailable()
</span><span class="lines">@@ -217,25 +221,9 @@
</span><span class="cx"> && class_getInstanceMethod(getAVSampleBufferAudioRendererClass(), @selector(setMuted:));
</span><span class="cx"> }
</span><span class="cx">
</span><del>-static const HashSet<String, ASCIICaseInsensitiveHash>& mimeTypeCache()
-{
- static NeverDestroyed<HashSet<String, ASCIICaseInsensitiveHash>> cache;
- static bool typeListInitialized = false;
-
- if (typeListInitialized)
- return cache;
- typeListInitialized = true;
-
- NSArray *types = [getAVURLAssetClass() audiovisualMIMETypes];
- for (NSString *mimeType in types)
- cache.get().add(mimeType);
-
- return cache;
-}
-
</del><span class="cx"> void MediaPlayerPrivateMediaSourceAVFObjC::getSupportedTypes(HashSet<String, ASCIICaseInsensitiveHash>& types)
</span><span class="cx"> {
</span><del>- types = mimeTypeCache();
</del><ins>+ types = AVFoundationMIMETypeCache::singleton().types();
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> MediaPlayer::SupportsType MediaPlayerPrivateMediaSourceAVFObjC::supportsType(const MediaEngineSupportParameters& parameters)
</span><span class="lines">@@ -248,7 +236,7 @@
</span><span class="cx"> return MediaPlayer::IsNotSupported;
</span><span class="cx"> #endif
</span><span class="cx">
</span><del>- if (parameters.type.isEmpty() || !mimeTypeCache().contains(parameters.type))
</del><ins>+ if (parameters.type.isEmpty() || !AVFoundationMIMETypeCache::singleton().types().contains(parameters.type))
</ins><span class="cx"> return MediaPlayer::IsNotSupported;
</span><span class="cx">
</span><span class="cx"> // The spec says:
</span></span></pre>
</div>
</div>
</body>
</html>