From f629ec17fa959e4a4f88ff4e2ae57d325a326c6c Mon Sep 17 00:00:00 2001 From: paweldomas Date: Fri, 28 Nov 2014 16:00:57 +0100 Subject: [PATCH] Focus and debug changes --- app.js | 90 +++++++++++++------------- config.js | 3 +- libs/strophe/strophe.jingle.adapter.js | 9 +++ libs/strophe/strophe.jingle.session.js | 2 + muc.js | 2 +- 5 files changed, 58 insertions(+), 48 deletions(-) diff --git a/app.js b/app.js index 928c90436..05ff6372a 100644 --- a/app.js +++ b/app.js @@ -2,7 +2,6 @@ /* application specific logic */ var connection = null; var authenticatedUser = false; -var focus = null; var activecall = null; var RTC = null; var nickname = null; @@ -595,7 +594,7 @@ $(document).bind('conferenceCreated.jingle', function (event, focus) $(document).bind('callterminated.jingle', function (event, sid, jid, reason) { // Leave the room if my call has been remotely terminated. - if (connection.emuc.joined && focus == null && reason === 'kick') { + if (connection.emuc.joined && reason === 'kick') { sessionTerminated = true; connection.emuc.doLeave(); messageHandler.openMessageDialog("Session Terminated", @@ -677,7 +676,7 @@ $(document).bind('joined.muc', function (event, jid, info) { document.createTextNode(Strophe.getResourceFromJid(jid) + ' (me)') ); - if (Object.keys(connection.emuc.members).length < 1) { +/* if (Object.keys(connection.emuc.members).length < 1) { focus = new ColibriFocus(connection, config.hosts.bridge); if (nickname !== null) { focus.setEndpointDisplayName(connection.emuc.myroomjid, @@ -694,7 +693,23 @@ $(document).bind('joined.muc', function (event, jid, info) { if (focus && config.etherpad_base) { Etherpad.init(); - } + }*/ + + var elem = $iq({to: config.hosts.focus, type: 'set'}); + elem.c('conference', { + xmlns: 'http://jitsi.org/protocol/focus', + room: roomUrl.substr(roomUrl.lastIndexOf("/") + 1) + }); + elem.up(); + + connection.sendIQ(elem, + function (result) { + console.info("Focus replied ", result); + }, + function (error) { + console.warn(error); + } + ); VideoLayout.showFocusIndicator(); @@ -720,6 +735,12 @@ $(document).bind('entered.muc', function (event, jid, info, pres) { console.log('is focus? ' + (focus ? 'true' : 'false')); + if (Strophe.getResourceFromJid(jid).indexOf('focus') != -1) + { + console.info("Ignore focus"); + return; + } + // Add Peer's container VideoLayout.ensurePeerContainerExists(jid); @@ -728,7 +749,7 @@ $(document).bind('entered.muc', function (event, jid, info, pres) { APIConnector.triggerEvent("participantJoined",{jid: jid}); } - if (focus !== null) { + /*if (focus !== null) { // FIXME: this should prepare the video if (focus.confid === null) { console.log('make new conference with', jid); @@ -743,7 +764,7 @@ $(document).bind('entered.muc', function (event, jid, info, pres) { console.log('invite', jid, 'into conference'); focus.addNewParticipant(jid); } - } + }*/ }); $(document).bind('left.muc', function (event, jid) { @@ -784,41 +805,6 @@ $(document).bind('left.muc', function (event, jid) { connection.jingle.terminateByJid(jid); - if (focus == null - // I shouldn't be the one that left to enter here. - && jid !== connection.emuc.myroomjid - && connection.emuc.myroomjid === connection.emuc.list_members[0] - // If our session has been terminated for some reason - // (kicked, hangup), don't try to become the focus - && !sessionTerminated) { - console.log('welcome to our new focus... myself'); - focus = new ColibriFocus(connection, config.hosts.bridge); - if (nickname !== null) { - focus.setEndpointDisplayName(connection.emuc.myroomjid, - nickname); - } - - Toolbar.showSipCallButton(true); - - if (Object.keys(connection.emuc.members).length > 0) { - focus.makeConference(Object.keys(connection.emuc.members)); - Toolbar.showRecordingButton(true); - } - $(document).trigger('focusechanged.muc', [focus]); - } - else if (focus && Object.keys(connection.emuc.members).length === 0) { - console.log('everyone left'); - // FIXME: closing the connection is a hack to avoid some - // problems with reinit - disposeConference(); - focus = new ColibriFocus(connection, config.hosts.bridge); - if (nickname !== null) { - focus.setEndpointDisplayName(connection.emuc.myroomjid, - nickname); - } - Toolbar.showSipCallButton(true); - Toolbar.showRecordingButton(false); - } if (connection.emuc.getPrezi(jid)) { $(document).trigger('presentationremoved.muc', [jid, connection.emuc.getPrezi(jid)]); @@ -867,11 +853,17 @@ $(document).bind('presence.muc', function (event, jid, info, pres) { if (displayName && displayName.length > 0) $(document).trigger('displaynamechanged', [jid, displayName]); - - if (focus !== null && info.displayName !== null) { - focus.setEndpointDisplayName(jid, info.displayName); + [jid, info.displayName]); + if (Strophe.getResourceFromJid(jid).indexOf('focus') != -1) + { + console.info("Ignore focus"); + return; } + /*if (focus !== null && info.displayName !== null) { + focus.setEndpointDisplayName(jid, info.displayName); + }*/ + //check if the video bridge is available if($(pres).find(">bridgeIsDown").length > 0 && !bridgeIsDown) { bridgeIsDown = true; @@ -972,7 +964,7 @@ function isVideoSrcDesktop(videoSrc) { } function getConferenceHandler() { - return focus ? focus : activecall; + return activecall; } function toggleVideo() { @@ -1414,7 +1406,6 @@ function disposeConference(onUnload) { if(onUnload) { stopLocalRtpStatsCollector(); } - focus = null; activecall = null; } @@ -1545,6 +1536,13 @@ function setView(viewName) { // } } +$(document).bind('error.jingle', + function (event, session, error) + { + console.error("Jingle error", error); + } +); + $(document).bind('fatalError.jingle', function (event, session, error) { diff --git a/config.js b/config.js index c8a6fbeb6..009412d0a 100644 --- a/config.js +++ b/config.js @@ -4,7 +4,8 @@ var config = { //anonymousdomain: 'guest.example.com', muc: 'conference.jitsi-meet.example.com', // FIXME: use XEP-0030 bridge: 'jitsi-videobridge.jitsi-meet.example.com', // FIXME: use XEP-0030 - //call_control: 'callcontrol.jitsi-meet.example.com' + call_control: 'callcontrol.jitsi-meet.example.com', + focus: 'focus.jitsi-meet.example.com' }, // getroomnode: function (path) { return 'someprefixpossiblybasedonpath'; }, // useStunTurn: true, // use XEP-0215 to fetch STUN and TURN server diff --git a/libs/strophe/strophe.jingle.adapter.js b/libs/strophe/strophe.jingle.adapter.js index d0f4847f6..5427db674 100644 --- a/libs/strophe/strophe.jingle.adapter.js +++ b/libs/strophe/strophe.jingle.adapter.js @@ -356,6 +356,15 @@ TraceablePeerConnection.prototype.modifySources = function(successCallback) { }); this.removessrc = []; + // FIXME: + // this was a hack for the situation when only one peer exists + // in the conference. + // check if still required and remove + if (sdp.media[0]) + sdp.media[0] = sdp.media[0].replace('a=recvonly', 'a=sendrecv'); + if (sdp.media[1]) + sdp.media[1] = sdp.media[1].replace('a=recvonly', 'a=sendrecv'); + sdp.raw = sdp.session + sdp.media.join(''); this.setRemoteDescription(new RTCSessionDescription({type: 'offer', sdp: sdp.raw}), function() { diff --git a/libs/strophe/strophe.jingle.session.js b/libs/strophe/strophe.jingle.session.js index 3b8515b20..c7faea66c 100644 --- a/libs/strophe/strophe.jingle.session.js +++ b/libs/strophe/strophe.jingle.session.js @@ -581,6 +581,8 @@ JingleSession.prototype.createdAnswer = function (sdp, provisional) { reason: $(stanza).find('error :first')[0].tagName, }:{}; error.source = 'answer'; + error.stanza = stanza; + $(document).trigger('error.jingle', [self.sid, error]); }, 10000); diff --git a/muc.js b/muc.js index 0594613ee..9ce52cff9 100644 --- a/muc.js +++ b/muc.js @@ -139,7 +139,7 @@ Strophe.addConnectionPlugin('emuc', { $(document).trigger('entered.muc', [from, member, pres]); } // Always trigger presence to update bindings - console.log('presence change from', from); + console.log('presence change from', from, pres); $(document).trigger('presence.muc', [from, member, pres]); // Trigger status message update