Skip to content

Commit 353da33

Browse files
committed
[EME] Check support for full content type (including codecs)
https://bugs.webkit.org/show_bug.cgi?id=310709 Reviewed by Jer Noble and Xabier Rodriguez-Calvar. When evaluating media capabilities for requestMediaKeySystemAccess, we use pass ParsedContentType's m_mimeType to the MediaSource, which omits parameters of the MIME type like codecs. The right field to use here is m_contentType, so MediaSource can check support against the full MIME type, rather than just its container type. * LayoutTests/media/encrypted-media/mock-navigator-requestMediaKeySystemAccess-expected.txt: * LayoutTests/media/encrypted-media/mock-navigator-requestMediaKeySystemAccess.html: Add test with supported type but unknown codec. * LayoutTests/platform/glib/TestExpectations: Unflag mock-navigator-requestMediaKeySystemAccess.html. * LayoutTests/platform/ios/TestExpectations: Ditto. * LayoutTests/platform/mac/TestExpectations: Ditto. * Source/WebCore/platform/encryptedmedia/CDMPrivate.cpp: (WebCore::CDMPrivate::getSupportedCapabilitiesForAudioVideoType): Use full contentType for MediaEngineSupportParameters. * Source/WebCore/platform/mock/mediasource/MockMediaPlayerMediaSource.cpp: (WebCore::MockMediaPlayerMediaSource::supportsType): Return NotSupported if codec is 'unknown' or 'invalid'. * Source/WebCore/platform/network/ParsedContentType.h: (WebCore::ParsedContentType::contentType const): Added, returns m_contentType. Original author: Andrzej Surdej <Andrzej_Surdej@comcast.com> See: #1643 Canonical link: https://commits.webkit.org/310696@main
1 parent ba8a9c5 commit 353da33

8 files changed

Lines changed: 21 additions & 6 deletions

File tree

LayoutTests/media/encrypted-media/mock-navigator-requestMediaKeySystemAccess-expected.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ EXPECTED (access.getConfiguration().sessionTypes[0] == 'temporary') OK
1313
EXPECTED (access.getConfiguration().distinctiveIdentifier == 'not-allowed') OK
1414
EXPECTED (access.getConfiguration().persistentState == 'not-allowed') OK
1515

16+
SET capabilities = '[ { "initDataTypes": [ "mock" ], "videoCapabilities": [ { "contentType": "video/mock; codecs=\"unknown\"" } ] } ]'
17+
RUN(promise = navigator.requestMediaKeySystemAccess("org.webkit.mock", capabilities))
18+
Promise rejected correctly OK
19+
EXPECTED (exceptionCode.name == 'NotSupportedError') OK
20+
1621
SET capabilities = '[ { "initDataTypes": [ "mock" ], "videoCapabilities": [ { "contentType": "unknown/mime; codecs=\"unknown\"" } ] } ]'
1722
RUN(promise = navigator.requestMediaKeySystemAccess("org.webkit.mock", capabilities))
1823
Promise rejected correctly OK

LayoutTests/media/encrypted-media/mock-navigator-requestMediaKeySystemAccess.html

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,17 @@
6666
});
6767
},
6868

69+
function() {
70+
failingTestWithCapabilities([{
71+
initDataTypes: ['mock'],
72+
videoCapabilities: [{ contentType: 'video/mock; codecs="unknown"' }]
73+
}],
74+
exceptionCode => {
75+
window.exceptionCode = exceptionCode;
76+
testExpected('exceptionCode.name', 'NotSupportedError');
77+
});
78+
},
79+
6980
function() {
7081
failingTestWithCapabilities([{
7182
initDataTypes: ['mock'],

LayoutTests/platform/glib/TestExpectations

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2597,7 +2597,6 @@ webkit.org/b/189345 http/tests/media/clearkey/collect-webkit-media-session.html
25972597

25982598
media/encrypted-media [ Pass ]
25992599

2600-
webkit.org/b/205857 media/encrypted-media/mock-navigator-requestMediaKeySystemAccess.html [ Skip ]
26012600
webkit.org/b/205860 media/encrypted-media/mock-MediaKeySession-remove.html [ Skip ]
26022601

26032602
webkit.org/b/251550 media/encrypted-media/mock-MediaKeySession-generateRequest.html [ Crash Pass ]

LayoutTests/platform/ios/TestExpectations

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2727,9 +2727,6 @@ webkit.org/b/245610 http/tests/security/xss-DENIED-xsl-external-entity.xml [ Fai
27272727
# Form validation popover does not obey minimum font size setting on iOS but Dynamic Type instead.
27282728
fast/forms/validation-message-minimum-font-size.html [ Skip ]
27292729

2730-
# New Encrypted Media API not enabled on iOS
2731-
media/encrypted-media/mock-navigator-requestMediaKeySystemAccess.html [ Skip ]
2732-
27332730
webkit.org/b/166736 fast/scrolling/page-cache-back-overflow-scroll-restore.html [ Skip ]
27342731

27352732
# Requires changes to QuickLook.framework tracked by rdar://problem/28544527

LayoutTests/platform/mac/TestExpectations

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1118,7 +1118,6 @@ webkit.org/b/165530 compositing/layer-creation/fixed-position-out-of-view-scaled
11181118
webkit.org/b/165874 streams/pipe-to.html [ Pass Failure ]
11191119

11201120
# New Encrypted Media API not enabled on Mac
1121-
media/encrypted-media/mock-navigator-requestMediaKeySystemAccess.html [ Skip ]
11221121
media/encrypted-media/mock-MediaKeySystemAccess.html [ Skip ]
11231122
media/encrypted-media/mock-MediaKeys-setServerCertificate.html [ Skip ]
11241123
media/encrypted-media/mock-MediaKeys-createSession.html [ Skip ]

Source/WebCore/platform/encryptedmedia/CDMPrivate.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,7 @@ std::optional<Vector<CDMMediaCapability>> CDMPrivate::getSupportedCapabilitiesFo
420420
// combination of container, media types, robustness and local accumulated configuration in combination
421421
// with restrictions:
422422
MediaEngineSupportParameters parameters;
423-
parameters.type = ContentType(contentType->mimeType());
423+
parameters.type = ContentType(contentType->contentType());
424424
if (MediaPlayer::supportsType(parameters) == MediaPlayer::SupportsType::IsNotSupported) {
425425

426426
// Try with Media Source:

Source/WebCore/platform/mock/mediasource/MockMediaPlayerMediaSource.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,9 @@ MediaPlayer::SupportsType MockMediaPlayerMediaSource::supportsType(const MediaEn
9494
if (codecs == "mock"_s || codecs == "kcom"_s)
9595
return MediaPlayer::SupportsType::IsSupported;
9696

97+
if (codecs == "unknown"_s || codecs == "invalid"_s)
98+
return MediaPlayer::SupportsType::IsNotSupported;
99+
97100
return MediaPlayer::SupportsType::MayBeSupported;
98101
}
99102

Source/WebCore/platform/network/ParsedContentType.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ class ParsedContentType {
4949
ParsedContentType(ParsedContentType&&) = default;
5050

5151
String mimeType() const { return m_mimeType; }
52+
String contentType() const { return m_contentType; }
5253
String charset() const;
5354
void setCharset(String&&);
5455

0 commit comments

Comments
 (0)