Diff
Modified: trunk/LayoutTests/ChangeLog (289696 => 289697)
--- trunk/LayoutTests/ChangeLog 2022-02-12 16:08:49 UTC (rev 289696)
+++ trunk/LayoutTests/ChangeLog 2022-02-12 18:16:51 UTC (rev 289697)
@@ -1,3 +1,19 @@
+2022-02-12 Jer Noble <[email protected]>
+
+ Add settings to restrict media containers and codecs when in Captive Portal mode
+ https://bugs.webkit.org/show_bug.cgi?id=236245
+
+ Reviewed by Eric Carlson.
+
+ * media/media-allowed-codecs-expected.txt: Added.
+ * media/media-allowed-codecs.html: Added.
+ * media/media-allowed-containers-expected.txt: Added.
+ * media/media-allowed-containers.html: Added.
+ * media/media-source/media-source-allowed-codecs-expected.txt: Added.
+ * media/media-source/media-source-allowed-codecs.html: Added.
+ * media/media-source/media-source-allowed-containers-expected.txt: Added.
+ * media/media-source/media-source-allowed-containers.html: Added.
+
2022-02-12 Rob Buis <[email protected]>
Suppress style invalidation when matching :checked
Added: trunk/LayoutTests/media/media-allowed-codecs-expected.txt (0 => 289697)
--- trunk/LayoutTests/media/media-allowed-codecs-expected.txt (rev 0)
+++ trunk/LayoutTests/media/media-allowed-codecs-expected.txt 2022-02-12 18:16:51 UTC (rev 289697)
@@ -0,0 +1,33 @@
+RUN(internals.settings.setAllowedMediaVideoCodecIDs(null))
+RUN(internals.settings.setAllowedMediaAudioCodecIDs(null))
+RUN(internals.settings.setAllowedMediaCodecTypes(null))
+EXPECTED (video.canPlayType("video/mp4; codecs=avc1") == 'probably') OK
+EXPECTED (video.canPlayType("video/mp4; codecs=mp4v") == 'probably') OK
+RUN(video.src = ""
+EVENT(canplay) OK
+RUN(internals.settings.setAllowedMediaVideoCodecIDs("avc1"))
+RUN(internals.settings.setAllowedMediaAudioCodecIDs("aac "))
+RUN(internals.settings.setAllowedMediaCodecTypes("avc1,mp4a.40"))
+EXPECTED (video.canPlayType("video/mp4; codecs=avc1") == 'probably') OK
+EXPECTED (video.canPlayType("video/mp4; codecs=mp4v") == '') OK
+RUN(video.src = ""
+EVENT(canplay) OK
+RUN(internals.settings.setAllowedMediaVideoCodecIDs("vp09"))
+RUN(internals.settings.setAllowedMediaAudioCodecIDs("opus"))
+RUN(internals.settings.setAllowedMediaCodecTypes("vp09,opus"))
+EXPECTED (video.canPlayType("video/mp4; codecs=avc1") == '') OK
+EXPECTED (video.canPlayType("video/mp4; codecs=mp4v") == '') OK
+RUN(video.src = ""
+EVENT(error) OK
+RUN(internals.settings.setAllowedMediaVideoCodecIDs("avc1"))
+RUN(internals.settings.setAllowedMediaAudioCodecIDs("opus"))
+RUN(internals.settings.setAllowedMediaCodecTypes("avc1,opus"))
+RUN(video.src = ""
+EVENT(error) OK
+RUN(internals.settings.setAllowedMediaVideoCodecIDs("vp09"))
+RUN(internals.settings.setAllowedMediaAudioCodecIDs("aac "))
+RUN(internals.settings.setAllowedMediaCodecTypes("vp09,mp4a.40"))
+RUN(video.src = ""
+EVENT(error) OK
+END OF TEST
+
Added: trunk/LayoutTests/media/media-allowed-codecs.html (0 => 289697)
--- trunk/LayoutTests/media/media-allowed-codecs.html (rev 0)
+++ trunk/LayoutTests/media/media-allowed-codecs.html 2022-02-12 18:16:51 UTC (rev 289697)
@@ -0,0 +1,60 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <title>media-allowed-codecs</title>
+ <script src=""
+ <script>
+ window.addEventListener('load', async event => {
+ if (!window.internals) {
+ failTest('Requires window.internals');
+ return;
+ }
+
+ video = document.createElement('video');
+ run('internals.settings.setAllowedMediaVideoCodecIDs(null)');
+ run('internals.settings.setAllowedMediaAudioCodecIDs(null)');
+ run('internals.settings.setAllowedMediaCodecTypes(null)');
+ testExpected('video.canPlayType("video/mp4; codecs=avc1")', 'probably');
+ testExpected('video.canPlayType("video/mp4; codecs=mp4v")', 'probably');
+ run('video.src = ""
+ await Promise.race([waitForAndSucceed(video, 'canplay'), waitForAndFail(video, 'error')]);
+
+ video = document.createElement('video');
+ run('internals.settings.setAllowedMediaVideoCodecIDs("avc1")');
+ run('internals.settings.setAllowedMediaAudioCodecIDs("aac ")');
+ run('internals.settings.setAllowedMediaCodecTypes("avc1,mp4a.40")');
+ testExpected('video.canPlayType("video/mp4; codecs=avc1")', 'probably');
+ testExpected('video.canPlayType("video/mp4; codecs=mp4v")', '');
+ run('video.src = ""
+ await Promise.race([waitForAndSucceed(video, 'canplay'), waitForAndFail(video, 'error')]);
+
+ video = document.createElement('video');
+ run('internals.settings.setAllowedMediaVideoCodecIDs("vp09")');
+ run('internals.settings.setAllowedMediaAudioCodecIDs("opus")');
+ run('internals.settings.setAllowedMediaCodecTypes("vp09,opus")');
+ testExpected('video.canPlayType("video/mp4; codecs=avc1")', '');
+ testExpected('video.canPlayType("video/mp4; codecs=mp4v")', '');
+ run('video.src = ""
+ await Promise.race([waitForAndSucceed(video, 'error'), waitForAndFail(video, 'canplay')]);
+
+ video = document.createElement('video');
+ run('internals.settings.setAllowedMediaVideoCodecIDs("avc1")');
+ run('internals.settings.setAllowedMediaAudioCodecIDs("opus")');
+ run('internals.settings.setAllowedMediaCodecTypes("avc1,opus")');
+ run('video.src = ""
+ await Promise.race([waitForAndSucceed(video, 'error'), waitForAndFail(video, 'canplay')]);
+
+ video = document.createElement('video');
+ run('internals.settings.setAllowedMediaVideoCodecIDs("vp09")');
+ run('internals.settings.setAllowedMediaAudioCodecIDs("aac ")');
+ run('internals.settings.setAllowedMediaCodecTypes("vp09,mp4a.40")');
+ run('video.src = ""
+ await Promise.race([waitForAndSucceed(video, 'error'), waitForAndFail(video, 'canplay')]);
+
+ endTest();
+ });
+ </script>
+</head>
+<body>
+</body>
+</html>
\ No newline at end of file
Added: trunk/LayoutTests/media/media-allowed-containers-expected.txt (0 => 289697)
--- trunk/LayoutTests/media/media-allowed-containers-expected.txt (rev 0)
+++ trunk/LayoutTests/media/media-allowed-containers-expected.txt 2022-02-12 18:16:51 UTC (rev 289697)
@@ -0,0 +1,17 @@
+RUN(internals.settings.setAllowedMediaContainerTypes(null))
+EXPECTED (video.canPlayType("audio/mp3") == 'maybe') OK
+EXPECTED (video.canPlayType("video/mp4") == 'maybe') OK
+RUN(video.src = ""
+EVENT(canplay) OK
+RUN(internals.settings.setAllowedMediaContainerTypes("audio/mp3"))
+EXPECTED (video.canPlayType("audio/mp3") == 'maybe') OK
+EXPECTED (video.canPlayType("video/mp4") == '') OK
+RUN(video.src = ""
+EVENT(error) OK
+RUN(internals.settings.setAllowedMediaContainerTypes("video/mp4"))
+EXPECTED (video.canPlayType("audio/mp3") == '') OK
+EXPECTED (video.canPlayType("video/mp4") == 'maybe') OK
+RUN(video.src = ""
+EVENT(canplay) OK
+END OF TEST
+
Added: trunk/LayoutTests/media/media-allowed-containers.html (0 => 289697)
--- trunk/LayoutTests/media/media-allowed-containers.html (rev 0)
+++ trunk/LayoutTests/media/media-allowed-containers.html 2022-02-12 18:16:51 UTC (rev 289697)
@@ -0,0 +1,40 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <title>media-allowed-containers</title>
+ <script src=""
+ <script>
+ window.addEventListener('load', async event => {
+ if (!window.internals) {
+ failTest('Requires window.internals');
+ return;
+ }
+
+ video = document.createElement('video');
+ run('internals.settings.setAllowedMediaContainerTypes(null)');
+ testExpected('video.canPlayType("audio/mp3")', 'maybe');
+ testExpected('video.canPlayType("video/mp4")', 'maybe');
+ run('video.src = ""
+ await Promise.race([waitForAndSucceed(video, 'canplay'), waitForAndFail(video, 'error')]);
+
+ video = document.createElement('video');
+ run('internals.settings.setAllowedMediaContainerTypes("audio/mp3")');
+ testExpected('video.canPlayType("audio/mp3")', 'maybe');
+ testExpected('video.canPlayType("video/mp4")', '');
+ run('video.src = ""
+ await Promise.race([waitForAndSucceed(video, 'error'), waitForAndFail(video, 'canplay')]);
+
+ video = document.createElement('video');
+ run('internals.settings.setAllowedMediaContainerTypes("video/mp4")');
+ testExpected('video.canPlayType("audio/mp3")', '');
+ testExpected('video.canPlayType("video/mp4")', 'maybe');
+ run('video.src = ""
+ await Promise.race([waitForAndSucceed(video, 'canplay'), waitForAndFail(video, 'error')]);
+
+ endTest();
+ });
+ </script>
+</head>
+<body>
+</body>
+</html>
\ No newline at end of file
Added: trunk/LayoutTests/media/media-source/media-source-allowed-codecs-expected.txt (0 => 289697)
--- trunk/LayoutTests/media/media-source/media-source-allowed-codecs-expected.txt (rev 0)
+++ trunk/LayoutTests/media/media-source/media-source-allowed-codecs-expected.txt 2022-02-12 18:16:51 UTC (rev 289697)
@@ -0,0 +1,18 @@
+RUN(internals.settings.setAllowedMediaVideoCodecIDs(null))
+EXPECTED (MediaSource.isTypeSupported("video/mp4; codecs=avc1") == 'true') OK
+EXPECTED (MediaSource.isTypeSupported("video/mp4; codecs=mp4v") == 'true') OK
+RUN(internals.settings.setAllowedMediaVideoCodecIDs("avc1"))
+RUN(internals.settings.setAllowedMediaAudioCodecIDs("aac "))
+RUN(internals.settings.setAllowedMediaCodecTypes("avc1,mp4a.40"))
+EXPECTED (MediaSource.isTypeSupported("video/mp4; codecs=avc1") == 'true') OK
+EXPECTED (MediaSource.isTypeSupported("video/mp4; codecs=mp4v") == 'false') OK
+EVENT(sourceopen)
+RUN(sourceBuffer = mediaSource.addSourceBuffer("video/mp4; codecs=avc1"))
+TEST(sourceBuffer.changeType("video/mp4; codecs=mp4v")) THROWS("NotSupportedError: The operation is not supported.") OK
+RUN(internals.settings.setAllowedMediaVideoCodecIDs("vp09"))
+RUN(internals.settings.setAllowedMediaAudioCodecIDs("opus"))
+RUN(internals.settings.setAllowedMediaCodecTypes("vp09,opus"))
+EXPECTED (MediaSource.isTypeSupported("video/mp4; codecs=avc1") == 'false') OK
+TEST(mediaSource.addSourceBuffer("video/mp4; codecs=avc1")) THROWS("NotSupportedError: The operation is not supported.") OK
+END OF TEST
+
Added: trunk/LayoutTests/media/media-source/media-source-allowed-codecs.html (0 => 289697)
--- trunk/LayoutTests/media/media-source/media-source-allowed-codecs.html (rev 0)
+++ trunk/LayoutTests/media/media-source/media-source-allowed-codecs.html 2022-02-12 18:16:51 UTC (rev 289697)
@@ -0,0 +1,47 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <title>media-source-allowed-containers</title>
+ <script src=""
+ <script>
+ window.addEventListener('load', async event => {
+ if (!window.internals) {
+ failTest('Requires window.internals');
+ return;
+ }
+
+ video = document.createElement('video');
+
+ run('internals.settings.setAllowedMediaVideoCodecIDs(null)');
+ testExpected('MediaSource.isTypeSupported("video/mp4; codecs=avc1")', true);
+ testExpected('MediaSource.isTypeSupported("video/mp4; codecs=mp4v")', true);
+
+ run('internals.settings.setAllowedMediaVideoCodecIDs("avc1")');
+ run('internals.settings.setAllowedMediaAudioCodecIDs("aac ")');
+ run('internals.settings.setAllowedMediaCodecTypes("avc1,mp4a.40")');
+
+ testExpected('MediaSource.isTypeSupported("video/mp4; codecs=avc1")', true);
+ testExpected('MediaSource.isTypeSupported("video/mp4; codecs=mp4v")', false);
+
+ mediaSource = new MediaSource();
+ video.srcObject = mediaSource;
+ await waitFor(mediaSource, 'sourceopen');
+
+ run('sourceBuffer = mediaSource.addSourceBuffer("video/mp4; codecs=avc1")');
+ testException('sourceBuffer.changeType("video/mp4; codecs=mp4v")', '"NotSupportedError: The operation is not supported."');
+
+ run('internals.settings.setAllowedMediaVideoCodecIDs("vp09")');
+ run('internals.settings.setAllowedMediaAudioCodecIDs("opus")');
+ run('internals.settings.setAllowedMediaCodecTypes("vp09,opus")');
+
+ testExpected('MediaSource.isTypeSupported("video/mp4; codecs=avc1")', false);
+
+ testException('mediaSource.addSourceBuffer("video/mp4; codecs=avc1")', '"NotSupportedError: The operation is not supported."');
+
+ endTest();
+ });
+ </script>
+</head>
+<body>
+</body>
+</html>
\ No newline at end of file
Added: trunk/LayoutTests/media/media-source/media-source-allowed-containers-expected.txt (0 => 289697)
--- trunk/LayoutTests/media/media-source/media-source-allowed-containers-expected.txt (rev 0)
+++ trunk/LayoutTests/media/media-source/media-source-allowed-containers-expected.txt 2022-02-12 18:16:51 UTC (rev 289697)
@@ -0,0 +1,8 @@
+RUN(internals.settings.setAllowedMediaContainerTypes(null))
+EXPECTED (MediaSource.isTypeSupported("video/mp4") == 'true') OK
+RUN(internals.settings.setAllowedMediaContainerTypes("video/mp4"))
+EXPECTED (MediaSource.isTypeSupported("video/mp4") == 'true') OK
+RUN(internals.settings.setAllowedMediaContainerTypes("video/webm"))
+EXPECTED (MediaSource.isTypeSupported("video/mp4") == 'false') OK
+END OF TEST
+
Added: trunk/LayoutTests/media/media-source/media-source-allowed-containers.html (0 => 289697)
--- trunk/LayoutTests/media/media-source/media-source-allowed-containers.html (rev 0)
+++ trunk/LayoutTests/media/media-source/media-source-allowed-containers.html 2022-02-12 18:16:51 UTC (rev 289697)
@@ -0,0 +1,30 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <title>media-source-allowed-containers</title>
+ <script src=""
+ <script>
+ window.addEventListener('load', async event => {
+ if (!window.internals) {
+ failTest('Requires window.internals');
+ return;
+ }
+
+ run('internals.settings.setAllowedMediaContainerTypes(null)');
+ testExpected('MediaSource.isTypeSupported("video/mp4")', true);
+
+ video = document.createElement('video');
+ run('internals.settings.setAllowedMediaContainerTypes("video/mp4")');
+ testExpected('MediaSource.isTypeSupported("video/mp4")', true);
+
+ video = document.createElement('video');
+ run('internals.settings.setAllowedMediaContainerTypes("video/webm")');
+ testExpected('MediaSource.isTypeSupported("video/mp4")', false);
+
+ endTest();
+ });
+ </script>
+</head>
+<body>
+</body>
+</html>
\ No newline at end of file
Modified: trunk/LayoutTests/media/video-test.js (289696 => 289697)
--- trunk/LayoutTests/media/video-test.js 2022-02-12 16:08:49 UTC (rev 289696)
+++ trunk/LayoutTests/media/video-test.js 2022-02-12 18:16:51 UTC (rev 289697)
@@ -217,16 +217,32 @@
});
}
-function waitFor(element, type, silent) {
+function waitFor(element, type, silent, success) {
return new Promise(resolve => {
element.addEventListener(type, event => {
- if (!silent)
+ if (silent) {
+ resolve(event);
+ return;
+ }
+
+ if (success !== undefined)
+ logResult(success, `EVENT(${event.type})`);
+ else
consoleWrite(`EVENT(${event.type})`);
+
resolve(event);
}, { once: true });
});
}
+function waitForAndSucceed(element, type) {
+ return waitFor(element, type, false, true);
+}
+
+function waitForAndFail(element, type) {
+ return waitFor(element, type, false, false);
+}
+
function waitForEventOnce(eventName, func, endit)
{
waitForEvent(eventName, func, endit, true)
Modified: trunk/LayoutTests/platform/gtk/TestExpectations (289696 => 289697)
--- trunk/LayoutTests/platform/gtk/TestExpectations 2022-02-12 16:08:49 UTC (rev 289696)
+++ trunk/LayoutTests/platform/gtk/TestExpectations 2022-02-12 18:16:51 UTC (rev 289697)
@@ -1850,3 +1850,5 @@
#////////////////////////////////////////////////////////////////////////////////////////
# These tests require platform support.
+media/media-allowed-codecs.html
+media/media-allowed-containers.html
\ No newline at end of file
Modified: trunk/LayoutTests/platform/mac/TestExpectations (289696 => 289697)
--- trunk/LayoutTests/platform/mac/TestExpectations 2022-02-12 16:08:49 UTC (rev 289696)
+++ trunk/LayoutTests/platform/mac/TestExpectations 2022-02-12 18:16:51 UTC (rev 289697)
@@ -2440,4 +2440,7 @@
[ Catalina BigSur Monterey ] fast/text/locale-shaping-3.html [ Pass ImageOnlyFailure ]
#rdar://80333071
-[ BigSur+ ] compositing/iframes/border-radius-composited-frame.html [ ImageOnlyFailure ]
\ No newline at end of file
+[ BigSur+ ] compositing/iframes/border-radius-composited-frame.html [ ImageOnlyFailure ]
+
+# rdar://84556831
+[ Catalina ] media/media-allowed-containers.html [ Skip ]
\ No newline at end of file
Modified: trunk/Source/WTF/ChangeLog (289696 => 289697)
--- trunk/Source/WTF/ChangeLog 2022-02-12 16:08:49 UTC (rev 289696)
+++ trunk/Source/WTF/ChangeLog 2022-02-12 18:16:51 UTC (rev 289697)
@@ -1,3 +1,12 @@
+2022-02-12 Jer Noble <[email protected]>
+
+ Add settings to restrict media containers and codecs when in Captive Portal mode
+ https://bugs.webkit.org/show_bug.cgi?id=236245
+
+ Reviewed by Eric Carlson.
+
+ * Scripts/Preferences/WebPreferences.yaml:
+
2022-02-12 Eric Carlson <[email protected]>
[macOS] Use system window and screen picker when available
Modified: trunk/Source/WTF/Scripts/Preferences/WebPreferences.yaml (289696 => 289697)
--- trunk/Source/WTF/Scripts/Preferences/WebPreferences.yaml 2022-02-12 16:08:49 UTC (rev 289696)
+++ trunk/Source/WTF/Scripts/Preferences/WebPreferences.yaml 2022-02-12 18:16:51 UTC (rev 289697)
@@ -1326,6 +1326,14 @@
WebCore:
default: -1
+MediaAudioCodecIDsAllowedInCaptivePortalMode:
+ type: String
+ webcoreBinding: none
+ exposed: [ WebKit ]
+ defaultValue:
+ WebKit:
+ default: '"aac ,zaac,qaac,caac,.mp3"'
+
MediaCapabilitiesEnabled:
type: bool
defaultValue:
@@ -1336,6 +1344,30 @@
WebCore:
default: false
+MediaCaptionFormatTypesAllowedInCaptivePortalMode:
+ type: String
+ webcoreBinding: none
+ exposed: [ WebKit ]
+ defaultValue:
+ WebKit:
+ default: '"c608,wvtt"'
+
+MediaCodecTypesAllowedInCaptivePortalMode:
+ type: String
+ webcoreBinding: none
+ exposed: [ WebKit ]
+ defaultValue:
+ WebKit:
+ default: '"mp4a.40,avc1"'
+
+MediaContainerTypesAllowedInCaptivePortalMode:
+ type: String
+ webcoreBinding: none
+ exposed: [ WebKit ]
+ defaultValue:
+ WebKit:
+ default: '"video/mp4,audio/mp4,video/x-m4v,audio/x-m4a,audio/mp3,application/x-mpegURL,vnd.apple.mpegURL"'
+
MediaContentTypesRequiringHardwareSupport:
type: String
webcoreExcludeFromInternalSettings: true
@@ -1455,6 +1487,14 @@
WebCore:
default: false
+MediaVideoCodecIDsAllowedInCaptivePortalMode:
+ type: String
+ webcoreBinding: none
+ exposed: [ WebKit ]
+ defaultValue:
+ WebKit:
+ default: '"avc1,zavc,qavc,cavc"'
+
MenuItemElementEnabled:
type: bool
webcoreBinding: RuntimeEnabledFeatures
Modified: trunk/Source/WebCore/ChangeLog (289696 => 289697)
--- trunk/Source/WebCore/ChangeLog 2022-02-12 16:08:49 UTC (rev 289696)
+++ trunk/Source/WebCore/ChangeLog 2022-02-12 18:16:51 UTC (rev 289697)
@@ -1,3 +1,102 @@
+2022-02-12 Jer Noble <[email protected]>
+
+ Add settings to restrict media containers and codecs when in Captive Portal mode
+ https://bugs.webkit.org/show_bug.cgi?id=236245
+
+ Reviewed by Eric Carlson.
+
+ Tests: media/media-allowed-codecs.html
+ media/media-allowed-containers.html
+ media/media-source/media-source-allowed-codecs.html
+ media/media-source/media-source-allowed-containers.html
+
+ Add settings at the WebCore level to optionally declare a list of container types,
+ video codecs, audio codecs, and caption formats to allow when loading media through
+ HTMLMediaElement and MediaSource.
+
+ There are some cases where the codec ID, typically a four-character-code embedded
+ in the container itself, does not match the RFC4281 codec string. Notably, this is the case
+ with "mp4a.40" and 'aac '. So the settings must include both the codec ID and the codec
+ type in string form.
+
+ Query these lists in HTMLMediaElement::canPlayType() and MediaSource::isTypeSupported()
+ and reject ContentTypes which do not conform to the allowed types.
+
+ Query these lists in MediaSource::changeType() to disallow switching to an unsupported
+ ContentType.
+
+ If these lists are set, pass them into AVURLAsset as creation options.
+
+ When a new AVAssetTrack is loaded, query these lists and if the track's type does not
+ conform to the allowed types, synthesize an error and block further loading.
+
+ * Modules/mediasource/MediaSource.cpp:
+ (WebCore::MediaSource::isTypeSupported):
+ * Modules/mediasource/SourceBuffer.cpp:
+ (WebCore::SourceBuffer::changeType):
+ (WebCore::SourceBuffer::sourceBufferPrivateDidReceiveInitializationSegment):
+ * Sources.txt:
+ * WebCore.xcodeproj/project.pbxproj:
+ * html/HTMLMediaElement.cpp:
+ (WebCore::HTMLMediaElement::canPlayType const):
+ (WebCore::HTMLMediaElement::allowedMediaContainerTypes const):
+ (WebCore::HTMLMediaElement::allowedMediaCodecTypes const):
+ (WebCore::HTMLMediaElement::allowedMediaVideoCodecTypes const):
+ (WebCore::HTMLMediaElement::allowedMediaAudioCodecTypes const):
+ (WebCore::HTMLMediaElement::allowedMediaCaptionFormatTypes const):
+ * html/HTMLMediaElement.h:
+ * page/SettingsBase.cpp:
+ (WebCore::SettingsBase::setAllowedMediaContainerTypes):
+ (WebCore::SettingsBase::setAllowedMediaVideoCodecTypes):
+ (WebCore::SettingsBase::setAllowedMediaAudioCodecTypes):
+ (WebCore::SettingsBase::setAllowedMediaCaptionFormatTypes):
+ * page/SettingsBase.h:
+ (WebCore::SettingsBase::setAllowedMediaContainerTypes):
+ (WebCore::SettingsBase::allowedMediaContainerTypes const):
+ (WebCore::SettingsBase::setAllowedMediaVideoCodecTypes):
+ (WebCore::SettingsBase::allowedMediaVideoCodecTypes const):
+ (WebCore::SettingsBase::setAllowedMediaAudioCodecTypes):
+ (WebCore::SettingsBase::allowedMediaAudioCodecTypes const):
+ (WebCore::SettingsBase::setAllowedMediaCaptionFormatTypes):
+ (WebCore::SettingsBase::allowedMediaCaptionFormatTypes const):
+ * platform/graphics/ContentTypeUtilities.cpp: Added.
+ (WebCore::contentTypesToCodecs):
+ (WebCore::contentTypeMeetsContainerAndCodecTypeRequirements):
+ * platform/graphics/ContentTypeUtilities.h: Added.
+ * platform/graphics/FourCC.h:
+ (WebCore::FourCC::encode const):
+ (WebCore::FourCC::decode):
+ * platform/graphics/MediaPlayer.cpp:
+ (WebCore::nullOptionalStringVector):
+ (WebCore::nullOptionalFourCCVector):
+ (WebCore::MediaPlayer::nextBestMediaEngine):
+ (WebCore::MediaPlayer::allowedMediaContainerTypes const):
+ (WebCore::MediaPlayer::allowedMediaVideoCodecTypes const):
+ (WebCore::MediaPlayer::allowedMediaAudioCodecTypes const):
+ (WebCore::MediaPlayer::allowedMediaCaptionFormatTypes const):
+ * platform/graphics/MediaPlayer.h:
+ (WebCore::MediaEngineSupportParameters::encode const):
+ (WebCore::MediaEngineSupportParameters::decode):
+ * platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.h:
+ (WebCore::MediaPlayerPrivateAVFoundation::loadingMetadata const):
+ * platform/graphics/avfoundation/objc/AVAssetTrackUtilities.mm:
+ (WebCore::contentTypesToCodecs): Deleted.
+ * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h:
+ * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
+ (WebCore::MediaPlayerPrivateAVFoundationObjC::createAVAssetForURL):
+ (WebCore::MediaPlayerPrivateAVFoundationObjC::allTracksArePlayable const):
+ (WebCore::MediaPlayerPrivateAVFoundationObjC::trackIsPlayable const):
+ (WebCore::MediaPlayerPrivateAVFoundationObjC::assetStatus const):
+ (WebCore::MediaPlayerPrivateAVFoundationObjC::supportsTypeAndCodecs):
+ (WebCore::assetTrackMetadataKeyNames):
+ * testing/InternalSettings.cpp:
+ (WebCore::InternalSettings::setAllowedMediaContainerTypes):
+ (WebCore::InternalSettings::setAllowedMediaVideoCodecTypes):
+ (WebCore::InternalSettings::setAllowedMediaAudioCodecTypes):
+ (WebCore::InternalSettings::setAllowedMediaCaptionFormatTypes):
+ * testing/InternalSettings.h:
+ * testing/InternalSettings.idl:
+
2022-02-12 Eric Carlson <[email protected]>
[macOS] Use system window and screen picker when available
Modified: trunk/Source/WebCore/Headers.cmake (289696 => 289697)
--- trunk/Source/WebCore/Headers.cmake 2022-02-12 16:08:49 UTC (rev 289696)
+++ trunk/Source/WebCore/Headers.cmake 2022-02-12 18:16:51 UTC (rev 289697)
@@ -1427,6 +1427,7 @@
platform/graphics/ColorUtilities.h
platform/graphics/ComplexTextController.h
platform/graphics/ConcreteImageBuffer.h
+ platform/graphics/ContentTypeUtilities.h
platform/graphics/DashArray.h
platform/graphics/DecodingOptions.h
platform/graphics/DestinationColorSpace.h
Modified: trunk/Source/WebCore/Modules/mediasource/MediaSource.cpp (289696 => 289697)
--- trunk/Source/WebCore/Modules/mediasource/MediaSource.cpp 2022-02-12 16:08:49 UTC (rev 289696)
+++ trunk/Source/WebCore/Modules/mediasource/MediaSource.cpp 2022-02-12 18:16:51 UTC (rev 289697)
@@ -36,6 +36,7 @@
#include "AudioTrackList.h"
#include "ContentType.h"
+#include "ContentTypeUtilities.h"
#include "Event.h"
#include "EventNames.h"
#include "HTMLMediaElement.h"
@@ -909,6 +910,17 @@
parameters.isMediaSource = true;
parameters.contentTypesRequiringHardwareSupport = WTFMove(contentTypesRequiringHardwareSupport);
+ if (context.isDocument()) {
+ auto& settings = downcast<Document>(context).settings();
+ if (!contentTypeMeetsContainerAndCodecTypeRequirements(contentType, settings.allowedMediaContainerTypes(), settings.allowedMediaCodecTypes()))
+ return false;
+
+ parameters.allowedMediaContainerTypes = settings.allowedMediaContainerTypes();
+ parameters.allowedMediaVideoCodecIDs = settings.allowedMediaVideoCodecIDs();
+ parameters.allowedMediaAudioCodecIDs = settings.allowedMediaAudioCodecIDs();
+ parameters.allowedMediaCaptionFormatTypes = settings.allowedMediaCaptionFormatTypes();
+ }
+
MediaPlayer::SupportsType supported = MediaPlayer::supportsType(parameters);
if (codecs.isEmpty())
Modified: trunk/Source/WebCore/Modules/mediasource/SourceBuffer.cpp (289696 => 289697)
--- trunk/Source/WebCore/Modules/mediasource/SourceBuffer.cpp 2022-02-12 16:08:49 UTC (rev 289696)
+++ trunk/Source/WebCore/Modules/mediasource/SourceBuffer.cpp 2022-02-12 18:16:51 UTC (rev 289697)
@@ -38,6 +38,7 @@
#include "AudioTrackList.h"
#include "AudioTrackPrivate.h"
#include "BufferSource.h"
+#include "ContentTypeUtilities.h"
#include "Event.h"
#include "EventNames.h"
#include "HTMLMediaElement.h"
@@ -355,6 +356,11 @@
// the types specified (currently or previously) of SourceBuffer objects in the sourceBuffers attribute of
// the parent media source, then throw a NotSupportedError exception and abort these steps.
ContentType contentType(type);
+
+ auto& settings = document().settings();
+ if (!contentTypeMeetsContainerAndCodecTypeRequirements(contentType, settings.allowedMediaContainerTypes(), settings.allowedMediaCodecTypes()))
+ return Exception { NotSupportedError };
+
if (!m_private->canSwitchToType(contentType))
return Exception { NotSupportedError };
@@ -786,7 +792,26 @@
// 5.1 If the initialization segment contains tracks with codecs the user agent does not support,
// then run the append error algorithm with the decode error parameter set to true and abort these steps.
// NOTE: This check is the responsibility of the SourceBufferPrivate.
+ if (auto& allowedMediaAudioCodecIDs = document().settings().allowedMediaAudioCodecIDs()) {
+ for (auto& audioTrackInfo : segment.audioTracks) {
+ if (audioTrackInfo.description && allowedMediaAudioCodecIDs->contains(FourCC::fromString(audioTrackInfo.description->codec())))
+ continue;
+ appendError(true);
+ completionHandler();
+ return;
+ }
+ }
+ if (auto& allowedMediaVideoCodecIDs = document().settings().allowedMediaVideoCodecIDs()) {
+ for (auto& videoTrackInfo : segment.videoTracks) {
+ if (videoTrackInfo.description && allowedMediaVideoCodecIDs->contains(FourCC::fromString(videoTrackInfo.description->codec())))
+ continue;
+ appendError(true);
+ completionHandler();
+ return;
+ }
+ }
+
// 5.2 For each audio track in the initialization segment, run following steps:
for (auto& audioTrackInfo : segment.audioTracks) {
// FIXME: Implement steps 5.2.1-5.2.8.1 as per Editor's Draft 09 January 2015, and reorder this
Modified: trunk/Source/WebCore/PAL/ChangeLog (289696 => 289697)
--- trunk/Source/WebCore/PAL/ChangeLog 2022-02-12 16:08:49 UTC (rev 289696)
+++ trunk/Source/WebCore/PAL/ChangeLog 2022-02-12 18:16:51 UTC (rev 289697)
@@ -1,3 +1,13 @@
+2022-02-12 Jer Noble <[email protected]>
+
+ Add settings to restrict media containers and codecs when in Captive Portal mode
+ https://bugs.webkit.org/show_bug.cgi?id=236245
+
+ Reviewed by Eric Carlson.
+
+ * pal/cocoa/AVFoundationSoftLink.h:
+ * pal/cocoa/AVFoundationSoftLink.mm:
+
2022-02-12 Eric Carlson <[email protected]>
[macOS] Use system window and screen picker when available
Modified: trunk/Source/WebCore/PAL/pal/cocoa/AVFoundationSoftLink.h (289696 => 289697)
--- trunk/Source/WebCore/PAL/pal/cocoa/AVFoundationSoftLink.h 2022-02-12 16:08:49 UTC (rev 289696)
+++ trunk/Source/WebCore/PAL/pal/cocoa/AVFoundationSoftLink.h 2022-02-12 18:16:51 UTC (rev 289697)
@@ -127,6 +127,14 @@
#define AVMediaTypeAudio PAL::get_AVFoundation_AVMediaTypeAudio()
SOFT_LINK_CONSTANT_FOR_HEADER(PAL, AVFoundation, AVMediaTypeMetadata, NSString *)
#define AVMediaTypeMetadata PAL::get_AVFoundation_AVMediaTypeMetadata()
+SOFT_LINK_CONSTANT_MAY_FAIL_FOR_HEADER(PAL, AVFoundation, AVURLAssetAllowableTypeCategoriesKey, NSString *)
+#define AVURLAssetAllowableTypeCategoriesKey PAL::get_AVFoundation_AVURLAssetAllowableTypeCategoriesKey()
+SOFT_LINK_CONSTANT_MAY_FAIL_FOR_HEADER(PAL, AVFoundation, AVURLAssetAllowableAudioCodecTypesKey, NSString *)
+#define AVURLAssetAllowableAudioCodecTypesKey PAL::get_AVFoundation_AVURLAssetAllowableAudioCodecTypesKey()
+SOFT_LINK_CONSTANT_MAY_FAIL_FOR_HEADER(PAL, AVFoundation, AVURLAssetAllowableVideoCodecTypesKey, NSString *)
+#define AVURLAssetAllowableVideoCodecTypesKey PAL::get_AVFoundation_AVURLAssetAllowableVideoCodecTypesKey()
+SOFT_LINK_CONSTANT_MAY_FAIL_FOR_HEADER(PAL, AVFoundation, AVURLAssetAllowableCaptionFormatsKey, NSString *)
+#define AVURLAssetAllowableCaptionFormatsKey PAL::get_AVFoundation_AVURLAssetAllowableCaptionFormatsKey()
SOFT_LINK_CONSTANT_FOR_HEADER(PAL, AVFoundation, AVURLAssetInheritURIQueryComponentFromReferencingURIKey, NSString *)
#define AVURLAssetInheritURIQueryComponentFromReferencingURIKey PAL::get_AVFoundation_AVURLAssetInheritURIQueryComponentFromReferencingURIKey()
SOFT_LINK_CONSTANT_FOR_HEADER(PAL, AVFoundation, AVAssetImageGeneratorApertureModeCleanAperture, NSString *)
Modified: trunk/Source/WebCore/PAL/pal/cocoa/AVFoundationSoftLink.mm (289696 => 289697)
--- trunk/Source/WebCore/PAL/pal/cocoa/AVFoundationSoftLink.mm 2022-02-12 16:08:49 UTC (rev 289696)
+++ trunk/Source/WebCore/PAL/pal/cocoa/AVFoundationSoftLink.mm 2022-02-12 18:16:51 UTC (rev 289697)
@@ -182,6 +182,10 @@
SOFT_LINK_CONSTANT_FOR_SOURCE_WITH_EXPORT(PAL, AVFoundation, AVStreamDataParserContentKeyRequestProtocolVersionsKey, NSString *, PAL_EXPORT)
SOFT_LINK_CONSTANT_FOR_SOURCE_WITH_EXPORT(PAL, AVFoundation, AVStreamSessionContentProtectionSessionIdentifierChangedNotification, NSString *, PAL_EXPORT)
SOFT_LINK_CONSTANT_FOR_SOURCE_WITH_EXPORT(PAL, AVFoundation, AVStreamingKeyDeliveryContentKeyType, NSString *, PAL_EXPORT)
+SOFT_LINK_CONSTANT_MAY_FAIL_FOR_SOURCE_WITH_EXPORT(PAL, AVFoundation, AVURLAssetAllowableTypeCategoriesKey, NSString *, PAL_EXPORT)
+SOFT_LINK_CONSTANT_MAY_FAIL_FOR_SOURCE_WITH_EXPORT(PAL, AVFoundation, AVURLAssetAllowableAudioCodecTypesKey, NSString *, PAL_EXPORT)
+SOFT_LINK_CONSTANT_MAY_FAIL_FOR_SOURCE_WITH_EXPORT(PAL, AVFoundation, AVURLAssetAllowableVideoCodecTypesKey, NSString *, PAL_EXPORT)
+SOFT_LINK_CONSTANT_MAY_FAIL_FOR_SOURCE_WITH_EXPORT(PAL, AVFoundation, AVURLAssetAllowableCaptionFormatsKey, NSString *, PAL_EXPORT)
SOFT_LINK_CONSTANT_FOR_SOURCE_WITH_EXPORT(PAL, AVFoundation, AVURLAssetCacheKey, NSString *, PAL_EXPORT)
SOFT_LINK_CONSTANT_FOR_SOURCE_WITH_EXPORT(PAL, AVFoundation, AVURLAssetInheritURIQueryComponentFromReferencingURIKey, NSString *, PAL_EXPORT)
SOFT_LINK_CONSTANT_FOR_SOURCE_WITH_EXPORT(PAL, AVFoundation, AVURLAssetOutOfBandAlternateTracksKey, NSString *, PAL_EXPORT)
Modified: trunk/Source/WebCore/Sources.txt (289696 => 289697)
--- trunk/Source/WebCore/Sources.txt 2022-02-12 16:08:49 UTC (rev 289696)
+++ trunk/Source/WebCore/Sources.txt 2022-02-12 18:16:51 UTC (rev 289697)
@@ -2003,6 +2003,7 @@
platform/graphics/ColorSpace.cpp
platform/graphics/ColorUtilities.cpp
platform/graphics/ComplexTextController.cpp
+platform/graphics/ContentTypeUtilities.cpp
platform/graphics/CrossfadeGeneratedImage.cpp
platform/graphics/DestinationColorSpace.cpp
platform/graphics/DisplayRefreshMonitor.cpp
Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (289696 => 289697)
--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2022-02-12 16:08:49 UTC (rev 289696)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2022-02-12 18:16:51 UTC (rev 289697)
@@ -4567,6 +4567,7 @@
CDAB6D2E17C814EE00C60B34 /* JSMediaControlsHost.h in Headers */ = {isa = PBXBuildFile; fileRef = CDAB6D2C17C814EE00C60B34 /* JSMediaControlsHost.h */; };
CDAB6D3117C9259500C60B34 /* UserAgentScripts.h in Headers */ = {isa = PBXBuildFile; fileRef = CDAB6D2F17C9259500C60B34 /* UserAgentScripts.h */; };
CDAC068324C6A95A002F727F /* VP9UtilitiesCocoa.h in Headers */ = {isa = PBXBuildFile; fileRef = CD6FE5B724BCE645009FCDA4 /* VP9UtilitiesCocoa.h */; settings = {ATTRIBUTES = (Private, ); }; };
+ CDAD1A5A27AFC27C00699285 /* ContentTypeUtilities.h in Headers */ = {isa = PBXBuildFile; fileRef = CDAD1A5727AFBF3900699285 /* ContentTypeUtilities.h */; settings = {ATTRIBUTES = (Private, ); }; };
CDB6354923F6023A00C0F9DE /* WebAVPlayerController.h in Headers */ = {isa = PBXBuildFile; fileRef = CDA29A2C1CBF73FC00901CCF /* WebAVPlayerController.h */; settings = {ATTRIBUTES = (Private, ); }; };
CDB7045A1F7465A1003923DF /* CDMFairPlayStreaming.h in Headers */ = {isa = PBXBuildFile; fileRef = CDB704581F7465A1003923DF /* CDMFairPlayStreaming.h */; };
CDB7045B1F7465A1003923DF /* CDMFairPlayStreaming.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CDB704591F7465A1003923DF /* CDMFairPlayStreaming.cpp */; };
@@ -16168,6 +16169,8 @@
CDAB6D2C17C814EE00C60B34 /* JSMediaControlsHost.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSMediaControlsHost.h; sourceTree = "<group>"; };
CDAB6D2F17C9259500C60B34 /* UserAgentScripts.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = UserAgentScripts.h; path = DerivedSources/WebCore/UserAgentScripts.h; sourceTree = BUILT_PRODUCTS_DIR; };
CDAB6D3017C9259500C60B34 /* UserAgentScriptsData.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = UserAgentScriptsData.cpp; path = DerivedSources/WebCore/UserAgentScriptsData.cpp; sourceTree = BUILT_PRODUCTS_DIR; };
+ CDAD1A5727AFBF3900699285 /* ContentTypeUtilities.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ContentTypeUtilities.h; sourceTree = "<group>"; };
+ CDAD1A5827AFBF3900699285 /* ContentTypeUtilities.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = ContentTypeUtilities.cpp; sourceTree = "<group>"; };
CDAE8C071746B95700532D78 /* PlatformMediaSessionManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PlatformMediaSessionManager.cpp; sourceTree = "<group>"; };
CDAE8C081746B95700532D78 /* PlatformMediaSessionManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PlatformMediaSessionManager.h; sourceTree = "<group>"; };
CDB704581F7465A1003923DF /* CDMFairPlayStreaming.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CDMFairPlayStreaming.h; sourceTree = "<group>"; };
@@ -28862,6 +28865,8 @@
C2F4E7891E45AEDF006D7105 /* ComplexTextController.h */,
1C84BE4126D3939F002D61FC /* ComposedCharacterClusterTextIterator.h */,
72BAC3A723E17328008D741C /* ConcreteImageBuffer.h */,
+ CDAD1A5827AFBF3900699285 /* ContentTypeUtilities.cpp */,
+ CDAD1A5727AFBF3900699285 /* ContentTypeUtilities.h */,
2D2FC0541460CD6F00263633 /* CrossfadeGeneratedImage.cpp */,
2D2FC0551460CD6F00263633 /* CrossfadeGeneratedImage.h */,
A8CB41020E85B8A50032C4F0 /* DashArray.h */,
@@ -33893,6 +33898,7 @@
CE799F981C6A46BC0097B518 /* ContentSecurityPolicySourceList.h in Headers */,
CE799FAC1C6A50660097B518 /* ContentSecurityPolicySourceListDirective.h in Headers */,
41D015CA0F4B5C71004A662F /* ContentType.h in Headers */,
+ CDAD1A5A27AFC27C00699285 /* ContentTypeUtilities.h in Headers */,
97627B8E14FB3CEE002CDCA1 /* ContextDestructionObserver.h in Headers */,
93B6A0E60B0BCA5C00F5027A /* ContextMenu.h in Headers */,
065AD4F50B0C2EDA005A2B1D /* ContextMenuClient.h in Headers */,
Added: trunk/Source/WebCore/css/captions.css (0 => 289697)
--- trunk/Source/WebCore/css/captions.css (rev 0)
+++ trunk/Source/WebCore/css/captions.css 2022-02-12 18:16:51 UTC (rev 289697)
@@ -0,0 +1,28 @@
+video::cue(*) {
+ background-color: rgba(0, 0, 0, 0.8);
+}
+
+video::cue(:future) > * {
+ color: gray;
+}
+
+video::-webkit-media-text-track-display {
+ font: 22px sans-serif; /* Keep in sync with `DEFAULTCAPTIONFONTSIZE`. */
+}
+
+video::-webkit-media-text-track-container b {
+ font-weight: bold;
+}
+
+video::-webkit-media-text-track-container u {
+ text-decoration: underline;
+}
+
+video::-webkit-media-text-track-container i {
+ font-style: italic;
+}
+
+video::-webkit-media-text-track-region {
+ background: rgba(0, 0, 0, 0.8);
+ color: rgba(255, 255, 255, 1);
+}
Modified: trunk/Source/WebCore/html/HTMLMediaElement.cpp (289696 => 289697)
--- trunk/Source/WebCore/html/HTMLMediaElement.cpp 2022-02-12 16:08:49 UTC (rev 289696)
+++ trunk/Source/WebCore/html/HTMLMediaElement.cpp 2022-02-12 18:16:51 UTC (rev 289697)
@@ -1089,6 +1089,12 @@
ContentType contentType(mimeType);
parameters.type = contentType;
parameters.contentTypesRequiringHardwareSupport = mediaContentTypesRequiringHardwareSupport();
+ parameters.allowedMediaContainerTypes = allowedMediaContainerTypes();
+ parameters.allowedMediaCodecTypes = allowedMediaCodecTypes();
+ parameters.allowedMediaVideoCodecIDs = allowedMediaVideoCodecIDs();
+ parameters.allowedMediaAudioCodecIDs = allowedMediaAudioCodecIDs();
+ parameters.allowedMediaCaptionFormatTypes = allowedMediaCaptionFormatTypes();
+
MediaPlayer::SupportsType support = MediaPlayer::supportsType(parameters);
String canPlay;
@@ -7407,6 +7413,31 @@
return true;
}
+const std::optional<Vector<String>>& HTMLMediaElement::allowedMediaContainerTypes() const
+{
+ return document().settings().allowedMediaContainerTypes();
+}
+
+const std::optional<Vector<String>>& HTMLMediaElement::allowedMediaCodecTypes() const
+{
+ return document().settings().allowedMediaCodecTypes();
+}
+
+const std::optional<Vector<FourCC>>& HTMLMediaElement::allowedMediaVideoCodecIDs() const
+{
+ return document().settings().allowedMediaVideoCodecIDs();
+}
+
+const std::optional<Vector<FourCC>>& HTMLMediaElement::allowedMediaAudioCodecIDs() const
+{
+ return document().settings().allowedMediaAudioCodecIDs();
+}
+
+const std::optional<Vector<FourCC>>& HTMLMediaElement::allowedMediaCaptionFormatTypes() const
+{
+ return document().settings().allowedMediaCaptionFormatTypes();
+}
+
void HTMLMediaElement::mediaPlayerBufferedTimeRangesChanged()
{
if (!m_textTracks || m_bufferedTimeRangesChangedTaskCancellationGroup.hasPendingTask())
Modified: trunk/Source/WebCore/html/HTMLMediaElement.h (289696 => 289697)
--- trunk/Source/WebCore/html/HTMLMediaElement.h 2022-02-12 16:08:49 UTC (rev 289696)
+++ trunk/Source/WebCore/html/HTMLMediaElement.h 2022-02-12 18:16:51 UTC (rev 289697)
@@ -770,6 +770,12 @@
bool mediaPlayerShouldDisableSleep() const final { return shouldDisableSleep() == SleepType::Display; }
bool mediaPlayerShouldCheckHardwareSupport() const final;
const Vector<ContentType>& mediaContentTypesRequiringHardwareSupport() const final;
+ const std::optional<Vector<String>>& allowedMediaContainerTypes() const final;
+ const std::optional<Vector<String>>& allowedMediaCodecTypes() const final;
+ const std::optional<Vector<FourCC>>& allowedMediaVideoCodecIDs() const final;
+ const std::optional<Vector<FourCC>>& allowedMediaAudioCodecIDs() const final;
+ const std::optional<Vector<FourCC>>& allowedMediaCaptionFormatTypes() const final;
+
void mediaPlayerBufferedTimeRangesChanged() final;
#if USE(GSTREAMER)
Modified: trunk/Source/WebCore/page/SettingsBase.cpp (289696 => 289697)
--- trunk/Source/WebCore/page/SettingsBase.cpp 2022-02-12 16:08:49 UTC (rev 289696)
+++ trunk/Source/WebCore/page/SettingsBase.cpp 2022-02-12 18:16:51 UTC (rev 289697)
@@ -199,8 +199,99 @@
m_mediaContentTypesRequiringHardwareSupport = contentTypes;
}
+void SettingsBase::setAllowedMediaContainerTypes(const String& types)
+{
+ if (types.isNull()) {
+ m_allowedMediaContainerTypes = std::nullopt;
+ return;
+ }
+ Vector<String> newTypes;
+ for (auto type : StringView(types).split(','))
+ newTypes.append(type.toString());
+ m_allowedMediaContainerTypes = WTFMove(newTypes);
+}
+
+void SettingsBase::setAllowedMediaCodecTypes(const String& types)
+{
+ if (types.isNull()) {
+ m_allowedMediaCodecTypes = std::nullopt;
+ return;
+ }
+
+ Vector<String> newTypes;
+ for (auto type : StringView(types).split(','))
+ newTypes.append(type.toString());
+
+ m_allowedMediaCodecTypes = WTFMove(newTypes);
+}
+
+void SettingsBase::setAllowedMediaVideoCodecIDs(const String& types)
+{
+ if (types.isNull()) {
+ m_allowedMediaVideoCodecIDs = std::nullopt;
+ return;
+ }
+
+ Vector<FourCC> newTypes;
+ for (auto type : StringView(types).split(',')) {
+ if (auto fourCC = FourCC::fromString(type))
+ newTypes.append(WTFMove(*fourCC));
+ }
+
+ m_allowedMediaVideoCodecIDs = WTFMove(newTypes);
+}
+
+void SettingsBase::setAllowedMediaAudioCodecIDs(const String& types)
+{
+ if (types.isNull()) {
+ m_allowedMediaAudioCodecIDs = std::nullopt;
+ return;
+ }
+
+ Vector<FourCC> newTypes;
+ for (auto type : StringView(types).split(',')) {
+ if (auto fourCC = FourCC::fromString(type))
+ newTypes.append(WTFMove(*fourCC));
+ }
+
+ m_allowedMediaAudioCodecIDs = WTFMove(newTypes);
+}
+
+void SettingsBase::setAllowedMediaCaptionFormatTypes(const String& types)
+{
+ if (types.isNull()) {
+ m_allowedMediaCaptionFormatTypes = std::nullopt;
+ return;
+ }
+
+ Vector<FourCC> newTypes;
+ for (auto type : StringView(types).split(',')) {
+ if (auto fourCC = FourCC::fromString(type))
+ newTypes.append(WTFMove(*fourCC));
+ }
+
+ m_allowedMediaCaptionFormatTypes = WTFMove(newTypes);
+}
+
+void SettingsBase::resetToConsistentState()
+{
+ m_minimumDOMTimerInterval = DOMTimer::defaultMinimumInterval();
+
+ setAllowedMediaContainerTypes(std::nullopt);
+ setAllowedMediaCodecTypes(std::nullopt);
+ setAllowedMediaVideoCodecIDs(std::nullopt);
+ setAllowedMediaAudioCodecIDs(std::nullopt);
+ setAllowedMediaCaptionFormatTypes(std::nullopt);
+
+#if ENABLE(TEXT_AUTOSIZING)
+ m_oneLineTextMultiplierCoefficient = defaultOneLineTextMultiplierCoefficient;
+ m_multiLineTextMultiplierCoefficient = defaultMultiLineTextMultiplierCoefficient;
+ m_maxTextAutosizingScaleIncrease = defaultMaxTextAutosizingScaleIncrease;
+#endif
+}
+
// MARK - onChange handlers
void SettingsBase::setNeedsRecalcStyleInAllFrames()
Modified: trunk/Source/WebCore/page/SettingsBase.h (289696 => 289697)
--- trunk/Source/WebCore/page/SettingsBase.h 2022-02-12 16:08:49 UTC (rev 289696)
+++ trunk/Source/WebCore/page/SettingsBase.h 2022-02-12 18:16:51 UTC (rev 289697)
@@ -34,6 +34,7 @@
#include "FontLoadTimingOverride.h"
#include "FontRenderingMode.h"
#include "ForcedAccessibilityValue.h"
+#include "FourCC.h"
#include "FrameFlattening.h"
#include "HTMLParserScriptingFlagPolicy.h"
#include "MediaPlayerEnums.h"
@@ -108,6 +109,28 @@
WEBCORE_EXPORT void setMediaContentTypesRequiringHardwareSupport(const String&);
const Vector<ContentType>& mediaContentTypesRequiringHardwareSupport() const { return m_mediaContentTypesRequiringHardwareSupport; }
+ void setAllowedMediaContainerTypes(std::optional<Vector<String>>&& types) { m_allowedMediaContainerTypes = WTFMove(types); }
+ WEBCORE_EXPORT void setAllowedMediaContainerTypes(const String&);
+ const std::optional<Vector<String>>& allowedMediaContainerTypes() const { return m_allowedMediaContainerTypes; }
+
+ void setAllowedMediaCodecTypes(std::optional<Vector<String>>&& types) { m_allowedMediaCodecTypes = WTFMove(types); }
+ WEBCORE_EXPORT void setAllowedMediaCodecTypes(const String&);
+ const std::optional<Vector<String>>& allowedMediaCodecTypes() const { return m_allowedMediaCodecTypes; }
+
+ void setAllowedMediaVideoCodecIDs(std::optional<Vector<FourCC>>&& types) { m_allowedMediaVideoCodecIDs = WTFMove(types); }
+ WEBCORE_EXPORT void setAllowedMediaVideoCodecIDs(const String&);
+ const std::optional<Vector<FourCC>>& allowedMediaVideoCodecIDs() const { return m_allowedMediaVideoCodecIDs; }
+
+ void setAllowedMediaAudioCodecIDs(std::optional<Vector<FourCC>>&& types) { m_allowedMediaAudioCodecIDs = WTFMove(types); }
+ WEBCORE_EXPORT void setAllowedMediaAudioCodecIDs(const String&);
+ const std::optional<Vector<FourCC>>& allowedMediaAudioCodecIDs() const { return m_allowedMediaAudioCodecIDs; }
+
+ void setAllowedMediaCaptionFormatTypes(std::optional<Vector<FourCC>>&& types) { m_allowedMediaCaptionFormatTypes = WTFMove(types); }
+ WEBCORE_EXPORT void setAllowedMediaCaptionFormatTypes(const String&);
+ const std::optional<Vector<FourCC>>& allowedMediaCaptionFormatTypes() const { return m_allowedMediaCaptionFormatTypes; }
+
+ WEBCORE_EXPORT void resetToConsistentState();
+
protected:
explicit SettingsBase(Page*);
virtual ~SettingsBase();
@@ -150,6 +173,11 @@
Timer m_setImageLoadingSettingsTimer;
Vector<ContentType> m_mediaContentTypesRequiringHardwareSupport;
+ std::optional<Vector<String>> m_allowedMediaContainerTypes;
+ std::optional<Vector<String>> m_allowedMediaCodecTypes;
+ std::optional<Vector<FourCC>> m_allowedMediaVideoCodecIDs;
+ std::optional<Vector<FourCC>> m_allowedMediaAudioCodecIDs;
+ std::optional<Vector<FourCC>> m_allowedMediaCaptionFormatTypes;
#if ENABLE(TEXT_AUTOSIZING)
static constexpr const float boostedOneLineTextMultiplierCoefficient = 2.23125f;
Added: trunk/Source/WebCore/platform/graphics/ContentTypeUtilities.cpp (0 => 289697)
--- trunk/Source/WebCore/platform/graphics/ContentTypeUtilities.cpp (rev 0)
+++ trunk/Source/WebCore/platform/graphics/ContentTypeUtilities.cpp 2022-02-12 18:16:51 UTC (rev 289697)
@@ -0,0 +1,49 @@
+/*
+ * Copyright (C) 2022 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "ContentTypeUtilities.h"
+
+namespace WebCore {
+
+#include "FourCC.h"
+#include <wtf/Algorithms.h>
+
+bool contentTypeMeetsContainerAndCodecTypeRequirements(const ContentType& type, const std::optional<Vector<String>>& allowedMediaContainerTypes, const std::optional<Vector<String>>& allowedMediaCodecTypes)
+{
+ if (allowedMediaContainerTypes && !allowedMediaContainerTypes->contains(type.containerType()))
+ return false;
+
+ if (!allowedMediaCodecTypes)
+ return true;
+
+ return allOf(type.codecs(), [&] (auto& codec) {
+ return anyOf(*allowedMediaCodecTypes, [&] (auto& allowedCodec) {
+ return codec.startsWith(allowedCodec);
+ });
+ });
+}
+
+}
Added: trunk/Source/WebCore/platform/graphics/ContentTypeUtilities.h (0 => 289697)
--- trunk/Source/WebCore/platform/graphics/ContentTypeUtilities.h (rev 0)
+++ trunk/Source/WebCore/platform/graphics/ContentTypeUtilities.h 2022-02-12 18:16:51 UTC (rev 289697)
@@ -0,0 +1,37 @@
+/*
+ * Copyright (C) 2022 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#include "ContentType.h"
+#include <wtf/Forward.h>
+
+namespace WebCore {
+
+struct FourCC;
+
+WEBCORE_EXPORT bool contentTypeMeetsContainerAndCodecTypeRequirements(const ContentType&, const std::optional<Vector<String>>& allowedMediaContainerTypes, const std::optional<Vector<String>>& allowedMediaCodecTypes);
+
+}
Modified: trunk/Source/WebCore/platform/graphics/FourCC.h (289696 => 289697)
--- trunk/Source/WebCore/platform/graphics/FourCC.h 2022-02-12 16:08:49 UTC (rev 289696)
+++ trunk/Source/WebCore/platform/graphics/FourCC.h 2022-02-12 18:16:51 UTC (rev 289697)
@@ -37,6 +37,18 @@
static std::optional<FourCC> fromString(StringView);
uint32_t value { 0 };
+
+ template<class Encoder>
+ void encode(Encoder& encoder) const
+ {
+ encoder << value;
+ }
+
+ template <class Decoder>
+ static WARN_UNUSED_RETURN bool decode(Decoder& decoder, FourCC& configuration)
+ {
+ return decoder.decode(configuration.value);
+ }
};
constexpr bool operator==(FourCC, FourCC);
Modified: trunk/Source/WebCore/platform/graphics/MediaPlayer.cpp (289696 => 289697)
--- trunk/Source/WebCore/platform/graphics/MediaPlayer.cpp 2022-02-12 16:08:49 UTC (rev 289696)
+++ trunk/Source/WebCore/platform/graphics/MediaPlayer.cpp 2022-02-12 18:16:51 UTC (rev 289697)
@@ -30,6 +30,7 @@
#include "ContentType.h"
#include "DeprecatedGlobalSettings.h"
+#include "FourCC.h"
#include "GraphicsContext.h"
#include "IntRect.h"
#include "LegacyCDMSession.h"
@@ -176,6 +177,18 @@
return vector;
}
+static const std::optional<Vector<String>>& nullOptionalStringVector()
+{
+ static NeverDestroyed<std::optional<Vector<String>>> vector;
+ return vector;
+}
+
+static const std::optional<Vector<FourCC>>& nullOptionalFourCCVector()
+{
+ static NeverDestroyed<std::optional<Vector<FourCC>>> vector;
+ return vector;
+}
+
class NullMediaPlayerClient : public MediaPlayerClient {
private:
#if !RELEASE_LOG_DISABLED
@@ -197,6 +210,12 @@
#if ENABLE(LEGACY_ENCRYPTED_MEDIA)
RefPtr<ArrayBuffer> mediaPlayerCachedKeyForKeyId(const String&) const final { return nullptr; }
#endif
+
+ const std::optional<Vector<String>>& allowedMediaContainerTypes() const final { return nullOptionalStringVector(); }
+ const std::optional<Vector<String>>& allowedMediaCodecTypes() const final { return nullOptionalStringVector(); }
+ const std::optional<Vector<FourCC>>& allowedMediaVideoCodecIDs() const final { return nullOptionalFourCCVector(); }
+ const std::optional<Vector<FourCC>>& allowedMediaAudioCodecIDs() const final { return nullOptionalFourCCVector(); }
+ const std::optional<Vector<FourCC>>& allowedMediaCaptionFormatTypes() const final { return nullOptionalFourCCVector(); }
};
const Vector<ContentType>& MediaPlayerClient::mediaContentTypesRequiringHardwareSupport() const
@@ -529,6 +548,11 @@
#if ENABLE(MEDIA_STREAM)
parameters.isMediaStream = !!m_mediaStream;
#endif
+ parameters.allowedMediaContainerTypes = allowedMediaContainerTypes();
+ parameters.allowedMediaCodecTypes = allowedMediaCodecTypes();
+ parameters.allowedMediaVideoCodecIDs = allowedMediaVideoCodecIDs();
+ parameters.allowedMediaAudioCodecIDs = allowedMediaAudioCodecIDs();
+ parameters.allowedMediaCaptionFormatTypes = allowedMediaCaptionFormatTypes();
if (m_activeEngineIdentifier) {
if (current)
@@ -1657,6 +1681,31 @@
return client().mediaPlayerShouldCheckHardwareSupport();
}
+const std::optional<Vector<String>>& MediaPlayer::allowedMediaContainerTypes() const
+{
+ return client().allowedMediaContainerTypes();
+}
+
+const std::optional<Vector<String>>& MediaPlayer::allowedMediaCodecTypes() const
+{
+ return client().allowedMediaCodecTypes();
+}
+
+const std::optional<Vector<FourCC>>& MediaPlayer::allowedMediaVideoCodecIDs() const
+{
+ return client().allowedMediaVideoCodecIDs();
+}
+
+const std::optional<Vector<FourCC>>& MediaPlayer::allowedMediaAudioCodecIDs() const
+{
+ return client().allowedMediaAudioCodecIDs();
+}
+
+const std::optional<Vector<FourCC>>& MediaPlayer::allowedMediaCaptionFormatTypes() const
+{
+ return client().allowedMediaCaptionFormatTypes();
+}
+
void MediaPlayer::applicationWillResignActive()
{
m_private->applicationWillResignActive();
Modified: trunk/Source/WebCore/platform/graphics/MediaPlayer.h (289696 => 289697)
--- trunk/Source/WebCore/platform/graphics/MediaPlayer.h 2022-02-12 16:08:49 UTC (rev 289696)
+++ trunk/Source/WebCore/platform/graphics/MediaPlayer.h 2022-02-12 18:16:51 UTC (rev 289697)
@@ -29,6 +29,7 @@
#include "ContentType.h"
#include "Cookie.h"
+#include "FourCC.h"
#include "GraphicsTypesGL.h"
#include "LayoutRect.h"
#include "MediaPlayerEnums.h"
@@ -97,6 +98,11 @@
bool isMediaSource { false };
bool isMediaStream { false };
Vector<ContentType> contentTypesRequiringHardwareSupport;
+ std::optional<Vector<String>> allowedMediaContainerTypes;
+ std::optional<Vector<String>> allowedMediaCodecTypes;
+ std::optional<Vector<FourCC>> allowedMediaVideoCodecIDs;
+ std::optional<Vector<FourCC>> allowedMediaAudioCodecIDs;
+ std::optional<Vector<FourCC>> allowedMediaCaptionFormatTypes;
template<class Encoder>
void encode(Encoder& encoder) const
@@ -106,37 +112,26 @@
encoder << isMediaSource;
encoder << isMediaStream;
encoder << contentTypesRequiringHardwareSupport;
+ encoder << allowedMediaContainerTypes;
+ encoder << allowedMediaCodecTypes;
+ encoder << allowedMediaVideoCodecIDs;
+ encoder << allowedMediaAudioCodecIDs;
+ encoder << allowedMediaCaptionFormatTypes;
}
template <class Decoder>
- static std::optional<MediaEngineSupportParameters> decode(Decoder& decoder)
+ static bool decode(Decoder& decoder, MediaEngineSupportParameters& parameters)
{
- std::optional<ContentType> type;
- decoder >> type;
- if (!type)
- return std::nullopt;
-
- std::optional<URL> url;
- decoder >> url;
- if (!url)
- return std::nullopt;
-
- std::optional<bool> isMediaSource;
- decoder >> isMediaSource;
- if (!isMediaSource)
- return std::nullopt;
-
- std::optional<bool> isMediaStream;
- decoder >> isMediaStream;
- if (!isMediaStream)
- return std::nullopt;
-
- std::optional<Vector<ContentType>> typesRequiringHardware;
- decoder >> typesRequiringHardware;
- if (!typesRequiringHardware)
- return std::nullopt;
-
- return {{ WTFMove(*type), WTFMove(*url), *isMediaSource, *isMediaStream, *typesRequiringHardware }};
+ return decoder.decode(parameters.type)
+ && decoder.decode(parameters.url)
+ && decoder.decode(parameters.isMediaSource)
+ && decoder.decode(parameters.isMediaStream)
+ && decoder.decode(parameters.contentTypesRequiringHardwareSupport)
+ && decoder.decode(parameters.allowedMediaContainerTypes)
+ && decoder.decode(parameters.allowedMediaCodecTypes)
+ && decoder.decode(parameters.allowedMediaVideoCodecIDs)
+ && decoder.decode(parameters.allowedMediaAudioCodecIDs)
+ && decoder.decode(parameters.allowedMediaCaptionFormatTypes);
}
};
@@ -275,6 +270,12 @@
virtual const Vector<ContentType>& mediaContentTypesRequiringHardwareSupport() const = 0;
virtual bool mediaPlayerShouldCheckHardwareSupport() const { return false; }
+ virtual const std::optional<Vector<String>>& allowedMediaContainerTypes() const = 0;
+ virtual const std::optional<Vector<String>>& allowedMediaCodecTypes() const = 0;
+ virtual const std::optional<Vector<FourCC>>& allowedMediaVideoCodecIDs() const = 0;
+ virtual const std::optional<Vector<FourCC>>& allowedMediaAudioCodecIDs() const = 0;
+ virtual const std::optional<Vector<FourCC>>& allowedMediaCaptionFormatTypes() const = 0;
+
virtual void mediaPlayerBufferedTimeRangesChanged() { }
virtual void mediaPlayerSeekableTimeRangesChanged() { }
@@ -634,6 +635,12 @@
const Vector<ContentType>& mediaContentTypesRequiringHardwareSupport() const;
bool shouldCheckHardwareSupport() const;
+ const std::optional<Vector<String>>& allowedMediaContainerTypes() const;
+ const std::optional<Vector<String>>& allowedMediaCodecTypes() const;
+ const std::optional<Vector<FourCC>>& allowedMediaVideoCodecIDs() const;
+ const std::optional<Vector<FourCC>>& allowedMediaAudioCodecIDs() const;
+ const std::optional<Vector<FourCC>>& allowedMediaCaptionFormatTypes() const;
+
#if !RELEASE_LOG_DISABLED
const Logger& mediaPlayerLogger();
const void* mediaPlayerLogIdentifier() { return client().mediaPlayerLogIdentifier(); }
Modified: trunk/Source/WebCore/platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.h (289696 => 289697)
--- trunk/Source/WebCore/platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.h 2022-02-12 16:08:49 UTC (rev 289696)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.h 2022-02-12 18:16:51 UTC (rev 289697)
@@ -329,6 +329,8 @@
void setNeedsRenderingModeChanged();
void renderingModeChanged();
+ bool loadingMetadata() const { return m_loadingMetadata; }
+
private:
MediaPlayer* m_player;
Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h (289696 => 289697)
--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h 2022-02-12 16:08:49 UTC (rev 289696)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h 2022-02-12 18:16:51 UTC (rev 289697)
@@ -350,6 +350,9 @@
std::optional<VideoFrameMetadata> videoFrameMetadata() final { return std::exchange(m_videoFrameMetadata, { }); }
void checkNewVideoFrameMetadata();
+ std::optional<bool> allTracksArePlayable() const;
+ bool trackIsPlayable(AVAssetTrack*) const;
+
RetainPtr<AVURLAsset> m_avAsset;
RetainPtr<AVPlayer> m_avPlayer;
RetainPtr<AVPlayerItem> m_avPlayerItem;
@@ -447,7 +450,9 @@
bool m_cachedCanPlayFastForward { false };
bool m_cachedCanPlayFastReverse { false };
mutable bool m_cachedAssetIsLoaded { false };
+ mutable bool m_cachedTracksAreLoaded { false };
mutable std::optional<bool> m_cachedAssetIsPlayable;
+ mutable std::optional<bool> m_cachedTracksArePlayable;
bool m_muted { false };
bool m_shouldObserveTimeControlStatus { false };
mutable std::optional<bool> m_tracksArePlayable;
Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm (289696 => 289697)
--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm 2022-02-12 16:08:49 UTC (rev 289696)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm 2022-02-12 18:16:51 UTC (rev 289697)
@@ -38,10 +38,12 @@
#import "CDMSessionAVFoundationObjC.h"
#import "CVUtilities.h"
#import "ColorSpaceCG.h"
+#import "ContentTypeUtilities.h"
#import "Cookie.h"
#import "DeprecatedGlobalSettings.h"
#import "ExtensionsGL.h"
#import "FloatConversion.h"
+#import "FourCC.h"
#import "GraphicsContext.h"
#import "ImageRotationSessionVT.h"
#import "InbandChapterTrackPrivateAVFObjC.h"
@@ -66,6 +68,7 @@
#import "SharedBuffer.h"
#import "SourceBufferParserWebM.h"
#import "TextTrackRepresentation.h"
+#import "UTIUtilities.h"
#import "VideoLayerManagerObjC.h"
#import "VideoTrackPrivateAVFObjC.h"
#import "WebCoreAVFResourceLoader.h"
@@ -948,6 +951,38 @@
[options setObject:@NO forKey:AVURLAssetUsesNoPersistentCacheKey];
}
+ auto allowedMediaContainerTypes = player()->allowedMediaContainerTypes();
+ if (allowedMediaContainerTypes && PAL::canLoad_AVFoundation_AVURLAssetAllowableTypeCategoriesKey()) {
+ auto nsTypes = adoptNS([[NSMutableArray alloc] init]);
+ for (auto type : *allowedMediaContainerTypes)
+ [nsTypes addObject:(NSString *)UTIFromMIMEType(type)];
+ [options setObject:nsTypes.get() forKey:AVURLAssetAllowableTypeCategoriesKey];
+ }
+
+ auto allowedMediaAudioCodecIDs = player()->allowedMediaAudioCodecIDs();
+ if (allowedMediaAudioCodecIDs && PAL::canLoad_AVFoundation_AVURLAssetAllowableAudioCodecTypesKey()) {
+ auto nsTypes = adoptNS([[NSMutableArray alloc] init]);
+ for (auto type : *allowedMediaAudioCodecIDs)
+ [nsTypes addObject:@(type.value)];
+ [options setObject:nsTypes.get() forKey:AVURLAssetAllowableAudioCodecTypesKey];
+ }
+
+ auto allowedMediaVideoCodecIDs = player()->allowedMediaVideoCodecIDs();
+ if (allowedMediaVideoCodecIDs && PAL::canLoad_AVFoundation_AVURLAssetAllowableVideoCodecTypesKey()) {
+ auto nsTypes = adoptNS([[NSMutableArray alloc] init]);
+ for (auto type : *allowedMediaVideoCodecIDs)
+ [nsTypes addObject:@(type.value)];
+ [options setObject:nsTypes.get() forKey:AVURLAssetAllowableVideoCodecTypesKey];
+ }
+
+ auto allowedMediaCaptionFormatTypes = player()->allowedMediaCaptionFormatTypes();
+ if (allowedMediaCaptionFormatTypes && PAL::canLoad_AVFoundation_AVURLAssetAllowableCaptionFormatsKey()) {
+ auto nsTypes = adoptNS([[NSMutableArray alloc] init]);
+ for (auto type : *allowedMediaCaptionFormatTypes)
+ [nsTypes addObject:@(type.value)];
+ [options setObject:nsTypes.get() forKey:AVURLAssetAllowableCaptionFormatsKey];
+ }
+
if (willUseWebMFormatReader)
registerFormatReaderIfNecessary();
@@ -1783,6 +1818,76 @@
processChapterTracks();
}
+std::optional<bool> MediaPlayerPrivateAVFoundationObjC::allTracksArePlayable() const
+{
+ if (m_avPlayerItem) {
+ for (AVPlayerItemTrack *track in [m_avPlayerItem tracks]) {
+ if (!trackIsPlayable(track.assetTrack))
+ return false;
+ }
+
+ return true;
+ }
+
+ if (!m_avAsset || [m_avAsset statusOfValueForKey:@"tracks" error:NULL] != AVKeyValueStatusLoaded)
+ return std::nullopt;
+
+ for (AVAssetTrack *assetTrack : [m_avAsset tracks]) {
+ if (!trackIsPlayable(assetTrack))
+ return false;
+ }
+ return true;
+}
+
+bool MediaPlayerPrivateAVFoundationObjC::trackIsPlayable(AVAssetTrack* track) const
+{
+ if (player()->shouldCheckHardwareSupport() && !assetTrackMeetsHardwareDecodeRequirements(track, player()->mediaContentTypesRequiringHardwareSupport()))
+ return false;
+
+ auto description = retainPtr((__bridge CMFormatDescriptionRef)track.formatDescriptions.firstObject);
+ if (!description)
+ return false;
+
+ auto mediaType = PAL::CMFormatDescriptionGetMediaType(description.get());
+ auto codecType = FourCC { PAL::CMFormatDescriptionGetMediaSubType(description.get()) };
+ switch (PAL::CMFormatDescriptionGetMediaType(description.get())) {
+ case kCMMediaType_Video: {
+ auto& allowedMediaVideoCodecIDs = player()->allowedMediaVideoCodecIDs();
+ if (allowedMediaVideoCodecIDs && !allowedMediaVideoCodecIDs->contains(codecType)) {
+ ERROR_LOG(LOGIDENTIFIER, "Video track with codec type '", codecType, "' not contained in allowed codec list; blocking");
+ return false;
+ }
+ return true;
+ }
+ case kCMMediaType_Audio: {
+ auto& allowedMediaAudioCodecIDs = player()->allowedMediaAudioCodecIDs();
+ if (allowedMediaAudioCodecIDs && !allowedMediaAudioCodecIDs->contains(codecType)) {
+ ERROR_LOG(LOGIDENTIFIER, "Audio track with codec type '", codecType, "' not contained in allowed codec list; blocking");
+ return false;
+ }
+ return true;
+ }
+ case kCMMediaType_Text:
+ case kCMMediaType_ClosedCaption:
+ case kCMMediaType_Subtitle: {
+ auto& allowedMediaCaptionFormatTypes = player()->allowedMediaCaptionFormatTypes();
+ if (allowedMediaCaptionFormatTypes && !allowedMediaCaptionFormatTypes->contains(codecType)) {
+ ERROR_LOG(LOGIDENTIFIER, "Text track with codec type '", codecType, "' not contained in allowed codec list; blocking");
+ return false;
+ }
+ return true;
+ }
+ case kCMMediaType_Muxed:
+ case kCMMediaType_TimeCode:
+ case kCMMediaType_Metadata:
+ // No-op
+ return true;
+ }
+
+ ERROR_LOG(LOGIDENTIFIER, "Track with unuexpected media type '", FourCC(mediaType), "' not contained in allowed codec list; ignoring");
+ return true;
+}
+
MediaPlayerPrivateAVFoundation::AssetStatus MediaPlayerPrivateAVFoundationObjC::assetStatus() const
{
if (!m_avAsset)
@@ -1808,23 +1913,21 @@
m_cachedAssetIsLoaded = true;
}
- if (!player()->shouldCheckHardwareSupport())
- m_tracksArePlayable = true;
+ // m_loadingMetadata will be false until all tracks' properties have finished loading.
+ // See: beginLoadingMetadata().
+ if (loadingMetadata())
+ return MediaPlayerAVAssetStatusLoading;
- if (!m_tracksArePlayable) {
- m_tracksArePlayable = true;
- for (AVAssetTrack *track in [m_avAsset tracks]) {
- if (!assetTrackMeetsHardwareDecodeRequirements(track, player()->mediaContentTypesRequiringHardwareSupport())) {
- m_tracksArePlayable = false;
- break;
- }
- }
+ if (!m_cachedTracksArePlayable) {
+ m_cachedTracksArePlayable = allTracksArePlayable();
+ if (!m_cachedTracksArePlayable)
+ return MediaPlayerAVAssetStatusLoading;
}
if (!m_cachedAssetIsPlayable)
m_cachedAssetIsPlayable = [[m_avAsset valueForKey:@"playable"] boolValue];
- if (*m_cachedAssetIsPlayable && m_tracksArePlayable.value())
+ if (*m_cachedAssetIsPlayable && *m_cachedTracksArePlayable)
return MediaPlayerAVAssetStatusPlayable;
return MediaPlayerAVAssetStatusLoaded;
@@ -1929,6 +2032,9 @@
return MediaPlayer::SupportsType::IsNotSupported;
#endif
+ if (!contentTypeMeetsContainerAndCodecTypeRequirements(parameters.type, parameters.allowedMediaContainerTypes, parameters.allowedMediaCodecTypes))
+ return MediaPlayer::SupportsType::IsNotSupported;
+
auto supported = AVAssetMIMETypeCache::singleton().canDecodeType(parameters.type.raw());
if (supported != MediaPlayer::SupportsType::IsSupported)
return supported;
@@ -3734,7 +3840,7 @@
NSArray* assetTrackMetadataKeyNames()
{
- static NSArray* keys = [[NSArray alloc] initWithObjects:@"totalSampleDataLength", @"mediaType", @"enabled", @"preferredTransform", @"naturalSize", nil];
+ static NSArray* keys = [[NSArray alloc] initWithObjects:@"totalSampleDataLength", @"mediaType", @"enabled", @"preferredTransform", @"naturalSize", @"formatDescriptions", nil];
return keys;
}
Modified: trunk/Source/WebCore/testing/InternalSettings.cpp (289696 => 289697)
--- trunk/Source/WebCore/testing/InternalSettings.cpp 2022-02-12 16:08:49 UTC (rev 289696)
+++ trunk/Source/WebCore/testing/InternalSettings.cpp 2022-02-12 18:16:51 UTC (rev 289697)
@@ -193,6 +193,8 @@
m_backup.restoreTo(settings());
m_backup = Backup { settings() };
+ m_page->settings().resetToConsistentState();
+
InternalSettingsGenerated::resetToConsistentState();
}
@@ -588,6 +590,48 @@
return { };
}
+ExceptionOr<void> InternalSettings::setAllowedMediaContainerTypes(const String& types)
+{
+ if (!m_page)
+ return Exception { InvalidAccessError };
+ m_page->settings().setAllowedMediaContainerTypes(types);
+ return { };
+}
+
+ExceptionOr<void> InternalSettings::setAllowedMediaCodecTypes(const String& types)
+{
+ if (!m_page)
+ return Exception { InvalidAccessError };
+ m_page->settings().setAllowedMediaCodecTypes(types);
+ return { };
+}
+
+ExceptionOr<void> InternalSettings::setAllowedMediaVideoCodecIDs(const String& types)
+{
+ if (!m_page)
+ return Exception { InvalidAccessError };
+ m_page->settings().setAllowedMediaVideoCodecIDs(types);
+ return { };
+}
+
+ExceptionOr<void> InternalSettings::setAllowedMediaAudioCodecIDs(const String& types)
+{
+ if (!m_page)
+ return Exception { InvalidAccessError };
+ m_page->settings().setAllowedMediaAudioCodecIDs(types);
+ return { };
+}
+
+ExceptionOr<void> InternalSettings::setAllowedMediaCaptionFormatTypes(const String& types)
+{
+ if (!m_page)
+ return Exception { InvalidAccessError };
+ m_page->settings().setAllowedMediaCaptionFormatTypes(types);
+ return { };
+}
+
+
+
// If you add to this class, make sure you are not duplicating functionality in the generated
// base class InternalSettingsGenerated and that you update the Backup class for test reproducability.
Modified: trunk/Source/WebCore/testing/InternalSettings.h (289696 => 289697)
--- trunk/Source/WebCore/testing/InternalSettings.h 2022-02-12 16:08:49 UTC (rev 289696)
+++ trunk/Source/WebCore/testing/InternalSettings.h 2022-02-12 18:16:51 UTC (rev 289697)
@@ -122,6 +122,12 @@
// AudioContext
ExceptionOr<void> setDefaultAudioContextSampleRate(float);
+ ExceptionOr<void> setAllowedMediaContainerTypes(const String&);
+ ExceptionOr<void> setAllowedMediaCodecTypes(const String&);
+ ExceptionOr<void> setAllowedMediaVideoCodecIDs(const String&);
+ ExceptionOr<void> setAllowedMediaAudioCodecIDs(const String&);
+ ExceptionOr<void> setAllowedMediaCaptionFormatTypes(const String&);
+
private:
explicit InternalSettings(Page*);
Modified: trunk/Source/WebCore/testing/InternalSettings.idl (289696 => 289697)
--- trunk/Source/WebCore/testing/InternalSettings.idl 2022-02-12 16:08:49 UTC (rev 289696)
+++ trunk/Source/WebCore/testing/InternalSettings.idl 2022-02-12 18:16:51 UTC (rev 289697)
@@ -95,4 +95,10 @@
// AudioContext
undefined setDefaultAudioContextSampleRate(float sampleRate);
+
+ undefined setAllowedMediaContainerTypes(DOMString? types);
+ undefined setAllowedMediaCodecTypes(DOMString? types);
+ undefined setAllowedMediaVideoCodecIDs(DOMString? types);
+ undefined setAllowedMediaAudioCodecIDs(DOMString? types);
+ undefined setAllowedMediaCaptionFormatTypes(DOMString? types);
};
Modified: trunk/Source/WebKit/ChangeLog (289696 => 289697)
--- trunk/Source/WebKit/ChangeLog 2022-02-12 16:08:49 UTC (rev 289696)
+++ trunk/Source/WebKit/ChangeLog 2022-02-12 18:16:51 UTC (rev 289697)
@@ -1,3 +1,28 @@
+2022-02-12 Jer Noble <[email protected]>
+
+ Add settings to restrict media containers and codecs when in Captive Portal mode
+ https://bugs.webkit.org/show_bug.cgi?id=236245
+
+ Reviewed by Eric Carlson.
+
+ RemoteMediaPlayerManager caches the results of supportsTypeAndCodecs() calls, which
+ is problematic when those results can change due to a change in settings. So enforce
+ the allowed codec and containers settings at the RemoteMediaPlayerManager level. Also,
+ pass those settings across the GPU process boundary via RemoteMediaPlayerProxyConfiguration.
+
+ Drive-by fix: refactor RemoteMediaPlayerProxyConfiguration::decode() so as not to require
+ re-declaring the types of every ivar, and greatly simplify the implementation.
+
+ * GPUProcess/media/RemoteMediaPlayerProxy.h:
+ * GPUProcess/media/RemoteMediaPlayerProxyConfiguration.h:
+ (WebKit::RemoteMediaPlayerProxyConfiguration::encode const):
+ (WebKit::RemoteMediaPlayerProxyConfiguration::decode):
+ * WebProcess/GPU/media/RemoteMediaPlayerManager.cpp:
+ (WebKit::RemoteMediaPlayerManager::createRemoteMediaPlayer):
+ (WebKit::RemoteMediaPlayerManager::supportsTypeAndCodecs):
+ * WebProcess/WebPage/WebPage.cpp:
+ (WebKit::WebPage::updatePreferences):
+
2022-02-12 Eric Carlson <[email protected]>
[macOS] Use system window and screen picker when available
Modified: trunk/Source/WebKit/GPUProcess/media/RemoteMediaPlayerProxy.h (289696 => 289697)
--- trunk/Source/WebKit/GPUProcess/media/RemoteMediaPlayerProxy.h 2022-02-12 16:08:49 UTC (rev 289696)
+++ trunk/Source/WebKit/GPUProcess/media/RemoteMediaPlayerProxy.h 2022-02-12 18:16:51 UTC (rev 289697)
@@ -76,6 +76,8 @@
class MediaPlaybackTargetContext;
#endif
class VideoTrackPrivate;
+
+struct FourCC;
}
#if USE(AVFOUNDATION)
@@ -293,6 +295,12 @@
const Vector<WebCore::ContentType>& mediaContentTypesRequiringHardwareSupport() const final;
bool mediaPlayerShouldCheckHardwareSupport() const final;
+ const std::optional<Vector<String>>& allowedMediaContainerTypes() const final { return m_configuration.allowedMediaContainerTypes; };
+ const std::optional<Vector<String>>& allowedMediaCodecTypes() const final { return m_configuration.allowedMediaCodecTypes; };
+ const std::optional<Vector<WebCore::FourCC>>& allowedMediaVideoCodecIDs() const final { return m_configuration.allowedMediaVideoCodecIDs; };
+ const std::optional<Vector<WebCore::FourCC>>& allowedMediaAudioCodecIDs() const final { return m_configuration.allowedMediaAudioCodecIDs; };
+ const std::optional<Vector<WebCore::FourCC>>& allowedMediaCaptionFormatTypes() const final { return m_configuration.allowedMediaCaptionFormatTypes; };
+
void startUpdateCachedStateMessageTimer();
void updateCachedState(bool = false);
void sendCachedState();
Modified: trunk/Source/WebKit/GPUProcess/media/RemoteMediaPlayerProxyConfiguration.h (289696 => 289697)
--- trunk/Source/WebKit/GPUProcess/media/RemoteMediaPlayerProxyConfiguration.h 2022-02-12 16:08:49 UTC (rev 289696)
+++ trunk/Source/WebKit/GPUProcess/media/RemoteMediaPlayerProxyConfiguration.h 2022-02-12 18:16:51 UTC (rev 289697)
@@ -28,6 +28,7 @@
#if ENABLE(GPU_PROCESS)
#include <WebCore/ContentType.h>
+#include <WebCore/FourCC.h>
#include <WebCore/PlatformTextTrack.h>
#include <WebCore/SecurityOriginData.h>
#include <wtf/text/WTFString.h>
@@ -40,6 +41,12 @@
String sourceApplicationIdentifier;
String networkInterfaceName;
Vector<WebCore::ContentType> mediaContentTypesRequiringHardwareSupport;
+ std::optional<Vector<String>> allowedMediaContainerTypes;
+ std::optional<Vector<String>> allowedMediaCodecTypes;
+ std::optional<Vector<WebCore::FourCC>> allowedMediaVideoCodecIDs;
+ std::optional<Vector<WebCore::FourCC>> allowedMediaAudioCodecIDs;
+ std::optional<Vector<WebCore::FourCC>> allowedMediaCaptionFormatTypes;
+
Vector<String> preferredAudioCharacteristics;
#if ENABLE(AVF_CAPTIONS)
Vector<WebCore::PlatformTextTrackData> outOfBandTrackData;
@@ -58,6 +65,11 @@
encoder << sourceApplicationIdentifier;
encoder << networkInterfaceName;
encoder << mediaContentTypesRequiringHardwareSupport;
+ encoder << allowedMediaContainerTypes;
+ encoder << allowedMediaCodecTypes;
+ encoder << allowedMediaVideoCodecIDs;
+ encoder << allowedMediaAudioCodecIDs;
+ encoder << allowedMediaCaptionFormatTypes;
encoder << preferredAudioCharacteristics;
#if ENABLE(AVF_CAPTIONS)
encoder << outOfBandTrackData;
@@ -70,86 +82,27 @@
}
template <class Decoder>
- static std::optional<RemoteMediaPlayerProxyConfiguration> decode(Decoder& decoder)
+ static bool decode(Decoder& decoder, RemoteMediaPlayerProxyConfiguration& configuration)
{
- std::optional<String> referrer;
- decoder >> referrer;
- if (!referrer)
- return std::nullopt;
-
- std::optional<String> userAgent;
- decoder >> userAgent;
- if (!userAgent)
- return std::nullopt;
-
- std::optional<String> sourceApplicationIdentifier;
- decoder >> sourceApplicationIdentifier;
- if (!sourceApplicationIdentifier)
- return std::nullopt;
-
- std::optional<String> networkInterfaceName;
- decoder >> networkInterfaceName;
- if (!networkInterfaceName)
- return std::nullopt;
-
- std::optional<Vector<WebCore::ContentType>> mediaContentTypesRequiringHardwareSupport;
- decoder >> mediaContentTypesRequiringHardwareSupport;
- if (!mediaContentTypesRequiringHardwareSupport)
- return std::nullopt;
-
- std::optional<Vector<String>> preferredAudioCharacteristics;
- decoder >> preferredAudioCharacteristics;
- if (!preferredAudioCharacteristics)
- return std::nullopt;
-
+ return decoder.decode(configuration.referrer)
+ && decoder.decode(configuration.userAgent)
+ && decoder.decode(configuration.sourceApplicationIdentifier)
+ && decoder.decode(configuration.networkInterfaceName)
+ && decoder.decode(configuration.mediaContentTypesRequiringHardwareSupport)
+ && decoder.decode(configuration.allowedMediaContainerTypes)
+ && decoder.decode(configuration.allowedMediaCodecTypes)
+ && decoder.decode(configuration.allowedMediaVideoCodecIDs)
+ && decoder.decode(configuration.allowedMediaAudioCodecIDs)
+ && decoder.decode(configuration.allowedMediaCaptionFormatTypes)
+ && decoder.decode(configuration.preferredAudioCharacteristics)
#if ENABLE(AVF_CAPTIONS)
- std::optional<Vector<WebCore::PlatformTextTrackData>> outOfBandTrackData;
- decoder >> outOfBandTrackData;
- if (!outOfBandTrackData)
- return std::nullopt;
+ && decoder.decode(configuration.outOfBandTrackData)
#endif
-
- std::optional<WebCore::SecurityOriginData> documentSecurityOrigin;
- decoder >> documentSecurityOrigin;
- if (!documentSecurityOrigin)
- return std::nullopt;
-
- std::optional<uint64_t> logIdentifier;
- decoder >> logIdentifier;
- if (!logIdentifier)
- return std::nullopt;
-
- std::optional<bool> shouldUsePersistentCache;
- decoder >> shouldUsePersistentCache;
- if (!shouldUsePersistentCache)
- return std::nullopt;
-
- std::optional<bool> isVideo;
- decoder >> isVideo;
- if (!isVideo)
- return std::nullopt;
-
- std::optional<bool> renderingCanBeAccelerated;
- decoder >> renderingCanBeAccelerated;
- if (!renderingCanBeAccelerated)
- return std::nullopt;
-
- return {{
- WTFMove(*referrer),
- WTFMove(*userAgent),
- WTFMove(*sourceApplicationIdentifier),
- WTFMove(*networkInterfaceName),
- WTFMove(*mediaContentTypesRequiringHardwareSupport),
- WTFMove(*preferredAudioCharacteristics),
-#if ENABLE(AVF_CAPTIONS)
- WTFMove(*outOfBandTrackData),
-#endif
- WTFMove(*documentSecurityOrigin),
- *logIdentifier,
- *shouldUsePersistentCache,
- *isVideo,
- *renderingCanBeAccelerated,
- }};
+ && decoder.decode(configuration.documentSecurityOrigin)
+ && decoder.decode(configuration.logIdentifier)
+ && decoder.decode(configuration.shouldUsePersistentCache)
+ && decoder.decode(configuration.isVideo)
+ && decoder.decode(configuration.renderingCanBeAccelerated);
}
};
Modified: trunk/Source/WebKit/WebProcess/GPU/media/RemoteMediaPlayerManager.cpp (289696 => 289697)
--- trunk/Source/WebKit/WebProcess/GPU/media/RemoteMediaPlayerManager.cpp 2022-02-12 16:08:49 UTC (rev 289696)
+++ trunk/Source/WebKit/WebProcess/GPU/media/RemoteMediaPlayerManager.cpp 2022-02-12 18:16:51 UTC (rev 289697)
@@ -36,6 +36,7 @@
#include "SampleBufferDisplayLayerManager.h"
#include "WebProcess.h"
#include "WebProcessCreationParameters.h"
+#include <WebCore/ContentTypeUtilities.h>
#include <WebCore/MediaPlayer.h>
#include <wtf/HashFunctions.h>
#include <wtf/HashMap.h>
@@ -166,6 +167,12 @@
auto documentSecurityOrigin = player->documentSecurityOrigin();
proxyConfiguration.documentSecurityOrigin = documentSecurityOrigin;
+ proxyConfiguration.allowedMediaContainerTypes = player->allowedMediaContainerTypes();
+ proxyConfiguration.allowedMediaCodecTypes = player->allowedMediaCodecTypes();
+ proxyConfiguration.allowedMediaVideoCodecIDs = player->allowedMediaVideoCodecIDs();
+ proxyConfiguration.allowedMediaAudioCodecIDs = player->allowedMediaAudioCodecIDs();
+ proxyConfiguration.allowedMediaCaptionFormatTypes = player->allowedMediaCaptionFormatTypes();
+
auto identifier = MediaPlayerIdentifier::generate();
gpuProcessConnection().connection().send(Messages::RemoteMediaPlayerManagerProxy::CreateMediaPlayer(identifier, remoteEngineIdentifier, proxyConfiguration), 0);
@@ -202,6 +209,10 @@
if (parameters.isMediaStream)
return MediaPlayer::SupportsType::IsNotSupported;
#endif
+
+ if (!contentTypeMeetsContainerAndCodecTypeRequirements(parameters.type, parameters.allowedMediaContainerTypes, parameters.allowedMediaCodecTypes))
+ return MediaPlayer::SupportsType::IsNotSupported;
+
return typeCache(remoteEngineIdentifier).supportsTypeAndCodecs(parameters);
}
Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp (289696 => 289697)
--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp 2022-02-12 16:08:49 UTC (rev 289696)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp 2022-02-12 18:16:51 UTC (rev 289697)
@@ -4116,6 +4116,12 @@
settings.setMathMLEnabled(false);
#endif
settings.setPdfJSViewerEnabled(true);
+
+ settings.setAllowedMediaContainerTypes(store.getStringValueForKey(WebPreferencesKey::mediaContainerTypesAllowedInCaptivePortalModeKey()));
+ settings.setAllowedMediaCodecTypes(store.getStringValueForKey(WebPreferencesKey::mediaCodecTypesAllowedInCaptivePortalModeKey()));
+ settings.setAllowedMediaVideoCodecIDs(store.getStringValueForKey(WebPreferencesKey::mediaVideoCodecIDsAllowedInCaptivePortalModeKey()));
+ settings.setAllowedMediaAudioCodecIDs(store.getStringValueForKey(WebPreferencesKey::mediaAudioCodecIDsAllowedInCaptivePortalModeKey()));
+ settings.setAllowedMediaCaptionFormatTypes(store.getStringValueForKey(WebPreferencesKey::mediaCaptionFormatTypesAllowedInCaptivePortalModeKey()));
}
#if ENABLE(ARKIT_INLINE_PREVIEW)