Title: [153706] trunk/Source/WebCore
Revision
153706
Author
jer.no...@apple.com
Date
2013-08-05 08:29:48 -0700 (Mon, 05 Aug 2013)

Log Message

Loading a video with a custom URL scheme will result in stalling playback
https://bugs.webkit.org/show_bug.cgi?id=119469

Reviewed by Eric Carlson.

Break the assumption that only one AVAssetResourceRequest will be outstanding simultaneously
by storing a HashMap of AVAssetResourceRequests and their resulting WebCoreAVFResourceLoader.
When loading is stopped (due to completion or error), notify the MediaPlayerPrivateAVFoundation
parent so that the map can be emptied.

* platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h:
* platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
(WebCore::MediaPlayerPrivateAVFoundationObjC::shouldWaitForLoadingOfResource): Store the request
    in m_resourceLoaderMap.
(WebCore::MediaPlayerPrivateAVFoundationObjC::didCancelLoadingRequest): Pull the request from
    m_resourceLoaderMap.
(WebCore::MediaPlayerPrivateAVFoundationObjC::didStopLoadingRequest): Remove the requset from
    m_resourceLoaderMap.
* platform/graphics/avfoundation/objc/WebCoreAVFResourceLoader.h:
* platform/graphics/avfoundation/objc/WebCoreAVFResourceLoader.mm:
(WebCore::WebCoreAVFResourceLoader::create): Return a PassRefPtr, rather than a PassOwnPtr.
(WebCore::WebCoreAVFResourceLoader::stopLoading): Call didStopLoadingRequest.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (153705 => 153706)


--- trunk/Source/WebCore/ChangeLog	2013-08-05 14:23:05 UTC (rev 153705)
+++ trunk/Source/WebCore/ChangeLog	2013-08-05 15:29:48 UTC (rev 153706)
@@ -1,3 +1,28 @@
+2013-08-03  Jer Noble  <jer.no...@apple.com>
+
+        Loading a video with a custom URL scheme will result in stalling playback
+        https://bugs.webkit.org/show_bug.cgi?id=119469
+
+        Reviewed by Eric Carlson.
+
+        Break the assumption that only one AVAssetResourceRequest will be outstanding simultaneously
+        by storing a HashMap of AVAssetResourceRequests and their resulting WebCoreAVFResourceLoader.
+        When loading is stopped (due to completion or error), notify the MediaPlayerPrivateAVFoundation
+        parent so that the map can be emptied.
+
+        * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h:
+        * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
+        (WebCore::MediaPlayerPrivateAVFoundationObjC::shouldWaitForLoadingOfResource): Store the request
+            in m_resourceLoaderMap.
+        (WebCore::MediaPlayerPrivateAVFoundationObjC::didCancelLoadingRequest): Pull the request from
+            m_resourceLoaderMap.
+        (WebCore::MediaPlayerPrivateAVFoundationObjC::didStopLoadingRequest): Remove the requset from
+            m_resourceLoaderMap.
+        * platform/graphics/avfoundation/objc/WebCoreAVFResourceLoader.h:
+        * platform/graphics/avfoundation/objc/WebCoreAVFResourceLoader.mm:
+        (WebCore::WebCoreAVFResourceLoader::create): Return a PassRefPtr, rather than a PassOwnPtr.
+        (WebCore::WebCoreAVFResourceLoader::stopLoading): Call didStopLoadingRequest.
+
 2013-08-05  Abhijeet Kandalkar  <abhijee...@samsung.com>
 
         Spatial Navigation should avoid unwanted calculation while deciding focus candidate.

Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h (153705 => 153706)


--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h	2013-08-05 14:23:05 UTC (rev 153705)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h	2013-08-05 15:29:48 UTC (rev 153706)
@@ -32,6 +32,7 @@
 #include <wtf/HashMap.h>
 
 OBJC_CLASS AVAssetImageGenerator;
+OBJC_CLASS AVAssetResourceLoadingRequest;
 OBJC_CLASS AVMediaSelectionGroup;
 OBJC_CLASS AVPlayer;
 OBJC_CLASS AVPlayerItem;
@@ -77,6 +78,7 @@
 #if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
     bool shouldWaitForLoadingOfResource(AVAssetResourceLoadingRequest*);
     void didCancelLoadingRequest(AVAssetResourceLoadingRequest*);
+    void didStopLoadingRequest(AVAssetResourceLoadingRequest *);
 #endif
 
 #if ENABLE(ENCRYPTED_MEDIA) || ENABLE(ENCRYPTED_MEDIA_V2)
@@ -201,7 +203,7 @@
     RetainPtr<VTPixelTransferSessionRef> m_pixelTransferSession;
 
     friend class WebCoreAVFResourceLoader;
-    OwnPtr<WebCoreAVFResourceLoader> m_resourceLoader;
+    HashMap<RetainPtr<AVAssetResourceLoadingRequest>, RefPtr<WebCoreAVFResourceLoader> > m_resourceLoaderMap;
     RetainPtr<WebCoreAVFLoaderDelegate> m_loaderDelegate;
     HashMap<String, RetainPtr<AVAssetResourceLoadingRequest> > m_keyURIToRequestMap;
     HashMap<String, RetainPtr<AVAssetResourceLoadingRequest> > m_sessionIDToRequestMap;

Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm (153705 => 153706)


