web real time communication
why webrtc isbnt it ?
used for sharing media in real time over internet but its not enough if the scale is large cuz then you would need to establish n*(n-1) connections for n peers , which makes it consume a large amount of bandwidth and cpu
this is an important part about capturing the media stream like audio video from the user
for capturing user media such as audio and video from mic and camera respectively we use getUserMedia()
const stream = await navigator.mediaDevices.getUserMedia({
video: true,
audio: true
});
this gets the stream from user
for capturing the screen of user instead , use getDisplayMedia()
const screen = await navigator.mediaDevices.getDisplayMedia({
video: true,
audio: true
});
now to add this stream to our rtcpeerconnection we use
const localStream = await getUserMedia({video: true, audio: true});
const peerConnection = new RTCPeerConnection(iceConfig);
localStream.getTracks().forEach(track => {
peerConnection.addTrack(track, localStream);
});