Fixes some issues related to xmpp module creation.

This commit is contained in:
hristoterezov 2015-01-19 18:54:41 +02:00
parent 3da8e39745
commit 6347730dc7
12 changed files with 105 additions and 91 deletions

View File

@ -25,19 +25,19 @@
<script src="service/RTC/MediaStreamTypes.js?v=1"></script> <script src="service/RTC/MediaStreamTypes.js?v=1"></script>
<script src="service/xmpp/XMPPEvents.js?v=1"></script> <script src="service/xmpp/XMPPEvents.js?v=1"></script>
<script src="service/desktopsharing/DesktopSharingEventTypes.js?v=1"></script> <script src="service/desktopsharing/DesktopSharingEventTypes.js?v=1"></script>
<script src="libs/modules/simulcast.bundle.js?v=3"></script> <script src="libs/modules/simulcast.bundle.js?v=4"></script>
<script src="libs/modules/connectionquality.bundle.js?v=1"></script> <script src="libs/modules/connectionquality.bundle.js?v=2"></script>
<script src="libs/modules/UI.bundle.js?v=5"></script> <script src="libs/modules/UI.bundle.js?v=6"></script>
<script src="libs/modules/statistics.bundle.js?v=1"></script> <script src="libs/modules/statistics.bundle.js?v=2"></script>
<script src="libs/modules/RTC.bundle.js?v=4"></script> <script src="libs/modules/RTC.bundle.js?v=5"></script>
<script src="libs/modules/desktopsharing.bundle.js?v=3"></script><!-- desktop sharing --> <script src="libs/modules/desktopsharing.bundle.js?v=3"></script><!-- desktop sharing -->
<script src="util.js?v=7"></script><!-- utility functions --> <script src="util.js?v=7"></script><!-- utility functions -->
<script src="libs/modules/xmpp.bundle.js?v=1"></script> <script src="libs/modules/xmpp.bundle.js?v=1"></script>
<script src="app.js?v=26"></script><!-- application logic --> <script src="app.js?v=27"></script><!-- application logic -->
<script src="libs/modules/API.bundle.js?v=1"></script> <script src="libs/modules/API.bundle.js?v=1"></script>
<script src="analytics.js?v=1"></script><!-- google analytics plugin --> <script src="analytics.js?v=1"></script><!-- google analytics plugin -->
<script src="keyboard_shortcut.js?v=4"></script> <script src="keyboard_shortcut.js?v=5"></script>
<link rel="stylesheet" href="css/font.css?v=6"/> <link rel="stylesheet" href="css/font.css?v=6"/>
<link rel="stylesheet" href="css/toastr.css?v=1"> <link rel="stylesheet" href="css/toastr.css?v=1">
<link rel="stylesheet" type="text/css" media="screen" href="css/main.css?v=30"/> <link rel="stylesheet" type="text/css" media="screen" href="css/main.css?v=30"/>

View File

