Title: [284951] branches/safari-612-branch
Revision
284951
Author
[email protected]
Date
2021-10-27 14:06:03 -0700 (Wed, 27 Oct 2021)

Log Message

Cherry-pick r284523. rdar://problem/83763291

    WebRTC p2p call, VP9-SVC only low layer decoded on receiver side
    https://bugs.webkit.org/show_bug.cgi?id=231071
    <rdar://problem/83763291>

    Reviewed by Eric Carlson.

    Source/ThirdParty/libwebrtc:

    In case VP9 SVC is used, fallback to software decoder for now.

    * Source/webrtc/sdk/WebKit/WebKitDecoder.mm:

    Source/WebCore:

    Add Internals API to check whether VP9 VTB is used or not.

    Test: webrtc/vp9-svc.html

    * Modules/mediastream/PeerConnectionBackend.h:
    * Modules/mediastream/RTCPeerConnection.cpp:
    * Modules/mediastream/RTCPeerConnection.h:
    * Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.cpp:
    * Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.h:
    * Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.cpp:
    * Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.h:
    * Modules/mediastream/libwebrtc/LibWebRTCStatsCollector.cpp:
    * Modules/mediastream/libwebrtc/LibWebRTCStatsCollector.h:
    * testing/Internals.cpp:
    * testing/Internals.h:
    * testing/Internals.idl:

    LayoutTests:

    * webrtc/vp9-svc-expected.txt: Added.
    * webrtc/vp9-svc.html: Added.

    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@284523 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Modified Paths

Added Paths

Diff

Modified: branches/safari-612-branch/LayoutTests/ChangeLog (284950 => 284951)


--- branches/safari-612-branch/LayoutTests/ChangeLog	2021-10-27 21:05:57 UTC (rev 284950)
+++ branches/safari-612-branch/LayoutTests/ChangeLog	2021-10-27 21:06:03 UTC (rev 284951)
@@ -1,5 +1,58 @@
 2021-10-26  Alan Coon  <[email protected]>
 
+        Cherry-pick r284523. rdar://problem/83763291
+
+    WebRTC p2p call, VP9-SVC only low layer decoded on receiver side
+    https://bugs.webkit.org/show_bug.cgi?id=231071
+    <rdar://problem/83763291>
+    
+    Reviewed by Eric Carlson.
+    
+    Source/ThirdParty/libwebrtc:
+    
+    In case VP9 SVC is used, fallback to software decoder for now.
+    
+    * Source/webrtc/sdk/WebKit/WebKitDecoder.mm:
+    
+    Source/WebCore:
+    
+    Add Internals API to check whether VP9 VTB is used or not.
+    
+    Test: webrtc/vp9-svc.html
+    
+    * Modules/mediastream/PeerConnectionBackend.h:
+    * Modules/mediastream/RTCPeerConnection.cpp:
+    * Modules/mediastream/RTCPeerConnection.h:
+    * Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.cpp:
+    * Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.h:
+    * Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.cpp:
+    * Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.h:
+    * Modules/mediastream/libwebrtc/LibWebRTCStatsCollector.cpp:
+    * Modules/mediastream/libwebrtc/LibWebRTCStatsCollector.h:
+    * testing/Internals.cpp:
+    * testing/Internals.h:
+    * testing/Internals.idl:
+    
+    LayoutTests:
+    
+    * webrtc/vp9-svc-expected.txt: Added.
+    * webrtc/vp9-svc.html: Added.
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@284523 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2021-10-20  Youenn Fablet  <[email protected]>
+
+            WebRTC p2p call, VP9-SVC only low layer decoded on receiver side
+            https://bugs.webkit.org/show_bug.cgi?id=231071
+            <rdar://problem/83763291>
+
+            Reviewed by Eric Carlson.
+
+            * webrtc/vp9-svc-expected.txt: Added.
+            * webrtc/vp9-svc.html: Added.
+
+2021-10-26  Alan Coon  <[email protected]>
+
         Cherry-pick r283667. rdar://problem/84629931
 
     Shadertoy "truchet district" fails to compile with error: Internal error compiling shader with Metal backend"

