|
@@ -11,64 +11,87 @@ function TraceablePeerConnection(ice_config, constraints) {
|
11
|
11
|
self.updateLog.push({
|
12
|
12
|
time: new Date(),
|
13
|
13
|
type: what,
|
14
|
|
- value: info
|
|
14
|
+ value: info || ""
|
15
|
15
|
});
|
16
|
16
|
};
|
17
|
17
|
this.onicecandidate = null;
|
18
|
18
|
this.peerconnection.onicecandidate = function (event) {
|
19
|
|
- self.trace('onicecandidate', event.candidate);
|
|
19
|
+ self.trace('onicecandidate', JSON.stringify(event.candidate));
|
20
|
20
|
if (self.onicecandidate !== null) {
|
21
|
21
|
self.onicecandidate(event);
|
22
|
22
|
}
|
23
|
23
|
};
|
24
|
24
|
this.onaddstream = null;
|
25
|
25
|
this.peerconnection.onaddstream = function (event) {
|
26
|
|
- self.trace('onaddstream', event.stream);
|
|
26
|
+ self.trace('onaddstream', event.stream.id);
|
27
|
27
|
if (self.onaddstream !== null) {
|
28
|
28
|
self.onaddstream(event);
|
29
|
29
|
}
|
30
|
30
|
};
|
31
|
31
|
this.onremovestream = null;
|
32
|
32
|
this.peerconnection.onremovestream = function (event) {
|
33
|
|
- self.trace('onremovestream', event.stream);
|
|
33
|
+ self.trace('onremovestream', event.stream.id);
|
34
|
34
|
if (self.onremovestream !== null) {
|
35
|
35
|
self.onremovestream(event);
|
36
|
36
|
}
|
37
|
37
|
};
|
38
|
38
|
this.onsignalingstatechange = null;
|
39
|
39
|
this.peerconnection.onsignalingstatechange = function (event) {
|
40
|
|
- self.trace('onsignalingstatechange', event);
|
|
40
|
+ self.trace('onsignalingstatechange', event.srcElement.signalingState);
|
41
|
41
|
if (self.onsignalingstatechange !== null) {
|
42
|
42
|
self.onsignalingstatechange(event);
|
43
|
43
|
}
|
44
|
44
|
};
|
45
|
45
|
this.oniceconnectionstatechange = null;
|
46
|
46
|
this.peerconnection.oniceconnectionstatechange = function (event) {
|
47
|
|
- self.trace('oniceconnectionstatechange', event);
|
|
47
|
+ self.trace('oniceconnectionstatechange', event.srcElement.iceConnectionState);
|
48
|
48
|
if (self.oniceconnectionstatechange !== null) {
|
49
|
49
|
self.oniceconnectionstatechange(event);
|
50
|
50
|
}
|
|
51
|
+ };
|
|
52
|
+ this.onnegotiationneeded = null;
|
|
53
|
+ this.peerconnection.onnegotiationneeded = function (event) {
|
|
54
|
+ self.trace('onnegotiationneeded');
|
|
55
|
+ if (self.onnegotiationneeded !== null) {
|
|
56
|
+ self.onnegotiationneeded(event);
|
|
57
|
+ }
|
|
58
|
+ };
|
|
59
|
+ self.ondatachannel = null;
|
|
60
|
+ this.peerconnection.ondatachannel = function (event) {
|
|
61
|
+ self.trace('ondatachannel', event);
|
|
62
|
+ if (self.ondatachannel !== null) {
|
|
63
|
+ self.ondatachannel(event);
|
|
64
|
+ }
|
51
|
65
|
}
|
52
|
66
|
};
|
53
|
67
|
|
|
68
|
+dumpSDP = function(description) {
|
|
69
|
+ return 'type: ' + description.type + '\r\n' + description.sdp;
|
|
70
|
+}
|
|
71
|
+
|
54
|
72
|
TraceablePeerConnection.prototype.__defineGetter__('signalingState', function() { return this.peerconnection.signalingState; });
|
55
|
73
|
TraceablePeerConnection.prototype.__defineGetter__('iceConnectionState', function() { return this.peerconnection.iceConnectionState; });
|
56
|
74
|
TraceablePeerConnection.prototype.__defineGetter__('localDescription', function() { return this.peerconnection.localDescription; });
|
57
|
75
|
TraceablePeerConnection.prototype.__defineGetter__('remoteDescription', function() { return this.peerconnection.remoteDescription; });
|
58
|
76
|
|
59
|
77
|
TraceablePeerConnection.prototype.addStream = function (stream) {
|
60
|
|
- this.trace('addStream', stream);
|
|
78
|
+ this.trace('addStream', stream.id);
|
61
|
79
|
this.peerconnection.addStream(stream);
|
62
|
80
|
};
|
63
|
81
|
|
64
|
82
|
TraceablePeerConnection.prototype.removeStream = function (stream) {
|
65
|
|
- this.trace('removeStream', stream);
|
|
83
|
+ this.trace('removeStream', stream.id);
|
66
|
84
|
this.peerconnection.removeStream(stream);
|
67
|
85
|
};
|
68
|
86
|
|
|
87
|
+TraceablePeerConnection.prototype.createDataChannel = function (label, opts) {
|
|
88
|
+ this.trace('createDataChannel', label, opts);
|
|
89
|
+ this.peerconnection.createDataChannel(label, opts);
|
|
90
|
+}
|
|
91
|
+
|
69
|
92
|
TraceablePeerConnection.prototype.setLocalDescription = function (description, successCallback, failureCallback) {
|
70
|
93
|
var self = this;
|
71
|
|
- this.trace('setLocalDescription', description);
|
|
94
|
+ this.trace('setLocalDescription', dumpSDP(description));
|
72
|
95
|
this.peerconnection.setLocalDescription(description,
|
73
|
96
|
function () {
|
74
|
97
|
self.trace('setLocalDescriptionOnSuccess');
|
|
@@ -83,7 +106,7 @@ TraceablePeerConnection.prototype.setLocalDescription = function (description, s
|
83
|
106
|
|
84
|
107
|
TraceablePeerConnection.prototype.setRemoteDescription = function (description, successCallback, failureCallback) {
|
85
|
108
|
var self = this;
|
86
|
|
- this.trace('setRemoteDescription', description);
|
|
109
|
+ this.trace('setRemoteDescription', dumpSDP(description));
|
87
|
110
|
this.peerconnection.setRemoteDescription(description,
|
88
|
111
|
function () {
|
89
|
112
|
self.trace('setRemoteDescriptionOnSuccess');
|
|
@@ -103,11 +126,11 @@ TraceablePeerConnection.prototype.close = function () {
|
103
|
126
|
|
104
|
127
|
TraceablePeerConnection.prototype.createOffer = function (successCallback, failureCallback, constraints) {
|
105
|
128
|
var self = this;
|
106
|
|
- this.trace('createOffer', constraints);
|
|
129
|
+ this.trace('createOffer', JSON.stringify(constraints, null, " "));
|
107
|
130
|
this.peerconnection.createOffer(
|
108
|
|
- function (sdp) {
|
109
|
|
- self.trace('createOfferOnSuccess', sdp);
|
110
|
|
- successCallback(sdp);
|
|
131
|
+ function (offer) {
|
|
132
|
+ self.trace('createOfferOnSuccess', dumpSDP(offer));
|
|
133
|
+ successCallback(offer);
|
111
|
134
|
},
|
112
|
135
|
function(err) {
|
113
|
136
|
self.trace('createOfferOnFailure', err);
|
|
@@ -119,11 +142,11 @@ TraceablePeerConnection.prototype.createOffer = function (successCallback, failu
|
119
|
142
|
|
120
|
143
|
TraceablePeerConnection.prototype.createAnswer = function (successCallback, failureCallback, constraints) {
|
121
|
144
|
var self = this;
|
122
|
|
- this.trace('createAnswer', constraints);
|
|
145
|
+ this.trace('createAnswer', JSON.stringify(constraints, null, " "));
|
123
|
146
|
this.peerconnection.createAnswer(
|
124
|
|
- function (sdp) {
|
125
|
|
- self.trace('createAnswerOnSuccess', sdp);
|
126
|
|
- successCallback(sdp);
|
|
147
|
+ function (answer) {
|
|
148
|
+ self.trace('createAnswerOnSuccess', dumpSDP(answer));
|
|
149
|
+ successCallback(answer);
|
127
|
150
|
},
|
128
|
151
|
function(err) {
|
129
|
152
|
self.trace('createAnswerOnFailure', err);
|
|
@@ -135,7 +158,7 @@ TraceablePeerConnection.prototype.createAnswer = function (successCallback, fail
|
135
|
158
|
|
136
|
159
|
TraceablePeerConnection.prototype.addIceCandidate = function (candidate, successCallback, failureCallback) {
|
137
|
160
|
var self = this;
|
138
|
|
- this.trace('addIceCandidate', candidate);
|
|
161
|
+ this.trace('addIceCandidate', JSON.stringify(candidate));
|
139
|
162
|
this.peerconnection.addIceCandidate(candidate);
|
140
|
163
|
/* maybe later
|
141
|
164
|
this.peerconnection.addIceCandidate(candidate,
|
|
@@ -411,6 +434,7 @@ Strophe.addConnectionPlugin('jingle', {
|
411
|
434
|
case 'session-accept':
|
412
|
435
|
sess.setRemoteDescription($(iq).find('>jingle'), 'answer');
|
413
|
436
|
sess.accept();
|
|
437
|
+ $(document).trigger('callaccepted.jingle', [sess.sid]);
|
414
|
438
|
break;
|
415
|
439
|
case 'session-terminate':
|
416
|
440
|
console.log('terminating...');
|
|
@@ -1939,7 +1963,6 @@ JingleSession.prototype.sendAnswer = function (provisional) {
|
1939
|
1963
|
|
1940
|
1964
|
JingleSession.prototype.createdAnswer = function (sdp, provisional) {
|
1941
|
1965
|
//console.log('createAnswer callback');
|
1942
|
|
- console.log(sdp);
|
1943
|
1966
|
var self = this;
|
1944
|
1967
|
this.localSDP = new SDP(sdp.sdp);
|
1945
|
1968
|
//this.localSDP.mangle();
|