webrtcscreensharingsimplewebrtcvideocall

Differentiate between screen share track and camera track in a normal webrtc


Is there any way to differentiate between screen share track and camera track in a webrtc video call?

I am able to add both video tracks(camera as well as screen share track) using proper negotiation event.But,I cannot differentiate these 2 tracks (Since they both have property of kind video and their id seems to be randomly generated and is different to the id of actual owner of the track )

I also went through couples of few similar questions that suggested the following things:

1.Differentiating using their ID.

This solution did not work for me because as soon as i will re-share my screen(after stop sharing and then sharing again),a new id will be assigned to the track coming from resharing.

2.Differentiating using transceiver.mid property

This too did not seem to work because while turning off the camera,camera track is removed from the peer instance(to save the bandwidth) and is added back when turning on the camera.This calls ontrack event on the remote side in which track has different transceiver.mid property(not same as what mid property previous camera track had)

In addition,I cannot assign any extra property to the stream obtained from getUserMedia api.track object seems to be immutable.

Please suggest a method which i can use to differentiate these 2 tracks.

Thanks


Solution

  • Based on my Observation, I think you have the following options to make it possible: