You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

app.js 43KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404
  1. /* jshint -W117 */
  2. /* application specific logic */
  3. var connection = null;
  4. var authenticatedUser = false;
  5. var focus = null;
  6. var activecall = null;
  7. var RTC = null;
  8. var nickname = null;
  9. var sharedKey = '';
  10. var recordingToken ='';
  11. var roomUrl = null;
  12. var roomName = null;
  13. var ssrc2jid = {};
  14. var mediaStreams = [];
  15. /**
  16. * The stats collector that process stats data and triggers updates to app.js.
  17. * @type {StatsCollector}
  18. */
  19. var statsCollector = null;
  20. /**
  21. * The stats collector for the local stream.
  22. * @type {LocalStatsCollector}
  23. */
  24. var localStatsCollector = null;
  25. /**
  26. * Indicates whether ssrc is camera video or desktop stream.
  27. * FIXME: remove those maps
  28. */
  29. var ssrc2videoType = {};
  30. var videoSrcToSsrc = {};
  31. /**
  32. * Currently focused video "src"(displayed in large video).
  33. * @type {String}
  34. */
  35. var focusedVideoSrc = null;
  36. var mutedAudios = {};
  37. var localVideoSrc = null;
  38. var flipXLocalVideo = true;
  39. var isFullScreen = false;
  40. var toolbarTimeout = null;
  41. var currentVideoWidth = null;
  42. var currentVideoHeight = null;
  43. /**
  44. * Method used to calculate large video size.
  45. * @type {function ()}
  46. */
  47. var getVideoSize;
  48. /**
  49. * Method used to get large video position.
  50. * @type {function ()}
  51. */
  52. var getVideoPosition;
  53. /* window.onbeforeunload = closePageWarning; */
  54. var sessionTerminated = false;
  55. function init() {
  56. RTC = setupRTC();
  57. if (RTC === null) {
  58. window.location.href = 'webrtcrequired.html';
  59. return;
  60. } else if (RTC.browser !== 'chrome') {
  61. window.location.href = 'chromeonly.html';
  62. return;
  63. }
  64. obtainAudioAndVideoPermissions(function (stream) {
  65. var audioStream = new webkitMediaStream(stream);
  66. var videoStream = new webkitMediaStream(stream);
  67. var videoTracks = stream.getVideoTracks();
  68. var audioTracks = stream.getAudioTracks();
  69. for (var i = 0; i < videoTracks.length; i++) {
  70. audioStream.removeTrack(videoTracks[i]);
  71. }
  72. VideoLayout.changeLocalAudio(audioStream);
  73. startLocalRtpStatsCollector(audioStream);
  74. for (i = 0; i < audioTracks.length; i++) {
  75. videoStream.removeTrack(audioTracks[i]);
  76. }
  77. VideoLayout.changeLocalVideo(videoStream, true);
  78. maybeDoJoin();
  79. });
  80. var jid = document.getElementById('jid').value || config.hosts.anonymousdomain || config.hosts.domain || window.location.hostname;
  81. connect(jid);
  82. }
  83. function connect(jid, password) {
  84. connection = new Strophe.Connection(document.getElementById('boshURL').value || config.bosh || '/http-bind');
  85. if (nickname) {
  86. connection.emuc.addDisplayNameToPresence(nickname);
  87. }
  88. if (connection.disco) {
  89. // for chrome, add multistream cap
  90. }
  91. connection.jingle.pc_constraints = RTC.pc_constraints;
  92. if (config.useIPv6) {
  93. // https://code.google.com/p/webrtc/issues/detail?id=2828
  94. if (!connection.jingle.pc_constraints.optional) connection.jingle.pc_constraints.optional = [];
  95. connection.jingle.pc_constraints.optional.push({googIPv6: true});
  96. }
  97. if(!password)
  98. password = document.getElementById('password').value;
  99. var anonymousConnectionFailed = false;
  100. connection.connect(jid, password, function (status, msg) {
  101. if (status === Strophe.Status.CONNECTED) {
  102. console.log('connected');
  103. if (config.useStunTurn) {
  104. connection.jingle.getStunAndTurnCredentials();
  105. }
  106. document.getElementById('connect').disabled = true;
  107. if(password)
  108. authenticatedUser = true;
  109. maybeDoJoin();
  110. } else if (status === Strophe.Status.CONNFAIL) {
  111. if(msg === 'x-strophe-bad-non-anon-jid') {
  112. anonymousConnectionFailed = true;
  113. }
  114. console.log('status', status);
  115. } else if (status === Strophe.Status.DISCONNECTED) {
  116. if(anonymousConnectionFailed) {
  117. // prompt user for username and password
  118. $(document).trigger('passwordrequired.main');
  119. }
  120. } else if (status === Strophe.Status.AUTHFAIL) {
  121. // wrong password or username, prompt user
  122. $(document).trigger('passwordrequired.main');
  123. } else {
  124. console.log('status', status);
  125. }
  126. });
  127. }
  128. /**
  129. * We ask for audio and video combined stream in order to get permissions and
  130. * not to ask twice.
  131. */
  132. function obtainAudioAndVideoPermissions(callback) {
  133. // Get AV
  134. getUserMediaWithConstraints(
  135. ['audio', 'video'],
  136. function (avStream) {
  137. callback(avStream);
  138. },
  139. function (error) {
  140. console.error('failed to obtain audio/video stream - stop', error);
  141. },
  142. config.resolution || '360');
  143. }
  144. function maybeDoJoin() {
  145. if (connection && connection.connected && Strophe.getResourceFromJid(connection.jid) // .connected is true while connecting?
  146. && (connection.jingle.localAudio || connection.jingle.localVideo)) {
  147. doJoin();
  148. }
  149. }
  150. function doJoin() {
  151. var roomnode = null;
  152. var path = window.location.pathname;
  153. var roomjid;
  154. // determinde the room node from the url
  155. // TODO: just the roomnode or the whole bare jid?
  156. if (config.getroomnode && typeof config.getroomnode === 'function') {
  157. // custom function might be responsible for doing the pushstate
  158. roomnode = config.getroomnode(path);
  159. } else {
  160. /* fall back to default strategy
  161. * this is making assumptions about how the URL->room mapping happens.
  162. * It currently assumes deployment at root, with a rewrite like the
  163. * following one (for nginx):
  164. location ~ ^/([a-zA-Z0-9]+)$ {
  165. rewrite ^/(.*)$ / break;
  166. }
  167. */
  168. if (path.length > 1) {
  169. roomnode = path.substr(1).toLowerCase();
  170. } else {
  171. var word = RoomNameGenerator.generateRoomWithoutSeparator(3);
  172. roomnode = word.toLowerCase();
  173. window.history.pushState('VideoChat',
  174. 'Room: ' + word, window.location.pathname + word);
  175. }
  176. }
  177. roomName = roomnode + '@' + config.hosts.muc;
  178. roomjid = roomName;
  179. if (config.useNicks) {
  180. var nick = window.prompt('Your nickname (optional)');
  181. if (nick) {
  182. roomjid += '/' + nick;
  183. } else {
  184. roomjid += '/' + Strophe.getNodeFromJid(connection.jid);
  185. }
  186. } else {
  187. var tmpJid = Strophe.getNodeFromJid(connection.jid);
  188. if(!authenticatedUser)
  189. tmpJid = tmpJid.substr(0, 8);
  190. roomjid += '/' + tmpJid;
  191. }
  192. connection.emuc.doJoin(roomjid);
  193. }
  194. function waitForRemoteVideo(selector, ssrc, stream) {
  195. if (selector.removed || !selector.parent().is(":visible")) {
  196. console.warn("Media removed before had started", selector);
  197. return;
  198. }
  199. if (stream.id === 'mixedmslabel') return;
  200. if (selector[0].currentTime > 0) {
  201. RTC.attachMediaStream(selector, stream); // FIXME: why do i have to do this for FF?
  202. // FIXME: add a class that will associate peer Jid, video.src, it's ssrc and video type
  203. // in order to get rid of too many maps
  204. if (ssrc && selector.attr('src')) {
  205. videoSrcToSsrc[selector.attr('src')] = ssrc;
  206. } else {
  207. console.warn("No ssrc given for video", selector);
  208. }
  209. $(document).trigger('videoactive.jingle', [selector]);
  210. } else {
  211. setTimeout(function () {
  212. waitForRemoteVideo(selector, ssrc, stream);
  213. }, 250);
  214. }
  215. }
  216. $(document).bind('remotestreamadded.jingle', function (event, data, sid) {
  217. var sess = connection.jingle.sessions[sid];
  218. var thessrc;
  219. // look up an associated JID for a stream id
  220. if (data.stream.id.indexOf('mixedmslabel') === -1) {
  221. var ssrclines
  222. = SDPUtil.find_lines(sess.peerconnection.remoteDescription.sdp, 'a=ssrc');
  223. ssrclines = ssrclines.filter(function (line) {
  224. return line.indexOf('mslabel:' + data.stream.label) !== -1;
  225. });
  226. if (ssrclines.length) {
  227. thessrc = ssrclines[0].substring(7).split(' ')[0];
  228. // ok to overwrite the one from focus? might save work in colibri.js
  229. console.log('associated jid', ssrc2jid[thessrc], data.peerjid);
  230. if (ssrc2jid[thessrc]) {
  231. data.peerjid = ssrc2jid[thessrc];
  232. }
  233. }
  234. }
  235. mediaStreams.push(new MediaStream(data, sid, thessrc));
  236. var container;
  237. var remotes = document.getElementById('remoteVideos');
  238. if (data.peerjid) {
  239. VideoLayout.ensurePeerContainerExists(data.peerjid);
  240. container = document.getElementById(
  241. 'participant_' + Strophe.getResourceFromJid(data.peerjid));
  242. } else {
  243. if (data.stream.id !== 'mixedmslabel') {
  244. console.error( 'can not associate stream',
  245. data.stream.id,
  246. 'with a participant');
  247. // We don't want to add it here since it will cause troubles
  248. return;
  249. }
  250. // FIXME: for the mixed ms we dont need a video -- currently
  251. container = document.createElement('span');
  252. container.id = 'mixedstream';
  253. container.className = 'videocontainer';
  254. remotes.appendChild(container);
  255. Util.playSoundNotification('userJoined');
  256. }
  257. var isVideo = data.stream.getVideoTracks().length > 0;
  258. if (container) {
  259. VideoLayout.addRemoteStreamElement( container,
  260. sid,
  261. data.stream,
  262. data.peerjid,
  263. thessrc);
  264. }
  265. // an attempt to work around https://github.com/jitsi/jitmeet/issues/32
  266. if (isVideo &&
  267. data.peerjid && sess.peerjid === data.peerjid &&
  268. data.stream.getVideoTracks().length === 0 &&
  269. connection.jingle.localVideo.getVideoTracks().length > 0) {
  270. //
  271. window.setTimeout(function () {
  272. sendKeyframe(sess.peerconnection);
  273. }, 3000);
  274. }
  275. });
  276. /**
  277. * Returns the JID of the user to whom given <tt>videoSrc</tt> belongs.
  278. * @param videoSrc the video "src" identifier.
  279. * @returns {null | String} the JID of the user to whom given <tt>videoSrc</tt>
  280. * belongs.
  281. */
  282. function getJidFromVideoSrc(videoSrc)
  283. {
  284. if (videoSrc === localVideoSrc)
  285. return connection.emuc.myroomjid;
  286. var ssrc = videoSrcToSsrc[videoSrc];
  287. if (!ssrc)
  288. {
  289. return null;
  290. }
  291. return ssrc2jid[ssrc];
  292. }
  293. // an attempt to work around https://github.com/jitsi/jitmeet/issues/32
  294. function sendKeyframe(pc) {
  295. console.log('sendkeyframe', pc.iceConnectionState);
  296. if (pc.iceConnectionState !== 'connected') return; // safe...
  297. pc.setRemoteDescription(
  298. pc.remoteDescription,
  299. function () {
  300. pc.createAnswer(
  301. function (modifiedAnswer) {
  302. pc.setLocalDescription(
  303. modifiedAnswer,
  304. function () {
  305. // noop
  306. },
  307. function (error) {
  308. console.log('triggerKeyframe setLocalDescription failed', error);
  309. }
  310. );
  311. },
  312. function (error) {
  313. console.log('triggerKeyframe createAnswer failed', error);
  314. }
  315. );
  316. },
  317. function (error) {
  318. console.log('triggerKeyframe setRemoteDescription failed', error);
  319. }
  320. );
  321. }
  322. // Really mute video, i.e. dont even send black frames
  323. function muteVideo(pc, unmute) {
  324. // FIXME: this probably needs another of those lovely state safeguards...
  325. // which checks for iceconn == connected and sigstate == stable
  326. pc.setRemoteDescription(pc.remoteDescription,
  327. function () {
  328. pc.createAnswer(
  329. function (answer) {
  330. var sdp = new SDP(answer.sdp);
  331. if (sdp.media.length > 1) {
  332. if (unmute)
  333. sdp.media[1] = sdp.media[1].replace('a=recvonly', 'a=sendrecv');
  334. else
  335. sdp.media[1] = sdp.media[1].replace('a=sendrecv', 'a=recvonly');
  336. sdp.raw = sdp.session + sdp.media.join('');
  337. answer.sdp = sdp.raw;
  338. }
  339. pc.setLocalDescription(answer,
  340. function () {
  341. console.log('mute SLD ok');
  342. },
  343. function (error) {
  344. console.log('mute SLD error');
  345. }
  346. );
  347. },
  348. function (error) {
  349. console.log(error);
  350. }
  351. );
  352. },
  353. function (error) {
  354. console.log('muteVideo SRD error');
  355. }
  356. );
  357. }
  358. /**
  359. * Callback for audio levels changed.
  360. * @param jid JID of the user
  361. * @param audioLevel the audio level value
  362. */
  363. function audioLevelUpdated(jid, audioLevel)
  364. {
  365. var resourceJid;
  366. if(jid === LocalStatsCollector.LOCAL_JID)
  367. {
  368. resourceJid = AudioLevels.LOCAL_LEVEL;
  369. if(isAudioMuted())
  370. return;
  371. }
  372. else
  373. {
  374. resourceJid = Strophe.getResourceFromJid(jid);
  375. }
  376. AudioLevels.updateAudioLevel(resourceJid, audioLevel);
  377. }
  378. /**
  379. * Starts the {@link StatsCollector} if the feature is enabled in config.js.
  380. */
  381. function startRtpStatsCollector()
  382. {
  383. stopRTPStatsCollector();
  384. if (config.enableRtpStats)
  385. {
  386. statsCollector = new StatsCollector(
  387. getConferenceHandler().peerconnection, 200, audioLevelUpdated);
  388. statsCollector.start();
  389. }
  390. }
  391. /**
  392. * Stops the {@link StatsCollector}.
  393. */
  394. function stopRTPStatsCollector()
  395. {
  396. if (statsCollector)
  397. {
  398. statsCollector.stop();
  399. statsCollector = null;
  400. }
  401. }
  402. /**
  403. * Starts the {@link LocalStatsCollector} if the feature is enabled in config.js
  404. * @param stream the stream that will be used for collecting statistics.
  405. */
  406. function startLocalRtpStatsCollector(stream)
  407. {
  408. if(config.enableRtpStats)
  409. {
  410. localStatsCollector = new LocalStatsCollector(stream, 100, audioLevelUpdated);
  411. localStatsCollector.start();
  412. }
  413. }
  414. /**
  415. * Stops the {@link LocalStatsCollector}.
  416. */
  417. function stopLocalRtpStatsCollector()
  418. {
  419. if(localStatsCollector)
  420. {
  421. localStatsCollector.stop();
  422. localStatsCollector = null;
  423. }
  424. }
  425. $(document).bind('callincoming.jingle', function (event, sid) {
  426. var sess = connection.jingle.sessions[sid];
  427. // TODO: do we check activecall == null?
  428. activecall = sess;
  429. startRtpStatsCollector();
  430. // Bind data channel listener in case we're a regular participant
  431. if (config.openSctp)
  432. {
  433. bindDataChannelListener(sess.peerconnection);
  434. }
  435. // TODO: check affiliation and/or role
  436. console.log('emuc data for', sess.peerjid, connection.emuc.members[sess.peerjid]);
  437. sess.usedrip = true; // not-so-naive trickle ice
  438. sess.sendAnswer();
  439. sess.accept();
  440. });
  441. $(document).bind('conferenceCreated.jingle', function (event, focus)
  442. {
  443. startRtpStatsCollector();
  444. });
  445. $(document).bind('conferenceCreated.jingle', function (event, focus)
  446. {
  447. // Bind data channel listener in case we're the focus
  448. if (config.openSctp)
  449. {
  450. bindDataChannelListener(focus.peerconnection);
  451. }
  452. });
  453. $(document).bind('callterminated.jingle', function (event, sid, jid, reason) {
  454. // Leave the room if my call has been remotely terminated.
  455. if (connection.emuc.joined && focus == null && reason === 'kick') {
  456. sessionTerminated = true;
  457. connection.emuc.doLeave();
  458. openMessageDialog( "Session Terminated",
  459. "Ouch! You have been kicked out of the meet!");
  460. }
  461. });
  462. $(document).bind('setLocalDescription.jingle', function (event, sid) {
  463. // put our ssrcs into presence so other clients can identify our stream
  464. var sess = connection.jingle.sessions[sid];
  465. var newssrcs = {};
  466. var directions = {};
  467. var localSDP = new SDP(sess.peerconnection.localDescription.sdp);
  468. localSDP.media.forEach(function (media) {
  469. var type = SDPUtil.parse_mid(SDPUtil.find_line(media, 'a=mid:'));
  470. if (SDPUtil.find_line(media, 'a=ssrc:')) {
  471. // assumes a single local ssrc
  472. var ssrc = SDPUtil.find_line(media, 'a=ssrc:').substring(7).split(' ')[0];
  473. newssrcs[type] = ssrc;
  474. directions[type] = (
  475. SDPUtil.find_line(media, 'a=sendrecv') ||
  476. SDPUtil.find_line(media, 'a=recvonly') ||
  477. SDPUtil.find_line(media, 'a=sendonly') ||
  478. SDPUtil.find_line(media, 'a=inactive') ||
  479. 'a=sendrecv').substr(2);
  480. }
  481. });
  482. console.log('new ssrcs', newssrcs);
  483. // Have to clear presence map to get rid of removed streams
  484. connection.emuc.clearPresenceMedia();
  485. var i = 0;
  486. Object.keys(newssrcs).forEach(function (mtype) {
  487. i++;
  488. var type = mtype;
  489. // Change video type to screen
  490. if (mtype === 'video' && isUsingScreenStream) {
  491. type = 'screen';
  492. }
  493. connection.emuc.addMediaToPresence(i, type, newssrcs[mtype], directions[mtype]);
  494. });
  495. if (i > 0) {
  496. connection.emuc.sendPresence();
  497. }
  498. });
  499. $(document).bind('joined.muc', function (event, jid, info) {
  500. updateRoomUrl(window.location.href);
  501. document.getElementById('localNick').appendChild(
  502. document.createTextNode(Strophe.getResourceFromJid(jid) + ' (me)')
  503. );
  504. if (Object.keys(connection.emuc.members).length < 1) {
  505. focus = new ColibriFocus(connection, config.hosts.bridge);
  506. if (nickname !== null) {
  507. focus.setEndpointDisplayName(connection.emuc.myroomjid,
  508. nickname);
  509. }
  510. Toolbar.showSipCallButton(true);
  511. Toolbar.showRecordingButton(false);
  512. }
  513. if (!focus)
  514. {
  515. Toolbar.showSipCallButton(false);
  516. }
  517. if (focus && config.etherpad_base) {
  518. Etherpad.init();
  519. }
  520. VideoLayout.showFocusIndicator();
  521. // Add myself to the contact list.
  522. ContactList.addContact(jid);
  523. // Once we've joined the muc show the toolbar
  524. Toolbar.showToolbar();
  525. if (info.displayName)
  526. $(document).trigger('displaynamechanged',
  527. ['localVideoContainer', info.displayName + ' (me)']);
  528. });
  529. $(document).bind('entered.muc', function (event, jid, info, pres) {
  530. console.log('entered', jid, info);
  531. console.log('is focus?' + focus ? 'true' : 'false');
  532. // Add Peer's container
  533. VideoLayout.ensurePeerContainerExists(jid);
  534. if (focus !== null) {
  535. // FIXME: this should prepare the video
  536. if (focus.confid === null) {
  537. console.log('make new conference with', jid);
  538. focus.makeConference(Object.keys(connection.emuc.members));
  539. Toolbar.showRecordingButton(true);
  540. } else {
  541. console.log('invite', jid, 'into conference');
  542. focus.addNewParticipant(jid);
  543. }
  544. }
  545. else if (sharedKey) {
  546. Toolbar.updateLockButton();
  547. }
  548. });
  549. $(document).bind('left.muc', function (event, jid) {
  550. console.log('left.muc', jid);
  551. // Need to call this with a slight delay, otherwise the element couldn't be
  552. // found for some reason.
  553. window.setTimeout(function () {
  554. var container = document.getElementById(
  555. 'participant_' + Strophe.getResourceFromJid(jid));
  556. if (container) {
  557. // hide here, wait for video to close before removing
  558. $(container).hide();
  559. VideoLayout.resizeThumbnails();
  560. }
  561. }, 10);
  562. // Unlock large video
  563. if (focusedVideoSrc)
  564. {
  565. if (getJidFromVideoSrc(focusedVideoSrc) === jid)
  566. {
  567. console.info("Focused video owner has left the conference");
  568. focusedVideoSrc = null;
  569. }
  570. }
  571. connection.jingle.terminateByJid(jid);
  572. if (focus == null
  573. // I shouldn't be the one that left to enter here.
  574. && jid !== connection.emuc.myroomjid
  575. && connection.emuc.myroomjid === connection.emuc.list_members[0]
  576. // If our session has been terminated for some reason
  577. // (kicked, hangup), don't try to become the focus
  578. && !sessionTerminated) {
  579. console.log('welcome to our new focus... myself');
  580. focus = new ColibriFocus(connection, config.hosts.bridge);
  581. if (nickname !== null) {
  582. focus.setEndpointDisplayName(connection.emuc.myroomjid,
  583. nickname);
  584. }
  585. Toolbar.showSipCallButton(true);
  586. if (Object.keys(connection.emuc.members).length > 0) {
  587. focus.makeConference(Object.keys(connection.emuc.members));
  588. Toolbar.showRecordingButton(true);
  589. }
  590. $(document).trigger('focusechanged.muc', [focus]);
  591. }
  592. else if (focus && Object.keys(connection.emuc.members).length === 0) {
  593. console.log('everyone left');
  594. // FIXME: closing the connection is a hack to avoid some
  595. // problems with reinit
  596. disposeConference();
  597. focus = new ColibriFocus(connection, config.hosts.bridge);
  598. if (nickname !== null) {
  599. focus.setEndpointDisplayName(connection.emuc.myroomjid,
  600. nickname);
  601. }
  602. Toolbar.showSipCallButton(true);
  603. Toolbar.showRecordingButton(false);
  604. }
  605. if (connection.emuc.getPrezi(jid)) {
  606. $(document).trigger('presentationremoved.muc',
  607. [jid, connection.emuc.getPrezi(jid)]);
  608. }
  609. });
  610. $(document).bind('presence.muc', function (event, jid, info, pres) {
  611. // Remove old ssrcs coming from the jid
  612. Object.keys(ssrc2jid).forEach(function (ssrc) {
  613. if (ssrc2jid[ssrc] == jid) {
  614. delete ssrc2jid[ssrc];
  615. }
  616. if (ssrc2videoType[ssrc] == jid) {
  617. delete ssrc2videoType[ssrc];
  618. }
  619. });
  620. $(pres).find('>media[xmlns="http://estos.de/ns/mjs"]>source').each(function (idx, ssrc) {
  621. //console.log(jid, 'assoc ssrc', ssrc.getAttribute('type'), ssrc.getAttribute('ssrc'));
  622. var ssrcV = ssrc.getAttribute('ssrc');
  623. ssrc2jid[ssrcV] = jid;
  624. var type = ssrc.getAttribute('type');
  625. ssrc2videoType[ssrcV] = type;
  626. // might need to update the direction if participant just went from sendrecv to recvonly
  627. if (type === 'video' || type === 'screen') {
  628. var el = $('#participant_' + Strophe.getResourceFromJid(jid) + '>video');
  629. switch (ssrc.getAttribute('direction')) {
  630. case 'sendrecv':
  631. el.show();
  632. break;
  633. case 'recvonly':
  634. el.hide();
  635. // FIXME: Check if we have to change large video
  636. //VideoLayout.updateLargeVideo(el);
  637. break;
  638. }
  639. }
  640. });
  641. if (info.displayName && info.displayName.length > 0)
  642. $(document).trigger('displaynamechanged',
  643. [jid, info.displayName]);
  644. if (focus !== null && info.displayName !== null) {
  645. focus.setEndpointDisplayName(jid, info.displayName);
  646. }
  647. });
  648. $(document).bind('presence.status.muc', function (event, jid, info, pres) {
  649. VideoLayout.setPresenceStatus(
  650. 'participant_' + Strophe.getResourceFromJid(jid), info.status);
  651. });
  652. $(document).bind('passwordrequired.muc', function (event, jid) {
  653. console.log('on password required', jid);
  654. $.prompt('<h2>Password required</h2>' +
  655. '<input id="lockKey" type="text" placeholder="shared key" autofocus>', {
  656. persistent: true,
  657. buttons: { "Ok": true, "Cancel": false},
  658. defaultButton: 1,
  659. loaded: function (event) {
  660. document.getElementById('lockKey').focus();
  661. },
  662. submit: function (e, v, m, f) {
  663. if (v) {
  664. var lockKey = document.getElementById('lockKey');
  665. if (lockKey.value !== null) {
  666. setSharedKey(lockKey.value);
  667. connection.emuc.doJoin(jid, lockKey.value);
  668. }
  669. }
  670. }
  671. });
  672. });
  673. $(document).bind('passwordrequired.main', function (event) {
  674. console.log('password is required');
  675. $.prompt('<h2>Password required</h2>' +
  676. '<input id="passwordrequired.username" type="text" placeholder="user@domain.net" autofocus>' +
  677. '<input id="passwordrequired.password" type="password" placeholder="user password">', {
  678. persistent: true,
  679. buttons: { "Ok": true, "Cancel": false},
  680. defaultButton: 1,
  681. loaded: function (event) {
  682. document.getElementById('passwordrequired.username').focus();
  683. },
  684. submit: function (e, v, m, f) {
  685. if (v) {
  686. var username = document.getElementById('passwordrequired.username');
  687. var password = document.getElementById('passwordrequired.password');
  688. if (username.value !== null && password.value != null) {
  689. connect(username.value, password.value);
  690. }
  691. }
  692. }
  693. });
  694. });
  695. /**
  696. * Checks if video identified by given src is desktop stream.
  697. * @param videoSrc eg.
  698. * blob:https%3A//pawel.jitsi.net/9a46e0bd-131e-4d18-9c14-a9264e8db395
  699. * @returns {boolean}
  700. */
  701. function isVideoSrcDesktop(videoSrc) {
  702. // FIXME: fix this mapping mess...
  703. // figure out if large video is desktop stream or just a camera
  704. var isDesktop = false;
  705. if (localVideoSrc === videoSrc) {
  706. // local video
  707. isDesktop = isUsingScreenStream;
  708. } else {
  709. // Do we have associations...
  710. var videoSsrc = videoSrcToSsrc[videoSrc];
  711. if (videoSsrc) {
  712. var videoType = ssrc2videoType[videoSsrc];
  713. if (videoType) {
  714. // Finally there...
  715. isDesktop = videoType === 'screen';
  716. } else {
  717. console.error("No video type for ssrc: " + videoSsrc);
  718. }
  719. } else {
  720. console.error("No ssrc for src: " + videoSrc);
  721. }
  722. }
  723. return isDesktop;
  724. }
  725. function getConferenceHandler() {
  726. return focus ? focus : activecall;
  727. }
  728. function toggleVideo() {
  729. if (!(connection && connection.jingle.localVideo))
  730. return;
  731. var sess = getConferenceHandler();
  732. if (sess) {
  733. sess.toggleVideoMute(
  734. function (isMuted) {
  735. if (isMuted) {
  736. $('#video').removeClass("icon-camera");
  737. $('#video').addClass("icon-camera icon-camera-disabled");
  738. } else {
  739. $('#video').removeClass("icon-camera icon-camera-disabled");
  740. $('#video').addClass("icon-camera");
  741. }
  742. }
  743. );
  744. }
  745. sess = focus || activecall;
  746. if (!sess) {
  747. return;
  748. }
  749. sess.pendingop = ismuted ? 'unmute' : 'mute';
  750. // connection.emuc.addVideoInfoToPresence(!ismuted);
  751. // connection.emuc.sendPresence();
  752. sess.modifySources();
  753. }
  754. /**
  755. * Mutes / unmutes audio for the local participant.
  756. */
  757. function toggleAudio() {
  758. if (!(connection && connection.jingle.localAudio)) {
  759. preMuted = true;
  760. // We still click the button.
  761. buttonClick("#mute", "icon-microphone icon-mic-disabled");
  762. return;
  763. }
  764. var localAudio = connection.jingle.localAudio;
  765. for (var idx = 0; idx < localAudio.getAudioTracks().length; idx++) {
  766. var audioEnabled = localAudio.getAudioTracks()[idx].enabled;
  767. localAudio.getAudioTracks()[idx].enabled = !audioEnabled;
  768. // isMuted is the opposite of audioEnabled
  769. connection.emuc.addAudioInfoToPresence(audioEnabled);
  770. connection.emuc.sendPresence();
  771. }
  772. buttonClick("#mute", "icon-microphone icon-mic-disabled");
  773. }
  774. /**
  775. * Checks whether the audio is muted or not.
  776. * @returns {boolean} true if audio is muted and false if not.
  777. */
  778. function isAudioMuted()
  779. {
  780. var localAudio = connection.jingle.localAudio;
  781. for (var idx = 0; idx < localAudio.getAudioTracks().length; idx++) {
  782. if(localAudio.getAudioTracks()[idx].enabled === true)
  783. return false;
  784. }
  785. return true;
  786. }
  787. // Starts or stops the recording for the conference.
  788. function toggleRecording() {
  789. if (focus === null || focus.confid === null) {
  790. console.log('non-focus, or conference not yet organized: not enabling recording');
  791. return;
  792. }
  793. if (!recordingToken)
  794. {
  795. $.prompt('<h2>Enter recording token</h2>' +
  796. '<input id="recordingToken" type="text" placeholder="token" autofocus>',
  797. {
  798. persistent: false,
  799. buttons: { "Save": true, "Cancel": false},
  800. defaultButton: 1,
  801. loaded: function (event) {
  802. document.getElementById('recordingToken').focus();
  803. },
  804. submit: function (e, v, m, f) {
  805. if (v) {
  806. var token = document.getElementById('recordingToken');
  807. if (token.value) {
  808. setRecordingToken(Util.escapeHtml(token.value));
  809. toggleRecording();
  810. }
  811. }
  812. }
  813. }
  814. );
  815. return;
  816. }
  817. var oldState = focus.recordingEnabled;
  818. Toolbar.toggleRecordingButtonState();
  819. focus.setRecording(!oldState,
  820. recordingToken,
  821. function (state) {
  822. console.log("New recording state: ", state);
  823. if (state == oldState) //failed to change, reset the token because it might have been wrong
  824. {
  825. Toolbar.toggleRecordingButtonState();
  826. setRecordingToken(null);
  827. }
  828. }
  829. );
  830. }
  831. /**
  832. * Returns an array of the video horizontal and vertical indents,
  833. * so that if fits its parent.
  834. *
  835. * @return an array with 2 elements, the horizontal indent and the vertical
  836. * indent
  837. */
  838. function getCameraVideoPosition(videoWidth,
  839. videoHeight,
  840. videoSpaceWidth,
  841. videoSpaceHeight) {
  842. // Parent height isn't completely calculated when we position the video in
  843. // full screen mode and this is why we use the screen height in this case.
  844. // Need to think it further at some point and implement it properly.
  845. var isFullScreen = document.fullScreen ||
  846. document.mozFullScreen ||
  847. document.webkitIsFullScreen;
  848. if (isFullScreen)
  849. videoSpaceHeight = window.innerHeight;
  850. var horizontalIndent = (videoSpaceWidth - videoWidth) / 2;
  851. var verticalIndent = (videoSpaceHeight - videoHeight) / 2;
  852. return [horizontalIndent, verticalIndent];
  853. }
  854. /**
  855. * Returns an array of the video horizontal and vertical indents.
  856. * Centers horizontally and top aligns vertically.
  857. *
  858. * @return an array with 2 elements, the horizontal indent and the vertical
  859. * indent
  860. */
  861. function getDesktopVideoPosition(videoWidth,
  862. videoHeight,
  863. videoSpaceWidth,
  864. videoSpaceHeight) {
  865. var horizontalIndent = (videoSpaceWidth - videoWidth) / 2;
  866. var verticalIndent = 0;// Top aligned
  867. return [horizontalIndent, verticalIndent];
  868. }
  869. /**
  870. * Returns an array of the video dimensions, so that it covers the screen.
  871. * It leaves no empty areas, but some parts of the video might not be visible.
  872. *
  873. * @return an array with 2 elements, the video width and the video height
  874. */
  875. function getCameraVideoSize(videoWidth,
  876. videoHeight,
  877. videoSpaceWidth,
  878. videoSpaceHeight) {
  879. if (!videoWidth)
  880. videoWidth = currentVideoWidth;
  881. if (!videoHeight)
  882. videoHeight = currentVideoHeight;
  883. var aspectRatio = videoWidth / videoHeight;
  884. var availableWidth = Math.max(videoWidth, videoSpaceWidth);
  885. var availableHeight = Math.max(videoHeight, videoSpaceHeight);
  886. if (availableWidth / aspectRatio < videoSpaceHeight) {
  887. availableHeight = videoSpaceHeight;
  888. availableWidth = availableHeight * aspectRatio;
  889. }
  890. if (availableHeight * aspectRatio < videoSpaceWidth) {
  891. availableWidth = videoSpaceWidth;
  892. availableHeight = availableWidth / aspectRatio;
  893. }
  894. return [availableWidth, availableHeight];
  895. }
  896. $(document).ready(function () {
  897. if(config.enableWelcomePage && window.location.pathname == "/" &&
  898. (!window.localStorage.welcomePageDisabled || window.localStorage.welcomePageDisabled == "false"))
  899. {
  900. $("#videoconference_page").hide();
  901. $("#domain_name").text(window.location.host + "/");
  902. $("span[name='appName']").text(brand.appName);
  903. function enter_room()
  904. {
  905. var val = $("#enter_room_field").val();
  906. if(!val)
  907. val = $("#enter_room_field").attr("room_name");
  908. window.location.pathname = "/" + val;
  909. }
  910. $("#enter_room_button").click(function()
  911. {
  912. enter_room();
  913. });
  914. $("#enter_room_field").keydown(function (event) {
  915. if (event.keyCode === 13) {
  916. enter_room();
  917. }
  918. });
  919. var updateTimeout;
  920. var animateTimeout;
  921. $("#reload_roomname").click(function () {
  922. clearTimeout(updateTimeout);
  923. clearTimeout(animateTimeout);
  924. update_roomname();
  925. });
  926. function animate(word) {
  927. var currentVal = $("#enter_room_field").attr("placeholder");
  928. $("#enter_room_field").attr("placeholder", currentVal + word.substr(0, 1));
  929. animateTimeout = setTimeout(function() {
  930. animate(word.substring(1, word.length))
  931. }, 70);
  932. }
  933. function update_roomname()
  934. {
  935. var word = RoomNameGenerator.generateRoomWithoutSeparator();
  936. $("#enter_room_field").attr("room_name", word);
  937. $("#enter_room_field").attr("placeholder", "");
  938. animate(word);
  939. updateTimeout = setTimeout(update_roomname, 10000);
  940. }
  941. update_roomname();
  942. $("#disable_welcome").click(function () {
  943. window.localStorage.welcomePageDisabled = $("#disable_welcome").is(":checked");
  944. });
  945. return;
  946. }
  947. $("#welcome_page").hide();
  948. Chat.init();
  949. $('body').popover({ selector: '[data-toggle=popover]',
  950. trigger: 'click hover'});
  951. // Set the defaults for prompt dialogs.
  952. jQuery.prompt.setDefaults({persistent: false});
  953. // Set default desktop sharing method
  954. setDesktopSharing(config.desktopSharing);
  955. // Initialize Chrome extension inline installs
  956. if (config.chromeExtensionId) {
  957. initInlineInstalls();
  958. }
  959. // By default we use camera
  960. getVideoSize = getCameraVideoSize;
  961. getVideoPosition = getCameraVideoPosition;
  962. VideoLayout.resizeLargeVideoContainer();
  963. $(window).resize(function () {
  964. VideoLayout.resizeLargeVideoContainer();
  965. VideoLayout.positionLarge();
  966. });
  967. // Listen for large video size updates
  968. document.getElementById('largeVideo')
  969. .addEventListener('loadedmetadata', function (e) {
  970. currentVideoWidth = this.videoWidth;
  971. currentVideoHeight = this.videoHeight;
  972. VideoLayout.positionLarge(currentVideoWidth, currentVideoHeight);
  973. });
  974. if (!$('#settings').is(':visible')) {
  975. console.log('init');
  976. init();
  977. } else {
  978. loginInfo.onsubmit = function (e) {
  979. if (e.preventDefault) e.preventDefault();
  980. $('#settings').hide();
  981. init();
  982. };
  983. }
  984. });
  985. $(window).bind('beforeunload', function () {
  986. if (connection && connection.connected) {
  987. // ensure signout
  988. $.ajax({
  989. type: 'POST',
  990. url: config.bosh,
  991. async: false,
  992. cache: false,
  993. contentType: 'application/xml',
  994. data: "<body rid='" + (connection.rid || connection._proto.rid) + "' xmlns='http://jabber.org/protocol/httpbind' sid='" + (connection.sid || connection._proto.sid) + "' type='terminate'><presence xmlns='jabber:client' type='unavailable'/></body>",
  995. success: function (data) {
  996. console.log('signed out');
  997. console.log(data);
  998. },
  999. error: function (XMLHttpRequest, textStatus, errorThrown) {
  1000. console.log('signout error', textStatus + ' (' + errorThrown + ')');
  1001. }
  1002. });
  1003. }
  1004. disposeConference(true);
  1005. });
  1006. function disposeConference(onUnload) {
  1007. var handler = getConferenceHandler();
  1008. if (handler && handler.peerconnection) {
  1009. // FIXME: probably removing streams is not required and close() should be enough
  1010. if (connection.jingle.localAudio) {
  1011. handler.peerconnection.removeStream(connection.jingle.localAudio);
  1012. }
  1013. if (connection.jingle.localVideo) {
  1014. handler.peerconnection.removeStream(connection.jingle.localVideo);
  1015. }
  1016. handler.peerconnection.close();
  1017. }
  1018. stopRTPStatsCollector();
  1019. if(onUnload) {
  1020. stopLocalRtpStatsCollector();
  1021. }
  1022. focus = null;
  1023. activecall = null;
  1024. }
  1025. function dump(elem, filename) {
  1026. elem = elem.parentNode;
  1027. elem.download = filename || 'meetlog.json';
  1028. elem.href = 'data:application/json;charset=utf-8,\n';
  1029. var data = {};
  1030. if (connection.jingle) {
  1031. Object.keys(connection.jingle.sessions).forEach(function (sid) {
  1032. var session = connection.jingle.sessions[sid];
  1033. if (session.peerconnection && session.peerconnection.updateLog) {
  1034. // FIXME: should probably be a .dump call
  1035. data["jingle_" + session.sid] = {
  1036. updateLog: session.peerconnection.updateLog,
  1037. stats: session.peerconnection.stats,
  1038. url: window.location.href
  1039. };
  1040. }
  1041. });
  1042. }
  1043. metadata = {};
  1044. metadata.time = new Date();
  1045. metadata.url = window.location.href;
  1046. metadata.ua = navigator.userAgent;
  1047. if (connection.logger) {
  1048. metadata.xmpp = connection.logger.log;
  1049. }
  1050. data.metadata = metadata;
  1051. elem.href += encodeURIComponent(JSON.stringify(data, null, ' '));
  1052. return false;
  1053. }
  1054. /**
  1055. * Changes the style class of the element given by id.
  1056. */
  1057. function buttonClick(id, classname) {
  1058. $(id).toggleClass(classname); // add the class to the clicked element
  1059. }
  1060. /**
  1061. * Shows a message to the user.
  1062. *
  1063. * @param titleString the title of the message
  1064. * @param messageString the text of the message
  1065. */
  1066. function openMessageDialog(titleString, messageString) {
  1067. $.prompt(messageString,
  1068. {
  1069. title: titleString,
  1070. persistent: false
  1071. }
  1072. );
  1073. }
  1074. /**
  1075. * Locks / unlocks the room.
  1076. */
  1077. function lockRoom(lock) {
  1078. if (lock)
  1079. connection.emuc.lockRoom(sharedKey);
  1080. else
  1081. connection.emuc.lockRoom('');
  1082. Toolbar.updateLockButton();
  1083. }
  1084. /**
  1085. * Sets the shared key.
  1086. */
  1087. function setSharedKey(sKey) {
  1088. sharedKey = sKey;
  1089. }
  1090. function setRecordingToken(token) {
  1091. recordingToken = token;
  1092. }
  1093. /**
  1094. * Updates the room invite url.
  1095. */
  1096. function updateRoomUrl(newRoomUrl) {
  1097. roomUrl = newRoomUrl;
  1098. // If the invite dialog has been already opened we update the information.
  1099. var inviteLink = document.getElementById('inviteLinkRef');
  1100. if (inviteLink) {
  1101. inviteLink.value = roomUrl;
  1102. inviteLink.select();
  1103. document.getElementById('jqi_state0_buttonInvite').disabled = false;
  1104. }
  1105. }
  1106. /**
  1107. * Warning to the user that the conference window is about to be closed.
  1108. */
  1109. function closePageWarning() {
  1110. if (focus !== null)
  1111. return "You are the owner of this conference call and"
  1112. + " you are about to end it.";
  1113. else
  1114. return "You are about to leave this conversation.";
  1115. }
  1116. /**
  1117. * Resizes and repositions videos in full screen mode.
  1118. */
  1119. $(document).on('webkitfullscreenchange mozfullscreenchange fullscreenchange',
  1120. function () {
  1121. VideoLayout.resizeLargeVideoContainer();
  1122. VideoLayout.positionLarge();
  1123. isFullScreen = document.fullScreen ||
  1124. document.mozFullScreen ||
  1125. document.webkitIsFullScreen;
  1126. if (isFullScreen) {
  1127. setView("fullscreen");
  1128. }
  1129. else {
  1130. setView("default");
  1131. }
  1132. }
  1133. );
  1134. /**
  1135. * Sets the current view.
  1136. */
  1137. function setView(viewName) {
  1138. // if (viewName == "fullscreen") {
  1139. // document.getElementById('videolayout_fullscreen').disabled = false;
  1140. // document.getElementById('videolayout_default').disabled = true;
  1141. // }
  1142. // else {
  1143. // document.getElementById('videolayout_default').disabled = false;
  1144. // document.getElementById('videolayout_fullscreen').disabled = true;
  1145. // }
  1146. }
  1147. function hangUp() {
  1148. if (connection && connection.connected) {
  1149. // ensure signout
  1150. $.ajax({
  1151. type: 'POST',
  1152. url: config.bosh,
  1153. async: false,
  1154. cache: false,
  1155. contentType: 'application/xml',
  1156. data: "<body rid='" + (connection.rid || connection._proto.rid) + "' xmlns='http://jabber.org/protocol/httpbind' sid='" + (connection.sid || connection._proto.sid) + "' type='terminate'><presence xmlns='jabber:client' type='unavailable'/></body>",
  1157. success: function (data) {
  1158. console.log('signed out');
  1159. console.log(data);
  1160. },
  1161. error: function (XMLHttpRequest, textStatus, errorThrown) {
  1162. console.log('signout error', textStatus + ' (' + errorThrown + ')');
  1163. }
  1164. });
  1165. }
  1166. disposeConference(true);
  1167. }
  1168. $(document).bind('fatalError.jingle',
  1169. function (event, session, error)
  1170. {
  1171. sessionTerminated = true;
  1172. connection.emuc.doLeave();
  1173. openMessageDialog( "Sorry",
  1174. "Your browser version is too old. Please update and try again...");
  1175. }
  1176. );
  1177. function callSipButtonClicked()
  1178. {
  1179. $.prompt('<h2>Enter SIP number</h2>' +
  1180. '<input id="sipNumber" type="text" value="" autofocus>',
  1181. {
  1182. persistent: false,
  1183. buttons: { "Dial": true, "Cancel": false},
  1184. defaultButton: 2,
  1185. loaded: function (event)
  1186. {
  1187. document.getElementById('sipNumber').focus();
  1188. },
  1189. submit: function (e, v, m, f)
  1190. {
  1191. if (v)
  1192. {
  1193. var numberInput = document.getElementById('sipNumber');
  1194. if (numberInput.value && numberInput.value.length)
  1195. {
  1196. connection.rayo.dial(
  1197. numberInput.value, 'fromnumber', roomName);
  1198. }
  1199. }
  1200. }
  1201. }
  1202. );
  1203. }
  1204. function hangup() {
  1205. disposeConference();
  1206. sessionTerminated = true;
  1207. connection.emuc.doLeave();
  1208. var buttons = {};
  1209. if(config.enableWelcomePage)
  1210. {
  1211. setTimeout(function()
  1212. {
  1213. window.localStorage.welcomePageDisabled = false;
  1214. window.location.pathname = "/";
  1215. }, 10000);
  1216. }
  1217. $.prompt("Session Terminated",
  1218. {
  1219. title: "You hung up the call",
  1220. persistent: true,
  1221. buttons: {
  1222. "Join again": true
  1223. },
  1224. closeText: '',
  1225. submit: function(event, value, message, formVals)
  1226. {
  1227. window.location.reload();
  1228. return false;
  1229. }
  1230. }
  1231. );
  1232. }