Introduce HAVE_MEDIA_PLAYER and HAVE_CORE_VIDEO
authortimothy_horton@apple.com <timothy_horton@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 21 Mar 2018 06:26:49 +0000 (06:26 +0000)
committertimothy_horton@apple.com <timothy_horton@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 21 Mar 2018 06:26:49 +0000 (06:26 +0000)
https://bugs.webkit.org/show_bug.cgi?id=183803
<rdar://problem/38690487>

Reviewed by Sam Weinig.

Source/WebCore:

* platform/audio/ios/MediaSessionManagerIOS.mm:
(WebCore::MediaSessionManageriOS::configureWireLessTargetMonitoring):
(WebCore::MediaSessionManageriOS::updateNowPlayingInfo):
(-[WebMediaSessionHelper initWithCallback:]):
(-[WebMediaSessionHelper dealloc]):
(-[WebMediaSessionHelper hasWirelessTargetsAvailable]):
* platform/cocoa/CoreVideoSoftLink.cpp:
* platform/cocoa/CoreVideoSoftLink.h:
* platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h:
* platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
(WebCore::MediaPlayerPrivateAVFoundationObjC::createVideoLayer):
(WebCore::MediaPlayerPrivateAVFoundationObjC::hasAvailableVideoFrame const):
(WebCore::MediaPlayerPrivateAVFoundationObjC::updateLastImage):
* platform/graphics/avfoundation/objc/MediaSampleAVFObjC.mm:
(WebCore::MediaSampleAVFObjC::getRGBAImageData const):
* platform/graphics/cv/PixelBufferConformerCV.cpp:
* platform/graphics/cv/PixelBufferConformerCV.h:
* platform/graphics/cv/TextureCacheCV.h:
* platform/graphics/cv/TextureCacheCV.mm:
* platform/graphics/cv/VideoTextureCopierCV.cpp:
* platform/graphics/cv/VideoTextureCopierCV.h:
Make it possible to disable our dependency on MediaPlayer and CoreVideo.

Source/WTF:

* wtf/Platform.h:

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

15 files changed:
Source/WTF/ChangeLog
Source/WTF/wtf/Platform.h
Source/WebCore/ChangeLog
Source/WebCore/platform/audio/ios/MediaSessionManagerIOS.mm
Source/WebCore/platform/cocoa/CoreVideoSoftLink.cpp
Source/WebCore/platform/cocoa/CoreVideoSoftLink.h
Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h
Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm
Source/WebCore/platform/graphics/avfoundation/objc/MediaSampleAVFObjC.mm
Source/WebCore/platform/graphics/cv/PixelBufferConformerCV.cpp
Source/WebCore/platform/graphics/cv/PixelBufferConformerCV.h
Source/WebCore/platform/graphics/cv/TextureCacheCV.h
Source/WebCore/platform/graphics/cv/TextureCacheCV.mm
Source/WebCore/platform/graphics/cv/VideoTextureCopierCV.cpp
Source/WebCore/platform/graphics/cv/VideoTextureCopierCV.h

index fd0a187..44fdff8 100644 (file)
@@ -1,3 +1,13 @@
+2018-03-20  Tim Horton  <timothy_horton@apple.com>
+
+        Introduce HAVE_MEDIA_PLAYER and HAVE_CORE_VIDEO
+        https://bugs.webkit.org/show_bug.cgi?id=183803
+        <rdar://problem/38690487>
+
+        Reviewed by Sam Weinig.
+
+        * wtf/Platform.h:
+
 2018-03-20  Brian Burg  <bburg@apple.com>
 
         SLEEP_THREAD_FOR_DEBUGGER should not use fancy number literals
index 735f8b3..09527f5 100644 (file)
 
 #if PLATFORM(IOS) || PLATFORM(MAC)
 #define USE_COREMEDIA 1
-#define HAVE_AVFOUNDATION_VIDEO_OUTPUT 1
 #define USE_VIDEOTOOLBOX 1
