Minor formatting fixes.

This commit is contained in:
Boris Grozev 2015-07-28 12:49:58 -05:00
parent 84a8d00234
commit 71229bdba9
9 changed files with 61 additions and 93 deletions

View File

@ -1,3 +1,4 @@
/* global $, $iq, config */
var params = {}; var params = {};
function getConfigParamsFromUrl() { function getConfigParamsFromUrl() {
if(!location.hash) if(!location.hash)

View File

@ -1,3 +1,4 @@
/* global config */
/** /**
* Provides statistics for the local stream. * Provides statistics for the local stream.
*/ */
@ -33,7 +34,7 @@ function timeDomainDataToAudioLevel(samples) {
} }
return parseFloat(((maxVolume - 127) / 128).toFixed(3)); return parseFloat(((maxVolume - 127) / 128).toFixed(3));
}; }
/** /**
* Animates audio level change * Animates audio level change
@ -41,20 +42,16 @@ function timeDomainDataToAudioLevel(samples) {
* @param lastLevel the last audio level * @param lastLevel the last audio level
* @returns {Number} the audio level to be set * @returns {Number} the audio level to be set
*/ */
function animateLevel(newLevel, lastLevel) function animateLevel(newLevel, lastLevel) {
{
var value = 0; var value = 0;
var diff = lastLevel - newLevel; var diff = lastLevel - newLevel;
if(diff > 0.2) if(diff > 0.2) {
{
value = lastLevel - 0.2; value = lastLevel - 0.2;
} }
else if(diff < -0.4) else if(diff < -0.4) {
{
value = lastLevel + 0.4; value = lastLevel + 0.4;
} }
else else {
{
value = newLevel; value = newLevel;
} }
@ -85,8 +82,8 @@ function LocalStatsCollector(stream, interval, statisticsService, eventEmitter)
* Starts the collecting the statistics. * Starts the collecting the statistics.
*/ */
LocalStatsCollector.prototype.start = function () { LocalStatsCollector.prototype.start = function () {
if (config.disableAudioLevels || !window.AudioContext if (config.disableAudioLevels || !window.AudioContext ||
|| RTCBrowserType.isTemasysPluginUsed()) RTCBrowserType.isTemasysPluginUsed())
return; return;
var context = new AudioContext(); var context = new AudioContext();
@ -116,7 +113,6 @@ LocalStatsCollector.prototype.start = function () {
}, },
this.intervalMilis this.intervalMilis
); );
}; };
/** /**

View File

@ -49,8 +49,6 @@ PeerStats.bandwidth = {};
*/ */
PeerStats.bitrate = {}; PeerStats.bitrate = {};
/** /**
* The packet loss rate * The packet loss rate
* @type {{}} * @type {{}}
@ -235,7 +233,7 @@ StatsCollector.prototype.errorCallback = function (error)
StatsCollector.prototype.start = function () StatsCollector.prototype.start = function ()
{ {
var self = this; var self = this;
if(!config.disableAudioLevels) { if (!config.disableAudioLevels) {
this.audioLevelsIntervalId = setInterval( this.audioLevelsIntervalId = setInterval(
function () { function () {
// Interval updates // Interval updates
@ -675,41 +673,34 @@ StatsCollector.prototype.processStatsReport = function () {
/** /**
* Stats processing logic. * Stats processing logic.
*/ */
StatsCollector.prototype.processAudioLevelReport = function () StatsCollector.prototype.processAudioLevelReport = function () {
{ if (!this.baselineAudioLevelsReport) {
if (!this.baselineAudioLevelsReport)
{
return; return;
} }
for (var idx in this.currentAudioLevelsReport) for (var idx in this.currentAudioLevelsReport) {
{
var now = this.currentAudioLevelsReport[idx]; var now = this.currentAudioLevelsReport[idx];
if (now.type != 'ssrc') if (now.type != 'ssrc') {
{
continue; continue;
} }
var before = this.baselineAudioLevelsReport[idx]; var before = this.baselineAudioLevelsReport[idx];
if (!before) if (!before) {
{
console.warn(getStatValue(now, 'ssrc') + ' not enough data'); console.warn(getStatValue(now, 'ssrc') + ' not enough data');
continue; continue;
} }
var ssrc = getStatValue(now, 'ssrc'); var ssrc = getStatValue(now, 'ssrc');
var jid = APP.xmpp.getJidFromSSRC(ssrc); var jid = APP.xmpp.getJidFromSSRC(ssrc);
if (!jid) if (!jid) {
{
if((Date.now() - now.timestamp) < 3000) if((Date.now() - now.timestamp) < 3000)
console.warn("No jid for ssrc: " + ssrc); console.warn("No jid for ssrc: " + ssrc);
continue; continue;
} }
var jidStats = this.jid2stats[jid]; var jidStats = this.jid2stats[jid];
if (!jidStats) if (!jidStats) {
{
jidStats = new PeerStats(); jidStats = new PeerStats();
this.jid2stats[jid] = jidStats; this.jid2stats[jid] = jidStats;
} }
@ -728,8 +719,7 @@ StatsCollector.prototype.processAudioLevelReport = function ()
return; return;
} }
if (audioLevel) if (audioLevel) {
{
// TODO: can't find specs about what this value really is, // TODO: can't find specs about what this value really is,
// but it seems to vary between 0 and around 32k. // but it seems to vary between 0 and around 32k.
audioLevel = audioLevel / 32767; audioLevel = audioLevel / 32767;
@ -737,8 +727,5 @@ StatsCollector.prototype.processAudioLevelReport = function ()
if(jid != APP.xmpp.myJid()) if(jid != APP.xmpp.myJid())
this.eventEmitter.emit("statistics.audioLevel", jid, audioLevel); this.eventEmitter.emit("statistics.audioLevel", jid, audioLevel);
} }
} }
}; };

View File

@ -1,3 +1,4 @@
/* global require, APP */
/** /**
* Created by hristo on 8/4/14. * Created by hristo on 8/4/14.
*/ */
@ -15,19 +16,15 @@ var localStats = null;
var rtpStats = null; var rtpStats = null;
function stopLocal() function stopLocal() {
{ if (localStats) {
if(localStats)
{
localStats.stop(); localStats.stop();
localStats = null; localStats = null;
} }
} }
function stopRemote() function stopRemote() {
{ if (rtpStats) {
if(rtpStats)
{
rtpStats.stop(); rtpStats.stop();
eventEmitter.emit("statistics.stop"); eventEmitter.emit("statistics.stop");
rtpStats = null; rtpStats = null;
@ -35,20 +32,18 @@ function stopRemote()
} }
function startRemoteStats (peerconnection) { function startRemoteStats (peerconnection) {
if(rtpStats) if (rtpStats) {
{
rtpStats.stop(); rtpStats.stop();
rtpStats = null;
} }
rtpStats = new RTPStats(peerconnection, 200, 2000, eventEmitter); rtpStats = new RTPStats(peerconnection, 200, 2000, eventEmitter);
rtpStats.start(); rtpStats.start();
} }
function onStreamCreated(stream) function onStreamCreated(stream) {
{ if(stream.getOriginalStream().getAudioTracks().length === 0) {
if(stream.getOriginalStream().getAudioTracks().length === 0)
return; return;
}
localStats = new LocalStats(stream.getOriginalStream(), 200, statistics, localStats = new LocalStats(stream.getOriginalStream(), 200, statistics,
eventEmitter); eventEmitter);
@ -64,9 +59,7 @@ function onDisposeConference(onUnload) {
} }
} }
var statistics = {
var statistics =
{
/** /**
* Indicates that this audio level is for local jid. * Indicates that this audio level is for local jid.
* @type {string} * @type {string}
@ -129,18 +122,17 @@ var statistics =
}); });
APP.xmpp.addListener(XMPPEvents.PEERCONNECTION_READY, function (session) { APP.xmpp.addListener(XMPPEvents.PEERCONNECTION_READY, function (session) {
CallStats.init(session); CallStats.init(session);
}) });
APP.RTC.addListener(RTCEvents.AUDIO_MUTE, function (mute) { APP.RTC.addListener(RTCEvents.AUDIO_MUTE, function (mute) {
CallStats.sendMuteEvent(mute, "audio"); CallStats.sendMuteEvent(mute, "audio");
}); });
APP.xmpp.addListener(XMPPEvents.CONFERENCE_SETUP_FAILED, function () { APP.xmpp.addListener(XMPPEvents.CONFERENCE_SETUP_FAILED, function () {
CallStats.sendSetupFailedEvent(); CallStats.sendSetupFailedEvent();
}) });
APP.RTC.addListener(RTCEvents.VIDEO_MUTE, function (mute) { APP.RTC.addListener(RTCEvents.VIDEO_MUTE, function (mute) {
CallStats.sendMuteEvent(mute, "video"); CallStats.sendMuteEvent(mute, "video");
}); });
} }
}; };

View File

@ -1,3 +1,4 @@
/* global $, require, config, interfaceConfig */
var i18n = require("i18next-client"); var i18n = require("i18next-client");
var languages = require("../../service/translation/languages"); var languages = require("../../service/translation/languages");
var Settings = require("../settings/Settings"); var Settings = require("../settings/Settings");
@ -23,7 +24,6 @@ var defaultOptions = {
fallbackOnNull: true, fallbackOnNull: true,
fallbackOnEmpty: true, fallbackOnEmpty: true,
useDataAttrOptions: true, useDataAttrOptions: true,
defaultValueFromContent: false,
app: interfaceConfig.APP_NAME, app: interfaceConfig.APP_NAME,
getAsync: false, getAsync: false,
defaultValueFromContent: false, defaultValueFromContent: false,
@ -63,8 +63,7 @@ var defaultOptions = {
// localStorageExpirationTime: 86400000 // in ms, default 1 week // localStorageExpirationTime: 86400000 // in ms, default 1 week
}; };
function initCompleted(t) function initCompleted(t) {
{
$("[data-i18n]").i18n(); $("[data-i18n]").i18n();
} }

View File

@ -1,4 +1,4 @@
/* global $, $iq, APP, config, connection, messageHandler, /* global $, $iq, APP, config, messageHandler,
roomName, sessionTerminated, Strophe, Util */ roomName, sessionTerminated, Strophe, Util */
var XMPPEvents = require("../../service/xmpp/XMPPEvents"); var XMPPEvents = require("../../service/xmpp/XMPPEvents");
var Settings = require("../settings/Settings"); var Settings = require("../settings/Settings");
@ -69,8 +69,8 @@ var Moderator = {
function listener(event) { function listener(event) {
if (event.data && event.data.sessionId) { if (event.data && event.data.sessionId) {
if (event.origin !== window.location.origin) { if (event.origin !== window.location.origin) {
console.warn( console.warn("Ignoring sessionId from different origin: " +
"Ignoring sessionId from different origin: " + event.origin); event.origin);
return; return;
} }
localStorage.setItem('sessionId', event.data.sessionId); localStorage.setItem('sessionId', event.data.sessionId);
@ -219,8 +219,7 @@ var Moderator = {
console.info("Authentication enabled: " + authenticationEnabled); console.info("Authentication enabled: " + authenticationEnabled);
externalAuthEnabled externalAuthEnabled = $(resultIq).find(
= $(resultIq).find(
'>conference>property' + '>conference>property' +
'[name=\'externalAuth\'][value=\'true\']').length > 0; '[name=\'externalAuth\'][value=\'true\']').length > 0;
@ -333,7 +332,8 @@ var Moderator = {
// Do not show in case of session invalid // Do not show in case of session invalid
// which means just a retry // which means just a retry
if (!invalidSession) { if (!invalidSession) {
eventEmitter.emit(XMPPEvents.FOCUS_DISCONNECTED, focusComponent, retrySec); eventEmitter.emit(XMPPEvents.FOCUS_DISCONNECTED,
focusComponent, retrySec);
} }
// Reset response timeout // Reset response timeout
getNextTimeout(true); getNextTimeout(true);

View File

@ -1,4 +1,4 @@
/* global $, $iq, config, connection, focusMucJid, messageHandler, Moderator, /* global $, $iq, config, connection, focusMucJid, messageHandler,
Toolbar, Util */ Toolbar, Util */
var Moderator = require("./moderator"); var Moderator = require("./moderator");
@ -23,14 +23,6 @@ function setRecordingToken(token) {
recordingToken = token; recordingToken = token;
} }
function setRecording(state, token, callback, connection) {
if (useJirecon){
setRecordingJirecon(state, token, callback, connection);
} else {
setRecordingColibri(state, token, callback, connection);
}
}
function setRecordingJirecon(state, token, callback, connection) { function setRecordingJirecon(state, token, callback, connection) {
if (state == recordingEnabled){ if (state == recordingEnabled){
return; return;
@ -93,6 +85,14 @@ function setRecordingColibri(state, token, callback, connection) {
); );
} }
function setRecording(state, token, callback, connection) {
if (useJirecon){
setRecordingJirecon(state, token, callback, connection);
} else {
setRecordingColibri(state, token, callback, connection);
}
}
var Recording = { var Recording = {
toggleRecording: function (tokenEmptyCallback, toggleRecording: function (tokenEmptyCallback,
startingCallback, startedCallback, connection) { startingCallback, startedCallback, connection) {
@ -150,6 +150,6 @@ var Recording = {
); );
} }
} };
module.exports = Recording; module.exports = Recording;

View File

@ -5,8 +5,6 @@
var XMPPEvents = require("../../service/xmpp/XMPPEvents"); var XMPPEvents = require("../../service/xmpp/XMPPEvents");
var Moderator = require("./moderator"); var Moderator = require("./moderator");
var bridgeIsDown = false;
module.exports = function(XMPP, eventEmitter) { module.exports = function(XMPP, eventEmitter) {
Strophe.addConnectionPlugin('emuc', { Strophe.addConnectionPlugin('emuc', {
connection: null, connection: null,
@ -20,18 +18,17 @@ module.exports = function(XMPP, eventEmitter) {
isOwner: false, isOwner: false,
role: null, role: null,
focusMucJid: null, focusMucJid: null,
bridgeIsDown: false,
init: function (conn) { init: function (conn) {
this.connection = conn; this.connection = conn;
}, },
initPresenceMap: function (myroomjid) { initPresenceMap: function (myroomjid) {
this.presMap['to'] = myroomjid; this.presMap['to'] = myroomjid;
this.presMap['xns'] = 'http://jabber.org/protocol/muc'; this.presMap['xns'] = 'http://jabber.org/protocol/muc';
if (APP.RTC.localAudio && APP.RTC.localAudio.isMuted()) if (APP.RTC.localAudio && APP.RTC.localAudio.isMuted()) {
{
this.addAudioInfoToPresence(true); this.addAudioInfoToPresence(true);
} }
if (APP.RTC.localVideo && APP.RTC.localVideo.isMuted()) if (APP.RTC.localVideo && APP.RTC.localVideo.isMuted()) {
{
this.addVideoInfoToPresence(true); this.addVideoInfoToPresence(true);
} }
}, },
@ -591,27 +588,25 @@ module.exports = function(XMPP, eventEmitter) {
Moderator.onMucMemberLeft(jid); Moderator.onMucMemberLeft(jid);
}, },
parsePresence: function (from, memeber, pres) { parsePresence: function (from, member, pres) {
if($(pres).find(">bridgeIsDown").length > 0 && !bridgeIsDown) { if($(pres).find(">bridgeIsDown").length > 0 && !this.bridgeIsDown) {
bridgeIsDown = true; this.bridgeIsDown = true;
eventEmitter.emit(XMPPEvents.BRIDGE_DOWN); eventEmitter.emit(XMPPEvents.BRIDGE_DOWN);
} }
if(memeber.isFocus) if(member.isFocus)
return; return;
var displayName = !config.displayJids var displayName = !config.displayJids
? memeber.displayName : Strophe.getResourceFromJid(from); ? member.displayName : Strophe.getResourceFromJid(from);
if (displayName && displayName.length > 0) if (displayName && displayName.length > 0) {
{
eventEmitter.emit(XMPPEvents.DISPLAY_NAME_CHANGED, from, displayName); eventEmitter.emit(XMPPEvents.DISPLAY_NAME_CHANGED, from, displayName);
} }
var id = $(pres).find('>userID').text(); var id = $(pres).find('>userID').text();
var email = $(pres).find('>email'); var email = $(pres).find('>email');
if(email.length > 0) { if (email.length > 0) {
id = email.text(); id = email.text();
} }

View File

@ -5,8 +5,7 @@ var XMPPEvents = require("../../service/xmpp/XMPPEvents");
var RTCBrowserType = require("../RTC/RTCBrowserType"); var RTCBrowserType = require("../RTC/RTCBrowserType");
module.exports = function(XMPP, eventEmitter) module.exports = function(XMPP, eventEmitter) {
{
function CallIncomingJingle(sid, connection) { function CallIncomingJingle(sid, connection) {
var sess = connection.jingle.sessions[sid]; var sess = connection.jingle.sessions[sid];
@ -21,7 +20,7 @@ module.exports = function(XMPP, eventEmitter)
sess.sendAnswer(); sess.sendAnswer();
sess.accept(); sess.accept();
}; }
Strophe.addConnectionPlugin('jingle', { Strophe.addConnectionPlugin('jingle', {
connection: null, connection: null,
@ -115,8 +114,7 @@ module.exports = function(XMPP, eventEmitter)
switch (action) { switch (action) {
case 'session-initiate': case 'session-initiate':
var startMuted = $(iq).find('jingle>startmuted'); var startMuted = $(iq).find('jingle>startmuted');
if (startMuted && startMuted.length > 0) if (startMuted && startMuted.length > 0) {
{
var audioMuted = startMuted.attr("audio"); var audioMuted = startMuted.attr("audio");
var videoMuted = startMuted.attr("video"); var videoMuted = startMuted.attr("video");
eventEmitter.emit(XMPPEvents.START_MUTED_FROM_FOCUS, eventEmitter.emit(XMPPEvents.START_MUTED_FROM_FOCUS,