Skip to content
Permalink
Browse files
Implement seek tolerance methods in WebAVPlayerController.
https://bugs.webkit.org/show_bug.cgi?id=178838
rdar://problem/33781777

Patch by Jeremy Jones <jeremyj@apple.com> on 2017-10-26
Reviewed by Eric Carlson.

Source/WebCore:

No new tests because this doesn't change any behavior in the page, but exposes seek tolerance to fullscreen platform UI.

* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::setCurrentTimeWithTolerance):
* html/HTMLMediaElement.h:
* platform/cocoa/PlaybackSessionModel.h:
* platform/cocoa/PlaybackSessionModelMediaElement.h:
* platform/cocoa/PlaybackSessionModelMediaElement.mm:
(WebCore::PlaybackSessionModelMediaElement::seekToTime):
* platform/ios/WebAVPlayerController.mm:
(-[WebAVPlayerController seekToTime:]):
(-[WebAVPlayerController seekToTime:toleranceBefore:toleranceAfter:]):
(-[WebAVPlayerController seekByTimeInterval:]):
(-[WebAVPlayerController seekByTimeInterval:toleranceBefore:toleranceAfter:]):
(-[WebAVPlayerController seekToBeginning:]):
(-[WebAVPlayerController seekToEnd:]):
* platform/ios/WebVideoFullscreenControllerAVKit.mm:
(VideoFullscreenControllerContext::seekToTime):

Source/WebKit:

This implementes additional methods on WebAVPlayerController that allows AVKit more control over seeking.

* UIProcess/Cocoa/PlaybackSessionManagerProxy.h:
* UIProcess/Cocoa/PlaybackSessionManagerProxy.mm:
(WebKit::PlaybackSessionModelContext::seekToTime):
(WebKit::PlaybackSessionManagerProxy::seekToTime):
* WebProcess/cocoa/PlaybackSessionManager.h:
* WebProcess/cocoa/PlaybackSessionManager.messages.in:
* WebProcess/cocoa/PlaybackSessionManager.mm:
(WebKit::PlaybackSessionManager::seekToTime):

Canonical link: https://commits.webkit.org/195073@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@224085 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
Jeremy Jones authored and webkit-commit-queue committed Oct 27, 2017
1 parent 77c093e commit 6bb8e5ea61ec04b716c0feaeb90f88d07ac75dbc
Showing 14 changed files with 87 additions and 19 deletions.
@@ -1,3 +1,30 @@
2017-10-26 Jeremy Jones <jeremyj@apple.com>

Implement seek tolerance methods in WebAVPlayerController.
https://bugs.webkit.org/show_bug.cgi?id=178838
rdar://problem/33781777

Reviewed by Eric Carlson.

No new tests because this doesn't change any behavior in the page, but exposes seek tolerance to fullscreen platform UI.

* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::setCurrentTimeWithTolerance):
* html/HTMLMediaElement.h:
* platform/cocoa/PlaybackSessionModel.h:
* platform/cocoa/PlaybackSessionModelMediaElement.h:
* platform/cocoa/PlaybackSessionModelMediaElement.mm:
(WebCore::PlaybackSessionModelMediaElement::seekToTime):
* platform/ios/WebAVPlayerController.mm:
(-[WebAVPlayerController seekToTime:]):
(-[WebAVPlayerController seekToTime:toleranceBefore:toleranceAfter:]):
(-[WebAVPlayerController seekByTimeInterval:]):
(-[WebAVPlayerController seekByTimeInterval:toleranceBefore:toleranceAfter:]):
(-[WebAVPlayerController seekToBeginning:]):
(-[WebAVPlayerController seekToEnd:]):
* platform/ios/WebVideoFullscreenControllerAVKit.mm:
(VideoFullscreenControllerContext::seekToTime):

2017-10-26 Michael Catanzaro <mcatanzaro@igalia.com>

Unreviewed, fix WPE build after r224074
@@ -3142,6 +3142,11 @@ void HTMLMediaElement::setCurrentTime(double time)
setCurrentTime(MediaTime::createWithDouble(time));
}

void HTMLMediaElement::setCurrentTimeWithTolerance(double time, double toleranceBefore, double toleranceAfter)
{
seekWithTolerance(MediaTime::createWithDouble(time), MediaTime::createWithDouble(toleranceBefore), MediaTime::createWithDouble(toleranceAfter), true);
}

