Title: [273550] trunk
Revision
273550
Author
[email protected]
Date
2021-02-26 04:05:33 -0800 (Fri, 26 Feb 2021)

Log Message

Add support for WebRTC priority
https://bugs.webkit.org/show_bug.cgi?id=222416

Reviewed by Eric Carlson.

LayoutTests/imported/w3c:

* resources/import-expectations.json:
* web-platform-tests/webrtc-priority/META.yml: Added.
* web-platform-tests/webrtc-priority/RTCPeerConnection-ondatachannel-expected.txt: Added.
* web-platform-tests/webrtc-priority/RTCPeerConnection-ondatachannel.html: Added.
* web-platform-tests/webrtc-priority/RTCRtpParameters-encodings-expected.txt: Added.
* web-platform-tests/webrtc-priority/RTCRtpParameters-encodings.html: Added.
* web-platform-tests/webrtc-priority/w3c-import.log: Added.

Source/WebCore:

Implement https://w3c.github.io/webrtc-priority/ by piping priorities between binding and backend.

Tests: imported/w3c/web-platform-tests/webrtc-priority/RTCPeerConnection-ondatachannel.html
       imported/w3c/web-platform-tests/webrtc-priority/RTCRtpParameters-encodings.html

* Modules/mediastream/RTCDataChannel.h:
* Modules/mediastream/RTCDataChannel.idl:
* Modules/mediastream/RTCRtpEncodingParameters.h:
* Modules/mediastream/RTCRtpEncodingParameters.idl:
* Modules/mediastream/libwebrtc/LibWebRTCDataChannelHandler.cpp:
(WebCore::LibWebRTCDataChannelHandler::fromRTCDataChannelInit):
(WebCore::LibWebRTCDataChannelHandler::channelEvent):
(WebCore::fromStdString): Deleted.
* Modules/mediastream/libwebrtc/LibWebRTCUtils.cpp:
(WebCore::fromRTCPriorityType):
(WebCore::toRTCPriorityType):
(WebCore::toWebRTCBitRatePriority):
(WebCore::fromWebRTCBitRatePriority):
(WebCore::toRTCEncodingParameters):
(WebCore::fromRTCEncodingParameters):
(WebCore::updateRTCRtpSendParameters):
* Modules/mediastream/libwebrtc/LibWebRTCUtils.h:
* WebCore.xcodeproj/project.pbxproj:
* platform/mediastream/RTCDataChannelHandler.h:
* platform/mediastream/RTCPriorityType.h: Renamed from Source/WebCore/Modules/mediastream/RTCPriorityType.h.

Modified Paths

Added Paths

Removed Paths

Diff

Modified: trunk/LayoutTests/imported/w3c/ChangeLog (273549 => 273550)


--- trunk/LayoutTests/imported/w3c/ChangeLog	2021-02-26 11:53:07 UTC (rev 273549)
+++ trunk/LayoutTests/imported/w3c/ChangeLog	2021-02-26 12:05:33 UTC (rev 273550)
@@ -1,3 +1,18 @@
+2021-02-26  Youenn Fablet  <[email protected]>
+
+        Add support for WebRTC priority
+        https://bugs.webkit.org/show_bug.cgi?id=222416
+
+        Reviewed by Eric Carlson.
+
+        * resources/import-expectations.json:
+        * web-platform-tests/webrtc-priority/META.yml: Added.
+        * web-platform-tests/webrtc-priority/RTCPeerConnection-ondatachannel-expected.txt: Added.
+        * web-platform-tests/webrtc-priority/RTCPeerConnection-ondatachannel.html: Added.
+        * web-platform-tests/webrtc-priority/RTCRtpParameters-encodings-expected.txt: Added.
+        * web-platform-tests/webrtc-priority/RTCRtpParameters-encodings.html: Added.
+        * web-platform-tests/webrtc-priority/w3c-import.log: Added.
+
 2021-02-25  Antoine Quint  <[email protected]>
 
         border-image-outset doesn't handle float values

Modified: trunk/LayoutTests/imported/w3c/resources/import-expectations.json (273549 => 273550)


