Title: [214420] trunk
Revision
214420
Author
commit-qu...@webkit.org
Date
2017-03-27 11:10:45 -0700 (Mon, 27 Mar 2017)

Log Message

Add support for RTCRtpReceiver/RTCRtpSender getParameters
https://bugs.webkit.org/show_bug.cgi?id=170057

Patch by Youenn Fablet <you...@apple.com> on 2017-03-27
Reviewed by Alex Christensen.

Source/ThirdParty/libwebrtc:

* Source/webrtc/api/mediatypes.h:

Source/WebCore:

Test: webrtc/video-getParameters.html

getParameters returns a dictionary of values taken from libwebrtc RtpReceiverInterface/RtpSenderInrterface objects.
Added a direct link between WebCore RTCRtpReceiver and libwebrtc RtpReceiverInterface object.
Making the link between WebCore RTCRtpSender and libwebrtc RtpSenderInrterface object through
PeerConnectionBackend to keep the current architecture shared with OpenWebRTC.
In the future, we should try to make the link more direct.

Added routines to support the conversion from libwebrtc to WebCore.
Ensured that RTCRtpReceiver is cleaning its backend when being stopped.

* CMakeLists.txt:
* DerivedSources.make:
* Modules/mediastream/MediaEndpointPeerConnection.cpp:
(WebCore::MediaEndpointPeerConnection::setRemoteDescriptionTask):
* Modules/mediastream/PeerConnectionBackend.h:
(WebCore::PeerConnectionBackend::getParameters):
* Modules/mediastream/RTCPeerConnection.cpp:
(WebCore::RTCPeerConnection::doClose):
(WebCore::RTCPeerConnection::getParameters):
* Modules/mediastream/RTCPeerConnection.h:
* Modules/mediastream/RTCRtpParameters.h: Added.
* Modules/mediastream/RTCRtpParameters.idl: Added.
* Modules/mediastream/RTCRtpReceiver.cpp:
(WebCore::RTCRtpReceiver::RTCRtpReceiver):
* Modules/mediastream/RTCRtpReceiver.h:
(WebCore::RTCRtpReceiver::Backend::~Backend):
(WebCore::RTCRtpReceiver::Backend::getParameters):
(WebCore::RTCRtpReceiver::create):
(WebCore::RTCRtpReceiver::stop):
(WebCore::RTCRtpReceiver::setBackend):
(WebCore::RTCRtpReceiver::getParameters):
* Modules/mediastream/RTCRtpReceiver.idl:
* Modules/mediastream/RTCRtpSender.cpp:
(WebCore::RTCRtpSender::create):
(WebCore::RTCRtpSender::RTCRtpSender):
(WebCore::RTCRtpSender::replaceTrack):
(WebCore::RTCRtpSender::getParameters):
* Modules/mediastream/RTCRtpSender.h:
(WebCore::RTCRtpSender::Backend::~Backend):
(WebCore::RTCRtpSender::isStopped):
(WebCore::RTCRtpSender::stop):
* Modules/mediastream/RTCRtpSender.idl:
* Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.cpp:
(WebCore::LibWebRTCMediaEndpoint::addTrack):
(WebCore::LibWebRTCMediaEndpoint::addRemoteTrack):
(WebCore::LibWebRTCMediaEndpoint::OnAddTrack):
(WebCore::LibWebRTCMediaEndpoint::stop):
(WebCore::fillEncodingParameters):
(WebCore::fillHeaderExtensionParameters):
(WebCore::fillCodecParameters):
(WebCore::fillRtpParameters):
(WebCore::RTCRtpReceiverBackend::getParameters):
(WebCore::LibWebRTCMediaEndpoint::getRTCRtpSenderParameters):
* Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.h:
* Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.cpp:
(WebCore::LibWebRTCPeerConnectionBackend::notifyAddedTrack):
(WebCore::LibWebRTCPeerConnectionBackend::getParameters):
* Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.h:
* WebCore.xcodeproj/project.pbxproj:
* platform/mediastream/mac/RealtimeOutgoingAudioSource.h:

LayoutTests:

* webrtc/video-getParameters-expected.txt: Added.
* webrtc/video-getParameters.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (214419 => 214420)


--- trunk/LayoutTests/ChangeLog	2017-03-27 17:50:33 UTC (rev 214419)
+++ trunk/LayoutTests/ChangeLog	2017-03-27 18:10:45 UTC (rev 214420)
@@ -1,3 +1,13 @@
+2017-03-27  Youenn Fablet  <you...@apple.com>
+
+        Add support for RTCRtpReceiver/RTCRtpSender getParameters
+        https://bugs.webkit.org/show_bug.cgi?id=170057
+
+        Reviewed by Alex Christensen.
+
+        * webrtc/video-getParameters-expected.txt: Added.
+        * webrtc/video-getParameters.html: Added.
+
 2017-03-27  Myles C. Maxfield  <mmaxfi...@apple.com>
 
         font variation properties don't need to accept numbers

Added: trunk/LayoutTests/webrtc/video-getParameters-expected.txt (0 => 214420)


--- trunk/LayoutTests/webrtc/video-getParameters-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/webrtc/video-getParameters-expected.txt	2017-03-27 18:10:45 UTC (rev 214420)
@@ -0,0 +1,3 @@
+
+PASS Basic video stats 
+

Added: trunk/LayoutTests/webrtc/video-getParameters.html (0 => 214420)


--- trunk/LayoutTests/webrtc/video-getParameters.html	                        (rev 0)
+++ trunk/LayoutTests/webrtc/video-getParameters.html	2017-03-27 18:10:45 UTC (rev 214420)
@@ -0,0 +1,56 @@
+<!doctype html>
+<html>
+    <head>
+        <meta charset="utf-8">
+        <title>Testing getParameters on a basic video exchange</title>
+        <script src=""
+        <script src=""
+    </head>
+    <body>
+        <script src =""
+        <script>
+var firstConnection, secondConnection;
+promise_test((test) => {
+    if (window.testRunner)
+        testRunner.setUserMediaPermission(true);
+
+    var sender, receiver;
+    var localStream, remoteStream;
+    return navigator.mediaDevices.getUserMedia({ video: true}).then((stream) => {
+        localStream = stream;
+        return new Promise((resolve, reject) => {
+            if (window.internals)
+                internals.useMockRTCPeerConnectionFactory("TwoRealPeerConnections");
+
+            createConnections((connection) => {
+                firstConnection = connection;
+                sender = firstConnection.addTrack(stream.getVideoTracks()[0], stream);
+            }, (connection) => {
+                secondConnection = connection;
+                receiver = secondConnection.addTransceiver("video").receiver;
+                secondConnection._ontrack_ = (trackEvent) => {
+                    remoteStream = trackEvent.streams[0];
+                    resolve();
+                };
+            });
+            setTimeout(() => reject("Test timed out"), 5000);
+        });
+    }).then(() => {
+        assert_true(!!sender, "sender should not be undefined");
+        assert_true(!!receiver, "receiver should not be undefined");
+        var senderParameters = sender.getParameters();
+        var receiverParameters = receiver.getParameters();
+        assert_true(!!senderParameters, "sender parameters should not be undefined or null");
+        assert_true(!!receiverParameters, "receiver parameters should not be undefined or null");
+
+        assert_equals(JSON.stringify(senderParameters), JSON.stringify(receiverParameters), "testing sender vs. receiver parameters");
+
+        senderParameters.encodings[0].fec.ssrc = 1;
+        senderParameters.encodings[0].rtx.ssrc = 1;
+        senderParameters.encodings[0].ssrc = 1;
+        assert_equals(JSON.stringify(senderParameters), '{"codecs":[],"degradationPreference":"balanced","encodings":[{"active":true,"dtx":"disabled","fec":{"ssrc":1},"maxBitrate":0,"maxFramerate":0,"priority":"medium","rid":"","rtx":{"ssrc":1},"scaleResolutionDownBy":1,"ssrc":1}],"headerExtensions":[],"transactionId":""}', "Testing sanitized parameters");
+    });
+}, "Basic video stats");
+        </script>
+    </body>
+</html>

