Introduce LibWebRTC backends for sender and receiver
authoryouenn@apple.com <youenn@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 4 Sep 2018 18:48:38 +0000 (18:48 +0000)
committeryouenn@apple.com <youenn@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 4 Sep 2018 18:48:38 +0000 (18:48 +0000)
https://bugs.webkit.org/show_bug.cgi?id=189171

Reviewed by Alejandro G. Castro.

Rename RTCRtpSender::Backend to RTCRtpSenderBackend, ditto for RTCRtpReceiver::Backend.
Make RTCRtpSender/RTCRtpReceiver own their backend.
This will allow the backends to own a libwebrtc sender/receiver ref counted object
and might allow us to cleanly separate code from unified plan vs plan B.

Update code so that libwebrtc code specific code is now creating senders and receivers.
This moves code from RTCPeerConnection down to LibWebRTCPeerConnectionBackend, in particular for
addTrack and addTransceiver methods.

Moved some code from LibWebRTCMediaEndpoint to LibWebRTCUtils to ease readability.

A future patch will allow to tie the libwebrtc sender/receiver to WebKit DOM sender/receiver.

Covered by existing tests.

* Modules/mediastream/PeerConnectionBackend.cpp:
(WebCore::PeerConnectionBackend::addTrack):
(WebCore::PeerConnectionBackend::addTransceiver):
* Modules/mediastream/PeerConnectionBackend.h:
* Modules/mediastream/RTCPeerConnection.cpp:
(WebCore::RTCPeerConnection::addTrack):
(WebCore::RTCPeerConnection::addTransceiver):
(WebCore::RTCPeerConnection::enqueueReplaceTrackTask):
* Modules/mediastream/RTCPeerConnection.h:
* Modules/mediastream/RTCRtpReceiver.cpp:
(WebCore::RTCRtpReceiver::RTCRtpReceiver):
* Modules/mediastream/RTCRtpReceiver.h:
(WebCore::RTCRtpReceiver::create):
(WebCore::RTCRtpReceiver::setBackend):
* Modules/mediastream/RTCRtpReceiverBackend.h: Added.
(WebCore::RTCRtpReceiverBackend::getParameters):
* Modules/mediastream/RTCRtpSender.cpp:
(WebCore::RTCRtpSender::create):
(WebCore::RTCRtpSender::RTCRtpSender):
* Modules/mediastream/RTCRtpSender.h:
* Modules/mediastream/RTCRtpSenderBackend.h: Added.
* Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.cpp:
(WebCore::LibWebRTCMediaEndpoint::addRemoteTrack):
* Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.cpp:
(WebCore::LibWebRTCPeerConnectionBackend::videoReceiver):
(WebCore::LibWebRTCPeerConnectionBackend::audioReceiver):
(WebCore::LibWebRTCPeerConnectionBackend::addTrack):
(WebCore::LibWebRTCPeerConnectionBackend::addTransceiver):
(WebCore::LibWebRTCPeerConnectionBackend::completeAddTransceiver):
* Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.h:
* Modules/mediastream/libwebrtc/LibWebRTCRtpReceiverBackend.cpp: Added.
(WebCore::LibWebRTCRtpReceiverBackend::getParameters):
* Modules/mediastream/libwebrtc/LibWebRTCRtpReceiverBackend.h: Added.
* Modules/mediastream/libwebrtc/LibWebRTCRtpSenderBackend.cpp: Added.
(WebCore::LibWebRTCRtpSenderBackend::replaceTrack):
(WebCore::LibWebRTCRtpSenderBackend::getParameters const):
* Modules/mediastream/libwebrtc/LibWebRTCRtpSenderBackend.h: Added.
* Modules/mediastream/libwebrtc/LibWebRTCUtils.cpp: Added.
(WebCore::fillEncodingParameters):
(WebCore::fillHeaderExtensionParameters):
(WebCore::fillCodecParameters):
(WebCore::fillRtpParameters):
* Modules/mediastream/libwebrtc/LibWebRTCUtils.h: Added.
(WebCore::fromStdString):
* WebCore.xcodeproj/project.pbxproj:

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

22 files changed:
Source/WebCore/CMakeLists.txt
Source/WebCore/ChangeLog
Source/WebCore/Modules/mediastream/PeerConnectionBackend.cpp
Source/WebCore/Modules/mediastream/PeerConnectionBackend.h
Source/WebCore/Modules/mediastream/RTCPeerConnection.cpp
Source/WebCore/Modules/mediastream/RTCPeerConnection.h
Source/WebCore/Modules/mediastream/RTCRtpReceiver.cpp
Source/WebCore/Modules/mediastream/RTCRtpReceiver.h
Source/WebCore/Modules/mediastream/RTCRtpReceiverBackend.h [new file with mode: 0644]
Source/WebCore/Modules/mediastream/RTCRtpSender.cpp
Source/WebCore/Modules/mediastream/RTCRtpSender.h
Source/WebCore/Modules/mediastream/RTCRtpSenderBackend.h [new file with mode: 0644]
Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.cpp
Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.cpp
Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.h
Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCRtpReceiverBackend.cpp [new file with mode: 0644]
Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCRtpReceiverBackend.h [new file with mode: 0644]
Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCRtpSenderBackend.cpp [new file with mode: 0644]
Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCRtpSenderBackend.h [new file with mode: 0644]
Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCUtils.cpp [new file with mode: 0644]
Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCUtils.h [new file with mode: 0644]
Source/WebCore/WebCore.xcodeproj/project.pbxproj

index d17ba57..2fdd331 100644 (file)
@@ -1568,6 +1568,9 @@ if (USE_LIBWEBRTC)
       Modules/mediastream/libwebrtc/LibWebRTCDataChannelHandler.cpp
       Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.cpp
       Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.cpp
+      Modules/mediastream/libwebrtc/LibWebRTCRtpReceiverBackend.cpp
+      Modules/mediastream/libwebrtc/LibWebRTCRtpSenderBackend.cpp
+      Modules/mediastream/libwebrtc/LibWebRTCUtils.cpp
       )
 endif ()
 