+
+#if !ENABLE(MINIMAL_SIMULATOR)
+#define HAVE_AVFOUNDATION_VIDEO_OUTPUT 1
+#define HAVE_CORE_VIDEO 1
+#define HAVE_MEDIA_PLAYER 1
+#endif
 #endif
 
 #if PLATFORM(IOS) || PLATFORM(MAC) || (OS(WINDOWS) && USE(CG))
index 820b631..20854d4 100644 (file)
@@ -1,5 +1,36 @@
 2018-03-20  Tim Horton  <timothy_horton@apple.com>
 
+        Introduce HAVE_MEDIA_PLAYER and HAVE_CORE_VIDEO
+        https://bugs.webkit.org/show_bug.cgi?id=183803
+        <rdar://problem/38690487>
+
+        Reviewed by Sam Weinig.
+
+        * platform/audio/ios/MediaSessionManagerIOS.mm:
+        (WebCore::MediaSessionManageriOS::configureWireLessTargetMonitoring):
+        (WebCore::MediaSessionManageriOS::updateNowPlayingInfo):
+        (-[WebMediaSessionHelper initWithCallback:]):
+        (-[WebMediaSessionHelper dealloc]):
+        (-[WebMediaSessionHelper hasWirelessTargetsAvailable]):
+        * platform/cocoa/CoreVideoSoftLink.cpp:
+        * platform/cocoa/CoreVideoSoftLink.h:
+        * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h:
+        * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
+        (WebCore::MediaPlayerPrivateAVFoundationObjC::createVideoLayer):
+        (WebCore::MediaPlayerPrivateAVFoundationObjC::hasAvailableVideoFrame const):
+        (WebCore::MediaPlayerPrivateAVFoundationObjC::updateLastImage):
+        * platform/graphics/avfoundation/objc/MediaSampleAVFObjC.mm:
+        (WebCore::MediaSampleAVFObjC::getRGBAImageData const):
+        * platform/graphics/cv/PixelBufferConformerCV.cpp:
+        * platform/graphics/cv/PixelBufferConformerCV.h:
+        * platform/graphics/cv/TextureCacheCV.h:
+        * platform/graphics/cv/TextureCacheCV.mm:
+        * platform/graphics/cv/VideoTextureCopierCV.cpp:
+        * platform/graphics/cv/VideoTextureCopierCV.h:
+        Make it possible to disable our dependency on MediaPlayer and CoreVideo.
+
+2018-03-20  Tim Horton  <timothy_horton@apple.com>
+
         Enable the minimal simulator feature flag when appropriate
         https://bugs.webkit.org/show_bug.cgi?id=183807
 
index df9dc89..8aa5015 100644 (file)
 #import "SystemMemory.h"
 #import "WebCoreThreadRun.h"
 #import <AVFoundation/AVAudioSession.h>
-#import <MediaPlayer/MPMediaItem.h>
-#import <MediaPlayer/MPNowPlayingInfoCenter.h>
-#import <MediaPlayer/MPVolumeView.h>
 #import <UIKit/UIApplication.h>
 #import <objc/runtime.h>
-#import <pal/spi/ios/MediaPlayerSPI.h>
 #import <wtf/BlockObjCExceptions.h>
 #import <wtf/MainThread.h>
 #import <wtf/RAMSize.h>
 #import <wtf/RetainPtr.h>
 #import <wtf/SoftLinking.h>
 
+#if HAVE(MEDIA_PLAYER)
+#import <MediaPlayer/MPMediaItem.h>
+#import <MediaPlayer/MPNowPlayingInfoCenter.h>
+#import <MediaPlayer/MPVolumeView.h>
+#import <pal/spi/ios/MediaPlayerSPI.h>
+#endif
+
 SOFT_LINK_FRAMEWORK(AVFoundation)
 SOFT_LINK_CLASS(AVFoundation, AVAudioSession)
 SOFT_LINK_POINTER(AVFoundation, AVAudioSessionInterruptionNotification, NSString *)
