From 553d0aa7eb1ca1c5fafcd78008fca081ce054469 Mon Sep 17 00:00:00 2001 From: "youenn@apple.com" Date: Wed, 14 Nov 2018 17:53:21 +0000 Subject: [PATCH] Convert libwebrtc error types to DOM exceptions https://bugs.webkit.org/show_bug.cgi?id=191590 Reviewed by Alex Christensen. LayoutTests/imported/w3c: * web-platform-tests/webrtc/RTCConfiguration-rtcpMuxPolicy-expected.txt: * web-platform-tests/webrtc/RTCPeerConnection-setLocalDescription-answer-expected.txt: * web-platform-tests/webrtc/RTCRtpTransceiver.https-expected.txt: Source/ThirdParty/libwebrtc: * Configurations/libwebrtc.iOS.exp: * Configurations/libwebrtc.iOSsim.exp: * Configurations/libwebrtc.mac.exp: Source/WebCore: Make use of overloaded callback method that provides an error type. This type is then used to create a DOM exception with the correct type. Covered by existing tests. * Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.cpp: (WebCore::LibWebRTCMediaEndpoint::doSetRemoteDescription): (WebCore::LibWebRTCMediaEndpoint::createSessionDescriptionFailed): (WebCore::LibWebRTCMediaEndpoint::setLocalSessionDescriptionFailed): (WebCore::LibWebRTCMediaEndpoint::setRemoteSessionDescriptionFailed): * Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.h: * Modules/mediastream/libwebrtc/LibWebRTCObservers.h: (WebCore::toExceptionCode): git-svn-id: https://svn.webkit.org/repository/webkit/trunk@238182 268f45cc-cd09-0410-ab3c-d52691b4dbfc --- LayoutTests/imported/w3c/ChangeLog | 11 +++++++++ .../RTCConfiguration-rtcpMuxPolicy-expected.txt | 4 ++-- ...nection-setLocalDescription-answer-expected.txt | 2 +- .../webrtc/RTCRtpTransceiver.https-expected.txt | 2 +- Source/ThirdParty/libwebrtc/ChangeLog | 11 +++++++++ .../libwebrtc/Configurations/libwebrtc.iOS.exp | 4 ++-- .../libwebrtc/Configurations/libwebrtc.iOSsim.exp | 4 ++-- .../libwebrtc/Configurations/libwebrtc.mac.exp | 4 ++-- Source/WebCore/ChangeLog | 20 ++++++++++++++++ .../libwebrtc/LibWebRTCMediaEndpoint.cpp | 22 +++++++++--------- .../mediastream/libwebrtc/LibWebRTCMediaEndpoint.h | 6 ++--- .../mediastream/libwebrtc/LibWebRTCObservers.h | 27 +++++++++++++++++++--- 12 files changed, 90 insertions(+), 27 deletions(-) diff --git a/LayoutTests/imported/w3c/ChangeLog b/LayoutTests/imported/w3c/ChangeLog index e4b008a..af5ee23 100644 --- a/LayoutTests/imported/w3c/ChangeLog +++ b/LayoutTests/imported/w3c/ChangeLog @@ -1,5 +1,16 @@ 2018-11-14 Youenn Fablet + Convert libwebrtc error types to DOM exceptions + https://bugs.webkit.org/show_bug.cgi?id=191590 + + Reviewed by Alex Christensen. + + * web-platform-tests/webrtc/RTCConfiguration-rtcpMuxPolicy-expected.txt: + * web-platform-tests/webrtc/RTCPeerConnection-setLocalDescription-answer-expected.txt: + * web-platform-tests/webrtc/RTCRtpTransceiver.https-expected.txt: + +2018-11-14 Youenn Fablet + Calling removeTrack on different RTCPeerConnection should throw InvalidAccessError https://bugs.webkit.org/show_bug.cgi?id=191603 diff --git a/LayoutTests/imported/w3c/web-platform-tests/webrtc/RTCConfiguration-rtcpMuxPolicy-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/webrtc/RTCConfiguration-rtcpMuxPolicy-expected.txt index 6dd6362..0e78fde 100644 --- a/LayoutTests/imported/w3c/web-platform-tests/webrtc/RTCConfiguration-rtcpMuxPolicy-expected.txt +++ b/LayoutTests/imported/w3c/web-platform-tests/webrtc/RTCConfiguration-rtcpMuxPolicy-expected.txt @@ -10,6 +10,6 @@ PASS setConfiguration(config) - with { rtcpMuxPolicy: 'invalid' } should throw T PASS setConfiguration({ rtcpMuxPolicy: 'negotiate' }) with initial rtcpMuxPolicy require should throw InvalidModificationError PASS setConfiguration({ rtcpMuxPolicy: 'require' }) with initial rtcpMuxPolicy negotiate should throw InvalidModificationError PASS setConfiguration({}) with initial rtcpMuxPolicy negotiate should throw InvalidModificationError -FAIL setRemoteDescription throws InvalidAccessError when called with an offer without rtcp-mux and rtcpMuxPolicy is set to require assert_throws: function "function () { throw e }" threw object "OperationError: Failed to set remote offer sdp: The m= section:audio1 is invalid. RTCP-MUX is not enabled when it is required." that is not a DOMException InvalidAccessError: property "code" is equal to 0, expected 15 -FAIL setRemoteDescription throws InvalidAccessError when called with an answer without rtcp-mux and rtcpMuxPolicy is set to require assert_throws: function "function () { throw e }" threw object "OperationError: Failed to set remote answer sdp: The order of m-lines in answer doesn't match order in offer. Rejecting answer." that is not a DOMException InvalidAccessError: property "code" is equal to 0, expected 15 +PASS setRemoteDescription throws InvalidAccessError when called with an offer without rtcp-mux and rtcpMuxPolicy is set to require +PASS setRemoteDescription throws InvalidAccessError when called with an answer without rtcp-mux and rtcpMuxPolicy is set to require diff --git a/LayoutTests/imported/w3c/web-platform-tests/webrtc/RTCPeerConnection-setLocalDescription-answer-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/webrtc/RTCPeerConnection-setLocalDescription-answer-expected.txt index 1ba1bee..8a04b5d 100644 --- a/LayoutTests/imported/w3c/web-platform-tests/webrtc/RTCPeerConnection-setLocalDescription-answer-expected.txt +++ b/LayoutTests/imported/w3c/web-platform-tests/webrtc/RTCPeerConnection-setLocalDescription-answer-expected.txt @@ -1,7 +1,7 @@ PASS setLocalDescription() with valid answer should succeed FAIL setLocalDescription() with type answer and null sdp should use lastAnswer generated from createAnswer promise_test: Unhandled rejection with value: object "OperationError: Expect line: v=" -FAIL setLocalDescription() with answer not created by own createAnswer() should reject with InvalidModificationError assert_throws: function "function () { throw e }" threw object "OperationError: Failed to set local answer sdp: Failed to apply the description for 0: Local fingerprint does not match identity. Expected: sha-256 12:E5:12:50:9C:09:A8:71:EF:5F:AF:F6:4C:08:7A:BF:0C:44:2D:A8:96:5C:34:3A:64:12:70:D2:51:60:2E:79 Got: sha-256 A5:C7:8C:82:7E:30:00:63:86:E5:AA:93:65:C2:60:83:49:01:E0:35:0F:91:F2:7A:C3:7B:AF:8F:52:3E:12:87" that is not a DOMException InvalidModificationError: property "code" is equal to 0, expected 13 +FAIL setLocalDescription() with answer not created by own createAnswer() should reject with InvalidModificationError assert_throws: function "function () { throw e }" threw object "OperationError: Failed to set local answer sdp: Failed to apply the description for 0: Local fingerprint does not match identity. Expected: sha-256 FD:12:D4:3F:20:8C:37:A8:9A:C0:CB:03:84:DF:97:20:40:24:C8:DB:B8:88:6C:8D:99:B6:25:48:5C:29:1E:0B Got: sha-256 CC:EB:A3:0C:D3:6C:7C:66:8B:E2:C8:A7:7B:00:92:56:A6:C8:C9:3E:D8:B9:CB:D0:5A:C9:7F:AE:10:4E:C7:CA" that is not a DOMException InvalidModificationError: property "code" is equal to 0, expected 13 PASS Calling setLocalDescription(answer) from stable state should reject with InvalidStateError PASS Calling setLocalDescription(answer) from have-local-offer state should reject with InvalidStateError diff --git a/LayoutTests/imported/w3c/web-platform-tests/webrtc/RTCRtpTransceiver.https-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/webrtc/RTCRtpTransceiver.https-expected.txt index bd6e47d..e8df9b1 100644 --- a/LayoutTests/imported/w3c/web-platform-tests/webrtc/RTCRtpTransceiver.https-expected.txt +++ b/LayoutTests/imported/w3c/web-platform-tests/webrtc/RTCRtpTransceiver.https-expected.txt @@ -8,7 +8,7 @@ PASS checkAddTransceiverWithDirection PASS checkAddTransceiverWithSetRemoteOfferSending PASS checkAddTransceiverWithSetRemoteOfferNoSend PASS checkAddTransceiverBadKind -FAIL checkNoMidOffer promise_test: Unhandled rejection with value: object "OperationError: Failed to set remote offer sdp: The BUNDLE group contains MID:0 matching no m= section." +FAIL checkNoMidOffer promise_test: Unhandled rejection with value: object "InvalidAccessError: Failed to set remote offer sdp: The BUNDLE group contains MID:0 matching no m= section." PASS checkSetDirection PASS checkCurrentDirection PASS checkSendrecvWithNoSendTrack diff --git a/Source/ThirdParty/libwebrtc/ChangeLog b/Source/ThirdParty/libwebrtc/ChangeLog index 080c384..56d92ef 100644 --- a/Source/ThirdParty/libwebrtc/ChangeLog +++ b/Source/ThirdParty/libwebrtc/ChangeLog @@ -1,5 +1,16 @@ 2018-11-14 Youenn Fablet + Convert libwebrtc error types to DOM exceptions + https://bugs.webkit.org/show_bug.cgi?id=191590 + + Reviewed by Alex Christensen. + + * Configurations/libwebrtc.iOS.exp: + * Configurations/libwebrtc.iOSsim.exp: + * Configurations/libwebrtc.mac.exp: + +2018-11-14 Youenn Fablet + Add support for transport and peerConnection stats https://bugs.webkit.org/show_bug.cgi?id=191592 diff --git a/Source/ThirdParty/libwebrtc/Configurations/libwebrtc.iOS.exp b/Source/ThirdParty/libwebrtc/Configurations/libwebrtc.iOS.exp index 5c69b88..d95d51e 100644 --- a/Source/ThirdParty/libwebrtc/Configurations/libwebrtc.iOS.exp +++ b/Source/ThirdParty/libwebrtc/Configurations/libwebrtc.iOS.exp @@ -129,8 +129,6 @@ __ZTVN6webrtc29SetSessionDescriptionObserverE __ZNK3rtc17ThreadCheckerImpl19CalledOnValidThreadEv __ZN7cricket18BasicPortAllocatorC1EPN3rtc14NetworkManagerEPNS1_19PacketSocketFactoryEPN6webrtc14TurnCustomizerEPNS_25RelayPortFactoryInterfaceE __ZN7cricket12AudioOptionsD1Ev -__ZN6webrtc32CreateSessionDescriptionObserver9OnFailureENS_8RTCErrorE -__ZN6webrtc29SetSessionDescriptionObserver9OnFailureENS_8RTCErrorE __ZN6webrtc28RtpHeaderExtensionCapabilityD1Ev __ZN6webrtc26PeerConnectionDependenciesD1Ev __ZN3rtc24BasicPacketSocketFactory21CreateClientTcpSocketERKNS_13SocketAddressES3_RKNS_9ProxyInfoERKNSt3__112basic_stringIcNS7_11char_traitsIcEENS7_9allocatorIcEEEERKNS_22PacketSocketTcpOptionsE @@ -233,3 +231,5 @@ __ZNK3rtc14SSLCertificate8GetStatsEv __ZN3rtc14RTCCertificate7FromPEMERKNS_17RTCCertificatePEME __ZN6webrtc26PeerConnectionDependenciesC1EPNS_22PeerConnectionObserverE __ZN6webrtc30PeerConnectionFactoryInterface20CreatePeerConnectionERKNS_23PeerConnectionInterface16RTCConfigurationENSt3__110unique_ptrIN7cricket13PortAllocatorENS5_14default_deleteIS8_EEEENS6_IN3rtc32RTCCertificateGeneratorInterfaceENS9_ISD_EEEEPNS_22PeerConnectionObserverE +__ZN6webrtc29SetSessionDescriptionObserver9OnFailureERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEE +__ZN6webrtc32CreateSessionDescriptionObserver9OnFailureERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEE diff --git a/Source/ThirdParty/libwebrtc/Configurations/libwebrtc.iOSsim.exp b/Source/ThirdParty/libwebrtc/Configurations/libwebrtc.iOSsim.exp index f4587da..19d0fe6 100644 --- a/Source/ThirdParty/libwebrtc/Configurations/libwebrtc.iOSsim.exp +++ b/Source/ThirdParty/libwebrtc/Configurations/libwebrtc.iOSsim.exp @@ -129,8 +129,6 @@ __ZTVN6webrtc29SetSessionDescriptionObserverE __ZNK3rtc17ThreadCheckerImpl19CalledOnValidThreadEv __ZN7cricket18BasicPortAllocatorC1EPN3rtc14NetworkManagerEPNS1_19PacketSocketFactoryEPN6webrtc14TurnCustomizerEPNS_25RelayPortFactoryInterfaceE __ZN7cricket12AudioOptionsD1Ev -__ZN6webrtc32CreateSessionDescriptionObserver9OnFailureENS_8RTCErrorE -__ZN6webrtc29SetSessionDescriptionObserver9OnFailureENS_8RTCErrorE __ZN6webrtc28RtpHeaderExtensionCapabilityD1Ev __ZN6webrtc26PeerConnectionDependenciesD1Ev __ZN3rtc24BasicPacketSocketFactory21CreateClientTcpSocketERKNS_13SocketAddressES3_RKNS_9ProxyInfoERKNSt3__112basic_stringIcNS7_11char_traitsIcEENS7_9allocatorIcEEEERKNS_22PacketSocketTcpOptionsE @@ -234,3 +232,5 @@ __ZNK3rtc14SSLCertificate8GetStatsEv __ZN3rtc14RTCCertificate7FromPEMERKNS_17RTCCertificatePEME __ZN6webrtc26PeerConnectionDependenciesC1EPNS_22PeerConnectionObserverE __ZN6webrtc30PeerConnectionFactoryInterface20CreatePeerConnectionERKNS_23PeerConnectionInterface16RTCConfigurationENSt3__110unique_ptrIN7cricket13PortAllocatorENS5_14default_deleteIS8_EEEENS6_IN3rtc32RTCCertificateGeneratorInterfaceENS9_ISD_EEEEPNS_22PeerConnectionObserverE +__ZN6webrtc29SetSessionDescriptionObserver9OnFailureERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEE +__ZN6webrtc32CreateSessionDescriptionObserver9OnFailureERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEE diff --git a/Source/ThirdParty/libwebrtc/Configurations/libwebrtc.mac.exp b/Source/ThirdParty/libwebrtc/Configurations/libwebrtc.mac.exp index f4587da..19d0fe6 100644 --- a/Source/ThirdParty/libwebrtc/Configurations/libwebrtc.mac.exp +++ b/Source/ThirdParty/libwebrtc/Configurations/libwebrtc.mac.exp @@ -129,8 +129,6 @@ __ZTVN6webrtc29SetSessionDescriptionObserverE __ZNK3rtc17ThreadCheckerImpl19CalledOnValidThreadEv __ZN7cricket18BasicPortAllocatorC1EPN3rtc14NetworkManagerEPNS1_19PacketSocketFactoryEPN6webrtc14TurnCustomizerEPNS_25RelayPortFactoryInterfaceE __ZN7cricket12AudioOptionsD1Ev -__ZN6webrtc32CreateSessionDescriptionObserver9OnFailureENS_8RTCErrorE -__ZN6webrtc29SetSessionDescriptionObserver9OnFailureENS_8RTCErrorE __ZN6webrtc28RtpHeaderExtensionCapabilityD1Ev __ZN6webrtc26PeerConnectionDependenciesD1Ev __ZN3rtc24BasicPacketSocketFactory21CreateClientTcpSocketERKNS_13SocketAddressES3_RKNS_9ProxyInfoERKNSt3__112basic_stringIcNS7_11char_traitsIcEENS7_9allocatorIcEEEERKNS_22PacketSocketTcpOptionsE @@ -234,3 +232,5 @@ __ZNK3rtc14SSLCertificate8GetStatsEv __ZN3rtc14RTCCertificate7FromPEMERKNS_17RTCCertificatePEME __ZN6webrtc26PeerConnectionDependenciesC1EPNS_22PeerConnectionObserverE __ZN6webrtc30PeerConnectionFactoryInterface20CreatePeerConnectionERKNS_23PeerConnectionInterface16RTCConfigurationENSt3__110unique_ptrIN7cricket13PortAllocatorENS5_14default_deleteIS8_EEEENS6_IN3rtc32RTCCertificateGeneratorInterfaceENS9_ISD_EEEEPNS_22PeerConnectionObserverE +__ZN6webrtc29SetSessionDescriptionObserver9OnFailureERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEE +__ZN6webrtc32CreateSessionDescriptionObserver9OnFailureERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEE diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog index 144009b..2261456 100644 --- a/Source/WebCore/ChangeLog +++ b/Source/WebCore/ChangeLog @@ -1,5 +1,25 @@ 2018-11-14 Youenn Fablet + Convert libwebrtc error types to DOM exceptions + https://bugs.webkit.org/show_bug.cgi?id=191590 + + Reviewed by Alex Christensen. + + Make use of overloaded callback method that provides an error type. + This type is then used to create a DOM exception with the correct type. + Covered by existing tests. + + * Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.cpp: + (WebCore::LibWebRTCMediaEndpoint::doSetRemoteDescription): + (WebCore::LibWebRTCMediaEndpoint::createSessionDescriptionFailed): + (WebCore::LibWebRTCMediaEndpoint::setLocalSessionDescriptionFailed): + (WebCore::LibWebRTCMediaEndpoint::setRemoteSessionDescriptionFailed): + * Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.h: + * Modules/mediastream/libwebrtc/LibWebRTCObservers.h: + (WebCore::toExceptionCode): + +2018-11-14 Youenn Fablet + Allow to remove MediaStreamPrivate observers when iterating over observers https://bugs.webkit.org/show_bug.cgi?id=187256 diff --git a/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.cpp b/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.cpp index 85219b0..7c85d97 100644 --- a/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.cpp +++ b/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.cpp @@ -193,7 +193,7 @@ void LibWebRTCMediaEndpoint::doSetRemoteDescription(RTCSessionDescription& descr webrtc::SdpParseError error; std::unique_ptr sessionDescription(webrtc::CreateSessionDescription(sessionDescriptionType(description.type()), description.sdp().utf8().data(), &error)); if (!sessionDescription) { - m_peerConnectionBackend.setRemoteDescriptionFailed(Exception { OperationError, fromStdString(error.description) }); + m_peerConnectionBackend.setRemoteDescriptionFailed(Exception { SyntaxError, fromStdString(error.description) }); return; } m_backend->SetRemoteDescription(&m_setRemoteSessionDescriptionObserver, sessionDescription.release()); @@ -772,15 +772,15 @@ void LibWebRTCMediaEndpoint::createSessionDescriptionSucceeded(std::unique_ptrisStopped()) return; if (protectedThis->m_isInitiator) - protectedThis->m_peerConnectionBackend.createOfferFailed(Exception { OperationError, WTFMove(error) }); + protectedThis->m_peerConnectionBackend.createOfferFailed(Exception { errorCode, WTFMove(errorMessage) }); else - protectedThis->m_peerConnectionBackend.createAnswerFailed(Exception { OperationError, WTFMove(error) }); + protectedThis->m_peerConnectionBackend.createAnswerFailed(Exception { errorCode, WTFMove(errorMessage) }); }); } @@ -793,12 +793,12 @@ void LibWebRTCMediaEndpoint::setLocalSessionDescriptionSucceeded() }); } -void LibWebRTCMediaEndpoint::setLocalSessionDescriptionFailed(const std::string& errorMessage) +void LibWebRTCMediaEndpoint::setLocalSessionDescriptionFailed(ExceptionCode errorCode, const char* errorMessage) { - callOnMainThread([protectedThis = makeRef(*this), error = fromStdString(errorMessage)] () mutable { + callOnMainThread([protectedThis = makeRef(*this), errorCode, errorMessage = String(errorMessage)] () mutable { if (protectedThis->isStopped()) return; - protectedThis->m_peerConnectionBackend.setLocalDescriptionFailed(Exception { OperationError, WTFMove(error) }); + protectedThis->m_peerConnectionBackend.setLocalDescriptionFailed(Exception { errorCode, WTFMove(errorMessage) }); }); } @@ -811,12 +811,12 @@ void LibWebRTCMediaEndpoint::setRemoteSessionDescriptionSucceeded() }); } -void LibWebRTCMediaEndpoint::setRemoteSessionDescriptionFailed(const std::string& errorMessage) +void LibWebRTCMediaEndpoint::setRemoteSessionDescriptionFailed(ExceptionCode errorCode, const char* errorMessage) { - callOnMainThread([protectedThis = makeRef(*this), error = fromStdString(errorMessage)] () mutable { + callOnMainThread([protectedThis = makeRef(*this), errorCode, errorMessage = String(errorMessage)] () mutable { if (protectedThis->isStopped()) return; - protectedThis->m_peerConnectionBackend.setRemoteDescriptionFailed(Exception { OperationError, WTFMove(error) }); + protectedThis->m_peerConnectionBackend.setRemoteDescriptionFailed(Exception { errorCode, WTFMove(errorMessage) }); }); } diff --git a/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.h b/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.h index 5e21082..41cd884 100644 --- a/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.h +++ b/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.h @@ -132,11 +132,11 @@ private: void OnIceCandidatesRemoved(const std::vector&) final; void createSessionDescriptionSucceeded(std::unique_ptr&&); - void createSessionDescriptionFailed(const std::string&); + void createSessionDescriptionFailed(ExceptionCode, const char*); void setLocalSessionDescriptionSucceeded(); - void setLocalSessionDescriptionFailed(const std::string&); + void setLocalSessionDescriptionFailed(ExceptionCode, const char*); void setRemoteSessionDescriptionSucceeded(); - void setRemoteSessionDescriptionFailed(const std::string&); + void setRemoteSessionDescriptionFailed(ExceptionCode, const char*); void addRemoteStream(webrtc::MediaStreamInterface&); void addRemoteTrack(rtc::scoped_refptr&&, const std::vector>&); void removeRemoteStream(webrtc::MediaStreamInterface&); diff --git a/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCObservers.h b/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCObservers.h index d199ca7..da92b31 100644 --- a/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCObservers.h +++ b/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCObservers.h @@ -26,6 +26,7 @@ #if USE(LIBWEBRTC) +#include "ExceptionCode.h" #include "LibWebRTCMacros.h" ALLOW_UNUSED_PARAMETERS_BEGIN @@ -36,6 +37,26 @@ ALLOW_UNUSED_PARAMETERS_END namespace WebCore { +static inline ExceptionCode toExceptionCode(webrtc::RTCErrorType type) +{ + switch (type) { + case webrtc::RTCErrorType::INVALID_PARAMETER: + return InvalidAccessError; + case webrtc::RTCErrorType::INVALID_RANGE: + return RangeError; + case webrtc::RTCErrorType::SYNTAX_ERROR: + return SyntaxError; + case webrtc::RTCErrorType::INVALID_STATE: + return InvalidStateError; + case webrtc::RTCErrorType::INVALID_MODIFICATION: + return InvalidModificationError; + case webrtc::RTCErrorType::NETWORK_ERROR: + return NetworkError; + default: + return OperationError; + } +} + template class CreateSessionDescriptionObserver final : public webrtc::CreateSessionDescriptionObserver { public: @@ -45,7 +66,7 @@ public: } void OnSuccess(webrtc::SessionDescriptionInterface* sessionDescription) final { m_endpoint.createSessionDescriptionSucceeded(std::unique_ptr(sessionDescription)); } - void OnFailure(const std::string& error) final { m_endpoint.createSessionDescriptionFailed(error); } + void OnFailure(webrtc::RTCError error) final { m_endpoint.createSessionDescriptionFailed(toExceptionCode(error.type()), error.message()); } void AddRef() const { m_endpoint.AddRef(); } rtc::RefCountReleaseStatus Release() const { return m_endpoint.Release(); } @@ -63,7 +84,7 @@ public: } void OnSuccess() final { m_endpoint.setLocalSessionDescriptionSucceeded(); } - void OnFailure(const std::string& error) final { m_endpoint.setLocalSessionDescriptionFailed(error); } + void OnFailure(webrtc::RTCError error) final { m_endpoint.setLocalSessionDescriptionFailed(toExceptionCode(error.type()), error.message()); } void AddRef() const { m_endpoint.AddRef(); } rtc::RefCountReleaseStatus Release() const { return m_endpoint.Release(); } @@ -81,7 +102,7 @@ public: } void OnSuccess() final { m_endpoint.setRemoteSessionDescriptionSucceeded(); } - void OnFailure(const std::string& error) final { m_endpoint.setRemoteSessionDescriptionFailed(error); } + void OnFailure(webrtc::RTCError error) final { m_endpoint.setRemoteSessionDescriptionFailed(toExceptionCode(error.type()), error.message()); } void AddRef() const { m_endpoint.AddRef(); } rtc::RefCountReleaseStatus Release() const { return m_endpoint.Release(); } -- 1.8.3.1