haikuwebkit/LayoutTests/webrtc/video-replace-track-to-null...

108 lines
3.3 KiB
HTML
Raw Permalink Normal View History

Add libwebrtc backend support for RTCRtpSender::replaceTrack https://bugs.webkit.org/show_bug.cgi?id=169841 Patch by Youenn Fablet <youenn@apple.com> on 2017-03-24 Reviewed by Alex Christensen. Source/WebCore: Tests: webrtc/audio-replace-track.html webrtc/video-replace-track.html Adding support for replaceTrack for audio and video sources. Replacing tracks will always succeed for audio sources. For video tracks, it will only succeed if the video resolution is not greater. LibWebRTCPeerConnectionBackend will delegate the track replacing by replacing the source of the outgoing sources with the source wrapped in the replacing track. Video test is not fully passing as size constraints for mock video sources are not providing the right video stream resolution. * Modules/mediastream/RTCRtpSender.cpp: (WebCore::RTCRtpSender::replaceTrack): * Modules/mediastream/RTCRtpSender.h: * Modules/mediastream/RTCRtpSender.idl: * Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.cpp: (WebCore::LibWebRTCPeerConnectionBackend::replaceTrack): * Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.h: * platform/mediastream/mac/RealtimeOutgoingAudioSource.cpp: (WebCore::RealtimeOutgoingAudioSource::setSource): * platform/mediastream/mac/RealtimeOutgoingAudioSource.h: * platform/mediastream/mac/RealtimeOutgoingVideoSource.cpp: (WebCore::RealtimeOutgoingVideoSource::setSource): * platform/mediastream/mac/RealtimeOutgoingVideoSource.h: * platform/mock/MockRealtimeVideoSource.cpp: (WebCore::MockRealtimeVideoSource::drawText): (WebCore::MockRealtimeVideoSource::generateFrame): LayoutTests: * webrtc/audio-replace-track-expected.txt: Added. * webrtc/audio-replace-track.html: Added. * webrtc/video-replace-track-expected.txt: Added. * webrtc/video-replace-track.html: Added. * webrtc/video-replace-track-to-null-expected.txt: Added. * webrtc/video-replace-track-to-null.html: Added. Canonical link: https://commits.webkit.org/186982@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@214357 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-03-24 18:01:18 +00:00
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Testing basic video exchange from offerer to receiver</title>
<script src="../resources/testharness.js"></script>
<script src="../resources/testharnessreport.js"></script>
</head>
<body>
<div id="log"></div>
<video id="video" autoplay=""></video>
<canvas id="canvas" width="640" height="480"></canvas>
<script src ="routines.js"></script>
<script>
video = document.getElementById("video");
canvas = document.getElementById("canvas");
async function getOutboundRTPStatsNumberOfEncodedFrames(connection)
Add libwebrtc backend support for RTCRtpSender::replaceTrack https://bugs.webkit.org/show_bug.cgi?id=169841 Patch by Youenn Fablet <youenn@apple.com> on 2017-03-24 Reviewed by Alex Christensen. Source/WebCore: Tests: webrtc/audio-replace-track.html webrtc/video-replace-track.html Adding support for replaceTrack for audio and video sources. Replacing tracks will always succeed for audio sources. For video tracks, it will only succeed if the video resolution is not greater. LibWebRTCPeerConnectionBackend will delegate the track replacing by replacing the source of the outgoing sources with the source wrapped in the replacing track. Video test is not fully passing as size constraints for mock video sources are not providing the right video stream resolution. * Modules/mediastream/RTCRtpSender.cpp: (WebCore::RTCRtpSender::replaceTrack): * Modules/mediastream/RTCRtpSender.h: * Modules/mediastream/RTCRtpSender.idl: * Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.cpp: (WebCore::LibWebRTCPeerConnectionBackend::replaceTrack): * Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.h: * platform/mediastream/mac/RealtimeOutgoingAudioSource.cpp: (WebCore::RealtimeOutgoingAudioSource::setSource): * platform/mediastream/mac/RealtimeOutgoingAudioSource.h: * platform/mediastream/mac/RealtimeOutgoingVideoSource.cpp: (WebCore::RealtimeOutgoingVideoSource::setSource): * platform/mediastream/mac/RealtimeOutgoingVideoSource.h: * platform/mock/MockRealtimeVideoSource.cpp: (WebCore::MockRealtimeVideoSource::drawText): (WebCore::MockRealtimeVideoSource::generateFrame): LayoutTests: * webrtc/audio-replace-track-expected.txt: Added. * webrtc/audio-replace-track.html: Added. * webrtc/video-replace-track-expected.txt: Added. * webrtc/video-replace-track.html: Added. * webrtc/video-replace-track-to-null-expected.txt: Added. * webrtc/video-replace-track-to-null.html: Added. Canonical link: https://commits.webkit.org/186982@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@214357 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-03-24 18:01:18 +00:00
{
var report = await connection.getStats();
var framesEncoded;
report.forEach((statItem) => {
if (statItem.type === "outbound-rtp") {
framesEncoded = statItem.framesEncoded;
}
});
return framesEncoded;
Add libwebrtc backend support for RTCRtpSender::replaceTrack https://bugs.webkit.org/show_bug.cgi?id=169841 Patch by Youenn Fablet <youenn@apple.com> on 2017-03-24 Reviewed by Alex Christensen. Source/WebCore: Tests: webrtc/audio-replace-track.html webrtc/video-replace-track.html Adding support for replaceTrack for audio and video sources. Replacing tracks will always succeed for audio sources. For video tracks, it will only succeed if the video resolution is not greater. LibWebRTCPeerConnectionBackend will delegate the track replacing by replacing the source of the outgoing sources with the source wrapped in the replacing track. Video test is not fully passing as size constraints for mock video sources are not providing the right video stream resolution. * Modules/mediastream/RTCRtpSender.cpp: (WebCore::RTCRtpSender::replaceTrack): * Modules/mediastream/RTCRtpSender.h: * Modules/mediastream/RTCRtpSender.idl: * Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.cpp: (WebCore::LibWebRTCPeerConnectionBackend::replaceTrack): * Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.h: * platform/mediastream/mac/RealtimeOutgoingAudioSource.cpp: (WebCore::RealtimeOutgoingAudioSource::setSource): * platform/mediastream/mac/RealtimeOutgoingAudioSource.h: * platform/mediastream/mac/RealtimeOutgoingVideoSource.cpp: (WebCore::RealtimeOutgoingVideoSource::setSource): * platform/mediastream/mac/RealtimeOutgoingVideoSource.h: * platform/mock/MockRealtimeVideoSource.cpp: (WebCore::MockRealtimeVideoSource::drawText): (WebCore::MockRealtimeVideoSource::generateFrame): LayoutTests: * webrtc/audio-replace-track-expected.txt: Added. * webrtc/audio-replace-track.html: Added. * webrtc/video-replace-track-expected.txt: Added. * webrtc/video-replace-track.html: Added. * webrtc/video-replace-track-to-null-expected.txt: Added. * webrtc/video-replace-track-to-null.html: Added. Canonical link: https://commits.webkit.org/186982@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@214357 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-03-24 18:01:18 +00:00
}
async function testFrameEncodedStarted(connection, count, previousFramesNumber)
Add libwebrtc backend support for RTCRtpSender::replaceTrack https://bugs.webkit.org/show_bug.cgi?id=169841 Patch by Youenn Fablet <youenn@apple.com> on 2017-03-24 Reviewed by Alex Christensen. Source/WebCore: Tests: webrtc/audio-replace-track.html webrtc/video-replace-track.html Adding support for replaceTrack for audio and video sources. Replacing tracks will always succeed for audio sources. For video tracks, it will only succeed if the video resolution is not greater. LibWebRTCPeerConnectionBackend will delegate the track replacing by replacing the source of the outgoing sources with the source wrapped in the replacing track. Video test is not fully passing as size constraints for mock video sources are not providing the right video stream resolution. * Modules/mediastream/RTCRtpSender.cpp: (WebCore::RTCRtpSender::replaceTrack): * Modules/mediastream/RTCRtpSender.h: * Modules/mediastream/RTCRtpSender.idl: * Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.cpp: (WebCore::LibWebRTCPeerConnectionBackend::replaceTrack): * Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.h: * platform/mediastream/mac/RealtimeOutgoingAudioSource.cpp: (WebCore::RealtimeOutgoingAudioSource::setSource): * platform/mediastream/mac/RealtimeOutgoingAudioSource.h: * platform/mediastream/mac/RealtimeOutgoingVideoSource.cpp: (WebCore::RealtimeOutgoingVideoSource::setSource): * platform/mediastream/mac/RealtimeOutgoingVideoSource.h: * platform/mock/MockRealtimeVideoSource.cpp: (WebCore::MockRealtimeVideoSource::drawText): (WebCore::MockRealtimeVideoSource::generateFrame): LayoutTests: * webrtc/audio-replace-track-expected.txt: Added. * webrtc/audio-replace-track.html: Added. * webrtc/video-replace-track-expected.txt: Added. * webrtc/video-replace-track.html: Added. * webrtc/video-replace-track-to-null-expected.txt: Added. * webrtc/video-replace-track-to-null.html: Added. Canonical link: https://commits.webkit.org/186982@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@214357 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-03-24 18:01:18 +00:00
{
var framesEncodedNumber = await getOutboundRTPStatsNumberOfEncodedFrames(connection);
if (previousFramesNumber && framesEncodedNumber > previousFramesNumber)
return;
Add libwebrtc backend support for RTCRtpSender::replaceTrack https://bugs.webkit.org/show_bug.cgi?id=169841 Patch by Youenn Fablet <youenn@apple.com> on 2017-03-24 Reviewed by Alex Christensen. Source/WebCore: Tests: webrtc/audio-replace-track.html webrtc/video-replace-track.html Adding support for replaceTrack for audio and video sources. Replacing tracks will always succeed for audio sources. For video tracks, it will only succeed if the video resolution is not greater. LibWebRTCPeerConnectionBackend will delegate the track replacing by replacing the source of the outgoing sources with the source wrapped in the replacing track. Video test is not fully passing as size constraints for mock video sources are not providing the right video stream resolution. * Modules/mediastream/RTCRtpSender.cpp: (WebCore::RTCRtpSender::replaceTrack): * Modules/mediastream/RTCRtpSender.h: * Modules/mediastream/RTCRtpSender.idl: * Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.cpp: (WebCore::LibWebRTCPeerConnectionBackend::replaceTrack): * Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.h: * platform/mediastream/mac/RealtimeOutgoingAudioSource.cpp: (WebCore::RealtimeOutgoingAudioSource::setSource): * platform/mediastream/mac/RealtimeOutgoingAudioSource.h: * platform/mediastream/mac/RealtimeOutgoingVideoSource.cpp: (WebCore::RealtimeOutgoingVideoSource::setSource): * platform/mediastream/mac/RealtimeOutgoingVideoSource.h: * platform/mock/MockRealtimeVideoSource.cpp: (WebCore::MockRealtimeVideoSource::drawText): (WebCore::MockRealtimeVideoSource::generateFrame): LayoutTests: * webrtc/audio-replace-track-expected.txt: Added. * webrtc/audio-replace-track.html: Added. * webrtc/video-replace-track-expected.txt: Added. * webrtc/video-replace-track.html: Added. * webrtc/video-replace-track-to-null-expected.txt: Added. * webrtc/video-replace-track-to-null.html: Added. Canonical link: https://commits.webkit.org/186982@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@214357 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-03-24 18:01:18 +00:00
if (count === undefined)
count = 0;
Add libwebrtc backend support for RTCRtpSender::replaceTrack https://bugs.webkit.org/show_bug.cgi?id=169841 Patch by Youenn Fablet <youenn@apple.com> on 2017-03-24 Reviewed by Alex Christensen. Source/WebCore: Tests: webrtc/audio-replace-track.html webrtc/video-replace-track.html Adding support for replaceTrack for audio and video sources. Replacing tracks will always succeed for audio sources. For video tracks, it will only succeed if the video resolution is not greater. LibWebRTCPeerConnectionBackend will delegate the track replacing by replacing the source of the outgoing sources with the source wrapped in the replacing track. Video test is not fully passing as size constraints for mock video sources are not providing the right video stream resolution. * Modules/mediastream/RTCRtpSender.cpp: (WebCore::RTCRtpSender::replaceTrack): * Modules/mediastream/RTCRtpSender.h: * Modules/mediastream/RTCRtpSender.idl: * Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.cpp: (WebCore::LibWebRTCPeerConnectionBackend::replaceTrack): * Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.h: * platform/mediastream/mac/RealtimeOutgoingAudioSource.cpp: (WebCore::RealtimeOutgoingAudioSource::setSource): * platform/mediastream/mac/RealtimeOutgoingAudioSource.h: * platform/mediastream/mac/RealtimeOutgoingVideoSource.cpp: (WebCore::RealtimeOutgoingVideoSource::setSource): * platform/mediastream/mac/RealtimeOutgoingVideoSource.h: * platform/mock/MockRealtimeVideoSource.cpp: (WebCore::MockRealtimeVideoSource::drawText): (WebCore::MockRealtimeVideoSource::generateFrame): LayoutTests: * webrtc/audio-replace-track-expected.txt: Added. * webrtc/audio-replace-track.html: Added. * webrtc/video-replace-track-expected.txt: Added. * webrtc/video-replace-track.html: Added. * webrtc/video-replace-track-to-null-expected.txt: Added. * webrtc/video-replace-track-to-null.html: Added. Canonical link: https://commits.webkit.org/186982@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@214357 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-03-24 18:01:18 +00:00
if (count >= 20)
return Promise.reject("test increasing frame encoded timed out");
await waitFor(100);
return testFrameEncodedStarted(connection, ++count, framesEncodedNumber);
}
async function testFrameEncodedStopped(connection, count, previousFramesNumber)
{
var framesEncodedNumber = await getOutboundRTPStatsNumberOfEncodedFrames(connection);
if (previousFramesNumber && framesEncodedNumber === previousFramesNumber)
return;
Add libwebrtc backend support for RTCRtpSender::replaceTrack https://bugs.webkit.org/show_bug.cgi?id=169841 Patch by Youenn Fablet <youenn@apple.com> on 2017-03-24 Reviewed by Alex Christensen. Source/WebCore: Tests: webrtc/audio-replace-track.html webrtc/video-replace-track.html Adding support for replaceTrack for audio and video sources. Replacing tracks will always succeed for audio sources. For video tracks, it will only succeed if the video resolution is not greater. LibWebRTCPeerConnectionBackend will delegate the track replacing by replacing the source of the outgoing sources with the source wrapped in the replacing track. Video test is not fully passing as size constraints for mock video sources are not providing the right video stream resolution. * Modules/mediastream/RTCRtpSender.cpp: (WebCore::RTCRtpSender::replaceTrack): * Modules/mediastream/RTCRtpSender.h: * Modules/mediastream/RTCRtpSender.idl: * Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.cpp: (WebCore::LibWebRTCPeerConnectionBackend::replaceTrack): * Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.h: * platform/mediastream/mac/RealtimeOutgoingAudioSource.cpp: (WebCore::RealtimeOutgoingAudioSource::setSource): * platform/mediastream/mac/RealtimeOutgoingAudioSource.h: * platform/mediastream/mac/RealtimeOutgoingVideoSource.cpp: (WebCore::RealtimeOutgoingVideoSource::setSource): * platform/mediastream/mac/RealtimeOutgoingVideoSource.h: * platform/mock/MockRealtimeVideoSource.cpp: (WebCore::MockRealtimeVideoSource::drawText): (WebCore::MockRealtimeVideoSource::generateFrame): LayoutTests: * webrtc/audio-replace-track-expected.txt: Added. * webrtc/audio-replace-track.html: Added. * webrtc/video-replace-track-expected.txt: Added. * webrtc/video-replace-track.html: Added. * webrtc/video-replace-track-to-null-expected.txt: Added. * webrtc/video-replace-track-to-null.html: Added. Canonical link: https://commits.webkit.org/186982@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@214357 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-03-24 18:01:18 +00:00
if (count === undefined)
count = 0;
if (count === 20)
return Promise.reject("test that number of encoded frames stopped increasing timed out");
await waitFor(100);
return testFrameEncodedStopped(connection, ++count, framesEncodedNumber);
Add libwebrtc backend support for RTCRtpSender::replaceTrack https://bugs.webkit.org/show_bug.cgi?id=169841 Patch by Youenn Fablet <youenn@apple.com> on 2017-03-24 Reviewed by Alex Christensen. Source/WebCore: Tests: webrtc/audio-replace-track.html webrtc/video-replace-track.html Adding support for replaceTrack for audio and video sources. Replacing tracks will always succeed for audio sources. For video tracks, it will only succeed if the video resolution is not greater. LibWebRTCPeerConnectionBackend will delegate the track replacing by replacing the source of the outgoing sources with the source wrapped in the replacing track. Video test is not fully passing as size constraints for mock video sources are not providing the right video stream resolution. * Modules/mediastream/RTCRtpSender.cpp: (WebCore::RTCRtpSender::replaceTrack): * Modules/mediastream/RTCRtpSender.h: * Modules/mediastream/RTCRtpSender.idl: * Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.cpp: (WebCore::LibWebRTCPeerConnectionBackend::replaceTrack): * Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.h: * platform/mediastream/mac/RealtimeOutgoingAudioSource.cpp: (WebCore::RealtimeOutgoingAudioSource::setSource): * platform/mediastream/mac/RealtimeOutgoingAudioSource.h: * platform/mediastream/mac/RealtimeOutgoingVideoSource.cpp: (WebCore::RealtimeOutgoingVideoSource::setSource): * platform/mediastream/mac/RealtimeOutgoingVideoSource.h: * platform/mock/MockRealtimeVideoSource.cpp: (WebCore::MockRealtimeVideoSource::drawText): (WebCore::MockRealtimeVideoSource::generateFrame): LayoutTests: * webrtc/audio-replace-track-expected.txt: Added. * webrtc/audio-replace-track.html: Added. * webrtc/video-replace-track-expected.txt: Added. * webrtc/video-replace-track.html: Added. * webrtc/video-replace-track-to-null-expected.txt: Added. * webrtc/video-replace-track-to-null.html: Added. Canonical link: https://commits.webkit.org/186982@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@214357 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-03-24 18:01:18 +00:00
}
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: Canonical link: https://commits.webkit.org/202059@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@232956 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-06-19 07:20:51 +00:00
var sender;
var sendingTrack;
var connection;
promise_test(async (test) => {
Add libwebrtc backend support for RTCRtpSender::replaceTrack https://bugs.webkit.org/show_bug.cgi?id=169841 Patch by Youenn Fablet <youenn@apple.com> on 2017-03-24 Reviewed by Alex Christensen. Source/WebCore: Tests: webrtc/audio-replace-track.html webrtc/video-replace-track.html Adding support for replaceTrack for audio and video sources. Replacing tracks will always succeed for audio sources. For video tracks, it will only succeed if the video resolution is not greater. LibWebRTCPeerConnectionBackend will delegate the track replacing by replacing the source of the outgoing sources with the source wrapped in the replacing track. Video test is not fully passing as size constraints for mock video sources are not providing the right video stream resolution. * Modules/mediastream/RTCRtpSender.cpp: (WebCore::RTCRtpSender::replaceTrack): * Modules/mediastream/RTCRtpSender.h: * Modules/mediastream/RTCRtpSender.idl: * Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.cpp: (WebCore::LibWebRTCPeerConnectionBackend::replaceTrack): * Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.h: * platform/mediastream/mac/RealtimeOutgoingAudioSource.cpp: (WebCore::RealtimeOutgoingAudioSource::setSource): * platform/mediastream/mac/RealtimeOutgoingAudioSource.h: * platform/mediastream/mac/RealtimeOutgoingVideoSource.cpp: (WebCore::RealtimeOutgoingVideoSource::setSource): * platform/mediastream/mac/RealtimeOutgoingVideoSource.h: * platform/mock/MockRealtimeVideoSource.cpp: (WebCore::MockRealtimeVideoSource::drawText): (WebCore::MockRealtimeVideoSource::generateFrame): LayoutTests: * webrtc/audio-replace-track-expected.txt: Added. * webrtc/audio-replace-track.html: Added. * webrtc/video-replace-track-expected.txt: Added. * webrtc/video-replace-track.html: Added. * webrtc/video-replace-track-to-null-expected.txt: Added. * webrtc/video-replace-track-to-null.html: Added. Canonical link: https://commits.webkit.org/186982@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@214357 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-03-24 18:01:18 +00:00
if (window.testRunner)
testRunner.setUserMediaPermission(true);
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: Canonical link: https://commits.webkit.org/202059@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@232956 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-06-19 07:20:51 +00:00
const frontStream = await navigator.mediaDevices.getUserMedia({ video: true });
const remoteStream = await new Promise((resolve, reject) => {
createConnections((firstConnection) => {
connection = firstConnection;
sender = firstConnection.addTrack(frontStream.getVideoTracks()[0], frontStream);
}, (secondConnection) => {
secondConnection.ontrack = (trackEvent) => {
resolve(trackEvent.streams[0]);
};
Add libwebrtc backend support for RTCRtpSender::replaceTrack https://bugs.webkit.org/show_bug.cgi?id=169841 Patch by Youenn Fablet <youenn@apple.com> on 2017-03-24 Reviewed by Alex Christensen. Source/WebCore: Tests: webrtc/audio-replace-track.html webrtc/video-replace-track.html Adding support for replaceTrack for audio and video sources. Replacing tracks will always succeed for audio sources. For video tracks, it will only succeed if the video resolution is not greater. LibWebRTCPeerConnectionBackend will delegate the track replacing by replacing the source of the outgoing sources with the source wrapped in the replacing track. Video test is not fully passing as size constraints for mock video sources are not providing the right video stream resolution. * Modules/mediastream/RTCRtpSender.cpp: (WebCore::RTCRtpSender::replaceTrack): * Modules/mediastream/RTCRtpSender.h: * Modules/mediastream/RTCRtpSender.idl: * Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.cpp: (WebCore::LibWebRTCPeerConnectionBackend::replaceTrack): * Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.h: * platform/mediastream/mac/RealtimeOutgoingAudioSource.cpp: (WebCore::RealtimeOutgoingAudioSource::setSource): * platform/mediastream/mac/RealtimeOutgoingAudioSource.h: * platform/mediastream/mac/RealtimeOutgoingVideoSource.cpp: (WebCore::RealtimeOutgoingVideoSource::setSource): * platform/mediastream/mac/RealtimeOutgoingVideoSource.h: * platform/mock/MockRealtimeVideoSource.cpp: (WebCore::MockRealtimeVideoSource::drawText): (WebCore::MockRealtimeVideoSource::generateFrame): LayoutTests: * webrtc/audio-replace-track-expected.txt: Added. * webrtc/audio-replace-track.html: Added. * webrtc/video-replace-track-expected.txt: Added. * webrtc/video-replace-track.html: Added. * webrtc/video-replace-track-to-null-expected.txt: Added. * webrtc/video-replace-track-to-null.html: Added. Canonical link: https://commits.webkit.org/186982@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@214357 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-03-24 18:01:18 +00:00
});
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: Canonical link: https://commits.webkit.org/202059@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@232956 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-06-19 07:20:51 +00:00
setTimeout(() => reject("Test timed out"), 5000);
Add libwebrtc backend support for RTCRtpSender::replaceTrack https://bugs.webkit.org/show_bug.cgi?id=169841 Patch by Youenn Fablet <youenn@apple.com> on 2017-03-24 Reviewed by Alex Christensen. Source/WebCore: Tests: webrtc/audio-replace-track.html webrtc/video-replace-track.html Adding support for replaceTrack for audio and video sources. Replacing tracks will always succeed for audio sources. For video tracks, it will only succeed if the video resolution is not greater. LibWebRTCPeerConnectionBackend will delegate the track replacing by replacing the source of the outgoing sources with the source wrapped in the replacing track. Video test is not fully passing as size constraints for mock video sources are not providing the right video stream resolution. * Modules/mediastream/RTCRtpSender.cpp: (WebCore::RTCRtpSender::replaceTrack): * Modules/mediastream/RTCRtpSender.h: * Modules/mediastream/RTCRtpSender.idl: * Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.cpp: (WebCore::LibWebRTCPeerConnectionBackend::replaceTrack): * Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.h: * platform/mediastream/mac/RealtimeOutgoingAudioSource.cpp: (WebCore::RealtimeOutgoingAudioSource::setSource): * platform/mediastream/mac/RealtimeOutgoingAudioSource.h: * platform/mediastream/mac/RealtimeOutgoingVideoSource.cpp: (WebCore::RealtimeOutgoingVideoSource::setSource): * platform/mediastream/mac/RealtimeOutgoingVideoSource.h: * platform/mock/MockRealtimeVideoSource.cpp: (WebCore::MockRealtimeVideoSource::drawText): (WebCore::MockRealtimeVideoSource::generateFrame): LayoutTests: * webrtc/audio-replace-track-expected.txt: Added. * webrtc/audio-replace-track.html: Added. * webrtc/video-replace-track-expected.txt: Added. * webrtc/video-replace-track.html: Added. * webrtc/video-replace-track-to-null-expected.txt: Added. * webrtc/video-replace-track-to-null.html: Added. Canonical link: https://commits.webkit.org/186982@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@214357 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-03-24 18:01:18 +00:00
});
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: Canonical link: https://commits.webkit.org/202059@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@232956 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-06-19 07:20:51 +00:00
video.srcObject = remoteStream;
await video.play();
}, "Set-up test");
promise_test(async (test) => {
await testFrameEncodedStarted(connection);
sendingTrack = sender.track;
assert_equals(sendingTrack.readyState, "live");
}, "Test that frame counter increases");
promise_test(async (test) => {
promise = sender.replaceTrack(null);
assert_true(!!sender.track);
await promise;
assert_equals(sender.track, null);
}, "Test replaceTrack with null track");
promise_test(async (test) => {
await testFrameEncodedStopped(connection);
assert_equals(sendingTrack.readyState, "live");
}, "Test that frame counter no longer increases");
Add libwebrtc backend support for RTCRtpSender::replaceTrack https://bugs.webkit.org/show_bug.cgi?id=169841 Patch by Youenn Fablet <youenn@apple.com> on 2017-03-24 Reviewed by Alex Christensen. Source/WebCore: Tests: webrtc/audio-replace-track.html webrtc/video-replace-track.html Adding support for replaceTrack for audio and video sources. Replacing tracks will always succeed for audio sources. For video tracks, it will only succeed if the video resolution is not greater. LibWebRTCPeerConnectionBackend will delegate the track replacing by replacing the source of the outgoing sources with the source wrapped in the replacing track. Video test is not fully passing as size constraints for mock video sources are not providing the right video stream resolution. * Modules/mediastream/RTCRtpSender.cpp: (WebCore::RTCRtpSender::replaceTrack): * Modules/mediastream/RTCRtpSender.h: * Modules/mediastream/RTCRtpSender.idl: * Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.cpp: (WebCore::LibWebRTCPeerConnectionBackend::replaceTrack): * Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.h: * platform/mediastream/mac/RealtimeOutgoingAudioSource.cpp: (WebCore::RealtimeOutgoingAudioSource::setSource): * platform/mediastream/mac/RealtimeOutgoingAudioSource.h: * platform/mediastream/mac/RealtimeOutgoingVideoSource.cpp: (WebCore::RealtimeOutgoingVideoSource::setSource): * platform/mediastream/mac/RealtimeOutgoingVideoSource.h: * platform/mock/MockRealtimeVideoSource.cpp: (WebCore::MockRealtimeVideoSource::drawText): (WebCore::MockRealtimeVideoSource::generateFrame): LayoutTests: * webrtc/audio-replace-track-expected.txt: Added. * webrtc/audio-replace-track.html: Added. * webrtc/video-replace-track-expected.txt: Added. * webrtc/video-replace-track.html: Added. * webrtc/video-replace-track-to-null-expected.txt: Added. * webrtc/video-replace-track-to-null.html: Added. Canonical link: https://commits.webkit.org/186982@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@214357 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-03-24 18:01:18 +00:00
</script>
</body>
</html>