Media Streams and Codecs — Vocabulary
5 exercises — 5 exercises practising MediaStream, codec negotiation, simulcast, screen capture, and WebRTC media vocabulary.
0 / 5 completed
1 / 5
A developer explains: "We get the user's camera and microphone using getUserMedia()." What does this function return and what are constraints?
getUserMedia() is the gateway to device media in WebRTC — it returns a MediaStream and lets you specify quality and device preferences via constraints.
Example call: const stream = await navigator.mediaDevices.getUserMedia({ video: { width: { ideal: 1280 }, height: { ideal: 720 }, facingMode: 'user' }, audio: { echoCancellation: true, noiseSuppression: true } }). The constraints are hints, not hard requirements — the browser selects the closest available option. The returned MediaStream contains separate tracks: one video MediaStreamTrack and one audio MediaStreamTrack. Each track can be added to an RTCPeerConnection individually (pc.addTrack(track, stream)) for transmission.
Key vocabulary:
• getUserMedia() — browser API requesting camera/microphone access; returns MediaStream
• MediaStreamTrack — a single audio or video track within a MediaStream; can be enabled/disabled independently
• constraints — video/audio quality and device preferences passed to getUserMedia; treated as hints by the browser
Example call: const stream = await navigator.mediaDevices.getUserMedia({ video: { width: { ideal: 1280 }, height: { ideal: 720 }, facingMode: 'user' }, audio: { echoCancellation: true, noiseSuppression: true } }). The constraints are hints, not hard requirements — the browser selects the closest available option. The returned MediaStream contains separate tracks: one video MediaStreamTrack and one audio MediaStreamTrack. Each track can be added to an RTCPeerConnection individually (pc.addTrack(track, stream)) for transmission.
Key vocabulary:
• getUserMedia() — browser API requesting camera/microphone access; returns MediaStream
• MediaStreamTrack — a single audio or video track within a MediaStream; can be enabled/disabled independently
• constraints — video/audio quality and device preferences passed to getUserMedia; treated as hints by the browser