[Mac] Update for output device API change
authoreric.carlson@apple.com <eric.carlson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 29 Mar 2015 02:07:43 +0000 (02:07 +0000)
committereric.carlson@apple.com <eric.carlson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 29 Mar 2015 02:07:43 +0000 (02:07 +0000)
https://bugs.webkit.org/show_bug.cgi?id=143187

Reviewed by Zalan Bujtas.

The API used for output device is being deprecated, update to the replacement.

* WebCore.xcodeproj/project.pbxproj: Add SPI headers.

* platform/graphics/MediaPlaybackTarget.h:
(WebCore::MediaPlaybackTarget::MediaPlaybackTarget): Update for API change.
(WebCore::MediaPlaybackTarget::setDevicePickerContext):
(WebCore::MediaPlaybackTarget::devicePickerContext):

* platform/graphics/avfoundation/MediaPlaybackTargetMac.mm:
(WebCore::MediaPlaybackTarget::encode):
(WebCore::MediaPlaybackTarget::decode):

* platform/graphics/avfoundation/objc/MediaPlaybackTargetPickerMac.h:
* platform/graphics/avfoundation/objc/MediaPlaybackTargetPickerMac.mm:
(WebCore::MediaPlaybackTargetPickerMac::MediaPlaybackTargetPickerMac):
(WebCore::MediaPlaybackTargetPickerMac::~MediaPlaybackTargetPickerMac):
(WebCore::MediaPlaybackTargetPickerMac::outputeDeviceAvailabilityChangedTimerFired):
(WebCore::MediaPlaybackTargetPickerMac::devicePicker):
(WebCore::MediaPlaybackTargetPickerMac::currentDeviceDidChange):
(WebCore::MediaPlaybackTargetPickerMac::stopMonitoringPlaybackTargets):
(-[WebAVOutputDeviceMenuControllerHelper observeValueForKeyPath:ofObject:change:context:]):
(-[WebAVOutputDevicePickerMenuControllerHelper observeValueForKeyPath:ofObject:change:context:]): Deleted.

* platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h:
* platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
(WebCore::MediaPlayerPrivateAVFoundationObjC::cancelLoad):
(WebCore::MediaPlayerPrivateAVFoundationObjC::createAVPlayer):
(WebCore::MediaPlayerPrivateAVFoundationObjC::setWirelessPlaybackTarget):
(-[WebCoreAVFMovieObserver observeValueForKeyPath:ofObject:change:context:]):

* platform/spi/cocoa/AVKitSPI.h: Copied from Source/WebCore/platform/spi/ios/AVKitSPI.h. Moved
    from ios directory, added Mac includes and prototypes.
* platform/spi/ios/AVKitSPI.h: Removed.

* platform/spi/mac/AVFoundationSPI.h: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@182117 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/platform/graphics/MediaPlaybackTarget.h
Source/WebCore/platform/graphics/avfoundation/MediaPlaybackTargetMac.mm
Source/WebCore/platform/graphics/avfoundation/objc/MediaPlaybackTargetPickerMac.h
Source/WebCore/platform/graphics/avfoundation/objc/MediaPlaybackTargetPickerMac.mm
Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h
Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm
Source/WebCore/platform/spi/cocoa/AVKitSPI.h [moved from Source/WebCore/platform/spi/ios/AVKitSPI.h with 84% similarity]
Source/WebCore/platform/spi/mac/AVFoundationSPI.h [new file with mode: 0644]

index 6e5d2e1..14aa4f8 100644 (file)
@@ -1,3 +1,47 @@
+2015-03-28  Eric Carlson  <eric.carlson@apple.com>
+
+        [Mac] Update for output device API change
+        https://bugs.webkit.org/show_bug.cgi?id=143187
+
+        Reviewed by Zalan Bujtas.
+
+        The API used for output device is being deprecated, update to the replacement.
+
+        * WebCore.xcodeproj/project.pbxproj: Add SPI headers.
+
+        * platform/graphics/MediaPlaybackTarget.h:
+        (WebCore::MediaPlaybackTarget::MediaPlaybackTarget): Update for API change.
+        (WebCore::MediaPlaybackTarget::setDevicePickerContext):
+        (WebCore::MediaPlaybackTarget::devicePickerContext):
+
+        * platform/graphics/avfoundation/MediaPlaybackTargetMac.mm:
+        (WebCore::MediaPlaybackTarget::encode):
+        (WebCore::MediaPlaybackTarget::decode):
+
+        * platform/graphics/avfoundation/objc/MediaPlaybackTargetPickerMac.h:
+        * platform/graphics/avfoundation/objc/MediaPlaybackTargetPickerMac.mm:
+        (WebCore::MediaPlaybackTargetPickerMac::MediaPlaybackTargetPickerMac):
+        (WebCore::MediaPlaybackTargetPickerMac::~MediaPlaybackTargetPickerMac):
+        (WebCore::MediaPlaybackTargetPickerMac::outputeDeviceAvailabilityChangedTimerFired):
+        (WebCore::MediaPlaybackTargetPickerMac::devicePicker):
+        (WebCore::MediaPlaybackTargetPickerMac::currentDeviceDidChange):
+        (WebCore::MediaPlaybackTargetPickerMac::stopMonitoringPlaybackTargets):
+        (-[WebAVOutputDeviceMenuControllerHelper observeValueForKeyPath:ofObject:change:context:]):
+        (-[WebAVOutputDevicePickerMenuControllerHelper observeValueForKeyPath:ofObject:change:context:]): Deleted.
+
+        * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h:
+        * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
+        (WebCore::MediaPlayerPrivateAVFoundationObjC::cancelLoad):
+        (WebCore::MediaPlayerPrivateAVFoundationObjC::createAVPlayer):
+        (WebCore::MediaPlayerPrivateAVFoundationObjC::setWirelessPlaybackTarget):
+        (-[WebCoreAVFMovieObserver observeValueForKeyPath:ofObject:change:context:]):
+
+        * platform/spi/cocoa/AVKitSPI.h: Copied from Source/WebCore/platform/spi/ios/AVKitSPI.h. Moved
+            from ios directory, added Mac includes and prototypes.
+        * platform/spi/ios/AVKitSPI.h: Removed.
+
+        * platform/spi/mac/AVFoundationSPI.h: Added.
+
 2015-03-28  Simon Fraser  <simon.fraser@apple.com>
 
         Optimize RenderLayer::intersectsDamageRect() slightly
