Changeset 197204 in webkit


Ignore:
Timestamp:
Feb 26, 2016 2:28:23 PM (8 years ago)
Author:
Beth Dakin
Message:

Add support for playbackControlsManager
https://bugs.webkit.org/show_bug.cgi?id=154742
-and corresponding-
rdar://problem/23833753

Reviewed by Jer Noble.

Source/WebCore:

Make AVKitSPI.h private so that it can be used from other projects.

  • WebCore.xcodeproj/project.pbxproj:

Right now, set up a controls manager for a video when it starts playing. In
the future, this is something that should be handled by the
PlatformMediaSessionManager since we only want a controls for the
currentSession.

  • html/HTMLMediaElement.cpp:

(WebCore::HTMLMediaElement::playInternal):

New function setUpVideoControlsManager.

  • page/ChromeClient.h:

Make these CoreMedia functions available on Mac and iOS instead of just iOS.

  • platform/cf/CoreMediaSoftLink.cpp:
  • platform/cf/CoreMediaSoftLink.h:

This patch fleshes out an implementation for a bunch of these interface
functions since they need to communicate to the playbackControlsManager. This
is also where the playbackControlsManager lives.

  • platform/mac/WebVideoFullscreenInterfaceMac.h:

Define an interface and implementation for WebPlaybackControlsManager.

  • platform/mac/WebVideoFullscreenInterfaceMac.mm:

(-[WebPlaybackControlsManager initWithWebVideoFullscreenInterfaceMac:]):
(-[WebPlaybackControlsManager isSeeking]):
(-[WebPlaybackControlsManager seekToTime:toleranceBefore:toleranceAfter:]):
(-[WebPlaybackControlsManager audioMediaSelectionOptions]):
(-[WebPlaybackControlsManager currentAudioMediaSelectionOption]):
(-[WebPlaybackControlsManager setCurrentAudioMediaSelectionOption:]):
(-[WebPlaybackControlsManager legibleMediaSelectionOptions]):
(-[WebPlaybackControlsManager currentLegibleMediaSelectionOption]):
(-[WebPlaybackControlsManager setCurrentLegibleMediaSelectionOption:]):
(-[WebPlaybackControlsManager cancelThumbnailAndAudioAmplitudeSampleGeneration]):

Relay this information to the playbackControlsManager.
(WebCore::WebVideoFullscreenInterfaceMac::setDuration):
(WebCore::WebVideoFullscreenInterfaceMac::setCurrentTime):
(WebCore::WebVideoFullscreenInterfaceMac::setRate):
(WebCore::WebVideoFullscreenInterfaceMac::setSeekableRanges):
(WebCore::WebVideoFullscreenInterfaceMac::ensureControlsManager):
(WebCore::WebVideoFullscreenInterfaceMac::playBackControlsManager):
(WebCore::WebVideoFullscreenInterfaceMac::setupFullscreen):

New SPI needed.

  • platform/spi/cocoa/AVKitSPI.h:
  • platform/spi/mac/AVFoundationSPI.h:

Source/WebKit2:

WebVideoFullscreenManagerProxy ensures the model and interface for the
UIProcess side of the playbackControlsManager. It also caches the
m_controlsManagerContextId so that it can return the
controlsManagerInterface.

  • UIProcess/Cocoa/WebVideoFullscreenManagerProxy.h:
  • UIProcess/Cocoa/WebVideoFullscreenManagerProxy.messages.in:
  • UIProcess/Cocoa/WebVideoFullscreenManagerProxy.mm:

(WebKit::WebVideoFullscreenManagerProxy::setUpVideoControlsManagerWithID):
(WebKit::WebVideoFullscreenManagerProxy::controlsManagerInterface):

Pipe isPlayingMediaDidChange() to WebViewImpl, and use that information to
update WebViewImplAdditions.

  • UIProcess/Cocoa/WebViewImpl.h:
  • UIProcess/Cocoa/WebViewImpl.mm:

(WebKit::WebViewImpl::isPlayingMediaDidChange):

  • UIProcess/PageClient.h:
  • UIProcess/WebPageProxy.cpp:

(WebKit::WebPageProxy::isPlayingMediaDidChange):
(WebKit::WebPageProxy::isPlayingVideoWithAudio):

  • UIProcess/WebPageProxy.h:

(WebKit::WebPageProxy::isPlayingAudio):

  • UIProcess/mac/PageClientImpl.h:
  • UIProcess/mac/PageClientImpl.mm:

(WebKit::PageClientImpl::isPlayingMediaDidChange):

Pipe setUpVideoControlsManager to the WebVideoFullscreenManager.

  • WebProcess/WebCoreSupport/WebChromeClient.cpp:

(WebKit::WebChromeClient::setUpVideoControlsManager):

  • WebProcess/WebCoreSupport/WebChromeClient.h:

Ensure the model an interface for the playbackControlsManager on the
WebProcess side and pass the message to the UIProcess to do the same.

  • WebProcess/cocoa/WebVideoFullscreenManager.h:
  • WebProcess/cocoa/WebVideoFullscreenManager.mm:

(WebKit::WebVideoFullscreenManager::setUpVideoControlsManager):

Location:
trunk/Source
Files:
24 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r197194 r197204  
     12016-02-26  Beth Dakin  <bdakin@apple.com>
     2
     3        Add support for playbackControlsManager
     4        https://bugs.webkit.org/show_bug.cgi?id=154742
     5        -and corresponding-
     6        rdar://problem/23833753
     7
     8        Reviewed by Jer Noble.
     9
     10        Make AVKitSPI.h private so that it can be used from other projects.
     11        * WebCore.xcodeproj/project.pbxproj:
     12
     13        Right now, set up a controls manager for a video when it starts playing. In
     14        the future, this is something that should be handled by the
     15        PlatformMediaSessionManager since we only want a controls for the
     16        currentSession.
     17        * html/HTMLMediaElement.cpp:
     18        (WebCore::HTMLMediaElement::playInternal):
     19
     20        New function setUpVideoControlsManager.
     21        * page/ChromeClient.h:
     22
     23        Make these CoreMedia functions available on Mac and iOS instead of just iOS.
     24        * platform/cf/CoreMediaSoftLink.cpp:
     25        * platform/cf/CoreMediaSoftLink.h:
     26
     27        This patch fleshes out an implementation for a bunch of these interface
     28        functions since they need to communicate to the playbackControlsManager. This
     29        is also where the playbackControlsManager lives.
     30        * platform/mac/WebVideoFullscreenInterfaceMac.h:
     31
     32        Define an interface and implementation for WebPlaybackControlsManager.
     33        * platform/mac/WebVideoFullscreenInterfaceMac.mm:
     34        (-[WebPlaybackControlsManager initWithWebVideoFullscreenInterfaceMac:]):
     35        (-[WebPlaybackControlsManager isSeeking]):
     36        (-[WebPlaybackControlsManager seekToTime:toleranceBefore:toleranceAfter:]):
     37        (-[WebPlaybackControlsManager audioMediaSelectionOptions]):
     38        (-[WebPlaybackControlsManager currentAudioMediaSelectionOption]):
     39        (-[WebPlaybackControlsManager setCurrentAudioMediaSelectionOption:]):
     40        (-[WebPlaybackControlsManager legibleMediaSelectionOptions]):
     41        (-[WebPlaybackControlsManager currentLegibleMediaSelectionOption]):
     42        (-[WebPlaybackControlsManager setCurrentLegibleMediaSelectionOption:]):
     43        (-[WebPlaybackControlsManager cancelThumbnailAndAudioAmplitudeSampleGeneration]):
     44
     45        Relay this information to the playbackControlsManager.
     46        (WebCore::WebVideoFullscreenInterfaceMac::setDuration):
     47        (WebCore::WebVideoFullscreenInterfaceMac::setCurrentTime):
     48        (WebCore::WebVideoFullscreenInterfaceMac::setRate):
     49        (WebCore::WebVideoFullscreenInterfaceMac::setSeekableRanges):
     50        (WebCore::WebVideoFullscreenInterfaceMac::ensureControlsManager):
     51        (WebCore::WebVideoFullscreenInterfaceMac::playBackControlsManager):
     52        (WebCore::WebVideoFullscreenInterfaceMac::setupFullscreen):
     53
     54        New SPI needed.
     55        * platform/spi/cocoa/AVKitSPI.h:
     56        * platform/spi/mac/AVFoundationSPI.h:
     57
    1582016-02-26  Said Abou-Hallawa  <sabouhallawa@apple.com>
    259
  • trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj

    r197142 r197204  
    330330                07EE76EF1BEA619800F89133 /* MockRealtimeVideoSourceMac.h in Headers */ = {isa = PBXBuildFile; fileRef = 07EE76ED1BEA619800F89133 /* MockRealtimeVideoSourceMac.h */; };
    331331                07EE76F01BEA619800F89133 /* MockRealtimeVideoSourceMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 07EE76EE1BEA619800F89133 /* MockRealtimeVideoSourceMac.mm */; };
    332                 07F0B97A1AC5DB3300E535D9 /* AVKitSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = 07F0B9791AC5DB3300E535D9 /* AVKitSPI.h */; };
     332                07F0B97A1AC5DB3300E535D9 /* AVKitSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = 07F0B9791AC5DB3300E535D9 /* AVKitSPI.h */; settings = {ATTRIBUTES = (Private, ); }; };
    333333                07F0B97C1AC5DB4600E535D9 /* AVFoundationSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = 07F0B97B1AC5DB4600E535D9 /* AVFoundationSPI.h */; settings = {ATTRIBUTES = (Private, ); }; };
    334334                07F876841AD580F900905849 /* MediaPlaybackTargetContext.h in Headers */ = {isa = PBXBuildFile; fileRef = 07F876831AD4A94500905849 /* MediaPlaybackTargetContext.h */; settings = {ATTRIBUTES = (Private, ); }; };
  • trunk/Source/WebCore/html/HTMLMediaElement.cpp

    r197114 r197204  
    29562956    }
    29572957
     2958    // FIXME: rdar://problem/23833752 We need to be more strategic about when we set up the video controls manager.
     2959    // It's really something that should be handled by the PlatformMediaSessionManager since we only want a controls
     2960    // manager for the currentSession.
     2961    if (document().page() && is<HTMLVideoElement>(*this)) {
     2962        HTMLVideoElement& asVideo = downcast<HTMLVideoElement>(*this);
     2963        document().page()->chrome().client().setUpVideoControlsManager(asVideo);
     2964    }
     2965
    29582966    // 4.8.10.9. Playing the media resource
    29592967    if (!m_player || m_networkState == NETWORK_EMPTY)
  • trunk/Source/WebCore/page/ChromeClient.h

    r195487 r197204  
    342342#if ENABLE(VIDEO)
    343343    virtual void enterVideoFullscreenForVideoElement(HTMLVideoElement&, HTMLMediaElementEnums::VideoFullscreenMode) { }
     344    virtual void setUpVideoControlsManager(HTMLVideoElement&) { }
    344345#endif
    345346    virtual void exitVideoFullscreenForVideoElement(WebCore::HTMLVideoElement&) { }
  • trunk/Source/WebCore/platform/cf/CoreMediaSoftLink.cpp

    r189913 r197204  
    4444SOFT_LINK_FUNCTION_FOR_SOURCE(WebCore, CoreMedia, CMTimeMakeWithSeconds, CMTime, (Float64 seconds, int32_t preferredTimeScale), (seconds, preferredTimeScale))
    4545SOFT_LINK_FUNCTION_FOR_SOURCE(WebCore, CoreMedia, CMTimeRangeGetEnd, CMTime, (CMTimeRange range), (range))
     46SOFT_LINK_FUNCTION_FOR_SOURCE(WebCore, CoreMedia, CMTimeRangeMake, CMTimeRange, (CMTime start, CMTime duration), (start, duration))
    4647
    4748SOFT_LINK_CONSTANT_FOR_SOURCE(WebCore, CoreMedia, kCMFormatDescriptionExtension_SampleDescriptionExtensionAtoms, CFStringRef)
     
    112113SOFT_LINK_FUNCTION_FOR_SOURCE(WebCore, CoreMedia, CMTimeMinimum, CMTime, (CMTime time1, CMTime time2), (time1, time2))
    113114SOFT_LINK_FUNCTION_FOR_SOURCE(WebCore, CoreMedia, CMTimeRangeContainsTime, Boolean, (CMTimeRange range, CMTime time), (range, time))
    114 SOFT_LINK_FUNCTION_FOR_SOURCE(WebCore, CoreMedia, CMTimeRangeMake, CMTimeRange, (CMTime start, CMTime duration), (start, duration))
    115115SOFT_LINK_FUNCTION_FOR_SOURCE(WebCore, CoreMedia, CMTimeSubtract, CMTime, (CMTime minuend, CMTime subtrahend), (minuend, subtrahend))
    116116
  • trunk/Source/WebCore/platform/cf/CoreMediaSoftLink.h

    r189913 r197204  
    5656SOFT_LINK_FUNCTION_FOR_HEADER(WebCore, CoreMedia, CMTimeRangeGetEnd, CMTime, (CMTimeRange range), (range))
    5757#define CMTimeRangeGetEnd softLink_CoreMedia_CMTimeRangeGetEnd
     58SOFT_LINK_FUNCTION_FOR_HEADER(WebCore, CoreMedia, CMTimeRangeMake, CMTimeRange, (CMTime start, CMTime duration), (start, duration))
     59#define CMTimeRangeMake softLink_CoreMedia_CMTimeRangeMake
    5860
    5961SOFT_LINK_CONSTANT_FOR_HEADER(WebCore, CoreMedia, kCMFormatDescriptionExtension_SampleDescriptionExtensionAtoms, CFStringRef)
     
    188190SOFT_LINK_FUNCTION_FOR_HEADER(WebCore, CoreMedia, CMTimeRangeContainsTime, Boolean, (CMTimeRange range, CMTime time), (range, time))
    189191#define CMTimeRangeContainsTime softLink_CoreMedia_CMTimeRangeContainsTime
    190 SOFT_LINK_FUNCTION_FOR_HEADER(WebCore, CoreMedia, CMTimeRangeMake, CMTimeRange, (CMTime start, CMTime duration), (start, duration))
    191 #define CMTimeRangeMake softLink_CoreMedia_CMTimeRangeMake
    192192SOFT_LINK_FUNCTION_FOR_HEADER(WebCore, CoreMedia, CMTimeSubtract, CMTime, (CMTime minuend, CMTime subtrahend), (minuend, subtrahend))
    193193#define CMTimeSubtract softLink_CoreMedia_CMTimeSubtract
  • trunk/Source/WebCore/platform/mac/WebVideoFullscreenInterfaceMac.h

    r196964 r197204  
    3636
    3737OBJC_CLASS NSWindow;
     38OBJC_CLASS WebPlaybackControlsManager;
    3839
    3940#if USE(APPLE_INTERNAL_SDK)
     
    6263
    6364    WEBCORE_EXPORT void resetMediaState() override { }
    64     WEBCORE_EXPORT void setDuration(double) override { }
    65     WEBCORE_EXPORT void setCurrentTime(double /*currentTime*/, double /*anchorTime*/) override { }
     65    WEBCORE_EXPORT void setDuration(double) override;
     66    WEBCORE_EXPORT void setCurrentTime(double /*currentTime*/, double /*anchorTime*/) override;
    6667    WEBCORE_EXPORT void setBufferedTime(double) override { }
    67     WEBCORE_EXPORT void setRate(bool /*isPlaying*/, float /*playbackRate*/) override { }
     68    WEBCORE_EXPORT void setRate(bool /*isPlaying*/, float /*playbackRate*/) override;
    6869    WEBCORE_EXPORT void setVideoDimensions(bool /*hasVideo*/, float /*width*/, float /*height*/) override { }
    69     WEBCORE_EXPORT void setSeekableRanges(const TimeRanges&) override { }
     70    WEBCORE_EXPORT void setSeekableRanges(const TimeRanges&) override;
    7071    WEBCORE_EXPORT void setCanPlayFastReverse(bool) override { }
    7172    WEBCORE_EXPORT void setAudioMediaSelectionOptions(const Vector<WTF::String>& /*options*/, uint64_t /*selectedIndex*/) override { }
     
    8182    WEBCORE_EXPORT void requestHideAndExitFullscreen() { }
    8283    WEBCORE_EXPORT void preparedToReturnToInline(bool visible, const IntRect& inlineRect, NSWindow *parentWindow);
     84    WEBCORE_EXPORT void ensureControlsManager();
    8385
    8486    HTMLMediaElementEnums::VideoFullscreenMode mode() const { return m_mode; }
     
    9193    void applicationDidBecomeActive() { }
    9294
     95    WEBCORE_EXPORT WebPlaybackControlsManager *playBackControlsManager();
     96
    9397private:
    9498    WebVideoFullscreenModel* m_videoFullscreenModel { nullptr };
     
    99103    RetainPtr<WebVideoFullscreenInterfaceMacObjC> m_webVideoFullscreenInterfaceObjC;
    100104#endif
     105    RetainPtr<WebPlaybackControlsManager> m_playbackControlsManager;
    101106};
    102107
  • trunk/Source/WebCore/platform/mac/WebVideoFullscreenInterfaceMac.mm

    r196964 r197204  
    2929#if PLATFORM(MAC) && ENABLE(VIDEO_PRESENTATION_MODE)
    3030
     31#import "AVKitSPI.h"
     32#import "CoreMediaSoftLink.h"
    3133#import "IntRect.h"
     34#import "MediaTimeAVFoundation.h"
     35#import "TimeRanges.h"
    3236#import "WebVideoFullscreenChangeObserver.h"
    3337#import "WebVideoFullscreenModel.h"
     38#import <AVFoundation/AVTime.h>
     39
     40#import "SoftLinking.h"
     41
     42SOFT_LINK_FRAMEWORK(AVKit)
     43SOFT_LINK_CLASS(AVKit, AVValueTiming)
    3444
    3545#if USE(APPLE_INTERNAL_SDK)
    3646#include <WebKitAdditions/WebVideoFullscreenInterfaceMacAdditions.mm>
    3747#endif
     48
     49using namespace WebCore;
     50
     51@interface WebPlaybackControlsManager : NSObject {
     52@private
     53    WebCore::WebVideoFullscreenInterfaceMac* _webVideoFullscreenInterfaceMac;
     54}
     55
     56@property (readwrite) NSTimeInterval contentDuration;
     57@property (nonatomic, retain, readwrite) AVValueTiming *timing;
     58@property NSTimeInterval seekToTime;
     59@property (nonatomic, retain, readwrite) NSArray *seekableTimeRanges;
     60@property (readwrite) BOOL hasEnabledAudio;
     61@property (readwrite) BOOL hasEnabledVideo;
     62
     63@property (nonatomic) float rate;
     64
     65- (instancetype)initWithWebVideoFullscreenInterfaceMac:(WebCore::WebVideoFullscreenInterfaceMac*)webVideoFullscreenInterfaceMac;
     66
     67@end
     68
     69#if USE(APPLE_INTERNAL_SDK)
     70#import <WebKitAdditions/WebPlaybackControlsControllerAdditions.mm>
     71#endif
     72
     73@implementation WebPlaybackControlsManager
     74
     75- (instancetype)initWithWebVideoFullscreenInterfaceMac:(WebCore::WebVideoFullscreenInterfaceMac*)webVideoFullscreenInterfaceMac
     76{
     77    if (!(self = [super init]))
     78        return nil;
     79
     80    _webVideoFullscreenInterfaceMac = webVideoFullscreenInterfaceMac;
     81
     82    return self;
     83}
     84
     85- (BOOL)isSeeking
     86{
     87    return NO;
     88}
     89
     90- (void)seekToTime:(NSTimeInterval)time toleranceBefore:(NSTimeInterval)toleranceBefore toleranceAfter:(NSTimeInterval)toleranceAfter
     91{
     92    UNUSED_PARAM(toleranceBefore);
     93    UNUSED_PARAM(toleranceAfter);
     94    _webVideoFullscreenInterfaceMac->webVideoFullscreenModel()->seekToTime(time);
     95}
     96
     97- (NSArray *)audioMediaSelectionOptions
     98{
     99    return @[];
     100}
     101
     102- (AVMediaSelectionOption *)currentAudioMediaSelectionOption
     103{
     104    return nil;
     105}
     106
     107- (void)setCurrentAudioMediaSelectionOption:(AVMediaSelectionOption *)audioMediaSelectionOption
     108{
     109    UNUSED_PARAM(audioMediaSelectionOption);
     110}
     111
     112- (NSArray *)legibleMediaSelectionOptions
     113{
     114    return @[];
     115}
     116
     117- (AVMediaSelectionOption *)currentLegibleMediaSelectionOption
     118{
     119    return nil;
     120}
     121
     122- (void)setCurrentLegibleMediaSelectionOption:(AVMediaSelectionOption *)legibleMediaSelectionOption
     123{
     124    UNUSED_PARAM(legibleMediaSelectionOption);
     125}
     126
     127- (void)cancelThumbnailAndAudioAmplitudeSampleGeneration
     128{
     129}
     130
     131#if USE(APPLE_INTERNAL_SDK)
     132#import <WebKitAdditions/WebPlaybackControlsControllerThumbnailAdditions.mm>
     133#endif
     134
     135@end
    38136
    39137namespace WebCore {
     
    75173}
    76174
     175void WebVideoFullscreenInterfaceMac::setDuration(double duration)
     176{
     177    WebPlaybackControlsManager* controlsManager = playBackControlsManager();
     178
     179    controlsManager.contentDuration = duration;
     180
     181    // FIXME: We take this as an indication that playback is ready, but that is not necessarily true.
     182    controlsManager.hasEnabledAudio = YES;
     183    controlsManager.hasEnabledVideo = YES;
     184}
     185
     186void WebVideoFullscreenInterfaceMac::setCurrentTime(double currentTime, double anchorTime)
     187{
     188    WebPlaybackControlsManager* controlsManager = playBackControlsManager();
     189
     190    NSTimeInterval anchorTimeStamp = ![controlsManager rate] ? NAN : anchorTime;
     191    AVValueTiming *timing = [getAVValueTimingClass() valueTimingWithAnchorValue:currentTime
     192        anchorTimeStamp:anchorTimeStamp rate:0];
     193   
     194    [controlsManager setTiming:timing];
     195}
     196
     197void WebVideoFullscreenInterfaceMac::setRate(bool isPlaying, float playbackRate)
     198{
     199    WebPlaybackControlsManager* controlsManager = playBackControlsManager();
     200
     201    [controlsManager setRate:isPlaying ? playbackRate : 0.];
     202}
     203
     204void WebVideoFullscreenInterfaceMac::setSeekableRanges(const TimeRanges& timeRanges)
     205{
     206    WebPlaybackControlsManager* controlsManager = playBackControlsManager();
     207
     208    RetainPtr<NSMutableArray> seekableRanges = adoptNS([[NSMutableArray alloc] init]);
     209
     210    for (unsigned i = 0; i < timeRanges.length(); i++) {
     211        const PlatformTimeRanges& ranges = timeRanges.ranges();
     212        CMTimeRange range = CMTimeRangeMake(toCMTime(ranges.start(i)), toCMTime(ranges.end(i)));
     213        [seekableRanges addObject:[NSValue valueWithCMTimeRange:range]];
     214    }
     215   
     216    [controlsManager setSeekableTimeRanges:seekableRanges.get()];
     217}
     218
     219void WebVideoFullscreenInterfaceMac::ensureControlsManager()
     220{
     221    playBackControlsManager();
     222}
     223
     224WebPlaybackControlsManager *WebVideoFullscreenInterfaceMac::playBackControlsManager()
     225{
     226#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101200
     227    if (!m_playbackControlsManager)
     228        m_playbackControlsManager = adoptNS([[WebPlaybackControlsManager alloc] initWithWebVideoFullscreenInterfaceMac:this]);
     229    return m_playbackControlsManager.get();
     230#else
     231    return nil;
     232#endif
     233}
     234
    77235#if !USE(APPLE_INTERNAL_SDK)
    78236void WebVideoFullscreenInterfaceMac::setupFullscreen(NSView&, const IntRect&, NSWindow *, HTMLMediaElementEnums::VideoFullscreenMode, bool)
  • trunk/Source/WebCore/platform/spi/cocoa/AVKitSPI.h

    r193340 r197204  
    2626#import "SoftLinking.h"
    2727#import <objc/runtime.h>
     28
     29#if USE(APPLE_INTERNAL_SDK)
     30
     31#import <AVKit/AVValueTiming.h>
     32
     33#else
     34
     35@interface AVValueTiming : NSObject <NSCoding, NSCopying, NSMutableCopying>
     36@end
     37
     38@interface AVValueTiming ()
     39+ (AVValueTiming *)valueTimingWithAnchorValue:(double)anchorValue anchorTimeStamp:(NSTimeInterval)timeStamp rate:(double)rate;
     40@property (NS_NONATOMIC_IOSONLY, readonly) double currentValue;
     41@end
     42
     43#endif // USE(APPLE_INTERNAL_SDK)
    2844
    2945#if PLATFORM(IOS)
     
    102118
    103119#endif // USE(APPLE_INTERNAL_SDK)
    104 
    105 @interface AVValueTiming : NSObject <NSCoding, NSCopying, NSMutableCopying>
    106 @end
    107 
    108 @interface AVValueTiming ()
    109 + (AVValueTiming *)valueTimingWithAnchorValue:(double)anchorValue anchorTimeStamp:(NSTimeInterval)timeStamp rate:(double)rate;
    110 @property (NS_NONATOMIC_IOSONLY, readonly) double currentValue;
    111 @end
    112 
    113120#endif // PLATFORM(IOS)
    114121
  • trunk/Source/WebKit2/ChangeLog

    r197203 r197204  
     12016-02-26  Beth Dakin  <bdakin@apple.com>
     2
     3        Add support for playbackControlsManager
     4        https://bugs.webkit.org/show_bug.cgi?id=154742
     5        -and corresponding-
     6        rdar://problem/23833753
     7
     8        Reviewed by Jer Noble.
     9
     10        WebVideoFullscreenManagerProxy ensures the model and interface for the
     11        UIProcess side of the playbackControlsManager. It also caches the
     12        m_controlsManagerContextId so that it can return the
     13        controlsManagerInterface.
     14        * UIProcess/Cocoa/WebVideoFullscreenManagerProxy.h:
     15        * UIProcess/Cocoa/WebVideoFullscreenManagerProxy.messages.in:
     16        * UIProcess/Cocoa/WebVideoFullscreenManagerProxy.mm:
     17        (WebKit::WebVideoFullscreenManagerProxy::setUpVideoControlsManagerWithID):
     18        (WebKit::WebVideoFullscreenManagerProxy::controlsManagerInterface):
     19
     20        Pipe isPlayingMediaDidChange() to WebViewImpl, and use that information to
     21        update WebViewImplAdditions.
     22        * UIProcess/Cocoa/WebViewImpl.h:
     23        * UIProcess/Cocoa/WebViewImpl.mm:
     24        (WebKit::WebViewImpl::isPlayingMediaDidChange):
     25        * UIProcess/PageClient.h:
     26        * UIProcess/WebPageProxy.cpp:
     27        (WebKit::WebPageProxy::isPlayingMediaDidChange):
     28        (WebKit::WebPageProxy::isPlayingVideoWithAudio):
     29        * UIProcess/WebPageProxy.h:
     30        (WebKit::WebPageProxy::isPlayingAudio):
     31        * UIProcess/mac/PageClientImpl.h:
     32        * UIProcess/mac/PageClientImpl.mm:
     33        (WebKit::PageClientImpl::isPlayingMediaDidChange):
     34
     35        Pipe setUpVideoControlsManager to the WebVideoFullscreenManager.
     36        * WebProcess/WebCoreSupport/WebChromeClient.cpp:
     37        (WebKit::WebChromeClient::setUpVideoControlsManager):
     38        * WebProcess/WebCoreSupport/WebChromeClient.h:
     39
     40        Ensure the model an interface for the playbackControlsManager on the
     41        WebProcess side and pass the message to the UIProcess to do the same.
     42        * WebProcess/cocoa/WebVideoFullscreenManager.h:
     43        * WebProcess/cocoa/WebVideoFullscreenManager.mm:
     44        (WebKit::WebVideoFullscreenManager::setUpVideoControlsManager):
     45
    1462016-02-26  Anders Carlsson  <andersca@apple.com>
    247
  • trunk/Source/WebKit2/UIProcess/Cocoa/WebVideoFullscreenManagerProxy.h

    r195755 r197204  
    120120    bool isVisible() const;
    121121
     122    PlatformWebVideoFullscreenInterface& controlsManagerInterface();
     123
    122124private:
    123125    friend class WebVideoFullscreenModelContext;
     
    134136    // Messages from WebVideoFullscreenManager
    135137    void setupFullscreenWithID(uint64_t contextId, uint32_t videoLayerID, const WebCore::IntRect& initialRect, float hostingScaleFactor, WebCore::HTMLMediaElementEnums::VideoFullscreenMode, bool allowsPictureInPicture);
     138    void setUpVideoControlsManagerWithID(uint64_t contextId);
    136139    void resetMediaState(uint64_t contextId);
    137140    void setCurrentTime(uint64_t contextId, double currentTime, double hostTime);
     
    176179    WebPageProxy* m_page;
    177180    HashMap<uint64_t, ModelInterfaceTuple> m_contextMap;
     181    uint64_t m_controlsManagerContextId { 0 };
    178182
    179183};
  • trunk/Source/WebKit2/UIProcess/Cocoa/WebVideoFullscreenManagerProxy.messages.in

    r195755 r197204  
    4040    CleanupFullscreen(uint64_t contextId)
    4141    PreparedToReturnToInline(uint64_t contextId, bool visible, WebCore::IntRect inlineRect)
     42    SetUpVideoControlsManagerWithID(uint64_t contextId)
    4243}
    4344#endif
  • trunk/Source/WebKit2/UIProcess/Cocoa/WebVideoFullscreenManagerProxy.mm

    r196964 r197204  
    375375}
    376376
     377void WebVideoFullscreenManagerProxy::setUpVideoControlsManagerWithID(uint64_t contextId)
     378{
     379    RefPtr<WebVideoFullscreenModelContext> model;
     380    RefPtr<PlatformWebVideoFullscreenInterface> interface;
     381
     382    std::tie(model, interface) = ensureModelAndInterface(contextId);
     383    m_controlsManagerContextId = contextId;
     384    interface->ensureControlsManager();
     385}
     386
    377387void WebVideoFullscreenManagerProxy::resetMediaState(uint64_t contextId)
    378388{
     
    616626}
    617627
     628PlatformWebVideoFullscreenInterface& WebVideoFullscreenManagerProxy::controlsManagerInterface()
     629{
     630    return ensureInterface(m_controlsManagerContextId);
     631}
     632
    618633void WebVideoFullscreenManagerProxy::fullscreenMayReturnToInline(uint64_t contextId)
    619634{
  • trunk/Source/WebKit2/UIProcess/Cocoa/WebViewImpl.h

    r196452 r197204  
    325325    void didChangeContentSize(CGSize);
    326326    void didHandleAcceptedCandidate();
     327    void isPlayingMediaDidChange();
    327328
    328329    void setIgnoresNonWheelEvents(bool);
  • trunk/Source/WebKit2/UIProcess/Cocoa/WebViewImpl.mm

    r196456 r197204  
    23722372}
    23732373
     2374void WebViewImpl::isPlayingMediaDidChange()
     2375{
     2376#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101200
     2377    updateWebViewImplAdditions();
     2378#endif
     2379}
     2380
    23742381void WebViewImpl::setIgnoresNonWheelEvents(bool ignoresNonWheelEvents)
    23752382{
  • trunk/Source/WebKit2/UIProcess/PageClient.h

    r196964 r197204  
    351351
    352352    virtual void didHandleAcceptedCandidate() = 0;
     353
     354    virtual void isPlayingMediaDidChange() = 0;
    353355#endif
    354356
  • trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp

    r197161 r197204  
    59865986        return;
    59875987
     5988#if PLATFORM(MAC)
     5989    m_pageClient.isPlayingMediaDidChange();
     5990#endif
    59885991    m_uiClient->isPlayingAudioDidChange(*this);
     5992}
     5993
     5994bool WebPageProxy::isPlayingVideoWithAudio() const
     5995{
     5996    return m_mediaState & MediaProducer::IsPlayingAudio && m_mediaState & MediaProducer::IsPlayingVideo;
    59895997}
    59905998
  • trunk/Source/WebKit2/UIProcess/WebPageProxy.h

    r197161 r197204  
    10121012    void isPlayingMediaDidChange(WebCore::MediaProducer::MediaStateFlags, uint64_t);
    10131013
     1014    bool isPlayingVideoWithAudio() const;
     1015
    10141016#if ENABLE(MEDIA_SESSION)
    10151017    void hasMediaSessionWithActiveMediaElementsDidChange(bool);
  • trunk/Source/WebKit2/UIProcess/mac/PageClientImpl.h

    r196964 r197204  
    215215    virtual void didHandleAcceptedCandidate() override;
    216216
     217    void isPlayingMediaDidChange() override;
     218
    217219    virtual void showPlatformContextMenu(NSMenu *, WebCore::IntPoint) override;
    218220
  • trunk/Source/WebKit2/UIProcess/mac/PageClientImpl.mm

    r196964 r197204  
    795795}
    796796
     797void PageClientImpl::isPlayingMediaDidChange()
     798{
     799    m_impl->isPlayingMediaDidChange();
     800}
     801
    797802void PageClientImpl::showPlatformContextMenu(NSMenu *menu, IntPoint location)
    798803{
  • trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.cpp

    r196964 r197204  
    856856}
    857857
     858void WebChromeClient::setUpVideoControlsManager(WebCore::HTMLVideoElement& videoElement)
     859{
     860    m_page->videoFullscreenManager()->setUpVideoControlsManager(videoElement);
     861}
     862
    858863void WebChromeClient::enterVideoFullscreenForVideoElement(WebCore::HTMLVideoElement& videoElement, WebCore::HTMLMediaElementEnums::VideoFullscreenMode mode)
    859864{
  • trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.h

    r195755 r197204  
    245245#if PLATFORM(IOS) || (PLATFORM(MAC) && ENABLE(VIDEO_PRESENTATION_MODE))
    246246    virtual bool supportsVideoFullscreen(WebCore::HTMLMediaElementEnums::VideoFullscreenMode) override;
     247    virtual void setUpVideoControlsManager(WebCore::HTMLVideoElement&) override;
    247248    virtual void enterVideoFullscreenForVideoElement(WebCore::HTMLVideoElement&, WebCore::HTMLMediaElementEnums::VideoFullscreenMode) override;
    248249    virtual void exitVideoFullscreenForVideoElement(WebCore::HTMLVideoElement&) override;
  • trunk/Source/WebKit2/WebProcess/cocoa/WebVideoFullscreenManager.h

    r196964 r197204  
    117117    void enterVideoFullscreenForVideoElement(WebCore::HTMLVideoElement&, WebCore::HTMLMediaElementEnums::VideoFullscreenMode);
    118118    void exitVideoFullscreenForVideoElement(WebCore::HTMLVideoElement&);
     119    void setUpVideoControlsManager(WebCore::HTMLVideoElement&);
    119120   
    120121protected:
  • trunk/Source/WebKit2/WebProcess/cocoa/WebVideoFullscreenManager.mm

    r196964 r197204  
    280280}
    281281
     282void WebVideoFullscreenManager::setUpVideoControlsManager(WebCore::HTMLVideoElement& videoElement)
     283{
     284    auto addResult = m_videoElements.ensure(&videoElement, [&] { return nextContextId(); });
     285    auto contextId = addResult.iterator->value;
     286
     287    RefPtr<WebVideoFullscreenModelVideoElement> model;
     288    RefPtr<WebVideoFullscreenInterfaceContext> interface;
     289    std::tie(model, interface) = ensureModelAndInterface(contextId);
     290    model->setVideoElement(&videoElement);
     291   
     292    m_page->send(Messages::WebVideoFullscreenManagerProxy::SetUpVideoControlsManagerWithID(contextId), m_page->pageID());
     293}
     294
    282295#pragma mark Interface to WebVideoFullscreenInterfaceContext:
    283296
Note: See TracChangeset for help on using the changeset viewer.