void HTMLMediaElement::setCurrentTime(const MediaTime& time)
{
if (m_mediaController)
@@ -226,6 +226,7 @@ class HTMLMediaElement
// playback state
WEBCORE_EXPORT double currentTime() const override;
void setCurrentTime(double) override;
void setCurrentTimeWithTolerance(double, double toleranceBefore, double toleranceAfter);
double currentTimeForBindings() const { return currentTime(); }
WEBCORE_EXPORT ExceptionOr<void> setCurrentTimeForBindings(double);
WEBCORE_EXPORT double getStartDate() const;
@@ -48,7 +48,7 @@ class PlaybackSessionModel {
virtual void togglePlayState() = 0;
virtual void beginScrubbing() = 0;
virtual void endScrubbing() = 0;
virtual void seekToTime(double time) = 0;
virtual void seekToTime(double time, double toleranceBefore = 0, double toleranceAfter = 0) = 0;
virtual void fastSeek(double time) = 0;
virtual void beginScanningForward() = 0;
virtual void beginScanningBackward() = 0;
@@ -62,7 +62,7 @@ class PlaybackSessionModelMediaElement final : public PlaybackSessionModel, publ
WEBCORE_EXPORT void togglePlayState() final;
WEBCORE_EXPORT void beginScrubbing() final;
WEBCORE_EXPORT void endScrubbing() final;
WEBCORE_EXPORT void seekToTime(double time) final;
WEBCORE_EXPORT void seekToTime(double time, double toleranceBefore, double toleranceAfter) final;
WEBCORE_EXPORT void fastSeek(double time) final;
WEBCORE_EXPORT void beginScanningForward() final;
WEBCORE_EXPORT void beginScanningBackward() final;
@@ -218,10 +218,10 @@
m_mediaElement->endScrubbing();
}

void PlaybackSessionModelMediaElement::seekToTime(double time)
void PlaybackSessionModelMediaElement::seekToTime(double time, double toleranceBefore, double toleranceAfter)
{
if (m_mediaElement)
m_mediaElement->setCurrentTime(time);
m_mediaElement->setCurrentTimeWithTolerance(time, toleranceBefore, toleranceAfter);
}

void PlaybackSessionModelMediaElement::fastSeek(double time)
@@ -167,7 +167,23 @@ - (void)endScrubbing:(id)sender
- (void)seekToTime:(NSTimeInterval)time
{
if (self.delegate)
self.delegate->fastSeek(time);
self.delegate->seekToTime(time);
}

- (void)seekToTime:(NSTimeInterval)time toleranceBefore:(NSTimeInterval)before toleranceAfter:(NSTimeInterval)after
{
self.delegate->seekToTime(time, before, after);
}

- (void)seekByTimeInterval:(NSTimeInterval)interval
{
[self seekByTimeInterval:interval toleranceBefore:0. toleranceAfter:0.];
}

- (void)seekByTimeInterval:(NSTimeInterval)interval toleranceBefore:(NSTimeInterval)before toleranceAfter:(NSTimeInterval)after
{
NSTimeInterval targetTime = [[self timing] currentValue] + interval;
[self seekToTime:targetTime toleranceBefore:before toleranceAfter:after];
}

- (NSTimeInterval)currentTimeWithinEndTimes
@@ -140,7 +140,7 @@ void didEnterFullscreen() override { }
void togglePlayState() override;
void beginScrubbing() override;
void endScrubbing() override;
void seekToTime(double) override;
void seekToTime(double, double, double) override;
void fastSeek(double time) override;
void beginScanningForward() override;
void beginScanningBackward() override;
@@ -635,13 +635,13 @@ void togglePictureInPicture() override { }
});
}

