Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MSE] Remove need for SourceBufferPrivate to query MediaSource duration #21256

Conversation

jyavenard
Copy link
Member

@jyavenard jyavenard commented Dec 4, 2023

adb77f8

[MSE] Remove need for SourceBufferPrivate to query MediaSource duration
https://bugs.webkit.org/show_bug.cgi?id=265778
rdar://119114938

Reviewed by Youenn Fablet.

We notify each SourceBufferPrivate that the MediaSource duration has changed
and use this cache value instead.

Covered by existing tests, no change in observable behaviour.

* Source/WebCore/Modules/mediasource/MediaSource.cpp:
(WebCore::MediaSource::MediaSource):
(WebCore::MediaSource::hasFutureTime):
(WebCore::MediaSource::setDurationInternal):
* Source/WebCore/Modules/mediasource/MediaSource.h:
* Source/WebCore/platform/graphics/MediaSourcePrivate.cpp:
(WebCore::MediaSourcePrivate::hasFutureTime const):
We don't need to pass the duration nor the buffered range as the MediaSourcePrivate owns this information anyway.
(WebCore::MediaSourcePrivate::duration const):
(WebCore::MediaSourcePrivate::durationChanged):
* Source/WebCore/platform/graphics/MediaSourcePrivate.h:
* Source/WebCore/platform/graphics/MediaSourcePrivateClient.h:
* Source/WebCore/platform/graphics/SourceBufferPrivate.cpp:
(WebCore::SourceBufferPrivate::mediaSourceDuration const):
Rename duration() to mediaSourceDuration() to remove ambiguity as to which duration this is related to.
(WebCore::SourceBufferPrivate::append):
(WebCore::SourceBufferPrivate::duration const): Deleted.
* Source/WebCore/platform/graphics/SourceBufferPrivate.h:
(WebCore::SourceBufferPrivate::setMediaSourceDuration):
* Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm:
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::currentMediaTimeMayProgress const):
* Source/WebCore/platform/graphics/avfoundation/objc/MediaSourcePrivateAVFObjC.mm:
(WebCore::MediaSourcePrivateAVFObjC::durationChanged):
* Source/WebCore/platform/graphics/gstreamer/mse/MediaPlayerPrivateGStreamerMSE.cpp:
(WebCore::MediaPlayerPrivateGStreamerMSE::load):
(WebCore::MediaPlayerPrivateGStreamerMSE::doSeek):
(WebCore::MediaPlayerPrivateGStreamerMSE::buffered const):
(WebCore::MediaPlayerPrivateGStreamerMSE::sourceSetup):
(WebCore::MediaPlayerPrivateGStreamerMSE::isTimeBuffered const):
(WebCore::MediaPlayerPrivateGStreamerMSE::durationChanged):
* Source/WebCore/platform/graphics/gstreamer/mse/MediaPlayerPrivateGStreamerMSE.h: remove need to keep reference to MediaSourcePrivateClient,
it was an API violation for the MediaPlayerPrivate to talk to the MediaSourcePrivateClient, this interface is reserved for the MediaSourcePrivate to talk to the MediaSource.
The MediaPlayerPrivateGStreamerMSE already contains a strong reference to the MediaSourcePrivate so we query it directly instead.
(The MediaSourcePrivateClient would have queried its private anyway)
(WebCore::MediaPlayerPrivateGStreamerMSE::mediaSourcePrivateClient): Deleted.
* Source/WebCore/platform/mock/mediasource/MockMediaPlayerMediaSource.cpp:
(WebCore::MockMediaPlayerMediaSource::currentMediaTimeMayProgress const):
* Source/WebCore/platform/mock/mediasource/MockMediaSourcePrivate.cpp:
(WebCore::MockMediaSourcePrivate::durationChanged):
* Source/WebKit/GPUProcess/media/RemoteMediaSourceProxy.cpp:
(WebKit::RemoteMediaSourceProxy::durationChanged):
(WebKit::RemoteMediaSourceProxy::duration const): Deleted.
* Source/WebKit/GPUProcess/media/RemoteMediaSourceProxy.h:

Canonical link: https://commits.webkit.org/271514@main

a401e56

Misc iOS, tvOS & watchOS macOS Linux Windows
βœ… πŸ§ͺ style βœ… πŸ›  ios βœ… πŸ›  mac βœ… πŸ›  wpe βœ… πŸ›  wincairo
βœ… πŸ§ͺ bindings βœ… πŸ›  ios-sim βœ… πŸ›  mac-AS-debug βœ… πŸ§ͺ wpe-wk2
βœ… πŸ§ͺ webkitperl βœ… πŸ§ͺ ios-wk2 βœ… πŸ§ͺ api-mac βœ… πŸ§ͺ api-wpe
βœ… πŸ§ͺ ios-wk2-wpt βœ… πŸ§ͺ mac-wk1 βœ… πŸ›  gtk
βœ… πŸ§ͺ api-ios βœ… πŸ§ͺ mac-wk2 βœ… πŸ§ͺ gtk-wk2
βœ… πŸ›  tv βœ… πŸ§ͺ mac-AS-debug-wk2 ❌ πŸ§ͺ api-gtk
βœ… πŸ›  tv-sim
βœ… πŸ›  πŸ§ͺ merge βœ… πŸ›  watch
βœ… πŸ›  watch-sim

