Changeset 230548 in webkit
- Timestamp:
- Apr 11, 2018, 2:49:28 PM (9 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 9 edited
-
LayoutTests/ChangeLog (modified) (1 diff)
-
LayoutTests/webrtc/utf8-sdp-expected.txt (added)
-
LayoutTests/webrtc/utf8-sdp.html (added)
-
Source/WebCore/ChangeLog (modified) (1 diff)
-
Source/WebCore/Modules/mediastream/MediaStreamTrack.h (modified) (1 diff)
-
Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.cpp (modified) (15 diffs)
-
Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.cpp (modified) (2 diffs)
-
Source/WebCore/platform/mediastream/MediaStreamTrackPrivate.h (modified) (1 diff)
-
Source/WebCore/testing/Internals.cpp (modified) (1 diff)
-
Source/WebCore/testing/Internals.h (modified) (1 diff)
-
Source/WebCore/testing/Internals.idl (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r230531 r230548 1 2018-04-11 Youenn Fablet <youenn@apple.com> 2 3 Preventively expect UTF8 strings from libwebrtc SDP and error messages 4 https://bugs.webkit.org/show_bug.cgi?id=184509 5 6 Reviewed by Eric Carlson. 7 8 * webrtc/utf8-sdp-expected.txt: Added. 9 * webrtc/utf8-sdp.html: Added. 10 1 11 2018-04-11 Alicia Boya García <aboya@igalia.com> 2 12 -
trunk/Source/WebCore/ChangeLog
r230544 r230548 1 2018-04-11 Youenn Fablet <youenn@apple.com> 2 3 Preventively expect UTF8 strings from libwebrtc SDP and error messages 4 https://bugs.webkit.org/show_bug.cgi?id=184509 5 6 Reviewed by Eric Carlson. 7 8 Make WebCore code expect any libwebrtc string to contain UTF-8. 9 Currently SDPs do not contain any UTF-8 specific character 10 but https://tools.ietf.org/html/rfc4566 allows it. 11 12 Add Internals API to set track id so that we can inject UTF-8 inside some WebRTC tests. 13 Test: webrtc/utf8-sdp.html 14 15 * Modules/mediastream/MediaStreamTrack.h: 16 (WebCore::MediaStreamTrack::setIdForTesting): 17 * Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.cpp: 18 (WebCore::fromStdString): 19 (WebCore::fromSessionDescription): 20 (WebCore::LibWebRTCMediaEndpoint::doSetLocalDescription): 21 (WebCore::LibWebRTCMediaEndpoint::doSetRemoteDescription): 22 (WebCore::LibWebRTCMediaEndpoint::mediaStreamFromRTCStream): 23 (WebCore::LibWebRTCMediaEndpoint::addRemoteTrack): 24 (WebCore::LibWebRTCMediaEndpoint::addDataChannel): 25 (WebCore::LibWebRTCMediaEndpoint::OnIceCandidate): 26 (WebCore::LibWebRTCMediaEndpoint::createSessionDescriptionSucceeded): 27 (WebCore::LibWebRTCMediaEndpoint::createSessionDescriptionFailed): 28 (WebCore::LibWebRTCMediaEndpoint::setLocalSessionDescriptionFailed): 29 (WebCore::LibWebRTCMediaEndpoint::setRemoteSessionDescriptionFailed): 30 (WebCore::trackId): Deleted. 31 * Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.cpp: 32 (WebCore::fromStdString): 33 (WebCore::LibWebRTCPeerConnectionBackend::doAddIceCandidate): 34 (WebCore::createReceiverForSource): 35 * platform/mediastream/MediaStreamTrackPrivate.h: 36 (WebCore::MediaStreamTrackPrivate::setIdForTesting): 37 * testing/Internals.cpp: 38 (WebCore::Internals::setMediaStreamTrackIdentifier): 39 * testing/Internals.h: 40 * testing/Internals.idl: 41 1 42 2018-04-11 Said Abou-Hallawa <sabouhallawa@apple.com> 2 43 -
trunk/Source/WebCore/Modules/mediastream/MediaStreamTrack.h
r226412 r230548 139 139 bool hasPendingActivity() const final; 140 140 141 void setIdForTesting(String&& id) { m_private->setIdForTesting(WTFMove(id)); } 142 141 143 protected: 142 144 MediaStreamTrack(ScriptExecutionContext&, Ref<MediaStreamTrackPrivate>&&); -
trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCMediaEndpoint.cpp
r230342 r230548 58 58 namespace WebCore { 59 59 60 static inline String fromStdString(const std::string& value) 61 { 62 return String::fromUTF8(value.data(), value.length()); 63 } 64 60 65 LibWebRTCMediaEndpoint::LibWebRTCMediaEndpoint(LibWebRTCPeerConnectionBackend& peerConnection, LibWebRTCProvider& client) 61 66 : m_peerConnectionBackend(peerConnection) … … 117 122 std::string sdp; 118 123 description->ToString(&sdp); 119 String sdpString(sdp.data(), sdp.size()); 120 121 return RTCSessionDescription::create(fromSessionDescriptionType(*description), WTFMove(sdpString)); 124 125 return RTCSessionDescription::create(fromSessionDescriptionType(*description), fromStdString(sdp)); 122 126 } 123 127 … … 161 165 162 166 if (!sessionDescription) { 163 String errorMessage(error.description.data(), error.description.size()); 164 m_peerConnectionBackend.setLocalDescriptionFailed(Exception { OperationError, WTFMove(errorMessage) }); 167 m_peerConnectionBackend.setLocalDescriptionFailed(Exception { OperationError, fromStdString(error.description) }); 165 168 return; 166 169 } … … 182 185 std::unique_ptr<webrtc::SessionDescriptionInterface> sessionDescription(webrtc::CreateSessionDescription(sessionDescriptionType(description.type()), description.sdp().utf8().data(), &error)); 183 186 if (!sessionDescription) { 184 String errorMessage(error.description.data(), error.description.size()); 185 m_peerConnectionBackend.setRemoteDescriptionFailed(Exception { OperationError, WTFMove(errorMessage) }); 187 m_peerConnectionBackend.setRemoteDescriptionFailed(Exception { OperationError, fromStdString(error.description) }); 186 188 return; 187 189 } … … 302 304 if (track) 303 305 m_id = track->id(); 304 }305 306 static inline String fromStdString(const std::string& value)307 {308 return String(value.data(), value.length());309 306 } 310 307 … … 619 616 } 620 617 621 static inline String trackId(webrtc::MediaStreamTrackInterface& videoTrack)622 {623 return String(videoTrack.id().data(), videoTrack.id().size());624 }625 626 618 MediaStream& LibWebRTCMediaEndpoint::mediaStreamFromRTCStream(webrtc::MediaStreamInterface& rtcStream) 627 619 { 628 620 auto mediaStream = m_streams.ensure(&rtcStream, [&rtcStream, this] { 629 621 auto label = rtcStream.label(); 630 auto stream = MediaStream::create(*m_peerConnectionBackend.connection().scriptExecutionContext(), MediaStreamPrivate::create({ }, String(label.data(), label.size())));622 auto stream = MediaStream::create(*m_peerConnectionBackend.connection().scriptExecutionContext(), MediaStreamPrivate::create({ }, fromStdString(label))); 631 623 auto streamPointer = stream.ptr(); 632 624 m_peerConnectionBackend.addRemoteStream(WTFMove(stream)); … … 668 660 case cricket::MEDIA_TYPE_AUDIO: { 669 661 rtc::scoped_refptr<webrtc::AudioTrackInterface> audioTrack = static_cast<webrtc::AudioTrackInterface*>(rtcTrack); 670 auto audioReceiver = m_peerConnectionBackend.audioReceiver( trackId(*rtcTrack));662 auto audioReceiver = m_peerConnectionBackend.audioReceiver(fromStdString(rtcTrack->id())); 671 663 672 664 receiver = WTFMove(audioReceiver.receiver); … … 676 668 case cricket::MEDIA_TYPE_VIDEO: { 677 669 rtc::scoped_refptr<webrtc::VideoTrackInterface> videoTrack = static_cast<webrtc::VideoTrackInterface*>(rtcTrack); 678 auto videoReceiver = m_peerConnectionBackend.videoReceiver( trackId(*rtcTrack));670 auto videoReceiver = m_peerConnectionBackend.videoReceiver(fromStdString(rtcTrack->id())); 679 671 680 672 receiver = WTFMove(videoReceiver.receiver); … … 767 759 init.maxPacketLifeTime = dataChannel->maxRetransmitTime(); 768 760 init.maxRetransmits = dataChannel->maxRetransmits(); 769 init.protocol = String(protocol.data(), protocol.size());761 init.protocol = fromStdString(protocol); 770 762 init.negotiated = dataChannel->negotiated(); 771 763 init.id = dataChannel->id(); … … 775 767 auto handler = std::make_unique<LibWebRTCDataChannelHandler>(WTFMove(dataChannel)); 776 768 ASSERT(m_peerConnectionBackend.connection().scriptExecutionContext()); 777 auto channel = RTCDataChannel::create(*m_peerConnectionBackend.connection().scriptExecutionContext(), WTFMove(handler), String(label.data(), label.size()), WTFMove(init));769 auto channel = RTCDataChannel::create(*m_peerConnectionBackend.connection().scriptExecutionContext(), WTFMove(handler), fromStdString(label), WTFMove(init)); 778 770 779 771 if (isOpened) { … … 873 865 std::string sdp; 874 866 rtcCandidate->ToString(&sdp); 875 String candidateSDP(sdp.data(), sdp.size());876 877 auto mid = rtcCandidate->sdp_mid();878 String candidateMid(mid.data(), mid.size());879 867 880 868 auto sdpMLineIndex = safeCast<unsigned short>(rtcCandidate->sdp_mline_index()); 881 869 882 callOnMainThread([protectedThis = makeRef(*this), mid = WTFMove(candidateMid), sdp = WTFMove(candidateSDP), sdpMLineIndex]{883 if (protectedThis->isStopped()) 884 return; 885 protectedThis->m_peerConnectionBackend.newICECandidate( String(sdp), String(mid), sdpMLineIndex);870 callOnMainThread([protectedThis = makeRef(*this), mid = fromStdString(rtcCandidate->sdp_mid()), sdp = fromStdString(sdp), sdpMLineIndex]() mutable { 871 if (protectedThis->isStopped()) 872 return; 873 protectedThis->m_peerConnectionBackend.newICECandidate(WTFMove(sdp), WTFMove(mid), sdpMLineIndex); 886 874 }); 887 875 } … … 896 884 std::string sdp; 897 885 description->ToString(&sdp); 898 String sdpString(sdp.data(), sdp.size()); 899 900 callOnMainThread([protectedThis = makeRef(*this), sdp = WTFMove(sdpString)] { 886 887 callOnMainThread([protectedThis = makeRef(*this), sdp = fromStdString(sdp)]() mutable { 901 888 if (protectedThis->isStopped()) 902 889 return; 903 890 if (protectedThis->m_isInitiator) 904 protectedThis->m_peerConnectionBackend.createOfferSucceeded( String(sdp));891 protectedThis->m_peerConnectionBackend.createOfferSucceeded(WTFMove(sdp)); 905 892 else 906 protectedThis->m_peerConnectionBackend.createAnswerSucceeded( String(sdp));893 protectedThis->m_peerConnectionBackend.createAnswerSucceeded(WTFMove(sdp)); 907 894 }); 908 895 } … … 910 897 void LibWebRTCMediaEndpoint::createSessionDescriptionFailed(const std::string& errorMessage) 911 898 { 912 String error(errorMessage.data(), errorMessage.size()); 913 callOnMainThread([protectedThis = makeRef(*this), error = WTFMove(error)] () mutable { 899 callOnMainThread([protectedThis = makeRef(*this), error = fromStdString(errorMessage)] () mutable { 914 900 if (protectedThis->isStopped()) 915 901 return; … … 932 918 void LibWebRTCMediaEndpoint::setLocalSessionDescriptionFailed(const std::string& errorMessage) 933 919 { 934 String error(errorMessage.data(), errorMessage.size()); 935 callOnMainThread([protectedThis = makeRef(*this), error = WTFMove(error)] () mutable { 920 callOnMainThread([protectedThis = makeRef(*this), error = fromStdString(errorMessage)] () mutable { 936 921 if (protectedThis->isStopped()) 937 922 return; … … 951 936 void LibWebRTCMediaEndpoint::setRemoteSessionDescriptionFailed(const std::string& errorMessage) 952 937 { 953 String error(errorMessage.data(), errorMessage.size()); 954 callOnMainThread([protectedThis = makeRef(*this), error = WTFMove(error)] () mutable { 938 callOnMainThread([protectedThis = makeRef(*this), error = fromStdString(errorMessage)] () mutable { 955 939 if (protectedThis->isStopped()) 956 940 return; -
trunk/Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.cpp
r230152 r230548 210 210 211 211 if (!rtcCandidate) { 212 String message(error.description.data(), error.description.size()); 213 addIceCandidateFailed(Exception { OperationError, WTFMove(message) }); 212 addIceCandidateFailed(Exception { OperationError, String::fromUTF8(error.description.data(), error.description.length()) }); 214 213 return; 215 214 } … … 238 237 static inline Ref<RTCRtpReceiver> createReceiverForSource(ScriptExecutionContext& context, Ref<RealtimeMediaSource>&& source) 239 238 { 240 String id = source->id(); 241 auto remoteTrackPrivate = MediaStreamTrackPrivate::create(WTFMove(source), WTFMove(id)); 239 auto remoteTrackPrivate = MediaStreamTrackPrivate::create(WTFMove(source), String { source->id() }); 242 240 auto remoteTrack = MediaStreamTrack::create(context, WTFMove(remoteTrackPrivate)); 243 241 -
trunk/Source/WebCore/platform/mediastream/MediaStreamTrackPrivate.h
r223728 r230548 101 101 ReadyState readyState() const { return m_readyState; } 102 102 103 void setIdForTesting(String&& id) { m_id = WTFMove(id); } 104 103 105 private: 104 106 MediaStreamTrackPrivate(Ref<RealtimeMediaSource>&&, String&& id); -
trunk/Source/WebCore/testing/Internals.cpp
r230211 r230548 4287 4287 } 4288 4288 4289 void Internals::setMediaStreamTrackIdentifier(MediaStreamTrack& track, String&& id) 4290 { 4291 track.setIdForTesting(WTFMove(id)); 4292 } 4289 4293 #endif 4290 4294 -
trunk/Source/WebCore/testing/Internals.h
r229475 r230548 623 623 void removeMediaStreamTrack(MediaStream&, MediaStreamTrack&); 624 624 void simulateMediaStreamTrackCaptureSourceFailure(MediaStreamTrack&); 625 void setMediaStreamTrackIdentifier(MediaStreamTrack&, String&& id); 625 626 #endif 626 627 -
trunk/Source/WebCore/testing/Internals.idl
r229475 r230548 567 567 [Conditional=MEDIA_STREAM] void removeMediaStreamTrack(MediaStream stream, MediaStreamTrack track); 568 568 [Conditional=MEDIA_STREAM] void simulateMediaStreamTrackCaptureSourceFailure(MediaStreamTrack track); 569 [Conditional=MEDIA_STREAM] void setMediaStreamTrackIdentifier(MediaStreamTrack track, DOMString identifier); 569 570 570 571 Promise<void> clearCacheStorageMemoryRepresentation();
Note:
See TracChangeset
for help on using the changeset viewer.