Extracts base class for ColibriFocus and JingleSession.
This commit is contained in:
parent
a2633e20e8
commit
a5951df0d9
2
app.js
2
app.js
|
@ -4,7 +4,6 @@ var connection = null;
|
||||||
var focus = null;
|
var focus = null;
|
||||||
var activecall = null;
|
var activecall = null;
|
||||||
var RTC = null;
|
var RTC = null;
|
||||||
var RTCPeerConnection = null;
|
|
||||||
var nickname = null;
|
var nickname = null;
|
||||||
var sharedKey = '';
|
var sharedKey = '';
|
||||||
var roomUrl = null;
|
var roomUrl = null;
|
||||||
|
@ -23,7 +22,6 @@ function init() {
|
||||||
window.location.href = 'chromeonly.html';
|
window.location.href = 'chromeonly.html';
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
RTCPeerconnection = TraceablePeerConnection;
|
|
||||||
|
|
||||||
connection = new Strophe.Connection(document.getElementById('boshURL').value || config.bosh || '/http-bind');
|
connection = new Strophe.Connection(document.getElementById('boshURL').value || config.bosh || '/http-bind');
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
<script src="libs/strophe/strophe.jingle.bundle.js?v=8"></script>
|
<script src="libs/strophe/strophe.jingle.bundle.js?v=8"></script>
|
||||||
<script src="libs/strophe/strophe.jingle.js?v=1"></script>
|
<script src="libs/strophe/strophe.jingle.js?v=1"></script>
|
||||||
<script src="libs/strophe/strophe.jingle.sdp.js?v=1"></script>
|
<script src="libs/strophe/strophe.jingle.sdp.js?v=1"></script>
|
||||||
|
<script src="libs/strophe/strophe.jingle.sessionbase.js?v=1"></script>
|
||||||
<script src="libs/strophe/strophe.jingle.session.js?v=1"></script>
|
<script src="libs/strophe/strophe.jingle.session.js?v=1"></script>
|
||||||
<script src="libs/colibri/colibri.focus.js?v=8"></script><!-- colibri focus implementation -->
|
<script src="libs/colibri/colibri.focus.js?v=8"></script><!-- colibri focus implementation -->
|
||||||
<script src="libs/colibri/colibri.session.js?v=1"></script>
|
<script src="libs/colibri/colibri.session.js?v=1"></script>
|
||||||
|
|
|
@ -34,17 +34,16 @@
|
||||||
THE SOFTWARE.
|
THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
/* jshint -W117 */
|
/* jshint -W117 */
|
||||||
|
|
||||||
|
ColibriFocus.prototype = Object.create(SessionBase.prototype);
|
||||||
function ColibriFocus(connection, bridgejid) {
|
function ColibriFocus(connection, bridgejid) {
|
||||||
this.connection = connection;
|
|
||||||
|
SessionBase.call(this, connection);
|
||||||
|
|
||||||
this.bridgejid = bridgejid;
|
this.bridgejid = bridgejid;
|
||||||
this.peers = [];
|
this.peers = [];
|
||||||
this.confid = null;
|
this.confid = null;
|
||||||
|
|
||||||
this.peerconnection
|
|
||||||
= new TraceablePeerConnection(
|
|
||||||
this.connection.jingle.ice_config,
|
|
||||||
this.connection.jingle.pc_constraints);
|
|
||||||
|
|
||||||
// media types of the conference
|
// media types of the conference
|
||||||
this.media = ['audio', 'video'];
|
this.media = ['audio', 'video'];
|
||||||
|
|
||||||
|
@ -623,9 +622,7 @@ ColibriFocus.prototype.sendSSRCUpdate = function (sdp, jid, isadd) {
|
||||||
ColibriFocus.prototype.setRemoteDescription = function (session, elem, desctype) {
|
ColibriFocus.prototype.setRemoteDescription = function (session, elem, desctype) {
|
||||||
var participant = this.peers.indexOf(session.peerjid);
|
var participant = this.peers.indexOf(session.peerjid);
|
||||||
console.log('Colibri.setRemoteDescription from', session.peerjid, participant);
|
console.log('Colibri.setRemoteDescription from', session.peerjid, participant);
|
||||||
var self = this;
|
|
||||||
var remoteSDP = new SDP('');
|
var remoteSDP = new SDP('');
|
||||||
var tmp;
|
|
||||||
var channel;
|
var channel;
|
||||||
remoteSDP.fromJingle(elem);
|
remoteSDP.fromJingle(elem);
|
||||||
|
|
||||||
|
@ -800,19 +797,3 @@ ColibriFocus.prototype.terminate = function (session, reason) {
|
||||||
delete this.remotessrc[session.peerjid];
|
delete this.remotessrc[session.peerjid];
|
||||||
this.modifySources();
|
this.modifySources();
|
||||||
};
|
};
|
||||||
|
|
||||||
ColibriFocus.prototype.modifySources = function () {
|
|
||||||
var self = this;
|
|
||||||
this.peerconnection.modifySources(function(){
|
|
||||||
$(document).trigger('setLocalDescription.jingle', [self.sid]);
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
ColibriFocus.prototype.hardMuteVideo = function (muted) {
|
|
||||||
|
|
||||||
this.peerconnection.hardMuteVideo(muted);
|
|
||||||
|
|
||||||
this.connection.jingle.localVideo.getVideoTracks().forEach(function (track) {
|
|
||||||
track.enabled = !muted;
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
|
@ -1,27 +1,17 @@
|
||||||
/* jshint -W117 */
|
/* jshint -W117 */
|
||||||
// Jingle stuff
|
// Jingle stuff
|
||||||
|
JingleSession.prototype = Object.create(SessionBase.prototype);
|
||||||
function JingleSession(me, sid, connection) {
|
function JingleSession(me, sid, connection) {
|
||||||
|
|
||||||
|
SessionBase.call(this, connection);
|
||||||
|
|
||||||
this.me = me;
|
this.me = me;
|
||||||
this.sid = sid;
|
this.sid = sid;
|
||||||
this.connection = connection;
|
|
||||||
this.initiator = null;
|
this.initiator = null;
|
||||||
this.responder = null;
|
this.responder = null;
|
||||||
this.isInitiator = null;
|
this.isInitiator = null;
|
||||||
this.peerjid = null;
|
this.peerjid = null;
|
||||||
this.state = null;
|
this.state = null;
|
||||||
/**
|
|
||||||
* Peer connection instance.
|
|
||||||
* @type {TraceablePeerConnection}
|
|
||||||
*/
|
|
||||||
this.peerconnection = null;
|
|
||||||
//console.log('create PeerConnection ' + JSON.stringify(this.ice_config));
|
|
||||||
try {
|
|
||||||
this.peerconnection = new RTCPeerconnection(this.ice_config, this.pc_constraints);
|
|
||||||
} catch (e) {
|
|
||||||
console.error('Failed to create PeerConnection, exception: ', e.message);
|
|
||||||
console.error(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
this.localSDP = null;
|
this.localSDP = null;
|
||||||
this.remoteSDP = null;
|
this.remoteSDP = null;
|
||||||
this.localStreams = [];
|
this.localStreams = [];
|
||||||
|
@ -633,39 +623,6 @@ JingleSession.prototype.sendTerminate = function (reason, text) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
JingleSession.prototype.addSource = function (elem) {
|
|
||||||
|
|
||||||
this.peerconnection.addSource(elem);
|
|
||||||
|
|
||||||
this.modifySources();
|
|
||||||
};
|
|
||||||
|
|
||||||
JingleSession.prototype.removeSource = function (elem) {
|
|
||||||
|
|
||||||
this.peerconnection.removeSource(elem);
|
|
||||||
|
|
||||||
this.modifySources();
|
|
||||||
};
|
|
||||||
|
|
||||||
JingleSession.prototype.modifySources = function() {
|
|
||||||
var self = this;
|
|
||||||
this.peerconnection.modifySources(function(){
|
|
||||||
$(document).trigger('setLocalDescription.jingle', [self.sid]);
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
// SDP-based mute by going recvonly/sendrecv
|
|
||||||
// FIXME: should probably black out the screen as well
|
|
||||||
JingleSession.prototype.hardMuteVideo = function (muted) {
|
|
||||||
|
|
||||||
this.peerconnection.hardMuteVideo(muted);
|
|
||||||
|
|
||||||
this.connection.jingle.localVideo.getVideoTracks().forEach(function (track) {
|
|
||||||
track.enabled = !muted;
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
JingleSession.prototype.sendMute = function (muted, content) {
|
JingleSession.prototype.sendMute = function (muted, content) {
|
||||||
var info = $iq({to: this.peerjid,
|
var info = $iq({to: this.peerjid,
|
||||||
type: 'set'})
|
type: 'set'})
|
||||||
|
|
|
@ -0,0 +1,46 @@
|
||||||
|
/**
|
||||||
|
* Base class for ColibriFocus and JingleSession.
|
||||||
|
* @param connection Strophe connection object
|
||||||
|
* @constructor
|
||||||
|
*/
|
||||||
|
function SessionBase(connection){
|
||||||
|
|
||||||
|
this.connection = connection;
|
||||||
|
this.peerconnection
|
||||||
|
= new TraceablePeerConnection(
|
||||||
|
connection.jingle.ice_config,
|
||||||
|
connection.jingle.pc_constraints);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
SessionBase.prototype.modifySources = function() {
|
||||||
|
var self = this;
|
||||||
|
this.peerconnection.modifySources(function(){
|
||||||
|
$(document).trigger('setLocalDescription.jingle', [self.sid]);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
SessionBase.prototype.addSource = function (elem) {
|
||||||
|
|
||||||
|
this.peerconnection.addSource(elem);
|
||||||
|
|
||||||
|
this.modifySources();
|
||||||
|
};
|
||||||
|
|
||||||
|
SessionBase.prototype.removeSource = function (elem) {
|
||||||
|
|
||||||
|
this.peerconnection.removeSource(elem);
|
||||||
|
|
||||||
|
this.modifySources();
|
||||||
|
};
|
||||||
|
|
||||||
|
// SDP-based mute by going recvonly/sendrecv
|
||||||
|
// FIXME: should probably black out the screen as well
|
||||||
|
SessionBase.prototype.hardMuteVideo = function (muted) {
|
||||||
|
|
||||||
|
this.peerconnection.hardMuteVideo(muted);
|
||||||
|
|
||||||
|
this.connection.jingle.localVideo.getVideoTracks().forEach(function (track) {
|
||||||
|
track.enabled = !muted;
|
||||||
|
});
|
||||||
|
};
|
Loading…
Reference in New Issue