--- trunk/LayoutTests/imported/w3c/resources/import-expectations.json	2021-02-26 11:53:07 UTC (rev 273549)
+++ trunk/LayoutTests/imported/w3c/resources/import-expectations.json	2021-02-26 12:05:33 UTC (rev 273550)
@@ -430,6 +430,7 @@
     "web-platform-tests/webmessaging": "import", 
     "web-platform-tests/webmessaging/": "import", 
     "web-platform-tests/webrtc": "import", 
+    "web-platform-tests/webrtc-priority": "import", 
     "web-platform-tests/webrtc/legacy": "skip", 
     "web-platform-tests/websockets": "import", 
     "web-platform-tests/webstorage": "skip", 

Added: trunk/LayoutTests/imported/w3c/web-platform-tests/webrtc-priority/META.yml (0 => 273550)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/webrtc-priority/META.yml	                        (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/webrtc-priority/META.yml	2021-02-26 12:05:33 UTC (rev 273550)
@@ -0,0 +1 @@
+spec: https://w3c.github.io/webrtc-priority/

Added: trunk/LayoutTests/imported/w3c/web-platform-tests/webrtc-priority/RTCPeerConnection-ondatachannel-expected.txt (0 => 273550)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/webrtc-priority/RTCPeerConnection-ondatachannel-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/webrtc-priority/RTCPeerConnection-ondatachannel-expected.txt	2021-02-26 12:05:33 UTC (rev 273550)
@@ -0,0 +1,4 @@
+
+FAIL In-band negotiated channel created on remote peer should match the same configuration as local peer assert_equals: expected "high" but got "low"
+PASS In-band negotiated channel created on remote peer should match the same (default) configuration as local peer
+

Added: trunk/LayoutTests/imported/w3c/web-platform-tests/webrtc-priority/RTCPeerConnection-ondatachannel.html (0 => 273550)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/webrtc-priority/RTCPeerConnection-ondatachannel.html	                        (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/webrtc-priority/RTCPeerConnection-ondatachannel.html	2021-02-26 12:05:33 UTC (rev 273550)
@@ -0,0 +1,66 @@
+<!doctype html>
+<meta charset=utf-8>
+<title>RTCPeerConnection.prototype.ondatachannel</title>
+<script src=""
+<script src=""
+<script src=""
+<script>
+'use strict';
+
+promise_test(async (t) => {
+  const resolver = new Resolver();
+  const pc1 = new RTCPeerConnection();
+  const pc2 = new RTCPeerConnection();
+  t.add_cleanup(() => pc1.close());
+  t.add_cleanup(() => pc2.close());
+
+  const dc1 = pc1.createDataChannel('test', {
+    ordered: false,
+    maxRetransmits: 1,
+    protocol: 'custom',
+    priority: 'high'
+  });
+
+  assert_equals(dc1.priority, 'high');
+
+  pc2._ondatachannel_ = t.step_func((event) => {
+    const dc2 = event.channel;
+
+    assert_equals(dc2.priority, 'high');
+
+    resolver.resolve();
+  });
+
+  exchangeIceCandidates(pc1, pc2);
+  await exchangeOfferAnswer(pc1, pc2);
+
+  await resolver;
+}, 'In-band negotiated channel created on remote peer should match the same configuration as local ' +
+  'peer');
+
+promise_test(async (t) => {
+  const resolver = new Resolver();
+  const pc1 = new RTCPeerConnection();
+  const pc2 = new RTCPeerConnection();
+  t.add_cleanup(() => pc1.close());
+  t.add_cleanup(() => pc2.close());
+
+  const dc1 = pc1.createDataChannel('');
+
+  assert_equals(dc1.priority, 'low');
+
+  pc2._ondatachannel_ = t.step_func((event) => {
+    const dc2 = event.channel;
+    assert_equals(dc2.priority, 'low');
+
+    resolver.resolve();
+  });
+
+  exchangeIceCandidates(pc1, pc2);
+  await exchangeOfferAnswer(pc1, pc2);
+
+  await resolver;
+}, 'In-band negotiated channel created on remote peer should match the same (default) ' +
+  'configuration as local peer');
+
+</script>

Added: trunk/LayoutTests/imported/w3c/web-platform-tests/webrtc-priority/RTCRtpParameters-encodings-expected.txt (0 => 273550)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/webrtc-priority/RTCRtpParameters-encodings-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/webrtc-priority/RTCRtpParameters-encodings-expected.txt	2021-02-26 12:05:33 UTC (rev 273550)
@@ -0,0 +1,9 @@
+
+PASS sender.getParameters() should return sendEncodings set by addTransceiver()
+PASS setParameters() with modified encoding.active should succeed with RTCRtpTransceiverInit
+PASS setParameters() with modified encoding.active should succeed without RTCRtpTransceiverInit
+PASS setParameters() with modified encoding.priority should succeed with RTCRtpTransceiverInit
+PASS setParameters() with modified encoding.priority should succeed without RTCRtpTransceiverInit
+PASS setParameters() with modified encoding.networkPriority should succeed with RTCRtpTransceiverInit
+PASS setParameters() with modified encoding.networkPriority should succeed without RTCRtpTransceiverInit
+

Added: trunk/LayoutTests/imported/w3c/web-platform-tests/webrtc-priority/RTCRtpParameters-encodings.html (0 => 273550)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/webrtc-priority/RTCRtpParameters-encodings.html	                        (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/webrtc-priority/RTCRtpParameters-encodings.html	2021-02-26 12:05:33 UTC (rev 273550)
@@ -0,0 +1,44 @@
+<!doctype html>
+<meta charset=utf-8>
+<title>RTCRtpParameters encodings</title>
+<script src=""
+<script src=""
+<script src=""
+<script src=""
+<script>
+  'use strict';
+
+  promise_test(async t => {
+    const pc = new RTCPeerConnection();
+    t.add_cleanup(() => pc.close());
+    const { sender } = pc.addTransceiver('video', {
+      sendEncodings: [{
+        active: false,
+        priority: 'low',
+        networkPriority: 'low',
+        maxBitrate: 8,
+        maxFramerate: 25,
+        rid: 'foo'
+      }]
+    });
+    await doOfferAnswerExchange(t, pc);
+
+    const param = sender.getParameters();
+    validateSenderRtpParameters(param);
+    const encoding = getFirstEncoding(param);
+
+    assert_equals(encoding.active, false);
+    assert_equals(encoding.priority, 'low');
+    assert_equals(encoding.networkPriority, 'low');
+  }, `sender.getParameters() should return sendEncodings set by addTransceiver()`);
+
+  test_modified_encoding('audio', 'active', false, true,
+    'setParameters() with modified encoding.active should succeed');
+
+  test_modified_encoding('audio', 'priority', 'very-low', 'high',
+    'setParameters() with modified encoding.priority should succeed');
+
+  test_modified_encoding('audio', 'networkPriority', 'very-low', 'high',
+    'setParameters() with modified encoding.networkPriority should succeed');
+
+</script>

Added: trunk/LayoutTests/imported/w3c/web-platform-tests/webrtc-priority/w3c-import.log (0 => 273550)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/webrtc-priority/w3c-import.log	                        (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/webrtc-priority/w3c-import.log	2021-02-26 12:05:33 UTC (rev 273550)
@@ -0,0 +1,19 @@
+The tests in this directory were imported from the W3C repository.
+Do NOT modify these tests directly in WebKit.
+Instead, create a pull request on the WPT github:
+	https://github.com/web-platform-tests/wpt
+
+Then run the Tools/Scripts/import-w3c-tests in WebKit to reimport
+
+Do NOT modify or remove this file.
+
+------------------------------------------------------------------------
+Properties requiring vendor prefixes:
+None
+Property values requiring vendor prefixes:
+None
+------------------------------------------------------------------------
+List of files:
+/LayoutTests/imported/w3c/web-platform-tests/webrtc-priority/META.yml
+/LayoutTests/imported/w3c/web-platform-tests/webrtc-priority/RTCPeerConnection-ondatachannel.html
+/LayoutTests/imported/w3c/web-platform-tests/webrtc-priority/RTCRtpParameters-encodings.html

Modified: trunk/Source/WebCore/ChangeLog (273549 => 273550)


--- trunk/Source/WebCore/ChangeLog	2021-02-26 11:53:07 UTC (rev 273549)
+++ trunk/Source/WebCore/ChangeLog	2021-02-26 12:05:33 UTC (rev 273550)
@@ -1,3 +1,36 @@
+2021-02-26  Youenn Fablet  <[email protected]>
+
+        Add support for WebRTC priority
+        https://bugs.webkit.org/show_bug.cgi?id=222416
+
+        Reviewed by Eric Carlson.
+
+        Implement https://w3c.github.io/webrtc-priority/ by piping priorities between binding and backend.
+
+        Tests: imported/w3c/web-platform-tests/webrtc-priority/RTCPeerConnection-ondatachannel.html
+               imported/w3c/web-platform-tests/webrtc-priority/RTCRtpParameters-encodings.html
+
+        * Modules/mediastream/RTCDataChannel.h:
+        * Modules/mediastream/RTCDataChannel.idl:
+        * Modules/mediastream/RTCRtpEncodingParameters.h:
+        * Modules/mediastream/RTCRtpEncodingParameters.idl:
+        * Modules/mediastream/libwebrtc/LibWebRTCDataChannelHandler.cpp:
+        (WebCore::LibWebRTCDataChannelHandler::fromRTCDataChannelInit):
+        (WebCore::LibWebRTCDataChannelHandler::channelEvent):
+        (WebCore::fromStdString): Deleted.
+        * Modules/mediastream/libwebrtc/LibWebRTCUtils.cpp:
+        (WebCore::fromRTCPriorityType):
+        (WebCore::toRTCPriorityType):
+        (WebCore::toWebRTCBitRatePriority):
+        (WebCore::fromWebRTCBitRatePriority):
+        (WebCore::toRTCEncodingParameters):
+        (WebCore::fromRTCEncodingParameters):
+        (WebCore::updateRTCRtpSendParameters):
+        * Modules/mediastream/libwebrtc/LibWebRTCUtils.h:
+        * WebCore.xcodeproj/project.pbxproj:
+        * platform/mediastream/RTCDataChannelHandler.h:
+        * platform/mediastream/RTCPriorityType.h: Renamed from Source/WebCore/Modules/mediastream/RTCPriorityType.h.
+
 2021-02-26  Imanol Fernandez  <[email protected]>
 
         Implement OpenXR port graphics binding

Modified: trunk/Source/WebCore/Modules/mediastream/RTCDataChannel.h (273549 => 273550)


--- trunk/Source/WebCore/Modules/mediastream/RTCDataChannel.h	2021-02-26 11:53:07 UTC (rev 273549)
+++ trunk/Source/WebCore/Modules/mediastream/RTCDataChannel.h	2021-02-26 12:05:33 UTC (rev 273550)
@@ -58,6 +58,7 @@
     String protocol() const { return m_options.protocol; }
     bool negotiated() const { return *m_options.negotiated; };
     Optional<unsigned short> id() const { return m_options.id; };
+    RTCPriorityType priority() const { return m_options.priority; };
 
     String label() const { return m_label; }
     RTCDataChannelState readyState() const {return m_readyState; }

Modified: trunk/Source/WebCore/Modules/mediastream/RTCDataChannel.idl (273549 => 273550)


--- trunk/Source/WebCore/Modules/mediastream/RTCDataChannel.idl	2021-02-26 11:53:07 UTC (rev 273549)
+++ trunk/Source/WebCore/Modules/mediastream/RTCDataChannel.idl	2021-02-26 12:05:33 UTC (rev 273550)
@@ -40,6 +40,7 @@
     readonly attribute unsigned short? id;
     readonly attribute RTCDataChannelState readyState;
     readonly attribute unsigned long bufferedAmount;
+    readonly attribute RTCPriorityType priority;
     attribute unsigned long bufferedAmountLowThreshold;
 
     attribute DOMString binaryType;

Deleted: trunk/Source/WebCore/Modules/mediastream/RTCPriorityType.h (273549 => 273550)


--- trunk/Source/WebCore/Modules/mediastream/RTCPriorityType.h	2021-02-26 11:53:07 UTC (rev 273549)
+++ trunk/Source/WebCore/Modules/mediastream/RTCPriorityType.h	2021-02-26 12:05:33 UTC (rev 273550)
@@ -1,36 +0,0 @@
-/*
- * Copyright (C) 2018 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
-
-#if ENABLE(WEB_RTC)
-
-namespace WebCore {
-
-enum class RTCPriorityType { VeryLow, Low, Medium, High };
-
-} // namespace WebCore
-
-#endif // ENABLE(WEB_RTC)

Modified: trunk/Source/WebCore/Modules/mediastream/RTCRtpEncodingParameters.h (273549 => 273550)


--- trunk/Source/WebCore/Modules/mediastream/RTCRtpEncodingParameters.h	2021-02-26 11:53:07 UTC (rev 273549)
+++ trunk/Source/WebCore/Modules/mediastream/RTCRtpEncodingParameters.h	2021-02-26 12:05:33 UTC (rev 273550)
@@ -41,7 +41,8 @@
     RTCRtpFecParameters fec;
     Optional<RTCDtxStatus> dtx;
     bool active { false};
-    RTCPriorityType priority { RTCPriorityType::Medium };
+    RTCPriorityType priority { RTCPriorityType::Low };
+    Optional<RTCPriorityType> networkPriority;
     unsigned long maxBitrate { 0 };
     unsigned long maxFramerate { 0 };
     double scaleResolutionDownBy { 1 };

Modified: trunk/Source/WebCore/Modules/mediastream/RTCRtpEncodingParameters.idl (273549 => 273550)


--- trunk/Source/WebCore/Modules/mediastream/RTCRtpEncodingParameters.idl	2021-02-26 11:53:07 UTC (rev 273549)
+++ trunk/Source/WebCore/Modules/mediastream/RTCRtpEncodingParameters.idl	2021-02-26 12:05:33 UTC (rev 273550)
@@ -34,6 +34,7 @@
     RTCDtxStatus dtx;
     boolean active = true;
     RTCPriorityType priority;
+    RTCPriorityType networkPriority;
     unsigned long maxBitrate;
     unsigned long maxFramerate;
     double scaleResolutionDownBy = 1;

Modified: trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCDataChannelHandler.cpp (273549 => 273550)


--- trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCDataChannelHandler.cpp	2021-02-26 11:53:07 UTC (rev 273549)
+++ trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCDataChannelHandler.cpp	2021-02-26 12:05:33 UTC (rev 273550)
@@ -28,6 +28,7 @@
 #if USE(LIBWEBRTC)
 
 #include "EventNames.h"
+#include "LibWebRTCUtils.h"
 #include "RTCDataChannel.h"
 #include "RTCDataChannelEvent.h"
 #include <wtf/MainThread.h>
@@ -48,14 +49,10 @@
         init.negotiated = *options.negotiated;
     if (options.id)
         init.id = *options.id;
+    init.priority = fromRTCPriorityType(options.priority);
     return init;
 }
 
-static inline String fromStdString(const std::string& value)
-{
-    return String::fromUTF8(value.data(), value.length());
-}
-
 Ref<RTCDataChannelEvent> LibWebRTCDataChannelHandler::channelEvent(Document& document, rtc::scoped_refptr<webrtc::DataChannelInterface>&& dataChannel)
 {
     auto protocol = dataChannel->protocol();
@@ -68,6 +65,7 @@
     init.protocol = fromStdString(protocol);
     init.negotiated = dataChannel->negotiated();
     init.id = dataChannel->id();
+    init.priority = toRTCPriorityType(dataChannel->priority());
 
     auto handler =  makeUnique<LibWebRTCDataChannelHandler>(WTFMove(dataChannel));
     auto channel = RTCDataChannel::create(document, WTFMove(handler), fromStdString(label), WTFMove(init));

Modified: trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCUtils.cpp (273549 => 273550)


--- trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCUtils.cpp	2021-02-26 11:53:07 UTC (rev 273549)
+++ trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCUtils.cpp	2021-02-26 12:05:33 UTC (rev 273550)
@@ -45,6 +45,59 @@
 
 namespace WebCore {
 
+webrtc::Priority fromRTCPriorityType(RTCPriorityType priority)
+{
+    switch (priority) {
+    case RTCPriorityType::VeryLow:
+        return webrtc::Priority::kVeryLow;
+    case RTCPriorityType::Low:
+        return webrtc::Priority::kLow;
+    case RTCPriorityType::Medium:
+        return webrtc::Priority::kMedium;
+    case RTCPriorityType::High:
+        return webrtc::Priority::kHigh;
+    }
+}
+
+RTCPriorityType toRTCPriorityType(webrtc::Priority priority)
+{
+    switch (priority) {
+    case webrtc::Priority::kVeryLow:
+        return RTCPriorityType::VeryLow;
+    case webrtc::Priority::kLow:
+        return RTCPriorityType::Low;
+    case webrtc::Priority::kMedium:
+        return RTCPriorityType::Medium;
+    case webrtc::Priority::kHigh:
+        return RTCPriorityType::High;
+    }
+}
+
+static inline double toWebRTCBitRatePriority(RTCPriorityType priority)
+{
+    switch (priority) {
+    case RTCPriorityType::VeryLow:
+        return 0.5;
+    case RTCPriorityType::Low:
+        return 1;
+    case RTCPriorityType::Medium:
+        return 2;
+    case RTCPriorityType::High:
+        return 4;
+    }
+}
+
+static inline RTCPriorityType fromWebRTCBitRatePriority(double priority)
+{
+    if (priority < 0.7)
+        return RTCPriorityType::VeryLow;
+    if (priority < 1.5)
+        return RTCPriorityType::Low;
+    if (priority < 2.5)
+        return RTCPriorityType::Medium;
+    return RTCPriorityType::High;
+}
+
 static inline RTCRtpEncodingParameters toRTCEncodingParameters(const webrtc::RtpEncodingParameters& rtcParameters)
 {
     RTCRtpEncodingParameters parameters;
@@ -61,6 +114,9 @@
     if (rtcParameters.scale_resolution_down_by)
         parameters.scaleResolutionDownBy = *rtcParameters.scale_resolution_down_by;
 
+    parameters.priority = fromWebRTCBitRatePriority(rtcParameters.bitrate_priority);
+    parameters.networkPriority = toRTCPriorityType(rtcParameters.network_priority);
+
     return parameters;
 }
 
@@ -80,6 +136,9 @@
     if (parameters.scaleResolutionDownBy)
         rtcParameters.scale_resolution_down_by = parameters.scaleResolutionDownBy;
 
+    rtcParameters.bitrate_priority = toWebRTCBitRatePriority(parameters.priority);
+    if (parameters.networkPriority)
+        rtcParameters.network_priority = fromRTCPriorityType(*parameters.networkPriority);
     return rtcParameters;
 }
 
@@ -191,6 +250,9 @@
             rtcParameters.encodings[i].max_framerate = parameters.encodings[i].maxFramerate;
         if (parameters.encodings[i].scaleResolutionDownBy)
             rtcParameters.encodings[i].scale_resolution_down_by = parameters.encodings[i].scaleResolutionDownBy;
+        rtcParameters.encodings[i].bitrate_priority = toWebRTCBitRatePriority(parameters.encodings[i].priority);
+        if (parameters.encodings[i].networkPriority)
+            rtcParameters.encodings[i].network_priority = fromRTCPriorityType(*parameters.encodings[i].networkPriority);
     }
 
     rtcParameters.header_extensions.clear();

Modified: trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCUtils.h (273549 => 273550)


--- trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCUtils.h	2021-02-26 11:53:07 UTC (rev 273549)
+++ trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCUtils.h	2021-02-26 12:05:33 UTC (rev 273550)
@@ -35,6 +35,7 @@
 
 class RTCError;
 
+enum class Priority;
 enum class RTCErrorType;
 enum class RtpTransceiverDirection;
 }
@@ -47,6 +48,7 @@
 struct RTCRtpSendParameters;
 struct RTCRtpTransceiverInit;
 
+enum class RTCPriorityType;
 enum class RTCRtpTransceiverDirection;
 
 RTCRtpParameters toRTCRtpParameters(const webrtc::RtpParameters&);
@@ -61,6 +63,10 @@
 ExceptionCode toExceptionCode(webrtc::RTCErrorType);
 Exception toException(const webrtc::RTCError&);
 
+RTCPriorityType toRTCPriorityType(webrtc::Priority);
+webrtc::Priority fromRTCPriorityType(RTCPriorityType);
+
+
 inline String fromStdString(const std::string& value)
 {
     return String::fromUTF8(value.data(), value.length());

Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (273549 => 273550)


--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2021-02-26 11:53:07 UTC (rev 273549)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2021-02-26 12:05:33 UTC (rev 273550)
@@ -1060,6 +1060,7 @@
 		413C8B332552F27D00E65055 /* RTCRtpSenderWithTransform.h in Headers */ = {isa = PBXBuildFile; fileRef = 413C8B2E2552F27B00E65055 /* RTCRtpSenderWithTransform.h */; };
 		413C8B342552F27D00E65055 /* RTCRtpTransform.h in Headers */ = {isa = PBXBuildFile; fileRef = 413C8B2F2552F27B00E65055 /* RTCRtpTransform.h */; };
 		413C8B352552F27D00E65055 /* RTCRtpReceiverWithTransform.h in Headers */ = {isa = PBXBuildFile; fileRef = 413C8B302552F27C00E65055 /* RTCRtpReceiverWithTransform.h */; };
+		413CC11D25E7D98E00D59C4B /* RTCPriorityType.h in Headers */ = {isa = PBXBuildFile; fileRef = 413CC11C25E7D98D00D59C4B /* RTCPriorityType.h */; };
 		413CCD4A20DE034F0065A21A /* MockMediaDevice.h in Headers */ = {isa = PBXBuildFile; fileRef = 413CCD4820DE013C0065A21A /* MockMediaDevice.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		413E00791DB0E4F2002341D2 /* MemoryRelease.h in Headers */ = {isa = PBXBuildFile; fileRef = 413E00781DB0E4DE002341D2 /* MemoryRelease.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		414460A22412994500814BE7 /* MediaSessionIdentifier.h in Headers */ = {isa = PBXBuildFile; fileRef = 414460A02412994100814BE7 /* MediaSessionIdentifier.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -7696,6 +7697,7 @@
 		413C8B2E2552F27B00E65055 /* RTCRtpSenderWithTransform.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RTCRtpSenderWithTransform.h; sourceTree = "<group>"; };
 		413C8B2F2552F27B00E65055 /* RTCRtpTransform.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RTCRtpTransform.h; sourceTree = "<group>"; };
 		413C8B302552F27C00E65055 /* RTCRtpReceiverWithTransform.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RTCRtpReceiverWithTransform.h; sourceTree = "<group>"; };
+		413CC11C25E7D98D00D59C4B /* RTCPriorityType.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RTCPriorityType.h; sourceTree = "<group>"; };
 		413CCD4820DE013C0065A21A /* MockMediaDevice.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MockMediaDevice.h; sourceTree = "<group>"; };
 		413E00771DB0E4DE002341D2 /* MemoryRelease.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MemoryRelease.cpp; sourceTree = "<group>"; };
 		413E00781DB0E4DE002341D2 /* MemoryRelease.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MemoryRelease.h; sourceTree = "<group>"; };
@@ -8016,7 +8018,6 @@
 		41FCB759214865D30038ADC6 /* RTCRtpCodecParameters.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = RTCRtpCodecParameters.idl; sourceTree = "<group>"; };
 		41FCB75A214866FD0038ADC6 /* RTCRtpHeaderExtensionParameters.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RTCRtpHeaderExtensionParameters.h; sourceTree = "<group>"; };
 		41FCB75B214866FD0038ADC6 /* RTCRtpFecParameters.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RTCRtpFecParameters.h; sourceTree = "<group>"; };
-		41FCB75C214866FE0038ADC6 /* RTCPriorityType.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RTCPriorityType.h; sourceTree = "<group>"; };
 		41FCB75D214866FE0038ADC6 /* RTCDegradationPreference.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RTCDegradationPreference.h; sourceTree = "<group>"; };
 		41FCB75E214866FF0038ADC6 /* RTCDtxStatus.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RTCDtxStatus.h; sourceTree = "<group>"; };
 		41FCB75F214866FF0038ADC6 /* RTCRtpCodecParameters.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RTCRtpCodecParameters.h; sourceTree = "<group>"; };
@@ -17323,7 +17324,6 @@
 				07221B7517CEC32700848E51 /* RTCPeerConnectionIceEvent.h */,
 				07221B7617CEC32700848E51 /* RTCPeerConnectionIceEvent.idl */,
 				41A48A9C1E83129100D2AC2D /* RTCPeerConnectionState.idl */,
-				41FCB75C214866FE0038ADC6 /* RTCPriorityType.h */,
 				41E593FD214865A900D3CB61 /* RTCPriorityType.idl */,
 				4114FE2F25BEBD18009D9F20 /* RTCRtcpParameters.h */,
 				4114FE3125BEBD18009D9F20 /* RTCRtcpParameters.idl */,
@@ -17477,6 +17477,7 @@
 				313591031E7DDC6000F30630 /* RTCIceTransportState.h */,
 				07221BAA17CF0AD400848E51 /* RTCPeerConnectionHandlerClient.h */,
 				41A48A9D1E8312EB00D2AC2D /* RTCPeerConnectionState.h */,
+				413CC11C25E7D98D00D59C4B /* RTCPriorityType.h */,
 				412BA5FE218C651800365474 /* RTCPMuxPolicy.h */,
 				412DE4B6219285BF0075F3A7 /* RTCRtpCapabilities.h */,
 				41E0A7DC23BB63DB00561060 /* RTCRtpCodecCapability.h */,
@@ -35087,6 +35088,7 @@
 				71537A01146BD9D7008BD615 /* SVGPathData.h in Headers */,
 				B2227A590D00BF220071B782 /* SVGPathElement.h in Headers */,
 				8476C9F011DF6A5800555B02 /* SVGPathParser.h in Headers */,
+				413CC11D25E7D98E00D59C4B /* RTCPriorityType.h in Headers */,
 				B2227A5B0D00BF220071B782 /* SVGPathSeg.h in Headers */,
 				B2227A810D00BF220071B782 /* SVGPathSegList.h in Headers */,
 				8476C9E611DF6A0B00555B02 /* SVGPathSegListBuilder.h in Headers */,

Modified: trunk/Source/WebCore/platform/mediastream/RTCDataChannelHandler.h (273549 => 273550)


--- trunk/Source/WebCore/platform/mediastream/RTCDataChannelHandler.h	2021-02-26 11:53:07 UTC (rev 273549)
+++ trunk/Source/WebCore/platform/mediastream/RTCDataChannelHandler.h	2021-02-26 12:05:33 UTC (rev 273550)
@@ -27,6 +27,7 @@
 
 #if ENABLE(WEB_RTC)
 
+#include "RTCPriorityType.h"
 #include <wtf/Optional.h>
 #include <wtf/text/WTFString.h>
 
@@ -39,6 +40,7 @@
     String protocol;
     Optional<bool> negotiated;
     Optional<unsigned short> id;
+    RTCPriorityType priority { RTCPriorityType::Low };
 };
 
 class RTCDataChannelHandlerClient;

Copied: trunk/Source/WebCore/platform/mediastream/RTCPriorityType.h (from rev 273549, trunk/Source/WebCore/Modules/mediastream/RTCPriorityType.h) (0 => 273550)


--- trunk/Source/WebCore/platform/mediastream/RTCPriorityType.h	                        (rev 0)
+++ trunk/Source/WebCore/platform/mediastream/RTCPriorityType.h	2021-02-26 12:05:33 UTC (rev 273550)
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2018 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
+
+#if ENABLE(WEB_RTC)
+
+namespace WebCore {
+
+enum class RTCPriorityType { VeryLow, Low, Medium, High };
+
+} // namespace WebCore
+
+#endif // ENABLE(WEB_RTC)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to