Diff
Modified: trunk/LayoutTests/ChangeLog (134801 => 134802)
--- trunk/LayoutTests/ChangeLog 2012-11-15 19:06:03 UTC (rev 134801)
+++ trunk/LayoutTests/ChangeLog 2012-11-15 19:08:54 UTC (rev 134802)
@@ -1,3 +1,17 @@
+2012-11-13 Jer Noble <[email protected]>
+
+ Support loading of blob URLs in AVFoundation.
+ https://bugs.webkit.org/show_bug.cgi?id=102182
+
+ Reviewed by Eric Carlson.
+
+ Add a new test which verifies blob url support in video elements.
+
+ * media/video-src-blob-expected.txt: Added.
+ * media/video-src-blob.html: Added.
+ * platform/mac/TestExpectations: Add expected failure results for OSX releases where
+ custom media loading is not supported.
+
2012-11-15 Sheriff Bot <[email protected]>
Unreviewed, rolling out r134649 and r134665.
Added: trunk/LayoutTests/media/video-src-blob-expected.txt (0 => 134802)
--- trunk/LayoutTests/media/video-src-blob-expected.txt (rev 0)
+++ trunk/LayoutTests/media/video-src-blob-expected.txt 2012-11-15 19:08:54 UTC (rev 134802)
@@ -0,0 +1,5 @@
+This tests the ability of the <video> element to load blob URLs. In the browser, select a video file:
+EVENT(change)
+EVENT(loadedmetadata)
+END OF TEST
+
Added: trunk/LayoutTests/media/video-src-blob.html (0 => 134802)
--- trunk/LayoutTests/media/video-src-blob.html (rev 0)
+++ trunk/LayoutTests/media/video-src-blob.html 2012-11-15 19:08:54 UTC (rev 134802)
@@ -0,0 +1,36 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <script src=""
+ <script src=""
+ <script>
+ function inputFileChanged(e) {
+ findMediaElement();
+ var file = e.target.files[0];
+ waitForEventAndEnd('loadedmetadata');
+ waitForEventAndFail('error');
+ video.src = ""
+ }
+
+ function runTest() {
+ var inputFile = document.getElementById('file');
+ var centerX = inputFile.offsetLeft + inputFile.offsetWidth / 2;
+ var centerY = inputFile.offsetTop + inputFile.offsetHeight / 2;
+ waitForEvent('change', inputFileChanged, false, false, inputFile);
+
+ if (window.eventSender) {
+ eventSender.beginDragWithFiles([findMediaFile("video", "content/test")]);
+ eventSender.mouseMoveTo(centerX, centerY);
+ eventSender.mouseUp();
+ }
+ }
+ </script>
+ </head>
+ <body _onload_="runTest()">
+ <div>
+ This tests the ability of the <video> element to load blob URLs. In the browser, select a video file:
+ <input type="file" name="file" id="file">
+ </div>
+ <video></video>
+ </body>
+</html>
Modified: trunk/LayoutTests/platform/mac/TestExpectations (134801 => 134802)
--- trunk/LayoutTests/platform/mac/TestExpectations 2012-11-15 19:06:03 UTC (rev 134801)
+++ trunk/LayoutTests/platform/mac/TestExpectations 2012-11-15 19:08:54 UTC (rev 134802)
@@ -1182,3 +1182,6 @@
webkit.org/b/100142 css3/filters/effect-reference-hw.html [ Fail ]
webkit.org/b/100142 css3/filters/effect-reference-ordering-hw.html [ Fail ]
webkit.org/b/100142 css3/filters/effect-reference.html [ Fail ]
+
+# Mountain Lion and prior do not support custom media data loading
+Bug(jernoble) [ MountainLion Lion SnowLeopard ] media/video-src-blob.html
Modified: trunk/Source/WebCore/ChangeLog (134801 => 134802)
--- trunk/Source/WebCore/ChangeLog 2012-11-15 19:06:03 UTC (rev 134801)
+++ trunk/Source/WebCore/ChangeLog 2012-11-15 19:08:54 UTC (rev 134802)
@@ -1,3 +1,63 @@
+2012-11-13 Jer Noble <[email protected]>
+
+ Support loading of blob URLs in AVFoundation.
+ https://bugs.webkit.org/show_bug.cgi?id=102182
+
+ Reviewed by Eric Carlson.
+
+ Add support for BLOB (and other non-natively supported schemed) URLs through the AVAssetResourceLoader API.
+
+ Test: media/video-src-blob.html
+
+ * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h:
+ * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
+ (WebCore::MediaPlayerPrivateAVFoundationObjC::shouldWaitForLoadingOfResource): Only go down the encrypted
+ media path if the key scheme is skp://.
+ (WebCore::MediaPlayerPrivateAVFoundationObjC::didCancelLoadingRequest): Added. Cancel resource loading if
+ the media engine requests it.
+ (WebCore::MediaPlayerPrivateAVFoundationObjC::addKey): Use the new, non-deprecated API.
+
+ Use the dispatch_main_queue() as the AVAssetResourceLoadDelegate queue now that <rdar://problem/12362461> is fixed.
+ * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
+ (WebCore::MediaPlayerPrivateAVFoundationObjC::createAVAssetForURL):
+ (-[WebCoreAVFLoaderDelegate resourceLoader:shouldWaitForLoadingOfRequestedResource:]):
+ (-[WebCoreAVFLoaderDelegate resourceLoader:didCancelLoadingRequest:]):
+
+ Add a new helper class to manage loading the CachedRawResource and feed the incoming
+ data to the AVAssetResourceLoader.
+ * platform/graphics/avfoundation/objc/WebCoreAVFResourceLoader.h: Added.
+ * platform/graphics/avfoundation/objc/WebCoreAVFResourceLoader.mm: Added.
+ (WebCore::WebCoreAVFResourceLoader::create): Simple factory.
+ (WebCore::WebCoreAVFResourceLoader::WebCoreAVFResourceLoader): Simple constructor.
+ (WebCore::WebCoreAVFResourceLoader::~WebCoreAVFResourceLoader): Simple destructor.
+ (WebCore::WebCoreAVFResourceLoader::startLoading): Tell the cachedResourceLoader to schedule loading.
+ (WebCore::WebCoreAVFResourceLoader::stopLoading): Remove this as a client of the resource.
+ (WebCore::WebCoreAVFResourceLoader::responseReceived): Fill in the contentInformation field of the
+ AVAssetResourceLoadingRequest.
+ (WebCore::WebCoreAVFResourceLoader::dataReceived): Call fulfillRequestWithResource.
+ (WebCore::WebCoreAVFResourceLoader::notifyFinished): Tell the AVAssetResourceLoadingRequest that loading
+ has completed.
+ (WebCore::WebCoreAVFResourceLoader::fulfillRequestWithResource): Fill in (if possible) the dataRequest
+ field of the AVAssetResourceLoadingRequest.
+
+ Add a MediaPlayerClient method allowing MediaPlayerPrivate subclasses to access the HTMLMediaElement's
+ document's cachedResourceLoader.
+ * html/HTMLMediaElement.cpp:
+ (WebCore::HTMLMediaElement::mediaPlayerCachedResourceLoader):
+ * html/HTMLMediaElement.h:
+ * platform/graphics/MediaPlayer.cpp:
+ (WebCore::MediaPlayer::cachedResourceLoader):
+ * platform/graphics/MediaPlayer.h:
+ (WebCore::MediaPlayerClient::mediaPlayerCachedResourceLoader):
+
+ Add a convenience method to convert from MIME type -> UTI.
+ * platform/network/mac/UTIUtilities.h:
+ * platform/network/mac/UTIUtilities.mm:
+ (WebCore::UTIFromMIMEType):
+
+ Add new files to project.
+ * WebCore.xcodeproj/project.pbxproj:
+
2012-11-15 Kenneth Rohde Christiansen <[email protected]>
Remove initiallyFitToViewport attribute
Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (134801 => 134802)
--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2012-11-15 19:06:03 UTC (rev 134801)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2012-11-15 19:08:54 UTC (rev 134802)
@@ -5890,6 +5890,7 @@
CD27F6E7145770D30078207D /* MediaController.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CD27F6E6145770D30078207D /* MediaController.cpp */; };
CD37B39815C1B971006DC898 /* DiagnosticLoggingKeys.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CD37B37415C1A7E1006DC898 /* DiagnosticLoggingKeys.cpp */; };
CD4AC52A1496AE9A0087C4EF /* Composite.wav in Copy Audio Resources */ = {isa = PBXBuildFile; fileRef = CD4AC5281496AE2F0087C4EF /* Composite.wav */; };
+ CD7E05221651C28200C1201F /* WebCoreAVFResourceLoader.mm in Sources */ = {isa = PBXBuildFile; fileRef = CD7E05211651A84100C1201F /* WebCoreAVFResourceLoader.mm */; };
CD82030A1395AB6A00F956C6 /* WebVideoFullscreenController.h in Headers */ = {isa = PBXBuildFile; fileRef = CD8203061395AB6A00F956C6 /* WebVideoFullscreenController.h */; settings = {ATTRIBUTES = (Private, ); }; };
CD82030B1395AB6A00F956C6 /* WebVideoFullscreenController.mm in Sources */ = {isa = PBXBuildFile; fileRef = CD8203071395AB6A00F956C6 /* WebVideoFullscreenController.mm */; settings = {COMPILER_FLAGS = "-Wno-undef -Wno-deprecated-declarations"; }; };
CD82030C1395AB6A00F956C6 /* WebVideoFullscreenHUDWindowController.h in Headers */ = {isa = PBXBuildFile; fileRef = CD8203081395AB6A00F956C6 /* WebVideoFullscreenHUDWindowController.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -13274,6 +13275,8 @@
CD37B37515C1A7E1006DC898 /* DiagnosticLoggingKeys.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DiagnosticLoggingKeys.h; sourceTree = "<group>"; };
CD4AC5281496AE2F0087C4EF /* Composite.wav */ = {isa = PBXFileReference; lastKnownFileType = audio.wav; name = Composite.wav; path = platform/audio/resources/Composite.wav; sourceTree = SOURCE_ROOT; };
CD4E0AFA11F7BC27009D3811 /* fullscreen.css */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.css; path = fullscreen.css; sourceTree = "<group>"; };
+ CD7E05201651A84100C1201F /* WebCoreAVFResourceLoader.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = WebCoreAVFResourceLoader.h; path = objc/WebCoreAVFResourceLoader.h; sourceTree = "<group>"; };
+ CD7E05211651A84100C1201F /* WebCoreAVFResourceLoader.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; name = WebCoreAVFResourceLoader.mm; path = objc/WebCoreAVFResourceLoader.mm; sourceTree = "<group>"; };
CD8203061395AB6A00F956C6 /* WebVideoFullscreenController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebVideoFullscreenController.h; sourceTree = "<group>"; };
CD8203071395AB6A00F956C6 /* WebVideoFullscreenController.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebVideoFullscreenController.mm; sourceTree = "<group>"; };
CD8203081395AB6A00F956C6 /* WebVideoFullscreenHUDWindowController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebVideoFullscreenHUDWindowController.h; sourceTree = "<group>"; };
@@ -21049,6 +21052,8 @@
children = (
DF9AFD7013FC31D80015FEB7 /* MediaPlayerPrivateAVFoundationObjC.h */,
DF9AFD7113FC31D80015FEB7 /* MediaPlayerPrivateAVFoundationObjC.mm */,
+ CD7E05201651A84100C1201F /* WebCoreAVFResourceLoader.h */,
+ CD7E05211651A84100C1201F /* WebCoreAVFResourceLoader.mm */,
);
name = objc;
sourceTree = "<group>";
@@ -28800,6 +28805,7 @@
E1424C93164B52C800F32D40 /* CookieJar.cpp in Sources */,
570B78BF1650CE81001DBE1B /* SelectRuleFeatureSet.cpp in Sources */,
1E50084816516AD800B7E098 /* RenderThemeMacShared.mm in Sources */,
+ CD7E05221651C28200C1201F /* WebCoreAVFResourceLoader.mm in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Modified: trunk/Source/WebCore/html/HTMLMediaElement.cpp (134801 => 134802)
--- trunk/Source/WebCore/html/HTMLMediaElement.cpp 2012-11-15 19:06:03 UTC (rev 134801)
+++ trunk/Source/WebCore/html/HTMLMediaElement.cpp 2012-11-15 19:08:54 UTC (rev 134802)
@@ -4599,6 +4599,11 @@
return mediaPlayerOwningDocument()->view()->windowClipRect();
}
+CachedResourceLoader* HTMLMediaElement::mediaPlayerCachedResourceLoader()
+{
+ return mediaPlayerOwningDocument()->cachedResourceLoader();
+}
+
void HTMLMediaElement::removeBehaviorsRestrictionsAfterFirstUserGesture()
{
m_restrictions = NoRestrictions;
Modified: trunk/Source/WebCore/html/HTMLMediaElement.h (134801 => 134802)
--- trunk/Source/WebCore/html/HTMLMediaElement.h 2012-11-15 19:06:03 UTC (rev 134801)
+++ trunk/Source/WebCore/html/HTMLMediaElement.h 2012-11-15 19:08:54 UTC (rev 134802)
@@ -441,6 +441,7 @@
virtual bool mediaPlayerIsLooping() const OVERRIDE;
virtual HostWindow* mediaPlayerHostWindow() OVERRIDE;
virtual IntRect mediaPlayerWindowClipRect() OVERRIDE;
+ virtual CachedResourceLoader* mediaPlayerCachedResourceLoader() OVERRIDE;
#if PLATFORM(WIN) && USE(AVFOUNDATION)
virtual GraphicsDeviceAdapter* mediaPlayerGraphicsDeviceAdapter(const MediaPlayer*) const OVERRIDE;
Modified: trunk/Source/WebCore/platform/graphics/MediaPlayer.cpp (134801 => 134802)
--- trunk/Source/WebCore/platform/graphics/MediaPlayer.cpp 2012-11-15 19:06:03 UTC (rev 134801)
+++ trunk/Source/WebCore/platform/graphics/MediaPlayer.cpp 2012-11-15 19:08:54 UTC (rev 134802)
@@ -1101,6 +1101,14 @@
}
#endif
+CachedResourceLoader* MediaPlayer::cachedResourceLoader()
+{
+ if (!m_mediaPlayerClient)
+ return 0;
+
+ return m_mediaPlayerClient->mediaPlayerCachedResourceLoader();
}
+}
+
#endif
Modified: trunk/Source/WebCore/platform/graphics/MediaPlayer.h (134801 => 134802)
--- trunk/Source/WebCore/platform/graphics/MediaPlayer.h 2012-11-15 19:06:03 UTC (rev 134801)
+++ trunk/Source/WebCore/platform/graphics/MediaPlayer.h 2012-11-15 19:08:54 UTC (rev 134802)
@@ -93,6 +93,7 @@
extern const PlatformMedia NoPlatformMedia;
+class CachedResourceLoader;
class ContentType;
class FrameView;
class GraphicsContext;
@@ -206,6 +207,7 @@
virtual bool mediaPlayerIsLooping() const { return false; }
virtual HostWindow* mediaPlayerHostWindow() { return 0; }
virtual IntRect mediaPlayerWindowClipRect() { return IntRect(); }
+ virtual CachedResourceLoader* mediaPlayerCachedResourceLoader() { return 0; }
};
class MediaPlayerSupportsTypeClient {
@@ -423,6 +425,8 @@
String engineDescription() const;
+ CachedResourceLoader* cachedResourceLoader();
+
private:
MediaPlayer(MediaPlayerClient*);
void loadWithNextMediaEngine(MediaPlayerFactory*);
Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h (134801 => 134802)
--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h 2012-11-15 19:06:03 UTC (rev 134801)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h 2012-11-15 19:08:54 UTC (rev 134802)
@@ -28,6 +28,7 @@
#if ENABLE(VIDEO) && USE(AVFOUNDATION)
+#include "CachedResourceClient.h"
#include "MediaPlayerPrivateAVFoundation.h"
#include <wtf/HashMap.h>
@@ -39,7 +40,7 @@
OBJC_CLASS AVAssetImageGenerator;
OBJC_CLASS WebCoreAVFMovieObserver;
-#if ENABLE(ENCRYPTED_MEDIA) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
+#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
OBJC_CLASS WebCoreAVFLoaderDelegate;
OBJC_CLASS AVAssetResourceLoadingRequest;
#endif
@@ -53,6 +54,8 @@
namespace WebCore {
+class WebCoreAVFResourceLoader;
+
class MediaPlayerPrivateAVFoundationObjC : public MediaPlayerPrivateAVFoundation {
public:
~MediaPlayerPrivateAVFoundationObjC();
@@ -62,8 +65,9 @@
void setAsset(id);
virtual void tracksChanged();
-#if ENABLE(ENCRYPTED_MEDIA) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
+#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
bool shouldWaitForLoadingOfResource(AVAssetResourceLoadingRequest*);
+ void didCancelLoadingRequest(AVAssetResourceLoadingRequest*);
#endif
private:
@@ -165,6 +169,11 @@
HashMap<String, RetainPtr<AVAssetResourceLoadingRequest> > m_keyURIToRequestMap;
HashMap<String, RetainPtr<AVAssetResourceLoadingRequest> > m_sessionIDToRequestMap;
#endif
+
+#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
+ friend class WebCoreAVFResourceLoader;
+ OwnPtr<WebCoreAVFResourceLoader> m_resourceLoader;
+#endif
};
}
Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm (134801 => 134802)
--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm 2012-11-15 19:06:03 UTC (rev 134801)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm 2012-11-15 19:08:54 UTC (rev 134802)
@@ -41,6 +41,7 @@
#import "SoftLinking.h"
#import "TimeRanges.h"
#import "UUID.h"
+#import "WebCoreAVFResourceLoader.h"
#import "WebCoreSystemInterface.h"
#import <objc/objc-runtime.h>
#import <wtf/UnusedParam.h>
@@ -117,23 +118,13 @@
-(void)observeValueForKeyPath:keyPath ofObject:(id)object change:(NSDictionary *)change context:(MediaPlayerAVFoundationObservationContext)context;
@end
-#if ENABLE(ENCRYPTED_MEDIA)
+#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
@interface WebCoreAVFLoaderDelegate : NSObject<AVAssetResourceLoaderDelegate> {
MediaPlayerPrivateAVFoundationObjC* m_callback;
}
- (id)initWithCallback:(MediaPlayerPrivateAVFoundationObjC*)callback;
- (BOOL)resourceLoader:(AVAssetResourceLoader *)resourceLoader shouldWaitForLoadingOfRequestedResource:(AVAssetResourceLoadingRequest *)loadingRequest;
@end
-
-static dispatch_queue_t globalLoaderDelegateQueue()
-{
- static dispatch_queue_t globalQueue;
- static dispatch_once_t onceToken;
- dispatch_once(&onceToken, ^{
- globalQueue = dispatch_queue_create("WebCoreAVFLoaderDelegate queue", DISPATCH_QUEUE_SERIAL);
- });
- return globalQueue;
-}
#endif
namespace WebCore {
@@ -335,8 +326,8 @@
NSURL *cocoaURL = KURL(ParsedURLString, url);
m_avAsset.adoptNS([[AVURLAsset alloc] initWithURL:cocoaURL options:options.get()]);
-#if ENABLE(ENCRYPTED_MEDIA)
- [[m_avAsset.get() resourceLoader] setDelegate:m_loaderDelegate.get() queue:globalLoaderDelegateQueue()];
+#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
+ [[m_avAsset.get() resourceLoader] setDelegate:m_loaderDelegate.get() queue:dispatch_get_main_queue()];
#endif
m_haveCheckedPlayability = false;
@@ -792,25 +783,42 @@
bool MediaPlayerPrivateAVFoundationObjC::shouldWaitForLoadingOfResource(AVAssetResourceLoadingRequest* avRequest)
{
+ String scheme = [[[avRequest request] URL] scheme];
String keyURI = [[[avRequest request] URL] absoluteString];
- // Create an initData with the following layout:
- // [4 bytes: keyURI size], [keyURI size bytes: keyURI]
- unsigned keyURISize = keyURI.length() * sizeof(UChar);
- RefPtr<ArrayBuffer> initDataBuffer = ArrayBuffer::create(4 + keyURISize, 1);
- RefPtr<DataView> initDataView = DataView::create(initDataBuffer, 0, initDataBuffer->byteLength());
- ExceptionCode ec = 0;
- initDataView->setUint32(0, keyURISize, true, ec);
+#if ENABLE(ENCRYPTED_MEDIA)
+ if (scheme == "skd") {
+ // Create an initData with the following layout:
+ // [4 bytes: keyURI size], [keyURI size bytes: keyURI]
+ unsigned keyURISize = keyURI.length() * sizeof(UChar);
+ RefPtr<ArrayBuffer> initDataBuffer = ArrayBuffer::create(4 + keyURISize, 1);
+ RefPtr<DataView> initDataView = DataView::create(initDataBuffer, 0, initDataBuffer->byteLength());
+ ExceptionCode ec = 0;
+ initDataView->setUint32(0, keyURISize, true, ec);
- RefPtr<Uint16Array> keyURIArray = Uint16Array::create(initDataBuffer, 4, keyURI.length());
- keyURIArray->setRange(keyURI.characters(), keyURI.length() / sizeof(unsigned char), 0);
+ RefPtr<Uint16Array> keyURIArray = Uint16Array::create(initDataBuffer, 4, keyURI.length());
+ keyURIArray->setRange(keyURI.characters(), keyURI.length() / sizeof(unsigned char), 0);
- if (!player()->keyNeeded("com.apple.lskd", emptyString(), static_cast<const unsigned char*>(initDataBuffer->data()), initDataBuffer->byteLength()))
- return false;
+ if (!player()->keyNeeded("com.apple.lskd", emptyString(), static_cast<const unsigned char*>(initDataBuffer->data()), initDataBuffer->byteLength()))
+ return false;
- m_keyURIToRequestMap.set(keyURI, avRequest);
+ m_keyURIToRequestMap.set(keyURI, avRequest);
+ return true;
+ }
+#endif
+
+ m_resourceLoader = WebCoreAVFResourceLoader::create(this, avRequest);
+ m_resourceLoader->startLoading();
return true;
}
+
+void MediaPlayerPrivateAVFoundationObjC::didCancelLoadingRequest(AVAssetResourceLoadingRequest* avRequest)
+{
+ String scheme = [[[avRequest request] URL] scheme];
+
+ if (m_resourceLoader)
+ m_resourceLoader->stopLoading();
+}
#endif
bool MediaPlayerPrivateAVFoundationObjC::isAvailable()
@@ -1089,10 +1097,8 @@
RetainPtr<AVAssetResourceLoadingRequest> avRequest = m_sessionIDToRequestMap.get(sessionID);
RetainPtr<NSData> keyData = adoptNS([[NSData alloc] initWithBytes:keyPtr length:keyLength]);
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wdeprecated-declarations"
- [avRequest.get() finishLoadingWithResponse:nil data:keyData.get() redirect:nil];
-#pragma clang diagnostic pop
+ [[avRequest.get() dataRequest] respondWithData:keyData.get()];
+ [avRequest.get() finishLoading];
m_sessionIDToRequestMap.remove(sessionID);
player()->keyAdded(keySystem, sessionID);
@@ -1242,7 +1248,7 @@
@end
-#if ENABLE(ENCRYPTED_MEDIA)
+#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
@implementation WebCoreAVFLoaderDelegate
- (id)initWithCallback:(MediaPlayerPrivateAVFoundationObjC*)callback
@@ -1254,13 +1260,14 @@
- (BOOL)resourceLoader:(AVAssetResourceLoader *)resourceLoader shouldWaitForLoadingOfRequestedResource:(AVAssetResourceLoadingRequest *)loadingRequest
{
UNUSED_PARAM(resourceLoader);
- dispatch_async(dispatch_get_main_queue(), ^{
- if (!m_callback->shouldWaitForLoadingOfResource(loadingRequest))
- [loadingRequest finishLoadingWithError:nil];
- });
- return TRUE;
+ return m_callback->shouldWaitForLoadingOfResource(loadingRequest);
}
+- (void)resourceLoader:(AVAssetResourceLoader *)resourceLoader didCancelLoadingRequest:(AVAssetResourceLoadingRequest *)loadingRequest
+{
+ UNUSED_PARAM(resourceLoader);
+ return m_callback->didCancelLoadingRequest(loadingRequest);
+}
@end
#endif
Added: trunk/Source/WebCore/platform/graphics/avfoundation/objc/WebCoreAVFResourceLoader.h (0 => 134802)
--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/WebCoreAVFResourceLoader.h (rev 0)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/WebCoreAVFResourceLoader.h 2012-11-15 19:08:54 UTC (rev 134802)
@@ -0,0 +1,72 @@
+/*
+ * Copyright (C) 2012 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. AND ITS CONTRIBUTORS ``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 ITS 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 WebCoreAVFResourceLoader_h
+#define WebCoreAVFResourceLoader_h
+
+#if ENABLE(VIDEO) && USE(AVFOUNDATION) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
+
+#include "CachedRawResource.h"
+#include "CachedResourceHandle.h"
+#include <wtf/PassOwnPtr.h>
+#include <wtf/RetainPtr.h>
+
+OBJC_CLASS AVAssetResourceLoadingRequest;
+
+namespace WebCore {
+
+class CachedResourceLoader;
+class MediaPlayerPrivateAVFoundationObjC;
+
+class WebCoreAVFResourceLoader : public CachedRawResourceClient {
+ WTF_MAKE_NONCOPYABLE(WebCoreAVFResourceLoader); WTF_MAKE_FAST_ALLOCATED;
+public:
+ static PassOwnPtr<WebCoreAVFResourceLoader> create(MediaPlayerPrivateAVFoundationObjC* parent, AVAssetResourceLoadingRequest*);
+ virtual ~WebCoreAVFResourceLoader();
+
+ void startLoading();
+ void stopLoading();
+
+ CachedRawResource* resource();
+
+private:
+ // CachedResourceClient
+ virtual void responseReceived(CachedResource*, const ResourceResponse&) OVERRIDE;
+ virtual void dataReceived(CachedResource*, const char*, int) OVERRIDE;
+ virtual void notifyFinished(CachedResource*) OVERRIDE;
+
+ void fulfillRequestWithResource(CachedResource*);
+
+ WebCoreAVFResourceLoader(MediaPlayerPrivateAVFoundationObjC* parent, AVAssetResourceLoadingRequest*);
+ MediaPlayerPrivateAVFoundationObjC* m_parent;
+ RetainPtr<AVAssetResourceLoadingRequest> m_avRequest;
+ CachedResourceHandle<CachedRawResource> m_resource;
+};
+
+}
+
+#endif // ENABLE(VIDEO) && USE(AVFOUNDATION)
+
+#endif // WebCoreAVFResourceLoader_h
Added: trunk/Source/WebCore/platform/graphics/avfoundation/objc/WebCoreAVFResourceLoader.mm (0 => 134802)
--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/WebCoreAVFResourceLoader.mm (rev 0)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/WebCoreAVFResourceLoader.mm 2012-11-15 19:08:54 UTC (rev 134802)
@@ -0,0 +1,167 @@
+/*
+ * Copyright (C) 2012 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. AND ITS CONTRIBUTORS ``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 ITS 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 "WebCoreAVFResourceLoader.h"
+
+#if ENABLE(VIDEO) && USE(AVFOUNDATION) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
+
+#import "CachedRawResource.h"
+#import "CachedResourceLoader.h"
+#import "CachedResourceRequest.h"
+#import "MediaPlayerPrivateAVFoundationObjC.h"
+#import "ResourceBuffer.h"
+#import "ResourceLoaderOptions.h"
+#import "SharedBuffer.h"
+#import "SoftLinking.h"
+#import "UTIUtilities.h"
+#import <AVFoundation/AVAssetResourceLoader.h>
+#import <objc/objc-runtime.h>
+#import <wtf/text/CString.h>
+
+namespace WebCore {
+
+PassOwnPtr<WebCoreAVFResourceLoader> WebCoreAVFResourceLoader::create(MediaPlayerPrivateAVFoundationObjC* parent, AVAssetResourceLoadingRequest* avRequest)
+{
+ ASSERT(avRequest);
+ ASSERT(parent);
+ return adoptPtr(new WebCoreAVFResourceLoader(parent, avRequest));
+}
+
+WebCoreAVFResourceLoader::WebCoreAVFResourceLoader(MediaPlayerPrivateAVFoundationObjC* parent, AVAssetResourceLoadingRequest* avRequest)
+ : m_parent(parent)
+ , m_avRequest(avRequest)
+{
+}
+
+WebCoreAVFResourceLoader::~WebCoreAVFResourceLoader()
+{
+ stopLoading();
+}
+
+void WebCoreAVFResourceLoader::startLoading()
+{
+ if (m_resource)
+ return;
+
+ KURL requestURL = [[m_avRequest.get() request] URL];
+
+ CachedResourceRequest request(ResourceRequest(requestURL), ResourceLoaderOptions(SendCallbacks, DoNotSniffContent, BufferData, DoNotAllowStoredCredentials, DoNotAskClientForCrossOriginCredentials, DoSecurityCheck));
+
+ request.mutableResourceRequest().setPriority(ResourceLoadPriorityLow);
+ CachedResourceLoader* loader = m_parent->player()->cachedResourceLoader();
+ m_resource = loader ? loader->requestRawResource(request) : 0;
+ if (m_resource)
+ m_resource->addClient(this);
+ else {
+ LOG_ERROR("Failed to start load for media at url %s", requestURL.string().ascii().data());
+ [m_avRequest.get() finishLoadingWithError:0];
+ }
+}
+
+void WebCoreAVFResourceLoader::stopLoading()
+{
+ if (!m_resource)
+ return;
+
+ m_resource->removeClient(this);
+ m_resource = 0;
+}
+
+void WebCoreAVFResourceLoader::responseReceived(CachedResource* resource, const ResourceResponse& response)
+{
+ ASSERT(resource == m_resource);
+
+ int status = response.httpStatusCode();
+ if (status && (status < 200 || status > 299)) {
+ [m_avRequest.get() finishLoadingWithError:0];
+ return;
+ }
+
+ if (AVAssetResourceLoadingContentInformationRequest* contentInfo = [m_avRequest.get() contentInformationRequest]) {
+ String uti = UTIFromMIMEType(response.mimeType().createCFString().get()).get();
+
+ [contentInfo setContentType:uti];
+ [contentInfo setContentLength:response.expectedContentLength()];
+ [contentInfo setByteRangeAccessSupported:YES];
+
+ if (![m_avRequest dataRequest]) {
+ [m_avRequest.get() finishLoading];
+ stopLoading();
+ }
+ }
+}
+
+void WebCoreAVFResourceLoader::dataReceived(CachedResource* resource, const char*, int)
+{
+ fulfillRequestWithResource(resource);
+}
+
+void WebCoreAVFResourceLoader::notifyFinished(CachedResource* resource)
+{
+ fulfillRequestWithResource(resource);
+ [m_avRequest.get() finishLoading];
+ stopLoading();
+}
+
+void WebCoreAVFResourceLoader::fulfillRequestWithResource(CachedResource* resource)
+{
+ ASSERT(resource == m_resource);
+ AVAssetResourceLoadingDataRequest* dataRequest = [m_avRequest dataRequest];
+ if (!dataRequest)
+ return;
+
+ SharedBuffer* data = ""
+
+ // Check for possible unsigned overflow.
+ ASSERT([dataRequest currentOffset] >= [dataRequest requestedOffset]);
+ ASSERT([dataRequest requestedLength] >= ([dataRequest currentOffset] - [dataRequest requestedOffset]));
+
+ unsigned remainingLength = [dataRequest requestedLength] - ([dataRequest currentOffset] - [dataRequest requestedOffset]);
+ do {
+ // Check to see if there is any data available in the buffer to fulfill the data request.
+ if (data->size() <= [dataRequest currentOffset])
+ return;
+
+ const char* someData;
+ unsigned receivedLength = data->getSomeData(someData, [dataRequest currentOffset]);
+
+ // Create an NSData with only as much of the received data as necessary to fulfill the request.
+ unsigned length = MIN(receivedLength, remainingLength);
+ RetainPtr<NSData> nsData = adoptNS([[NSData alloc] initWithBytes:someData length:length]);
+
+ [dataRequest respondWithData:nsData.get()];
+ remainingLength -= length;
+ } while (remainingLength);
+
+ if ([dataRequest currentOffset] + [dataRequest requestedLength] >= [dataRequest requestedOffset]) {
+ [m_avRequest.get() finishLoading];
+ stopLoading();
+ }
+}
+
+}
+
+#endif // ENABLE(VIDEO) && USE(AVFOUNDATION)
Modified: trunk/Source/WebCore/platform/network/mac/UTIUtilities.h (134801 => 134802)
--- trunk/Source/WebCore/platform/network/mac/UTIUtilities.h 2012-11-15 19:06:03 UTC (rev 134801)
+++ trunk/Source/WebCore/platform/network/mac/UTIUtilities.h 2012-11-15 19:08:54 UTC (rev 134802)
@@ -30,6 +30,7 @@
namespace WebCore {
RetainPtr<CFStringRef> mimeTypeFromUTITree(CFStringRef uti);
+RetainPtr<CFStringRef> UTIFromMIMEType(CFStringRef mime);
}
#endif // UTIUtilities_h
Modified: trunk/Source/WebCore/platform/network/mac/UTIUtilities.mm (134801 => 134802)
--- trunk/Source/WebCore/platform/network/mac/UTIUtilities.mm 2012-11-15 19:06:03 UTC (rev 134801)
+++ trunk/Source/WebCore/platform/network/mac/UTIUtilities.mm 2012-11-15 19:08:54 UTC (rev 134802)
@@ -79,4 +79,10 @@
return nil;
}
+RetainPtr<CFStringRef> UTIFromMIMEType(CFStringRef mime)
+{
+ RetainPtr<CFStringRef> uti = adoptCF(UTTypeCreatePreferredIdentifierForTag(kUTTagClassMIMEType, mime, 0));
+ return uti;
}
+
+}