Using Multiple USB Cameras with RTC Web

I want to use several USB cameras with web RTC.

For ex) https://apprtc.appspot.com/?r=93443359

This application is a sample web RTC. I can connect to another machine, but I need to disconnect once to change the camera.

What I want,

1. Use one camera at a time on one screen. 2. (if 1 is not possible), I want to switch the camera without disconnecting the current connection

Does anyone have any info on how to use two cameras on web RTC?

+4
source share
2 answers

call getUserMedia twice and change the camera input between

+3
source

You can use restrictions to specify which camera to use, and you can display both of them on the same page. To indicate which camera to use, see the following snippet (works only on Chrome 30+):

getUserMedia({ video: { mandatory: { sourceId: webcamId, ... } }, successCallback, failCallback); 

webcamId you can get:

 MediaStreamTrack.getSources(function(sources){ var cams = _.filter(sources, function(e){ //only return video elements return e.kind === 'video'; }); var camIds = _.map(cams, function (e) { // return only ids return e.id; }); }); 

In the above snippet, I used the underscore filter and map methods.

Additional information on:

+4
source

All Articles