|
|
@@ -109,6 +109,20 @@ ColibriFocus.prototype.makeConference = function (peers) {
|
|
109
|
109
|
});
|
|
110
|
110
|
$(document).trigger('remotestreamadded.jingle', [event, self.sid]);
|
|
111
|
111
|
};
|
|
|
112
|
+ this.peerconnection.onicecandidate = function (event) {
|
|
|
113
|
+ //console.log('focus onicecandidate', self.confid, new Date().getTime(), event.candidate);
|
|
|
114
|
+ if (!event.candidate) {
|
|
|
115
|
+ console.log('end of candidates');
|
|
|
116
|
+ return;
|
|
|
117
|
+ }
|
|
|
118
|
+ if (self.confid === 0) {
|
|
|
119
|
+ self.drip_container.push(event.candidate);
|
|
|
120
|
+ } else {
|
|
|
121
|
+ self.sendIceCandidate(event.candidate);
|
|
|
122
|
+ }
|
|
|
123
|
+ };
|
|
|
124
|
+ this._makeConference();
|
|
|
125
|
+ /*
|
|
112
|
126
|
this.peerconnection.createOffer(
|
|
113
|
127
|
function (offer) {
|
|
114
|
128
|
self.peerconnection.setLocalDescription(
|
|
|
@@ -128,18 +142,7 @@ ColibriFocus.prototype.makeConference = function (peers) {
|
|
128
|
142
|
console.warn(error);
|
|
129
|
143
|
}
|
|
130
|
144
|
);
|
|
131
|
|
- this.peerconnection.onicecandidate = function (event) {
|
|
132
|
|
- //console.log('focus onicecandidate', self.confid, new Date().getTime(), event.candidate);
|
|
133
|
|
- if (!event.candidate) {
|
|
134
|
|
- console.log('end of candidates');
|
|
135
|
|
- return;
|
|
136
|
|
- }
|
|
137
|
|
- if (self.confid === 0) {
|
|
138
|
|
- self.drip_container.push(event.candidate);
|
|
139
|
|
- } else {
|
|
140
|
|
- self.sendIceCandidate(candidate);
|
|
141
|
|
- }
|
|
142
|
|
- };
|
|
|
145
|
+ */
|
|
143
|
146
|
};
|
|
144
|
147
|
|
|
145
|
148
|
ColibriFocus.prototype._makeConference = function () {
|
|
|
@@ -147,6 +150,23 @@ ColibriFocus.prototype._makeConference = function () {
|
|
147
|
150
|
var elem = $iq({to: this.bridgejid, type: 'get'});
|
|
148
|
151
|
elem.c('conference', {xmlns: 'http://jitsi.org/protocol/colibri'});
|
|
149
|
152
|
|
|
|
153
|
+ var stream = this.connection.jingle.localStream;
|
|
|
154
|
+ var types = [];
|
|
|
155
|
+ if (connection.jingle.localStream.getAudioTracks().length > 0) {
|
|
|
156
|
+ types.push('audio');
|
|
|
157
|
+ }
|
|
|
158
|
+ if (connection.jingle.localStream.getVideoTracks().length > 0) {
|
|
|
159
|
+ types.push('video');
|
|
|
160
|
+ }
|
|
|
161
|
+ types.forEach(function (name) {
|
|
|
162
|
+ elem.c('content', {name: name});
|
|
|
163
|
+ elem.c('channel', {initiator: 'true', expire: '15'}).up();
|
|
|
164
|
+ for (var j = 0; j < self.peers.length; j++) {
|
|
|
165
|
+ elem.c('channel', {initiator: 'true', expire:'15' }).up();
|
|
|
166
|
+ }
|
|
|
167
|
+ elem.up(); // end of content
|
|
|
168
|
+ });
|
|
|
169
|
+ /*
|
|
150
|
170
|
var localSDP = new SDP(this.peerconnection.localDescription.sdp);
|
|
151
|
171
|
localSDP.media.forEach(function (media, channel) {
|
|
152
|
172
|
var name = SDPUtil.parse_mline(media.split('\r\n')[0]).media;
|
|
|
@@ -169,6 +189,7 @@ ColibriFocus.prototype._makeConference = function () {
|
|
169
|
189
|
}
|
|
170
|
190
|
elem.up(); // end of content
|
|
171
|
191
|
});
|
|
|
192
|
+ */
|
|
172
|
193
|
|
|
173
|
194
|
this.connection.sendIQ(elem,
|
|
174
|
195
|
function (result) {
|
|
|
@@ -200,25 +221,13 @@ ColibriFocus.prototype.createdConference = function (result) {
|
|
200
|
221
|
this.channels[j].push(tmp[j]);
|
|
201
|
222
|
}
|
|
202
|
223
|
}
|
|
203
|
|
- console.log('remote channels', this.channels);
|
|
204
|
|
- var localSDP = new SDP(this.peerconnection.localDescription.sdp);
|
|
205
|
|
- localSDP.removeSessionLines('a=group:');
|
|
206
|
|
- localSDP.removeSessionLines('a=msid-semantic:');
|
|
207
|
224
|
|
|
208
|
|
- if (this.drip_container.length) {
|
|
209
|
|
- this.sendIceCandidates(this.drip_container);
|
|
210
|
|
- this.drip_container = [];
|
|
211
|
|
- }
|
|
|
225
|
+ console.log('remote channels', this.channels);
|
|
212
|
226
|
|
|
213
|
|
- // establish our channel with the bridge
|
|
214
|
|
- // static answer taken from chrome M31, should be replaced by a
|
|
215
|
|
- // dynamic one that is based on our offer FIXME
|
|
216
|
|
- var bridgeSDP = new SDP("");
|
|
217
|
|
- // var bridgeSDP = new SDP('v=0\r\no=- 5151055458874951233 2 IN IP4 127.0.0.1\r\ns=-\r\nt=0 0\r\nm=audio 1 RTP/SAVPF 111 103 104 0 8 106 105 13 126\r\nc=IN IP4 0.0.0.0\r\na=rtcp:1 IN IP4 0.0.0.0\r\na=mid:audio\r\na=extmap:1 urn:ietf:params:rtp-hdrext:ssrc-audio-level\r\na=sendrecv\r\na=rtpmap:111 opus/48000/2\r\na=fmtp:111 minptime=10\r\na=rtpmap:103 ISAC/16000\r\na=rtpmap:104 ISAC/32000\r\na=rtpmap:0 PCMU/8000\r\na=rtpmap:8 PCMA/8000\r\na=rtpmap:106 CN/32000\r\na=rtpmap:105 CN/16000\r\na=rtpmap:13 CN/8000\r\na=rtpmap:126 telephone-event/8000\r\na=maxptime:60\r\nm=video 1 RTP/SAVPF 100 116 117\r\nc=IN IP4 0.0.0.0\r\na=rtcp:1 IN IP4 0.0.0.0\r\na=mid:video\r\na=extmap:2 urn:ietf:params:rtp-hdrext:toffset\r\na=extmap:3 http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time\r\na=sendrecv\r\na=rtpmap:100 VP8/90000\r\na=rtcp-fb:100 ccm fir\r\na=rtcp-fb:100 nack\r\na=rtcp-fb:100 goog-remb\r\na=rtpmap:116 red/90000\r\na=rtpmap:117 ulpfec/90000\r\n');
|
|
218
|
|
- // only do what's in the offer
|
|
219
|
|
- bridgeSDP.session = localSDP.session;
|
|
220
|
|
- bridgeSDP.media.length = localSDP.media.length;
|
|
|
227
|
+ var bridgeSDP = new SDP('v=0\r\no=- 5151055458874951233 2 IN IP4 127.0.0.1\r\ns=-\r\nt=0 0\r\nm=audio 1 RTP/SAVPF 111 103 104 0 8 106 105 13 126\r\nc=IN IP4 0.0.0.0\r\na=rtcp:1 IN IP4 0.0.0.0\r\na=mid:audio\r\na=extmap:1 urn:ietf:params:rtp-hdrext:ssrc-audio-level\r\na=sendrecv\r\na=rtpmap:111 opus/48000/2\r\na=fmtp:111 minptime=10\r\na=rtpmap:103 ISAC/16000\r\na=rtpmap:104 ISAC/32000\r\na=rtpmap:0 PCMU/8000\r\na=rtpmap:8 PCMA/8000\r\na=rtpmap:106 CN/32000\r\na=rtpmap:105 CN/16000\r\na=rtpmap:13 CN/8000\r\na=rtpmap:126 telephone-event/8000\r\na=maxptime:60\r\nm=video 1 RTP/SAVPF 100 116 117\r\nc=IN IP4 0.0.0.0\r\na=rtcp:1 IN IP4 0.0.0.0\r\na=mid:video\r\na=extmap:2 urn:ietf:params:rtp-hdrext:toffset\r\na=extmap:3 http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time\r\na=sendrecv\r\na=rtpmap:100 VP8/90000\r\na=rtcp-fb:100 ccm fir\r\na=rtcp-fb:100 nack\r\na=rtcp-fb:100 goog-remb\r\na=rtpmap:116 red/90000\r\na=rtpmap:117 ulpfec/90000\r\n');
|
|
|
228
|
+ bridgeSDP.media.length = this.mychannel.length;
|
|
221
|
229
|
var channel;
|
|
|
230
|
+ /*
|
|
222
|
231
|
for (channel = 0; channel < bridgeSDP.media.length; channel++) {
|
|
223
|
232
|
bridgeSDP.media[channel] = '';
|
|
224
|
233
|
// unchanged lines
|
|
|
@@ -249,8 +258,9 @@ ColibriFocus.prototype.createdConference = function (result) {
|
|
249
|
258
|
}
|
|
250
|
259
|
// FIXME: changed lines -- a=sendrecv direction, a=setup direction
|
|
251
|
260
|
}
|
|
252
|
|
- // get the mixed ssrc
|
|
|
261
|
+ */
|
|
253
|
262
|
for (channel = 0; channel < bridgeSDP.media.length; channel++) {
|
|
|
263
|
+ // get the mixed ssrc
|
|
254
|
264
|
tmp = $(this.mychannel[channel]).find('>source[xmlns="urn:xmpp:jingle:apps:rtp:ssma:0"]');
|
|
255
|
265
|
// FIXME: check rtp-level-relay-type
|
|
256
|
266
|
if (tmp.length) {
|
|
|
@@ -278,26 +288,83 @@ ColibriFocus.prototype.createdConference = function (result) {
|
|
278
|
288
|
tmp = tmp.find('>fingerprint');
|
|
279
|
289
|
if (tmp.length) {
|
|
280
|
290
|
bridgeSDP.media[channel] += 'a=fingerprint:' + tmp.attr('hash') + ' ' + tmp.text() + '\r\n';
|
|
281
|
|
- if (tmp.attr('setup')) {
|
|
282
|
|
- bridgeSDP.media[channel] += 'a=setup:' + tmp.attr('setup') + '\r\n';
|
|
283
|
|
- } else {
|
|
284
|
|
- bridgeSDP.media[channel] += 'a=setup:active\r\n';
|
|
285
|
|
- }
|
|
|
291
|
+ bridgeSDP.media[channel] += 'a=setup:actpass\r\n'; // offer so always actpass
|
|
286
|
292
|
}
|
|
287
|
293
|
}
|
|
288
|
294
|
}
|
|
289
|
295
|
bridgeSDP.raw = bridgeSDP.session + bridgeSDP.media.join('');
|
|
290
|
296
|
|
|
291
|
297
|
this.peerconnection.setRemoteDescription(
|
|
292
|
|
- new RTCSessionDescription({type: 'answer', sdp: bridgeSDP.raw}),
|
|
|
298
|
+ new RTCSessionDescription({type: 'offer', sdp: bridgeSDP.raw}),
|
|
293
|
299
|
function () {
|
|
294
|
300
|
console.log('setRemoteDescription success');
|
|
|
301
|
+ self.peerconnection.createAnswer(
|
|
|
302
|
+ function (answer) {
|
|
|
303
|
+ self.peerconnection.setLocalDescription(answer,
|
|
|
304
|
+ function () {
|
|
|
305
|
+ console.log('setLocalDescription succeded.');
|
|
|
306
|
+ // make sure our presence is updated
|
|
|
307
|
+ $(document).trigger('setLocalDescription.jingle', [self.sid]);
|
|
|
308
|
+ var elem = $iq({to: self.bridgejid, type: 'get'});
|
|
|
309
|
+ elem.c('conference', {xmlns: 'http://jitsi.org/protocol/colibri', id: self.confid});
|
|
|
310
|
+ var localSDP = new SDP(self.peerconnection.localDescription.sdp);
|
|
|
311
|
+ localSDP.media.forEach(function (media, channel) {
|
|
|
312
|
+ var name = SDPUtil.parse_mline(media.split('\r\n')[0]).media;
|
|
|
313
|
+ elem.c('content', {name: name});
|
|
|
314
|
+ elem.c('channel', {
|
|
|
315
|
+ initiator: 'true',
|
|
|
316
|
+ expire: '15',
|
|
|
317
|
+ id: self.mychannel[channel].attr('id')
|
|
|
318
|
+ });
|
|
|
319
|
+
|
|
|
320
|
+ // FIXME: should reuse code from .toJingle
|
|
|
321
|
+ var mline = SDPUtil.parse_mline(media.split('\r\n')[0]);
|
|
|
322
|
+ for (var j = 0; j < mline.fmt.length; j++) {
|
|
|
323
|
+ var rtpmap = SDPUtil.find_line(media, 'a=rtpmap:' + mline.fmt[j]);
|
|
|
324
|
+ elem.c('payload-type', SDPUtil.parse_rtpmap(rtpmap));
|
|
|
325
|
+ elem.up();
|
|
|
326
|
+ }
|
|
|
327
|
+
|
|
|
328
|
+ localSDP.TransportToJingle(channel, elem);
|
|
|
329
|
+
|
|
|
330
|
+ elem.up(); // end of channel
|
|
|
331
|
+ for (j = 0; j < self.peers.length; j++) {
|
|
|
332
|
+ elem.c('channel', {initiator: 'true', expire:'15' }).up();
|
|
|
333
|
+ }
|
|
|
334
|
+ elem.up(); // end of content
|
|
|
335
|
+ });
|
|
|
336
|
+
|
|
|
337
|
+ self.connection.sendIQ(elem,
|
|
|
338
|
+ function (result) {
|
|
|
339
|
+ // ...
|
|
|
340
|
+ },
|
|
|
341
|
+ function (error) {
|
|
|
342
|
+ console.warn(error);
|
|
|
343
|
+ }
|
|
|
344
|
+ );
|
|
|
345
|
+
|
|
|
346
|
+ // now initiate sessions
|
|
|
347
|
+ for (var i = 0; i < numparticipants; i++) {
|
|
|
348
|
+ self.initiate(self.peers[i], true);
|
|
|
349
|
+ }
|
|
|
350
|
+ },
|
|
|
351
|
+ function (error) {
|
|
|
352
|
+ console.warn('setLocalDescription failed.', error);
|
|
|
353
|
+ }
|
|
|
354
|
+ );
|
|
|
355
|
+ },
|
|
|
356
|
+ function (error) {
|
|
|
357
|
+ console.warn('createAnswer failed.', error);
|
|
|
358
|
+ }
|
|
|
359
|
+ );
|
|
|
360
|
+ /*
|
|
295
|
361
|
for (var i = 0; i < numparticipants; i++) {
|
|
296
|
362
|
self.initiate(self.peers[i], true);
|
|
297
|
363
|
}
|
|
|
364
|
+ */
|
|
298
|
365
|
},
|
|
299
|
366
|
function (error) {
|
|
300
|
|
- console.log('setRemoteDescription failed');
|
|
|
367
|
+ console.log('setRemoteDescription failed.', error);
|
|
301
|
368
|
}
|
|
302
|
369
|
);
|
|
303
|
370
|
|
|
|
@@ -674,6 +741,7 @@ ColibriFocus.prototype.sendIceCandidates = function (candidates) {
|
|
674
|
741
|
mycands.up(); // content
|
|
675
|
742
|
}
|
|
676
|
743
|
}
|
|
|
744
|
+ console.log('send cands', candidates);
|
|
677
|
745
|
this.connection.sendIQ(mycands,
|
|
678
|
746
|
function (res) {
|
|
679
|
747
|
console.log('got result');
|
|
|
@@ -769,8 +837,6 @@ ColibriFocus.prototype.modifySources = function () {
|
|
769
|
837
|
this.removessrc = [];
|
|
770
|
838
|
|
|
771
|
839
|
sdp.raw = sdp.session + sdp.media.join('');
|
|
772
|
|
- /*
|
|
773
|
|
- * this seems to create a number of problems...
|
|
774
|
840
|
this.peerconnection.setRemoteDescription(
|
|
775
|
841
|
new RTCSessionDescription({type: 'offer', sdp: sdp.raw }),
|
|
776
|
842
|
function () {
|
|
|
@@ -803,7 +869,8 @@ ColibriFocus.prototype.modifySources = function () {
|
|
803
|
869
|
console.log('setModifiedRemoteDescription failed');
|
|
804
|
870
|
}
|
|
805
|
871
|
);
|
|
806
|
|
- */
|
|
|
872
|
+ /*
|
|
|
873
|
+ * now that we have a passive focus, this way is bad again! :-)
|
|
807
|
874
|
this.peerconnection.createOffer(
|
|
808
|
875
|
function (modifiedOffer) {
|
|
809
|
876
|
console.log('created (un)modified offer');
|
|
|
@@ -830,6 +897,7 @@ ColibriFocus.prototype.modifySources = function () {
|
|
830
|
897
|
console.log('creating (un)modified offerfailed');
|
|
831
|
898
|
}
|
|
832
|
899
|
);
|
|
|
900
|
+ */
|
|
833
|
901
|
};
|
|
834
|
902
|
|
|
835
|
903
|
|