RTCRtpSender.replaceTrack(null) ends current track
authoryouenn@apple.com <youenn@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 19 Jun 2018 07:20:51 +0000 (07:20 +0000)
committeryouenn@apple.com <youenn@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 19 Jun 2018 07:20:51 +0000 (07:20 +0000)
commitd3eea7dd4352a0285cce0410054bbae0f773a41a
treef0c0e4f602af8d7de8500d3358923dc10a1e82fa
parenta0959d75748c8214cfd85440ec39838727c6790a
RTCRtpSender.replaceTrack(null) ends current track
https://bugs.webkit.org/show_bug.cgi?id=184911
<rdar://problem/40758138>

Reviewed by Eric Carlson.

LayoutTests/imported/w3c:

* web-platform-tests/webrtc/RTCRtpSender-replaceTrack-expected.txt:

Source/WebCore:

Before the patch, when replacing the sender track by null, the previous track was stopped.
Instead of doing that, the track now stays alive and it is the realtime source that is stopped.
This ensures that the data is no longer sent while the track can still be used elsewhere.

Covered by updated and rebased tests.

* Modules/mediastream/PeerConnectionBackend.h:
* Modules/mediastream/RTCPeerConnection.cpp:
(WebCore::RTCPeerConnection::addTransceiver):
(WebCore::RTCPeerConnection::enqueueReplaceTrackTask):
(WebCore::RTCPeerConnection::replaceTrack):
* Modules/mediastream/RTCPeerConnection.h:
* Modules/mediastream/RTCRtpSender.cpp:
(WebCore::RTCRtpSender::replaceTrack):
* Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.cpp:
(WebCore::updateTrackSource):
(WebCore::LibWebRTCPeerConnectionBackend::replaceTrack):
* Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.h:

LayoutTests:

Added checks for readyState to ensure the track remains live.
Split the main test into several tests to ease readability.

* webrtc/video-replace-track-to-null-expected.txt:
* webrtc/video-replace-track-to-null.html:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@232956 268f45cc-cd09-0410-ab3c-d52691b4dbfc
12 files changed:
LayoutTests/ChangeLog
LayoutTests/imported/w3c/ChangeLog
LayoutTests/imported/w3c/web-platform-tests/webrtc/RTCRtpSender-replaceTrack-expected.txt
LayoutTests/webrtc/video-replace-track-to-null-expected.txt
LayoutTests/webrtc/video-replace-track-to-null.html
Source/WebCore/ChangeLog
Source/WebCore/Modules/mediastream/PeerConnectionBackend.h
Source/WebCore/Modules/mediastream/RTCPeerConnection.cpp
Source/WebCore/Modules/mediastream/RTCPeerConnection.h
Source/WebCore/Modules/mediastream/RTCRtpSender.cpp
Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.cpp
Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.h