Prompt
I'm trying to add screen sharing and recording to a call feature
Latest observation
Nov 2, 2026
OpenAI APIWeb search: off
Sure — screen sharing and call recording are usually added as two separate media features on top of an existing WebRTC/VoIP call stack.
1) Screen sharing
If your call feature uses WebRTC, the usual approach is:
- Get a screen capture stream from the browser/device
- Replace or add that stream to the active peer connection
- Renegotiate if needed
Browser API
Use:
navigator.mediaDevices.getDisplayMedia({ video: true, audio: true })
Typical flow
- User clicks Share Screen
- Browser prompts for screen/window/tab selection
- You receive a media stream
- Send that track through the existing RTCPeerConnection
- Stop sharing when the track ends
Example
const screenStream = await navigator.mediaDevices.getDisplayMedia({
video: true,
audio: true
});
const screenTrack = screenStream.getVideoTracks()[0];
// Replace the existing video track
const sender = pc.getSenders().find(s => s.track && s.track.kind === 'video');
if (sender) {
await sender.replaceTrack(screenTrack);
}
screenTrack.onended = async () => {
// Restore camera when sharing stops
const cameraStream = await navigator.mediaDevices.getUserMedia({ video: true, audio: true });
const cameraTrack = cameraStream.getVideoTracks()[0];
await sender.replaceTrack(cameraTrack);
};
2) Recording
Recording can mean different things:
A. Client-side recording
Record locally in the browser using MediaRecorder.
- Good for saving a local copy
- Easy to implement
- Limited by browser/device support
Example:
const stream = new MediaStream([
...localVideoStream.getTracks(),
...remoteAudioStream.getAudioTracks()
]);
const recorder = new MediaRecorder(stream);
const chunks = [];
recorder.ondataavailable = e => {
if (e.data.size > 0) chunks.push(e.data);
};
recorder.onstop = () => {
const blob = new Blob(chunks, { type: 'video/webm' });
const url = URL.createObjectURL(blob);
const a = document.createElement('a');
a.href = url;
a.download = 'recording.webm';
a.click();
};
recorder.start();
B. Server-side recording
Record on your backend or media server.
- Better for multiparty calls
- More reliable
- Lets you record without depending on browser state
- Common in production apps
This usually requires:
- SFU/MCU media server support, or
- server-side compositing/recording
Examples of platforms/tools:
- Twilio Video
- Daily
- Agora
- LiveKit
- Janus
- Jitsi
- Kurento
3) Important design choice
You need to decide:
- Record only local participant?
- Record everyone?
- Record screen share only?
- Record both camera + screen + audio?
- Store recordings locally or server-side?
4) Common pitfalls
- Screen share audio support varies by browser
getDisplayMedia()requires a user gesture- Some browsers don’t support recording all combined tracks well
- If you’re using a platform like Zoom/Meet-style architecture, recording is usually best on the server
- Mobile support is limited for screen sharing
5) Recommended approach
If this is a production call app:
- Use WebRTC for calls
- Use server-side recording if you need reliable recordings
- Use
getDisplayMedia()for screen sharing - Implement track switching with
replaceTrack()
If you want, I can help you with:
- A React/WebRTC implementation
- A Node.js backend for recording
- A Twilio/Agora/LiveKit-specific solution
- A full working example for screen share + recording