--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm	2013-08-05 14:23:05 UTC (rev 153705)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm	2013-08-05 15:29:48 UTC (rev 153706)
@@ -942,8 +942,9 @@
     }
 #endif
 
-    m_resourceLoader = WebCoreAVFResourceLoader::create(this, avRequest);
-    m_resourceLoader->startLoading();
+    RefPtr<WebCoreAVFResourceLoader> resourceLoader = WebCoreAVFResourceLoader::create(this, avRequest);
+    m_resourceLoaderMap.add(avRequest, resourceLoader);
+    resourceLoader->startLoading();
     return true;
 }
 
@@ -951,9 +952,16 @@
 {
     String scheme = [[[avRequest request] URL] scheme];
 
-    if (m_resourceLoader)
-        m_resourceLoader->stopLoading();
+    WebCoreAVFResourceLoader* resourceLoader = m_resourceLoaderMap.get(avRequest);
+
+    if (resourceLoader)
+        resourceLoader->stopLoading();
 }
+
+void MediaPlayerPrivateAVFoundationObjC::didStopLoadingRequest(AVAssetResourceLoadingRequest *avRequest)
+{
+    m_resourceLoaderMap.remove(avRequest);
+}
 #endif
 
 bool MediaPlayerPrivateAVFoundationObjC::isAvailable()

Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/WebCoreAVFResourceLoader.h (153705 => 153706)


--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/WebCoreAVFResourceLoader.h	2013-08-05 14:23:05 UTC (rev 153705)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/WebCoreAVFResourceLoader.h	2013-08-05 15:29:48 UTC (rev 153706)
@@ -31,7 +31,8 @@
 #include "CachedRawResourceClient.h"
 #include "CachedResourceHandle.h"
 #include <wtf/Noncopyable.h>
-#include <wtf/PassOwnPtr.h>
+#include <wtf/PassRefPtr.h>
+#include <wtf/RefCounted.h>
 #include <wtf/RetainPtr.h>
 
 OBJC_CLASS AVAssetResourceLoadingRequest;
@@ -42,10 +43,10 @@
 class CachedResourceLoader;
 class MediaPlayerPrivateAVFoundationObjC;
 
-class WebCoreAVFResourceLoader : public CachedRawResourceClient {
+class WebCoreAVFResourceLoader : public RefCounted<WebCoreAVFResourceLoader>, CachedRawResourceClient {
     WTF_MAKE_NONCOPYABLE(WebCoreAVFResourceLoader); WTF_MAKE_FAST_ALLOCATED;
 public:
-    static PassOwnPtr<WebCoreAVFResourceLoader> create(MediaPlayerPrivateAVFoundationObjC* parent, AVAssetResourceLoadingRequest*);
+    static PassRefPtr<WebCoreAVFResourceLoader> create(MediaPlayerPrivateAVFoundationObjC* parent, AVAssetResourceLoadingRequest *);
     virtual ~WebCoreAVFResourceLoader();
 
     void startLoading();
@@ -61,7 +62,7 @@
 
     void fulfillRequestWithResource(CachedResource*);
 
-    WebCoreAVFResourceLoader(MediaPlayerPrivateAVFoundationObjC* parent, AVAssetResourceLoadingRequest*);
+    WebCoreAVFResourceLoader(MediaPlayerPrivateAVFoundationObjC* parent, AVAssetResourceLoadingRequest *);
     MediaPlayerPrivateAVFoundationObjC* m_parent;
     RetainPtr<AVAssetResourceLoadingRequest> m_avRequest;
     CachedResourceHandle<CachedRawResource> m_resource;

Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/WebCoreAVFResourceLoader.mm (153705 => 153706)


--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/WebCoreAVFResourceLoader.mm	2013-08-05 14:23:05 UTC (rev 153705)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/WebCoreAVFResourceLoader.mm	2013-08-05 15:29:48 UTC (rev 153706)
@@ -43,14 +43,14 @@
 
 namespace WebCore {
 
-PassOwnPtr<WebCoreAVFResourceLoader> WebCoreAVFResourceLoader::create(MediaPlayerPrivateAVFoundationObjC* parent, AVAssetResourceLoadingRequest* avRequest)
+PassRefPtr<WebCoreAVFResourceLoader> WebCoreAVFResourceLoader::create(MediaPlayerPrivateAVFoundationObjC* parent, AVAssetResourceLoadingRequest *avRequest)
 {
     ASSERT(avRequest);
     ASSERT(parent);
-    return adoptPtr(new WebCoreAVFResourceLoader(parent, avRequest));
+    return adoptRef(new WebCoreAVFResourceLoader(parent, avRequest));
 }
 
-WebCoreAVFResourceLoader::WebCoreAVFResourceLoader(MediaPlayerPrivateAVFoundationObjC* parent, AVAssetResourceLoadingRequest* avRequest)
+WebCoreAVFResourceLoader::WebCoreAVFResourceLoader(MediaPlayerPrivateAVFoundationObjC* parent, AVAssetResourceLoadingRequest *avRequest)
     : m_parent(parent)
     , m_avRequest(avRequest)
 {
@@ -88,6 +88,8 @@
 
     m_resource->removeClient(this);
     m_resource = 0;
+
+    m_parent->didStopLoadingRequest(m_avRequest.get());
 }
 
 void WebCoreAVFResourceLoader::responseReceived(CachedResource* resource, const ResourceResponse& response)
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to