|
|
|
@ -11,64 +11,87 @@ function TraceablePeerConnection(ice_config, constraints) { |
|
|
|
|
self.updateLog.push({ |
|
|
|
|
time: new Date(), |
|
|
|
|
type: what, |
|
|
|
|
value: info |
|
|
|
|
value: info || "" |
|
|
|
|
}); |
|
|
|
|
}; |
|
|
|
|
this.onicecandidate = null; |
|
|
|
|
this.peerconnection.onicecandidate = function (event) { |
|
|
|
|
self.trace('onicecandidate', event.candidate); |
|
|
|
|
self.trace('onicecandidate', JSON.stringify(event.candidate)); |
|
|
|
|
if (self.onicecandidate !== null) { |
|
|
|
|
self.onicecandidate(event); |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
this.onaddstream = null; |
|
|
|
|
this.peerconnection.onaddstream = function (event) { |
|
|
|
|
self.trace('onaddstream', event.stream); |
|
|
|
|
self.trace('onaddstream', event.stream.id); |
|
|
|
|
if (self.onaddstream !== null) { |
|
|
|
|
self.onaddstream(event); |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
this.onremovestream = null; |
|
|
|
|
this.peerconnection.onremovestream = function (event) { |
|
|
|
|
self.trace('onremovestream', event.stream); |
|
|
|
|
self.trace('onremovestream', event.stream.id); |
|
|
|
|
if (self.onremovestream !== null) { |
|
|
|
|
self.onremovestream(event); |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
this.onsignalingstatechange = null; |
|
|
|
|
this.peerconnection.onsignalingstatechange = function (event) { |
|
|
|
|
self.trace('onsignalingstatechange', event); |
|
|
|
|
self.trace('onsignalingstatechange', event.srcElement.signalingState); |
|
|
|
|
if (self.onsignalingstatechange !== null) { |
|
|
|
|
self.onsignalingstatechange(event); |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
this.oniceconnectionstatechange = null; |
|
|
|
|
this.peerconnection.oniceconnectionstatechange = function (event) { |
|
|
|
|
self.trace('oniceconnectionstatechange', event); |
|
|
|
|
self.trace('oniceconnectionstatechange', event.srcElement.iceConnectionState); |
|
|
|
|
if (self.oniceconnectionstatechange !== null) { |
|
|
|
|
self.oniceconnectionstatechange(event); |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
this.onnegotiationneeded = null; |
|
|
|
|
this.peerconnection.onnegotiationneeded = function (event) { |
|
|
|
|
self.trace('onnegotiationneeded'); |
|
|
|
|
if (self.onnegotiationneeded !== null) { |
|
|
|
|
self.onnegotiationneeded(event); |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
self.ondatachannel = null; |
|
|
|
|
this.peerconnection.ondatachannel = function (event) { |
|
|
|
|
self.trace('ondatachannel', event); |
|
|
|
|
if (self.ondatachannel !== null) { |
|
|
|
|
self.ondatachannel(event); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
dumpSDP = function(description) { |
|
|
|
|
return 'type: ' + description.type + '\r\n' + description.sdp; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
TraceablePeerConnection.prototype.__defineGetter__('signalingState', function() { return this.peerconnection.signalingState; }); |
|
|
|
|
TraceablePeerConnection.prototype.__defineGetter__('iceConnectionState', function() { return this.peerconnection.iceConnectionState; }); |
|
|
|
|
TraceablePeerConnection.prototype.__defineGetter__('localDescription', function() { return this.peerconnection.localDescription; }); |
|
|
|
|
TraceablePeerConnection.prototype.__defineGetter__('remoteDescription', function() { return this.peerconnection.remoteDescription; }); |
|
|
|
|
|
|
|
|
|
TraceablePeerConnection.prototype.addStream = function (stream) { |
|
|
|
|
this.trace('addStream', stream); |
|
|
|
|
this.trace('addStream', stream.id); |
|
|
|
|
this.peerconnection.addStream(stream); |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
TraceablePeerConnection.prototype.removeStream = function (stream) { |
|
|
|
|
this.trace('removeStream', stream); |
|
|
|
|
this.trace('removeStream', stream.id); |
|
|
|
|
this.peerconnection.removeStream(stream); |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
TraceablePeerConnection.prototype.createDataChannel = function (label, opts) { |
|
|
|
|
this.trace('createDataChannel', label, opts); |
|
|
|
|
this.peerconnection.createDataChannel(label, opts); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
TraceablePeerConnection.prototype.setLocalDescription = function (description, successCallback, failureCallback) { |
|
|
|
|
var self = this; |
|
|
|
|
this.trace('setLocalDescription', description); |
|
|
|
|
this.trace('setLocalDescription', dumpSDP(description)); |
|
|
|
|
this.peerconnection.setLocalDescription(description,
|
|
|
|
|
function () { |
|
|
|
|
self.trace('setLocalDescriptionOnSuccess'); |
|
|
|
@ -83,7 +106,7 @@ TraceablePeerConnection.prototype.setLocalDescription = function (description, s |
|
|
|
|
|
|
|
|
|
TraceablePeerConnection.prototype.setRemoteDescription = function (description, successCallback, failureCallback) { |
|
|
|
|
var self = this; |
|
|
|
|
this.trace('setRemoteDescription', description); |
|
|
|
|
this.trace('setRemoteDescription', dumpSDP(description)); |
|
|
|
|
this.peerconnection.setRemoteDescription(description,
|
|
|
|
|
function () { |
|
|
|
|
self.trace('setRemoteDescriptionOnSuccess'); |
|
|
|
@ -103,11 +126,11 @@ TraceablePeerConnection.prototype.close = function () { |
|
|
|
|
|
|
|
|
|
TraceablePeerConnection.prototype.createOffer = function (successCallback, failureCallback, constraints) { |
|
|
|
|
var self = this; |
|
|
|
|
this.trace('createOffer', constraints); |
|
|
|
|
this.trace('createOffer', JSON.stringify(constraints, null, " ")); |
|
|
|
|
this.peerconnection.createOffer( |
|
|
|
|
function (sdp) { |
|
|
|
|
self.trace('createOfferOnSuccess', sdp); |
|
|
|
|
successCallback(sdp); |
|
|
|
|
function (offer) { |
|
|
|
|
self.trace('createOfferOnSuccess', dumpSDP(offer)); |
|
|
|
|
successCallback(offer); |
|
|
|
|
}, |
|
|
|
|
function(err) { |
|
|
|
|
self.trace('createOfferOnFailure', err); |
|
|
|
@ -119,11 +142,11 @@ TraceablePeerConnection.prototype.createOffer = function (successCallback, failu |
|
|
|
|
|
|
|
|
|
TraceablePeerConnection.prototype.createAnswer = function (successCallback, failureCallback, constraints) { |
|
|
|
|
var self = this; |
|
|
|
|
this.trace('createAnswer', constraints); |
|
|
|
|
this.trace('createAnswer', JSON.stringify(constraints, null, " ")); |
|
|
|
|
this.peerconnection.createAnswer( |
|
|
|
|
function (sdp) { |
|
|
|
|
self.trace('createAnswerOnSuccess', sdp); |
|
|
|
|
successCallback(sdp); |
|
|
|
|
function (answer) { |
|
|
|
|
self.trace('createAnswerOnSuccess', dumpSDP(answer)); |
|
|
|
|
successCallback(answer); |
|
|
|
|
}, |
|
|
|
|
function(err) { |
|
|
|
|
self.trace('createAnswerOnFailure', err); |
|
|
|
@ -135,7 +158,7 @@ TraceablePeerConnection.prototype.createAnswer = function (successCallback, fail |
|
|
|
|
|
|
|
|
|
TraceablePeerConnection.prototype.addIceCandidate = function (candidate, successCallback, failureCallback) { |
|
|
|
|
var self = this; |
|
|
|
|
this.trace('addIceCandidate', candidate); |
|
|
|
|
this.trace('addIceCandidate', JSON.stringify(candidate)); |
|
|
|
|
this.peerconnection.addIceCandidate(candidate); |
|
|
|
|
/* maybe later |
|
|
|
|
this.peerconnection.addIceCandidate(candidate,
|
|
|
|
@ -411,6 +434,7 @@ Strophe.addConnectionPlugin('jingle', { |
|
|
|
|
case 'session-accept': |
|
|
|
|
sess.setRemoteDescription($(iq).find('>jingle'), 'answer'); |
|
|
|
|
sess.accept(); |
|
|
|
|
$(document).trigger('callaccepted.jingle', [sess.sid]); |
|
|
|
|
break; |
|
|
|
|
case 'session-terminate': |
|
|
|
|
console.log('terminating...'); |
|
|
|
@ -1939,7 +1963,6 @@ JingleSession.prototype.sendAnswer = function (provisional) { |
|
|
|
|
|
|
|
|
|
JingleSession.prototype.createdAnswer = function (sdp, provisional) { |
|
|
|
|
//console.log('createAnswer callback');
|
|
|
|
|
console.log(sdp); |
|
|
|
|
var self = this; |
|
|
|
|
this.localSDP = new SDP(sdp.sdp); |
|
|
|
|
//this.localSDP.mangle();
|
|
|
|
|