|
|
@@ -7,6 +7,7 @@ var RTCPeerConnection = null;
|
|
7
|
7
|
var nickname = null;
|
|
8
|
8
|
var sharedKey = '';
|
|
9
|
9
|
var roomUrl = null;
|
|
|
10
|
+var ssrc2jid = {};
|
|
10
|
11
|
|
|
11
|
12
|
window.onbeforeunload = closePageWarning;
|
|
12
|
13
|
|
|
|
@@ -114,12 +115,31 @@ $(document).bind('remotestreamadded.jingle', function (event, data, sid) {
|
|
114
|
115
|
}
|
|
115
|
116
|
}
|
|
116
|
117
|
var sess = connection.jingle.sessions[sid];
|
|
|
118
|
+
|
|
|
119
|
+ // look up an associated JID for a stream id
|
|
|
120
|
+ if (data.stream.id.indexOf('mixedmslabel') == -1) {
|
|
|
121
|
+ var ssrclines = SDPUtil.find_lines(sess.peerconnection.remoteDescription.sdp, 'a=ssrc');
|
|
|
122
|
+ ssrclines = ssrclines.filter(function (line) {
|
|
|
123
|
+ return line.indexOf('mslabel:' + data.stream.label) != -1;
|
|
|
124
|
+ })
|
|
|
125
|
+ if (ssrclines.length) {
|
|
|
126
|
+ thessrc = ssrclines[0].substring(7).split(' ')[0];
|
|
|
127
|
+ // ok to overwrite the one from focus? might save work in colibri.js
|
|
|
128
|
+ console.log('associated jid', ssrc2jid[thessrc], data.peerjid);
|
|
|
129
|
+ if (ssrc2jid[thessrc]) {
|
|
|
130
|
+ data.peerjid = ssrc2jid[thessrc];
|
|
|
131
|
+ }
|
|
|
132
|
+ }
|
|
|
133
|
+ }
|
|
|
134
|
+
|
|
117
|
135
|
var vid = document.createElement('video');
|
|
118
|
136
|
// FIXME: the span should not be created here but on muc join
|
|
119
|
137
|
var span = document.createElement('span');
|
|
120
|
138
|
if (data.peerjid) {
|
|
121
|
139
|
// FIXME: how to name this span? data.peerjid is not set for jingle clients
|
|
122
|
140
|
span.id = 'participant_' + Strophe.getResourceFromJid(data.peerjid);
|
|
|
141
|
+ } else if (data.stream.id != 'mixedmslabel') {
|
|
|
142
|
+ console.warn('can not associate stream', data.stream.id, 'with a participant');
|
|
123
|
143
|
}
|
|
124
|
144
|
span.className = 'videocontainer';
|
|
125
|
145
|
var id = 'remoteVideo_' + sid + '_' + data.stream.id;
|
|
|
@@ -191,6 +211,29 @@ $(document).bind('callterminated.jingle', function (event, sid, reason) {
|
|
191
|
211
|
// FIXME
|
|
192
|
212
|
});
|
|
193
|
213
|
|
|
|
214
|
+$(document).bind('setLocalDescription.jingle', function (event, sid) {
|
|
|
215
|
+ // put our ssrcs into presence so other clients can identify our stream
|
|
|
216
|
+ var sess = connection.jingle.sessions[sid];
|
|
|
217
|
+ var newssrcs = {};
|
|
|
218
|
+ var localSDP = new SDP(sess.peerconnection.localDescription.sdp);
|
|
|
219
|
+ localSDP.media.forEach(function (media) {
|
|
|
220
|
+ var type = SDPUtil.parse_mline(media.split('\r\n')[0]).media;
|
|
|
221
|
+ var ssrc = SDPUtil.find_line(media, 'a=ssrc:').substring(7).split(' ')[0];
|
|
|
222
|
+ // assumes a single local ssrc
|
|
|
223
|
+ newssrcs[type] = ssrc;
|
|
|
224
|
+ });
|
|
|
225
|
+ console.log('new ssrcs', newssrcs);
|
|
|
226
|
+ // just blast off presence for everything -- TODO: optimize
|
|
|
227
|
+ var pres = $pres({to: connection.emuc.myroomjid });
|
|
|
228
|
+ pres.c('x', {xmlns: 'http://jabber.org/protocol/muc'}).up();
|
|
|
229
|
+
|
|
|
230
|
+ pres.c('media', {xmlns: 'http://estos.de/ns/mjs'});
|
|
|
231
|
+ Object.keys(newssrcs).forEach(function (mtype) {
|
|
|
232
|
+ pres.c('source', {type: mtype, ssrc: newssrcs[mtype]}).up();
|
|
|
233
|
+ });
|
|
|
234
|
+ pres.up();
|
|
|
235
|
+ connection.send(pres);
|
|
|
236
|
+});
|
|
194
|
237
|
|
|
195
|
238
|
$(document).bind('joined.muc', function (event, jid, info) {
|
|
196
|
239
|
updateRoomUrl(window.location.href);
|
|
|
@@ -203,7 +246,7 @@ $(document).bind('joined.muc', function (event, jid, info) {
|
|
203
|
246
|
}
|
|
204
|
247
|
});
|
|
205
|
248
|
|
|
206
|
|
-$(document).bind('entered.muc', function (event, jid, info) {
|
|
|
249
|
+$(document).bind('entered.muc', function (event, jid, info, pres) {
|
|
207
|
250
|
console.log('entered', jid, info);
|
|
208
|
251
|
console.log(focus);
|
|
209
|
252
|
|
|
|
@@ -220,6 +263,10 @@ $(document).bind('entered.muc', function (event, jid, info) {
|
|
220
|
263
|
else if (sharedKey) {
|
|
221
|
264
|
updateLockButton();
|
|
222
|
265
|
}
|
|
|
266
|
+ $(pres).find('>media[xmlns="http://estos.de/ns/mjs"]>source').each(function (idx, ssrc) {
|
|
|
267
|
+ //console.log(jid, 'assoc ssrc', ssrc.getAttribute('type'), ssrc.getAttribute('ssrc'));
|
|
|
268
|
+ ssrc2jid[ssrc.getAttribute('ssrc')] = jid;
|
|
|
269
|
+ });
|
|
223
|
270
|
});
|
|
224
|
271
|
|
|
225
|
272
|
$(document).bind('left.muc', function (event, jid) {
|
|
|
@@ -265,6 +312,11 @@ $(document).bind('passwordrequired.muc', function (event, jid) {
|
|
265
|
312
|
}
|
|
266
|
313
|
}
|
|
267
|
314
|
});
|
|
|
315
|
+$(document).bind('presence.muc', function (event, jid, info, pres) {
|
|
|
316
|
+ $(pres).find('>media[xmlns="http://estos.de/ns/mjs"]>source').each(function (idx, ssrc) {
|
|
|
317
|
+ //console.log(jid, 'assoc ssrc', ssrc.getAttribute('type'), ssrc.getAttribute('ssrc'));
|
|
|
318
|
+ ssrc2jid[ssrc.getAttribute('ssrc')] = jid;
|
|
|
319
|
+ });
|
|
268
|
320
|
});
|
|
269
|
321
|
|
|
270
|
322
|
function toggleVideo() {
|