Is it possible to stream from multiple camera device at once using WebRTC

620 views Asked by At

i've implement webRTC conference call concept in my project, now i want to stream from dual camera at a same time, like my room contain 10 user including staff others are students, if staff want to show their back camera for only one student, but other students should watch staff's face from front camera at a same time,

above concept is possible in webRTC, if yes kindly share your thoughts and share your sample codes to achieve this, if not possible in webRTC is that available in any other third party video conference API providers ?

Here i attach my conference webRTC source code,

   var all_videotab = [];
function createPeer(userIdToCall) {
    const peer = new RTCPeerConnection({
        iceServers: [
            {
               urls: [
                 "******",
               ],
               username: "****",
               credential: "*****"
            },
            {
              urls: [
                "******"
              ]
            }
        ]
    });
    peer.onnegotiationneeded = () => userIdToCall ? handleNegotiationNeededEvent(peer, userIdToCall) : null;
    peer.onicecandidate = handleICECandidateEvent;
    peer.ontrack = (e) => {
        if(!all_videotab.includes(userIdToCall)) {
            const container = document.createElement('div');
            container.classList.add('remote-video-container');
            const video = document.createElement('video');
            video.srcObject = e.streams[0];
            video.autoplay = true;
            video.playsInline = true;
            video.classList.add("remote-video");
            container.appendChild(video);
            if (isAdmin) {
                const button = document.createElement("button");
                button.innerHTML = `Hide user's cam`;
                button.classList.add('button');
                button.setAttribute('user-id', userIdToCall);
                container.appendChild(button);
            }
            all_videotab.push(userIdToCall);
            container.id = userIdToCall;
            remoteVideoContainer.appendChild(container);
        }
        
    }
    return peer;
}

Hope i'll get worthy solution from this community,

0

There are 0 answers