2017-09-25 23:23:27 +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="video1" autoplay=""></video>
|
|
|
|
<video id="video2" 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 testImage(video)
|
|
|
|
{
|
|
|
|
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;
|
|
|
|
|
|
|
|
var index = 20;
|
|
|
|
assert_true(data[index] < 100);
|
|
|
|
assert_true(data[index + 1] < 100);
|
|
|
|
assert_true(data[index + 2] < 100);
|
|
|
|
|
|
|
|
index = 80;
|
|
|
|
assert_true(data[index] > 200);
|
|
|
|
assert_true(data[index + 1] > 200);
|
|
|
|
assert_true(data[index + 2] > 200);
|
|
|
|
|
|
|
|
index += 80;
|
|
|
|
assert_true(data[index] > 200);
|
|
|
|
assert_true(data[index + 1] > 200);
|
|
|
|
assert_true(data[index + 2] < 100);
|
|
|
|
}
|
|
|
|
|
|
|
|
promise_test((test) => {
|
|
|
|
if (window.testRunner)
|
|
|
|
testRunner.setUserMediaPermission(true);
|
|
|
|
|
|
|
|
var stream;
|
Mock video devices should only support discrete sizes
https://bugs.webkit.org/show_bug.cgi?id=189000
<rdar://problem/43766551>
Reviewed by Youenn Fablet.
Source/WebCore:
While many/most video capture devices only support a finite number of discrete width/height
pairs, our mock video capture devices supported arbitrary width and height combinations which
made it difficult to write realistic tests using them. Change the mock devices to support
finite "presets" like those supported by AVFoundation. Create a RealtimeVideoSource base
class with support for these presets, so the same code will eventually be used by the mock
and real capture devices.
No new tests, existing tests updated for these changes.
* Sources.txt: Add RealtimeVideoSource.cpp, remove MockRealtimeMediaSource.cpp.
* WebCore.xcodeproj/project.pbxproj: Ditto.
* platform/mediastream/MediaConstraints.h: Deal with min constraint less than the supported minimum
and max larger than the supported maximum when there is no ideal.
* platform/mediastream/RealtimeMediaSource.cpp:
(WebCore::RealtimeMediaSource::selectSettings): Use supportsSizeAndFrameRate for widths,
heights, and framerates in advanced constraints so a width and height that are supported but
in the same preset are filtered out.
(WebCore::RealtimeMediaSource::setSize): New.
* platform/mediastream/RealtimeMediaSource.h:
* platform/mediastream/RealtimeMediaSourceSettings.h: Remove an unneeded include.
* platform/mediastream/RealtimeVideoSource.cpp: Added.
(WebCore::RealtimeVideoSource::RealtimeVideoSource):
(WebCore::RealtimeVideoSource::~RealtimeVideoSource):
(WebCore::RealtimeVideoSource::startProducingData):
(WebCore::RealtimeVideoSource::setSupportedFrameRates):
(WebCore::RealtimeVideoSource::addSupportedCapabilities const):
(WebCore::RealtimeVideoSource::supportsSizeAndFrameRate):
(WebCore::RealtimeVideoSource::bestSupportedCaptureSizeForWidthAndHeight):
(WebCore::RealtimeVideoSource::applySize):
(WebCore::RealtimeVideoSource::applySizeAndFrameRate):
(WebCore::RealtimeVideoSource::videoSampleAvailable):
(WebCore::RealtimeVideoSource::applyFrameRate):
(WebCore::RealtimeVideoSource::supportsFrameRate):
* platform/mediastream/RealtimeVideoSource.h: Copied from Source/WebCore/platform/mock/MockRealtimeAudioSource.h.
(WebCore::RealtimeVideoSource::setSupportedCaptureSizes):
(WebCore::RealtimeVideoSource::setDefaultSize):
(WebCore::RealtimeVideoSource::observedFrameRate const):
* platform/mediastream/mac/AVMediaCaptureSource.mm:
(WebCore::AVMediaCaptureSource::initializeSettings): Don't set label, it isn't used.
* platform/mediastream/mac/MockRealtimeVideoSourceMac.mm:
(WebCore::MockRealtimeVideoSourceMac::applySize): Call the base class.
* platform/mock/MockMediaDevice.h:
(WebCore::MockCameraProperties::encode const): Add frame rates, sizes, and facing mode.
(WebCore::MockCameraProperties::decode): Ditto.
* platform/mock/MockRealtimeAudioSource.cpp:
(WebCore::MockRealtimeAudioSource::MockRealtimeAudioSource): No more MockRealtimeMediaSource.
(WebCore::MockRealtimeAudioSource::settings const): Clean up.
(WebCore::MockRealtimeAudioSource::capabilities const): Ditto.
(WebCore::MockRealtimeAudioSource::settingsDidChange): Ditto.
(WebCore::MockRealtimeAudioSource::stopProducingData): m_elapsedTime isn't used, delete it.
(WebCore::MockRealtimeAudioSource::updateSettings): Deleted.
(WebCore::MockRealtimeAudioSource::initializeCapabilities): Deleted.
(WebCore::MockRealtimeAudioSource::initializeSupportedConstraints): Deleted.
(WebCore::MockRealtimeAudioSource::elapsedTime): Deleted.
* platform/mock/MockRealtimeAudioSource.h:
* platform/mock/MockRealtimeMediaSourceCenter.cpp: Moved all of the mock device management
code from MockRealtimeMediaSource.cpp here.
(WebCore::defaultDevices):
(WebCore::devices):
(WebCore::deviceMap):
(WebCore::deviceListForDevice):
(WebCore::createCaptureDevice):
(WebCore::MockRealtimeMediaSourceCenter::resetDevices):
(WebCore::MockRealtimeMediaSourceCenter::setDevices):
(WebCore::MockRealtimeMediaSourceCenter::addDevice):
(WebCore::MockRealtimeMediaSourceCenter::removeDevice):
(WebCore::MockRealtimeMediaSourceCenter::mockDeviceWithPersistentID):
(WebCore::MockRealtimeMediaSourceCenter::captureDeviceWithPersistentID):
(WebCore::MockRealtimeMediaSourceCenter::audioDevices):
(WebCore::MockRealtimeMediaSourceCenter::videoDevices):
(WebCore::MockRealtimeMediaSourceCenter::displayDevices):
* platform/mock/MockRealtimeVideoSource.cpp:
(WebCore::MockRealtimeVideoSource::MockRealtimeVideoSource): Use RealtimeVideoSource, no
more MockRealtimeMediaSource.
(WebCore::MockRealtimeVideoSource::capabilities const): Ditto, cleanup.
(WebCore::MockRealtimeVideoSource::settings const): Ditto.
(WebCore::MockRealtimeVideoSource::settingsDidChange): Ditto.
(WebCore::MockRealtimeVideoSource::startCaptureTimer): Ditto.
(WebCore::MockRealtimeVideoSource::startProducingData): Ditto.
(WebCore::MockRealtimeVideoSource::stopProducingData): Ditto.
(WebCore::MockRealtimeVideoSource::elapsedTime): Ditto.
(WebCore::MockRealtimeVideoSource::applySize): Ditto.
(WebCore::MockRealtimeVideoSource::drawText): Render the actual frame rate.
(WebCore::MockRealtimeVideoSource::generateFrame): Use m_fillColor.
(WebCore::MockRealtimeVideoSource::~MockRealtimeVideoSource): Deleted.
(WebCore::MockRealtimeVideoSource::updateSettings): Deleted.
(WebCore::MockRealtimeVideoSource::initializeCapabilities): Deleted.
(WebCore::MockRealtimeVideoSource::initializeSupportedConstraints): Deleted.
(WebCore::MockRealtimeVideoSource::applyFrameRate): Deleted.
* platform/mock/MockRealtimeVideoSource.h:
(WebCore::MockRealtimeVideoSource::updateSampleBuffer): Deleted.
Source/WebKit:
* UIProcess/WebProcessPool.cpp:
(WebKit::WebProcessPool::resetMockMediaDevices):
* WebProcess/WebProcess.cpp:
(WebKit::WebProcess::resetMockMediaDevices):
LayoutTests:
Updated tests and results now that we have better support for width and height constraints.
* fast/mediastream/MediaDevices-getUserMedia.html:
* fast/mediastream/MediaStreamTrack-getCapabilities-expected.txt:
* fast/mediastream/apply-constraints-advanced-expected.txt:
* fast/mediastream/apply-constraints-advanced.html:
* fast/mediastream/apply-constraints-video-expected.txt:
* fast/mediastream/apply-constraints-video.html:
* fast/mediastream/getUserMedia-default-expected.txt:
* fast/mediastream/getUserMedia-default.html:
* imported/w3c/web-platform-tests/mediacapture-streams/MediaStreamTrack-getSettings.https-expected.txt:
* webrtc/video-interruption.html:
* webrtc/video.html:
Canonical link: https://commits.webkit.org/204164@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@235513 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-08-30 19:03:55 +00:00
|
|
|
return navigator.mediaDevices.getUserMedia({video: {advanced: [{width:{min:640}}, {height:{min:480} } ]}}).then((stream) => {
|
2017-09-25 23:23:27 +00:00
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
createConnections((firstConnection) => {
|
|
|
|
var track = stream.getVideoTracks()[0];
|
|
|
|
firstConnection.addTrack(stream.getVideoTracks()[0], stream);
|
|
|
|
}, (secondConnection) => {
|
|
|
|
secondConnection.ontrack = (trackEvent) => {
|
|
|
|
assert_true(trackEvent.track instanceof MediaStreamTrack);
|
|
|
|
assert_true(trackEvent.receiver instanceof RTCRtpReceiver);
|
|
|
|
assert_true(Array.isArray(trackEvent.streams), "Array.isArray() should return true");
|
|
|
|
assert_true(Object.isFrozen(trackEvent.streams), "Object.isFrozen() should return true");
|
|
|
|
assert_equals(trackEvent.track.id, stream.getVideoTracks()[0].id);
|
|
|
|
assert_equals(trackEvent.track, trackEvent.streams[0].getVideoTracks()[0]);
|
|
|
|
resolve(trackEvent.streams[0]);
|
|
|
|
};
|
|
|
|
});
|
|
|
|
setTimeout(() => reject("Test timed out"), 5000);
|
|
|
|
});
|
|
|
|
}).then((s) => {
|
|
|
|
stream = s;
|
|
|
|
video1.srcObject = stream;
|
|
|
|
return video1.play();
|
|
|
|
}).then(() => {
|
|
|
|
testImage(video1);
|
|
|
|
}).then(() => {
|
|
|
|
internals.beginMediaSessionInterruption('EnteringBackground');
|
|
|
|
}).then(() => {
|
|
|
|
internals.endMediaSessionInterruption('');
|
|
|
|
}).then(() => {
|
|
|
|
video2.srcObject = stream;
|
|
|
|
return video2.play();
|
|
|
|
}).then(() => {
|
|
|
|
testImage(video2);
|
|
|
|
});
|
|
|
|
}, "Basic video exchange with media session interruption");
|
|
|
|
</script>
|
|
|
|
</body>
|
|
|
|
</html>
|