Modified: trunk/Source/ThirdParty/libwebrtc/ChangeLog (214419 => 214420)


--- trunk/Source/ThirdParty/libwebrtc/ChangeLog	2017-03-27 17:50:33 UTC (rev 214419)
+++ trunk/Source/ThirdParty/libwebrtc/ChangeLog	2017-03-27 18:10:45 UTC (rev 214420)
@@ -1,3 +1,12 @@
+2017-03-27  Youenn Fablet  <you...@apple.com>
+
+        Add support for RTCRtpReceiver/RTCRtpSender getParameters
+        https://bugs.webkit.org/show_bug.cgi?id=170057
+
+        Reviewed by Alex Christensen.
+
+        * Source/webrtc/api/mediatypes.h:
+
 2017-03-22  Alex Christensen  <achristen...@webkit.org>
 
         Fix warnings in libwebrtc

Modified: trunk/Source/ThirdParty/libwebrtc/Source/webrtc/api/mediatypes.h (214419 => 214420)


--- trunk/Source/ThirdParty/libwebrtc/Source/webrtc/api/mediatypes.h	2017-03-27 17:50:33 UTC (rev 214419)
+++ trunk/Source/ThirdParty/libwebrtc/Source/webrtc/api/mediatypes.h	2017-03-27 18:10:45 UTC (rev 214420)
@@ -11,6 +11,8 @@
 #ifndef WEBRTC_API_MEDIATYPES_H_
 #define WEBRTC_API_MEDIATYPES_H_
 
+#include "webrtc/base/export.h"
+
 #include <string>
 
 namespace cricket {
@@ -21,7 +23,7 @@
   MEDIA_TYPE_DATA
 };
 
-std::string MediaTypeToString(MediaType type);
+WEBRTC_DYLIB_EXPORT std::string MediaTypeToString(MediaType type);
 // Aborts on invalid string. Only expected to be used on strings that are
 // guaranteed to be valid, such as MediaStreamTrackInterface::kind().
 MediaType MediaTypeFromString(const std::string& type_str);

Modified: trunk/Source/WebCore/CMakeLists.txt (214419 => 214420)


--- trunk/Source/WebCore/CMakeLists.txt	2017-03-27 17:50:33 UTC (rev 214419)
+++ trunk/Source/WebCore/CMakeLists.txt	2017-03-27 18:10:45 UTC (rev 214420)
@@ -250,6 +250,7 @@
     Modules/mediastream/RTCPeerConnection.idl
     Modules/mediastream/RTCPeerConnectionIceEvent.idl
     Modules/mediastream/RTCPeerConnectionState.idl
+    Modules/mediastream/RTCRtpParameters.idl
     Modules/mediastream/RTCRtpReceiver.idl
     Modules/mediastream/RTCRtpSender.idl
     Modules/mediastream/RTCRtpTransceiver.idl

Modified: trunk/Source/WebCore/ChangeLog (214419 => 214420)


--- trunk/Source/WebCore/ChangeLog	2017-03-27 17:50:33 UTC (rev 214419)
+++ trunk/Source/WebCore/ChangeLog	2017-03-27 18:10:45 UTC (rev 214420)
@@ -1,3 +1,72 @@
+2017-03-27  Youenn Fablet  <you...@apple.com>
+
+        Add support for RTCRtpReceiver/RTCRtpSender getParameters
+        https://bugs.webkit.org/show_bug.cgi?id=170057
+
+        Reviewed by Alex Christensen.
+
+        Test: webrtc/video-getParameters.html
+
+        getParameters returns a dictionary of values taken from libwebrtc RtpReceiverInterface/RtpSenderInrterface objects.
+        Added a direct link between WebCore RTCRtpReceiver and libwebrtc RtpReceiverInterface object.
+        Making the link between WebCore RTCRtpSender and libwebrtc RtpSenderInrterface object through
+        PeerConnectionBackend to keep the current architecture shared with OpenWebRTC.
+        In the future, we should try to make the link more direct.
+
+        Added routines to support the conversion from libwebrtc to WebCore.
+        Ensured that RTCRtpReceiver is cleaning its backend when being stopped.
+
+        * CMakeLists.txt:
+        * DerivedSources.make:
+        * Modules/mediastream/MediaEndpointPeerConnection.cpp:
+        (WebCore::MediaEndpointPeerConnection::setRemoteDescriptionTask):
+        * Modules/mediastream/PeerConnectionBackend.h:
+        (WebCore::PeerConnectionBackend::getParameters):
+        * Modules/mediastream/RTCPeerConnection.cpp:
+        (WebCore::RTCPeerConnection::doClose):
+        (WebCore::RTCPeerConnection::getParameters):
+        * Modules/mediastream/RTCPeerConnection.h:
+        * Modules/mediastream/RTCRtpParameters.h: Added.
+        * Modules/mediastream/RTCRtpParameters.idl: Added.
+        * Modules/mediastream/RTCRtpReceiver.cpp:
+        (WebCore::RTCRtpReceiver::RTCRtpReceiver):
+        * Modules/mediastream/RTCRtpReceiver.h:
+        (WebCore::RTCRtpReceiver::Backend::~Backend):
+        (WebCore::RTCRtpReceiver::Backend::getParameters):
+        (WebCore::RTCRtpReceiver::create):
+        (WebCore::RTCRtpReceiver::stop):
+        (WebCore::RTCRtpReceiver::setBackend):
+        (WebCore::RTCRtpReceiver::getParameters):
+        * Modules/mediastream/RTCRtpReceiver.idl:
+        * Modules/mediastream/RTCRtpSender.cpp:
+        (WebCore::RTCRtpSender::create):
+        (WebCore::RTCRtpSender::RTCRtpSender):
+        (WebCore::RTCRtpSender::replaceTrack):
+        (WebCore::RTCRtpSender::getParameters):
+        * Modules/mediastream/RTCRtpSender.h:
+        (WebCore::RTCRtpSender::Backend::~Backend):
+        (WebCore::RTCRtpSender::isStopped):
+        (WebCore::RTCRtpSender::stop):
+        * Modules/mediastream/RTCRtpSender.idl:
+        * Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.cpp:
+        (WebCore::LibWebRTCMediaEndpoint::addTrack):
+        (WebCore::LibWebRTCMediaEndpoint::addRemoteTrack):
+        (WebCore::LibWebRTCMediaEndpoint::OnAddTrack):
+        (WebCore::LibWebRTCMediaEndpoint::stop):
+        (WebCore::fillEncodingParameters):
+        (WebCore::fillHeaderExtensionParameters):
+        (WebCore::fillCodecParameters):
+        (WebCore::fillRtpParameters):
+        (WebCore::RTCRtpReceiverBackend::getParameters):
+        (WebCore::LibWebRTCMediaEndpoint::getRTCRtpSenderParameters):
+        * Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.h:
+        * Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.cpp:
+        (WebCore::LibWebRTCPeerConnectionBackend::notifyAddedTrack):
+        (WebCore::LibWebRTCPeerConnectionBackend::getParameters):
+        * Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.h:
+        * WebCore.xcodeproj/project.pbxproj:
+        * platform/mediastream/mac/RealtimeOutgoingAudioSource.h:
+
 2017-03-27  Myles C. Maxfield  <mmaxfi...@apple.com>
 
         font variation properties don't need to accept numbers

Modified: trunk/Source/WebCore/DerivedSources.make (214419 => 214420)


--- trunk/Source/WebCore/DerivedSources.make	2017-03-27 17:50:33 UTC (rev 214419)
+++ trunk/Source/WebCore/DerivedSources.make	2017-03-27 18:10:45 UTC (rev 214420)
@@ -194,6 +194,7 @@
     $(WebCore)/Modules/mediastream/RTCOfferOptions.idl \
     $(WebCore)/Modules/mediastream/RTCPeerConnection.idl \
     $(WebCore)/Modules/mediastream/RTCPeerConnectionState.idl \