@jyavenard jyavenard requested a review from philn as a code owner December 4, 2023 06:33
@jyavenard jyavenard self-assigned this Dec 4, 2023
@jyavenard jyavenard added the Media Bugs related to the HTML 5 Media elements. label Dec 4, 2023
@webkit-ews-buildbot webkit-ews-buildbot added the merging-blocked Applied to prevent a change from being merged label Dec 4, 2023
@jyavenard jyavenard removed the merging-blocked Applied to prevent a change from being merged label Dec 4, 2023
@jyavenard jyavenard force-pushed the eng/MSE-Remove-need-for-SourceBufferPrivate-to-query-MediaSource-duration branch from 7288f22 to a401e56 Compare December 4, 2023 07:31
@@ -129,6 +130,8 @@ class SourceBufferPrivate
WEBCORE_EXPORT void setClient(SourceBufferPrivateClient&);
WEBCORE_EXPORT void detach();

void setMediaSourceDuration(const MediaTime& duration) { m_mediaSourceDuration = duration; }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could be MediaTime, since it is basically smaller than a uint64_t

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not really.
a MediaTime is :

    union {
        int64_t m_timeValue;
        double m_timeValueAsDouble;
    };
    uint32_t m_timeScale;
    uint8_t m_timeFlags;

so it's 16 bytes as uint8_t would take a word.

@jyavenard jyavenard added the merge-queue Applied to send a pull request to merge-queue label Dec 4, 2023
https://bugs.webkit.org/show_bug.cgi?id=265778
rdar://119114938

Reviewed by Youenn Fablet.

We notify each SourceBufferPrivate that the MediaSource duration has changed
and use this cache value instead.

Covered by existing tests, no change in observable behaviour.

* Source/WebCore/Modules/mediasource/MediaSource.cpp:
(WebCore::MediaSource::MediaSource):
(WebCore::MediaSource::hasFutureTime):
(WebCore::MediaSource::setDurationInternal):
* Source/WebCore/Modules/mediasource/MediaSource.h:
* Source/WebCore/platform/graphics/MediaSourcePrivate.cpp:
(WebCore::MediaSourcePrivate::hasFutureTime const):
We don't need to pass the duration nor the buffered range as the MediaSourcePrivate owns this information anyway.
(WebCore::MediaSourcePrivate::duration const):
(WebCore::MediaSourcePrivate::durationChanged):
* Source/WebCore/platform/graphics/MediaSourcePrivate.h:
* Source/WebCore/platform/graphics/MediaSourcePrivateClient.h:
* Source/WebCore/platform/graphics/SourceBufferPrivate.cpp:
(WebCore::SourceBufferPrivate::mediaSourceDuration const):
Rename duration() to mediaSourceDuration() to remove ambiguity as to which duration this is related to.
(WebCore::SourceBufferPrivate::append):
(WebCore::SourceBufferPrivate::duration const): Deleted.
* Source/WebCore/platform/graphics/SourceBufferPrivate.h:
(WebCore::SourceBufferPrivate::setMediaSourceDuration):
* Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm:
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::currentMediaTimeMayProgress const):
* Source/WebCore/platform/graphics/avfoundation/objc/MediaSourcePrivateAVFObjC.mm:
(WebCore::MediaSourcePrivateAVFObjC::durationChanged):
* Source/WebCore/platform/graphics/gstreamer/mse/MediaPlayerPrivateGStreamerMSE.cpp:
(WebCore::MediaPlayerPrivateGStreamerMSE::load):
(WebCore::MediaPlayerPrivateGStreamerMSE::doSeek):
(WebCore::MediaPlayerPrivateGStreamerMSE::buffered const):
(WebCore::MediaPlayerPrivateGStreamerMSE::sourceSetup):
(WebCore::MediaPlayerPrivateGStreamerMSE::isTimeBuffered const):
(WebCore::MediaPlayerPrivateGStreamerMSE::durationChanged):
* Source/WebCore/platform/graphics/gstreamer/mse/MediaPlayerPrivateGStreamerMSE.h: remove need to keep reference to MediaSourcePrivateClient,
it was an API violation for the MediaPlayerPrivate to talk to the MediaSourcePrivateClient, this interface is reserved for the MediaSourcePrivate to talk to the MediaSource.
The MediaPlayerPrivateGStreamerMSE already contains a strong reference to the MediaSourcePrivate so we query it directly instead.
(The MediaSourcePrivateClient would have queried its private anyway)
(WebCore::MediaPlayerPrivateGStreamerMSE::mediaSourcePrivateClient): Deleted.
* Source/WebCore/platform/mock/mediasource/MockMediaPlayerMediaSource.cpp:
(WebCore::MockMediaPlayerMediaSource::currentMediaTimeMayProgress const):
* Source/WebCore/platform/mock/mediasource/MockMediaSourcePrivate.cpp:
(WebCore::MockMediaSourcePrivate::durationChanged):
* Source/WebKit/GPUProcess/media/RemoteMediaSourceProxy.cpp:
(WebKit::RemoteMediaSourceProxy::durationChanged):
(WebKit::RemoteMediaSourceProxy::duration const): Deleted.
* Source/WebKit/GPUProcess/media/RemoteMediaSourceProxy.h:

Canonical link: https://commits.webkit.org/271514@main
@webkit-commit-queue webkit-commit-queue force-pushed the eng/MSE-Remove-need-for-SourceBufferPrivate-to-query-MediaSource-duration branch from a401e56 to adb77f8 Compare December 4, 2023 23:13
@webkit-commit-queue webkit-commit-queue merged commit adb77f8 into WebKit:main Dec 4, 2023
@webkit-commit-queue
Copy link
Collaborator

Committed 271514@main (adb77f8): https://commits.webkit.org/271514@main

Reviewed commits have been landed. Closing PR #21256 and removing active labels.

@webkit-commit-queue webkit-commit-queue removed the merge-queue Applied to send a pull request to merge-queue label Dec 4, 2023
@jyavenard jyavenard deleted the eng/MSE-Remove-need-for-SourceBufferPrivate-to-query-MediaSource-duration branch February 1, 2024 04:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Media Bugs related to the HTML 5 Media elements.
Projects
None yet
5 participants