Changeset 282217 in webkit
- Timestamp:
- Sep 9, 2021 9:08:51 AM (10 months ago)
- Location:
- trunk
- Files:
-
- 14 edited
-
LayoutTests/ChangeLog (modified) (1 diff)
-
LayoutTests/imported/w3c/ChangeLog (modified) (1 diff)
-
LayoutTests/imported/w3c/web-platform-tests/webrtc/RTCPeerConnection-description-attributes-timing.https-expected.txt (modified) (1 diff)
-
LayoutTests/imported/w3c/web-platform-tests/webrtc/RTCPeerConnection-setLocalDescription-rollback-expected.txt (modified) (1 diff)
-
LayoutTests/webrtc/datachannel/mdns-ice-candidates.html (modified) (1 diff)
-
Source/WebCore/ChangeLog (modified) (1 diff)
-
Source/WebCore/Modules/mediastream/PeerConnectionBackend.cpp (modified) (6 diffs)
-
Source/WebCore/Modules/mediastream/PeerConnectionBackend.h (modified) (5 diffs)
-
Source/WebCore/Modules/mediastream/RTCPeerConnection.cpp (modified) (3 diffs)
-
Source/WebCore/Modules/mediastream/RTCPeerConnection.h (modified) (3 diffs)
-
Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.cpp (modified) (6 diffs)
-
Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.h (modified) (1 diff)
-
Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.cpp (modified) (4 diffs)
-
Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r282214 r282217 1 2021-09-09 Youenn Fablet <youenn@apple.com> 2 3 Update RTCPeerConnection descriptions as per specification 4 https://bugs.webkit.org/show_bug.cgi?id=229963 5 6 Reviewed by Eric Carlson. 7 8 Now that we update descriptions at specific times, 9 we need to wait a bit to get the description. 10 11 * webrtc/datachannel/mdns-ice-candidates.html: 12 1 13 2021-09-09 Eric Hutchison <ehutchison@apple.com> 2 14 -
trunk/LayoutTests/imported/w3c/ChangeLog
r282208 r282217 1 2021-09-09 Youenn Fablet <youenn@apple.com> 2 3 Update RTCPeerConnection descriptions as per specification 4 https://bugs.webkit.org/show_bug.cgi?id=229963 5 6 Reviewed by Eric Carlson. 7 8 * web-platform-tests/webrtc/RTCPeerConnection-description-attributes-timing.https-expected.txt: 9 * web-platform-tests/webrtc/RTCPeerConnection-setLocalDescription-rollback-expected.txt: 10 1 11 2021-09-09 Manuel Rego Casasnovas <rego@igalia.com> 2 12 -
trunk/LayoutTests/imported/w3c/web-platform-tests/webrtc/RTCPeerConnection-description-attributes-timing.https-expected.txt
r270252 r282217 1 1 2 FAIL pendingLocalDescription is surfaced at the right time assert_equals: pendingLocalDescription is still null while promise pending expected null but got object "[object RTCSessionDescription]" 3 FAIL pendingRemoteDescription is surfaced at the right time assert_equals: pendingRemoteDescription is still null while promise pending expected null but got object "[object RTCSessionDescription]" 4 FAIL currentLocalDescription is surfaced at the right time assert_equals: currentLocalDescription is still null while promise pending expected null but got object "[object RTCSessionDescription]" 5 FAIL currentRemoteDescription is surfaced at the right time assert_equals: currentRemoteDescription is still null while promise pending expected null but got object "[object RTCSessionDescription]" 2 PASS pendingLocalDescription is surfaced at the right time 3 PASS pendingRemoteDescription is surfaced at the right time 4 PASS currentLocalDescription is surfaced at the right time 5 PASS currentRemoteDescription is surfaced at the right time 6 6 -
trunk/LayoutTests/imported/w3c/web-platform-tests/webrtc/RTCPeerConnection-setLocalDescription-rollback-expected.txt
r281985 r282217 4 4 PASS setLocalDescription(rollback) after setting answer description should reject with InvalidStateError 5 5 PASS setLocalDescription(rollback) should ignore invalid sdp content and succeed 6 FAIL setLocalDescription(rollback) should update internal state with a queued tassk, in the right order assert_ not_equals: pendingLocalDescription should not be set synchronously after a call to sLD got disallowed value null6 FAIL setLocalDescription(rollback) should update internal state with a queued tassk, in the right order assert_equals: pendingLocalDescription should be updated before the signalingstatechange event expected null but got object "[object RTCSessionDescription]" 7 7 -
trunk/LayoutTests/webrtc/datachannel/mdns-ice-candidates.html
r269236 r282217 161 161 const channel2 = pc.createDataChannel('sendDataChannel2'); 162 162 const offer2 = await pc.createOffer(); 163 const description = pc.localDescription;164 163 165 164 // Make sure we can apply the filtered description. 166 await pc.setLocalDescription(description); 165 await pc.setLocalDescription(pc.localDescription); 166 167 // Reapply description which should have candidates. 168 await pc.setLocalDescription(offer2); 169 const description = pc.localDescription; 167 170 168 171 const lines = description.sdp.split('\r\n').filter(line => { -
trunk/Source/WebCore/ChangeLog
r282211 r282217 1 2021-09-09 Youenn Fablet <youenn@apple.com> 2 3 Update RTCPeerConnection descriptions as per specification 4 https://bugs.webkit.org/show_bug.cgi?id=229963 5 6 Reviewed by Eric Carlson. 7 8 A peer connection has two sets of descriptions: main thread descriptions which are exposed to JS and signaling thread descriptions 9 which are used/modified internally by the backend. 10 WebRTC spec describes when signaling thread descriptions should be used to set main thread descriptions. 11 This should be done at the end of setting remote/local descriptions, as well as when adding or surfacing an ICE candidate. 12 We make sure to grab signaling thread descriptions at those moments, then hop to main thread to set the main thread descriptions. 13 14 In case of closed connection, we stop early as we do not need to surface new descriptions (as well as resolve promises/fire events). 15 16 Covered by rebased tests. 17 18 * Modules/mediastream/PeerConnectionBackend.cpp: 19 (WebCore::PeerConnectionBackend::setLocalDescriptionSucceeded): 20 (WebCore::PeerConnectionBackend::setRemoteDescriptionSucceeded): 21 (WebCore::PeerConnectionBackend::addIceCandidate): 22 (WebCore::PeerConnectionBackend::newICECandidate): 23 * Modules/mediastream/PeerConnectionBackend.h: 24 * Modules/mediastream/RTCPeerConnection.cpp: 25 (WebCore::updateDescription): 26 (WebCore::RTCPeerConnection::updateDescriptions): 27 * Modules/mediastream/RTCPeerConnection.h: 28 * Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.cpp: 29 (WebCore::fromSessionDescriptionType): 30 (WebCore::descriptionsFromPeerConnection): 31 (WebCore::LibWebRTCMediaEndpoint::addIceCandidate): 32 (WebCore::LibWebRTCMediaEndpoint::OnIceCandidate): 33 (WebCore::LibWebRTCMediaEndpoint::setLocalSessionDescriptionSucceeded): 34 (WebCore::LibWebRTCMediaEndpoint::setRemoteSessionDescriptionSucceeded): 35 * Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.h: 36 * Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.cpp: 37 (WebCore::LibWebRTCPeerConnectionBackend::doAddIceCandidate): 38 * Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.h: 39 1 40 2021-09-09 Antti Koivisto <antti@apple.com> 2 41 -
trunk/Source/WebCore/Modules/mediastream/PeerConnectionBackend.cpp
r282197 r282217 176 176 } 177 177 178 void PeerConnectionBackend::setLocalDescriptionSucceeded(std:: unique_ptr<RTCSctpTransportBackend>&& sctpBackend)178 void PeerConnectionBackend::setLocalDescriptionSucceeded(std::optional<DescriptionStates>&& descriptionStates, std::unique_ptr<RTCSctpTransportBackend>&& sctpBackend) 179 179 { 180 180 ASSERT(isMainThread()); … … 182 182 183 183 ASSERT(m_setDescriptionPromise); 184 m_peerConnection.doTask([this, promise = WTFMove(m_setDescriptionPromise), sctpBackend = WTFMove(sctpBackend)]() mutable { 185 if (m_peerConnection.isClosed()) 186 return; 187 184 m_peerConnection.doTask([this, promise = WTFMove(m_setDescriptionPromise), descriptionStates = WTFMove(descriptionStates), sctpBackend = WTFMove(sctpBackend)]() mutable { 185 if (m_peerConnection.isClosed()) 186 return; 187 188 if (descriptionStates) 189 m_peerConnection.updateDescriptions(WTFMove(*descriptionStates)); 188 190 m_peerConnection.updateTransceiversAfterSuccessfulLocalDescription(); 189 191 m_peerConnection.updateSctpBackend(WTFMove(sctpBackend)); … … 214 216 } 215 217 216 void PeerConnectionBackend::setRemoteDescriptionSucceeded(std:: unique_ptr<RTCSctpTransportBackend>&& sctpBackend)218 void PeerConnectionBackend::setRemoteDescriptionSucceeded(std::optional<DescriptionStates>&& descriptionStates, std::unique_ptr<RTCSctpTransportBackend>&& sctpBackend) 217 219 { 218 220 ASSERT(isMainThread()); … … 235 237 } 236 238 237 m_peerConnection.doTask([this, promise = WTFMove(promise), sctpBackend = WTFMove(sctpBackend)]() mutable { 238 if (m_peerConnection.isClosed()) 239 return; 240 239 m_peerConnection.doTask([this, promise = WTFMove(promise), descriptionStates = WTFMove(descriptionStates), sctpBackend = WTFMove(sctpBackend)]() mutable { 240 if (m_peerConnection.isClosed()) 241 return; 242 243 if (descriptionStates) 244 m_peerConnection.updateDescriptions(WTFMove(*descriptionStates)); 241 245 m_peerConnection.updateTransceiversAfterSuccessfulRemoteDescription(); 242 246 m_peerConnection.updateSctpBackend(WTFMove(sctpBackend)); … … 315 319 if (!weakThis || weakThis->m_peerConnection.isClosed()) 316 320 return; 317 RELEASE_LOG_ERROR(WebRTC, "Adding ice candidate finished, success=%d", result.hasException()); 318 promise.settle(WTFMove(result)); 321 322 if (result.hasException()) { 323 RELEASE_LOG_ERROR(WebRTC, "Adding ice candidate failed %d", result.exception().code()); 324 promise.reject(result.releaseException()); 325 return; 326 } 327 328 if (auto descriptions = result.releaseReturnValue()) 329 weakThis->m_peerConnection.updateDescriptions(WTFMove(*descriptions)); 330 promise.resolve(); 319 331 }); 320 332 } … … 350 362 } 351 363 352 void PeerConnectionBackend::newICECandidate(String&& sdp, String&& mid, unsigned short sdpMLineIndex, String&& serverURL) 353 { 354 m_peerConnection.doTask([logSiteIdentifier = LOGIDENTIFIER, this, sdp = WTFMove(sdp), mid = WTFMove(mid), sdpMLineIndex, serverURL = WTFMove(serverURL)]() mutable { 355 if (m_peerConnection.isClosed()) 356 return; 364 void PeerConnectionBackend::newICECandidate(String&& sdp, String&& mid, unsigned short sdpMLineIndex, String&& serverURL, std::optional<DescriptionStates>&& descriptions) 365 { 366 m_peerConnection.doTask([logSiteIdentifier = LOGIDENTIFIER, this, sdp = WTFMove(sdp), mid = WTFMove(mid), sdpMLineIndex, serverURL = WTFMove(serverURL), descriptions = WTFMove(descriptions)]() mutable { 367 if (m_peerConnection.isClosed()) 368 return; 369 370 if (descriptions) 371 m_peerConnection.updateDescriptions(WTFMove(*descriptions)); 357 372 358 373 UNUSED_PARAM(logSiteIdentifier); -
trunk/Source/WebCore/Modules/mediastream/PeerConnectionBackend.h
r282197 r282217 105 105 virtual void close() = 0; 106 106 107 virtual RefPtr<RTCSessionDescription> localDescription() const = 0;108 virtual RefPtr<RTCSessionDescription> currentLocalDescription() const = 0;109 virtual RefPtr<RTCSessionDescription> pendingLocalDescription() const = 0;110 111 virtual RefPtr<RTCSessionDescription> remoteDescription() const = 0;112 virtual RefPtr<RTCSessionDescription> currentRemoteDescription() const = 0;113 virtual RefPtr<RTCSessionDescription> pendingRemoteDescription() const = 0;114 115 107 virtual void restartIce() = 0; 116 108 virtual bool setConfiguration(MediaEndpointConfiguration&&) = 0; … … 131 123 virtual void emulatePlatformEvent(const String& action) = 0; 132 124 133 void newICECandidate(String&& sdp, String&& mid, unsigned short sdpMLineIndex, String&& serverURL); 125 struct DescriptionStates { 126 std::optional<RTCSdpType> currentLocalDescriptionSdpType; 127 String currentLocalDescriptionSdp; 128 std::optional<RTCSdpType> pendingLocalDescriptionSdpType; 129 String pendingLocalDescriptionSdp; 130 std::optional<RTCSdpType> currentRemoteDescriptionSdpType; 131 String currentRemoteDescriptionSdp; 132 std::optional<RTCSdpType> pendingRemoteDescriptionSdpType; 133 String pendingRemoteDescriptionSdp; 134 }; 135 136 void newICECandidate(String&& sdp, String&& mid, unsigned short sdpMLineIndex, String&& serverURL, std::optional<DescriptionStates>&&); 134 137 virtual void disableICECandidateFiltering(); 135 138 void enableICECandidateFiltering(); … … 188 191 bool shouldFilterICECandidates() const { return m_shouldFilterICECandidates; }; 189 192 193 using AddIceCandidateCallbackFunction = void(ExceptionOr<std::optional<PeerConnectionBackend::DescriptionStates>>&&); 194 using AddIceCandidateCallback = Function<AddIceCandidateCallbackFunction>; 195 190 196 protected: 191 197 void fireICECandidateEvent(RefPtr<RTCIceCandidate>&&, String&& url); … … 200 206 void createAnswerFailed(Exception&&); 201 207 202 void setLocalDescriptionSucceeded(std:: unique_ptr<RTCSctpTransportBackend>&&);208 void setLocalDescriptionSucceeded(std::optional<DescriptionStates>&&, std::unique_ptr<RTCSctpTransportBackend>&&); 203 209 void setLocalDescriptionFailed(Exception&&); 204 210 205 void setRemoteDescriptionSucceeded(std:: unique_ptr<RTCSctpTransportBackend>&&);211 void setRemoteDescriptionSucceeded(std::optional<DescriptionStates>&&, std::unique_ptr<RTCSctpTransportBackend>&&); 206 212 void setRemoteDescriptionFailed(Exception&&); 207 208 void addIceCandidateSucceeded();209 void addIceCandidateFailed(Exception&&);210 213 211 214 void validateSDP(const String&) const; … … 224 227 virtual void doSetLocalDescription(const RTCSessionDescription*) = 0; 225 228 virtual void doSetRemoteDescription(const RTCSessionDescription&) = 0; 226 virtual void doAddIceCandidate(RTCIceCandidate&, Function<void(ExceptionOr<void>&&)>&&) = 0;229 virtual void doAddIceCandidate(RTCIceCandidate&, AddIceCandidateCallback&&) = 0; 227 230 virtual void endOfIceCandidates(DOMPromiseDeferred<void>&&); 228 231 virtual void doStop() = 0; -
trunk/Source/WebCore/Modules/mediastream/RTCPeerConnection.cpp
r282197 r282217 248 248 } 249 249 250 RefPtr<RTCSessionDescription> RTCPeerConnection::localDescription() const251 {252 return m_backend->localDescription();253 }254 255 RefPtr<RTCSessionDescription> RTCPeerConnection::currentLocalDescription() const256 {257 return m_backend->currentLocalDescription();258 }259 260 RefPtr<RTCSessionDescription> RTCPeerConnection::pendingLocalDescription() const261 {262 return m_backend->pendingLocalDescription();263 }264 265 250 void RTCPeerConnection::setRemoteDescription(Description&& remoteDescription, Ref<DeferredPromise>&& promise) 266 251 { … … 285 270 m_backend->setRemoteDescription(*description, WTFMove(promise)); 286 271 }); 287 }288 289 RefPtr<RTCSessionDescription> RTCPeerConnection::remoteDescription() const290 {291 return m_backend->remoteDescription();292 }293 294 RefPtr<RTCSessionDescription> RTCPeerConnection::currentRemoteDescription() const295 {296 return m_backend->currentRemoteDescription();297 }298 299 RefPtr<RTCSessionDescription> RTCPeerConnection::pendingRemoteDescription() const300 {301 return m_backend->pendingRemoteDescription();302 272 } 303 273 … … 935 905 } 936 906 907 static void updateDescription(RefPtr<RTCSessionDescription>& description, std::optional<RTCSdpType> type, String&& sdp) 908 { 909 if (description && type && description->sdp() == sdp && description->type() == *type) 910 return; 911 if (!type || sdp.isEmpty()) { 912 description = nullptr; 913 return; 914 } 915 description = RTCSessionDescription::create(*type, WTFMove(sdp)); 916 } 917 918 void RTCPeerConnection::updateDescriptions(PeerConnectionBackend::DescriptionStates&& states) 919 { 920 updateDescription(m_currentLocalDescription, states.currentLocalDescriptionSdpType, WTFMove(states.currentLocalDescriptionSdp)); 921 updateDescription(m_pendingLocalDescription, states.pendingLocalDescriptionSdpType, WTFMove(states.pendingLocalDescriptionSdp)); 922 updateDescription(m_currentRemoteDescription, states.currentRemoteDescriptionSdpType, WTFMove(states.currentRemoteDescriptionSdp)); 923 updateDescription(m_pendingRemoteDescription, states.pendingRemoteDescriptionSdpType, WTFMove(states.pendingRemoteDescriptionSdp)); 924 } 925 937 926 void RTCPeerConnection::updateTransceiverTransports() 938 927 { -
trunk/Source/WebCore/Modules/mediastream/RTCPeerConnection.h
r282197 r282217 113 113 using Description = Variant<RTCSessionDescriptionInit, RefPtr<RTCSessionDescription>>; 114 114 void setLocalDescription(std::optional<Description>&&, Ref<DeferredPromise>&&); 115 RefPtr<RTCSessionDescription> localDescription() const ;116 RefPtr<RTCSessionDescription> currentLocalDescription() const ;117 RefPtr<RTCSessionDescription> pendingLocalDescription() const ;115 RefPtr<RTCSessionDescription> localDescription() const { return m_pendingLocalDescription ? m_pendingLocalDescription.get() : m_currentLocalDescription.get(); } 116 RefPtr<RTCSessionDescription> currentLocalDescription() const { return m_currentLocalDescription.get(); } 117 RefPtr<RTCSessionDescription> pendingLocalDescription() const { return m_pendingLocalDescription.get(); } 118 118 119 119 void setRemoteDescription(Description&&, Ref<DeferredPromise>&&); 120 R efPtr<RTCSessionDescription> remoteDescription() const;121 R efPtr<RTCSessionDescription> currentRemoteDescription() const;122 R efPtr<RTCSessionDescription> pendingRemoteDescription() const;120 RTCSessionDescription* remoteDescription() const { return m_pendingRemoteDescription ? m_pendingRemoteDescription.get() : m_currentRemoteDescription.get(); } 121 RTCSessionDescription* currentRemoteDescription() const { return m_currentRemoteDescription.get(); } 122 RTCSessionDescription* pendingRemoteDescription() const { return m_pendingRemoteDescription.get(); } 123 123 124 124 using Candidate = std::optional<Variant<RTCIceCandidateInit, RefPtr<RTCIceCandidate>>>; … … 188 188 void doTask(Function<void()>&&); 189 189 190 void updateDescriptions(PeerConnectionBackend::DescriptionStates&&); 190 191 void updateTransceiversAfterSuccessfulLocalDescription(); 191 192 void updateTransceiversAfterSuccessfulRemoteDescription(); … … 272 273 Vector<Ref<RTCIceTransport>> m_iceTransports; 273 274 RefPtr<RTCSctpTransport> m_sctpTransport; 275 276 RefPtr<RTCSessionDescription> m_currentLocalDescription; 277 RefPtr<RTCSessionDescription> m_pendingLocalDescription; 278 RefPtr<RTCSessionDescription> m_currentRemoteDescription; 279 RefPtr<RTCSessionDescription> m_pendingRemoteDescription; 274 280 }; 275 281 -
trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.cpp
r282197 r282217 61 61 #include <webrtc/system_wrappers/include/field_trial.h> 62 62 #include <wtf/MainThread.h> 63 #include <wtf/SharedTask.h> 63 64 64 65 namespace WebCore { … … 142 143 ASSERT_NOT_REACHED(); 143 144 return ""; 144 }145 146 static inline RTCSdpType fromSessionDescriptionType(const webrtc::SessionDescriptionInterface& description)147 {148 auto type = description.type();149 if (type == webrtc::SessionDescriptionInterface::kOffer)150 return RTCSdpType::Offer;151 if (type == webrtc::SessionDescriptionInterface::kAnswer)152 return RTCSdpType::Answer;153 ASSERT(type == webrtc::SessionDescriptionInterface::kPrAnswer);154 return RTCSdpType::Pranswer;155 }156 157 static inline RefPtr<RTCSessionDescription> fromSessionDescription(const webrtc::SessionDescriptionInterface* description)158 {159 if (!description)160 return nullptr;161 162 std::string sdp;163 description->ToString(&sdp);164 165 return RTCSessionDescription::create(fromSessionDescriptionType(*description), fromStdString(sdp));166 }167 168 // FIXME: We might want to create a new object only if the session actually changed for all description getters.169 RefPtr<RTCSessionDescription> LibWebRTCMediaEndpoint::currentLocalDescription() const170 {171 return m_backend ? fromSessionDescription(m_backend->current_local_description()) : nullptr;172 }173 174 RefPtr<RTCSessionDescription> LibWebRTCMediaEndpoint::currentRemoteDescription() const175 {176 return m_backend ? fromSessionDescription(m_backend->current_remote_description()) : nullptr;177 }178 179 RefPtr<RTCSessionDescription> LibWebRTCMediaEndpoint::pendingLocalDescription() const180 {181 return m_backend ? fromSessionDescription(m_backend->pending_local_description()) : nullptr;182 }183 184 RefPtr<RTCSessionDescription> LibWebRTCMediaEndpoint::pendingRemoteDescription() const185 {186 return m_backend ? fromSessionDescription(m_backend->pending_remote_description()) : nullptr;187 }188 189 RefPtr<RTCSessionDescription> LibWebRTCMediaEndpoint::localDescription() const190 {191 return m_backend ? fromSessionDescription(m_backend->local_description()) : nullptr;192 }193 194 RefPtr<RTCSessionDescription> LibWebRTCMediaEndpoint::remoteDescription() const195 {196 return m_backend ? fromSessionDescription(m_backend->remote_description()) : nullptr;197 145 } 198 146 … … 621 569 } 622 570 623 void LibWebRTCMediaEndpoint::addIceCandidate(std::unique_ptr<webrtc::IceCandidateInterface>&& candidate, std::function<void(webrtc::RTCError)>&& callback) 624 { 625 m_backend->AddIceCandidate(WTFMove(candidate), WTFMove(callback)); 571 static inline RTCSdpType fromSessionDescriptionType(const webrtc::SessionDescriptionInterface& description) 572 { 573 auto type = description.type(); 574 if (type == webrtc::SessionDescriptionInterface::kOffer) 575 return RTCSdpType::Offer; 576 if (type == webrtc::SessionDescriptionInterface::kAnswer) 577 return RTCSdpType::Answer; 578 ASSERT(type == webrtc::SessionDescriptionInterface::kPrAnswer); 579 return RTCSdpType::Pranswer; 580 } 581 582 static std::optional<PeerConnectionBackend::DescriptionStates> descriptionsFromPeerConnection(webrtc::PeerConnectionInterface* connection) 583 { 584 if (!connection) 585 return { }; 586 587 std::optional<RTCSdpType> currentLocalDescriptionSdpType, pendingLocalDescriptionSdpType, currentRemoteDescriptionSdpType, pendingRemoteDescriptionSdpType; 588 std::string currentLocalDescriptionSdp, pendingLocalDescriptionSdp, currentRemoteDescriptionSdp, pendingRemoteDescriptionSdp; 589 if (auto* description = connection->current_local_description()) { 590 currentLocalDescriptionSdpType = fromSessionDescriptionType(*description); 591 description->ToString(¤tLocalDescriptionSdp); 592 } 593 if (auto* description = connection->pending_local_description()) { 594 pendingLocalDescriptionSdpType = fromSessionDescriptionType(*description); 595 description->ToString(&pendingLocalDescriptionSdp); 596 } 597 if (auto* description = connection->current_remote_description()) { 598 currentRemoteDescriptionSdpType = fromSessionDescriptionType(*description); 599 description->ToString(¤tRemoteDescriptionSdp); 600 } 601 if (auto* description = connection->pending_remote_description()) { 602 pendingRemoteDescriptionSdpType = fromSessionDescriptionType(*description); 603 description->ToString(&pendingRemoteDescriptionSdp); 604 } 605 606 return PeerConnectionBackend::DescriptionStates { 607 currentLocalDescriptionSdpType, fromStdString(currentLocalDescriptionSdp), 608 pendingLocalDescriptionSdpType, fromStdString(pendingLocalDescriptionSdp), 609 currentRemoteDescriptionSdpType, fromStdString(currentRemoteDescriptionSdp), 610 pendingRemoteDescriptionSdpType, fromStdString(pendingRemoteDescriptionSdp) 611 }; 612 } 613 614 void LibWebRTCMediaEndpoint::addIceCandidate(std::unique_ptr<webrtc::IceCandidateInterface>&& candidate, PeerConnectionBackend::AddIceCandidateCallback&& callback) 615 { 616 m_backend->AddIceCandidate(WTFMove(candidate), [task = createSharedTask<PeerConnectionBackend::AddIceCandidateCallbackFunction>(WTFMove(callback)), backend = m_backend](auto&& error) mutable { 617 callOnMainThread([task = WTFMove(task), descriptions = descriptionsFromPeerConnection(backend.get()), error = WTFMove(error)]() mutable { 618 if (!error.ok()) { 619 task->run(toException(error)); 620 return; 621 } 622 task->run(WTFMove(descriptions)); 623 }); 624 }); 626 625 } 627 626 … … 635 634 auto sdpMLineIndex = safeCast<unsigned short>(rtcCandidate->sdp_mline_index()); 636 635 637 callOnMainThread([protectedThis = makeRef(*this), mid = fromStdString(rtcCandidate->sdp_mid()), sdp = fromStdString(sdp), sdpMLineIndex, url = fromStdString(rtcCandidate->server_url())]() mutable {638 if (protectedThis->isStopped()) 639 return; 640 protectedThis->m_peerConnectionBackend.newICECandidate(WTFMove(sdp), WTFMove(mid), sdpMLineIndex, WTFMove(url) );636 callOnMainThread([protectedThis = makeRef(*this), descriptions = descriptionsFromPeerConnection(m_backend.get()), mid = fromStdString(rtcCandidate->sdp_mid()), sdp = fromStdString(sdp), sdpMLineIndex, url = fromStdString(rtcCandidate->server_url())]() mutable { 637 if (protectedThis->isStopped()) 638 return; 639 protectedThis->m_peerConnectionBackend.newICECandidate(WTFMove(sdp), WTFMove(mid), sdpMLineIndex, WTFMove(url), WTFMove(descriptions)); 641 640 }); 642 641 } … … 700 699 void LibWebRTCMediaEndpoint::setLocalSessionDescriptionSucceeded() 701 700 { 702 callOnMainThread([protectedThis = makeRef(*this), sctpState = SctpTransportState(m_backend->GetSctpTransport())]() mutable {703 if (protectedThis->isStopped()) 704 return; 705 protectedThis->m_peerConnectionBackend.setLocalDescriptionSucceeded( sctpState.createBackend());701 callOnMainThread([protectedThis = makeRef(*this), descriptions = descriptionsFromPeerConnection(m_backend.get()), sctpState = SctpTransportState(m_backend->GetSctpTransport())]() mutable { 702 if (protectedThis->isStopped()) 703 return; 704 protectedThis->m_peerConnectionBackend.setLocalDescriptionSucceeded(WTFMove(descriptions), sctpState.createBackend()); 706 705 }); 707 706 } … … 718 717 void LibWebRTCMediaEndpoint::setRemoteSessionDescriptionSucceeded() 719 718 { 720 callOnMainThread([protectedThis = makeRef(*this), sctpState = SctpTransportState(m_backend->GetSctpTransport())]() mutable {721 if (protectedThis->isStopped()) 722 return; 723 protectedThis->m_peerConnectionBackend.setRemoteDescriptionSucceeded( sctpState.createBackend());719 callOnMainThread([protectedThis = makeRef(*this), descriptions = descriptionsFromPeerConnection(m_backend.get()), sctpState = SctpTransportState(m_backend->GetSctpTransport())]() mutable { 720 if (protectedThis->isStopped()) 721 return; 722 protectedThis->m_peerConnectionBackend.setRemoteDescriptionSucceeded(WTFMove(descriptions), sctpState.createBackend()); 724 723 }); 725 724 } -
trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.h
r281981 r282217 90 90 void getStats(webrtc::RtpSenderInterface&, Ref<DeferredPromise>&&); 91 91 std::unique_ptr<RTCDataChannelHandler> createDataChannel(const String&, const RTCDataChannelInit&); 92 void addIceCandidate(std::unique_ptr<webrtc::IceCandidateInterface>&&, std::function<void(webrtc::RTCError)>&&);92 void addIceCandidate(std::unique_ptr<webrtc::IceCandidateInterface>&&, PeerConnectionBackend::AddIceCandidateCallback&&); 93 93 94 94 void close(); 95 95 void stop(); 96 96 bool isStopped() const { return !m_backend; } 97 98 RefPtr<RTCSessionDescription> localDescription() const;99 RefPtr<RTCSessionDescription> remoteDescription() const;100 RefPtr<RTCSessionDescription> currentLocalDescription() const;101 RefPtr<RTCSessionDescription> currentRemoteDescription() const;102 RefPtr<RTCSessionDescription> pendingLocalDescription() const;103 RefPtr<RTCSessionDescription> pendingRemoteDescription() const;104 97 105 98 bool addTrack(LibWebRTCRtpSenderBackend&, MediaStreamTrack&, const Vector<String>&); -
trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.cpp
r282054 r282217 48 48 #include "RealtimeOutgoingVideoSource.h" 49 49 #include "Settings.h" 50 #include <wtf/SharedTask.h>51 50 52 51 namespace WebCore { … … 271 270 } 272 271 273 void LibWebRTCPeerConnectionBackend::doAddIceCandidate(RTCIceCandidate& candidate, Function<void(ExceptionOr<void>&&)>&& callback)272 void LibWebRTCPeerConnectionBackend::doAddIceCandidate(RTCIceCandidate& candidate, AddIceCandidateCallback&& callback) 274 273 { 275 274 webrtc::SdpParseError error; … … 282 281 } 283 282 284 m_endpoint->addIceCandidate(WTFMove(rtcCandidate), [task = createSharedTask<void(ExceptionOr<void>&&)>(WTFMove(callback))](auto&& error) mutable { 285 callOnMainThread([task = WTFMove(task), error = WTFMove(error)] { 286 if (!error.ok()) { 287 task->run(toException(error)); 288 return; 289 } 290 task->run({ }); 291 }); 292 }); 283 m_endpoint->addIceCandidate(WTFMove(rtcCandidate), WTFMove(callback)); 293 284 } 294 285 … … 312 303 } 313 304 314 RefPtr<RTCSessionDescription> LibWebRTCPeerConnectionBackend::currentLocalDescription() const315 {316 auto description = m_endpoint->currentLocalDescription();317 if (description)318 validateSDP(description->sdp());319 return description;320 }321 322 RefPtr<RTCSessionDescription> LibWebRTCPeerConnectionBackend::currentRemoteDescription() const323 {324 return m_endpoint->currentRemoteDescription();325 }326 327 RefPtr<RTCSessionDescription> LibWebRTCPeerConnectionBackend::pendingLocalDescription() const328 {329 auto description = m_endpoint->pendingLocalDescription();330 if (description)331 validateSDP(description->sdp());332 return description;333 }334 335 RefPtr<RTCSessionDescription> LibWebRTCPeerConnectionBackend::pendingRemoteDescription() const336 {337 return m_endpoint->pendingRemoteDescription();338 }339 340 RefPtr<RTCSessionDescription> LibWebRTCPeerConnectionBackend::localDescription() const341 {342 auto description = m_endpoint->localDescription();343 if (description)344 validateSDP(description->sdp());345 return description;346 }347 348 RefPtr<RTCSessionDescription> LibWebRTCPeerConnectionBackend::remoteDescription() const349 {350 return m_endpoint->remoteDescription();351 }352 353 305 static inline RefPtr<RTCRtpSender> findExistingSender(const Vector<RefPtr<RTCRtpTransceiver>>& transceivers, LibWebRTCRtpSenderBackend& senderBackend) 354 306 { -
trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.h
r281981 r282217 63 63 void doSetLocalDescription(const RTCSessionDescription*) final; 64 64 void doSetRemoteDescription(const RTCSessionDescription&) final; 65 void doAddIceCandidate(RTCIceCandidate&, Function<void(ExceptionOr<void>&&)>&&) final;65 void doAddIceCandidate(RTCIceCandidate&, AddIceCandidateCallback&&) final; 66 66 void doStop() final; 67 67 std::unique_ptr<RTCDataChannelHandler> createDataChannelHandler(const String&, const RTCDataChannelInit&) final; … … 71 71 void getStats(RTCRtpSender&, Ref<DeferredPromise>&&) final; 72 72 void getStats(RTCRtpReceiver&, Ref<DeferredPromise>&&) final; 73 74 RefPtr<RTCSessionDescription> localDescription() const final;75 RefPtr<RTCSessionDescription> currentLocalDescription() const final;76 RefPtr<RTCSessionDescription> pendingLocalDescription() const final;77 78 RefPtr<RTCSessionDescription> remoteDescription() const final;79 RefPtr<RTCSessionDescription> currentRemoteDescription() const final;80 RefPtr<RTCSessionDescription> pendingRemoteDescription() const final;81 73 82 74 std::optional<bool> canTrickleIceCandidates() const final;
Note: See TracChangeset
for help on using the changeset viewer.