+    $(WebCore)/Modules/mediastream/RTCRtpParameters.idl \
     $(WebCore)/Modules/mediastream/RTCRtpReceiver.idl \
     $(WebCore)/Modules/mediastream/RTCRtpSender.idl \
     $(WebCore)/Modules/mediastream/RTCRtpTransceiver.idl \

Modified: trunk/Source/WebCore/Modules/mediastream/MediaEndpointPeerConnection.cpp (214419 => 214420)


--- trunk/Source/WebCore/Modules/mediastream/MediaEndpointPeerConnection.cpp	2017-03-27 17:50:33 UTC (rev 214419)
+++ trunk/Source/WebCore/Modules/mediastream/MediaEndpointPeerConnection.cpp	2017-03-27 18:10:45 UTC (rev 214420)
@@ -500,7 +500,7 @@
             }
 
             if (!transceiver) {
-                auto sender = RTCRtpSender::create(String(mediaDescription.type), Vector<String>(), m_peerConnection.senderClient());
+                auto sender = RTCRtpSender::create(String(mediaDescription.type), Vector<String>(), m_peerConnection.senderBackend());
                 auto receiver = createReceiver(mediaDescription.mid, mediaDescription.type, mediaDescription.mediaStreamTrackId);
 
                 auto newTransceiver = RTCRtpTransceiver::create(WTFMove(sender), WTFMove(receiver));

Modified: trunk/Source/WebCore/Modules/mediastream/PeerConnectionBackend.h (214419 => 214420)


--- trunk/Source/WebCore/Modules/mediastream/PeerConnectionBackend.h	2017-03-27 17:50:33 UTC (rev 214419)
+++ trunk/Source/WebCore/Modules/mediastream/PeerConnectionBackend.h	2017-03-27 18:10:45 UTC (rev 214420)
@@ -34,6 +34,7 @@
 #if ENABLE(WEB_RTC)
 
 #include "JSDOMPromise.h"
+#include "RTCRtpParameters.h"
 #include "RTCSignalingState.h"
 
 namespace WebCore {
@@ -97,6 +98,8 @@
     virtual void replaceTrack(RTCRtpSender&, Ref<MediaStreamTrack>&&, DOMPromise<void>&&) = 0;
     virtual void notifyAddedTrack(RTCRtpSender&) { }
 
+    virtual RTCRtpParameters getParameters(RTCRtpSender&) const { return { }; }
+
     void markAsNeedingNegotiation();
     bool isNegotiationNeeded() const { return m_negotiationNeeded; };
     void clearNegotiationNeededState() { m_negotiationNeeded = false; };

Modified: trunk/Source/WebCore/Modules/mediastream/RTCPeerConnection.cpp (214419 => 214420)


--- trunk/Source/WebCore/Modules/mediastream/RTCPeerConnection.cpp	2017-03-27 17:50:33 UTC (rev 214419)
+++ trunk/Source/WebCore/Modules/mediastream/RTCPeerConnection.cpp	2017-03-27 18:10:45 UTC (rev 214420)
@@ -348,11 +348,14 @@
     m_iceConnectionState = RTCIceConnectionState::Closed;
     m_signalingState = RTCSignalingState::Closed;
 
-    m_backend->stop();
+    for (RTCRtpReceiver& receiver : m_transceiverSet->receivers())
+        receiver.stop();
 
     for (RTCRtpSender& sender : m_transceiverSet->senders())
         sender.stop();
 
+    m_backend->stop();
+
     return true;
 }
 
@@ -522,6 +525,11 @@
     m_backend->replaceTrack(sender, withTrack.releaseNonNull(), WTFMove(promise));
 }
 
+RTCRtpParameters RTCPeerConnection::getParameters(RTCRtpSender& sender) const
+{
+    return m_backend->getParameters(sender);
+}
+
 } // namespace WebCore
 
 #endif // ENABLE(WEB_RTC)

Modified: trunk/Source/WebCore/Modules/mediastream/RTCPeerConnection.h (214419 => 214420)


--- trunk/Source/WebCore/Modules/mediastream/RTCPeerConnection.h	2017-03-27 17:50:33 UTC (rev 214419)
+++ trunk/Source/WebCore/Modules/mediastream/RTCPeerConnection.h	2017-03-27 18:10:45 UTC (rev 214420)
@@ -58,11 +58,12 @@
 
 struct RTCAnswerOptions;
 struct RTCOfferOptions;
+struct RTCRtpParameters;
 struct RTCRtpTransceiverInit {
     RTCRtpTransceiverDirection direction;
 };
 
