|
|
@@ -23,660 +23,6 @@ function init() {
|
|
23
|
23
|
|
|
24
|
24
|
RTC.start();
|
|
25
|
25
|
xmpp.start(UI.getCreadentials);
|
|
26
|
|
-
|
|
27
|
|
-<<<<<<< HEAD
|
|
28
|
|
-=======
|
|
29
|
|
- var configDomain = config.hosts.anonymousdomain || config.hosts.domain;
|
|
30
|
|
-
|
|
31
|
|
- // Force authenticated domain if room is appended with '?login=true'
|
|
32
|
|
- if (config.hosts.anonymousdomain &&
|
|
33
|
|
- window.location.search.indexOf("login=true") !== -1) {
|
|
34
|
|
- configDomain = config.hosts.domain;
|
|
35
|
|
- }
|
|
36
|
|
-
|
|
37
|
|
- var jid = document.getElementById('jid').value || configDomain || window.location.hostname;
|
|
38
|
|
- connect(jid);
|
|
39
|
|
-}
|
|
40
|
|
-
|
|
41
|
|
-function connect(jid, password) {
|
|
42
|
|
- connection = new Strophe.Connection(document.getElementById('boshURL').value || config.bosh || '/http-bind');
|
|
43
|
|
-
|
|
44
|
|
- var settings = UI.getSettings();
|
|
45
|
|
- var email = settings.email;
|
|
46
|
|
- var displayName = settings.displayName;
|
|
47
|
|
- if(email) {
|
|
48
|
|
- connection.emuc.addEmailToPresence(email);
|
|
49
|
|
- } else {
|
|
50
|
|
- connection.emuc.addUserIdToPresence(settings.uid);
|
|
51
|
|
- }
|
|
52
|
|
- if(displayName) {
|
|
53
|
|
- connection.emuc.addDisplayNameToPresence(displayName);
|
|
54
|
|
- }
|
|
55
|
|
-
|
|
56
|
|
- if (connection.disco) {
|
|
57
|
|
- // for chrome, add multistream cap
|
|
58
|
|
- }
|
|
59
|
|
- connection.jingle.pc_constraints = RTC.getPCConstraints();
|
|
60
|
|
- if (config.useIPv6) {
|
|
61
|
|
- // https://code.google.com/p/webrtc/issues/detail?id=2828
|
|
62
|
|
- if (!connection.jingle.pc_constraints.optional) connection.jingle.pc_constraints.optional = [];
|
|
63
|
|
- connection.jingle.pc_constraints.optional.push({googIPv6: true});
|
|
64
|
|
- }
|
|
65
|
|
-
|
|
66
|
|
- if(!password)
|
|
67
|
|
- password = document.getElementById('password').value;
|
|
68
|
|
-
|
|
69
|
|
- var anonymousConnectionFailed = false;
|
|
70
|
|
- connection.connect(jid, password, function (status, msg) {
|
|
71
|
|
- console.log('Strophe status changed to', Strophe.getStatusString(status));
|
|
72
|
|
- if (status === Strophe.Status.CONNECTED) {
|
|
73
|
|
- if (config.useStunTurn) {
|
|
74
|
|
- connection.jingle.getStunAndTurnCredentials();
|
|
75
|
|
- }
|
|
76
|
|
- document.getElementById('connect').disabled = true;
|
|
77
|
|
-
|
|
78
|
|
- console.info("My Jabber ID: " + connection.jid);
|
|
79
|
|
-
|
|
80
|
|
- if(password)
|
|
81
|
|
- authenticatedUser = true;
|
|
82
|
|
- maybeDoJoin();
|
|
83
|
|
- } else if (status === Strophe.Status.CONNFAIL) {
|
|
84
|
|
- if(msg === 'x-strophe-bad-non-anon-jid') {
|
|
85
|
|
- anonymousConnectionFailed = true;
|
|
86
|
|
- }
|
|
87
|
|
- } else if (status === Strophe.Status.DISCONNECTED) {
|
|
88
|
|
- if(anonymousConnectionFailed) {
|
|
89
|
|
- // prompt user for username and password
|
|
90
|
|
- $(document).trigger('passwordrequired.main');
|
|
91
|
|
- }
|
|
92
|
|
- } else if (status === Strophe.Status.AUTHFAIL) {
|
|
93
|
|
- // wrong password or username, prompt user
|
|
94
|
|
- $(document).trigger('passwordrequired.main');
|
|
95
|
|
-
|
|
96
|
|
- }
|
|
97
|
|
- });
|
|
98
|
|
-}
|
|
99
|
|
-
|
|
100
|
|
-
|
|
101
|
|
-
|
|
102
|
|
-function maybeDoJoin() {
|
|
103
|
|
- if (connection && connection.connected && Strophe.getResourceFromJid(connection.jid) // .connected is true while connecting?
|
|
104
|
|
- && (RTC.localAudio || RTC.localVideo)) {
|
|
105
|
|
- doJoin();
|
|
106
|
|
- }
|
|
107
|
|
-}
|
|
108
|
|
-
|
|
109
|
|
-function doJoin() {
|
|
110
|
|
- if (!roomName) {
|
|
111
|
|
- UI.generateRoomName();
|
|
112
|
|
- }
|
|
113
|
|
-
|
|
114
|
|
- Moderator.allocateConferenceFocus(
|
|
115
|
|
- roomName, doJoinAfterFocus);
|
|
116
|
|
-}
|
|
117
|
|
-
|
|
118
|
|
-function doJoinAfterFocus() {
|
|
119
|
|
-
|
|
120
|
|
- // Close authentication dialog if opened
|
|
121
|
|
- if (authDialog) {
|
|
122
|
|
- UI.messageHandler.closeDialog();
|
|
123
|
|
- authDialog = null;
|
|
124
|
|
- }
|
|
125
|
|
- // Clear retry interval, so that we don't call 'doJoinAfterFocus' twice
|
|
126
|
|
- if (authRetryId) {
|
|
127
|
|
- window.clearTimeout(authRetryId);
|
|
128
|
|
- authRetryId = null;
|
|
129
|
|
- }
|
|
130
|
|
-
|
|
131
|
|
- var roomjid;
|
|
132
|
|
- roomjid = roomName;
|
|
133
|
|
-
|
|
134
|
|
- if (config.useNicks) {
|
|
135
|
|
- var nick = window.prompt('Your nickname (optional)');
|
|
136
|
|
- if (nick) {
|
|
137
|
|
- roomjid += '/' + nick;
|
|
138
|
|
- } else {
|
|
139
|
|
- roomjid += '/' + Strophe.getNodeFromJid(connection.jid);
|
|
140
|
|
- }
|
|
141
|
|
- } else {
|
|
142
|
|
-
|
|
143
|
|
- var tmpJid = Strophe.getNodeFromJid(connection.jid);
|
|
144
|
|
-
|
|
145
|
|
- if(!authenticatedUser)
|
|
146
|
|
- tmpJid = tmpJid.substr(0, 8);
|
|
147
|
|
-
|
|
148
|
|
- roomjid += '/' + tmpJid;
|
|
149
|
|
- }
|
|
150
|
|
- connection.emuc.doJoin(roomjid);
|
|
151
|
|
-}
|
|
152
|
|
-
|
|
153
|
|
-function waitForRemoteVideo(selector, ssrc, stream, jid) {
|
|
154
|
|
- // XXX(gp) so, every call to this function is *always* preceded by a call
|
|
155
|
|
- // to the RTC.attachMediaStream() function but that call is *not* followed
|
|
156
|
|
- // by an update to the videoSrcToSsrc map!
|
|
157
|
|
- //
|
|
158
|
|
- // The above way of doing things results in video SRCs that don't correspond
|
|
159
|
|
- // to any SSRC for a short period of time (to be more precise, for as long
|
|
160
|
|
- // the waitForRemoteVideo takes to complete). This causes problems (see
|
|
161
|
|
- // bellow).
|
|
162
|
|
- //
|
|
163
|
|
- // I'm wondering why we need to do that; i.e. why call RTC.attachMediaStream()
|
|
164
|
|
- // a second time in here and only then update the videoSrcToSsrc map? Why
|
|
165
|
|
- // not simply update the videoSrcToSsrc map when the RTC.attachMediaStream()
|
|
166
|
|
- // is called the first time? I actually do that in the lastN changed event
|
|
167
|
|
- // handler because the "orphan" video SRC is causing troubles there. The
|
|
168
|
|
- // purpose of this method would then be to fire the "videoactive.jingle".
|
|
169
|
|
- //
|
|
170
|
|
- // Food for though I guess :-)
|
|
171
|
|
-
|
|
172
|
|
- if (selector.removed || !selector.parent().is(":visible")) {
|
|
173
|
|
- console.warn("Media removed before had started", selector);
|
|
174
|
|
- return;
|
|
175
|
|
- }
|
|
176
|
|
-
|
|
177
|
|
- if (stream.id === 'mixedmslabel') return;
|
|
178
|
|
-
|
|
179
|
|
- if (selector[0].currentTime > 0) {
|
|
180
|
|
- var videoStream = simulcast.getReceivingVideoStream(stream);
|
|
181
|
|
- RTC.attachMediaStream(selector, videoStream); // FIXME: why do i have to do this for FF?
|
|
182
|
|
-
|
|
183
|
|
- // FIXME: add a class that will associate peer Jid, video.src, it's ssrc and video type
|
|
184
|
|
- // in order to get rid of too many maps
|
|
185
|
|
- if (ssrc && jid) {
|
|
186
|
|
- jid2Ssrc[Strophe.getResourceFromJid(jid)] = ssrc;
|
|
187
|
|
- } else {
|
|
188
|
|
- console.warn("No ssrc given for jid", jid);
|
|
189
|
|
- }
|
|
190
|
|
-
|
|
191
|
|
- $(document).trigger('videoactive.jingle', [selector]);
|
|
192
|
|
- } else {
|
|
193
|
|
- setTimeout(function () {
|
|
194
|
|
- waitForRemoteVideo(selector, ssrc, stream, jid);
|
|
195
|
|
- }, 250);
|
|
196
|
|
- }
|
|
197
|
|
-}
|
|
198
|
|
-
|
|
199
|
|
-$(document).bind('remotestreamadded.jingle', function (event, data, sid) {
|
|
200
|
|
- waitForPresence(data, sid);
|
|
201
|
|
-});
|
|
202
|
|
-
|
|
203
|
|
-function waitForPresence(data, sid) {
|
|
204
|
|
- var sess = connection.jingle.sessions[sid];
|
|
205
|
|
-
|
|
206
|
|
- var thessrc;
|
|
207
|
|
-
|
|
208
|
|
- // look up an associated JID for a stream id
|
|
209
|
|
- if (data.stream.id && data.stream.id.indexOf('mixedmslabel') === -1) {
|
|
210
|
|
- // look only at a=ssrc: and _not_ at a=ssrc-group: lines
|
|
211
|
|
-
|
|
212
|
|
- var ssrclines
|
|
213
|
|
- = SDPUtil.find_lines(sess.peerconnection.remoteDescription.sdp, 'a=ssrc:');
|
|
214
|
|
- ssrclines = ssrclines.filter(function (line) {
|
|
215
|
|
- // NOTE(gp) previously we filtered on the mslabel, but that property
|
|
216
|
|
- // is not always present.
|
|
217
|
|
- // return line.indexOf('mslabel:' + data.stream.label) !== -1;
|
|
218
|
|
-
|
|
219
|
|
- return ((line.indexOf('msid:' + data.stream.id) !== -1));
|
|
220
|
|
- });
|
|
221
|
|
- if (ssrclines.length) {
|
|
222
|
|
- thessrc = ssrclines[0].substring(7).split(' ')[0];
|
|
223
|
|
-
|
|
224
|
|
- // We signal our streams (through Jingle to the focus) before we set
|
|
225
|
|
- // our presence (through which peers associate remote streams to
|
|
226
|
|
- // jids). So, it might arrive that a remote stream is added but
|
|
227
|
|
- // ssrc2jid is not yet updated and thus data.peerjid cannot be
|
|
228
|
|
- // successfully set. Here we wait for up to a second for the
|
|
229
|
|
- // presence to arrive.
|
|
230
|
|
-
|
|
231
|
|
- if (!ssrc2jid[thessrc]) {
|
|
232
|
|
- // TODO(gp) limit wait duration to 1 sec.
|
|
233
|
|
- setTimeout(function(d, s) {
|
|
234
|
|
- return function() {
|
|
235
|
|
- waitForPresence(d, s);
|
|
236
|
|
- }
|
|
237
|
|
- }(data, sid), 250);
|
|
238
|
|
- return;
|
|
239
|
|
- }
|
|
240
|
|
-
|
|
241
|
|
- // ok to overwrite the one from focus? might save work in colibri.js
|
|
242
|
|
- console.log('associated jid', ssrc2jid[thessrc], data.peerjid);
|
|
243
|
|
- if (ssrc2jid[thessrc]) {
|
|
244
|
|
- data.peerjid = ssrc2jid[thessrc];
|
|
245
|
|
- }
|
|
246
|
|
- }
|
|
247
|
|
- }
|
|
248
|
|
-
|
|
249
|
|
- //TODO: this code should be removed when firefox implement multistream support
|
|
250
|
|
- if(RTC.getBrowserType() == RTCBrowserType.RTC_BROWSER_FIREFOX)
|
|
251
|
|
- {
|
|
252
|
|
- if((notReceivedSSRCs.length == 0) ||
|
|
253
|
|
- !ssrc2jid[notReceivedSSRCs[notReceivedSSRCs.length - 1]])
|
|
254
|
|
- {
|
|
255
|
|
- // TODO(gp) limit wait duration to 1 sec.
|
|
256
|
|
- setTimeout(function(d, s) {
|
|
257
|
|
- return function() {
|
|
258
|
|
- waitForPresence(d, s);
|
|
259
|
|
- }
|
|
260
|
|
- }(data, sid), 250);
|
|
261
|
|
- return;
|
|
262
|
|
- }
|
|
263
|
|
-
|
|
264
|
|
- thessrc = notReceivedSSRCs.pop();
|
|
265
|
|
- if (ssrc2jid[thessrc]) {
|
|
266
|
|
- data.peerjid = ssrc2jid[thessrc];
|
|
267
|
|
- }
|
|
268
|
|
- }
|
|
269
|
|
-
|
|
270
|
|
- RTC.createRemoteStream(data, sid, thessrc);
|
|
271
|
|
-
|
|
272
|
|
- var isVideo = data.stream.getVideoTracks().length > 0;
|
|
273
|
|
- // an attempt to work around https://github.com/jitsi/jitmeet/issues/32
|
|
274
|
|
- if (isVideo &&
|
|
275
|
|
- data.peerjid && sess.peerjid === data.peerjid &&
|
|
276
|
|
- data.stream.getVideoTracks().length === 0 &&
|
|
277
|
|
- RTC.localVideo.getTracks().length > 0) {
|
|
278
|
|
- //
|
|
279
|
|
- window.setTimeout(function () {
|
|
280
|
|
- sendKeyframe(sess.peerconnection);
|
|
281
|
|
- }, 3000);
|
|
282
|
|
- }
|
|
283
|
|
-}
|
|
284
|
|
-
|
|
285
|
|
-// an attempt to work around https://github.com/jitsi/jitmeet/issues/32
|
|
286
|
|
-function sendKeyframe(pc) {
|
|
287
|
|
- console.log('sendkeyframe', pc.iceConnectionState);
|
|
288
|
|
- if (pc.iceConnectionState !== 'connected') return; // safe...
|
|
289
|
|
- pc.setRemoteDescription(
|
|
290
|
|
- pc.remoteDescription,
|
|
291
|
|
- function () {
|
|
292
|
|
- pc.createAnswer(
|
|
293
|
|
- function (modifiedAnswer) {
|
|
294
|
|
- pc.setLocalDescription(
|
|
295
|
|
- modifiedAnswer,
|
|
296
|
|
- function () {
|
|
297
|
|
- // noop
|
|
298
|
|
- },
|
|
299
|
|
- function (error) {
|
|
300
|
|
- console.log('triggerKeyframe setLocalDescription failed', error);
|
|
301
|
|
- UI.messageHandler.showError();
|
|
302
|
|
- }
|
|
303
|
|
- );
|
|
304
|
|
- },
|
|
305
|
|
- function (error) {
|
|
306
|
|
- console.log('triggerKeyframe createAnswer failed', error);
|
|
307
|
|
- UI.messageHandler.showError();
|
|
308
|
|
- }
|
|
309
|
|
- );
|
|
310
|
|
- },
|
|
311
|
|
- function (error) {
|
|
312
|
|
- console.log('triggerKeyframe setRemoteDescription failed', error);
|
|
313
|
|
- UI.messageHandler.showError();
|
|
314
|
|
- }
|
|
315
|
|
- );
|
|
316
|
|
-}
|
|
317
|
|
-
|
|
318
|
|
-// Really mute video, i.e. dont even send black frames
|
|
319
|
|
-function muteVideo(pc, unmute) {
|
|
320
|
|
- // FIXME: this probably needs another of those lovely state safeguards...
|
|
321
|
|
- // which checks for iceconn == connected and sigstate == stable
|
|
322
|
|
- pc.setRemoteDescription(pc.remoteDescription,
|
|
323
|
|
- function () {
|
|
324
|
|
- pc.createAnswer(
|
|
325
|
|
- function (answer) {
|
|
326
|
|
- var sdp = new SDP(answer.sdp);
|
|
327
|
|
- if (sdp.media.length > 1) {
|
|
328
|
|
- if (unmute)
|
|
329
|
|
- sdp.media[1] = sdp.media[1].replace('a=recvonly', 'a=sendrecv');
|
|
330
|
|
- else
|
|
331
|
|
- sdp.media[1] = sdp.media[1].replace('a=sendrecv', 'a=recvonly');
|
|
332
|
|
- sdp.raw = sdp.session + sdp.media.join('');
|
|
333
|
|
- answer.sdp = sdp.raw;
|
|
334
|
|
- }
|
|
335
|
|
- pc.setLocalDescription(answer,
|
|
336
|
|
- function () {
|
|
337
|
|
- console.log('mute SLD ok');
|
|
338
|
|
- },
|
|
339
|
|
- function (error) {
|
|
340
|
|
- console.log('mute SLD error');
|
|
341
|
|
- UI.messageHandler.showError('Error',
|
|
342
|
|
- 'Oops! Something went wrong and we failed to ' +
|
|
343
|
|
- 'mute! (SLD Failure)');
|
|
344
|
|
- }
|
|
345
|
|
- );
|
|
346
|
|
- },
|
|
347
|
|
- function (error) {
|
|
348
|
|
- console.log(error);
|
|
349
|
|
- UI.messageHandler.showError();
|
|
350
|
|
- }
|
|
351
|
|
- );
|
|
352
|
|
- },
|
|
353
|
|
- function (error) {
|
|
354
|
|
- console.log('muteVideo SRD error');
|
|
355
|
|
- UI.messageHandler.showError('Error',
|
|
356
|
|
- 'Oops! Something went wrong and we failed to stop video!' +
|
|
357
|
|
- '(SRD Failure)');
|
|
358
|
|
-
|
|
359
|
|
- }
|
|
360
|
|
- );
|
|
361
|
|
-}
|
|
362
|
|
-
|
|
363
|
|
-$(document).bind('setLocalDescription.jingle', function (event, sid) {
|
|
364
|
|
- // put our ssrcs into presence so other clients can identify our stream
|
|
365
|
|
- var sess = connection.jingle.sessions[sid];
|
|
366
|
|
- var newssrcs = [];
|
|
367
|
|
- var media = simulcast.parseMedia(sess.peerconnection.localDescription);
|
|
368
|
|
- media.forEach(function (media) {
|
|
369
|
|
-
|
|
370
|
|
- if(Object.keys(media.sources).length > 0) {
|
|
371
|
|
- // TODO(gp) maybe exclude FID streams?
|
|
372
|
|
- Object.keys(media.sources).forEach(function (ssrc) {
|
|
373
|
|
- newssrcs.push({
|
|
374
|
|
- 'ssrc': ssrc,
|
|
375
|
|
- 'type': media.type,
|
|
376
|
|
- 'direction': media.direction
|
|
377
|
|
- });
|
|
378
|
|
- });
|
|
379
|
|
- }
|
|
380
|
|
- else if(sess.localStreamsSSRC && sess.localStreamsSSRC[media.type])
|
|
381
|
|
- {
|
|
382
|
|
- newssrcs.push({
|
|
383
|
|
- 'ssrc': sess.localStreamsSSRC[media.type],
|
|
384
|
|
- 'type': media.type,
|
|
385
|
|
- 'direction': media.direction
|
|
386
|
|
- });
|
|
387
|
|
- }
|
|
388
|
|
-
|
|
389
|
|
- });
|
|
390
|
|
-
|
|
391
|
|
- console.log('new ssrcs', newssrcs);
|
|
392
|
|
-
|
|
393
|
|
- // Have to clear presence map to get rid of removed streams
|
|
394
|
|
- connection.emuc.clearPresenceMedia();
|
|
395
|
|
-
|
|
396
|
|
- if (newssrcs.length > 0) {
|
|
397
|
|
- for (var i = 1; i <= newssrcs.length; i ++) {
|
|
398
|
|
- // Change video type to screen
|
|
399
|
|
- if (newssrcs[i-1].type === 'video' && desktopsharing.isUsingScreenStream()) {
|
|
400
|
|
- newssrcs[i-1].type = 'screen';
|
|
401
|
|
- }
|
|
402
|
|
- connection.emuc.addMediaToPresence(i,
|
|
403
|
|
- newssrcs[i-1].type, newssrcs[i-1].ssrc, newssrcs[i-1].direction);
|
|
404
|
|
- }
|
|
405
|
|
-
|
|
406
|
|
- connection.emuc.sendPresence();
|
|
407
|
|
- }
|
|
408
|
|
-});
|
|
409
|
|
-
|
|
410
|
|
-$(document).bind('iceconnectionstatechange.jingle', function (event, sid, session) {
|
|
411
|
|
- switch (session.peerconnection.iceConnectionState) {
|
|
412
|
|
- case 'checking':
|
|
413
|
|
- session.timeChecking = (new Date()).getTime();
|
|
414
|
|
- session.firstconnect = true;
|
|
415
|
|
- break;
|
|
416
|
|
- case 'completed': // on caller side
|
|
417
|
|
- case 'connected':
|
|
418
|
|
- if (session.firstconnect) {
|
|
419
|
|
- session.firstconnect = false;
|
|
420
|
|
- var metadata = {};
|
|
421
|
|
- metadata.setupTime = (new Date()).getTime() - session.timeChecking;
|
|
422
|
|
- session.peerconnection.getStats(function (res) {
|
|
423
|
|
- if(res && res.result) {
|
|
424
|
|
- res.result().forEach(function (report) {
|
|
425
|
|
- if (report.type == 'googCandidatePair' && report.stat('googActiveConnection') == 'true') {
|
|
426
|
|
- metadata.localCandidateType = report.stat('googLocalCandidateType');
|
|
427
|
|
- metadata.remoteCandidateType = report.stat('googRemoteCandidateType');
|
|
428
|
|
-
|
|
429
|
|
- // log pair as well so we can get nice pie charts
|
|
430
|
|
- metadata.candidatePair = report.stat('googLocalCandidateType') + ';' + report.stat('googRemoteCandidateType');
|
|
431
|
|
-
|
|
432
|
|
- if (report.stat('googRemoteAddress').indexOf('[') === 0) {
|
|
433
|
|
- metadata.ipv6 = true;
|
|
434
|
|
- }
|
|
435
|
|
- }
|
|
436
|
|
- });
|
|
437
|
|
- }
|
|
438
|
|
- });
|
|
439
|
|
- }
|
|
440
|
|
- break;
|
|
441
|
|
- }
|
|
442
|
|
-});
|
|
443
|
|
-
|
|
444
|
|
-$(document).bind('presence.muc', function (event, jid, info, pres) {
|
|
445
|
|
-
|
|
446
|
|
- //check if the video bridge is available
|
|
447
|
|
- if($(pres).find(">bridgeIsDown").length > 0 && !bridgeIsDown) {
|
|
448
|
|
- bridgeIsDown = true;
|
|
449
|
|
- UI.messageHandler.showError("Error",
|
|
450
|
|
- "Jitsi Videobridge is currently unavailable. Please try again later!");
|
|
451
|
|
- }
|
|
452
|
|
-
|
|
453
|
|
- if (info.isFocus)
|
|
454
|
|
- {
|
|
455
|
|
- return;
|
|
456
|
|
- }
|
|
457
|
|
-
|
|
458
|
|
- // Remove old ssrcs coming from the jid
|
|
459
|
|
- Object.keys(ssrc2jid).forEach(function (ssrc) {
|
|
460
|
|
- if (ssrc2jid[ssrc] == jid) {
|
|
461
|
|
- delete ssrc2jid[ssrc];
|
|
462
|
|
- delete ssrc2videoType[ssrc];
|
|
463
|
|
- }
|
|
464
|
|
- });
|
|
465
|
|
-
|
|
466
|
|
- $(pres).find('>media[xmlns="http://estos.de/ns/mjs"]>source').each(function (idx, ssrc) {
|
|
467
|
|
- //console.log(jid, 'assoc ssrc', ssrc.getAttribute('type'), ssrc.getAttribute('ssrc'));
|
|
468
|
|
- var ssrcV = ssrc.getAttribute('ssrc');
|
|
469
|
|
- ssrc2jid[ssrcV] = jid;
|
|
470
|
|
- notReceivedSSRCs.push(ssrcV);
|
|
471
|
|
-
|
|
472
|
|
- var type = ssrc.getAttribute('type');
|
|
473
|
|
- ssrc2videoType[ssrcV] = type;
|
|
474
|
|
-
|
|
475
|
|
- // might need to update the direction if participant just went from sendrecv to recvonly
|
|
476
|
|
- if (type === 'video' || type === 'screen') {
|
|
477
|
|
- var el = $('#participant_' + Strophe.getResourceFromJid(jid) + '>video');
|
|
478
|
|
- switch (ssrc.getAttribute('direction')) {
|
|
479
|
|
- case 'sendrecv':
|
|
480
|
|
- el.show();
|
|
481
|
|
- break;
|
|
482
|
|
- case 'recvonly':
|
|
483
|
|
- el.hide();
|
|
484
|
|
- // FIXME: Check if we have to change large video
|
|
485
|
|
- //VideoLayout.updateLargeVideo(el);
|
|
486
|
|
- break;
|
|
487
|
|
- }
|
|
488
|
|
- }
|
|
489
|
|
- });
|
|
490
|
|
-
|
|
491
|
|
- var displayName = !config.displayJids
|
|
492
|
|
- ? info.displayName : Strophe.getResourceFromJid(jid);
|
|
493
|
|
-
|
|
494
|
|
- if (displayName && displayName.length > 0)
|
|
495
|
|
- $(document).trigger('displaynamechanged',
|
|
496
|
|
- [jid, displayName]);
|
|
497
|
|
- /*if (focus !== null && info.displayName !== null) {
|
|
498
|
|
- focus.setEndpointDisplayName(jid, info.displayName);
|
|
499
|
|
- }*/
|
|
500
|
|
-
|
|
501
|
|
- //check if the video bridge is available
|
|
502
|
|
- if($(pres).find(">bridgeIsDown").length > 0 && !bridgeIsDown) {
|
|
503
|
|
- bridgeIsDown = true;
|
|
504
|
|
- UI.messageHandler.showError("Error",
|
|
505
|
|
- "Jitsi Videobridge is currently unavailable. Please try again later!");
|
|
506
|
|
- }
|
|
507
|
|
-
|
|
508
|
|
- var id = $(pres).find('>userID').text();
|
|
509
|
|
- var email = $(pres).find('>email');
|
|
510
|
|
- if(email.length > 0) {
|
|
511
|
|
- id = email.text();
|
|
512
|
|
- }
|
|
513
|
|
- UI.setUserAvatar(jid, id);
|
|
514
|
|
-
|
|
515
|
|
-});
|
|
516
|
|
-
|
|
517
|
|
-$(document).bind('kicked.muc', function (event, jid) {
|
|
518
|
|
- console.info(jid + " has been kicked from MUC!");
|
|
519
|
|
- if (connection.emuc.myroomjid === jid) {
|
|
520
|
|
- sessionTerminated = true;
|
|
521
|
|
- disposeConference(false);
|
|
522
|
|
- connection.emuc.doLeave();
|
|
523
|
|
- UI.messageHandler.openMessageDialog("Session Terminated",
|
|
524
|
|
- "Ouch! You have been kicked out of the meet!");
|
|
525
|
|
- }
|
|
526
|
|
-});
|
|
527
|
|
-
|
|
528
|
|
-$(document).bind('passwordrequired.main', function (event) {
|
|
529
|
|
- console.log('password is required');
|
|
530
|
|
-
|
|
531
|
|
- UI.messageHandler.openTwoButtonDialog(null,
|
|
532
|
|
- '<h2>Password required</h2>' +
|
|
533
|
|
- '<input id="passwordrequired.username" type="text" placeholder="user@domain.net" autofocus>' +
|
|
534
|
|
- '<input id="passwordrequired.password" type="password" placeholder="user password">',
|
|
535
|
|
- true,
|
|
536
|
|
- "Ok",
|
|
537
|
|
- function (e, v, m, f) {
|
|
538
|
|
- if (v) {
|
|
539
|
|
- var username = document.getElementById('passwordrequired.username');
|
|
540
|
|
- var password = document.getElementById('passwordrequired.password');
|
|
541
|
|
-
|
|
542
|
|
- if (username.value !== null && password.value != null) {
|
|
543
|
|
- connect(username.value, password.value);
|
|
544
|
|
- }
|
|
545
|
|
- }
|
|
546
|
|
- },
|
|
547
|
|
- function (event) {
|
|
548
|
|
- document.getElementById('passwordrequired.username').focus();
|
|
549
|
|
- }
|
|
550
|
|
- );
|
|
551
|
|
-});
|
|
552
|
|
-
|
|
553
|
|
-/**
|
|
554
|
|
- * Checks if video identified by given src is desktop stream.
|
|
555
|
|
- * @param videoSrc eg.
|
|
556
|
|
- * blob:https%3A//pawel.jitsi.net/9a46e0bd-131e-4d18-9c14-a9264e8db395
|
|
557
|
|
- * @returns {boolean}
|
|
558
|
|
- */
|
|
559
|
|
-function isVideoSrcDesktop(jid) {
|
|
560
|
|
- // FIXME: fix this mapping mess...
|
|
561
|
|
- // figure out if large video is desktop stream or just a camera
|
|
562
|
|
-
|
|
563
|
|
- if(!jid)
|
|
564
|
|
- return false;
|
|
565
|
|
- var isDesktop = false;
|
|
566
|
|
- if (connection.emuc.myroomjid &&
|
|
567
|
|
- Strophe.getResourceFromJid(connection.emuc.myroomjid) === jid) {
|
|
568
|
|
- // local video
|
|
569
|
|
- isDesktop = desktopsharing.isUsingScreenStream();
|
|
570
|
|
- } else {
|
|
571
|
|
- // Do we have associations...
|
|
572
|
|
- var videoSsrc = jid2Ssrc[jid];
|
|
573
|
|
- if (videoSsrc) {
|
|
574
|
|
- var videoType = ssrc2videoType[videoSsrc];
|
|
575
|
|
- if (videoType) {
|
|
576
|
|
- // Finally there...
|
|
577
|
|
- isDesktop = videoType === 'screen';
|
|
578
|
|
- } else {
|
|
579
|
|
- console.error("No video type for ssrc: " + videoSsrc);
|
|
580
|
|
- }
|
|
581
|
|
- } else {
|
|
582
|
|
- console.error("No ssrc for jid: " + jid);
|
|
583
|
|
- }
|
|
584
|
|
- }
|
|
585
|
|
- return isDesktop;
|
|
586
|
|
-}
|
|
587
|
|
-
|
|
588
|
|
-/**
|
|
589
|
|
- * Mutes/unmutes the local video.
|
|
590
|
|
- *
|
|
591
|
|
- * @param mute <tt>true</tt> to mute the local video; otherwise, <tt>false</tt>
|
|
592
|
|
- * @param options an object which specifies optional arguments such as the
|
|
593
|
|
- * <tt>boolean</tt> key <tt>byUser</tt> with default value <tt>true</tt> which
|
|
594
|
|
- * specifies whether the method was initiated in response to a user command (in
|
|
595
|
|
- * contrast to an automatic decision taken by the application logic)
|
|
596
|
|
- */
|
|
597
|
|
-function setVideoMute(mute, options) {
|
|
598
|
|
- if (connection && RTC.localVideo) {
|
|
599
|
|
- if (activecall) {
|
|
600
|
|
- activecall.setVideoMute(
|
|
601
|
|
- mute,
|
|
602
|
|
- function (mute) {
|
|
603
|
|
- var video = $('#video');
|
|
604
|
|
- var communicativeClass = "icon-camera";
|
|
605
|
|
- var muteClass = "icon-camera icon-camera-disabled";
|
|
606
|
|
-
|
|
607
|
|
- if (mute) {
|
|
608
|
|
- video.removeClass(communicativeClass);
|
|
609
|
|
- video.addClass(muteClass);
|
|
610
|
|
- } else {
|
|
611
|
|
- video.removeClass(muteClass);
|
|
612
|
|
- video.addClass(communicativeClass);
|
|
613
|
|
- }
|
|
614
|
|
- connection.emuc.addVideoInfoToPresence(mute);
|
|
615
|
|
- connection.emuc.sendPresence();
|
|
616
|
|
- },
|
|
617
|
|
- options);
|
|
618
|
|
- }
|
|
619
|
|
- }
|
|
620
|
|
-}
|
|
621
|
|
-
|
|
622
|
|
-$(document).on('inlastnchanged', function (event, oldValue, newValue) {
|
|
623
|
|
- if (config.muteLocalVideoIfNotInLastN) {
|
|
624
|
|
- setVideoMute(!newValue, { 'byUser': false });
|
|
625
|
|
- }
|
|
626
|
|
-});
|
|
627
|
|
-
|
|
628
|
|
-/**
|
|
629
|
|
- * Mutes/unmutes the local video.
|
|
630
|
|
- */
|
|
631
|
|
-function toggleVideo() {
|
|
632
|
|
- buttonClick("#video", "icon-camera icon-camera-disabled");
|
|
633
|
|
-
|
|
634
|
|
- if (connection && activecall && RTC.localVideo ) {
|
|
635
|
|
- setVideoMute(!RTC.localVideo.isMuted());
|
|
636
|
|
- }
|
|
637
|
|
-}
|
|
638
|
|
-
|
|
639
|
|
-/**
|
|
640
|
|
- * Mutes / unmutes audio for the local participant.
|
|
641
|
|
- */
|
|
642
|
|
-function toggleAudio() {
|
|
643
|
|
- setAudioMuted(!RTC.localAudio.isMuted());
|
|
644
|
|
-}
|
|
645
|
|
-
|
|
646
|
|
-/**
|
|
647
|
|
- * Sets muted audio state for the local participant.
|
|
648
|
|
- */
|
|
649
|
|
-function setAudioMuted(mute) {
|
|
650
|
|
- if (!(connection && RTC.localAudio)) {
|
|
651
|
|
- preMuted = mute;
|
|
652
|
|
- // We still click the button.
|
|
653
|
|
- buttonClick("#mute", "icon-microphone icon-mic-disabled");
|
|
654
|
|
- return;
|
|
655
|
|
- }
|
|
656
|
|
-
|
|
657
|
|
- if (forceMuted && !mute) {
|
|
658
|
|
- console.info("Asking focus for unmute");
|
|
659
|
|
- connection.moderate.setMute(connection.emuc.myroomjid, mute);
|
|
660
|
|
- // FIXME: wait for result before resetting muted status
|
|
661
|
|
- forceMuted = false;
|
|
662
|
|
- }
|
|
663
|
|
-
|
|
664
|
|
- if (mute == RTC.localAudio.isMuted()) {
|
|
665
|
|
- // Nothing to do
|
|
666
|
|
- return;
|
|
667
|
|
- }
|
|
668
|
|
-
|
|
669
|
|
- // It is not clear what is the right way to handle multiple tracks.
|
|
670
|
|
- // So at least make sure that they are all muted or all unmuted and
|
|
671
|
|
- // that we send presence just once.
|
|
672
|
|
- RTC.localAudio.mute();
|
|
673
|
|
- // isMuted is the opposite of audioEnabled
|
|
674
|
|
- connection.emuc.addAudioInfoToPresence(mute);
|
|
675
|
|
- connection.emuc.sendPresence();
|
|
676
|
|
- UI.showLocalAudioIndicator(mute);
|
|
677
|
|
-
|
|
678
|
|
- buttonClick("#mute", "icon-microphone icon-mic-disabled");
|
|
679
|
|
->>>>>>> ed78c0053c52d49035c4d506016fc799f7ea6511
|
|
680
|
26
|
}
|
|
681
|
27
|
|
|
682
|
28
|
|