index 0bce1a4..288dbeb 100644 (file)
                07E9E12E18F5E2760011A3A4 /* InbandMetadataTextTrackPrivateAVF.h in Headers */ = {isa = PBXBuildFile; fileRef = 07E9E12D18F5E2760011A3A4 /* InbandMetadataTextTrackPrivateAVF.h */; };
                07E9E13018F62B370011A3A4 /* InbandMetadataTextTrackPrivateAVF.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 07E9E12F18F62B370011A3A4 /* InbandMetadataTextTrackPrivateAVF.cpp */; };
                07EDC3EE1AACB75D00983EB5 /* MediaSessionManagerMac.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 07EDC3ED1AACB75D00983EB5 /* MediaSessionManagerMac.cpp */; };
+               07F0B97A1AC5DB3300E535D9 /* AVKitSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = 07F0B9791AC5DB3300E535D9 /* AVKitSPI.h */; };
+               07F0B97C1AC5DB4600E535D9 /* AVFoundationSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = 07F0B97B1AC5DB4600E535D9 /* AVFoundationSPI.h */; };
                07F944161864D046005D31CB /* MediaSessionManager.h in Headers */ = {isa = PBXBuildFile; fileRef = CDAE8C081746B95700532D78 /* MediaSessionManager.h */; settings = {ATTRIBUTES = (Private, ); }; };
                07FBDE2C18FED178001A7CFF /* JSDataCueCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 07FBDE2B18FED178001A7CFF /* JSDataCueCustom.cpp */; };
                07FE99DC18807A7D00256648 /* HTMLMediaSession.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 07FE99DA18807A7D00256648 /* HTMLMediaSession.cpp */; };
                CE1252391A166FA000864480 /* QuickLookSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = CE1252381A166FA000864480 /* QuickLookSPI.h */; };
                CE12523B1A16711000864480 /* NSFileManagerSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = CE12523A1A16711000864480 /* NSFileManagerSPI.h */; settings = {ATTRIBUTES = (Private, ); }; };
                CE12523D1A1676CD00864480 /* QuartzCoreSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = CE12523C1A1676CD00864480 /* QuartzCoreSPI.h */; settings = {ATTRIBUTES = (Private, ); }; };