index 8c0a91d..bc413ec 100644 (file)
@@ -1,3 +1,71 @@
+2018-09-04  Youenn Fablet  <youenn@apple.com>
+
+        Introduce LibWebRTC backends for sender and receiver
+        https://bugs.webkit.org/show_bug.cgi?id=189171
+
+        Reviewed by Alejandro G. Castro.
+
+        Rename RTCRtpSender::Backend to RTCRtpSenderBackend, ditto for RTCRtpReceiver::Backend.
+        Make RTCRtpSender/RTCRtpReceiver own their backend.
+        This will allow the backends to own a libwebrtc sender/receiver ref counted object
+        and might allow us to cleanly separate code from unified plan vs plan B.
+
+        Update code so that libwebrtc code specific code is now creating senders and receivers.
+        This moves code from RTCPeerConnection down to LibWebRTCPeerConnectionBackend, in particular for
+        addTrack and addTransceiver methods.
+
+        Moved some code from LibWebRTCMediaEndpoint to LibWebRTCUtils to ease readability.
+
+        A future patch will allow to tie the libwebrtc sender/receiver to WebKit DOM sender/receiver.
+
+        Covered by existing tests.
+
+        * Modules/mediastream/PeerConnectionBackend.cpp:
+        (WebCore::PeerConnectionBackend::addTrack):
+        (WebCore::PeerConnectionBackend::addTransceiver):
+        * Modules/mediastream/PeerConnectionBackend.h:
+        * Modules/mediastream/RTCPeerConnection.cpp:
+        (WebCore::RTCPeerConnection::addTrack):
+        (WebCore::RTCPeerConnection::addTransceiver):
+        (WebCore::RTCPeerConnection::enqueueReplaceTrackTask):
+        * Modules/mediastream/RTCPeerConnection.h:
+        * Modules/mediastream/RTCRtpReceiver.cpp:
+        (WebCore::RTCRtpReceiver::RTCRtpReceiver):
+        * Modules/mediastream/RTCRtpReceiver.h:
+        (WebCore::RTCRtpReceiver::create):
+        (WebCore::RTCRtpReceiver::setBackend):
+        * Modules/mediastream/RTCRtpReceiverBackend.h: Added.
+        (WebCore::RTCRtpReceiverBackend::getParameters):
+        * Modules/mediastream/RTCRtpSender.cpp:
+        (WebCore::RTCRtpSender::create):
+        (WebCore::RTCRtpSender::RTCRtpSender):
+        * Modules/mediastream/RTCRtpSender.h:
+        * Modules/mediastream/RTCRtpSenderBackend.h: Added.
+        * Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.cpp:
+        (WebCore::LibWebRTCMediaEndpoint::addRemoteTrack):
+        * Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.cpp:
+        (WebCore::LibWebRTCPeerConnectionBackend::videoReceiver):
+        (WebCore::LibWebRTCPeerConnectionBackend::audioReceiver):
+        (WebCore::LibWebRTCPeerConnectionBackend::addTrack):
+        (WebCore::LibWebRTCPeerConnectionBackend::addTransceiver):
+        (WebCore::LibWebRTCPeerConnectionBackend::completeAddTransceiver):
+        * Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.h:
+        * Modules/mediastream/libwebrtc/LibWebRTCRtpReceiverBackend.cpp: Added.
+        (WebCore::LibWebRTCRtpReceiverBackend::getParameters):
+        * Modules/mediastream/libwebrtc/LibWebRTCRtpReceiverBackend.h: Added.
+        * Modules/mediastream/libwebrtc/LibWebRTCRtpSenderBackend.cpp: Added.
+        (WebCore::LibWebRTCRtpSenderBackend::replaceTrack):
+        (WebCore::LibWebRTCRtpSenderBackend::getParameters const):
+        * Modules/mediastream/libwebrtc/LibWebRTCRtpSenderBackend.h: Added.
+        * Modules/mediastream/libwebrtc/LibWebRTCUtils.cpp: Added.
+        (WebCore::fillEncodingParameters):
+        (WebCore::fillHeaderExtensionParameters):
+        (WebCore::fillCodecParameters):
+        (WebCore::fillRtpParameters):
+        * Modules/mediastream/libwebrtc/LibWebRTCUtils.h: Added.
+        (WebCore::fromStdString):
+        * WebCore.xcodeproj/project.pbxproj:
+
 2018-09-04  Antoine Quint  <graouts@apple.com>
 
         [Modern Media Controls] Disabling both fullscreen and picture-in-picture shows an empty top left container
index 28734b2..333113f 100644 (file)
@@ -530,6 +530,21 @@ void PeerConnectionBackend::markAsNeedingNegotiation()
         m_peerConnection.scheduleNegotiationNeededEvent();
 }
 
+ExceptionOr<Ref<RTCRtpSender>> PeerConnectionBackend::addTrack(RTCRtpSender*, MediaStreamTrack&, const Vector<String>&)
+{
+    return Exception { NotSupportedError, "Not implemented"_s };
+}
+
+ExceptionOr<Ref<RTCRtpTransceiver>> PeerConnectionBackend::addTransceiver(const String&, const RTCRtpTransceiverInit&)
+{
+    return Exception { NotSupportedError, "Not implemented"_s };
+}
+
+ExceptionOr<Ref<RTCRtpTransceiver>> PeerConnectionBackend::addTransceiver(Ref<MediaStreamTrack>&&, const RTCRtpTransceiverInit&)
+{
+    return Exception { NotSupportedError, "Not implemented"_s };
+}
+
 #if !RELEASE_LOG_DISABLED
 WTFLogChannel& PeerConnectionBackend::logChannel() const
 {
index f8a976b..95e0f99 100644 (file)
@@ -50,6 +50,7 @@ class RTCIceCandidate;
 class RTCPeerConnection;
 class RTCRtpReceiver;
 class RTCRtpSender;
+class RTCRtpTransceiver;
 class RTCSessionDescription;
 class RTCStatsReport;
 
@@ -57,6 +58,7 @@ struct MediaEndpointConfiguration;
 struct RTCAnswerOptions;
 struct RTCDataChannelInit;
 struct RTCOfferOptions;
+struct RTCRtpTransceiverInit;
 
 namespace PeerConnection {
 using SessionDescriptionPromise = DOMPromiseDeferred<IDLDictionary<RTCSessionDescription::Init>>;
@@ -99,11 +101,11 @@ public:
     virtual void getStats(MediaStreamTrack*, Ref<DeferredPromise>&&) = 0;
 
     virtual Ref<RTCRtpReceiver> createReceiver(const String& transceiverMid, const String& trackKind, const String& trackId) = 0;
-    virtual void replaceTrack(RTCRtpSender&, RefPtr<MediaStreamTrack>&&, DOMPromiseDeferred<void>&&) = 0;
-    virtual bool notifyAddedTrack(RTCRtpSender&) { return false; }
+    virtual ExceptionOr<Ref<RTCRtpSender>> addTrack(RTCRtpSender*, MediaStreamTrack&, const Vector<String>&);
     virtual void notifyRemovedTrack(RTCRtpSender&) { }
 
-    virtual RTCRtpParameters getParameters(RTCRtpSender&) const { return { }; }
+    virtual ExceptionOr<Ref<RTCRtpTransceiver>> addTransceiver(const String&, const RTCRtpTransceiverInit&);
+    virtual ExceptionOr<Ref<RTCRtpTransceiver>> addTransceiver(Ref<MediaStreamTrack>&&, const RTCRtpTransceiverInit&);
 
     void markAsNeedingNegotiation();
     bool isNegotiationNeeded() const { return m_negotiationNeeded; };
index a04f81e..31e69e2 100644 (file)
@@ -128,7 +128,7 @@ ExceptionOr<Ref<RTCRtpSender>> RTCPeerConnection::addTrack(Ref<MediaStreamTrack>
     for (auto& transceiver : m_transceiverSet->list()) {
         auto& existingSender = transceiver->sender();
         if (existingSender.trackKind() == track->kind() && existingSender.trackId().isNull() && !transceiver->hasSendingDirection()) {
-            existingSender.setTrack(WTFMove(track));
+            existingSender.setTrack(track.copyRef());
             existingSender.setMediaStreamIds(WTFMove(mediaStreamIds));
             transceiver->enableSendingDirection();
             sender = &existingSender;
@@ -137,27 +137,7 @@ ExceptionOr<Ref<RTCRtpSender>> RTCPeerConnection::addTrack(Ref<MediaStreamTrack>
         }
     }
 
-    if (!sender) {
-        String transceiverMid = RTCRtpTransceiver::getNextMid();
-        const String& trackKind = track->kind();
-        String trackId = createCanonicalUUIDString();
-
-        auto newSender = RTCRtpSender::create(WTFMove(track), WTFMove(mediaStreamIds), *this);
-        auto receiver = m_backend->createReceiver(transceiverMid, trackKind, trackId);
-        auto transceiver = RTCRtpTransceiver::create(WTFMove(newSender), WTFMove(receiver));
-
-        // This transceiver is not yet associated with an m-line (null mid), but we need a
-        // provisional mid if the transceiver is used to create an offer.
-        transceiver->setProvisionalMid(transceiverMid);
-
-        sender = &transceiver->sender();
-        m_transceiverSet->append(WTFMove(transceiver));
-    }
-
-    if (!m_backend->notifyAddedTrack(*sender))
-        return Exception { InvalidAccessError, "Unable to add track"_s };
-
-    return Ref<RTCRtpSender> { *sender };
+    return m_backend->addTrack(sender, track.get(), mediaStreamIds);
 }
 
 ExceptionOr<void> RTCPeerConnection::removeTrack(RTCRtpSender& sender)
@@ -192,31 +172,11 @@ ExceptionOr<Ref<RTCRtpTransceiver>> RTCPeerConnection::addTransceiver(AddTransce
         if (kind != "audio" && kind != "video")
             return Exception { TypeError };
 
-        auto sender = RTCRtpSender::create(String(kind), Vector<String>(), *this);
-        return completeAddTransceiver(WTFMove(sender), init, createCanonicalUUIDString(), kind);
+        return m_backend->addTransceiver(kind, init);
     }
 
-    Ref<MediaStreamTrack> track = WTF::get<RefPtr<MediaStreamTrack>>(withTrack).releaseNonNull();
-    const String& trackId = track->id();
-    const String& trackKind = track->kind();
-
-    auto sender = RTCRtpSender::create(WTFMove(track), Vector<String>(), *this);
-    if (!m_backend->notifyAddedTrack(sender))
-        return Exception { InvalidAccessError, "Unable to add track"_s };
-
-    return completeAddTransceiver(WTFMove(sender), init, trackId, trackKind);
-}
-
-Ref<RTCRtpTransceiver> RTCPeerConnection::completeAddTransceiver(Ref<RTCRtpSender>&& sender, const RTCRtpTransceiverInit& init, const String& trackId, const String& trackKind)
-{
-    String transceiverMid = RTCRtpTransceiver::getNextMid();
-    auto transceiver = RTCRtpTransceiver::create(WTFMove(sender), m_backend->createReceiver(transceiverMid, trackKind, trackId));
-
-    transceiver->setProvisionalMid(transceiverMid);
-    transceiver->setDirection(init.direction);
-
-    m_transceiverSet->append(transceiver.copyRef());
-    return transceiver;
+    auto track = WTF::get<RefPtr<MediaStreamTrack>>(withTrack).releaseNonNull();
+    return m_backend->addTransceiver(WTFMove(track), init);
 }
 
 void RTCPeerConnection::queuedCreateOffer(RTCOfferOptions&& options, SessionDescriptionPromise&& promise)
@@ -586,28 +546,11 @@ void RTCPeerConnection::enqueueReplaceTrackTask(RTCRtpSender& sender, RefPtr<Med
         bool hasTrack = protectedSender->track();
         protectedSender->setTrack(withTrack.releaseNonNull());
         if (!hasTrack)
-            protectedThis->m_backend->notifyAddedTrack(protectedSender.get());
+            protectedThis->m_backend->addTrack(protectedSender.ptr(), *protectedSender->track(), { });
         promise.resolve();
     });
 }
 
