Skip to content

Commit c9d619e

Browse files
committed
[EME] Check support for full content type (including codecs)
https://bugs.webkit.org/show_bug.cgi?id=310709 Reviewed by NOBODY (OOPS!). 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: WebPlatformForEmbedded/WPEWebKit#1643
1 parent 7e2a2b0 commit c9d619e

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
@@ -3450,7 +3450,6 @@ webkit.org/b/189345 http/tests/media/clearkey/collect-webkit-media-session.html
34503450

34513451
media/encrypted-media [ Pass ]
34523452

3453-
webkit.org/b/205857 media/encrypted-media/mock-navigator-requestMediaKeySystemAccess.html [ Skip ]
34543453
webkit.org/b/205860 media/encrypted-media/mock-MediaKeySession-remove.html [ Skip ]
34553454

34563455

LayoutTests/platform/ios/TestExpectations

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

2780-
# New Encrypted Media API not enabled on iOS
2781-
media/encrypted-media/mock-navigator-requestMediaKeySystemAccess.html [ Skip ]
2782-
27832780
webkit.org/b/166736 fast/scrolling/page-cache-back-overflow-scroll-restore.html [ Skip ]
27842781

27852782
# 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
@@ -1018,7 +1018,6 @@ webkit.org/b/165530 compositing/layer-creation/fixed-position-out-of-view-scaled
10181018
webkit.org/b/165874 streams/pipe-to.html [ Pass Failure ]
10191019

10201020
# New Encrypted Media API not enabled on Mac
1021-
media/encrypted-media/mock-navigator-requestMediaKeySystemAccess.html [ Skip ]
10221021
media/encrypted-media/mock-MediaKeySystemAccess.html [ Skip ]
10231022
media/encrypted-media/mock-MediaKeys-setServerCertificate.html [ Skip ]
10241023
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
@@ -422,7 +422,7 @@ std::optional<Vector<CDMMediaCapability>> CDMPrivate::getSupportedCapabilitiesFo
422422
// 3.13. If the user agent and implementation definitely support playback of encrypted media data for the
423423
// combination of container, media types, robustness and local accumulated configuration in combination
424424
// with restrictions:
425-
MediaEngineSupportParameters parameters { .type = ContentType(contentType->mimeType()) };
425+
MediaEngineSupportParameters parameters { .type = ContentType(contentType->contentType()) };
426426
if (MediaPlayer::supportsType(parameters) == MediaPlayer::SupportsType::IsNotSupported) {
427427
// Try with Media Source:
428428
parameters.platformType = PlatformMediaDecodingType::MediaSource;

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

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

101+
if (codecs == "unknown"_s || codecs == "invalid"_s)
102+
return MediaPlayer::SupportsType::IsNotSupported;
103+
101104
return MediaPlayer::SupportsType::MayBeSupported;
102105
}
103106

Source/WebCore/platform/network/ParsedContentType.h

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

4646
String mimeType() const { return m_mimeType; }
47+
String contentType() const { return m_contentType; }
4748
String charset() const;
4849
void setCharset(String&&);
4950

0 commit comments

Comments
 (0)