Skip to content
Permalink
Browse files
[GPUP-MSE] Implement time changed callback
https://bugs.webkit.org/show_bug.cgi?id=225485
<rdar://problem/77625992>

Reviewed by Jer Noble.

Implement MediaPlayerPrivateMediaSourceAVFObjC::setCurrentTimeDidChangeCallback so
the GPU process doesn't have to poll currentTime.

No change in functionality.

* platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.h:
* platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm:
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::MediaPlayerPrivateMediaSourceAVFObjC):
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::~MediaPlayerPrivateMediaSourceAVFObjC):
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::setCurrentTimeDidChangeCallback):


Canonical link: https://commits.webkit.org/237539@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@277272 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
eric-carlson committed May 10, 2021
1 parent 8e0a5c7 commit 8334829c08e376dd9a9a66aba0552fdca1af7da3
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 0 deletions.
@@ -1,3 +1,22 @@
2021-05-10 Eric Carlson <eric.carlson@apple.com>

[GPUP-MSE] Implement time changed callback
https://bugs.webkit.org/show_bug.cgi?id=225485
<rdar://problem/77625992>

Reviewed by Jer Noble.

Implement MediaPlayerPrivateMediaSourceAVFObjC::setCurrentTimeDidChangeCallback so
the GPU process doesn't have to poll currentTime.

No change in functionality.

* platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.h:
* platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm:
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::MediaPlayerPrivateMediaSourceAVFObjC):
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::~MediaPlayerPrivateMediaSourceAVFObjC):
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::setCurrentTimeDidChangeCallback):

2021-05-10 Devin Rousso <drousso@apple.com>

Add support for a `media` attribute on `<meta name="theme-color" content="...">`
@@ -263,6 +263,8 @@ class MediaPlayerPrivateMediaSourceAVFObjC

bool isVideoOutputAvailable() const;

bool setCurrentTimeDidChangeCallback(MediaPlayer::CurrentTimeDidChangeCallback&&) final;

friend class MediaSourcePrivateAVFObjC;

struct PendingSeek {
@@ -295,6 +297,8 @@ class MediaPlayerPrivateMediaSourceAVFObjC
HashMap<RetainPtr<CFTypeRef>, AudioRendererProperties> m_sampleBufferAudioRendererMap;
RetainPtr<AVSampleBufferRenderSynchronizer> m_synchronizer;
ALLOW_NEW_API_WITHOUT_GUARDS_END
mutable MediaPlayer::CurrentTimeDidChangeCallback m_currentTimeDidChangeCallback;
RetainPtr<id> m_timeChangedObserver;
RetainPtr<id> m_timeJumpedObserver;
RetainPtr<id> m_durationObserver;
RetainPtr<id> m_performTaskObserver;
@@ -169,6 +169,9 @@ static void CMTimebaseEffectiveRateChangedCallback(CMNotificationCenterRef, cons

if (m_pendingSeek)
seekInternal();

if (m_currentTimeDidChangeCallback)
m_currentTimeDidChangeCallback(CMTIME_IS_NUMERIC(time) ? PAL::toMediaTime(time) : MediaTime::zeroTime());
}];
}

@@ -180,6 +183,8 @@ static void CMTimebaseEffectiveRateChangedCallback(CMNotificationCenterRef, cons

if (m_timeJumpedObserver)
[m_synchronizer removeTimeObserver:m_timeJumpedObserver.get()];
if (m_timeChangedObserver)
[m_synchronizer removeTimeObserver:m_timeChangedObserver.get()];
if (m_durationObserver)
[m_synchronizer removeTimeObserver:m_durationObserver.get()];
flushPendingSizeChanges();
@@ -410,6 +415,22 @@ void getSupportedTypes(HashSet<String, ASCIICaseInsensitiveHash>& types) const f
return synchronizerTime;
}

bool MediaPlayerPrivateMediaSourceAVFObjC::setCurrentTimeDidChangeCallback(MediaPlayer::CurrentTimeDidChangeCallback&& callback)
{
m_currentTimeDidChangeCallback = WTFMove(callback);

if (m_currentTimeDidChangeCallback) {
m_timeChangedObserver = [m_synchronizer addPeriodicTimeObserverForInterval:CMTimeMake(1, 10) queue:dispatch_get_main_queue() usingBlock:^(CMTime time) {
if (m_currentTimeDidChangeCallback)
m_currentTimeDidChangeCallback(CMTIME_IS_NUMERIC(time) ? PAL::toMediaTime(time) : MediaTime::zeroTime());
}];

} else
m_timeChangedObserver = nullptr;

return true;
}

MediaTime MediaPlayerPrivateMediaSourceAVFObjC::startTime() const
{
return MediaTime::zeroTime();

0 comments on commit 8334829

Please sign in to comment.