Multiple camera

shows code to list devices target a device
should janus be modified to support selecting a device or having multiple cameras ?

function start() {
if (window.stream) {
window.stream.getTracks().forEach(track => {
track.stop();
});
}
const audioSource = audioInputSelect.value;
const videoSource = videoSelect.value;
const constraints = {
audio: {deviceId: audioSource ? {exact: audioSource} : undefined},
video: {deviceId: videoSource ? {exact: videoSource} : undefined}
};
navigator.mediaDevices.getUserMedia(constraints).then(gotStream).then(gotDevices).catch(handleError);
}

The new janus.js has a tracks array you can use to capture multiple things:

It depends on the plugin you want to use on whether you can actually use more than one, though.

2 Likes

hi thx for the reply
tests show only one video can be rendered at a time

i found → stackoverflow.com/questions/22787549/accessing-multiple-camera-javascript-getusermedia

a snip

function start() {
if (window.stream) {
window.stream.getTracks().forEach(track => {
track.stop();
});
}
const audioSource = audioInputSelect.value;
const videoSource = did1;
// const videoSource = videoSelect.value;
console.log('selected device ’ + videoSource);
const constraints = {
// audio: {deviceId: audioSource ? {exact: audioSource} : undefined},
// audio: false,
video: {deviceId: videoSource ? {exact: videoSource} : undefined}
};

if (did1.length > 0){

// navigator.mediaDevices.getUserMedia(constraints).then(gotStream).then(gotDevices).catch(handleError);
navigator.mediaDevices.getUserMedia(constraints).then(gotStream).catch(handleError);
}
const videoSource3 = did2;
console.log('selected device3 ’ + videoSource3);
const constraints3 = {
//audio: {deviceId: audioSource ? {exact: audioSource} : undefined},
// audio: false,
video: {deviceId: videoSource3 ? {exact: videoSource3} : undefined}
};

if (did2.length > 0){
navigator.mediaDevices.getUserMedia(constraints3).then(gotStream3).catch(handleError);
}

Can two cameras be captured and streamed at the same time ?

Yes, please see my previous answer.

I found the sample , it works !
https://webrtc.github.io/test-pages/