How to access RemoteParticipant video stream in webRTC, while using Twilio Video API

411 views Asked by At

I am using TwilioVideo for video calling in a webapp. I am trying to record remoteParticipant audio and video and store it in a local drive.

Here is a link to my sample app, you can open two browser windows with the same url & provide two different userNames, but same roomName and connect.

After the video call is established through Twilio API between local and remote participants, I tried obtaining the remoteMediaStreams using the below method but I get undefined. Can someone please advise how I can obtain remoteParticiant stream (audio + video).

window.RTCPeerConnection.getRemoteStreams -> undefined

1

There are 1 answers

2
philnash On

Twilio developer evangelist here.

The RTCPeerConnection class doesn't have a getRemoteStreams function, which is why that is undefined.

Instances of RTCPeerConnection may have a getRemoteStreams function, but in this application you do not have direct access to the instance of the RTCPeerConnection object being used by the Twilio Video SDK, so you can't call on it. Also, getRemoteStreams is also non-standard and deprecated in favour of getReceivers.

It looks like you are using this Twilio Video example application. To get hold of the remote streams you will need to hook into the room's participants and their audio and video tracks. I recommend you take a look through the various components and hooks in the application to understand how to access the media streams for each of the participants.