Title: [212315] trunk/Source/WebCore
Revision
212315
Author
[email protected]
Date
2017-02-14 11:40:13 -0800 (Tue, 14 Feb 2017)

Log Message

[WebRTC] Implement description getters for libwebrtc RTCPeerConnection
https://bugs.webkit.org/show_bug.cgi?id=168234

Patch by Youenn Fablet <[email protected]> on 2017-02-14
Reviewed by Alex Christensen.

Allows passing W3C webrtc tests.

Implementing localDescription/remoteDescription using libwebrtc backend.
current and pending description getters are made the same as local/remote getters for the moment.
This should be fixed when upgrading to latest libwebrtc revision.

* Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.cpp:
(WebCore::toSessionDescriptionType):
(WebCore::fromSessionDescriptionType):
(WebCore::fromSessionDescription):
(WebCore::LibWebRTCMediaEndpoint::localDescription):
(WebCore::LibWebRTCMediaEndpoint::remoteDescription):
(WebCore::LibWebRTCMediaEndpoint::doSetLocalDescription):
(WebCore::LibWebRTCMediaEndpoint::doSetRemoteDescription):
* Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.h:
* Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.cpp:
(WebCore::LibWebRTCPeerConnectionBackend::localDescription):
* Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (212314 => 212315)


--- trunk/Source/WebCore/ChangeLog	2017-02-14 19:34:09 UTC (rev 212314)
+++ trunk/Source/WebCore/ChangeLog	2017-02-14 19:40:13 UTC (rev 212315)
@@ -1,3 +1,29 @@
+2017-02-14  Youenn Fablet  <[email protected]>
+
+        [WebRTC] Implement description getters for libwebrtc RTCPeerConnection
+        https://bugs.webkit.org/show_bug.cgi?id=168234
+
+        Reviewed by Alex Christensen.
+
+        Allows passing W3C webrtc tests.
+
+        Implementing localDescription/remoteDescription using libwebrtc backend.
+        current and pending description getters are made the same as local/remote getters for the moment.
+        This should be fixed when upgrading to latest libwebrtc revision.
+
+        * Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.cpp:
+        (WebCore::toSessionDescriptionType):
+        (WebCore::fromSessionDescriptionType):
+        (WebCore::fromSessionDescription):
+        (WebCore::LibWebRTCMediaEndpoint::localDescription):
+        (WebCore::LibWebRTCMediaEndpoint::remoteDescription):
+        (WebCore::LibWebRTCMediaEndpoint::doSetLocalDescription):
+        (WebCore::LibWebRTCMediaEndpoint::doSetRemoteDescription):
+        * Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.h:
+        * Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.cpp:
+        (WebCore::LibWebRTCPeerConnectionBackend::localDescription):
+        * Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.h:
+
 2017-02-14  Jeremy Jones  <[email protected]>
 
         When playing inline after fullscreen, set a flag instead of adding attribute plays inline, and use in requiresFullscreenForVideoPlayback.

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


--- trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.cpp	2017-02-14 19:34:09 UTC (rev 212314)
+++ trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.cpp	2017-02-14 19:40:13 UTC (rev 212315)
@@ -76,6 +76,41 @@
     }
 }
 