void VideoFullscreenControllerContext::seekToTime(double time)
void VideoFullscreenControllerContext::seekToTime(double time, double toleranceBefore, double toleranceAfter)
{
ASSERT(isUIThread());
RefPtr<VideoFullscreenControllerContext> protectedThis(this);
WebThreadRun([protectedThis, this, time] {
WebThreadRun([protectedThis, this, time, toleranceBefore, toleranceAfter] {
if (m_playbackModel)
m_playbackModel->seekToTime(time);
m_playbackModel->seekToTime(time, toleranceBefore, toleranceAfter);
});
}

@@ -1,3 +1,22 @@
2017-10-26 Jeremy Jones <jeremyj@apple.com>

Implement seek tolerance methods in WebAVPlayerController.
https://bugs.webkit.org/show_bug.cgi?id=178838
rdar://problem/33781777

Reviewed by Eric Carlson.

This implementes additional methods on WebAVPlayerController that allows AVKit more control over seeking.

* UIProcess/Cocoa/PlaybackSessionManagerProxy.h:
* UIProcess/Cocoa/PlaybackSessionManagerProxy.mm:
(WebKit::PlaybackSessionModelContext::seekToTime):
(WebKit::PlaybackSessionManagerProxy::seekToTime):
* WebProcess/cocoa/PlaybackSessionManager.h:
* WebProcess/cocoa/PlaybackSessionManager.messages.in:
* WebProcess/cocoa/PlaybackSessionManager.mm:
(WebKit::PlaybackSessionManager::seekToTime):

2017-10-26 Brian Burg <bburg@apple.com>

Web Automation: denying user permission for getUserMedia doesn't work
@@ -100,7 +100,7 @@ class PlaybackSessionModelContext final: public RefCounted<PlaybackSessionModelC
void togglePlayState() final;
void beginScrubbing() final;
void endScrubbing() final;
void seekToTime(double) final;
void seekToTime(double, double, double) final;
void fastSeek(double time) final;
void beginScanningForward() final;
void beginScanningBackward() final;
@@ -209,7 +209,7 @@ class PlaybackSessionManagerProxy : public RefCounted<PlaybackSessionManagerProx
void togglePlayState(uint64_t contextId);
void beginScrubbing(uint64_t contextId);
void endScrubbing(uint64_t contextId);
void seekToTime(uint64_t contextId, double time);
void seekToTime(uint64_t contextId, double time, double before, double after);
void fastSeek(uint64_t contextId, double time);
void beginScanningForward(uint64_t contextId);
void beginScanningBackward(uint64_t contextId);
@@ -86,10 +86,10 @@
m_playbackStartedTimeNeedsUpdate = isPlaying();
}

void PlaybackSessionModelContext::seekToTime(double time)
void PlaybackSessionModelContext::seekToTime(double time, double toleranceBefore, double toleranceAfter)
{
if (m_manager)
m_manager->seekToTime(m_contextId, time);
m_manager->seekToTime(m_contextId, time, toleranceBefore, toleranceAfter);
}

void PlaybackSessionModelContext::fastSeek(double time)
@@ -494,9 +494,9 @@
m_page->send(Messages::PlaybackSessionManager::EndScrubbing(contextId), m_page->pageID());
}

void PlaybackSessionManagerProxy::seekToTime(uint64_t contextId, double time)
void PlaybackSessionManagerProxy::seekToTime(uint64_t contextId, double time, double toleranceBefore, double toleranceAfter)
{
m_page->send(Messages::PlaybackSessionManager::SeekToTime(contextId, time), m_page->pageID());
m_page->send(Messages::PlaybackSessionManager::SeekToTime(contextId, time, toleranceBefore, toleranceAfter), m_page->pageID());
}

void PlaybackSessionManagerProxy::fastSeek(uint64_t contextId, double time)
@@ -146,7 +146,7 @@ class PlaybackSessionManager : public RefCounted<PlaybackSessionManager>, privat
void togglePlayState(uint64_t contextId);
void beginScrubbing(uint64_t contextId);
void endScrubbing(uint64_t contextId);
void seekToTime(uint64_t contextId, double time);
void seekToTime(uint64_t contextId, double time, double toleranceBefore, double toleranceAfter);
void fastSeek(uint64_t contextId, double time);
void beginScanningForward(uint64_t contextId);
void beginScanningBackward(uint64_t contextId);
@@ -28,7 +28,7 @@ messages -> PlaybackSessionManager {
TogglePlayState(uint64_t contextId)
BeginScrubbing(uint64_t contextId)
EndScrubbing(uint64_t contextId)
SeekToTime(uint64_t contextId, double time)
SeekToTime(uint64_t contextId, double time, double toleranceBefore, double toleranceAfter)
FastSeek(uint64_t contextId, double time)
BeginScanningForward(uint64_t contextId)
BeginScanningBackward(uint64_t contextId)
@@ -409,10 +409,10 @@ static uint64_t nextContextId()
ensureModel(contextId).endScrubbing();
}

void PlaybackSessionManager::seekToTime(uint64_t contextId, double time)
void PlaybackSessionManager::seekToTime(uint64_t contextId, double time, double toleranceBefore, double toleranceAfter)
{
UserGestureIndicator indicator(ProcessingUserGesture);
ensureModel(contextId).seekToTime(time);
ensureModel(contextId).seekToTime(time, toleranceBefore, toleranceAfter);
}

void PlaybackSessionManager::fastSeek(uint64_t contextId, double time)

0 comments on commit 6bb8e5e

Please sign in to comment.