-               CE12523F1A16AE1200864480 /* AVKitSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = CE12523E1A16AE1200864480 /* AVKitSPI.h */; };
                CE1252411A16B1B600864480 /* MediaPlayerSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = CE1252401A16B1B600864480 /* MediaPlayerSPI.h */; settings = {ATTRIBUTES = (Private, ); }; };
                CE1252431A16C01A00864480 /* CoreUISPI.h in Headers */ = {isa = PBXBuildFile; fileRef = CE1252421A16C01A00864480 /* CoreUISPI.h */; };
                CE1252451A16C22500864480 /* DynamicLinkerSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = CE1252441A16C22500864480 /* DynamicLinkerSPI.h */; };
                07E9E12D18F5E2760011A3A4 /* InbandMetadataTextTrackPrivateAVF.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InbandMetadataTextTrackPrivateAVF.h; sourceTree = "<group>"; };
                07E9E12F18F62B370011A3A4 /* InbandMetadataTextTrackPrivateAVF.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InbandMetadataTextTrackPrivateAVF.cpp; sourceTree = "<group>"; };
                07EDC3ED1AACB75D00983EB5 /* MediaSessionManagerMac.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MediaSessionManagerMac.cpp; sourceTree = "<group>"; };
+               07F0B9791AC5DB3300E535D9 /* AVKitSPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AVKitSPI.h; sourceTree = "<group>"; };
+               07F0B97B1AC5DB4600E535D9 /* AVFoundationSPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AVFoundationSPI.h; sourceTree = "<group>"; };
                07FBDE2B18FED178001A7CFF /* JSDataCueCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSDataCueCustom.cpp; sourceTree = "<group>"; };
                07FE99DA18807A7D00256648 /* HTMLMediaSession.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HTMLMediaSession.cpp; sourceTree = "<group>"; };
                07FE99DB18807A7D00256648 /* HTMLMediaSession.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HTMLMediaSession.h; sourceTree = "<group>"; };
                CE1252381A166FA000864480 /* QuickLookSPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = QuickLookSPI.h; path = ios/QuickLookSPI.h; sourceTree = "<group>"; };
                CE12523A1A16711000864480 /* NSFileManagerSPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NSFileManagerSPI.h; sourceTree = "<group>"; };
                CE12523C1A1676CD00864480 /* QuartzCoreSPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = QuartzCoreSPI.h; sourceTree = "<group>"; };
-               CE12523E1A16AE1200864480 /* AVKitSPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AVKitSPI.h; path = ios/AVKitSPI.h; sourceTree = "<group>"; };
                CE1252401A16B1B600864480 /* MediaPlayerSPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MediaPlayerSPI.h; path = ios/MediaPlayerSPI.h; sourceTree = "<group>"; };
                CE1252421A16C01A00864480 /* CoreUISPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CoreUISPI.h; path = ios/CoreUISPI.h; sourceTree = "<group>"; };
                CE1252441A16C22500864480 /* DynamicLinkerSPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DynamicLinkerSPI.h; sourceTree = "<group>"; };
                653EF83719A043AE0052202C /* cocoa */ = {
                        isa = PBXGroup;
                        children = (
+                               07F0B9791AC5DB3300E535D9 /* AVKitSPI.h */,
                                CD4097FF1A8C855F004C65E9 /* CFNSURLConnectionSPI.h */,
                                1C5E980F1A02CEFA002DB55F /* CoreTextSPI.h */,
                                CE12524A1A16C79B00864480 /* DispatchSPI.h */,
                9348428019F1A9190009D5AE /* mac */ = {
                        isa = PBXGroup;
                        children = (
+                               07F0B97B1AC5DB4600E535D9 /* AVFoundationSPI.h */,
                                2D59F1BE1A0044C6001F3D29 /* DataDetectorsSPI.h */,
                                2D413F601A187A3F0041A521 /* LookupSPI.h */,
                                1C6466271A12C3F90094603C /* NSFontSPI.h */,
                A172182419DE182B00464D17 /* ios */ = {
                        isa = PBXGroup;
                        children = (
-                               CE12523E1A16AE1200864480 /* AVKitSPI.h */,
                                CE1252421A16C01A00864480 /* CoreUISPI.h */,
                                CEC337AE1A46086D009B8523 /* GraphicsServicesSPI.h */,
                                CE1252481A16C3BC00864480 /* MobileGestaltSPI.h */,
                                A8CFF04E0A154F09000A4234 /* AutoTableLayout.h in Headers */,
                                070363E0181A1CDC00C074A5 /* AVAudioCaptureSource.h in Headers */,
                                070363E2181A1CDC00C074A5 /* AVCaptureDeviceManager.h in Headers */,
-                               CE12523F1A16AE1200864480 /* AVKitSPI.h in Headers */,
                                070363E4181A1CDC00C074A5 /* AVMediaCaptureSource.h in Headers */,
                                CD336F6217F9F64700DDDCD0 /* AVTrackPrivateAVFObjCImpl.h in Headers */,
                                070363E6181A1CDC00C074A5 /* AVVideoCaptureSource.h in Headers */,
                                6FA4454E898F2FC168BC38C1 /* JSBeforeUnloadEvent.h in Headers */,
                                FDF09DC91399B62200688E5B /* JSBiquadFilterNode.h in Headers */,
                                2E2D99CE10E2BBDA00496337 /* JSBlob.h in Headers */,
+                               07F0B97C1AC5DB4600E535D9 /* AVFoundationSPI.h in Headers */,
                                1449E24C107D4A8400B5793F /* JSCallbackData.h in Headers */,
                                1A37636C1A2E68BB009A7EE2 /* StorageNamespaceProvider.h in Headers */,
                                65DF323A09D1DE65000BE325 /* JSCanvasGradient.h in Headers */,
                                07C59B7217F79C7C000FBCBB /* JSMediaSourceStates.h in Headers */,
                                07277E4D17D018CC0015534D /* JSMediaStream.h in Headers */,
                                07277E4F17D018CC0015534D /* JSMediaStreamAudioDestinationNode.h in Headers */,
+                               07F0B97A1AC5DB3300E535D9 /* AVKitSPI.h in Headers */,
                                FDBD480D159BC6870093EB4F /* JSMediaStreamAudioSourceNode.h in Headers */,
                                0705851317FA7107005F2BCB /* JSMediaStreamCapabilities.h in Headers */,
                                07277E5117D018CC0015534D /* JSMediaStreamEvent.h in Headers */,
index 85d5952..7b7b64f 100644 (file)
@@ -33,7 +33,7 @@
 #if PLATFORM(COCOA)
 OBJC_CLASS NSKeyedArchiver;
 OBJC_CLASS NSKeyedUnarchiver;
-OBJC_CLASS AVOutputDevicePickerContext;
+OBJC_CLASS AVOutputContext;
 #endif
 
 namespace WebCore {
@@ -43,18 +43,18 @@ public:
     virtual ~MediaPlaybackTarget() { }
 
 #if PLATFORM(COCOA)
-    WEBCORE_EXPORT MediaPlaybackTarget(AVOutputDevicePickerContext *context = nil) { m_devicePickerContext = context; }
+    WEBCORE_EXPORT MediaPlaybackTarget(AVOutputContext *context = nil) { m_devicePickerContext = context; }
 
     WEBCORE_EXPORT void encode(NSKeyedArchiver *) const;
     WEBCORE_EXPORT static bool decode(NSKeyedUnarchiver *, MediaPlaybackTarget&);
 
-    void setDevicePickerContext(AVOutputDevicePickerContext *context) { m_devicePickerContext = context; }
-    AVOutputDevicePickerContext *devicePickerContext() const { return m_devicePickerContext.get(); }
+    void setDevicePickerContext(AVOutputContext *context) { m_devicePickerContext = context; }
+    AVOutputContext *devicePickerContext() const { return m_devicePickerContext.get(); }
 #endif
 
 protected:
 #if PLATFORM(COCOA)
-    RetainPtr<AVOutputDevicePickerContext> m_devicePickerContext;
+    RetainPtr<AVOutputContext> m_devicePickerContext;
 #endif
 };
 
index 4450475..7d7f10f 100644 (file)
 
 #if ENABLE(WIRELESS_PLAYBACK_TARGET) && !PLATFORM(IOS)
 
-#import <AVFoundation/AVOutputDevicePickerContext.h>
 #import <WebCore/MediaPlaybackTarget.h>
 #import <WebCore/SoftLinking.h>
 #import <objc/runtime.h>
 
-typedef AVOutputDevicePickerContext AVOutputDevicePickerContextType;
-
 SOFT_LINK_FRAMEWORK_OPTIONAL(AVFoundation)
-SOFT_LINK_CLASS(AVFoundation, AVOutputDevicePickerContext)
+SOFT_LINK_CLASS(AVFoundation, AVOutputContext)
 
 namespace WebCore {
 
@@ -44,26 +41,26 @@ static NSString * const deviceContextKey = @"deviceContext";
 
 void MediaPlaybackTarget::encode(NSKeyedArchiver *archiver) const
 {
-    if ([getAVOutputDevicePickerContextClass() conformsToProtocol:@protocol(NSSecureCoding)])
+    if ([getAVOutputContextClass() conformsToProtocol:@protocol(NSSecureCoding)])
         [archiver encodeObject:m_devicePickerContext.get() forKey:deviceContextKey];
 }
 
 bool MediaPlaybackTarget::decode(NSKeyedUnarchiver *unarchiver, MediaPlaybackTarget& playbackTarget)
 {
-    if (![getAVOutputDevicePickerContextClass() conformsToProtocol:@protocol(NSSecureCoding)])
+    if (![getAVOutputContextClass() conformsToProtocol:@protocol(NSSecureCoding)])
         return false;
 
-    AVOutputDevicePickerContext *context = nil;
-
+    AVOutputContext *context = nil;
     @try {
-        context = [unarchiver decodeObjectOfClass:getAVOutputDevicePickerContextClass() forKey:deviceContextKey];
+        context = [unarchiver decodeObjectOfClass:getAVOutputContextClass() forKey:deviceContextKey];
     } @catch (NSException *exception) {
-        LOG_ERROR("The target picker being decoded is not a AVOutputDevicePickerContext.");
+        LOG_ERROR("The target picker being decoded is not a AVOutputContext.");
+        return false;
     }
 
     playbackTarget.m_devicePickerContext = context;
 
-    return context;
+    return true;
 }
 
 } // namespace WebCore
index 873dc02..bb9934a 100644 (file)
@@ -32,8 +32,8 @@
 #include <wtf/RetainPtr.h>
 #include <wtf/RunLoop.h>
 
-OBJC_CLASS AVOutputDevicePickerMenuController;
-OBJC_CLASS WebAVOutputDevicePickerMenuControllerHelper;
+OBJC_CLASS AVOutputDeviceMenuController;
+OBJC_CLASS WebAVOutputDeviceMenuControllerHelper;
 
 namespace WebCore {
 
@@ -54,11 +54,11 @@ public:
 private:
     explicit MediaPlaybackTargetPickerMac(MediaPlaybackTargetPicker::Client&);
 
-    AVOutputDevicePickerMenuController *devicePicker();
+    AVOutputDeviceMenuController *devicePicker();
     void outputeDeviceAvailabilityChangedTimerFired();
 
-    RetainPtr<AVOutputDevicePickerMenuController> m_devicePickerMenuController;
-    RetainPtr<WebAVOutputDevicePickerMenuControllerHelper> m_devicePickerMenuControllerDelegate;
+    RetainPtr<AVOutputDeviceMenuController> m_outputDeviceMenuController;
+    RetainPtr<WebAVOutputDeviceMenuControllerHelper> m_outputDeviceMenuControllerDelegate;
     RunLoop::Timer<MediaPlaybackTargetPickerMac> m_deviceChangeTimer;
 };
 
index 21b2536..1e1308c 100644 (file)
 
 #if ENABLE(WIRELESS_PLAYBACK_TARGET) && !PLATFORM(IOS)
 
+#import <WebCore/AVFoundationSPI.h>
+#import <WebCore/AVKitSPI.h>
 #import <WebCore/FloatRect.h>
 #import <WebCore/MediaPlaybackTarget.h>
 #import <WebCore/SoftLinking.h>
 #import <objc/runtime.h>
 #import <wtf/MainThread.h>
 
-@class AVOutputDevicePickerContext;
-@interface AVOutputDevicePickerMenuController : NSObject
-@property (readonly) AVOutputDevicePickerContext * outputDevicePickerContext;
-@property (readonly, getter = isExternalOutputDeviceAvailable) BOOL externalOutputDeviceAvailable;
-- (instancetype)initWithOutputDevicePickerContext:(AVOutputDevicePickerContext *)outputDevicePickerContext NS_DESIGNATED_INITIALIZER;
-- (void)showMenuForRect:(NSRect)screenRect appearanceName:(NSString *)appearanceName;
-@end
-
-typedef AVOutputDevicePickerContext AVOutputDevicePickerContextType;
-typedef AVOutputDevicePickerMenuController AVOutputDevicePickerMenuControllerType;
+typedef AVOutputContext AVOutputContextType;
+typedef AVOutputDeviceMenuController AVOutputDeviceMenuControllerType;
 
 SOFT_LINK_FRAMEWORK_OPTIONAL(AVFoundation)
 SOFT_LINK_FRAMEWORK_OPTIONAL(AVKit)
 
-SOFT_LINK_CLASS(AVFoundation, AVOutputDevicePickerContext)
-SOFT_LINK_CLASS(AVKit, AVOutputDevicePickerMenuController)
-SOFT_LINK_CLASS(AVKit, AVOutputDevicePickerDelegate)
+SOFT_LINK_CLASS(AVFoundation, AVOutputContext)
+SOFT_LINK_CLASS(AVKit, AVOutputDeviceMenuController)
 
 using namespace WebCore;
 
 static NSString *externalOutputDeviceAvailableKeyName = @"externalOutputDeviceAvailable";
 static NSString *externalOutputDevicePickedKeyName = @"externalOutputDevicePicked";
 
-@interface WebAVOutputDevicePickerMenuControllerHelper : NSObject {
+@interface WebAVOutputDeviceMenuControllerHelper : NSObject {
     MediaPlaybackTargetPickerMac* m_callback;
 }
 
@@ -75,7 +68,7 @@ std::unique_ptr<MediaPlaybackTargetPickerMac> MediaPlaybackTargetPickerMac::crea
 
 MediaPlaybackTargetPickerMac::MediaPlaybackTargetPickerMac(MediaPlaybackTargetPicker::Client& client)
     : MediaPlaybackTargetPicker(client)
-    , m_devicePickerMenuControllerDelegate(adoptNS([[WebAVOutputDevicePickerMenuControllerHelper alloc] initWithCallback:this]))
+    , m_outputDeviceMenuControllerDelegate(adoptNS([[WebAVOutputDeviceMenuControllerHelper alloc] initWithCallback:this]))
     , m_deviceChangeTimer(RunLoop::main(), this, &MediaPlaybackTargetPickerMac::outputeDeviceAvailabilityChangedTimerFired)
 {
 }
@@ -83,18 +76,13 @@ MediaPlaybackTargetPickerMac::MediaPlaybackTargetPickerMac(MediaPlaybackTargetPi
 MediaPlaybackTargetPickerMac::~MediaPlaybackTargetPickerMac()
 {
     m_deviceChangeTimer.stop();
-    [m_devicePickerMenuControllerDelegate clearCallback];
-
-    if (m_devicePickerMenuController) {
-        [m_devicePickerMenuController removeObserver:m_devicePickerMenuControllerDelegate.get() forKeyPath:externalOutputDeviceAvailableKeyName];
-        [m_devicePickerMenuController removeObserver:m_devicePickerMenuControllerDelegate.get() forKeyPath:externalOutputDevicePickedKeyName];
-        m_devicePickerMenuController = nil;
-    }
+    [m_outputDeviceMenuControllerDelegate clearCallback];
+    stopMonitoringPlaybackTargets();
 }
 
 void MediaPlaybackTargetPickerMac::outputeDeviceAvailabilityChangedTimerFired()
 {
-    if (!m_devicePickerMenuController || !m_client)
+    if (!m_outputDeviceMenuController || !m_client)
         return;
 
     m_client->externalOutputDeviceAvailableDidChange(devicePicker().externalOutputDeviceAvailable);
@@ -109,20 +97,23 @@ void MediaPlaybackTargetPickerMac::availableDevicesDidChange()
     m_deviceChangeTimer.startOneShot(0);
 }
 
-AVOutputDevicePickerMenuControllerType *MediaPlaybackTargetPickerMac::devicePicker()
+AVOutputDeviceMenuControllerType *MediaPlaybackTargetPickerMac::devicePicker()
 {
-    if (!m_devicePickerMenuController) {
-        RetainPtr<AVOutputDevicePickerContextType> context = adoptNS([[getAVOutputDevicePickerContextClass() alloc] init]);
-        m_devicePickerMenuController = adoptNS([[getAVOutputDevicePickerMenuControllerClass() alloc] initWithOutputDevicePickerContext:context.get()]);
+    if (!getAVOutputDeviceMenuControllerClass())
+        return nullptr;
 
-        [m_devicePickerMenuController addObserver:m_devicePickerMenuControllerDelegate.get() forKeyPath:externalOutputDeviceAvailableKeyName options:NSKeyValueObservingOptionNew context:nil];
-        [m_devicePickerMenuController addObserver:m_devicePickerMenuControllerDelegate.get() forKeyPath:externalOutputDevicePickedKeyName options:NSKeyValueObservingOptionNew context:nil];
+    if (!m_outputDeviceMenuController) {
+        RetainPtr<AVOutputContextType> context = adoptNS([[getAVOutputContextClass() alloc] init]);
+        m_outputDeviceMenuController = adoptNS([[getAVOutputDeviceMenuControllerClass() alloc] initWithOutputContext:context.get()]);
 
-        if (m_devicePickerMenuController.get().externalOutputDeviceAvailable)
+        [m_outputDeviceMenuController.get() addObserver:m_outputDeviceMenuControllerDelegate.get() forKeyPath:externalOutputDeviceAvailableKeyName options:NSKeyValueObservingOptionNew context:nullptr];
+        [m_outputDeviceMenuController.get() addObserver:m_outputDeviceMenuControllerDelegate.get() forKeyPath:externalOutputDevicePickedKeyName options:NSKeyValueObservingOptionNew context:nullptr];
+
+        if (m_outputDeviceMenuController.get().externalOutputDeviceAvailable)
             availableDevicesDidChange();
     }
 
-    return m_devicePickerMenuController.get();
+    return m_outputDeviceMenuController.get();
 }
 
 void MediaPlaybackTargetPickerMac::showPlaybackTargetPicker(const FloatRect& location, bool)
@@ -138,7 +129,14 @@ void MediaPlaybackTargetPickerMac::currentDeviceDidChange()
     if (!m_client)
         return;
 
-    m_client->didChoosePlaybackTarget(MediaPlaybackTarget([devicePicker() outputDevicePickerContext]));
+    AVOutputDeviceMenuControllerType* devicePicker = this->devicePicker();
+    if (!devicePicker)
+        return;
+
+    if (devicePicker.isExternalOutputDevicePicked)
+        m_client->didChoosePlaybackTarget(WebCore::MediaPlaybackTarget([devicePicker outputContext]));
+    else
+        m_client->didChoosePlaybackTarget(WebCore::MediaPlaybackTarget(nil));
 }
 
 void MediaPlaybackTargetPickerMac::startingMonitoringPlaybackTargets()
@@ -148,11 +146,16 @@ void MediaPlaybackTargetPickerMac::startingMonitoringPlaybackTargets()
 
 void MediaPlaybackTargetPickerMac::stopMonitoringPlaybackTargets()
 {
+    if (m_outputDeviceMenuController) {
+        [m_outputDeviceMenuController removeObserver:m_outputDeviceMenuControllerDelegate.get() forKeyPath:externalOutputDeviceAvailableKeyName];
+        [m_outputDeviceMenuController removeObserver:m_outputDeviceMenuControllerDelegate.get() forKeyPath:externalOutputDevicePickedKeyName];
+        m_outputDeviceMenuController = nullptr;
+    }
 }
 
 } // namespace WebCore
 
-@implementation WebAVOutputDevicePickerMenuControllerHelper
+@implementation WebAVOutputDeviceMenuControllerHelper
 - (instancetype)initWithCallback:(MediaPlaybackTargetPickerMac*)callback
 {
     if (!(self = [super init]))
@@ -180,7 +183,7 @@ void MediaPlaybackTargetPickerMac::stopMonitoringPlaybackTargets()
     if (![keyPath isEqualToString:externalOutputDeviceAvailableKeyName] && ![keyPath isEqualToString:externalOutputDevicePickedKeyName])
         return;
 
-    RetainPtr<WebAVOutputDevicePickerMenuControllerHelper> strongSelf = self;
+    RetainPtr<WebAVOutputDeviceMenuControllerHelper> strongSelf = self;
     RetainPtr<NSString> strongKeyPath = keyPath;
     callOnMainThread([strongSelf, strongKeyPath] {
         MediaPlaybackTargetPickerMac* callback = strongSelf->m_callback;
index ee661b8..bb2e656 100644 (file)
@@ -34,7 +34,7 @@
 OBJC_CLASS AVAssetImageGenerator;
 OBJC_CLASS AVAssetResourceLoadingRequest;
 OBJC_CLASS AVMediaSelectionGroup;
-OBJC_CLASS AVOutputDevicePickerContext;
+OBJC_CLASS AVOutputContext;
 OBJC_CLASS AVPlayer;
 OBJC_CLASS AVPlayerItem;
 OBJC_CLASS AVPlayerItemLegibleOutput;
@@ -351,7 +351,7 @@ private:
 #endif
 
 #if PLATFORM(MAC) && ENABLE(WIRELESS_PLAYBACK_TARGET)
-    RetainPtr<AVOutputDevicePickerContext> m_outputDevicePickerContext;
+    RetainPtr<AVOutputContext> m_outputContext;
 #endif
 
     mutable RetainPtr<NSArray> m_cachedSeekableRanges;
index d7f7717..207efb3 100644 (file)
@@ -28,6 +28,7 @@
 #if ENABLE(VIDEO) && USE(AVFOUNDATION)
 #import "MediaPlayerPrivateAVFoundationObjC.h"
 
+#import "AVFoundationSPI.h"
 #import "AVTrackPrivateAVFObjCImpl.h"
 #import "AudioSourceProviderAVFObjC.h"
 #import "AudioTrackPrivateAVFObjC.h"
@@ -136,14 +137,6 @@ template <> struct iterator_traits<HashSet<RefPtr<WebCore::MediaSelectionOptionA
 @property (nonatomic, readonly) NSURL *resolvedURL;
 @end
 
-#if PLATFORM(MAC) && ENABLE(WIRELESS_PLAYBACK_TARGET)
-typedef AVOutputDevicePickerContext AVOutputDevicePickerContextType;
-
-@interface AVPlayer (WebKitExtensions)
-@property (nonatomic) AVOutputDevicePickerContext *outputDevicePickerContext;
-@end
-#endif
-
 typedef AVPlayer AVPlayerType;
 typedef AVPlayerItem AVPlayerItemType;
 typedef AVPlayerItemLegibleOutput AVPlayerItemLegibleOutputType;
@@ -555,7 +548,7 @@ void MediaPlayerPrivateAVFoundationObjC::cancelLoad()
         [m_avPlayer.get() removeObserver:m_objcObserver.get() forKeyPath:@"rate"];
 #if ENABLE(WIRELESS_PLAYBACK_TARGET)
         [m_avPlayer.get() removeObserver:m_objcObserver.get() forKeyPath:@"externalPlaybackActive"];
-        [m_avPlayer.get() removeObserver:m_objcObserver.get() forKeyPath:@"outputDevicePickerContext"];
+        [m_avPlayer.get() removeObserver:m_objcObserver.get() forKeyPath:@"outputContext"];
 #endif
         m_avPlayer = nil;
     }
@@ -937,7 +930,7 @@ void MediaPlayerPrivateAVFoundationObjC::createAVPlayer()
     [m_avPlayer.get() addObserver:m_objcObserver.get() forKeyPath:@"rate" options:NSKeyValueObservingOptionNew context:(void *)MediaPlayerAVFoundationObservationContextPlayer];
 #if ENABLE(WIRELESS_PLAYBACK_TARGET)
     [m_avPlayer.get() addObserver:m_objcObserver.get() forKeyPath:@"externalPlaybackActive" options:NSKeyValueObservingOptionNew context:(void *)MediaPlayerAVFoundationObservationContextPlayer];
-    [m_avPlayer.get() addObserver:m_objcObserver.get() forKeyPath:@"outputDevicePickerContext" options:NSKeyValueObservingOptionNew context:(void *)MediaPlayerAVFoundationObservationContextPlayer];
+    [m_avPlayer.get() addObserver:m_objcObserver.get() forKeyPath:@"outputContext" options:NSKeyValueObservingOptionNew context:(void *)MediaPlayerAVFoundationObservationContextPlayer];
 #endif
 
 #if ENABLE(WIRELESS_PLAYBACK_TARGET)
@@ -953,8 +946,8 @@ void MediaPlayerPrivateAVFoundationObjC::createAVPlayer()
 #endif
 
 #if ENABLE(WIRELESS_PLAYBACK_TARGET) && !PLATFORM(IOS)
-    if (m_outputDevicePickerContext)
-        m_avPlayer.get().outputDevicePickerContext = m_outputDevicePickerContext.get();
+    if (m_outputContext)
+        m_avPlayer.get().outputContext = m_outputContext.get();
 #endif
 
     if (player()->client().mediaPlayerIsVideo())
@@ -2769,14 +2762,14 @@ void MediaPlayerPrivateAVFoundationObjC::setWirelessVideoPlaybackDisabled(bool d
 #if !PLATFORM(IOS)
 void MediaPlayerPrivateAVFoundationObjC::setWirelessPlaybackTarget(const MediaPlaybackTarget& target)
 {
-    m_outputDevicePickerContext = target.devicePickerContext();
+    m_outputContext = target.devicePickerContext();
 
-    LOG(Media, "MediaPlayerPrivateAVFoundationObjC::setWirelessPlaybackTarget(%p) - target = %p", this, m_outputDevicePickerContext.get());
+    LOG(Media, "MediaPlayerPrivateAVFoundationObjC::setWirelessPlaybackTarget(%p) - target = %p", this, m_outputContext.get());
 
     if (!m_avPlayer)
         return;
 
-    m_avPlayer.get().outputDevicePickerContext = m_outputDevicePickerContext.get();
+    m_avPlayer.get().outputContext = m_outputContext.get();
 }
 #endif
 
@@ -3209,7 +3202,7 @@ NSArray* assetTrackMetadataKeyNames()
 #if ENABLE(WIRELESS_PLAYBACK_TARGET)
         else if ([keyPath isEqualToString:@"externalPlaybackActive"])
             function = WTF::bind(&MediaPlayerPrivateAVFoundationObjC::playbackTargetIsWirelessDidChange, m_callback);
-        else if ([keyPath isEqualToString:@"outputDevicePickerContext"])
+        else if ([keyPath isEqualToString:@"outputContext"])
             function = WTF::bind(&MediaPlayerPrivateAVFoundationObjC::playbackTargetIsWirelessDidChange, m_callback);
 #endif
     }
similarity index 84%
rename from Source/WebCore/platform/spi/ios/AVKitSPI.h
rename to Source/WebCore/platform/spi/cocoa/AVKitSPI.h
index 6f447d2..43e1c19 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2014 Apple Inc. All rights reserved.
+ * Copyright (C) 2014, 2015 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+#import "SoftLinking.h"
+#import <objc/runtime.h>
+
+#if PLATFORM(IOS)
 #import <AVKit/AVKit.h>
 #import <QuartzCore/QuartzCore.h>
 #import <UIKit/UIKit.h>
@@ -93,7 +97,7 @@ typedef NSInteger AVPlayerViewControllerOptimizedFullscreenStopReason;
 @property (nonatomic, weak) id <AVPlayerViewControllerDelegate> delegate;
 @end
 
-#endif
+#endif // USE(APPLE_INTERNAL_SDK)
 
 #if USE(APPLE_INTERNAL_SDK) && __IPHONE_OS_VERSION_MIN_REQUIRED < 90000
 
@@ -110,3 +114,33 @@ typedef NSInteger AVPlayerViewControllerOptimizedFullscreenStopReason;
 @end
 
 #endif
+
+#endif // PLATFORM(IOS)
+
+#if ENABLE(WIRELESS_PLAYBACK_TARGET) && !PLATFORM(IOS)
+
+#if USE(APPLE_INTERNAL_SDK)
+
+#import <AVKit/AVOutputDeviceMenuController.h>
+
+#else
+
+@class AVOutputContext;
+
+NS_CLASS_AVAILABLE_MAC(10_11)
+@interface AVOutputDeviceMenuController : NSObject
+
+- (instancetype)initWithOutputContext:(AVOutputContext *)outputContext NS_DESIGNATED_INITIALIZER;
+
+@property (readonly) AVOutputContext *outputContext;
+@property (readonly, getter=isExternalOutputDeviceAvailable) BOOL externalOutputDeviceAvailable;
+@property (readonly, getter=isExternalOutputDevicePicked) BOOL externalOutputDevicePicked;
+
+- (void)showMenuForRect:(NSRect)screenRect appearanceName:(NSString *)appearanceName;
+
+@end
+
+
+#endif
+
+#endif
diff --git a/Source/WebCore/platform/spi/mac/AVFoundationSPI.h b/Source/WebCore/platform/spi/mac/AVFoundationSPI.h
new file mode 100644 (file)
index 0000000..67a8993
--- /dev/null
@@ -0,0 +1,50 @@
+/*
+ * Copyright (C) 2015 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 "SoftLinking.h"
+#import <objc/runtime.h>
+
+#if ENABLE(WIRELESS_PLAYBACK_TARGET) && !PLATFORM(IOS)
+
+#if USE(APPLE_INTERNAL_SDK)
+
+#import <AVFoundation/AVOutputContext.h>
+#import <AVFoundation/AVPlayer_Private.h>
+
+#else
+
+@class AVOutputContext;
+@interface AVOutputContext : NSObject <NSSecureCoding>
+@property (nonatomic, readonly) NSString *deviceName;
++ (instancetype)outputContext;
+@end
+
+@interface AVPlayer (AVPlayerExternalPlaybackSupportPrivate)
+@property (nonatomic, retain) AVOutputContext *outputContext;
+@end
+
+#endif
+
+#endif