Added: branches/safari-612-branch/LayoutTests/webrtc/vp9-svc-expected.txt (0 => 284951)


--- branches/safari-612-branch/LayoutTests/webrtc/vp9-svc-expected.txt	                        (rev 0)
+++ branches/safari-612-branch/LayoutTests/webrtc/vp9-svc-expected.txt	2021-10-27 21:06:03 UTC (rev 284951)
@@ -0,0 +1,5 @@
+
+
+PASS Use VP9 without SVC
+PASS Use VP9 with SVC
+

Added: branches/safari-612-branch/LayoutTests/webrtc/vp9-svc.html (0 => 284951)


--- branches/safari-612-branch/LayoutTests/webrtc/vp9-svc.html	                        (rev 0)
+++ branches/safari-612-branch/LayoutTests/webrtc/vp9-svc.html	2021-10-27 21:06:03 UTC (rev 284951)
@@ -0,0 +1,85 @@
+<!doctype html>
+<html>
+    <head>
+        <meta charset="utf-8">
+        <title>VP9 SVC in WebRTC</title>
+        <script src=""
+        <script src=""
+    </head>
+    <body>
+        <video id="video" autoplay playsInline width="320" height="240"></video>
+        <script src =""
+        <script>
+function enableVP9SVC(sdp)
+{
+    const firstSsrc = sdp.match(/a=ssrc:(\d+)/);
+    if (firstSsrc && firstSsrc.length > 1) {
+        let simGroup = 'a=ssrc-group:SIM';
+        const ssrc = firstSsrc[1];
+        simGroup += ` ${ssrc}`;
+        const ssrcLinesTemplate = sdp.match(new RegExp(`a=ssrc:${ssrc}(.+)`, 'g'));
+        for (let i = 0; i < 2 ; ++i) {
+            const ssrc1 = '' + Math.floor(Math.random() * 0xffffffff);
+            simGroup += ` ${ssrc1}`;
+            sdp += ssrcLinesTemplate.join('\r\n').replace(new RegExp(`a=ssrc:${ssrc}(.+)`, 'g'), `a=ssrc:${ssrc1}$1`) + '\r\n';
+        }
+        sdp += `${simGroup}\r\n`;
+    }
+    return sdp;
+}
+
+async function testVP9Decoder(useVP9SVC)
+{
+    let receivingConnection;
+    const codecs = RTCRtpSender.getCapabilities("video").codecs;
+    const vp9Codecs = codecs.filter(codec => codec.mimeType === "video/VP9");
+
+    if (!vp9Codecs.length)
+        return;
+
+    const localStream = await navigator.mediaDevices.getUserMedia({video: {width: 1280, height: 720}});
+    const remoteStream = await new Promise((resolve, reject) => {
+        track = localStream.getVideoTracks()[0];
+
+        createConnections((firstConnection) => {
+            firstConnection.addTrack(track, localStream);
+            const codecs = RTCRtpSender.getCapabilities('video').codecs.filter(c => c.mimeType.includes('VP9'));
+            firstConnection.getTransceivers()[0].setCodecPreferences(codecs);
+        }, (secondConnection) => {
+            receivingConnection = secondConnection;
+            secondConnection._ontrack_ = (trackEvent) => {
+                remoteTrack = trackEvent.track;
+                resolve(trackEvent.streams[0]);
+            };
+        }, { observeOffer : (offer) => {
+            if (useVP9SVC)
+                offer.sdp = enableVP9SVC(offer.sdp);
+            return offer;
+        }
+        });
+        setTimeout(() => reject("Test timed out"), 5000);
+    });
+    video.srcObject = remoteStream;
+    await video.play();
+
+    let counter = 0;
+    while (video.videoWidth !== 1280 && ++counter < 100)
+       await new Promise(resolve => setTimeout(resolve, 50));
+    assert_equals(video.videoWidth, 1280);
+    assert_equals(video.videoHeight, 720);
+
+    if (!window.internals || !window.internals.isSupportingVP9VTB())
+        return;
+    assert_equals(await internals.isVP9VTBDeccoderUsed(receivingConnection), !useVP9SVC);
+}
+
+promise_test(async () => {
+    return testVP9Decoder(false); 
+}, "Use VP9 without SVC");
+
+promise_test(async () => {
+    return testVP9Decoder(true); 
+}, "Use VP9 with SVC");
+        </script>
+    </body>
+</html>