@@ -70,6 +73,7 @@ SOFT_LINK_POINTER(UIKit, UIApplicationDidEnterBackgroundNotification, NSString *
 #define UIApplicationDidBecomeActiveNotification getUIApplicationDidBecomeActiveNotification()
 #define UIApplicationDidEnterBackgroundNotification getUIApplicationDidEnterBackgroundNotification()
 
+#if HAVE(MEDIA_PLAYER)
 SOFT_LINK_FRAMEWORK(MediaPlayer)
 SOFT_LINK_CLASS(MediaPlayer, MPAVRoutingController)
 SOFT_LINK_CLASS(MediaPlayer, MPNowPlayingInfoCenter)
@@ -87,6 +91,7 @@ SOFT_LINK_POINTER(MediaPlayer, kMRMediaRemoteNowPlayingInfoUniqueIdentifier, NSS
 #define MPNowPlayingInfoPropertyPlaybackRate getMPNowPlayingInfoPropertyPlaybackRate()
 #define MPVolumeViewWirelessRoutesAvailableDidChangeNotification getMPVolumeViewWirelessRoutesAvailableDidChangeNotification()
 #define kMRMediaRemoteNowPlayingInfoUniqueIdentifier getkMRMediaRemoteNowPlayingInfoUniqueIdentifier()
+#endif // HAVE(MEDIA_PLAYER)
 
 WEBCORE_EXPORT NSString* WebUIApplicationWillResignActiveNotification = @"WebUIApplicationWillResignActiveNotification";
 WEBCORE_EXPORT NSString* WebUIApplicationWillEnterForegroundNotification = @"WebUIApplicationWillEnterForegroundNotification";
@@ -97,21 +102,32 @@ using namespace WebCore;
 
 @interface WebMediaSessionHelper : NSObject {
     MediaSessionManageriOS* _callback;
+
+#if HAVE(MEDIA_PLAYER)
     RetainPtr<MPVolumeView> _volumeView;
     RetainPtr<MPAVRoutingController> _airPlayPresenceRoutingController;
+#endif
 }
 
 - (id)initWithCallback:(MediaSessionManageriOS*)callback;
+
+#if HAVE(MEDIA_PLAYER)
 - (void)allocateVolumeView;
 - (void)setVolumeView:(RetainPtr<MPVolumeView>)volumeView;
+#endif
+
 - (void)clearCallback;
 - (void)interruption:(NSNotification *)notification;
 - (void)applicationWillEnterForeground:(NSNotification *)notification;
 - (void)applicationWillResignActive:(NSNotification *)notification;
 - (void)applicationDidEnterBackground:(NSNotification *)notification;
 - (BOOL)hasWirelessTargetsAvailable;
+
+#if HAVE(MEDIA_PLAYER)
 - (void)startMonitoringAirPlayRoutes;
 - (void)stopMonitoringAirPlayRoutes;
+#endif
+
 @end
 
 namespace WebCore {
@@ -173,6 +189,7 @@ bool MediaSessionManageriOS::hasWirelessTargetsAvailable()
 
 void MediaSessionManageriOS::configureWireLessTargetMonitoring()
 {
+#if HAVE(MEDIA_PLAYER)
     bool requiresMonitoring = anyOfSessions([] (PlatformMediaSession& session, size_t) {
         return session.requiresPlaybackTargetRouteMonitoring();
     });
@@ -187,6 +204,7 @@ void MediaSessionManageriOS::configureWireLessTargetMonitoring()
         [m_objcObserver stopMonitoringAirPlayRoutes];
 
     END_BLOCK_OBJC_EXCEPTIONS
+#endif
 }
 
 bool MediaSessionManageriOS::sessionWillBeginPlayback(PlatformMediaSession& session)
@@ -235,6 +253,7 @@ PlatformMediaSession* MediaSessionManageriOS::nowPlayingEligibleSession()
 
 void MediaSessionManageriOS::updateNowPlayingInfo()
 {
+#if HAVE(MEDIA_PLAYER)
     BEGIN_BLOCK_OBJC_EXCEPTIONS
     MPNowPlayingInfoCenter *nowPlaying = (MPNowPlayingInfoCenter *)[getMPNowPlayingInfoCenterClass() defaultCenter];
     const PlatformMediaSession* currentSession = this->nowPlayingEligibleSession();
@@ -282,6 +301,7 @@ void MediaSessionManageriOS::updateNowPlayingInfo()
     m_nowPlayingActive = true;
     [nowPlaying setNowPlayingInfo:info.get()];
     END_BLOCK_OBJC_EXCEPTIONS
+#endif // HAVE(MEDIA_PLAYER)
 }
 
 bool MediaSessionManageriOS::sessionCanLoadMedia(const PlatformMediaSession& session) const
@@ -305,6 +325,7 @@ void MediaSessionManageriOS::externalOutputDeviceAvailableDidChange()
 
 @implementation WebMediaSessionHelper
 
+#if HAVE(MEDIA_PLAYER)
 - (void)allocateVolumeView
 {
     if (pthread_main_np()) {
@@ -335,6 +356,7 @@ void MediaSessionManageriOS::externalOutputDeviceAvailableDidChange()
     if (_volumeView)
         [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(wirelessRoutesAvailableDidChange:) name:MPVolumeViewWirelessRoutesAvailableDidChangeNotification object:_volumeView.get()];
 }
+#endif
 
 - (id)initWithCallback:(MediaSessionManageriOS*)callback
 {
@@ -357,7 +379,9 @@ void MediaSessionManageriOS::externalOutputDeviceAvailableDidChange()
     [center addObserver:self selector:@selector(applicationDidEnterBackground:) name:UIApplicationDidEnterBackgroundNotification object:nil];
     [center addObserver:self selector:@selector(applicationDidEnterBackground:) name:WebUIApplicationDidEnterBackgroundNotification object:nil];
 
+#if HAVE(MEDIA_PLAYER)
     [self allocateVolumeView];
+#endif
 
     // Now playing won't work unless we turn on the delivery of remote control events.
     dispatch_async(dispatch_get_main_queue(), ^ {
@@ -373,6 +397,7 @@ void MediaSessionManageriOS::externalOutputDeviceAvailableDidChange()
 {
     LOG(Media, "-[WebMediaSessionHelper dealloc]");
 
+#if HAVE(MEDIA_PLAYER)
     if (!isMainThread()) {
         callOnMainThread([volumeView = WTFMove(_volumeView), routingController = WTFMove(_airPlayPresenceRoutingController)] () mutable {
             LOG(Media, "-[WebMediaSessionHelper dealloc] - dipatched to MainThread");
@@ -386,6 +411,7 @@ void MediaSessionManageriOS::externalOutputDeviceAvailableDidChange()
             routingController.clear();
         });
     }
+#endif
 
     [[NSNotificationCenter defaultCenter] removeObserver:self];
     [super dealloc];
@@ -400,9 +426,14 @@ void MediaSessionManageriOS::externalOutputDeviceAvailableDidChange()
 - (BOOL)hasWirelessTargetsAvailable
 {
     LOG(Media, "-[WebMediaSessionHelper hasWirelessTargetsAvailable]");
+#if HAVE(MEDIA_PLAYER)
     return _volumeView ? [_volumeView areWirelessRoutesAvailable] : NO;
+#else
+    return NO;
+#endif
 }
 
+#if HAVE(MEDIA_PLAYER)
 - (void)startMonitoringAirPlayRoutes
 {
     if (_airPlayPresenceRoutingController)
@@ -438,6 +469,7 @@ void MediaSessionManageriOS::externalOutputDeviceAvailableDidChange()
         protectedSelf->_airPlayPresenceRoutingController = nil;
     });
 }
+#endif // HAVE(MEDIA_PLAYER)
 
 - (void)interruption:(NSNotification *)notification
 {
index 66e1e6e..5749ca7 100644 (file)
@@ -25,6 +25,8 @@
 
 #include "config.h"
 
+#if HAVE(CORE_VIDEO)
+
 #include <CoreVideo/CoreVideo.h>
 #include <wtf/SoftLinking.h>
 
@@ -89,3 +91,4 @@ SOFT_LINK_CONSTANT_FOR_SOURCE(WebCore, CoreVideo, kCVPixelBufferExtendedPixelsBo
 SOFT_LINK_CONSTANT_FOR_SOURCE(WebCore, CoreVideo, kCVPixelBufferOpenGLCompatibilityKey, CFStringRef)
 #endif
 
+#endif // HAVE(CORE_VIDEO)
index 69f4c4b..a213c7c 100644 (file)
@@ -23,8 +23,9 @@
  * THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef CoreVideoSoftLink_h
-#define CoreVideoSoftLink_h
+#pragma once
+
+#if HAVE(CORE_VIDEO)
 
 #include <CoreVideo/CoreVideo.h>
 #include <wtf/SoftLinking.h>
@@ -142,4 +143,4 @@ SOFT_LINK_CONSTANT_FOR_HEADER(WebCore, CoreVideo, kCVPixelBufferOpenGLCompatibil
 #define kCVPixelBufferOpenGLCompatibilityKey get_CoreVideo_kCVPixelBufferOpenGLCompatibilityKey()
 #endif
 
-#endif // CoreVideoSoftLink_h
+#endif // HAVE(CORE_VIDEO)
index 54f420b..b717427 100644 (file)
@@ -368,7 +368,9 @@ private:
     std::unique_ptr<VideoTextureCopierCV> m_videoTextureCopier;
 #endif
 
+#if HAVE(CORE_VIDEO)
     std::unique_ptr<PixelBufferConformerCV> m_pixelBufferConformer;
+#endif
 
 #if HAVE(AVFOUNDATION_LOADER_DELEGATE)
     friend class WebCoreAVFResourceLoader;
index 675dcf4..b2ba746 100644 (file)
@@ -681,7 +681,7 @@ void MediaPlayerPrivateAVFoundationObjC::createVideoLayer()
         if (!m_videoLayer)
             createAVPlayerLayer();
 
-#if USE(VIDEOTOOLBOX)
+#if USE(VIDEOTOOLBOX) && HAVE(AVFOUNDATION_VIDEO_OUTPUT)
         if (!m_videoOutput)
             createVideoOutput();
 #endif
@@ -756,8 +756,10 @@ bool MediaPlayerPrivateAVFoundationObjC::hasAvailableVideoFrame() const
     if (currentRenderingMode() == MediaRenderingToLayer)
         return m_cachedIsReadyForDisplay;
 
+#if HAVE(AVFOUNDATION_VIDEO_OUTPUT)
     if (m_videoOutput && (m_lastPixelBuffer || [m_videoOutput hasNewPixelBufferForItemTime:[m_avPlayerItem currentTime]]))
         return true;
+#endif
 
     return m_videoFrameHasDrawn;
 }
@@ -2338,6 +2340,7 @@ bool MediaPlayerPrivateAVFoundationObjC::videoOutputHasAvailableFrame()
 
 void MediaPlayerPrivateAVFoundationObjC::updateLastImage()
 {
+#if HAVE(CORE_VIDEO)
     // Calls to copyPixelBufferForItemTime:itemTimeForDisplay: may return nil if the pixel buffer
     // for the requested time has already been retrieved. In this case, the last valid image (if any)
     // should be displayed.
@@ -2362,6 +2365,7 @@ void MediaPlayerPrivateAVFoundationObjC::updateLastImage()
 #if !RELEASE_LOG_DISABLED
     DEBUG_LOG(LOGIDENTIFIER, "creating buffer took ", (MonotonicTime::now() - start).seconds());
 #endif
+#endif // HAVE(CORE_VIDEO)
 }
 
 void MediaPlayerPrivateAVFoundationObjC::paintWithVideoOutput(GraphicsContext& context, const FloatRect& outputRect)
index 635863c..1898dcb 100644 (file)
@@ -279,6 +279,7 @@ Ref<MediaSample> MediaSampleAVFObjC::createNonDisplayingCopy() const
 
 RefPtr<JSC::Uint8ClampedArray> MediaSampleAVFObjC::getRGBAImageData() const
 {
+#if HAVE(CORE_VIDEO)
     const OSType imageFormat = kCVPixelFormatType_32RGBA;
     RetainPtr<CFNumberRef> imageFormatNumber = adoptCF(CFNumberCreate(nullptr,  kCFNumberIntType,  &imageFormat));
 
@@ -299,6 +300,9 @@ RefPtr<JSC::Uint8ClampedArray> MediaSampleAVFObjC::getRGBAImageData() const
     ASSERT(status == noErr);
 
     return result;
+#else
+    return nullptr;
+#endif
 }
 
 }
index 6a4c431..e47dc5b 100644 (file)
@@ -26,6 +26,8 @@
 #include "config.h"
 #include "PixelBufferConformerCV.h"
 
+#if HAVE(CORE_VIDEO)
+
 #include "GraphicsContextCG.h"
 #include <wtf/SoftLinking.h>
 
@@ -118,3 +120,5 @@ RetainPtr<CGImageRef> PixelBufferConformerCV::createImageFromPixelBuffer(CVPixel
 }
 
 }
+
+#endif // HAVE(CORE_VIDEO)
index d17bb3c..dd13569 100644 (file)
@@ -23,8 +23,9 @@
  * THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef PixelBufferConformerCV_h
-#define PixelBufferConformerCV_h
+#pragma once
+
+#if HAVE(CORE_VIDEO)
 
 #include <wtf/RetainPtr.h>
 
@@ -48,4 +49,4 @@ private:
 
 }
 
-#endif // PixelBufferConformerCV_h
+#endif // HAVE(CORE_VIDEO)
index e9749c3..547c79c 100644 (file)
@@ -23,8 +23,9 @@
  * THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef TextureCacheCV_h
-#define TextureCacheCV_h
+#pragma once
+
+#if HAVE(CORE_VIDEO)
 
 #include "GraphicsTypes3D.h"
 #include <wtf/Ref.h>
@@ -67,4 +68,4 @@ private:
 
 }
 
-#endif // TextureCacheCV_h
+#endif // HAVE(CORE_VIDEO)
index 5fbb022..bbb8e75 100644 (file)
@@ -26,6 +26,8 @@
 #include "config.h"
 #include "TextureCacheCV.h"
 
+#if HAVE(CORE_VIDEO)
+
 #include "GraphicsContext3D.h"
 
 #include "CoreVideoSoftLink.h"
@@ -89,3 +91,5 @@ RetainPtr<TextureCacheCV::TextureType> TextureCacheCV::textureFromImage(CVPixelB
 }
 
 }
+
+#endif // HAVE(CORE_VIDEO)
index 3316b47..ab618ff 100644 (file)
@@ -26,6 +26,8 @@
 #include "config.h"
 #include "VideoTextureCopierCV.h"
 
+#if HAVE(CORE_VIDEO)
+
 #include "FourCC.h"
 #include "Logging.h"
 #include "TextureCacheCV.h"
@@ -945,3 +947,5 @@ bool VideoTextureCopierCV::copyVideoTextureToPlatformTexture(Platform3DObject vi
 }
 
 }
+
+#endif // HAVE(CORE_VIDEO)
index 472f9f1..bee2210 100644 (file)
@@ -23,8 +23,9 @@
  * THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef VideoTextureCopierCV_h
-#define VideoTextureCopierCV_h
+#pragma once
+
+#if HAVE(CORE_VIDEO)
 
 #import "GraphicsContext3D.h"
 #import <wtf/UnsafePointer.h>
@@ -102,4 +103,4 @@ private:
 
 }
 
-#endif // VideoTextureCopierCV_h
+#endif // HAVE(CORE_VIDEO)