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

Switch to alternate <source> element for AirPlay when necessary #5380

Merged

Conversation

eric-carlson
Copy link
Contributor

@eric-carlson eric-carlson commented Oct 14, 2022

4ec10f6

Switch to alternate <source> element for AirPlay when necessary
https://bugs.webkit.org/show_bug.cgi?id=246466
<rdar://101136233>

Reviewed by Jer Noble.

* LayoutTests/media/media-source/remoteplayback-from-source-element-expected.txt: Added.
* LayoutTests/media/media-source/remoteplayback-from-source-element.html: Added.
* LayoutTests/TestExpectations: New test skipped everywhere.
* LayoutTests/platform/mac/TestExpectations: New test enabled.

* Source/WebCore/Modules/remoteplayback/RemotePlayback.cpp:
(WebCore::RemotePlayback::watchAvailability): Add runtime logging.
(WebCore::RemotePlayback::cancelWatchAvailability): Ditto.
(WebCore::RemotePlayback::prompt): Ditto.
(WebCore::RemotePlayback::shouldPlayToRemoteTargetChanged): Ditto.
(WebCore::RemotePlayback::setState): Ditto.
(WebCore::RemotePlayback::disconnect): Ditto.
(WebCore::RemotePlayback::availabilityChanged): Ditto.
(WebCore::RemotePlayback::setLogger):  Ditto.
(WebCore::RemotePlayback::logChannel const): Ditto.
* Source/WebCore/Modules/remoteplayback/RemotePlayback.h:

* Source/WebCore/html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::HTMLMediaElement): Set remote logger.
(WebCore::HTMLMediaElement::checkPlaybackTargetCompatibility): If loaded from a <source>
element and is another <source> uses a media engine that supports remote playback, try
loading that.
(WebCore::HTMLMediaElement::loadResource): Don't bother trying MSE, MediaStream, or blob
if the load requires remote playback.
(WebCore::HTMLMediaElement::applyConfiguration): Apply the stored configuration.
(WebCore::HTMLMediaElement::setReadyState): Apply the remote configuration once
HAVE_FUTURE_DATA is reached.
(WebCore::HTMLMediaElement::selectNextSourceChild): Set parameter `requiresRemotePlayback`
field.
(WebCore::HTMLMediaElement::clearMediaPlayer): Force a target availability event.
(WebCore::HTMLMediaElement::wirelessRoutesAvailableDidChange): Only post availability event
when availability actually changes.
(WebCore::HTMLMediaElement::setIsPlayingToWirelessTarget):
(WebCore::HTMLMediaElement::enqueuePlaybackTargetAvailabilityChangedEvent): Add parameter
so we don't necessarily post events when availability doesn't change.
(WebCore::HTMLMediaElement::addEventListener): Force a target availability event.
* Source/WebCore/html/HTMLMediaElement.h:

* Source/WebCore/html/MediaElementSession.cpp:
(WebCore::MediaElementSession::showPlaybackTargetPicker): Always log.

* Source/WebCore/platform/graphics/MediaPlayer.cpp:
(WebCore::MediaPlayer::load): Add `requiresRemotePlayback` parameter.
* Source/WebCore/platform/graphics/MediaPlayer.h:
(WebCore::MediaEngineSupportParameters::encode const):
(WebCore::MediaEngineSupportParameters::decode):

* Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm:
(WebCore::MediaPlayerPrivateMediaStreamAVFObjC::supportsType): Consider new support field.

* Source/WebCore/platform/graphics/cocoa/MediaPlayerPrivateWebM.mm:
(WebCore::MediaPlayerPrivateWebM::supportsType): Ditto.

* Source/WebCore/testing/Internals.cpp:
(WebCore::Internals::setMockMediaPlaybackTargetPickerEnabled): NULL-check frame and page.
(WebCore::Internals::setMockMediaPlaybackTargetPickerState): Ditto.
(WebCore::Internals::mockMediaPlaybackTargetPickerDismissPopup): Ditto.

* Source/WebKit/GPUProcess/media/RemoteMediaPlayerProxy.cpp:
(WebKit::RemoteMediaPlayerProxy::load): Add "requires remote playback" parameter.
* Source/WebKit/GPUProcess/media/RemoteMediaPlayerProxy.h:
* Source/WebKit/GPUProcess/media/RemoteMediaPlayerProxy.messages.in: Ditto.

* Source/WebKit/WebProcess/GPU/media/MediaPlayerPrivateRemote.cpp:
(WebKit::MediaPlayerPrivateRemote::load): Ditto.

* Source/WebKit/WebProcess/GPU/media/RemoteMediaPlayerMIMETypeCache.cpp:
(WebKit::RemoteMediaPlayerMIMETypeCache::supportsTypeAndCodecs): Ditto.
* Source/WebKit/WebProcess/GPU/media/RemoteMediaPlayerMIMETypeCache.h:

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

4870c57

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

@eric-carlson eric-carlson self-assigned this Oct 14, 2022
@eric-carlson eric-carlson added Media Bugs related to the HTML 5 Media elements. WebKit Nightly Build labels Oct 14, 2022
@webkit-ews-buildbot webkit-ews-buildbot added the merging-blocked Applied to prevent a change from being merged label Oct 14, 2022
Source/WebCore/Modules/remoteplayback/RemotePlayback.h Outdated Show resolved Hide resolved
Source/WebCore/Modules/remoteplayback/RemotePlayback.h Outdated Show resolved Hide resolved
ERROR_LOG(LOGIDENTIFIER, "player incompatible after ", delta.value(), ", calling setShouldPlayToPlaybackTarget(false)");
m_failedToPlayToWirelessTarget = true;
m_remotePlaybackConfiguration = { };
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this be: m_remotePlaybackConfiguration = std::nullopt;?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The two are equivalent

