haikuwebkit/LayoutTests/webrtc/video-remote-mute.html

66 lines
2.1 KiB
HTML
Raw Permalink Normal View History

Improve WebRTC track enabled support https://bugs.webkit.org/show_bug.cgi?id=169727 Patch by Youenn Fablet <youenn@apple.com> on 2017-03-16 Reviewed by Alex Christensen. Source/WebCore: Tests: webrtc/peer-connection-audio-mute2.html webrtc/peer-connection-remote-audio-mute.html webrtc/video-remote-mute.html Making sure muted/disabled sources produce silence/black frames. For outgoing audio/video sources, this should be done by the actual a/v providers. We keep this filtering here until we are sure they implement that. * platform/audio/mac/AudioSampleDataSource.mm: (WebCore::AudioSampleDataSource::pullAvalaibleSamplesAsChunks): Ensuring disabled audio tracks send silence. Used for outgoing webrtc tracks. * platform/mediastream/mac/MockRealtimeAudioSourceMac.mm: (WebCore::MockRealtimeAudioSourceMac::render): Ditto. * platform/mediastream/mac/RealtimeIncomingAudioSource.cpp: (WebCore::RealtimeIncomingAudioSource::OnData): Ditto. * platform/mediastream/mac/RealtimeIncomingVideoSource.cpp: (WebCore::RealtimeIncomingVideoSource::pixelBufferFromVideoFrame): Generating black frames if muted. (WebCore::RealtimeIncomingVideoSource::OnFrame): * platform/mediastream/mac/RealtimeIncomingVideoSource.h: * platform/mediastream/mac/RealtimeOutgoingVideoSource.cpp: (WebCore::RealtimeOutgoingVideoSource::videoSampleAvailable): Ensuring we quit after sending black frame. LayoutTests: * TestExpectations: * webrtc/audio-peer-connection-webaudio.html: * webrtc/peer-connection-audio-mute-expected.txt: * webrtc/peer-connection-audio-mute.html: * webrtc/peer-connection-audio-mute2-expected.txt: Added. * webrtc/peer-connection-audio-mute2.html: Added. * webrtc/peer-connection-remote-audio-mute-expected.txt: Added. * webrtc/peer-connection-remote-audio-mute.html: Added. * webrtc/video-mute-expected.txt: * webrtc/video-mute.html: * webrtc/video-remote-mute-expected.txt: Added. * webrtc/video-remote-mute.html: Added. Canonical link: https://commits.webkit.org/186716@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@214044 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-03-16 16:09:50 +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>
<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");
function isVideoBlack()
{
canvas.width = video.videoWidth;
canvas.height = video.videoHeight;
canvas.getContext('2d').drawImage(video, 0, 0, canvas.width, canvas.height);
imageData = canvas.getContext('2d').getImageData(10, 325, 250, 1);
data = imageData.data;
for (var cptr = 0; cptr < canvas.width * canvas.height; ++cptr) {
if (data[4 * cptr] || data[4 * cptr + 1] || data[4 * cptr + 2])
return false;
}
return true;
}
var track;
promise_test((test) => {
if (window.testRunner)
testRunner.setUserMediaPermission(true);
return navigator.mediaDevices.getUserMedia({ video: true}).then((localStream) => {
return new Promise((resolve, reject) => {
createConnections((firstConnection) => {
firstConnection.addTrack(localStream.getVideoTracks()[0], localStream);
Improve WebRTC track enabled support https://bugs.webkit.org/show_bug.cgi?id=169727 Patch by Youenn Fablet <youenn@apple.com> on 2017-03-16 Reviewed by Alex Christensen. Source/WebCore: Tests: webrtc/peer-connection-audio-mute2.html webrtc/peer-connection-remote-audio-mute.html webrtc/video-remote-mute.html Making sure muted/disabled sources produce silence/black frames. For outgoing audio/video sources, this should be done by the actual a/v providers. We keep this filtering here until we are sure they implement that. * platform/audio/mac/AudioSampleDataSource.mm: (WebCore::AudioSampleDataSource::pullAvalaibleSamplesAsChunks): Ensuring disabled audio tracks send silence. Used for outgoing webrtc tracks. * platform/mediastream/mac/MockRealtimeAudioSourceMac.mm: (WebCore::MockRealtimeAudioSourceMac::render): Ditto. * platform/mediastream/mac/RealtimeIncomingAudioSource.cpp: (WebCore::RealtimeIncomingAudioSource::OnData): Ditto. * platform/mediastream/mac/RealtimeIncomingVideoSource.cpp: (WebCore::RealtimeIncomingVideoSource::pixelBufferFromVideoFrame): Generating black frames if muted. (WebCore::RealtimeIncomingVideoSource::OnFrame): * platform/mediastream/mac/RealtimeIncomingVideoSource.h: * platform/mediastream/mac/RealtimeOutgoingVideoSource.cpp: (WebCore::RealtimeOutgoingVideoSource::videoSampleAvailable): Ensuring we quit after sending black frame. LayoutTests: * TestExpectations: * webrtc/audio-peer-connection-webaudio.html: * webrtc/peer-connection-audio-mute-expected.txt: * webrtc/peer-connection-audio-mute.html: * webrtc/peer-connection-audio-mute2-expected.txt: Added. * webrtc/peer-connection-audio-mute2.html: Added. * webrtc/peer-connection-remote-audio-mute-expected.txt: Added. * webrtc/peer-connection-remote-audio-mute.html: Added. * webrtc/video-mute-expected.txt: * webrtc/video-mute.html: * webrtc/video-remote-mute-expected.txt: Added. * webrtc/video-remote-mute.html: Added. Canonical link: https://commits.webkit.org/186716@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@214044 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-03-16 16:09:50 +00:00
}, (secondConnection) => {
secondConnection.ontrack = (trackEvent) => { resolve(trackEvent.streams[0]); };
Improve WebRTC track enabled support https://bugs.webkit.org/show_bug.cgi?id=169727 Patch by Youenn Fablet <youenn@apple.com> on 2017-03-16 Reviewed by Alex Christensen. Source/WebCore: Tests: webrtc/peer-connection-audio-mute2.html webrtc/peer-connection-remote-audio-mute.html webrtc/video-remote-mute.html Making sure muted/disabled sources produce silence/black frames. For outgoing audio/video sources, this should be done by the actual a/v providers. We keep this filtering here until we are sure they implement that. * platform/audio/mac/AudioSampleDataSource.mm: (WebCore::AudioSampleDataSource::pullAvalaibleSamplesAsChunks): Ensuring disabled audio tracks send silence. Used for outgoing webrtc tracks. * platform/mediastream/mac/MockRealtimeAudioSourceMac.mm: (WebCore::MockRealtimeAudioSourceMac::render): Ditto. * platform/mediastream/mac/RealtimeIncomingAudioSource.cpp: (WebCore::RealtimeIncomingAudioSource::OnData): Ditto. * platform/mediastream/mac/RealtimeIncomingVideoSource.cpp: (WebCore::RealtimeIncomingVideoSource::pixelBufferFromVideoFrame): Generating black frames if muted. (WebCore::RealtimeIncomingVideoSource::OnFrame): * platform/mediastream/mac/RealtimeIncomingVideoSource.h: * platform/mediastream/mac/RealtimeOutgoingVideoSource.cpp: (WebCore::RealtimeOutgoingVideoSource::videoSampleAvailable): Ensuring we quit after sending black frame. LayoutTests: * TestExpectations: * webrtc/audio-peer-connection-webaudio.html: * webrtc/peer-connection-audio-mute-expected.txt: * webrtc/peer-connection-audio-mute.html: * webrtc/peer-connection-audio-mute2-expected.txt: Added. * webrtc/peer-connection-audio-mute2.html: Added. * webrtc/peer-connection-remote-audio-mute-expected.txt: Added. * webrtc/peer-connection-remote-audio-mute.html: Added. * webrtc/video-mute-expected.txt: * webrtc/video-mute.html: * webrtc/video-remote-mute-expected.txt: Added. * webrtc/video-remote-mute.html: Added. Canonical link: https://commits.webkit.org/186716@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@214044 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-03-16 16:09:50 +00:00
});
setTimeout(() => reject("Test timed out"), 5000);
});
}).then((remoteStream) => {
video.srcObject = remoteStream;
track = remoteStream.getVideoTracks()[0];
return video.play();
}).then(() => {
assert_false(isVideoBlack());
}).then(() => {
track.enabled = false;
return waitFor(500);
}).then(() => {
assert_true(isVideoBlack());
track.enabled = true;
return waitFor(500);
}).then(() => {
assert_false(isVideoBlack());
});
}, "Incoming muted/unmuted video track");
</script>
</body>
</html>