@ -184,9 +184,9 @@ var DataChannels =
} }
function onSelectedEndpointChanged(userJid) function onSelectedEndpointChanged(userResource)
{ {
console.log('selected endpoint changed: ', userJid); console.log('selected endpoint changed: ', userResource);
if (_dataChannels && _dataChannels.length != 0) if (_dataChannels && _dataChannels.length != 0)
{ {
_dataChannels.some(function (dataChannel) { _dataChannels.some(function (dataChannel) {
@ -194,8 +194,9 @@ function onSelectedEndpointChanged(userJid)
{ {
dataChannel.send(JSON.stringify({ dataChannel.send(JSON.stringify({
'colibriClass': 'SelectedEndpointChangedEvent', 'colibriClass': 'SelectedEndpointChangedEvent',
'selectedEndpoint': (!userJid || userJid == null) 'selectedEndpoint':
? null : userJid (!userResource || userResource === null)?
null : userResource
})); }));
return true; return true;
@ -204,13 +205,13 @@ function onSelectedEndpointChanged(userJid)
} }
} }
$(document).bind("selectedendpointchanged", function(event, userJid) { $(document).bind("selectedendpointchanged", function(event, userResource) {
onSelectedEndpointChanged(userJid); onSelectedEndpointChanged(userResource);
}); });
function onPinnedEndpointChanged(userJid) function onPinnedEndpointChanged(userResource)
{ {
console.log('pinned endpoint changed: ', userJid); console.log('pinned endpoint changed: ', userResource);
if (_dataChannels && _dataChannels.length != 0) if (_dataChannels && _dataChannels.length != 0)
{ {
_dataChannels.some(function (dataChannel) { _dataChannels.some(function (dataChannel) {
@ -218,8 +219,9 @@ function onPinnedEndpointChanged(userJid)
{ {
dataChannel.send(JSON.stringify({ dataChannel.send(JSON.stringify({
'colibriClass': 'PinnedEndpointChangedEvent', 'colibriClass': 'PinnedEndpointChangedEvent',
'pinnedEndpoint': (!userJid || userJid == null) 'pinnedEndpoint':
? null : Strophe.getResourceFromJid(userJid) (!userResource || userResource == null)?
null : userResource
})); }));
return true; return true;
@ -228,8 +230,8 @@ function onPinnedEndpointChanged(userJid)
} }
} }
$(document).bind("pinnedendpointchanged", function(event, userJid) { $(document).bind("pinnedendpointchanged", function(event, userResource) {
onPinnedEndpointChanged(userJid); onPinnedEndpointChanged(userResource);
}); });
module.exports = DataChannels; module.exports = DataChannels;
@ -339,7 +341,7 @@ module.exports = LocalStream;
* *
* @constructor * @constructor
*/ */
function MediaStream(data, sid, ssrc, eventEmmiter, browser) { function MediaStream(data, sid, ssrc, browser) {
// XXX(gp) to minimize headaches in the future, we should build our // XXX(gp) to minimize headaches in the future, we should build our
// abstractions around tracks and not streams. ORTC is track based API. // abstractions around tracks and not streams. ORTC is track based API.
@ -358,7 +360,6 @@ function MediaStream(data, sid, ssrc, eventEmmiter, browser) {
this.type = (this.stream.getVideoTracks().length > 0)? this.type = (this.stream.getVideoTracks().length > 0)?
MediaStreamType.VIDEO_TYPE : MediaStreamType.AUDIO_TYPE; MediaStreamType.VIDEO_TYPE : MediaStreamType.AUDIO_TYPE;
this.muted = false; this.muted = false;
eventEmmiter.emit(StreamEventTypes.EVENT_TYPE_REMOTE_CREATED, this);
if(browser == RTCBrowserType.RTC_BROWSER_FIREFOX) if(browser == RTCBrowserType.RTC_BROWSER_FIREFOX)
{ {
if (!this.getVideoTracks) if (!this.getVideoTracks)
@ -442,13 +443,15 @@ var RTC = {
} }
}, },
createRemoteStream: function (data, sid, thessrc) { createRemoteStream: function (data, sid, thessrc) {
var remoteStream = new MediaStream(data, sid, thessrc, eventEmitter, var remoteStream = new MediaStream(data, sid, thessrc,
this.getBrowserType()); this.getBrowserType());
var jid = data.peerjid || xmpp.myJid(); var jid = data.peerjid || xmpp.myJid();
if(!this.remoteStreams[jid]) { if(!this.remoteStreams[jid]) {
this.remoteStreams[jid] = {}; this.remoteStreams[jid] = {};
} }
this.remoteStreams[jid][remoteStream.type]= remoteStream; this.remoteStreams[jid][remoteStream.type]= remoteStream;
eventEmitter.emit(StreamEventTypes.EVENT_TYPE_REMOTE_CREATED, remoteStream);
console.debug("ADD remote stream ", remoteStream.type, " ", jid, " ", thessrc);
return remoteStream; return remoteStream;
}, },
getBrowserType: function () { getBrowserType: function () {

View File

@ -6129,7 +6129,7 @@ var VideoLayout = (function (my) {
// picked up later by the lastN changed event handler. // picked up later by the lastN changed event handler.
lastNPickupJid = jid; lastNPickupJid = jid;
$(document).trigger("pinnedendpointchanged", [jid]); $(document).trigger("pinnedendpointchanged", [Strophe.getResourceFromJid(jid)]);
} }
} else if (jid == xmpp.myJid()) { } else if (jid == xmpp.myJid()) {
$("#localVideoContainer").click(); $("#localVideoContainer").click();

View File

@ -219,7 +219,7 @@ SimulcastReceiver.prototype.getReceivingVideoStreamBySSRC = function (ssrc)
var sid, electedStream; var sid, electedStream;
var i, j, k; var i, j, k;
var jid = ssrc2jid[ssrc]; var jid = ssrc2jid[ssrc];
if(jid) if(jid && RTC.remoteStreams[jid])
{ {
var remoteStreamObject = RTC.remoteStreams[jid][MediaStreamType.VIDEO_TYPE]; var remoteStreamObject = RTC.remoteStreams[jid][MediaStreamType.VIDEO_TYPE];
var remoteStream = remoteStreamObject.getOriginalStream(); var remoteStream = remoteStreamObject.getOriginalStream();
@ -239,6 +239,10 @@ SimulcastReceiver.prototype.getReceivingVideoStreamBySSRC = function (ssrc)
} }
} }
else
{
console.debug(RTC.remoteStreams, jid, ssrc);
}
return { return {
sid: sid, sid: sid,

View File

@ -3827,31 +3827,32 @@ module.exports = function(XMPP, eventEmitter) {
var JingleSession = require("./JingleSession"); var JingleSession = require("./JingleSession");
function CallIncomingJingle(sid, connection) {
var sess = connection.jingle.sessions[sid];
// TODO: do we check activecall == null?
activecall = sess;
statistics.onConferenceCreated(sess);
RTC.onConferenceCreated(sess);
// TODO: check affiliation and/or role
console.log('emuc data for', sess.peerjid, connection.emuc.members[sess.peerjid]);
sess.usedrip = true; // not-so-naive trickle ice
sess.sendAnswer();
sess.accept();
};
module.exports = function(XMPP) module.exports = function(XMPP)
{ {
function CallIncomingJingle(sid, connection) {
var sess = connection.jingle.sessions[sid];
// TODO: do we check activecall == null?
connection.jingle.activecall = sess;
statistics.onConferenceCreated(sess);
RTC.onConferenceCreated(sess);
// TODO: check affiliation and/or role
console.log('emuc data for', sess.peerjid, connection.emuc.members[sess.peerjid]);
sess.usedrip = true; // not-so-naive trickle ice
sess.sendAnswer();
sess.accept();
};
Strophe.addConnectionPlugin('jingle', { Strophe.addConnectionPlugin('jingle', {
connection: null, connection: null,
sessions: {}, sessions: {},
jid2session: {}, jid2session: {},
ice_config: {iceServers: []}, ice_config: {iceServers: []},
pc_constraints: {}, pc_constraints: {},
activecall: null,
media_constraints: { media_constraints: {
mandatory: { mandatory: {
'OfferToReceiveAudio': true, 'OfferToReceiveAudio': true,
@ -4389,7 +4390,6 @@ var SDP = require("./SDP");
var eventEmitter = new EventEmitter(); var eventEmitter = new EventEmitter();
var connection = null; var connection = null;
var authenticatedUser = false; var authenticatedUser = false;
var activecall = null;
function connect(jid, password, uiCredentials) { function connect(jid, password, uiCredentials) {
var bosh var bosh
@ -4576,7 +4576,7 @@ var XMPP = {
}, },
disposeConference: function (onUnload) { disposeConference: function (onUnload) {
eventEmitter.emit(XMPPEvents.DISPOSE_CONFERENCE, onUnload); eventEmitter.emit(XMPPEvents.DISPOSE_CONFERENCE, onUnload);
var handler = activecall; var handler = connection.jingle.activecall;
if (handler && handler.peerconnection) { if (handler && handler.peerconnection) {
// FIXME: probably removing streams is not required and close() should // FIXME: probably removing streams is not required and close() should
// be enough // be enough
@ -4588,7 +4588,7 @@ var XMPP = {
} }
handler.peerconnection.close(); handler.peerconnection.close();
} }
activecall = null; connection.jingle.activecall = null;
if(!onUnload) if(!onUnload)
{ {
this.sessionTerminated = true; this.sessionTerminated = true;
@ -4615,9 +4615,9 @@ var XMPP = {
return Moderator.isExternalAuthEnabled(); return Moderator.isExternalAuthEnabled();
}, },
switchStreams: function (stream, oldStream, callback) { switchStreams: function (stream, oldStream, callback) {
if (activecall) { if (connection && connection.jingle.activecall) {
// FIXME: will block switchInProgress on true value in case of exception // FIXME: will block switchInProgress on true value in case of exception
activecall.switchStreams(stream, oldStream, callback); connection.jingle.activecall.switchStreams(stream, oldStream, callback);
} else { } else {
// We are done immediately // We are done immediately
console.error("No conference handler"); console.error("No conference handler");
@ -4627,9 +4627,9 @@ var XMPP = {
} }
}, },
setVideoMute: function (mute, callback, options) { setVideoMute: function (mute, callback, options) {
if(activecall && connection && RTC.localVideo) if(connection && RTC.localVideo && connection.jingle.activecall)
{ {
activecall.setVideoMute(mute, callback, options); connection.jingle.activecall.setVideoMute(mute, callback, options);
} }
}, },
setAudioMute: function (mute, callback) { setAudioMute: function (mute, callback) {
@ -4797,7 +4797,7 @@ var XMPP = {
connection.moderate.eject(jid); connection.moderate.eject(jid);
}, },
findJidFromResource: function (resource) { findJidFromResource: function (resource) {
connection.emuc.findJidFromResource(resource); return connection.emuc.findJidFromResource(resource);
}, },
getMembers: function () { getMembers: function () {
return connection.emuc.members; return connection.emuc.members;

View File

@ -183,9 +183,9 @@ var DataChannels =
} }
function onSelectedEndpointChanged(userJid) function onSelectedEndpointChanged(userResource)
{ {
console.log('selected endpoint changed: ', userJid); console.log('selected endpoint changed: ', userResource);
if (_dataChannels && _dataChannels.length != 0) if (_dataChannels && _dataChannels.length != 0)
{ {
_dataChannels.some(function (dataChannel) { _dataChannels.some(function (dataChannel) {
@ -193,8 +193,9 @@ function onSelectedEndpointChanged(userJid)
{ {
dataChannel.send(JSON.stringify({ dataChannel.send(JSON.stringify({
'colibriClass': 'SelectedEndpointChangedEvent', 'colibriClass': 'SelectedEndpointChangedEvent',
'selectedEndpoint': (!userJid || userJid == null) 'selectedEndpoint':
? null : userJid (!userResource || userResource === null)?
null : userResource
})); }));
return true; return true;
@ -203,13 +204,13 @@ function onSelectedEndpointChanged(userJid)
} }
} }
$(document).bind("selectedendpointchanged", function(event, userJid) { $(document).bind("selectedendpointchanged", function(event, userResource) {
onSelectedEndpointChanged(userJid); onSelectedEndpointChanged(userResource);
}); });
function onPinnedEndpointChanged(userJid) function onPinnedEndpointChanged(userResource)
{ {
console.log('pinned endpoint changed: ', userJid); console.log('pinned endpoint changed: ', userResource);
if (_dataChannels && _dataChannels.length != 0) if (_dataChannels && _dataChannels.length != 0)
{ {
_dataChannels.some(function (dataChannel) { _dataChannels.some(function (dataChannel) {
@ -217,8 +218,9 @@ function onPinnedEndpointChanged(userJid)
{ {
dataChannel.send(JSON.stringify({ dataChannel.send(JSON.stringify({
'colibriClass': 'PinnedEndpointChangedEvent', 'colibriClass': 'PinnedEndpointChangedEvent',
'pinnedEndpoint': (!userJid || userJid == null) 'pinnedEndpoint':
? null : Strophe.getResourceFromJid(userJid) (!userResource || userResource == null)?
null : userResource
})); }));
return true; return true;
@ -227,8 +229,8 @@ function onPinnedEndpointChanged(userJid)
} }
} }
$(document).bind("pinnedendpointchanged", function(event, userJid) { $(document).bind("pinnedendpointchanged", function(event, userResource) {
onPinnedEndpointChanged(userJid); onPinnedEndpointChanged(userResource);
}); });
module.exports = DataChannels; module.exports = DataChannels;

View File

@ -14,7 +14,7 @@
* *
* @constructor * @constructor
*/ */
function MediaStream(data, sid, ssrc, eventEmmiter, browser) { function MediaStream(data, sid, ssrc, browser) {
// XXX(gp) to minimize headaches in the future, we should build our // XXX(gp) to minimize headaches in the future, we should build our
// abstractions around tracks and not streams. ORTC is track based API. // abstractions around tracks and not streams. ORTC is track based API.
@ -33,7 +33,6 @@ function MediaStream(data, sid, ssrc, eventEmmiter, browser) {
this.type = (this.stream.getVideoTracks().length > 0)? this.type = (this.stream.getVideoTracks().length > 0)?
MediaStreamType.VIDEO_TYPE : MediaStreamType.AUDIO_TYPE; MediaStreamType.VIDEO_TYPE : MediaStreamType.AUDIO_TYPE;
this.muted = false; this.muted = false;
eventEmmiter.emit(StreamEventTypes.EVENT_TYPE_REMOTE_CREATED, this);
if(browser == RTCBrowserType.RTC_BROWSER_FIREFOX) if(browser == RTCBrowserType.RTC_BROWSER_FIREFOX)
{ {
if (!this.getVideoTracks) if (!this.getVideoTracks)

View File

@ -56,13 +56,15 @@ var RTC = {
} }
}, },
createRemoteStream: function (data, sid, thessrc) { createRemoteStream: function (data, sid, thessrc) {
var remoteStream = new MediaStream(data, sid, thessrc, eventEmitter, var remoteStream = new MediaStream(data, sid, thessrc,
this.getBrowserType()); this.getBrowserType());
var jid = data.peerjid || xmpp.myJid(); var jid = data.peerjid || xmpp.myJid();
if(!this.remoteStreams[jid]) { if(!this.remoteStreams[jid]) {
this.remoteStreams[jid] = {}; this.remoteStreams[jid] = {};
} }
this.remoteStreams[jid][remoteStream.type]= remoteStream; this.remoteStreams[jid][remoteStream.type]= remoteStream;
eventEmitter.emit(StreamEventTypes.EVENT_TYPE_REMOTE_CREATED, remoteStream);
console.debug("ADD remote stream ", remoteStream.type, " ", jid, " ", thessrc);
return remoteStream; return remoteStream;
}, },
getBrowserType: function () { getBrowserType: function () {

View File

@ -1742,7 +1742,7 @@ var VideoLayout = (function (my) {
// picked up later by the lastN changed event handler. // picked up later by the lastN changed event handler.
lastNPickupJid = jid; lastNPickupJid = jid;
$(document).trigger("pinnedendpointchanged", [jid]); $(document).trigger("pinnedendpointchanged", [Strophe.getResourceFromJid(jid)]);
} }
} else if (jid == xmpp.myJid()) { } else if (jid == xmpp.myJid()) {
$("#localVideoContainer").click(); $("#localVideoContainer").click();

View File

@ -185,7 +185,7 @@ SimulcastReceiver.prototype.getReceivingVideoStreamBySSRC = function (ssrc)
var sid, electedStream; var sid, electedStream;
var i, j, k; var i, j, k;
var jid = ssrc2jid[ssrc]; var jid = ssrc2jid[ssrc];
if(jid) if(jid && RTC.remoteStreams[jid])
{ {
var remoteStreamObject = RTC.remoteStreams[jid][MediaStreamType.VIDEO_TYPE]; var remoteStreamObject = RTC.remoteStreams[jid][MediaStreamType.VIDEO_TYPE];
var remoteStream = remoteStreamObject.getOriginalStream(); var remoteStream = remoteStreamObject.getOriginalStream();
@ -205,6 +205,10 @@ SimulcastReceiver.prototype.getReceivingVideoStreamBySSRC = function (ssrc)
} }
} }
else
{
console.debug(RTC.remoteStreams, jid, ssrc);
}
return { return {
sid: sid, sid: sid,

View File

@ -2,31 +2,32 @@
var JingleSession = require("./JingleSession"); var JingleSession = require("./JingleSession");
function CallIncomingJingle(sid, connection) {
var sess = connection.jingle.sessions[sid];
// TODO: do we check activecall == null?
activecall = sess;
statistics.onConferenceCreated(sess);
RTC.onConferenceCreated(sess);
// TODO: check affiliation and/or role
console.log('emuc data for', sess.peerjid, connection.emuc.members[sess.peerjid]);
sess.usedrip = true; // not-so-naive trickle ice
sess.sendAnswer();
sess.accept();
};
module.exports = function(XMPP) module.exports = function(XMPP)
{ {
function CallIncomingJingle(sid, connection) {
var sess = connection.jingle.sessions[sid];
// TODO: do we check activecall == null?
connection.jingle.activecall = sess;
statistics.onConferenceCreated(sess);
RTC.onConferenceCreated(sess);
// TODO: check affiliation and/or role
console.log('emuc data for', sess.peerjid, connection.emuc.members[sess.peerjid]);
sess.usedrip = true; // not-so-naive trickle ice
sess.sendAnswer();
sess.accept();
};
Strophe.addConnectionPlugin('jingle', { Strophe.addConnectionPlugin('jingle', {
connection: null, connection: null,
sessions: {}, sessions: {},
jid2session: {}, jid2session: {},
ice_config: {iceServers: []}, ice_config: {iceServers: []},
pc_constraints: {}, pc_constraints: {},
activecall: null,
media_constraints: { media_constraints: {
mandatory: { mandatory: {
'OfferToReceiveAudio': true, 'OfferToReceiveAudio': true,

View File

@ -6,7 +6,6 @@ var SDP = require("./SDP");
var eventEmitter = new EventEmitter(); var eventEmitter = new EventEmitter();
var connection = null; var connection = null;
var authenticatedUser = false; var authenticatedUser = false;
var activecall = null;
function connect(jid, password, uiCredentials) { function connect(jid, password, uiCredentials) {
var bosh var bosh
@ -193,7 +192,7 @@ var XMPP = {
}, },
disposeConference: function (onUnload) { disposeConference: function (onUnload) {
eventEmitter.emit(XMPPEvents.DISPOSE_CONFERENCE, onUnload); eventEmitter.emit(XMPPEvents.DISPOSE_CONFERENCE, onUnload);
var handler = activecall; var handler = connection.jingle.activecall;
if (handler && handler.peerconnection) { if (handler && handler.peerconnection) {
// FIXME: probably removing streams is not required and close() should // FIXME: probably removing streams is not required and close() should
// be enough // be enough
@ -205,7 +204,7 @@ var XMPP = {
} }
handler.peerconnection.close(); handler.peerconnection.close();
} }
activecall = null; connection.jingle.activecall = null;
if(!onUnload) if(!onUnload)
{ {
this.sessionTerminated = true; this.sessionTerminated = true;
@ -232,9 +231,9 @@ var XMPP = {
return Moderator.isExternalAuthEnabled(); return Moderator.isExternalAuthEnabled();
}, },
switchStreams: function (stream, oldStream, callback) { switchStreams: function (stream, oldStream, callback) {
if (activecall) { if (connection && connection.jingle.activecall) {
// FIXME: will block switchInProgress on true value in case of exception // FIXME: will block switchInProgress on true value in case of exception
activecall.switchStreams(stream, oldStream, callback); connection.jingle.activecall.switchStreams(stream, oldStream, callback);
} else { } else {
// We are done immediately // We are done immediately
console.error("No conference handler"); console.error("No conference handler");
@ -244,9 +243,9 @@ var XMPP = {
} }
}, },
setVideoMute: function (mute, callback, options) { setVideoMute: function (mute, callback, options) {
if(activecall && connection && RTC.localVideo) if(connection && RTC.localVideo && connection.jingle.activecall)
{ {
activecall.setVideoMute(mute, callback, options); connection.jingle.activecall.setVideoMute(mute, callback, options);
} }
}, },
setAudioMute: function (mute, callback) { setAudioMute: function (mute, callback) {
@ -414,7 +413,7 @@ var XMPP = {
connection.moderate.eject(jid); connection.moderate.eject(jid);
}, },
findJidFromResource: function (resource) { findJidFromResource: function (resource) {
connection.emuc.findJidFromResource(resource); return connection.emuc.findJidFromResource(resource);
}, },
getMembers: function () { getMembers: function () {
return connection.emuc.members; return connection.emuc.members;