Diff
Modified: trunk/LayoutTests/ChangeLog (290978 => 290979)
--- trunk/LayoutTests/ChangeLog 2022-03-08 08:06:12 UTC (rev 290978)
+++ trunk/LayoutTests/ChangeLog 2022-03-08 08:53:32 UTC (rev 290979)
@@ -1,3 +1,14 @@
+2022-03-08 Youenn Fablet <[email protected]>
+
+ Improve WebRTC VPX media capabilities accuracy
+ https://bugs.webkit.org/show_bug.cgi?id=237462
+
+ Reviewed by Eric Carlson.
+
+ * webrtc/video-mute-vp8.html:
+ * webrtc/vp9-expected.txt:
+ * webrtc/vp9.html:
+
2022-03-08 Chris Dumez <[email protected]>
Resync web-platform-tests/beacon from upstream
Modified: trunk/LayoutTests/webrtc/video-mute-vp8.html (290978 => 290979)
--- trunk/LayoutTests/webrtc/video-mute-vp8.html 2022-03-08 08:06:12 UTC (rev 290978)
+++ trunk/LayoutTests/webrtc/video-mute-vp8.html 2022-03-08 08:53:32 UTC (rev 290979)
@@ -32,6 +32,29 @@
const description = await pc.createOffer();
pc.close();
assert_true(description.sdp.indexOf("VP8") !== -1, "VP8 codec is in the SDP");
+
+ if (!navigator.mediaCapabilities)
+ return;
+
+ let videoConfiguration = { contentType: 'video/vp8', width: 800, height: 600, bitrate: 3000, framerate: 24 };
+ let results = await navigator.mediaCapabilities.decodingInfo({type: 'webrtc', video: videoConfiguration });
+ assert_true(results.supported, "decoder supported 1");
+ assert_false(results.powerEfficient, "decoder powerEfficient 1");
+ assert_true(results.smooth, "decoder smooth 1");
+
+ results = await navigator.mediaCapabilities.encodingInfo({type: 'webrtc', video: videoConfiguration });
+ assert_true(results.supported, "encoder supported 1");
+ assert_false(results.powerEfficient, "encoder powerEfficient 1");
+
+ videoConfiguration = { contentType: 'video/VP8', width: 800, height: 600, bitrate: 3000, framerate: 24 };
+ results = await navigator.mediaCapabilities.decodingInfo({type: 'webrtc', video: videoConfiguration });
+ assert_true(results.supported, "decoder supported 2");
+ assert_false(results.powerEfficient, "decoder powerEfficient 2");
+ assert_true(results.smooth, "decoder smooth 2");
+
+ results = await navigator.mediaCapabilities.encodingInfo({type: 'webrtc', video: videoConfiguration });
+ assert_true(results.supported, "encoder supported 2");
+ assert_false(results.powerEfficient, "encoder powerEfficient 2");
}, "Verify VP8 activation")
var track;
Modified: trunk/LayoutTests/webrtc/vp9-expected.txt (290978 => 290979)
--- trunk/LayoutTests/webrtc/vp9-expected.txt 2022-03-08 08:06:12 UTC (rev 290978)
+++ trunk/LayoutTests/webrtc/vp9-expected.txt 2022-03-08 08:53:32 UTC (rev 290979)
@@ -2,6 +2,8 @@
PASS VP9 in sender getCapabilities
PASS VP9 in receiver getCapabilities
+PASS VP9 decoding in navigator.mediaCapabilities
+PASS VP9 encoding in navigator.mediaCapabilities
PASS Verify VP9 activation
PASS Setting video exchange
PASS Ensuring connection state is connected
Modified: trunk/LayoutTests/webrtc/vp9.html (290978 => 290979)
--- trunk/LayoutTests/webrtc/vp9.html 2022-03-08 08:06:12 UTC (rev 290978)
+++ trunk/LayoutTests/webrtc/vp9.html 2022-03-08 08:53:32 UTC (rev 290979)
@@ -67,6 +67,30 @@
}, "VP9 in receiver getCapabilities");
if (hasVP9) {
+ promise_test(async () => {
+ let videoConfiguration = { contentType: 'video/vp9', width: 800, height: 600, bitrate: 3000, framerate: 24 };
+ let results = await navigator.mediaCapabilities.decodingInfo({type: 'webrtc', video: videoConfiguration });
+ assert_true(results.supported, "decoder supported 1");
+ assert_true(results.smooth, "decoder smooth 1");
+
+ videoConfiguration = { contentType: 'video/VP9', width: 800, height: 600, bitrate: 3000, framerate: 24 };
+ results = await navigator.mediaCapabilities.decodingInfo({type: 'webrtc', video: videoConfiguration });
+ assert_true(results.supported, "decoder supported 2");
+ assert_true(results.smooth, "decoder smooth 2");
+ }, "VP9 decoding in navigator.mediaCapabilities");
+
+ promise_test(async () => {
+ let videoConfiguration = { contentType: 'video/vp9', width: 800, height: 600, bitrate: 3000, framerate: 24 };
+ let results = await navigator.mediaCapabilities.encodingInfo({type: 'webrtc', video: videoConfiguration });
+ assert_true(results.supported, "encoder supported 1");
+ assert_equals(results.powerEfficient, results.smooth, "encoder powerEfficient 1");
+
+ videoConfiguration = { contentType: 'video/VP9', width: 800, height: 600, bitrate: 3000, framerate: 24 };
+ results = await navigator.mediaCapabilities.encodingInfo({type: 'webrtc', video: videoConfiguration });
+ assert_true(results.supported, "encoder supported 2");
+ assert_equals(results.powerEfficient, results.smooth, "encoder powerEfficient 2");
+ }, "VP9 encoding in navigator.mediaCapabilities");
+
promise_test(async (test) => {
const pc = new RTCPeerConnection();
pc.addTransceiver("video");
Modified: trunk/Source/WebCore/ChangeLog (290978 => 290979)
--- trunk/Source/WebCore/ChangeLog 2022-03-08 08:06:12 UTC (rev 290978)
+++ trunk/Source/WebCore/ChangeLog 2022-03-08 08:53:32 UTC (rev 290979)
@@ -1,3 +1,18 @@
+2022-03-08 Youenn Fablet <[email protected]>
+
+ Improve WebRTC VPX media capabilities accuracy
+ https://bugs.webkit.org/show_bug.cgi?id=237462
+
+ Reviewed by Eric Carlson.
+
+ Reuse VPx decoder media capabilities routines for WebRTC.
+ Use caseless string comparison for content type.
+ Covered by updated tests.
+
+ * platform/graphics/cocoa/VP9UtilitiesCocoa.h:
+ * platform/graphics/cocoa/VP9UtilitiesCocoa.mm:
+ * platform/mediastream/libwebrtc/LibWebRTCProvider.cpp:
+
2022-03-07 Simon Fraser <[email protected]>
Rename VolatilityState to SetNonVolatileResult
Modified: trunk/Source/WebCore/platform/graphics/cocoa/VP9UtilitiesCocoa.h (290978 => 290979)
--- trunk/Source/WebCore/platform/graphics/cocoa/VP9UtilitiesCocoa.h 2022-03-08 08:06:12 UTC (rev 290978)
+++ trunk/Source/WebCore/platform/graphics/cocoa/VP9UtilitiesCocoa.h 2022-03-08 08:53:32 UTC (rev 290979)
@@ -49,6 +49,8 @@
bool isVP8DecoderAvailable();
bool isVPCodecConfigurationRecordSupported(const VPCodecConfigurationRecord&);
std::optional<MediaCapabilitiesInfo> validateVPParameters(const VPCodecConfigurationRecord&, const VideoConfiguration&);
+std::optional<MediaCapabilitiesInfo> computeVPParameters(const VideoConfiguration&);
+bool isVPSoftwareDecoderSmooth(const VideoConfiguration&);
RetainPtr<CMFormatDescriptionRef> createFormatDescriptionFromVP9HeaderParser(const vp9_parser::Vp9HeaderParser&, const webm::Element<webm::Colour>&);
Modified: trunk/Source/WebCore/platform/graphics/cocoa/VP9UtilitiesCocoa.mm (290978 => 290979)
--- trunk/Source/WebCore/platform/graphics/cocoa/VP9UtilitiesCocoa.mm 2022-03-08 08:06:12 UTC (rev 290978)
+++ trunk/Source/WebCore/platform/graphics/cocoa/VP9UtilitiesCocoa.mm 2022-03-08 08:53:32 UTC (rev 290979)
@@ -249,7 +249,22 @@
if (*videoConfiguration.colorGamut == ColorGamut::Rec2020 && codecConfiguration.colorPrimaries != 9)
return std::nullopt;
}
+ return computeVPParameters(videoConfiguration);
+}
+bool isVPSoftwareDecoderSmooth(const VideoConfiguration& videoConfiguration)
+{
+ if (videoConfiguration.height <= 1080 && videoConfiguration.framerate > 60)
+ return false;
+
+ if (videoConfiguration.height <= 2160 && videoConfiguration.framerate > 30)
+ return false;
+
+ return true;
+}
+
+std::optional<MediaCapabilitiesInfo> computeVPParameters(const VideoConfiguration& videoConfiguration)
+{
MediaCapabilitiesInfo info;
if (vp9HardwareDecoderAvailable()) {
@@ -278,12 +293,7 @@
// SW VP9 Decoder has much more variable capabilities depending on CPU characteristics.
// FIXME: Add a lookup table for device-to-capabilities. For now, assume that the SW VP9
// decoder can support 4K @ 30.
- if (videoConfiguration.height <= 1080 && videoConfiguration.framerate > 60)
- info.smooth = false;
- if (videoConfiguration.height <= 2160 && videoConfiguration.framerate > 30)
- info.smooth = false;
- else
- info.smooth = true;
+ info.smooth = isVPSoftwareDecoderSmooth(videoConfiguration);
// For wall-powered devices, always report VP9 as supported, even if not powerEfficient.
if (!systemHasBattery()) {
Modified: trunk/Source/WebCore/platform/mediastream/libwebrtc/LibWebRTCProvider.cpp (290978 => 290979)
--- trunk/Source/WebCore/platform/mediastream/libwebrtc/LibWebRTCProvider.cpp 2022-03-08 08:06:12 UTC (rev 290978)
+++ trunk/Source/WebCore/platform/mediastream/libwebrtc/LibWebRTCProvider.cpp 2022-03-08 08:53:32 UTC (rev 290979)
@@ -57,6 +57,10 @@
#include <wtf/NeverDestroyed.h>
#endif
+#if PLATFORM(COCOA)
+#include "VP9UtilitiesCocoa.h"
+#endif
+
namespace WebCore {
#if !USE(LIBWEBRTC)
@@ -569,6 +573,19 @@
}
#endif // USE(LIBWEBRTC)
+#if !PLATFORM(COCOA)
+// FIXME: Implement these routines.
+static std::optional<MediaCapabilitiesInfo> computeVPParameters(const VideoConfiguration&)
+{
+ return { };
+}
+
+static bool isVPSoftwareDecoderSmooth(const VideoConfiguration&)
+{
+ return true;
+}
+#endif
+
void LibWebRTCProvider::createDecodingConfiguration(MediaDecodingConfiguration&& configuration, DecodingConfigurationCallback&& callback)
{
ASSERT(configuration.type == MediaDecodingType::WebRTC);
@@ -584,17 +601,23 @@
callback({ });
return;
}
- info.supported = true;
-#if PLATFORM(COCOA)
auto containerType = contentType.containerType();
- if (containerType == "video/vp8")
+ if (equalIgnoringASCIICase(containerType, "video/vp8")) {
info.powerEfficient = false;
- else if (containerType == "video/vp9")
- info.powerEfficient = isSupportingVP9VTB();
- else
+ info.smooth = isVPSoftwareDecoderSmooth(*info.supportedConfiguration.video);
+ } else if (equalIgnoringASCIICase(containerType, "video/vp9")) {
+ auto decodingInfo = computeVPParameters(*info.supportedConfiguration.video);
+ if (decodingInfo && !decodingInfo->supported && isSupportingVP9VTB()) {
+ callback({ });
+ return;
+ }
+ info.powerEfficient = decodingInfo ? decodingInfo->powerEfficient : true;
+ info.smooth = decodingInfo ? decodingInfo->smooth : isVPSoftwareDecoderSmooth(*info.supportedConfiguration.video);
+ } else {
+ // FIXME: Provide more granular H.264 decoder information.
info.powerEfficient = true;
- info.smooth = info.powerEfficient;
-#endif
+ info.smooth = true;
+ }
}
if (info.supportedConfiguration.audio) {
ContentType contentType { info.supportedConfiguration.audio->contentType };
@@ -603,8 +626,8 @@
callback({ });
return;
}
- info.supported = true;
}
+ info.supported = true;
callback(WTFMove(info));
#else
UNUSED_PARAM(configuration);
@@ -630,13 +653,15 @@
info.supported = true;
#if PLATFORM(COCOA)
auto containerType = contentType.containerType();
- if (containerType == "video/vp8")
+ if (equalIgnoringASCIICase(containerType, "video/vp8") || equalIgnoringASCIICase(containerType, "video/vp9")) {
info.powerEfficient = false;
- else if (containerType == "video/vp9")
- info.powerEfficient = isSupportingVP9VTB();
- else
+ // FIXME: Provide more granular VPX encoder smoothness.
+ info.smooth = false;
+ } else {
+ // FIXME: Provide more granular H.264 encoder information.
info.powerEfficient = true;
- info.smooth = info.powerEfficient;
+ info.smooth = true;
+ }
#endif
}
if (info.supportedConfiguration.audio) {