RTCMultiConnection
RTCMultiConnection copied to clipboard
Is there a way detect if remote stream is user sharing their screen?
I tried isScreen flag but it only works in local, for remote this is always coming false.
Connection object is an object with data from the each local peer. I think that's why isScreen flag of remote users is always false.
So, I think you should use extra. when create room, set extra data like this. if(isScreen) { connection.extra.isScreen = true; } else { connection.extra.isScreen = false; }
and when remote user join, they can check this property in event.extra object. connection.onstream = function(event) { var isScreenShare = event.extra.isScreen; }
When you start screen capture for the first user, here we get the id of the screen capture stream and send it to all participants in the room:
connection.addStream({
screen: true,
oneway: true,
data: true,
streamCallback: function(stream) {
connection.extra = {
stream_id: stream.id
};
connection.updateExtraData();
}
});
Text data arrives faster than screen capture, so you can send it inside a callback:
connection.onstream = function(event) {
if (event.type == "remote") {
if (event.stream.id == event.extra.stream_id) {
// here if the stream turned out to be a screen share
} else {
// here is the usual video stream from a webcam
}
}
}