-class RTCPeerConnection final : public RefCounted<RTCPeerConnection>, public RTCRtpSenderClient, public EventTargetWithInlineData, public ActiveDOMObject {
+class RTCPeerConnection final : public RefCounted<RTCPeerConnection>, public RTCRtpSender::Backend, public EventTargetWithInlineData, public ActiveDOMObject {
 public:
     static Ref<RTCPeerConnection> create(ScriptExecutionContext&);
     virtual ~RTCPeerConnection();
@@ -134,7 +135,7 @@
 
     void scheduleNegotiationNeededEvent();
 
-    RTCRtpSenderClient& senderClient() { return *this; }
+    RTCRtpSender::Backend& senderBackend() { return *this; }
     void fireEvent(Event&);
 
     void disableICECandidateFiltering() { m_backend->disableICECandidateFiltering(); }
@@ -160,8 +161,10 @@
     const char* activeDOMObjectName() const final;
     bool canSuspendForDocumentSuspension() const final;
 
-    // RTCRtpSenderClient
+    // FIXME: We might want PeerConnectionBackend to be the Backend
+    // RTCRtpSender::Backend
     void replaceTrack(RTCRtpSender&, RefPtr<MediaStreamTrack>&&, DOMPromise<void>&&) final;
+    RTCRtpParameters getParameters(RTCRtpSender&) const final;
 
     void updateConnectionState();
     bool doClose();

Added: trunk/Source/WebCore/Modules/mediastream/RTCRtpParameters.h (0 => 214420)


--- trunk/Source/WebCore/Modules/mediastream/RTCRtpParameters.h	                        (rev 0)
+++ trunk/Source/WebCore/Modules/mediastream/RTCRtpParameters.h	2017-03-27 18:10:45 UTC (rev 214420)
@@ -0,0 +1,84 @@
+/*
+ * Copyright (C) 2017 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)
+
+#include <wtf/Vector.h>
+#include <wtf/text/WTFString.h>
+
+namespace WebCore {
+
+struct RTCRtpParameters {
+
+    struct FecParameters {
+        unsigned long ssrc;
+    };
+
+    struct RtxParameters {
+        unsigned long ssrc;
+    };
+
+    enum class PriorityType { VeryLow, Low, Medium, High };
+    enum class DegradationPreference { MaintainFramerate, MaintainResolution, Balanced };
+    enum class DtxStatus { Disabled, Enabled };
+
+    struct CodecParameters {
+        unsigned short payloadType { 0 };
+        String mimeType;
+        unsigned long clockRate { 0 };
+        unsigned short channels = 1;
+    };
+
+    struct EncodingParameters {
+        unsigned long ssrc { 0 };
+        RtxParameters rtx;
+        FecParameters fec;
+        DtxStatus dtx { DtxStatus::Disabled };
+        bool active { false};
+        PriorityType priority { PriorityType::Medium };
+        unsigned long maxBitrate { 0 };
+        unsigned long maxFramerate { 0 };
+        String rid;
+        double scaleResolutionDownBy { 1 };
+    };
+
+    struct HeaderExtensionParameters {
+        String uri;
+        unsigned short id;
+    };
+
+    String transactionId;
+    Vector<EncodingParameters> encodings;
+    Vector<HeaderExtensionParameters> headerExtensions;
+    Vector<CodecParameters> codecs;
+    DegradationPreference degradationPreference = DegradationPreference::Balanced;
+};
+
+
+} // namespace WebCore
+
+#endif // ENABLE(WEB_RTC)

Added: trunk/Source/WebCore/Modules/mediastream/RTCRtpParameters.idl (0 => 214420)


--- trunk/Source/WebCore/Modules/mediastream/RTCRtpParameters.idl	                        (rev 0)
+++ trunk/Source/WebCore/Modules/mediastream/RTCRtpParameters.idl	2017-03-27 18:10:45 UTC (rev 214420)
@@ -0,0 +1,126 @@
+/*
+* Copyright (C) 2017 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.
+*/
+
+[
+    Conditional=WEB_RTC,
+    EnabledAtRuntime=PeerConnection,
+    JSGenerateToJSObject,
+] dictionary RTCRtpParameters {
+    DOMString transactionId;
+    sequence<RTCRtpEncodingParameters> encodings;
+    sequence<RTCRtpHeaderExtensionParameters> headerExtensions;
+    // FIXME: Add RTCRtcpParameters rtcp;
+    sequence<RTCRtpCodecParameters> codecs;
+    RTCDegradationPreference degradationPreference = "balanced";
+};
+
+[
+    Conditional=WEB_RTC,
+    EnabledAtRuntime=PeerConnection,
+    JSGenerateToJSObject,
+] dictionary RTCRtpCodecParameters {
+    unsigned short payloadType;
+    DOMString mimeType;
+    unsigned long clockRate;
+    unsigned short channels = 1;
+    // FIXME: Add DOMString sdpFmtpLine;
+};
+
+[
+    Conditional=WEB_RTC,
+    EnabledAtRuntime=PeerConnection,
+    JSGenerateToJSObject,
+] dictionary RTCRtpEncodingParameters {
+    unsigned long ssrc;
+    RTCRtpRtxParameters rtx;
+    RTCRtpFecParameters fec;
+    RTCDtxStatus dtx;
+    boolean active;
+    RTCPriorityType priority;
+    unsigned long maxBitrate;
+    unsigned long maxFramerate;
+    DOMString rid;
+    double scaleResolutionDownBy = 1;
+};
+
+[
+    Conditional=WEB_RTC,
+    EnabledAtRuntime=PeerConnection,
+    JSGenerateToJSObject,
+] dictionary RTCRtpHeaderExtensionParameters {
+    DOMString uri;
+    unsigned short id;
+    // FIXME: Add boolean encrypted;
+};
+
+//[
+//    Conditional=WEB_RTC,
+//    EnabledAtRuntime=PeerConnection,
+//    JSGenerateToJSObject,
+//] dictionary RTCRtcpParameters {
+//    DOMString cname;
+//    boolean reducedSize;
+//};
+
+[
+    Conditional=WEB_RTC,
+    EnabledAtRuntime=PeerConnection,
+    JSGenerateToJSObject,
+] dictionary RTCRtpFecParameters {
+    unsigned long ssrc;
+};
+
+[
+    Conditional=WEB_RTC,
+    EnabledAtRuntime=PeerConnection,
+    JSGenerateToJSObject,
+] dictionary RTCRtpRtxParameters {
+    unsigned long ssrc;
+};
+
+[
+    Conditional=WEB_RTC,
+] enum RTCDegradationPreference {
+    "maintain-framerate",
+    "maintain-resolution",
+    "balanced"
+};
+
+[
+    Conditional=WEB_RTC,
+] enum RTCDtxStatus {
+    "disabled",
+    "enabled"
+};
+
+[
+    Conditional=WEB_RTC,
+    EnabledAtRuntime=PeerConnection,
+] enum RTCPriorityType {
+    "very-low",
+    "low",
+    "medium",
+    "high"
+};

Modified: trunk/Source/WebCore/Modules/mediastream/RTCRtpReceiver.cpp (214419 => 214420)


--- trunk/Source/WebCore/Modules/mediastream/RTCRtpReceiver.cpp	2017-03-27 17:50:33 UTC (rev 214419)
+++ trunk/Source/WebCore/Modules/mediastream/RTCRtpReceiver.cpp	2017-03-27 18:10:45 UTC (rev 214420)
@@ -33,10 +33,13 @@
 
 #if ENABLE(WEB_RTC)
 
+#include "RTCRtpParameters.h"
+
 namespace WebCore {
 
-RTCRtpReceiver::RTCRtpReceiver(Ref<MediaStreamTrack>&& track)
+RTCRtpReceiver::RTCRtpReceiver(Ref<MediaStreamTrack>&& track, Backend* backend)
     : RTCRtpSenderReceiverBase(WTFMove(track))
+    , m_backend(backend)
 {
 }
 

Modified: trunk/Source/WebCore/Modules/mediastream/RTCRtpReceiver.h (214419 => 214420)


--- trunk/Source/WebCore/Modules/mediastream/RTCRtpReceiver.h	2017-03-27 17:50:33 UTC (rev 214419)
+++ trunk/Source/WebCore/Modules/mediastream/RTCRtpReceiver.h	2017-03-27 18:10:45 UTC (rev 214420)
@@ -32,24 +32,38 @@
 
 #if ENABLE(WEB_RTC)
 
+#include "RTCRtpParameters.h"
 #include "RTCRtpSenderReceiverBase.h"
 
 namespace WebCore {
 
+
 class RTCRtpReceiver : public RTCRtpSenderReceiverBase {
 public:
-    static Ref<RTCRtpReceiver> create(Ref<MediaStreamTrack>&& track)
+    class Backend {
+    public:
+        virtual ~Backend() { }
+        virtual RTCRtpParameters getParameters() { return { }; }
+    };
+
+    static Ref<RTCRtpReceiver> create(Ref<MediaStreamTrack>&& track, Backend* backend = nullptr)
     {
-        return adoptRef(*new RTCRtpReceiver(WTFMove(track)));
+        return adoptRef(*new RTCRtpReceiver(WTFMove(track), backend));
     }
 
+    void stop() { m_backend = nullptr; }
+    // FIXME: We should pass a UniqueRef here.
+    void setBackend(std::unique_ptr<Backend>&& backend) { m_backend = WTFMove(backend); }
+
     bool isDispatched() const { return m_isDispatched; }
     void setDispatched(bool isDispatched) { m_isDispatched = isDispatched; }
+    RTCRtpParameters getParameters() { return m_backend ? m_backend->getParameters() : RTCRtpParameters(); }
 
 private:
-    explicit RTCRtpReceiver(Ref<MediaStreamTrack>&&);
+    explicit RTCRtpReceiver(Ref<MediaStreamTrack>&&, Backend*);
 
     bool m_isDispatched { false };
+    std::unique_ptr<Backend> m_backend;
 };
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/Modules/mediastream/RTCRtpReceiver.idl (214419 => 214420)


--- trunk/Source/WebCore/Modules/mediastream/RTCRtpReceiver.idl	2017-03-27 17:50:33 UTC (rev 214419)
+++ trunk/Source/WebCore/Modules/mediastream/RTCRtpReceiver.idl	2017-03-27 18:10:45 UTC (rev 214420)
@@ -34,9 +34,9 @@
     EnabledAtRuntime=PeerConnection,
 ] interface RTCRtpReceiver {
     readonly attribute MediaStreamTrack track;
+    RTCRtpParameters getParameters();
     // FIXME 169662: missing transport
     // FIXME 169662: missing rtcpTransport
     // FIXME 169662: missing getCapabilities
-    // FIXME 169662: missing getParameters
     // FIXME 169662: missing getContributingSources
 };

Modified: trunk/Source/WebCore/Modules/mediastream/RTCRtpSender.cpp (214419 => 214420)


--- trunk/Source/WebCore/Modules/mediastream/RTCRtpSender.cpp	2017-03-27 17:50:33 UTC (rev 214419)
+++ trunk/Source/WebCore/Modules/mediastream/RTCRtpSender.cpp	2017-03-27 18:10:45 UTC (rev 214420)
@@ -37,23 +37,23 @@
 
 namespace WebCore {
 
-Ref<RTCRtpSender> RTCRtpSender::create(Ref<MediaStreamTrack>&& track, Vector<String>&& mediaStreamIds, RTCRtpSenderClient& client)
+Ref<RTCRtpSender> RTCRtpSender::create(Ref<MediaStreamTrack>&& track, Vector<String>&& mediaStreamIds, Backend& backend)
 {
-    auto sender = adoptRef(*new RTCRtpSender(String(track->kind()), WTFMove(mediaStreamIds), client));
+    auto sender = adoptRef(*new RTCRtpSender(String(track->kind()), WTFMove(mediaStreamIds), backend));
     sender->setTrack(WTFMove(track));
     return sender;
 }
 
-Ref<RTCRtpSender> RTCRtpSender::create(String&& trackKind, Vector<String>&& mediaStreamIds, RTCRtpSenderClient& client)
+Ref<RTCRtpSender> RTCRtpSender::create(String&& trackKind, Vector<String>&& mediaStreamIds, Backend& backend)
 {
-    return adoptRef(*new RTCRtpSender(WTFMove(trackKind), WTFMove(mediaStreamIds), client));
+    return adoptRef(*new RTCRtpSender(WTFMove(trackKind), WTFMove(mediaStreamIds), backend));
 }
 
-RTCRtpSender::RTCRtpSender(String&& trackKind, Vector<String>&& mediaStreamIds, RTCRtpSenderClient& client)
+RTCRtpSender::RTCRtpSender(String&& trackKind, Vector<String>&& mediaStreamIds, Backend& backend)
     : RTCRtpSenderReceiverBase()
     , m_trackKind(WTFMove(trackKind))
     , m_mediaStreamIds(WTFMove(mediaStreamIds))
-    , m_client(&client)
+    , m_backend(&backend)
 {
 }
 
@@ -87,9 +87,16 @@
     if (!withTrack && m_track)
         m_track->stopProducingData();
 
-    m_client->replaceTrack(*this, WTFMove(withTrack), WTFMove(promise));
+    m_backend->replaceTrack(*this, WTFMove(withTrack), WTFMove(promise));
 }
 
+RTCRtpParameters RTCRtpSender::getParameters()
+{
+    if (isStopped())
+        return { };
+    return m_backend->getParameters(*this);
+}
+
 } // namespace WebCore
 
 #endif // ENABLE(WEB_RTC)

Modified: trunk/Source/WebCore/Modules/mediastream/RTCRtpSender.h (214419 => 214420)


--- trunk/Source/WebCore/Modules/mediastream/RTCRtpSender.h	2017-03-27 17:50:33 UTC (rev 214419)
+++ trunk/Source/WebCore/Modules/mediastream/RTCRtpSender.h	2017-03-27 18:10:45 UTC (rev 214420)
@@ -37,18 +37,18 @@
 
 namespace WebCore {
 
-class RTCRtpSenderClient {
+class RTCRtpSender : public RTCRtpSenderReceiverBase {
 public:
-    virtual void replaceTrack(RTCRtpSender&, RefPtr<MediaStreamTrack>&&, DOMPromise<void>&&) = 0;
+    class Backend {
+    public:
+        virtual void replaceTrack(RTCRtpSender&, RefPtr<MediaStreamTrack>&&, DOMPromise<void>&&) = 0;
+        virtual RTCRtpParameters getParameters(RTCRtpSender&) const = 0;
+        virtual ~Backend() { }
+    };
 
-    virtual ~RTCRtpSenderClient() { }
-};
+    static Ref<RTCRtpSender> create(Ref<MediaStreamTrack>&&, Vector<String>&& mediaStreamIds, Backend&);
+    static Ref<RTCRtpSender> create(String&& trackKind, Vector<String>&& mediaStreamIds, Backend&);
 
-class RTCRtpSender : public RTCRtpSenderReceiverBase {
-public:
-    static Ref<RTCRtpSender> create(Ref<MediaStreamTrack>&&, Vector<String>&& mediaStreamIds, RTCRtpSenderClient&);
-    static Ref<RTCRtpSender> create(String&& trackKind, Vector<String>&& mediaStreamIds, RTCRtpSenderClient&);
-
     const String& trackId() const { return m_trackId; }
     const String& trackKind() const { return m_trackKind; }
 
@@ -55,20 +55,22 @@
     const Vector<String>& mediaStreamIds() const { return m_mediaStreamIds; }
     void setMediaStreamIds(Vector<String>&& mediaStreamIds) { m_mediaStreamIds = WTFMove(mediaStreamIds); }
 
-    bool isStopped() const { return !m_client; }
-    void stop() { m_client = nullptr; }
+    bool isStopped() const { return !m_backend; }
+    void stop() { m_backend = nullptr; }
     void setTrack(Ref<MediaStreamTrack>&&);
     void setTrackToNull();
 
     void replaceTrack(RefPtr<MediaStreamTrack>&&, DOMPromise<void>&&);
 
+    RTCRtpParameters getParameters();
+
 private:
-    RTCRtpSender(String&& trackKind, Vector<String>&& mediaStreamIds, RTCRtpSenderClient&);
+    RTCRtpSender(String&& trackKind, Vector<String>&& mediaStreamIds, Backend&);
 
     String m_trackId;
     String m_trackKind;
     Vector<String> m_mediaStreamIds;
-    RTCRtpSenderClient* m_client;
+    Backend* m_backend;
 };
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/Modules/mediastream/RTCRtpSender.idl (214419 => 214420)


--- trunk/Source/WebCore/Modules/mediastream/RTCRtpSender.idl	2017-03-27 17:50:33 UTC (rev 214419)
+++ trunk/Source/WebCore/Modules/mediastream/RTCRtpSender.idl	2017-03-27 18:10:45 UTC (rev 214420)
@@ -38,6 +38,6 @@
     // FIXME 169662: missing rtcpTransport
     // FIXME 169662: missing getCapabilities
     // FIXME 169662: missing setParameters
-    // FIXME 169662: missing getParameters
+    RTCRtpParameters getParameters();
     Promise<void> replaceTrack(MediaStreamTrack? withTrack);
 };

Modified: trunk/Source/WebCore/Modules/mediastream/RTCStatsReport.h (214419 => 214420)


--- trunk/Source/WebCore/Modules/mediastream/RTCStatsReport.h	2017-03-27 17:50:33 UTC (rev 214419)
+++ trunk/Source/WebCore/Modules/mediastream/RTCStatsReport.h	2017-03-27 18:10:45 UTC (rev 214420)
@@ -124,7 +124,7 @@
         bool ended { false };
         bool detached { false };
         unsigned long frameWidth { 0 };
-        unsigned long frameHeight { 0};
+        unsigned long frameHeight { 0 };
         double framesPerSecond { 0 };
         unsigned long framesSent { 0 };
         unsigned long framesReceived { 0 };

Modified: trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.cpp (214419 => 214420)


--- trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.cpp	2017-03-27 17:50:33 UTC (rev 214419)
+++ trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.cpp	2017-03-27 18:10:45 UTC (rev 214420)
@@ -160,7 +160,7 @@
     m_backend->SetRemoteDescription(&m_setRemoteSessionDescriptionObserver, sessionDescription.release());
 }
 
-void LibWebRTCMediaEndpoint::addTrack(MediaStreamTrack& track, const Vector<String>& mediaStreamIds)
+void LibWebRTCMediaEndpoint::addTrack(RTCRtpSender& sender, MediaStreamTrack& track, const Vector<String>& mediaStreamIds)
 {
     if (!LibWebRTCProvider::factory())
         return;
@@ -178,9 +178,8 @@
     case RealtimeMediaSource::Type::Audio: {
         auto trackSource = RealtimeOutgoingAudioSource::create(source);
         auto audioTrack = LibWebRTCProvider::factory()->CreateAudioTrack(track.id().utf8().data(), trackSource.ptr());
-        trackSource->setTrack(rtc::scoped_refptr<webrtc::AudioTrackInterface>(audioTrack));
         m_peerConnectionBackend.addAudioSource(WTFMove(trackSource));
-        m_backend->AddTrack(audioTrack.get(), WTFMove(mediaStreams));
+        m_senders.add(&sender, m_backend->AddTrack(audioTrack.get(), WTFMove(mediaStreams)));
         return;
     }
     case RealtimeMediaSource::Type::Video: {
@@ -187,7 +186,7 @@
         auto videoSource = RealtimeOutgoingVideoSource::create(source);
         auto videoTrack = LibWebRTCProvider::factory()->CreateVideoTrack(track.id().utf8().data(), videoSource.ptr());
         m_peerConnectionBackend.addVideoSource(WTFMove(videoSource));
-        m_backend->AddTrack(videoTrack.get(), WTFMove(mediaStreams));
+        m_senders.add(&sender, m_backend->AddTrack(videoTrack.get(), WTFMove(mediaStreams)));
         return;
     }
     case RealtimeMediaSource::Type::None:
@@ -246,6 +245,7 @@
 static inline void fillRTCRTPStreamStats(RTCStatsReport::RTCRTPStreamStats& stats, const webrtc::RTCRTPStreamStats& rtcStats)
 {
     fillRTCStats(stats, rtcStats);
+
     if (rtcStats.ssrc.is_defined())
         stats.ssrc = *rtcStats.ssrc;
     if (rtcStats.associate_stats_id.is_defined())
@@ -276,6 +276,7 @@
 static inline void fillInboundRTPStreamStats(RTCStatsReport::InboundRTPStreamStats& stats, const webrtc::RTCInboundRTPStreamStats& rtcStats)
 {
     fillRTCRTPStreamStats(stats, rtcStats);
+
     if (rtcStats.packets_received.is_defined())
         stats.packetsReceived = *rtcStats.packets_received;
     if (rtcStats.bytes_received.is_defined())
@@ -327,6 +328,7 @@
 static inline void fillRTCMediaStreamTrackStats(RTCStatsReport::MediaStreamTrackStats& stats, const webrtc::RTCMediaStreamTrackStats& rtcStats)
 {
     fillRTCStats(stats, rtcStats);
+
     if (rtcStats.track_identifier.is_defined())
         stats.trackIdentifier = fromStdString(*rtcStats.track_identifier);
     if (rtcStats.remote_source.is_defined())
@@ -364,7 +366,7 @@
 static inline void fillRTCDataChannelStats(RTCStatsReport::DataChannelStats& stats, const webrtc::RTCDataChannelStats& rtcStats)
 {
     fillRTCStats(stats, rtcStats);
-    
+
     if (rtcStats.label.is_defined())
         stats.label = fromStdString(*rtcStats.label);
     if (rtcStats.protocol.is_defined())
@@ -468,14 +470,25 @@
     m_peerConnectionBackend.connection().fireEvent(MediaStreamEvent::create(eventNames().addstreamEvent, false, false, &mediaStream));
 }
 
-void LibWebRTCMediaEndpoint::addRemoteTrack(const webrtc::RtpReceiverInterface& rtcReceiver, const std::vector<rtc::scoped_refptr<webrtc::MediaStreamInterface>>& rtcStreams)
+class RTCRtpReceiverBackend final : public RTCRtpReceiver::Backend {
+public:
+    explicit RTCRtpReceiverBackend(rtc::scoped_refptr<webrtc::RtpReceiverInterface>&& rtcReceiver) : m_rtcReceiver(WTFMove(rtcReceiver)) { }
+private:
+    RTCRtpParameters getParameters() final;
+
+    rtc::scoped_refptr<webrtc::RtpReceiverInterface> m_rtcReceiver;
+};
+
+
+void LibWebRTCMediaEndpoint::addRemoteTrack(rtc::scoped_refptr<webrtc::RtpReceiverInterface>&& rtcReceiver, const std::vector<rtc::scoped_refptr<webrtc::MediaStreamInterface>>& rtcStreams)
 {
+    ASSERT(rtcReceiver);
     RefPtr<RTCRtpReceiver> receiver;
     RefPtr<RealtimeMediaSource> remoteSource;
 
-    auto* rtcTrack = rtcReceiver.track().get();
+    auto* rtcTrack = rtcReceiver->track().get();
 
-    switch (rtcReceiver.media_type()) {
+    switch (rtcReceiver->media_type()) {
     case cricket::MEDIA_TYPE_DATA:
         return;
     case cricket::MEDIA_TYPE_AUDIO: {
@@ -496,6 +509,8 @@
     }
     }
 
+    receiver->setBackend(std::make_unique<RTCRtpReceiverBackend>(WTFMove(rtcReceiver)));
+    
     auto* track = receiver->track();
     ASSERT(track);
 
@@ -537,11 +552,10 @@
 
 void LibWebRTCMediaEndpoint::OnAddTrack(rtc::scoped_refptr<webrtc::RtpReceiverInterface> receiver, const std::vector<rtc::scoped_refptr<webrtc::MediaStreamInterface>>& streams)
 {
-    callOnMainThread([protectedThis = makeRef(*this), receiver = WTFMove(receiver), streams] {
+    callOnMainThread([protectedThis = makeRef(*this), receiver = WTFMove(receiver), streams]() mutable {
         if (protectedThis->isStopped())
             return;
-        ASSERT(receiver);
-        protectedThis->addRemoteTrack(*receiver, streams);
+        protectedThis->addRemoteTrack(WTFMove(receiver), streams);
     });
 }
 
@@ -603,6 +617,7 @@
     m_backend->Close();
     m_backend = nullptr;
     m_streams.clear();
+    m_senders.clear();
 }
 
 void LibWebRTCMediaEndpoint::OnRenegotiationNeeded()
@@ -750,6 +765,115 @@
     });
 }
 
+static inline RTCRtpParameters::EncodingParameters fillEncodingParameters(const webrtc::RtpEncodingParameters& rtcParameters)
+{
+    RTCRtpParameters::EncodingParameters parameters;
+
+    if (rtcParameters.ssrc)
+        parameters.ssrc = *rtcParameters.ssrc;
+    if (rtcParameters.rtx && rtcParameters.rtx->ssrc)
+        parameters.rtx.ssrc = *rtcParameters.rtx->ssrc;
+    if (rtcParameters.fec && rtcParameters.fec->ssrc)
+        parameters.fec.ssrc = *rtcParameters.fec->ssrc;
+    if (rtcParameters.dtx) {
+        switch (*rtcParameters.dtx) {
+        case webrtc::DtxStatus::DISABLED:
+            parameters.dtx = RTCRtpParameters::DtxStatus::Disabled;
+            break;
+        case webrtc::DtxStatus::ENABLED:
+            parameters.dtx = RTCRtpParameters::DtxStatus::Enabled;
+        }
+    }
+    parameters.active = rtcParameters.active;
+    if (rtcParameters.priority) {
+        switch (*rtcParameters.priority) {
+        case webrtc::PriorityType::VERY_LOW:
+            parameters.priority = RTCRtpParameters::PriorityType::VeryLow;
+            break;
+        case webrtc::PriorityType::LOW:
+            parameters.priority = RTCRtpParameters::PriorityType::Low;
+            break;
+        case webrtc::PriorityType::MEDIUM:
+            parameters.priority = RTCRtpParameters::PriorityType::Medium;
+            break;
+        case webrtc::PriorityType::HIGH:
+            parameters.priority = RTCRtpParameters::PriorityType::High;
+            break;
+        }
+    }
+    if (rtcParameters.max_bitrate_bps)
+        parameters.maxBitrate = *rtcParameters.max_bitrate_bps;
+    if (rtcParameters.max_framerate)
+        parameters.maxFramerate = *rtcParameters.max_framerate;
+    parameters.rid = fromStdString(rtcParameters.rid);
+    parameters.scaleResolutionDownBy = rtcParameters.scale_resolution_down_by;
+
+    return parameters;
+}
+
+static inline RTCRtpParameters::HeaderExtensionParameters fillHeaderExtensionParameters(const webrtc::RtpHeaderExtensionParameters& rtcParameters)
+{
+    RTCRtpParameters::HeaderExtensionParameters parameters;
+
+    parameters.uri = fromStdString(rtcParameters.uri);
+    parameters.id = rtcParameters.id;
+
+    return parameters;
+}
+
+static inline RTCRtpParameters::CodecParameters fillCodecParameters(const webrtc::RtpCodecParameters& rtcParameters)
+{
+    RTCRtpParameters::CodecParameters parameters;
+
+    parameters.payloadType = rtcParameters.payload_type;
+    parameters.mimeType = fromStdString(rtcParameters.mime_type());
+    if (rtcParameters.clock_rate)
+        parameters.clockRate = *rtcParameters.clock_rate;
+    if (rtcParameters.num_channels)
+        parameters.channels = *rtcParameters.num_channels;
+
+    return parameters;
+}
+
+static RTCRtpParameters fillRtpParameters(const webrtc::RtpParameters rtcParameters)
+{
+    RTCRtpParameters parameters;
+
+    parameters.transactionId = fromStdString(rtcParameters.transaction_id);
+    for (auto& rtcEncoding : rtcParameters.encodings)
+        parameters.encodings.append(fillEncodingParameters(rtcEncoding));
+    for (auto& extension : rtcParameters.header_extensions)
+        parameters.headerExtensions.append(fillHeaderExtensionParameters(extension));
+    for (auto& codec : rtcParameters.codecs)
+        parameters.codecs.append(fillCodecParameters(codec));
+
+    switch (rtcParameters.degradation_preference) {
+    case webrtc::DegradationPreference::MAINTAIN_FRAMERATE:
+        parameters.degradationPreference = RTCRtpParameters::DegradationPreference::MaintainFramerate;
+        break;
+    case webrtc::DegradationPreference::MAINTAIN_RESOLUTION:
+        parameters.degradationPreference = RTCRtpParameters::DegradationPreference::MaintainResolution;
+        break;
+    case webrtc::DegradationPreference::BALANCED:
+        parameters.degradationPreference = RTCRtpParameters::DegradationPreference::Balanced;
+        break;
+    };
+    return parameters;
+}
+
+RTCRtpParameters RTCRtpReceiverBackend::getParameters()
+{
+    return fillRtpParameters(m_rtcReceiver->GetParameters());
+}
+
+RTCRtpParameters LibWebRTCMediaEndpoint::getRTCRtpSenderParameters(RTCRtpSender& sender)
+{
+    auto rtcSender = m_senders.get(&sender);
+    if (!rtcSender)
+        return { };
+    return fillRtpParameters(rtcSender->GetParameters());
+}
+
 } // namespace WebCore
 
 #endif // USE(LIBWEBRTC)

Modified: trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.h (214419 => 214420)


--- trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.h	2017-03-27 17:50:33 UTC (rev 214419)
+++ trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.h	2017-03-27 18:10:45 UTC (rev 214420)
@@ -28,6 +28,7 @@
 
 #include "LibWebRTCProvider.h"
 #include "PeerConnectionBackend.h"
+#include "RTCRtpReceiver.h"
 #include "RealtimeOutgoingAudioSource.h"
 #include "RealtimeOutgoingVideoSource.h"
 
@@ -79,7 +80,8 @@
     RefPtr<RTCSessionDescription> pendingLocalDescription() const;
     RefPtr<RTCSessionDescription> pendingRemoteDescription() const;
 
-    void addTrack(MediaStreamTrack&, const Vector<String>&);
+    void addTrack(RTCRtpSender&, MediaStreamTrack&, const Vector<String>&);
+    RTCRtpParameters getRTCRtpSenderParameters(RTCRtpSender&);
 
 private:
     LibWebRTCMediaEndpoint(LibWebRTCPeerConnectionBackend&, LibWebRTCProvider&);
@@ -103,7 +105,7 @@
     void setRemoteSessionDescriptionSucceeded();
     void setRemoteSessionDescriptionFailed(const std::string&);
     void addRemoteStream(webrtc::MediaStreamInterface&);
-    void addRemoteTrack(const webrtc::RtpReceiverInterface&, const std::vector<rtc::scoped_refptr<webrtc::MediaStreamInterface>>&);
+    void addRemoteTrack(rtc::scoped_refptr<webrtc::RtpReceiverInterface>&&, const std::vector<rtc::scoped_refptr<webrtc::MediaStreamInterface>>&);
     void removeRemoteStream(webrtc::MediaStreamInterface&);
     void addDataChannel(rtc::scoped_refptr<webrtc::DataChannelInterface>&&);
 
@@ -175,6 +177,7 @@
     SetLocalSessionDescriptionObserver m_setLocalSessionDescriptionObserver;
     SetRemoteSessionDescriptionObserver m_setRemoteSessionDescriptionObserver;
     HashMap<webrtc::MediaStreamInterface*, MediaStream*> m_streams;
+    HashMap<RTCRtpSender*, rtc::scoped_refptr<webrtc::RtpSenderInterface>> m_senders;
 
     bool m_isInitiator { false };
 };

Modified: trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.cpp (214419 => 214420)


--- trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.cpp	2017-03-27 17:50:33 UTC (rev 214419)
+++ trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.cpp	2017-03-27 18:10:45 UTC (rev 214420)
@@ -307,7 +307,7 @@
 void LibWebRTCPeerConnectionBackend::notifyAddedTrack(RTCRtpSender& sender)
 {
     ASSERT(sender.track());
-    m_endpoint->addTrack(*sender.track(), sender.mediaStreamIds());
+    m_endpoint->addTrack(sender, *sender.track(), sender.mediaStreamIds());
 }
 
 void LibWebRTCPeerConnectionBackend::removeRemoteStream(MediaStream* mediaStream)
@@ -364,6 +364,11 @@
     }
 }
 
+RTCRtpParameters LibWebRTCPeerConnectionBackend::getParameters(RTCRtpSender& sender) const
+{
+    return m_endpoint->getRTCRtpSenderParameters(sender);
+}
+
 } // namespace WebCore
 
 #endif // USE(LIBWEBRTC)

Modified: trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.h (214419 => 214420)


--- trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.h	2017-03-27 17:50:33 UTC (rev 214419)
+++ trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.h	2017-03-27 18:10:45 UTC (rev 214420)
@@ -70,6 +70,7 @@
     RefPtr<RTCSessionDescription> pendingRemoteDescription() const final;
 
     void replaceTrack(RTCRtpSender&, Ref<MediaStreamTrack>&&, DOMPromise<void>&&) final;
+    RTCRtpParameters getParameters(RTCRtpSender&) const final;
 
     void emulatePlatformEvent(const String&) final { }
 

Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (214419 => 214420)


--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2017-03-27 17:50:33 UTC (rev 214419)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2017-03-27 18:10:45 UTC (rev 214420)
@@ -2710,6 +2710,8 @@
 		5E2C43711BCF0D750001E2BD /* JSRTCRtpTransceiver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5E2C436D1BCF0D690001E2BD /* JSRTCRtpTransceiver.cpp */; };
 		5E2C43721BCF0D750001E2BC /* JSRTCRtpReceiver.h in Headers */ = {isa = PBXBuildFile; fileRef = 5E2C436E1BCF0D690001E2BC /* JSRTCRtpReceiver.h */; };
 		5E2C43721BCF0D750001E2BD /* JSRTCRtpTransceiver.h in Headers */ = {isa = PBXBuildFile; fileRef = 5E2C436E1BCF0D690001E2BD /* JSRTCRtpTransceiver.h */; };
