Spaces:
Running
Running
File size: 1,105 Bytes
6bcb42f |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
import getUserMedia from 'get-user-media-promise';
// Single Setup For All Video Streams used by the GUI
// While VideoProvider uses a private _singleSetup
// property to ensure that each instance of a VideoProvider
// use the same setup, this ensures that all instances
// of VideoProviders use a single stream. This way, closing a camera modal
// does not affect the video on the stage, and a program running and disabling
// video on the stage will not affect the camera modal's video.
const requestStack = [];
const requestVideoStream = videoDesc => {
let streamPromise;
if (requestStack.length === 0) {
streamPromise = getUserMedia({
audio: false,
video: videoDesc
});
requestStack.push(streamPromise);
} else if (requestStack.length > 0) {
streamPromise = requestStack[0];
requestStack.push(true);
}
return streamPromise;
};
const requestDisableVideo = () => {
requestStack.pop();
if (requestStack.length > 0) return false;
return true;
};
export {
requestVideoStream,
requestDisableVideo
};
|