Open pastissolo opened 10 years ago
You should try a similar demo!
// initiator's session
var initiator = new RTCMultiConnection();
// initiator will share both audio and video!
initiator.session = {
audio: true,
video: true
};
initiator.transmitRoomOnce = true;
initiator.open();
// this is participant's code
var participant = new RTCMultiConnection();
participant.onNewSession = function (session) {
// participant will join with only audio!
session.join({
audio: true
});
};
participant.connect();
This example is many-to-many
i.e. audio will be shared among all "interconnected" users; and all participants will receive video from initiator.
????
sorry, pheraps i am confused....
the method
-connect()
has to be called from both initiator and participant to set up the signaling channel.
if i don't i can see the peers can't comunicate;
if i do ( i added initiator.connect() at the end of your first block of code) what happens is that initiator capture his own audio and video and share it with participant, participant, on the other hand, capture his own audio but it does not share it with initiator.
ps: i am using websocket
No. NEVER!
This method initializes RTCMultiSession
object; which is the backbone object used to handle everything in RTCMultiConnection.
On constructor invocation of RTCMultiSession
object, it (i.e. RTCMultiSession
) tries to connect with signaling-server.
That's why it is said that "connect" method connect with signaling server!
Both "open" and "join" do the same job! Both initializes RTCMultiSession
which (i.e. RTCMultiSession
), on constructor invocation, quickly tries to connect with signaling server.
Difference between "open" and "connect" is that "open" method do two especial things for you:
Room-description is what passed over onNewSession
event.
Because you're using transmitRoomOnce
which transmits room-description as soon as it is created; however transmits just once. So, newcomers or late-viewers can't see/access those room-descriptions.
var initiator = new RTCMultiConnection('channel-id');
// initiator will share both audio and video!
initiator.session = {
audio: true,
video: true
};
// don't need to call "connect" here
// it will be redundant
// though it will NOT affect the code!
initiator.open();
// this is participant's code
var participant = new RTCMultiConnection('channel-id');
// this object stores "room-descriptions" to make sure
// duplicate descriptions are not passed over "onNewSession" event handler
var listOfRoomDescriptions = {};
participant.onNewSession = function (roomDescription) {
if (listOfRoomDescriptions[roomDescription.sessionid]) return;
listOfRoomDescriptions[roomDescription.sessionid] = roomDescription;
// participant will join with only audio!
roomDescription.join({
audio: true
});
};
participant.connect();
Hi, i am trying to set up a project for video assistance, audio comunication should be both ways, video comunication should be only one way, from one peer to other(s).
i found that impossible to do; in my code, video and audio comunication both ways work perfectly; than i changed into :
This way:
i found that offers to receive audio and video are setted by default the same as getusermedia capture options:
so i forced sdpConstraints:
it is commented on the code above inside onNewSession().
but this way the behaviour is odd:
do you have any idea?