+		5E2C43731BCF0D750001E2BE /* JSRTCRtpParameters.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5E2C436F1BCF0D690001E2BE /* JSRTCRtpParameters.cpp */; };
+		5E2C43741BCF0D750001E2BE /* JSRTCRtpParameters.h in Headers */ = {isa = PBXBuildFile; fileRef = 5E2C43701BCF0D690001E2BE /* JSRTCRtpParameters.h */; };
 		5E2C43731BCF0D750001E2BC /* JSRTCRtpSender.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5E2C436F1BCF0D690001E2BC /* JSRTCRtpSender.cpp */; };
 		5E2C43741BCF0D750001E2BC /* JSRTCRtpSender.h in Headers */ = {isa = PBXBuildFile; fileRef = 5E2C43701BCF0D690001E2BC /* JSRTCRtpSender.h */; };
 		5E2C437B1BCF9A570001E2BC /* RTCPeerConnectionBuiltins.h in Headers */ = {isa = PBXBuildFile; fileRef = 5E2C43761BCF9A0B0001E2BC /* RTCPeerConnectionBuiltins.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -9332,6 +9334,8 @@
 		41A3D58D101C152D00316D07 /* DedicatedWorkerThread.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DedicatedWorkerThread.h; sourceTree = "<group>"; };
 		41A48A9C1E83129100D2AC2D /* RTCPeerConnectionState.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = RTCPeerConnectionState.idl; sourceTree = "<group>"; };
 		41A48A9D1E8312EB00D2AC2D /* RTCPeerConnectionState.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RTCPeerConnectionState.h; sourceTree = "<group>"; };
+		41A48AA71E84AEEC00D2AC2D /* RTCRtpParameters.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = RTCRtpParameters.idl; sourceTree = "<group>"; };
+		41A48AA81E84AF1D00D2AC2D /* RTCRtpParameters.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RTCRtpParameters.h; sourceTree = "<group>"; };
 		41ABE6791D0580D5006D862D /* CrossOriginPreflightChecker.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CrossOriginPreflightChecker.cpp; sourceTree = "<group>"; };
 		41ABE67A1D0580D5006D862D /* CrossOriginPreflightChecker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CrossOriginPreflightChecker.h; sourceTree = "<group>"; };
 		41AD75391CEF6BCE00A31486 /* FetchOptions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FetchOptions.h; sourceTree = "<group>"; };
@@ -10422,6 +10426,8 @@
 		5E2C436E1BCF0D690001E2BD /* JSRTCRtpTransceiver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSRTCRtpTransceiver.h; sourceTree = "<group>"; };
 		5E2C436F1BCF0D690001E2BC /* JSRTCRtpSender.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSRTCRtpSender.cpp; sourceTree = "<group>"; };
 		5E2C43701BCF0D690001E2BC /* JSRTCRtpSender.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSRTCRtpSender.h; sourceTree = "<group>"; };
+		5E2C436F1BCF0D690001E2BE /* JSRTCRtpParameters.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSRTCRtpParameters.cpp; sourceTree = "<group>"; };
+		5E2C43701BCF0D690001E2BE /* JSRTCRtpParameters.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSRTCRtpParameters.h; sourceTree = "<group>"; };
 		5E2C43751BCF9A0B0001E2BC /* RTCPeerConnectionBuiltins.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RTCPeerConnectionBuiltins.cpp; sourceTree = "<group>"; };
 		5E2C43761BCF9A0B0001E2BC /* RTCPeerConnectionBuiltins.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RTCPeerConnectionBuiltins.h; sourceTree = "<group>"; };
 		5E2C43781BCF9A0B0001E2BC /* RTCPeerConnectionInternalsBuiltins.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RTCPeerConnectionInternalsBuiltins.cpp; sourceTree = "<group>"; };
@@ -15958,6 +15964,8 @@
 				07221B7917CEC32700848E51 /* RTCPeerConnection.idl */,
 				5E2C43541BCEE30D0001E2BC /* RTCPeerConnection.js */,
 				5E2C43551BCEE30D0001E2BC /* RTCPeerConnectionInternals.js */,
+				41A48AA71E84AEEC00D2AC2D /* RTCRtpParameters.idl */,
+				41A48AA81E84AF1D00D2AC2D /* RTCRtpParameters.h */,
 				5E2C43561BCEE30D0001E2BC /* RTCRtpReceiver.cpp */,
 				5E2C43571BCEE30D0001E2BC /* RTCRtpReceiver.h */,
 				5E2C43581BCEE30D0001E2BC /* RTCRtpReceiver.idl */,
@@ -16196,6 +16204,8 @@
 				07969DA017D14151007FF842 /* JSRTCPeerConnection.h */,
 				5E2C436D1BCF0D690001E2BC /* JSRTCRtpReceiver.cpp */,
 				5E2C436E1BCF0D690001E2BC /* JSRTCRtpReceiver.h */,
+				5E2C436F1BCF0D690001E2BE /* JSRTCRtpParameters.cpp */,
+				5E2C43701BCF0D690001E2BE /* JSRTCRtpParameters.h */,
 				5E2C436F1BCF0D690001E2BC /* JSRTCRtpSender.cpp */,
 				5E2C43701BCF0D690001E2BC /* JSRTCRtpSender.h */,
 				5E2C436D1BCF0D690001E2BD /* JSRTCRtpTransceiver.cpp */,
@@ -27856,6 +27866,7 @@
 				07969DBA17D14151007FF842 /* JSRTCPeerConnection.h in Headers */,
 				5E2C43721BCF0D750001E2BC /* JSRTCRtpReceiver.h in Headers */,
 				5E2C43741BCF0D750001E2BC /* JSRTCRtpSender.h in Headers */,
+				5E2C43741BCF0D750001E2BE /* JSRTCRtpParameters.h in Headers */,
 				5E2C43721BCF0D750001E2BD /* JSRTCRtpTransceiver.h in Headers */,
 				07969DBC17D14151007FF842 /* JSRTCSessionDescription.h in Headers */,
 				07969DC217D14151007FF842 /* JSRTCStatsReport.h in Headers */,
@@ -31822,6 +31833,7 @@
 				07969DB917D14151007FF842 /* JSRTCPeerConnection.cpp in Sources */,
 				5E2C43711BCF0D750001E2BC /* JSRTCRtpReceiver.cpp in Sources */,
 				5E2C43731BCF0D750001E2BC /* JSRTCRtpSender.cpp in Sources */,
+				5E2C43731BCF0D750001E2BE /* JSRTCRtpParameters.cpp in Sources */,
 				5E2C43711BCF0D750001E2BD /* JSRTCRtpTransceiver.cpp in Sources */,
 				07969DBB17D14151007FF842 /* JSRTCSessionDescription.cpp in Sources */,
 				07969DC117D14151007FF842 /* JSRTCStatsReport.cpp in Sources */,

Modified: trunk/Source/WebCore/platform/mediastream/mac/RealtimeOutgoingAudioSource.h (214419 => 214420)


--- trunk/Source/WebCore/platform/mediastream/mac/RealtimeOutgoingAudioSource.h	2017-03-27 17:50:33 UTC (rev 214419)
+++ trunk/Source/WebCore/platform/mediastream/mac/RealtimeOutgoingAudioSource.h	2017-03-27 18:10:45 UTC (rev 214420)
@@ -48,7 +48,6 @@
     static Ref<RealtimeOutgoingAudioSource> create(Ref<RealtimeMediaSource>&& audioSource) { return adoptRef(*new RealtimeOutgoingAudioSource(WTFMove(audioSource))); }
     ~RealtimeOutgoingAudioSource() { stop(); }
 
-    void setTrack(rtc::scoped_refptr<webrtc::AudioTrackInterface>&& track) { m_track = WTFMove(track); }
     void stop();
 
     bool setSource(Ref<RealtimeMediaSource>&&);
@@ -76,7 +75,6 @@
 
     Vector<webrtc::AudioTrackSinkInterface*> m_sinks;
     Ref<RealtimeMediaSource> m_audioSource;
-    rtc::scoped_refptr<webrtc::AudioTrackInterface> m_track;
     Ref<AudioSampleDataSource> m_sampleConverter;
     CAAudioStreamDescription m_inputStreamDescription;
     CAAudioStreamDescription m_outputStreamDescription;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to