Source/WebCore/html/HTMLMediaElement.cpp Show resolved Hide resolved
Source/WebCore/html/HTMLMediaElement.cpp Outdated Show resolved Hide resolved
@eric-carlson eric-carlson added merge-queue Applied to send a pull request to merge-queue and removed merging-blocked Applied to prevent a change from being merged labels Oct 14, 2022
https://bugs.webkit.org/show_bug.cgi?id=246466
<rdar://101136233>

Reviewed by Jer Noble.

* LayoutTests/media/media-source/remoteplayback-from-source-element-expected.txt: Added.
* LayoutTests/media/media-source/remoteplayback-from-source-element.html: Added.
* LayoutTests/TestExpectations: New test skipped everywhere.
* LayoutTests/platform/mac/TestExpectations: New test enabled.

* Source/WebCore/Modules/remoteplayback/RemotePlayback.cpp:
(WebCore::RemotePlayback::watchAvailability): Add runtime logging.
(WebCore::RemotePlayback::cancelWatchAvailability): Ditto.
(WebCore::RemotePlayback::prompt): Ditto.
(WebCore::RemotePlayback::shouldPlayToRemoteTargetChanged): Ditto.
(WebCore::RemotePlayback::setState): Ditto.
(WebCore::RemotePlayback::disconnect): Ditto.
(WebCore::RemotePlayback::availabilityChanged): Ditto.
(WebCore::RemotePlayback::setLogger):  Ditto.
(WebCore::RemotePlayback::logChannel const): Ditto.
* Source/WebCore/Modules/remoteplayback/RemotePlayback.h:

* Source/WebCore/html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::HTMLMediaElement): Set remote logger.
(WebCore::HTMLMediaElement::checkPlaybackTargetCompatibility): If loaded from a <source>
element and is another <source> uses a media engine that supports remote playback, try
loading that.
(WebCore::HTMLMediaElement::loadResource): Don't bother trying MSE, MediaStream, or blob
if the load requires remote playback.
(WebCore::HTMLMediaElement::applyConfiguration): Apply the stored configuration.
(WebCore::HTMLMediaElement::setReadyState): Apply the remote configuration once
HAVE_FUTURE_DATA is reached.
(WebCore::HTMLMediaElement::selectNextSourceChild): Set parameter `requiresRemotePlayback`
field.
(WebCore::HTMLMediaElement::clearMediaPlayer): Force a target availability event.
(WebCore::HTMLMediaElement::wirelessRoutesAvailableDidChange): Only post availability event
when availability actually changes.
(WebCore::HTMLMediaElement::setIsPlayingToWirelessTarget):
(WebCore::HTMLMediaElement::enqueuePlaybackTargetAvailabilityChangedEvent): Add parameter
so we don't necessarily post events when availability doesn't change.
(WebCore::HTMLMediaElement::addEventListener): Force a target availability event.
* Source/WebCore/html/HTMLMediaElement.h:

* Source/WebCore/html/MediaElementSession.cpp:
(WebCore::MediaElementSession::showPlaybackTargetPicker): Always log.

* Source/WebCore/platform/graphics/MediaPlayer.cpp:
(WebCore::MediaPlayer::load): Add `requiresRemotePlayback` parameter.
* Source/WebCore/platform/graphics/MediaPlayer.h:
(WebCore::MediaEngineSupportParameters::encode const):
(WebCore::MediaEngineSupportParameters::decode):

* Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm:
(WebCore::MediaPlayerPrivateMediaStreamAVFObjC::supportsType): Consider new support field.

* Source/WebCore/platform/graphics/cocoa/MediaPlayerPrivateWebM.mm:
(WebCore::MediaPlayerPrivateWebM::supportsType): Ditto.

* Source/WebCore/testing/Internals.cpp:
(WebCore::Internals::setMockMediaPlaybackTargetPickerEnabled): NULL-check frame and page.
(WebCore::Internals::setMockMediaPlaybackTargetPickerState): Ditto.
(WebCore::Internals::mockMediaPlaybackTargetPickerDismissPopup): Ditto.

* Source/WebKit/GPUProcess/media/RemoteMediaPlayerProxy.cpp:
(WebKit::RemoteMediaPlayerProxy::load): Add "requires remote playback" parameter.
* Source/WebKit/GPUProcess/media/RemoteMediaPlayerProxy.h:
* Source/WebKit/GPUProcess/media/RemoteMediaPlayerProxy.messages.in: Ditto.

* Source/WebKit/WebProcess/GPU/media/MediaPlayerPrivateRemote.cpp:
(WebKit::MediaPlayerPrivateRemote::load): Ditto.

* Source/WebKit/WebProcess/GPU/media/RemoteMediaPlayerMIMETypeCache.cpp:
(WebKit::RemoteMediaPlayerMIMETypeCache::supportsTypeAndCodecs): Ditto.
* Source/WebKit/WebProcess/GPU/media/RemoteMediaPlayerMIMETypeCache.h:

Canonical link: https://commits.webkit.org/255624@main
@webkit-commit-queue
Copy link
Collaborator

Committed 255624@main (4ec10f6): https://commits.webkit.org/255624@main

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

@webkit-commit-queue webkit-commit-queue removed the merge-queue Applied to send a pull request to merge-queue label Oct 17, 2022
@webkit-commit-queue webkit-commit-queue merged commit 4ec10f6 into WebKit:main Oct 17, 2022
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