+static inline RTCSessionDescription::SdpType fromSessionDescriptionType(const webrtc::SessionDescriptionInterface& description)
+{
+    auto type = description.type();
+    if (type == webrtc::SessionDescriptionInterface::kOffer)
+        return RTCSessionDescription::SdpType::Offer;
+    if (type == webrtc::SessionDescriptionInterface::kAnswer)
+        return RTCSessionDescription::SdpType::Answer;
+    ASSERT(type == webrtc::SessionDescriptionInterface::kPrAnswer);
+    return RTCSessionDescription::SdpType::Pranswer;
+}
+
+static inline RefPtr<RTCSessionDescription> fromSessionDescription(const webrtc::SessionDescriptionInterface* description)
+{
+    if (!description)
+        return nullptr;
+
+    std::string sdp;
+    description->ToString(&sdp);
+    String sdpString(sdp.data(), sdp.size());
+
+    return RTCSessionDescription::create(fromSessionDescriptionType(*description), WTFMove(sdpString));
+}
+
+RefPtr<RTCSessionDescription> LibWebRTCMediaEndpoint::localDescription() const
+{
+    // FIXME: We might want to create a new object only if the session actually changed.
+    return fromSessionDescription(m_backend->local_description());
+}
+
+RefPtr<RTCSessionDescription> LibWebRTCMediaEndpoint::remoteDescription() const
+{
+    // FIXME: We might want to create a new object only if the session actually changed.
+    return fromSessionDescription(m_backend->remote_description());
+}
+
 void LibWebRTCMediaEndpoint::doSetLocalDescription(RTCSessionDescription& description)
 {
     webrtc::SdpParseError error;

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


--- trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.h	2017-02-14 19:34:09 UTC (rev 212314)
+++ trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.h	2017-02-14 19:40:13 UTC (rev 212315)
@@ -72,6 +72,9 @@
     void stop();
     bool isStopped() const { return !m_backend; }
 
+    RefPtr<RTCSessionDescription> localDescription() const;
+    RefPtr<RTCSessionDescription> remoteDescription() const;
+
 private:
     LibWebRTCMediaEndpoint(LibWebRTCPeerConnectionBackend&, LibWebRTCProvider&);
 

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


--- trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.cpp	2017-02-14 19:34:09 UTC (rev 212314)
+++ trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.cpp	2017-02-14 19:40:13 UTC (rev 212315)
@@ -221,6 +221,16 @@
     return m_endpoint->createDataChannel(label, options);
 }
 
+RefPtr<RTCSessionDescription> LibWebRTCPeerConnectionBackend::localDescription() const
+{
+    return m_endpoint->localDescription();
+}
+
+RefPtr<RTCSessionDescription> LibWebRTCPeerConnectionBackend::remoteDescription() const
+{
+    return m_endpoint->remoteDescription();
+}
+
 } // namespace WebCore
 
 #endif // USE(LIBWEBRTC)

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


--- trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.h	2017-02-14 19:34:09 UTC (rev 212314)
+++ trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.h	2017-02-14 19:40:13 UTC (rev 212315)
@@ -58,19 +58,17 @@
     void getStats(MediaStreamTrack*, Ref<DeferredPromise>&&) final;
     Ref<RTCRtpReceiver> createReceiver(const String& transceiverMid, const String& trackKind, const String& trackId) final;
 
-    // FIXME: API to implement for real
-    RefPtr<RTCSessionDescription> localDescription() const final { return nullptr; }
-    RefPtr<RTCSessionDescription> currentLocalDescription() const final { return nullptr; }
-    RefPtr<RTCSessionDescription> pendingLocalDescription() const final { return nullptr; }
+    RefPtr<RTCSessionDescription> localDescription() const final;
+    RefPtr<RTCSessionDescription> currentLocalDescription() const final { return localDescription(); }
+    RefPtr<RTCSessionDescription> pendingLocalDescription() const final { return localDescription(); }
 
-    RefPtr<RTCSessionDescription> remoteDescription() const final { return nullptr; }
-    RefPtr<RTCSessionDescription> currentRemoteDescription() const final { return nullptr; }
-    RefPtr<RTCSessionDescription> pendingRemoteDescription() const final { return nullptr; }
+    RefPtr<RTCSessionDescription> remoteDescription() const final;
+    RefPtr<RTCSessionDescription> currentRemoteDescription() const final { return remoteDescription(); }
+    RefPtr<RTCSessionDescription> pendingRemoteDescription() const final { return remoteDescription(); }
 
+    // FIXME: API to implement for real
     Vector<RefPtr<MediaStream>> getRemoteStreams() const final { return { }; }
-
     void replaceTrack(RTCRtpSender&, RefPtr<MediaStreamTrack>&&, DOMPromise<void>&&) final { }
-
     bool isNegotiationNeeded() const final { return false; }
     void markAsNeedingNegotiation() final;
     void clearNegotiationNeededState() final { }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to