-void RTCPeerConnection::replaceTrack(RTCRtpSender& sender, RefPtr<MediaStreamTrack>&& withTrack, DOMPromiseDeferred<void>&& promise)
-{
-    INFO_LOG(LOGIDENTIFIER);
-
-    if (!sender.track() && withTrack) {
-        enqueueReplaceTrackTask(sender, withTrack.releaseNonNull(), WTFMove(promise));
-        return;
-    }
-
-    m_backend->replaceTrack(sender, WTFMove(withTrack), WTFMove(promise));
-}
-
-RTCRtpParameters RTCPeerConnection::getParameters(RTCRtpSender& sender) const
-{
-    return m_backend->getParameters(sender);
-}
-
 void RTCPeerConnection::dispatchEvent(Event& event)
 {
     DEBUG_LOG(LOGIDENTIFIER, "dispatching '", event.type(), "'");
index 427bf22..84eb9bc 100644 (file)
@@ -66,7 +66,6 @@ struct RTCRtpTransceiverInit {
 
 class RTCPeerConnection final
     : public RefCounted<RTCPeerConnection>
-    , public RTCRtpSender::Backend
     , public EventTargetWithInlineData
     , public ActiveDOMObject
 #if !RELEASE_LOG_DISABLED
@@ -109,6 +108,8 @@ public:
     bool isClosed() const { return m_connectionState == RTCPeerConnectionState::Closed; }
     bool isStopped() const { return m_isStopped; }
 
+    void addInternalTransceiver(Ref<RTCRtpTransceiver>&& transceiver) { m_transceiverSet->append(WTFMove(transceiver)); }
+
     // 5.1 RTCPeerConnection extensions
     const Vector<std::reference_wrapper<RTCRtpSender>>& getSenders() const { return m_transceiverSet->senders(); }
     const Vector<std::reference_wrapper<RTCRtpReceiver>>& getReceivers() const { return m_transceiverSet->receivers(); }
@@ -144,7 +145,6 @@ public:
 
     void scheduleNegotiationNeededEvent();
 
-    RTCRtpSender::Backend& senderBackend() { return *this; }
     void fireEvent(Event&);
 
     void disableICECandidateFiltering() { m_backend->disableICECandidateFiltering(); }
@@ -186,11 +186,6 @@ private:
     const char* activeDOMObjectName() const final;
     bool canSuspendForDocumentSuspension() const final;
 
-    // FIXME: We might want PeerConnectionBackend to be the Backend
-    // RTCRtpSender::Backend
-    void replaceTrack(RTCRtpSender&, RefPtr<MediaStreamTrack>&&, DOMPromiseDeferred<void>&&) final;
-    RTCRtpParameters getParameters(RTCRtpSender&) const final;
-
     void updateConnectionState();
     bool doClose();
     void doStop();
index 3d67319..8fbe9a2 100644 (file)
@@ -37,9 +37,9 @@
 
 namespace WebCore {
 
-RTCRtpReceiver::RTCRtpReceiver(Ref<MediaStreamTrack>&& track, Backend* backend)
+RTCRtpReceiver::RTCRtpReceiver(Ref<MediaStreamTrack>&& track, std::unique_ptr<RTCRtpReceiverBackend>&& backend)
     : RTCRtpSenderReceiverBase(WTFMove(track))
-    , m_backend(backend)
+    , m_backend(WTFMove(backend))
 {
 }
 
index 14ab069..db6b749 100644 (file)
@@ -33,6 +33,7 @@
 #if ENABLE(WEB_RTC)
 
 #include "RTCRtpParameters.h"
+#include "RTCRtpReceiverBackend.h"
 #include "RTCRtpSenderReceiverBase.h"
 
 namespace WebCore {
@@ -40,31 +41,20 @@ namespace WebCore {
 
 class RTCRtpReceiver : public RTCRtpSenderReceiverBase {
 public:
-    class Backend {
-    public:
-        virtual ~Backend() = default;
-        virtual RTCRtpParameters getParameters() { return { }; }
-    };
-
-    static Ref<RTCRtpReceiver> create(Ref<MediaStreamTrack>&& track, Backend* backend = nullptr)
+    static Ref<RTCRtpReceiver> create(Ref<MediaStreamTrack>&& track, std::unique_ptr<RTCRtpReceiverBackend>&& backend = nullptr)
     {
-        return adoptRef(*new RTCRtpReceiver(WTFMove(track), backend));
+        return adoptRef(*new RTCRtpReceiver(WTFMove(track), WTFMove(backend)));
     }
 
     void stop();
 
-    // 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; }
+    void setBackend(std::unique_ptr<RTCRtpReceiverBackend>&& backend) { m_backend = WTFMove(backend); }
     RTCRtpParameters getParameters() { return m_backend ? m_backend->getParameters() : RTCRtpParameters(); }
 
 private:
-    explicit RTCRtpReceiver(Ref<MediaStreamTrack>&&, Backend*);
+    RTCRtpReceiver(Ref<MediaStreamTrack>&&, std::unique_ptr<RTCRtpReceiverBackend>&&);
 
-    bool m_isDispatched { false };
-    std::unique_ptr<Backend> m_backend;
+    std::unique_ptr<RTCRtpReceiverBackend> m_backend;
 };
 
 } // namespace WebCore
diff --git a/Source/WebCore/Modules/mediastream/RTCRtpReceiverBackend.h b/Source/WebCore/Modules/mediastream/RTCRtpReceiverBackend.h
new file mode 100644 (file)
index 0000000..137d646
--- /dev/null
@@ -0,0 +1,41 @@
+/*
+ * Copyright (C) 2018 Apple Inc.
+ *
+ * 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 "RTCRtpParameters.h"
+
+namespace WebCore {
+
+class RTCRtpReceiverBackend {
+public:
+    virtual ~RTCRtpReceiverBackend() = default;
+    virtual RTCRtpParameters getParameters() { return { }; }
+};
+
+} // namespace WebCore
+
+#endif // ENABLE(WEB_RTC)
index 18dc9bd..6a3d1bc 100644 (file)
 
 namespace WebCore {
 
-Ref<RTCRtpSender> RTCRtpSender::create(Ref<MediaStreamTrack>&& track, Vector<String>&& mediaStreamIds, Backend& backend)
+Ref<RTCRtpSender> RTCRtpSender::create(Ref<MediaStreamTrack>&& track, Vector<String>&& mediaStreamIds, std::unique_ptr<RTCRtpSenderBackend>&& backend)
 {
-    auto sender = adoptRef(*new RTCRtpSender(String(track->kind()), WTFMove(mediaStreamIds), backend));
+    auto sender = adoptRef(*new RTCRtpSender(String(track->kind()), WTFMove(mediaStreamIds), WTFMove(backend)));
     sender->setTrack(WTFMove(track));
     return sender;
 }
 
-Ref<RTCRtpSender> RTCRtpSender::create(String&& trackKind, Vector<String>&& mediaStreamIds, Backend& backend)
+Ref<RTCRtpSender> RTCRtpSender::create(String&& trackKind, Vector<String>&& mediaStreamIds, std::unique_ptr<RTCRtpSenderBackend>&& backend)
 {
-    return adoptRef(*new RTCRtpSender(WTFMove(trackKind), WTFMove(mediaStreamIds), backend));
+    return adoptRef(*new RTCRtpSender(WTFMove(trackKind), WTFMove(mediaStreamIds), WTFMove(backend)));
 }
 
-RTCRtpSender::RTCRtpSender(String&& trackKind, Vector<String>&& mediaStreamIds, Backend& backend)
+RTCRtpSender::RTCRtpSender(String&& trackKind, Vector<String>&& mediaStreamIds, std::unique_ptr<RTCRtpSenderBackend>&& backend)
     : RTCRtpSenderReceiverBase()
     , m_trackKind(WTFMove(trackKind))
     , m_mediaStreamIds(WTFMove(mediaStreamIds))
-    , m_backend(&backend)
+    , m_backend(WTFMove(backend))
 {
 }
 
index 8958df6..4e1e4b5 100644 (file)
 #if ENABLE(WEB_RTC)
 
 #include "PeerConnectionBackend.h"
+#include "RTCRtpSenderBackend.h"
 #include "RTCRtpSenderReceiverBase.h"
 
 namespace WebCore {
 
 class RTCRtpSender : public RTCRtpSenderReceiverBase {
 public:
-    class Backend {
-    public:
-        virtual void replaceTrack(RTCRtpSender&, RefPtr<MediaStreamTrack>&&, DOMPromiseDeferred<void>&&) = 0;
-        virtual RTCRtpParameters getParameters(RTCRtpSender&) const = 0;
-        virtual ~Backend() = default;
-    };
-
-    static Ref<RTCRtpSender> create(Ref<MediaStreamTrack>&&, Vector<String>&& mediaStreamIds, Backend&);
-    static Ref<RTCRtpSender> create(String&& trackKind, Vector<String>&& mediaStreamIds, Backend&);
+    static Ref<RTCRtpSender> create(Ref<MediaStreamTrack>&&, Vector<String>&& mediaStreamIds, std::unique_ptr<RTCRtpSenderBackend>&&);
+    static Ref<RTCRtpSender> create(String&& trackKind, Vector<String>&& mediaStreamIds, std::unique_ptr<RTCRtpSenderBackend>&&);
 
     const String& trackId() const { return m_trackId; }
     const String& trackKind() const { return m_trackKind; }
@@ -65,12 +59,12 @@ public:
     RTCRtpParameters getParameters();
 
 private:
-    RTCRtpSender(String&& trackKind, Vector<String>&& mediaStreamIds, Backend&);
+    RTCRtpSender(String&& trackKind, Vector<String>&& mediaStreamIds, std::unique_ptr<RTCRtpSenderBackend>&&);
 
     String m_trackId;
     String m_trackKind;
     Vector<String> m_mediaStreamIds;
-    Backend* m_backend;
+    std::unique_ptr<RTCRtpSenderBackend> m_backend;
 };
 
 } // namespace WebCore
diff --git a/Source/WebCore/Modules/mediastream/RTCRtpSenderBackend.h b/Source/WebCore/Modules/mediastream/RTCRtpSenderBackend.h
new file mode 100644 (file)
index 0000000..5d258a4
--- /dev/null
@@ -0,0 +1,46 @@
+/*
+ * Copyright (C) 2018 Apple Inc.
+ *
+ * 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 "JSDOMPromiseDeferred.h"
+#include "RTCRtpParameters.h"
+
+namespace WebCore {
+
+class MediaStreamTrack;
+class RTCRtpSender;
+
+class RTCRtpSenderBackend {
+public:
+    virtual void replaceTrack(RTCRtpSender&, RefPtr<MediaStreamTrack>&&, DOMPromiseDeferred<void>&&) = 0;
+    virtual RTCRtpParameters getParameters(RTCRtpSender&) const = 0;
+    virtual ~RTCRtpSenderBackend() = default;
+};
+
+} // namespace WebCore
+
+#endif // ENABLE(WEB_RTC)
index 6a54faa..b5ebb7d 100644 (file)
 #include "LibWebRTCDataChannelHandler.h"
 #include "LibWebRTCPeerConnectionBackend.h"
 #include "LibWebRTCProvider.h"
+#include "LibWebRTCRtpReceiverBackend.h"
+#include "LibWebRTCRtpSenderBackend.h"
 #include "LibWebRTCStatsCollector.h"
+#include "LibWebRTCUtils.h"
 #include "Logging.h"
 #include "NotImplemented.h"
 #include "Performance.h"
 
 namespace WebCore {
 
-static inline String fromStdString(const std::string& value)
-{
-    return String::fromUTF8(value.data(), value.length());
-}
-
 LibWebRTCMediaEndpoint::LibWebRTCMediaEndpoint(LibWebRTCPeerConnectionBackend& peerConnection, LibWebRTCProvider& client)
     : m_peerConnectionBackend(peerConnection)
     , m_peerConnectionFactory(*client.factory())
@@ -366,16 +364,6 @@ void LibWebRTCMediaEndpoint::addRemoteStream(webrtc::MediaStreamInterface&)
 {
 }
 
-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);
@@ -405,7 +393,7 @@ void LibWebRTCMediaEndpoint::addRemoteTrack(rtc::scoped_refptr<webrtc::RtpReceiv
     }
     }
 
-    receiver->setBackend(std::make_unique<RTCRtpReceiverBackend>(WTFMove(rtcReceiver)));
+    receiver->setBackend(std::make_unique<LibWebRTCRtpReceiverBackend>(WTFMove(rtcReceiver)));
     
     auto* track = receiver->track();
     ASSERT(track);
@@ -626,94 +614,6 @@ void LibWebRTCMediaEndpoint::setRemoteSessionDescriptionFailed(const std::string
     });
 }
 
-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.max_bitrate_bps)
-        parameters.maxBitrate = *rtcParameters.max_bitrate_bps;
-    if (rtcParameters.max_framerate)
-        parameters.maxFramerate = *rtcParameters.max_framerate;
-    parameters.rid = fromStdString(rtcParameters.rid);
-    if (rtcParameters.scale_resolution_down_by)
-        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) {
-    // FIXME: Support DegradationPreference::DISABLED.
-    case webrtc::DegradationPreference::DISABLED:
-    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);
index 4580a44..c7c0644 100644 (file)
@@ -31,6 +31,8 @@
 #include "IceCandidate.h"
 #include "LibWebRTCDataChannelHandler.h"
 #include "LibWebRTCMediaEndpoint.h"
+#include "LibWebRTCRtpReceiverBackend.h"
+#include "LibWebRTCRtpSenderBackend.h"
 #include "MediaEndpointConfiguration.h"
 #include "Page.h"
 #include "RTCIceCandidate.h"
@@ -254,7 +256,8 @@ LibWebRTCPeerConnectionBackend::VideoReceiver LibWebRTCPeerConnectionBackend::vi
     auto source = RealtimeIncomingVideoSource::create(nullptr, WTFMove(trackId));
     auto receiver = createReceiverForSource(*m_peerConnection.scriptExecutionContext(), source.copyRef());
 
-    auto transceiver = RTCRtpTransceiver::create(RTCRtpSender::create("video", { }, m_peerConnection), receiver.copyRef());
+    auto senderBackend = std::make_unique<LibWebRTCRtpSenderBackend>(*this, nullptr);
+    auto transceiver = RTCRtpTransceiver::create(RTCRtpSender::create("video", { }, WTFMove(senderBackend)), receiver.copyRef());
     transceiver->disableSendingDirection();
     m_peerConnection.addTransceiver(WTFMove(transceiver));
 
@@ -276,7 +279,8 @@ LibWebRTCPeerConnectionBackend::AudioReceiver LibWebRTCPeerConnectionBackend::au
     auto source = RealtimeIncomingAudioSource::create(nullptr, WTFMove(trackId));
     auto receiver = createReceiverForSource(*m_peerConnection.scriptExecutionContext(), source.copyRef());
 
-    auto transceiver = RTCRtpTransceiver::create(RTCRtpSender::create("audio", { }, m_peerConnection), receiver.copyRef());
+    auto senderBackend = std::make_unique<LibWebRTCRtpSenderBackend>(*this, nullptr);
+    auto transceiver = RTCRtpTransceiver::create(RTCRtpSender::create("audio", { }, WTFMove(senderBackend)), receiver.copyRef());
     transceiver->disableSendingDirection();
     m_peerConnection.addTransceiver(WTFMove(transceiver));
 
@@ -327,10 +331,59 @@ RefPtr<RTCSessionDescription> LibWebRTCPeerConnectionBackend::remoteDescription(
     return m_endpoint->remoteDescription();
 }
 
-bool LibWebRTCPeerConnectionBackend::notifyAddedTrack(RTCRtpSender& sender)
+ExceptionOr<Ref<RTCRtpSender>> LibWebRTCPeerConnectionBackend::addTrack(RTCRtpSender* sender, MediaStreamTrack& track, const Vector<String>& mediaStreamIds)
 {
-    ASSERT(sender.track());
-    return m_endpoint->addTrack(sender, *sender.track(), sender.mediaStreamIds());
+    if (!sender) {
+        String transceiverMid = RTCRtpTransceiver::getNextMid();
+        const String& trackKind = track.kind();
+        String trackId = createCanonicalUUIDString();
+
+        auto senderBackend = std::make_unique<LibWebRTCRtpSenderBackend>(*this, nullptr);
+        auto newSender = RTCRtpSender::create(makeRef(track), Vector<String> { mediaStreamIds }, WTFMove(senderBackend));
+        auto receiver = createReceiver(transceiverMid, trackKind, trackId);
+        auto transceiver = RTCRtpTransceiver::create(WTFMove(newSender), WTFMove(receiver));
+
+        // This transceiver is not yet associated with an m-line (null mid), but we need a
+        // provisional mid if the transceiver is used to create an offer.
+        transceiver->setProvisionalMid(transceiverMid);
+
+        sender = &transceiver->sender();
+        m_peerConnection.addInternalTransceiver(WTFMove(transceiver));
+    }
+
+    if (!m_endpoint->addTrack(*sender, track, mediaStreamIds))
+        return Exception { TypeError, "Unable to add track"_s };
+
+    return makeRef(*sender);
+}
+
+ExceptionOr<Ref<RTCRtpTransceiver>> LibWebRTCPeerConnectionBackend::addTransceiver(const String& trackKind, const RTCRtpTransceiverInit& init)
+{
+    auto senderBackend = std::make_unique<LibWebRTCRtpSenderBackend>(*this, nullptr);
+    auto newSender = RTCRtpSender::create(String(trackKind), Vector<String>(), WTFMove(senderBackend));
+    return completeAddTransceiver(WTFMove(newSender), init, createCanonicalUUIDString(), trackKind);
+}
+
+ExceptionOr<Ref<RTCRtpTransceiver>> LibWebRTCPeerConnectionBackend::addTransceiver(Ref<MediaStreamTrack>&& track, const RTCRtpTransceiverInit& init)
+{
+    auto senderBackend = std::make_unique<LibWebRTCRtpSenderBackend>(*this, nullptr);
+    auto sender = RTCRtpSender::create(track.copyRef(), Vector<String>(), WTFMove(senderBackend));
+    if (!m_endpoint->addTrack(sender.get(), track, Vector<String> { }))
+        return Exception { InvalidAccessError, "Unable to add track"_s };
+
+    return completeAddTransceiver(WTFMove(sender), init, track->id(), track->kind());
+}
+
+Ref<RTCRtpTransceiver> LibWebRTCPeerConnectionBackend::completeAddTransceiver(Ref<RTCRtpSender>&& sender, const RTCRtpTransceiverInit& init, const String& trackId, const String& trackKind)
+{
+    String transceiverMid = RTCRtpTransceiver::getNextMid();
+    auto transceiver = RTCRtpTransceiver::create(WTFMove(sender), createReceiver(transceiverMid, trackKind, trackId));
+
+    transceiver->setProvisionalMid(transceiverMid);
+    transceiver->setDirection(init.direction);
+
+    m_peerConnection.addInternalTransceiver(transceiver.copyRef());
+    return transceiver;
 }
 
 void LibWebRTCPeerConnectionBackend::notifyRemovedTrack(RTCRtpSender& sender)
index 437b7e6..d10bb1a 100644 (file)
@@ -28,6 +28,7 @@
 
 #include "PeerConnectionBackend.h"
 #include <wtf/HashMap.h>
+#include <wtf/WeakPtr.h>
 
 namespace webrtc {
 class IceCandidateInterface;
@@ -45,7 +46,7 @@ class RealtimeIncomingVideoSource;
 class RealtimeOutgoingAudioSource;
 class RealtimeOutgoingVideoSource;
 
-class LibWebRTCPeerConnectionBackend final : public PeerConnectionBackend {
+class LibWebRTCPeerConnectionBackend final : public PeerConnectionBackend, public CanMakeWeakPtr<LibWebRTCPeerConnectionBackend> {
     WTF_MAKE_FAST_ALLOCATED;
 public:
     LibWebRTCPeerConnectionBackend(RTCPeerConnection&, LibWebRTCProvider&);
@@ -54,6 +55,9 @@ public:
     bool hasAudioSources() const { return m_audioSources.size(); }
     bool hasVideoSources() const { return m_videoSources.size(); }
 
+    void replaceTrack(RTCRtpSender&, RefPtr<MediaStreamTrack>&&, DOMPromiseDeferred<void>&&);
+    RTCRtpParameters getParameters(RTCRtpSender&) const;
+
 private:
     void doCreateOffer(RTCOfferOptions&&) final;
     void doCreateAnswer(RTCAnswerOptions&&) final;
@@ -74,22 +78,23 @@ private:
     RefPtr<RTCSessionDescription> currentRemoteDescription() const final;
     RefPtr<RTCSessionDescription> pendingRemoteDescription() const final;
 
-    void replaceTrack(RTCRtpSender&, RefPtr<MediaStreamTrack>&&, DOMPromiseDeferred<void>&&) final;
-    RTCRtpParameters getParameters(RTCRtpSender&) const final;
-
     void emulatePlatformEvent(const String&) final { }
     void applyRotationForOutgoingVideoSources() final;
 
-    friend LibWebRTCMediaEndpoint;
+    friend class LibWebRTCMediaEndpoint;
+    friend class LibWebRTCRtpSenderBackend;
     RTCPeerConnection& connection() { return m_peerConnection; }
     void addAudioSource(Ref<RealtimeOutgoingAudioSource>&&);
     void addVideoSource(Ref<RealtimeOutgoingVideoSource>&&);
 
     void getStatsSucceeded(const DeferredPromise&, Ref<RTCStatsReport>&&);
 
-    bool notifyAddedTrack(RTCRtpSender&) final;
+    ExceptionOr<Ref<RTCRtpSender>> addTrack(RTCRtpSender*, MediaStreamTrack&, const Vector<String>&) final;
     void notifyRemovedTrack(RTCRtpSender&) final;
 
+    ExceptionOr<Ref<RTCRtpTransceiver>> addTransceiver(const String&, const RTCRtpTransceiverInit&) final;
+    ExceptionOr<Ref<RTCRtpTransceiver>> addTransceiver(Ref<MediaStreamTrack>&&, const RTCRtpTransceiverInit&) final;
+
     struct VideoReceiver {
         Ref<RTCRtpReceiver> receiver;
         Ref<RealtimeIncomingVideoSource> source;
@@ -104,6 +109,8 @@ private:
 private:
     bool isLocalDescriptionSet() const final { return m_isLocalDescriptionSet; }
 
+    Ref<RTCRtpTransceiver> completeAddTransceiver(Ref<RTCRtpSender>&&, const RTCRtpTransceiverInit&, const String& trackId, const String& trackKind);
+
     Ref<LibWebRTCMediaEndpoint> m_endpoint;
     bool m_isLocalDescriptionSet { false };
     bool m_isRemoteDescriptionSet { false };
diff --git a/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCRtpReceiverBackend.cpp b/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCRtpReceiverBackend.cpp
new file mode 100644 (file)
index 0000000..4df4e7c
--- /dev/null
@@ -0,0 +1,41 @@
+/*
+ * Copyright (C) 2018 Apple Inc.
+ *
+ * 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.
+ */
+
+#include "config.h"
+#include "LibWebRTCRtpReceiverBackend.h"
+
+#include "LibWebRTCUtils.h"
+
+#if ENABLE(WEB_RTC) && USE(LIBWEBRTC)
+
+namespace WebCore {
+
+RTCRtpParameters LibWebRTCRtpReceiverBackend::getParameters()
+{
+    return fillRtpParameters(m_rtcReceiver->GetParameters());
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(WEB_RTC) && USE(LIBWEBRTC)
diff --git a/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCRtpReceiverBackend.h b/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCRtpReceiverBackend.h
new file mode 100644 (file)
index 0000000..7ace2e4
--- /dev/null
@@ -0,0 +1,57 @@
+/*
+ * Copyright (C) 2018 Apple Inc.
+ *
+ * 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) && USE(LIBWEBRTC)
+
+#include "LibWebRTCMacros.h"
+#include "RTCRtpReceiverBackend.h"
+
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wunused-parameter"
+
+#include <webrtc/api/rtpreceiverinterface.h>
+#include <webrtc/rtc_base/scoped_ref_ptr.h>
+
+#pragma GCC diagnostic pop
+
+namespace WebCore {
+
+class LibWebRTCRtpReceiverBackend final : public RTCRtpReceiverBackend {
+public:
+    explicit LibWebRTCRtpReceiverBackend(rtc::scoped_refptr<webrtc::RtpReceiverInterface>&& rtcReceiver)
+        : m_rtcReceiver(WTFMove(rtcReceiver))
+    {
+    }
+
+private:
+    RTCRtpParameters getParameters() final;
+
+    rtc::scoped_refptr<webrtc::RtpReceiverInterface> m_rtcReceiver;
+};
+
+} // namespace WebCore
+
+#endif // ENABLE(WEB_RTC) && USE(LIBWEBRTC)
diff --git a/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCRtpSenderBackend.cpp b/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCRtpSenderBackend.cpp
new file mode 100644 (file)
index 0000000..36863a9
--- /dev/null
@@ -0,0 +1,65 @@
+/*
+ * Copyright (C) 2018 Apple Inc.
+ *
+ * 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.
+ */
+
+#include "config.h"
+#include "LibWebRTCRtpSenderBackend.h"
+
+#if ENABLE(WEB_RTC) && USE(LIBWEBRTC)
+
+#include "LibWebRTCPeerConnectionBackend.h"
+#include "LibWebRTCUtils.h"
+#include "RTCPeerConnection.h"
+#include "RTCRtpSender.h"
+
+namespace WebCore {
+
+void LibWebRTCRtpSenderBackend::replaceTrack(RTCRtpSender& sender, RefPtr<MediaStreamTrack>&& track, DOMPromiseDeferred<void>&& promise)
+{
+    if (!m_peerConnectionBackend) {
+        promise.reject(Exception { InvalidStateError, "No WebRTC backend"_s });
+        return;
+    }
+
+    if (!sender.track() && track) {
+        m_peerConnectionBackend->connection().enqueueReplaceTrackTask(sender, track.releaseNonNull(), WTFMove(promise));
+        return;
+    }
+
+    m_peerConnectionBackend->replaceTrack(sender, WTFMove(track), WTFMove(promise));
+}
+
+RTCRtpParameters LibWebRTCRtpSenderBackend::getParameters(RTCRtpSender& sender) const
+{
+    if (!m_rtcSender) {
+        // FIXME: We should not need to go through the backend and should directly have m_rtcSender here.
+        if (!m_peerConnectionBackend)
+            return { };
+        return m_peerConnectionBackend->getParameters(sender);
+    }
+    return fillRtpParameters(m_rtcSender->GetParameters());
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(WEB_RTC) && USE(LIBWEBRTC)
diff --git a/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCRtpSenderBackend.h b/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCRtpSenderBackend.h
new file mode 100644 (file)
index 0000000..3fd331a
--- /dev/null
@@ -0,0 +1,64 @@
+/*
+ * Copyright (C) 2018 Apple Inc.
+ *
+ * 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 "LibWebRTCMacros.h"
+#include "RTCRtpSenderBackend.h"
+#include <wtf/WeakPtr.h>
+
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wunused-parameter"
+
+#include <webrtc/api/rtpsenderinterface.h>
+#include <webrtc/rtc_base/scoped_ref_ptr.h>
+
+#pragma GCC diagnostic pop
+
+namespace WebCore {
+
+class LibWebRTCPeerConnectionBackend;
+
+class LibWebRTCRtpSenderBackend final : public RTCRtpSenderBackend {
+public:
+    explicit LibWebRTCRtpSenderBackend(LibWebRTCPeerConnectionBackend& backend, rtc::scoped_refptr<webrtc::RtpSenderInterface>&& rtcSender)
+        : m_peerConnectionBackend(makeWeakPtr(&backend))
+        , m_rtcSender(WTFMove(rtcSender))
+    {
+    }
+
+private:
+    void setRTCSender(rtc::scoped_refptr<webrtc::RtpSenderInterface>&& rtcSender) { m_rtcSender = WTFMove(rtcSender); }
+    void replaceTrack(RTCRtpSender&, RefPtr<MediaStreamTrack>&&, DOMPromiseDeferred<void>&&) final;
+    RTCRtpParameters getParameters(RTCRtpSender&) const final;
+
+    WeakPtr<LibWebRTCPeerConnectionBackend> m_peerConnectionBackend;
+    rtc::scoped_refptr<webrtc::RtpSenderInterface> m_rtcSender;
+};
+
+} // namespace WebCore
+
+#endif // ENABLE(WEB_RTC)
diff --git a/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCUtils.cpp b/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCUtils.cpp
new file mode 100644 (file)
index 0000000..4e85411
--- /dev/null
@@ -0,0 +1,122 @@
+/*
+ * 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.
+ */
+
+#include "config.h"
+#include "LibWebRTCUtils.h"
+
+#if USE(LIBWEBRTC)
+
+#include "LibWebRTCMacros.h"
+#include "RTCRtpParameters.h"
+#include <webrtc/api/rtpparameters.h>
+#include <wtf/text/WTFString.h>
+
+namespace WebCore {
+
+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.max_bitrate_bps)
+        parameters.maxBitrate = *rtcParameters.max_bitrate_bps;
+    if (rtcParameters.max_framerate)
+        parameters.maxFramerate = *rtcParameters.max_framerate;
+    parameters.rid = fromStdString(rtcParameters.rid);
+    if (rtcParameters.scale_resolution_down_by)
+        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;
+}
+
+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) {
+    // FIXME: Support DegradationPreference::DISABLED.
+    case webrtc::DegradationPreference::DISABLED:
+    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;
+}
+
+}; // namespace WebCore
+
+#endif // USE(LIBWEBRTC)
diff --git a/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCUtils.h b/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCUtils.h
new file mode 100644 (file)
index 0000000..f26c3cf
--- /dev/null
@@ -0,0 +1,48 @@
+/*
+ * 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 USE(LIBWEBRTC)
+
+#include <wtf/text/WTFString.h>
+
+namespace webrtc {
+struct RtpParameters;
+}
+
+namespace WebCore {
+
+struct RTCRtpParameters;
+
+RTCRtpParameters fillRtpParameters(const webrtc::RtpParameters&);
+
+inline String fromStdString(const std::string& value)
+{
+    return String::fromUTF8(value.data(), value.length());
+}
+
+} // namespace WebCore
+
+#endif // USE(LIBWEBRTC)
index 5fc7690..908305e 100644 (file)
                41815C1F138319830057AAA4 /* WebCoreTestSupport.h in Headers */ = {isa = PBXBuildFile; fileRef = 41815C1D138319830057AAA4 /* WebCoreTestSupport.h */; settings = {ATTRIBUTES = (Private, ); }; };
                418205471E53E98C00D62207 /* RTCController.h in Headers */ = {isa = PBXBuildFile; fileRef = 418205451E53C8CD00D62207 /* RTCController.h */; settings = {ATTRIBUTES = (Private, ); }; };
                4184F5161EAF05A800F18BF0 /* OrientationNotifier.h in Headers */ = {isa = PBXBuildFile; fileRef = 4184F5151EAF059800F18BF0 /* OrientationNotifier.h */; settings = {ATTRIBUTES = (Private, ); }; };
+               4186BD3E213EE3400001826F /* LibWebRTCUtils.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 41D1A049213EDDFD0063FB6B /* LibWebRTCUtils.cpp */; };
+               4186BD3F213EE3430001826F /* LibWebRTCRtpSenderBackend.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 41D1A04B213EDDFE0063FB6B /* LibWebRTCRtpSenderBackend.cpp */; };
+               4186BD40213EE3450001826F /* LibWebRTCRtpReceiverBackend.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 41D1A04A213EDDFE0063FB6B /* LibWebRTCRtpReceiverBackend.cpp */; };
                41885B9311B6FDA6003383BB /* FormSubmission.h in Headers */ = {isa = PBXBuildFile; fileRef = 41885B9111B6FDA6003383BB /* FormSubmission.h */; settings = {ATTRIBUTES = (Private, ); }; };
                418A06D0133C04D500CD379C /* EventDispatcher.h in Headers */ = {isa = PBXBuildFile; fileRef = 418A06CE133C04D500CD379C /* EventDispatcher.h */; };
                418F88050FF957AF0080F045 /* JSAbstractWorker.h in Headers */ = {isa = PBXBuildFile; fileRef = 418F88030FF957AE0080F045 /* JSAbstractWorker.h */; };
                418205451E53C8CD00D62207 /* RTCController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RTCController.h; sourceTree = "<group>"; };
                418205481E53EAAD00D62207 /* RTCController.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RTCController.cpp; sourceTree = "<group>"; };
                4184F5151EAF059800F18BF0 /* OrientationNotifier.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OrientationNotifier.h; sourceTree = "<group>"; };
+               4186BD3B213EDE380001826F /* LibWebRTCRtpReceiverBackend.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = LibWebRTCRtpReceiverBackend.h; path = libwebrtc/LibWebRTCRtpReceiverBackend.h; sourceTree = "<group>"; };
+               4186BD3D213EDE390001826F /* LibWebRTCRtpSenderBackend.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = LibWebRTCRtpSenderBackend.h; path = libwebrtc/LibWebRTCRtpSenderBackend.h; sourceTree = "<group>"; };
                41885B9111B6FDA6003383BB /* FormSubmission.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FormSubmission.h; sourceTree = "<group>"; };
                41885B9211B6FDA6003383BB /* FormSubmission.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FormSubmission.cpp; sourceTree = "<group>"; };
                418A06CE133C04D500CD379C /* EventDispatcher.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EventDispatcher.h; sourceTree = "<group>"; };
                41D129CA1F3D0EE300D15E47 /* CacheStorageRecord.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CacheStorageRecord.h; sourceTree = "<group>"; };
                41D129CC1F3D0EE300D15E47 /* CacheStorageConnection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CacheStorageConnection.h; sourceTree = "<group>"; };
                41D129D41F3D0F6600D15E47 /* CacheStorageProvider.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CacheStorageProvider.h; sourceTree = "<group>"; };
+               41D1A046213EDDEB0063FB6B /* RTCRtpSenderBackend.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RTCRtpSenderBackend.h; sourceTree = "<group>"; };
+               41D1A048213EDDEB0063FB6B /* RTCRtpReceiverBackend.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RTCRtpReceiverBackend.h; sourceTree = "<group>"; };
+               41D1A049213EDDFD0063FB6B /* LibWebRTCUtils.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = LibWebRTCUtils.cpp; path = libwebrtc/LibWebRTCUtils.cpp; sourceTree = "<group>"; };
+               41D1A04A213EDDFE0063FB6B /* LibWebRTCRtpReceiverBackend.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = LibWebRTCRtpReceiverBackend.cpp; path = libwebrtc/LibWebRTCRtpReceiverBackend.cpp; sourceTree = "<group>"; };
+               41D1A04B213EDDFE0063FB6B /* LibWebRTCRtpSenderBackend.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = LibWebRTCRtpSenderBackend.cpp; path = libwebrtc/LibWebRTCRtpSenderBackend.cpp; sourceTree = "<group>"; };
+               41D1A04C213EDDFF0063FB6B /* LibWebRTCUtils.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = LibWebRTCUtils.h; path = libwebrtc/LibWebRTCUtils.h; sourceTree = "<group>"; };
                41D28D0B2139E01D00F4206F /* LibWebRTCStatsCollector.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = LibWebRTCStatsCollector.cpp; path = libwebrtc/LibWebRTCStatsCollector.cpp; sourceTree = "<group>"; };
                41D28D0C2139E01E00F4206F /* LibWebRTCStatsCollector.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = LibWebRTCStatsCollector.h; path = libwebrtc/LibWebRTCStatsCollector.h; sourceTree = "<group>"; };
                41D51BB21E4E2E8100131A5B /* LibWebRTCAudioFormat.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = LibWebRTCAudioFormat.h; path = libwebrtc/LibWebRTCAudioFormat.h; sourceTree = "<group>"; };
                                5E2C43561BCEE30D0001E2BC /* RTCRtpReceiver.cpp */,
                                5E2C43571BCEE30D0001E2BC /* RTCRtpReceiver.h */,
                                5E2C43581BCEE30D0001E2BC /* RTCRtpReceiver.idl */,
+                               41D1A048213EDDEB0063FB6B /* RTCRtpReceiverBackend.h */,
                                5E2C43591BCEE30D0001E2BC /* RTCRtpSender.cpp */,
                                5E2C435A1BCEE30D0001E2BC /* RTCRtpSender.h */,
                                5E2C435B1BCEE30D0001E2BC /* RTCRtpSender.idl */,
+                               41D1A046213EDDEB0063FB6B /* RTCRtpSenderBackend.h */,
                                5E2C435D1BCEE30D0001E2BC /* RTCRtpSenderReceiverBase.h */,
                                5E5E2B101CFC3E4B000C0D85 /* RTCRtpTransceiver.cpp */,
                                5E5E2B111CFC3E4B000C0D85 /* RTCRtpTransceiver.h */,
                                415A3B732138E264001B4BAA /* LibWebRTCObservers.h */,
                                417612AD1E3A993B00C3D81D /* LibWebRTCPeerConnectionBackend.cpp */,
                                417612AE1E3A993B00C3D81D /* LibWebRTCPeerConnectionBackend.h */,
+                               41D1A04A213EDDFE0063FB6B /* LibWebRTCRtpReceiverBackend.cpp */,
+                               4186BD3B213EDE380001826F /* LibWebRTCRtpReceiverBackend.h */,
+                               41D1A04B213EDDFE0063FB6B /* LibWebRTCRtpSenderBackend.cpp */,
+                               4186BD3D213EDE390001826F /* LibWebRTCRtpSenderBackend.h */,
                                41D28D0B2139E01D00F4206F /* LibWebRTCStatsCollector.cpp */,
                                41D28D0C2139E01E00F4206F /* LibWebRTCStatsCollector.h */,
+                               41D1A049213EDDFD0063FB6B /* LibWebRTCUtils.cpp */,
+                               41D1A04C213EDDFF0063FB6B /* LibWebRTCUtils.h */,
                        );
                        name = libwebrtc;
                        sourceTree = "<group>";
                                5CDD83641E4325A000621E92 /* LibWebRTCDataChannelHandler.cpp in Sources */,
                                417612AF1E3A994000C3D81D /* LibWebRTCMediaEndpoint.cpp in Sources */,
                                417612B11E3A994000C3D81D /* LibWebRTCPeerConnectionBackend.cpp in Sources */,
+                               4186BD40213EE3450001826F /* LibWebRTCRtpReceiverBackend.cpp in Sources */,
+                               4186BD3F213EE3430001826F /* LibWebRTCRtpSenderBackend.cpp in Sources */,
                                41D28D0D2139E05800F4206F /* LibWebRTCStatsCollector.cpp in Sources */,
+                               4186BD3E213EE3400001826F /* LibWebRTCUtils.cpp in Sources */,
                                9759E93E14EF1CF80026A2DD /* LoadableTextTrack.cpp in Sources */,
                                445775EA2047303C008DCE5D /* LocalDefaultSystemAppearance.mm in Sources */,
                                FABE72FE1059C21100D999DD /* MathMLNames.cpp in Sources */,