Modified: branches/safari-612-branch/Source/ThirdParty/libwebrtc/ChangeLog (284950 => 284951)


--- branches/safari-612-branch/Source/ThirdParty/libwebrtc/ChangeLog	2021-10-27 21:05:57 UTC (rev 284950)
+++ branches/safari-612-branch/Source/ThirdParty/libwebrtc/ChangeLog	2021-10-27 21:06:03 UTC (rev 284951)
@@ -1,3 +1,57 @@
+2021-10-26  Alan Coon  <[email protected]>
+
+        Cherry-pick r284523. rdar://problem/83763291
+
+    WebRTC p2p call, VP9-SVC only low layer decoded on receiver side
+    https://bugs.webkit.org/show_bug.cgi?id=231071
+    <rdar://problem/83763291>
+    
+    Reviewed by Eric Carlson.
+    
+    Source/ThirdParty/libwebrtc:
+    
+    In case VP9 SVC is used, fallback to software decoder for now.
+    
+    * Source/webrtc/sdk/WebKit/WebKitDecoder.mm:
+    
+    Source/WebCore:
+    
+    Add Internals API to check whether VP9 VTB is used or not.
+    
+    Test: webrtc/vp9-svc.html
+    
+    * Modules/mediastream/PeerConnectionBackend.h:
+    * Modules/mediastream/RTCPeerConnection.cpp:
+    * Modules/mediastream/RTCPeerConnection.h:
+    * Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.cpp:
+    * Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.h:
+    * Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.cpp:
+    * Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.h:
+    * Modules/mediastream/libwebrtc/LibWebRTCStatsCollector.cpp:
+    * Modules/mediastream/libwebrtc/LibWebRTCStatsCollector.h:
+    * testing/Internals.cpp:
+    * testing/Internals.h:
+    * testing/Internals.idl:
+    
+    LayoutTests:
+    
+    * webrtc/vp9-svc-expected.txt: Added.
+    * webrtc/vp9-svc.html: Added.
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@284523 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2021-10-20  Youenn Fablet  <[email protected]>
+
+            WebRTC p2p call, VP9-SVC only low layer decoded on receiver side
+            https://bugs.webkit.org/show_bug.cgi?id=231071
+            <rdar://problem/83763291>
+
+            Reviewed by Eric Carlson.
+
+            In case VP9 SVC is used, fallback to software decoder for now.
+
+            * Source/webrtc/sdk/WebKit/WebKitDecoder.mm:
+
 2021-10-18  Russell Epstein  <[email protected]>
 
         Apply patch. rdar://problem/84124706

Modified: branches/safari-612-branch/Source/ThirdParty/libwebrtc/Source/webrtc/sdk/WebKit/WebKitDecoder.mm (284950 => 284951)


--- branches/safari-612-branch/Source/ThirdParty/libwebrtc/Source/webrtc/sdk/WebKit/WebKitDecoder.mm	2021-10-27 21:05:57 UTC (rev 284950)
+++ branches/safari-612-branch/Source/ThirdParty/libwebrtc/Source/webrtc/sdk/WebKit/WebKitDecoder.mm	2021-10-27 21:06:03 UTC (rev 284951)
@@ -31,6 +31,7 @@
 #import "WebKitUtilities.h"
 #import "api/video_codecs/video_decoder.h"
 #import "api/video_codecs/video_decoder_factory.h"
+#import "api/video_codecs/video_decoder_software_fallback_wrapper.h"
 #import "modules/video_coding/codecs/h264/include/h264.h"
 #import "modules/video_coding/include/video_error_codes.h"
 #import "sdk/objc/components/video_codec/RTCVideoDecoderH264.h"
