muaz-khan / RTCMultiConnection

RTCMultiConnection is a WebRTC JavaScript library for peer-to-peer applications (screen sharing, audio/video conferencing, file sharing, media streaming etc.)
https://muazkhan.com:9001/
MIT License
2.56k stars 1.37k forks source link

Creating a observation room #67

Open Qaisarimran opened 8 years ago

Qaisarimran commented 8 years ago

Am trying to create a private room in which multiple peer can connect to me. But they should be aware of other peers in the room.

Explaination. Any peer join the room should be visible to me only. Peer should only able to see me, not the other peers in the room.

muaz-khan commented 8 years ago

There are two solutions:

1) Oneway broadcast: Demo / Source

2) Set broadcast:true instead of oneway:true in the above demo, and it will become one-to-many instead of oneway.

Ref documentation:

  1. http://www.rtcmulticonnection.org/docs/direction/
  2. http://www.rtcmulticonnection.org/docs/session/
Qaisarimran commented 8 years ago

Thanks Muaz, it work like a charm.

Qaisarimran commented 8 years ago

I have two more questions.

1) Is there any way to to broadcast shared screen and video combined in one window. 2) Is there any way i can get the name of peer connecting to the room

muaz-khan commented 8 years ago

You can share both screen and video in parallel (in both Chrome & Firefox) and adjust the layout/UI to make sure video overlaps screen's bottom-right corner.

Multi-stream sharing can be handled with connection.session object.

connection.session = {
      audio: true,
      video: true,
      screen: true
};

connection.onstream = function(event) {
     if(event.type === 'remote') {
          if(event.isScreen) screenVideo.src = event.blobURL;
          if(event.isVideo) smallVideo.src = event.blobURL;
     }
};

You can get unique-userid of the peer using connection.userid.

You can pass extra data using connection.extra={}. Each even is having event.extra object.

You can directly access native RTCPeerConnection object using following snippet:

var nativePeer = connection.peers['remote-userid'].peer.connection;
nativePeer.getRemoteStreams();
nativePeer.getLocalStreams();
nativePeer.addStream(...);
nativePeer.removeStream(...);
nativePeer.localDescription;
nativePeer.remoteDescription
Qaisarimran commented 8 years ago

How i can close an open room. am using RTCMultiConnection

muaz-khan commented 8 years ago
Experiment Name Demo Source Code
Session Re-initiation Test Demo Source
Qaisarimran commented 8 years ago

Am facing a problem that when i start a room am able to see everyone connecting the room (as am admin), but if my internet disconnect and when i come back i have to join again as a peer.