@@ -124,9 +125,11 @@
 
 class RemoteVideoDecoder final : public webrtc::VideoDecoder {
 public:
-    explicit RemoteVideoDecoder(WebKitVideoDecoder);
+    RemoteVideoDecoder(WebKitVideoDecoder, bool isVP9);
     ~RemoteVideoDecoder();
 
+    bool isVP9() const { return m_isVP9; }
+
 private:
     int32_t InitDecode(const VideoCodec*, int32_t number_of_cores) final;
     int32_t Decode(const EncodedImage&, bool missing_frames, int64_t render_time_ms) final;
@@ -135,6 +138,7 @@
     const char* ImplementationName() const final { return "RemoteVideoToolBox"; }
 
     WebKitVideoDecoder m_internalDecoder;
+    bool m_isVP9 { false };
 };
 
 struct VideoDecoderCallbacks {
@@ -158,8 +162,9 @@
     callbacks.registerDecodeCompleteCallback = registerDecodeCompleteCallback;
 }
 
-RemoteVideoDecoder::RemoteVideoDecoder(WebKitVideoDecoder internalDecoder)
+RemoteVideoDecoder::RemoteVideoDecoder(WebKitVideoDecoder internalDecoder, bool isVP9)
     : m_internalDecoder(internalDecoder)
+    , m_isVP9(isVP9)
 {
 }
 
@@ -193,6 +198,11 @@
         encodedWidth = rtc::dchecked_cast<uint16_t>(input_image._encodedWidth);
         encodedHeight = rtc::dchecked_cast<uint16_t>(input_image._encodedHeight);
     }
+
+    // VP9 VTB does not support SVC
+    if (m_isVP9 && input_image._frameType == VideoFrameType::kVideoFrameKey && input_image.SpatialIndex() && *input_image.SpatialIndex() > 0)
+        return WEBRTC_VIDEO_CODEC_FALLBACK_SOFTWARE;
+
     return videoDecoderCallbacks().decodeCallback(m_internalDecoder, input_image.Timestamp(), input_image.data(), input_image.size(), encodedWidth, encodedHeight);
 }
 
@@ -226,7 +236,10 @@
     if (!identifier)
         return m_internalFactory->CreateVideoDecoder(format);
 
-    return std::make_unique<RemoteVideoDecoder>(identifier);
+    auto decoder = std::make_unique<RemoteVideoDecoder>(identifier, format.name == "VP9");
+    if (!decoder->isVP9())
+        return decoder;
+    return webrtc::CreateVideoDecoderSoftwareFallbackWrapper(m_internalFactory->CreateVideoDecoder(format), std::move(decoder));
 }
 
 std::unique_ptr<webrtc::VideoDecoderFactory> createWebKitDecoderFactory(WebKitH265 supportsH265, WebKitVP9 supportsVP9, WebKitVP9VTB supportsVP9VTB)

Modified: branches/safari-612-branch/Source/WebCore/ChangeLog (284950 => 284951)


--- branches/safari-612-branch/Source/WebCore/ChangeLog	2021-10-27 21:05:57 UTC (rev 284950)
+++ branches/safari-612-branch/Source/WebCore/ChangeLog	2021-10-27 21:06:03 UTC (rev 284951)
@@ -1,5 +1,72 @@
 2021-10-26  Alan Coon  <[email protected]>
 
+        Cherry-pick r284523. rdar://problem/83763291
+
+    WebRTC p2p call, VP9-SVC only low layer decoded on receiver side
+    https://bugs.webkit.org/show_bug.cgi?id=231071
+    <rdar://problem/83763291>
+    
+    Reviewed by Eric Carlson.
+    
+    Source/ThirdParty/libwebrtc:
+    
+    In case VP9 SVC is used, fallback to software decoder for now.
+    
+    * Source/webrtc/sdk/WebKit/WebKitDecoder.mm:
+    
+    Source/WebCore:
+    
+    Add Internals API to check whether VP9 VTB is used or not.
+    
+    Test: webrtc/vp9-svc.html
+    
+    * Modules/mediastream/PeerConnectionBackend.h:
+    * Modules/mediastream/RTCPeerConnection.cpp:
+    * Modules/mediastream/RTCPeerConnection.h:
+    * Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.cpp:
+    * Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.h:
+    * Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.cpp:
+    * Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.h:
+    * Modules/mediastream/libwebrtc/LibWebRTCStatsCollector.cpp:
+    * Modules/mediastream/libwebrtc/LibWebRTCStatsCollector.h:
+    * testing/Internals.cpp:
+    * testing/Internals.h:
+    * testing/Internals.idl:
+    
+    LayoutTests:
+    
+    * webrtc/vp9-svc-expected.txt: Added.
+    * webrtc/vp9-svc.html: Added.
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@284523 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2021-10-20  Youenn Fablet  <[email protected]>
+
+            WebRTC p2p call, VP9-SVC only low layer decoded on receiver side
+            https://bugs.webkit.org/show_bug.cgi?id=231071
+            <rdar://problem/83763291>
+
+            Reviewed by Eric Carlson.
+
+            Add Internals API to check whether VP9 VTB is used or not.
+
+            Test: webrtc/vp9-svc.html
+
+            * Modules/mediastream/PeerConnectionBackend.h:
+            * Modules/mediastream/RTCPeerConnection.cpp:
+            * Modules/mediastream/RTCPeerConnection.h:
+            * Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.cpp:
+            * Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.h:
+            * Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.cpp:
+            * Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.h:
+            * Modules/mediastream/libwebrtc/LibWebRTCStatsCollector.cpp:
+            * Modules/mediastream/libwebrtc/LibWebRTCStatsCollector.h:
+            * testing/Internals.cpp:
+            * testing/Internals.h:
+            * testing/Internals.idl:
+
+2021-10-26  Alan Coon  <[email protected]>
+
         Cherry-pick r284220. rdar://problem/84625558
 
     Adopt attribution AVCaptureSession SPI for GPU process

Modified: branches/safari-612-branch/Source/WebCore/Modules/mediastream/PeerConnectionBackend.h (284950 => 284951)


--- branches/safari-612-branch/Source/WebCore/Modules/mediastream/PeerConnectionBackend.h	2021-10-27 21:05:57 UTC (rev 284950)
+++ branches/safari-612-branch/Source/WebCore/Modules/mediastream/PeerConnectionBackend.h	2021-10-27 21:06:03 UTC (rev 284951)
@@ -112,6 +112,7 @@
     virtual void restartIce() = 0;
     virtual bool setConfiguration(MediaEndpointConfiguration&&) = 0;
 
+    virtual void gatherDecoderImplementationName(Function<void(String&&)>&&) = 0;
     virtual void getStats(Ref<DeferredPromise>&&) = 0;
     virtual void getStats(RTCRtpSender&, Ref<DeferredPromise>&&) = 0;
     virtual void getStats(RTCRtpReceiver&, Ref<DeferredPromise>&&) = 0;

Modified: branches/safari-612-branch/Source/WebCore/Modules/mediastream/RTCPeerConnection.cpp (284950 => 284951)


--- branches/safari-612-branch/Source/WebCore/Modules/mediastream/RTCPeerConnection.cpp	2021-10-27 21:05:57 UTC (rev 284950)
+++ branches/safari-612-branch/Source/WebCore/Modules/mediastream/RTCPeerConnection.cpp	2021-10-27 21:06:03 UTC (rev 284951)
@@ -478,6 +478,11 @@
     m_backend->getStats(WTFMove(promise));
 }
 
+void RTCPeerConnection::gatherDecoderImplementationName(Function<void(String&&)>&& callback)
+{
+    m_backend->gatherDecoderImplementationName(WTFMove(callback));
+}
+
 ExceptionOr<Ref<RTCDataChannel>> RTCPeerConnection::createDataChannel(String&& label, RTCDataChannelInit&& options)
 {
     ALWAYS_LOG(LOGIDENTIFIER);

Modified: branches/safari-612-branch/Source/WebCore/Modules/mediastream/RTCPeerConnection.h (284950 => 284951)


--- branches/safari-612-branch/Source/WebCore/Modules/mediastream/RTCPeerConnection.h	2021-10-27 21:05:57 UTC (rev 284950)
+++ branches/safari-612-branch/Source/WebCore/Modules/mediastream/RTCPeerConnection.h	2021-10-27 21:06:03 UTC (rev 284951)
@@ -153,6 +153,8 @@
 
     // 8.2 Statistics API
     void getStats(MediaStreamTrack*, Ref<DeferredPromise>&&);
+    // Used for testing
+    WEBCORE_EXPORT void gatherDecoderImplementationName(Function<void(String&&)>&&);
 
     // EventTarget
     EventTargetInterface eventTargetInterface() const final { return RTCPeerConnectionEventTargetInterfaceType; }

Modified: branches/safari-612-branch/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.cpp (284950 => 284951)


--- branches/safari-612-branch/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.cpp	2021-10-27 21:05:57 UTC (rev 284950)
+++ branches/safari-612-branch/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.cpp	2021-10-27 21:06:03 UTC (rev 284951)
@@ -301,15 +301,39 @@
 
 rtc::scoped_refptr<LibWebRTCStatsCollector> LibWebRTCMediaEndpoint::createStatsCollector(Ref<DeferredPromise>&& promise)
 {
-    return LibWebRTCStatsCollector::create([promise = WTFMove(promise), protectedThis = makeRef(*this)](auto&& report) mutable {
+    return LibWebRTCStatsCollector::create([promise = WTFMove(promise), protectedThis = makeRef(*this)](auto&& rtcReport) mutable {
         ASSERT(isMainThread());
-        if (protectedThis->isStopped() || !report)
+        if (protectedThis->isStopped())
             return;
 
-        promise->resolve<IDLInterface<RTCStatsReport>>(report.releaseNonNull());
+        promise->resolve<IDLInterface<RTCStatsReport>>(LibWebRTCStatsCollector::createReport(rtcReport));
     });
 }
 
+void LibWebRTCMediaEndpoint::gatherDecoderImplementationName(Function<void(String&&)>&& callback)
+{
+    if (!m_backend) {
+        callback({ });
+        return;
+    }
+    auto collector = LibWebRTCStatsCollector::create([callback = WTFMove(callback)](auto&& rtcReport) mutable {
+        ASSERT(isMainThread());
+        if (rtcReport) {
+            for (const auto& rtcStats : *rtcReport) {
+                if (rtcStats.type() == webrtc::RTCInboundRTPStreamStats::kType) {
+                    auto& inboundRTPStats = static_cast<const webrtc::RTCInboundRTPStreamStats&>(rtcStats);
+                    if (inboundRTPStats.decoder_implementation.is_defined()) {
+                        callback(fromStdString(*inboundRTPStats.decoder_implementation));
+                        return;
+                    }
+                }
+            }
+        }
+        callback({ });
+    });
+    m_backend->GetStats(WTFMove(collector));
+}
+
 void LibWebRTCMediaEndpoint::getStats(Ref<DeferredPromise>&& promise)
 {
     if (m_backend)

Modified: branches/safari-612-branch/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.h (284950 => 284951)


--- branches/safari-612-branch/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.h	2021-10-27 21:05:57 UTC (rev 284950)
+++ branches/safari-612-branch/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.h	2021-10-27 21:06:03 UTC (rev 284951)
@@ -85,6 +85,7 @@
     void doSetRemoteDescription(const RTCSessionDescription&);
     void doCreateOffer(const RTCOfferOptions&);
     void doCreateAnswer();
+    void gatherDecoderImplementationName(Function<void(String&&)>&&);
     void getStats(Ref<DeferredPromise>&&);
     void getStats(webrtc::RtpReceiverInterface&, Ref<DeferredPromise>&&);
     void getStats(webrtc::RtpSenderInterface&, Ref<DeferredPromise>&&);

Modified: branches/safari-612-branch/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.cpp (284950 => 284951)


--- branches/safari-612-branch/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.cpp	2021-10-27 21:05:57 UTC (rev 284950)
+++ branches/safari-612-branch/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.cpp	2021-10-27 21:06:03 UTC (rev 284951)
@@ -194,6 +194,12 @@
     return m_endpoint->setConfiguration(page->libWebRTCProvider(), configurationFromMediaEndpointConfiguration(WTFMove(configuration)));
 }
 
+void LibWebRTCPeerConnectionBackend::gatherDecoderImplementationName(Function<void(String&&)>&& callback)
+{
+    m_endpoint->gatherDecoderImplementationName(WTFMove(callback));
+
+}
+
 void LibWebRTCPeerConnectionBackend::getStats(Ref<DeferredPromise>&& promise)
 {
     m_endpoint->getStats(WTFMove(promise));

Modified: branches/safari-612-branch/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.h (284950 => 284951)


--- branches/safari-612-branch/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.h	2021-10-27 21:05:57 UTC (rev 284950)
+++ branches/safari-612-branch/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.h	2021-10-27 21:06:03 UTC (rev 284951)
@@ -67,6 +67,7 @@
     std::unique_ptr<RTCDataChannelHandler> createDataChannelHandler(const String&, const RTCDataChannelInit&) final;
     void restartIce() final;
     bool setConfiguration(MediaEndpointConfiguration&&) final;
+    void gatherDecoderImplementationName(Function<void(String&&)>&&) final;
     void getStats(Ref<DeferredPromise>&&) final;
     void getStats(RTCRtpSender&, Ref<DeferredPromise>&&) final;
     void getStats(RTCRtpReceiver&, Ref<DeferredPromise>&&) final;

Modified: branches/safari-612-branch/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCStatsCollector.cpp (284950 => 284951)


--- branches/safari-612-branch/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCStatsCollector.cpp	2021-10-27 21:05:57 UTC (rev 284950)
+++ branches/safari-612-branch/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCStatsCollector.cpp	2021-10-27 21:06:03 UTC (rev 284951)
@@ -634,13 +634,18 @@
 void LibWebRTCStatsCollector::OnStatsDelivered(const rtc::scoped_refptr<const webrtc::RTCStatsReport>& rtcReport)
 {
     callOnMainThread([this, protectedThis = rtc::scoped_refptr<LibWebRTCStatsCollector>(this), rtcReport]() {
-        m_callback(RTCStatsReport::create([rtcReport](auto& mapAdapter) {
-            if (rtcReport)
-                initializeRTCStatsReportBackingMap(mapAdapter, *rtcReport);
-        }));
+        m_callback(rtcReport);
     });
 }
 
+Ref<RTCStatsReport> LibWebRTCStatsCollector::createReport(const rtc::scoped_refptr<const webrtc::RTCStatsReport>& rtcReport)
+{
+    return RTCStatsReport::create([rtcReport](auto& mapAdapter) {
+        if (rtcReport)
+            initializeRTCStatsReportBackingMap(mapAdapter, *rtcReport);
+    });
+}
+
 }; // namespace WTF
 
 

Modified: branches/safari-612-branch/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCStatsCollector.h (284950 => 284951)


--- branches/safari-612-branch/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCStatsCollector.h	2021-10-27 21:05:57 UTC (rev 284950)
+++ branches/safari-612-branch/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCStatsCollector.h	2021-10-27 21:06:03 UTC (rev 284951)
@@ -47,9 +47,11 @@
 
 class LibWebRTCStatsCollector : public webrtc::RTCStatsCollectorCallback {
 public:
-    using CollectorCallback = CompletionHandler<void(RefPtr<RTCStatsReport>&&)>;
+    using CollectorCallback = CompletionHandler<void(const rtc::scoped_refptr<const webrtc::RTCStatsReport>&)>;
     static rtc::scoped_refptr<LibWebRTCStatsCollector> create(CollectorCallback&& callback) { return new rtc::RefCountedObject<LibWebRTCStatsCollector>(WTFMove(callback)); }
 
+    static Ref<RTCStatsReport> createReport(const rtc::scoped_refptr<const webrtc::RTCStatsReport>&);
+
     explicit LibWebRTCStatsCollector(CollectorCallback&&);
     ~LibWebRTCStatsCollector();
 

Modified: branches/safari-612-branch/Source/WebCore/testing/Internals.cpp (284950 => 284951)


--- branches/safari-612-branch/Source/WebCore/testing/Internals.cpp	2021-10-27 21:05:57 UTC (rev 284950)
+++ branches/safari-612-branch/Source/WebCore/testing/Internals.cpp	2021-10-27 21:06:03 UTC (rev 284951)
@@ -1605,6 +1605,22 @@
 #endif
 }
 
+bool Internals::isSupportingVP9VTB() const
+{
+#if USE(LIBWEBRTC)
+    if (auto* page = contextDocument()->page())
+        return page->libWebRTCProvider().isSupportingVP9VTB();
+#endif
+    return false;
+}
+
+void Internals::isVP9VTBDeccoderUsed(RTCPeerConnection& connection, DOMPromiseDeferred<IDLBoolean>&& promise)
+{
+    connection.gatherDecoderImplementationName([promise = WTFMove(promise)](auto&& name) mutable {
+        promise.resolve(name.contains("VideoToolBox"));
+    });
+}
+
 void Internals::setSFrameCounter(RTCRtpSFrameTransform& transform, const String& counter)
 {
     if (auto value = parseInteger<uint64_t>(counter))

Modified: branches/safari-612-branch/Source/WebCore/testing/Internals.h (284950 => 284951)


--- branches/safari-612-branch/Source/WebCore/testing/Internals.h	2021-10-27 21:05:57 UTC (rev 284950)
+++ branches/safari-612-branch/Source/WebCore/testing/Internals.h	2021-10-27 21:06:03 UTC (rev 284951)
@@ -639,6 +639,9 @@
     void setWebRTCH265Support(bool);
     void setWebRTCVP9Support(bool supportVP9Profile0, bool supportVP9Profile2);
     void setWebRTCVP9VTBSupport(bool);
+    bool isSupportingVP9VTB() const;
+    void isVP9VTBDeccoderUsed(RTCPeerConnection&, DOMPromiseDeferred<IDLBoolean>&&);
+
     void setSFrameCounter(RTCRtpSFrameTransform&, const String&);
     uint64_t sframeCounter(const RTCRtpSFrameTransform&);
     uint64_t sframeKeyId(const RTCRtpSFrameTransform&);

Modified: branches/safari-612-branch/Source/WebCore/testing/Internals.idl (284950 => 284951)


--- branches/safari-612-branch/Source/WebCore/testing/Internals.idl	2021-10-27 21:05:57 UTC (rev 284950)
+++ branches/safari-612-branch/Source/WebCore/testing/Internals.idl	2021-10-27 21:06:03 UTC (rev 284951)
@@ -868,6 +868,8 @@
     [Conditional=WEB_RTC] undefined setWebRTCH265Support(boolean allowed);
     [Conditional=WEB_RTC] undefined setWebRTCVP9Support(boolean supportVP9Profile0, boolean supportVP9Profile2);
     [Conditional=WEB_RTC] undefined setWebRTCVP9VTBSupport(boolean allowed);
+    [Conditional=WEB_RTC] boolean isSupportingVP9VTB();
+    [Conditional=WEB_RTC] Promise<boolean> isVP9VTBDeccoderUsed(RTCPeerConnection connection);
     [Conditional=WEB_RTC] undefined setSFrameCounter(RTCRtpSFrameTransform transform, DOMString counter);
     [Conditional=WEB_RTC] unsigned long long sframeCounter(RTCRtpSFrameTransform transform);
     [Conditional=WEB_RTC] unsigned long long sframeKeyId(RTCRtpSFrameTransform transform);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to