ソースを参照

Moves duplicated methods to peer connection adapter.

master
paweldomas 11年前
コミット
8b96d134e3
4個のファイルの変更219行の追加275行の削除
  1. 2
    2
      app.js
  2. 14
    130
      libs/colibri/colibri.focus.js
  3. 185
    0
      libs/strophe/strophe.jingle.adapter.js
  4. 18
    143
      libs/strophe/strophe.jingle.session.js

+ 2
- 2
app.js ファイルの表示

@@ -725,8 +725,8 @@ function toggleVideo() {
725 725
     if (!sess) {
726 726
         return;
727 727
     }
728
-    sess.pendingop = ismuted ? 'unmute' : 'mute';
729
-    sess.modifySources();
728
+    sess.peerconnection.pendingop = ismuted ? 'unmute' : 'mute';
729
+    sess.peerconnection.modifySources();
730 730
 }
731 731
 
732 732
 function toggleAudio() {

+ 14
- 130
libs/colibri/colibri.focus.js ファイルの表示

@@ -40,7 +40,10 @@ function ColibriFocus(connection, bridgejid) {
40 40
     this.peers = [];
41 41
     this.confid = null;
42 42
 
43
-    this.peerconnection = null;
43
+    this.peerconnection
44
+        = new TraceablePeerConnection(
45
+            this.connection.jingle.ice_config,
46
+            this.connection.jingle.pc_constraints);
44 47
 
45 48
     // media types of the conference
46 49
     this.media = ['audio', 'video'];
@@ -51,13 +54,6 @@ function ColibriFocus(connection, bridgejid) {
51 54
     this.channels = [];
52 55
     this.remotessrc = {};
53 56
 
54
-    // ssrc lines to be added on next update
55
-    this.addssrc = [];
56
-    // ssrc lines to be removed on next update
57
-    this.removessrc = [];
58
-    // pending mute/unmute video op that modify local description
59
-    this.pendingop = null;
60
-
61 57
     // container for candidates from the focus
62 58
     // gathered before confid is known
63 59
     this.drip_container = [];
@@ -81,7 +77,6 @@ ColibriFocus.prototype.makeConference = function (peers) {
81 77
         self.channels.push([]);
82 78
     });
83 79
 
84
-    this.peerconnection = new TraceablePeerConnection(this.connection.jingle.ice_config, this.connection.jingle.pc_constraints);
85 80
     this.peerconnection.addStream(this.connection.jingle.localStream);
86 81
     this.peerconnection.oniceconnectionstatechange = function (event) {
87 82
         console.warn('ice connection state changed to', self.peerconnection.iceConnectionState);
@@ -651,9 +646,11 @@ ColibriFocus.prototype.setRemoteDescription = function (session, elem, desctype)
651 646
     // ACT 4: add new a=ssrc lines to local remotedescription
652 647
     for (channel = 0; channel < this.channels[participant].length; channel++) {
653 648
         //if (channel == 0) continue; FIXME: does not work as intended
654
-        if (!this.addssrc[channel]) this.addssrc[channel] = '';
655 649
         if (SDPUtil.find_lines(remoteSDP.media[channel], 'a=ssrc:').length) {
656
-            this.addssrc[channel] += SDPUtil.find_lines(remoteSDP.media[channel], 'a=ssrc:').join('\r\n') + '\r\n';
650
+            this.peerconnection.enqueueAddSsrc(
651
+                channel,
652
+                SDPUtil.find_lines(remoteSDP.media[channel], 'a=ssrc:').join('\r\n') + '\r\n'
653
+            );
657 654
         }
658 655
     }
659 656
     this.modifySources();
@@ -764,8 +761,7 @@ ColibriFocus.prototype.terminate = function (session, reason) {
764 761
     }
765 762
     var ssrcs = this.remotessrc[session.peerjid];
766 763
     for (var i = 0; i < ssrcs.length; i++) {
767
-        if (!this.removessrc[i]) this.removessrc[i] = '';
768
-        this.removessrc[i] += ssrcs[i];
764
+        this.peerconnection.enqueueRemoveSsrc(i, ssrcs[i]);
769 765
     }
770 766
     // remove from this.peers
771 767
     this.peers.splice(participant, 1);
@@ -796,7 +792,7 @@ ColibriFocus.prototype.terminate = function (session, reason) {
796 792
     for (var j = 0; j < ssrcs.length; j++) {
797 793
         sdp.media[j] = 'a=mid:' + contents[j] + '\r\n';
798 794
         sdp.media[j] += ssrcs[j];
799
-        this.removessrc[j] += ssrcs[j];
795
+        this.peerconnection.enqueueRemoveSsrc(j, ssrcs[j]);
800 796
     }
801 797
     this.sendSSRCUpdate(sdp, session.peerjid, false);
802 798
 
@@ -806,126 +802,14 @@ ColibriFocus.prototype.terminate = function (session, reason) {
806 802
 
807 803
 ColibriFocus.prototype.modifySources = function () {
808 804
     var self = this;
809
-    if (this.peerconnection.signalingState == 'closed') return;
810
-    if (!(this.addssrc.length || this.removessrc.length || this.pendingop !== null)) return;
811
-
812
-    // FIXME: this is a big hack
813
-    // https://code.google.com/p/webrtc/issues/detail?id=2688
814
-    if (!(this.peerconnection.signalingState == 'stable' && this.peerconnection.iceConnectionState == 'connected')) {
815
-        console.warn('modifySources not yet', this.peerconnection.signalingState, this.peerconnection.iceConnectionState);
816
-        window.setTimeout(function () { self.modifySources(); }, 250);
817
-        this.wait = true;
818
-        return;
819
-    }
820
-    if (this.wait) {
821
-        window.setTimeout(function () { self.modifySources(); }, 2500);
822
-        this.wait = false;
823
-        return;
824
-    }
825
-    var sdp = new SDP(this.peerconnection.remoteDescription.sdp);
826
-
827
-    // add sources
828
-    this.addssrc.forEach(function (lines, idx) {
829
-        sdp.media[idx] += lines;
805
+    this.peerconnection.modifySources(function(){
806
+        $(document).trigger('setLocalDescription.jingle', [self.sid]);
830 807
     });
831
-    this.addssrc = [];
832
-
833
-    // remove sources
834
-    this.removessrc.forEach(function (lines, idx) {
835
-        lines = lines.split('\r\n');
836
-        lines.pop(); // remove empty last element;
837
-        lines.forEach(function (line) {
838
-            sdp.media[idx] = sdp.media[idx].replace(line + '\r\n', '');
839
-        });
840
-    });
841
-    this.removessrc = [];
842
-
843
-    sdp.raw = sdp.session + sdp.media.join('');
844
-    this.peerconnection.setRemoteDescription(
845
-        new RTCSessionDescription({type: 'offer', sdp: sdp.raw }),
846
-        function () {
847
-            console.log('setModifiedRemoteDescription ok');
848
-            self.peerconnection.createAnswer(
849
-                function (modifiedAnswer) {
850
-                    console.log('modifiedAnswer created');
851
-
852
-                    // change video direction, see https://github.com/jitsi/jitmeet/issues/41
853
-                    if (self.pendingop !== null) {
854
-                        var sdp = new SDP(modifiedAnswer.sdp);
855
-                        if (sdp.media.length > 1) {
856
-                            switch(self.pendingop) {
857
-                            case 'mute':
858
-                                sdp.media[1] = sdp.media[1].replace('a=sendrecv', 'a=recvonly');
859
-                                break;
860
-                            case 'unmute':
861
-                                sdp.media[1] = sdp.media[1].replace('a=recvonly', 'a=sendrecv');
862
-                                break;
863
-                            }
864
-                            sdp.raw = sdp.session + sdp.media.join('');
865
-                            modifiedAnswer.sdp = sdp.raw;
866
-                        }
867
-                        self.pendingop = null;
868
-                    }
869
-
870
-                    // FIXME: pushing down an answer while ice connection state
871
-                    // is still checking is bad...
872
-                    //console.log(self.peerconnection.iceConnectionState);
873
-
874
-                    // trying to work around another chrome bug
875
-                    //modifiedAnswer.sdp = modifiedAnswer.sdp.replace(/a=setup:active/g, 'a=setup:actpass');
876
-                    self.peerconnection.setLocalDescription(modifiedAnswer,
877
-                        function () {
878
-                            console.log('setModifiedLocalDescription ok');
879
-                            $(document).trigger('setLocalDescription.jingle', [self.sid]);
880
-                        },
881
-                        function (error) {
882
-                            console.log('setModifiedLocalDescription failed', error);
883
-                        }
884
-                    );
885
-                },
886
-                function (error) {
887
-                    console.log('createModifiedAnswer failed', error);
888
-                }
889
-            );
890
-        },
891
-        function (error) {
892
-            console.log('setModifiedRemoteDescription failed', error);
893
-        }
894
-    );
895
-    /*
896
-     * now that we have a passive focus, this way is bad again! :-)
897
-    this.peerconnection.createOffer(
898
-        function (modifiedOffer) {
899
-            console.log('created (un)modified offer');
900
-            self.peerconnection.setLocalDescription(modifiedOffer,
901
-                function () {
902
-                    console.log('setModifiedLocalDescription ok');
903
-                    self.peerconnection.setRemoteDescription(
904
-                        new RTCSessionDescription({type: 'answer', sdp: sdp.raw }),
905
-                        function () {
906
-                            console.log('setModifiedRemoteDescription ok');
907
-                        },
908
-                        function (error) {
909
-                            console.log('setModifiedRemoteDescription failed');
910
-                        }
911
-                    );
912
-                    $(document).trigger('setLocalDescription.jingle', [self.sid]);
913
-                },
914
-                function (error) {
915
-                    console.log('setModifiedLocalDescription failed');
916
-                }
917
-            );
918
-        },
919
-        function (error) {
920
-            console.log('creating (un)modified offerfailed');
921
-        }
922
-    );
923
-    */
924 808
 };
925 809
 
926 810
 ColibriFocus.prototype.hardMuteVideo = function (muted) {
927
-    this.pendingop = muted ? 'mute' : 'unmute';
928
-    this.modifySources();
811
+
812
+    this.peerconnection.hardMuteVideo(muted);
929 813
 
930 814
     this.connection.jingle.localStream.getVideoTracks().forEach(function (track) {
931 815
         track.enabled = !muted;

+ 185
- 0
libs/strophe/strophe.jingle.adapter.js ファイルの表示

@@ -7,6 +7,24 @@ function TraceablePeerConnection(ice_config, constraints) {
7 7
     this.statsinterval = null;
8 8
     this.maxstats = 300; // limit to 300 values, i.e. 5 minutes; set to 0 to disable
9 9
 
10
+    /**
11
+     * Array of ssrcs that will be added on next modifySources call.
12
+     * @type {Array}
13
+     */
14
+    this.addssrc = [];
15
+    /**
16
+     * Array of ssrcs that will be added on next modifySources call.
17
+     * @type {Array}
18
+     */
19
+    this.removessrc = [];
20
+    /**
21
+     * Pending operation that will be done during modifySources call.
22
+     * Currently 'mute'/'unmute' operations are supported.
23
+     *
24
+     * @type {String}
25
+     */
26
+    this.pendingop = null;
27
+
10 28
     // override as desired
11 29
     this.trace = function(what, info) {
12 30
         //console.warn('WTRACE', what, info);
@@ -163,6 +181,173 @@ TraceablePeerConnection.prototype.setRemoteDescription = function (description,
163 181
      */
164 182
 };
165 183
 
184
+TraceablePeerConnection.prototype.hardMuteVideo = function (muted) {
185
+    this.pendingop = muted ? 'mute' : 'unmute';
186
+    this.modifySources();
187
+};
188
+
189
+TraceablePeerConnection.prototype.enqueueAddSsrc = function(channel, ssrcLines) {
190
+    if (!this.addssrc[channel]) {
191
+        this.addssrc[channel] = '';
192
+    }
193
+    this.addssrc[channel] += ssrcLines;
194
+}
195
+
196
+TraceablePeerConnection.prototype.addSource = function (elem) {
197
+    console.log('addssrc', new Date().getTime());
198
+    console.log('ice', this.iceConnectionState);
199
+    var sdp = new SDP(this.remoteDescription.sdp);
200
+
201
+    var self = this;
202
+    $(elem).each(function (idx, content) {
203
+        var name = $(content).attr('name');
204
+        var lines = '';
205
+        tmp = $(content).find('>source[xmlns="urn:xmpp:jingle:apps:rtp:ssma:0"]');
206
+        tmp.each(function () {
207
+            var ssrc = $(this).attr('ssrc');
208
+            $(this).find('>parameter').each(function () {
209
+                lines += 'a=ssrc:' + ssrc + ' ' + $(this).attr('name');
210
+                if ($(this).attr('value') && $(this).attr('value').length)
211
+                    lines += ':' + $(this).attr('value');
212
+                lines += '\r\n';
213
+            });
214
+        });
215
+        sdp.media.forEach(function(media, idx) {
216
+            if (!SDPUtil.find_line(media, 'a=mid:' + name))
217
+                return;
218
+            sdp.media[idx] += lines;
219
+            self.enqueueAddSsrc(idx, lines);
220
+        });
221
+        sdp.raw = sdp.session + sdp.media.join('');
222
+    });
223
+    this.modifySources();
224
+};
225
+
226
+TraceablePeerConnection.prototype.enqueueRemoveSsrc = function(channel, ssrcLines) {
227
+    if (!this.removessrc[channel]){
228
+        this.removessrc[channel] = '';
229
+    }
230
+    this.removessrc[channel] += ssrcLines;
231
+}
232
+
233
+TraceablePeerConnection.prototype.removeSource = function (elem) {
234
+    console.log('removessrc', new Date().getTime());
235
+    console.log('ice', this.iceConnectionState);
236
+    var sdp = new SDP(this.remoteDescription.sdp);
237
+
238
+    var self = this;
239
+    $(elem).each(function (idx, content) {
240
+        var name = $(content).attr('name');
241
+        var lines = '';
242
+        tmp = $(content).find('>source[xmlns="urn:xmpp:jingle:apps:rtp:ssma:0"]');
243
+        tmp.each(function () {
244
+            var ssrc = $(this).attr('ssrc');
245
+            $(this).find('>parameter').each(function () {
246
+                lines += 'a=ssrc:' + ssrc + ' ' + $(this).attr('name');
247
+                if ($(this).attr('value') && $(this).attr('value').length)
248
+                    lines += ':' + $(this).attr('value');
249
+                lines += '\r\n';
250
+            });
251
+        });
252
+        sdp.media.forEach(function(media, idx) {
253
+            if (!SDPUtil.find_line(media, 'a=mid:' + name))
254
+                return;
255
+            sdp.media[idx] += lines;
256
+            self.enqueueRemoveSsrc(idx, lines);
257
+        });
258
+        sdp.raw = sdp.session + sdp.media.join('');
259
+    });
260
+    this.modifySources();
261
+};
262
+
263
+TraceablePeerConnection.prototype.modifySources = function(successCallback) {
264
+    var self = this;
265
+    if (this.signalingState == 'closed') return;
266
+    if (!(this.addssrc.length || this.removessrc.length || this.pendingop !== null)){
267
+        if(successCallback){
268
+            successCallback();
269
+        }
270
+        return;
271
+    }
272
+
273
+    // FIXME: this is a big hack
274
+    // https://code.google.com/p/webrtc/issues/detail?id=2688
275
+    if (!(this.signalingState == 'stable' && this.iceConnectionState == 'connected')) {
276
+        console.warn('modifySources not yet', this.signalingState, this.iceConnectionState);
277
+        this.wait = true;
278
+        window.setTimeout(function() { self.modifySources(); }, 250);
279
+        return;
280
+    }
281
+    if (this.wait) {
282
+        window.setTimeout(function() { self.modifySources(); }, 2500);
283
+        this.wait = false;
284
+        return;
285
+    }
286
+
287
+    var sdp = new SDP(this.remoteDescription.sdp);
288
+
289
+    // add sources
290
+    this.addssrc.forEach(function(lines, idx) {
291
+        sdp.media[idx] += lines;
292
+    });
293
+    this.addssrc = [];
294
+
295
+    // remove sources
296
+    this.removessrc.forEach(function(lines, idx) {
297
+        lines = lines.split('\r\n');
298
+        lines.pop(); // remove empty last element;
299
+        lines.forEach(function(line) {
300
+            sdp.media[idx] = sdp.media[idx].replace(line + '\r\n', '');
301
+        });
302
+    });
303
+    this.removessrc = [];
304
+
305
+    sdp.raw = sdp.session + sdp.media.join('');
306
+    this.setRemoteDescription(new RTCSessionDescription({type: 'offer', sdp: sdp.raw}),
307
+        function() {
308
+            self.createAnswer(
309
+                function(modifiedAnswer) {
310
+                    // change video direction, see https://github.com/jitsi/jitmeet/issues/41
311
+                    if (self.pendingop !== null) {
312
+                        var sdp = new SDP(modifiedAnswer.sdp);
313
+                        if (sdp.media.length > 1) {
314
+                            switch(self.pendingop) {
315
+                                case 'mute':
316
+                                    sdp.media[1] = sdp.media[1].replace('a=sendrecv', 'a=recvonly');
317
+                                    break;
318
+                                case 'unmute':
319
+                                    sdp.media[1] = sdp.media[1].replace('a=recvonly', 'a=sendrecv');
320
+                                    break;
321
+                            }
322
+                            sdp.raw = sdp.session + sdp.media.join('');
323
+                            modifiedAnswer.sdp = sdp.raw;
324
+                        }
325
+                        self.pendingop = null;
326
+                    }
327
+
328
+                    self.setLocalDescription(modifiedAnswer,
329
+                        function() {
330
+                            //console.log('modified setLocalDescription ok');
331
+                            if(successCallback){
332
+                                successCallback();
333
+                            }
334
+                        },
335
+                        function(error) {
336
+                            console.error('modified setLocalDescription failed', error);
337
+                        }
338
+                    );
339
+                },
340
+                function(error) {
341
+                    console.error('modified answer failed', error);
342
+                }
343
+            );
344
+        },
345
+        function(error) {
346
+            console.error('modify failed', error);
347
+        }
348
+    );
349
+};
350
+
166 351
 TraceablePeerConnection.prototype.close = function () {
167 352
     this.trace('stop');
168 353
     if (this.statsinterval !== null) {

+ 18
- 143
libs/strophe/strophe.jingle.session.js ファイルの表示

@@ -9,7 +9,19 @@ function JingleSession(me, sid, connection) {
9 9
     this.isInitiator = null;
10 10
     this.peerjid = null;
11 11
     this.state = null;
12
+    /**
13
+     * Peer connection instance.
14
+     * @type {TraceablePeerConnection}
15
+     */
12 16
     this.peerconnection = null;
17
+    //console.log('create PeerConnection ' + JSON.stringify(this.ice_config));
18
+    try {
19
+        this.peerconnection = new RTCPeerconnection(this.ice_config, this.pc_constraints);
20
+    } catch (e) {
21
+        console.error('Failed to create PeerConnection, exception: ', e.message);
22
+        console.error(e);
23
+    }
24
+
13 25
     this.remoteStream = null;
14 26
     this.localSDP = null;
15 27
     this.remoteSDP = null;
@@ -35,10 +47,6 @@ function JingleSession(me, sid, connection) {
35 47
 
36 48
     this.reason = null;
37 49
 
38
-    this.addssrc = [];
39
-    this.removessrc = [];
40
-    this.pendingop = null;
41
-
42 50
     this.wait = true;
43 51
 }
44 52
 
@@ -54,16 +62,6 @@ JingleSession.prototype.initiate = function (peerjid, isInitiator) {
54 62
     this.initiator = isInitiator ? this.me : peerjid;
55 63
     this.responder = !isInitiator ? this.me : peerjid;
56 64
     this.peerjid = peerjid;
57
-    //console.log('create PeerConnection ' + JSON.stringify(this.ice_config));
58
-    try {
59
-        this.peerconnection = new RTCPeerconnection(this.ice_config,
60
-            this.pc_constraints);
61
-    } catch (e) {
62
-        console.error('Failed to create PeerConnection, exception: ',
63
-            e.message);
64
-        console.error(e);
65
-        return;
66
-    }
67 65
     this.hadstuncandidate = false;
68 66
     this.hadturncandidate = false;
69 67
     this.lasticecandidate = false;
@@ -635,150 +633,27 @@ JingleSession.prototype.sendTerminate = function (reason, text) {
635 633
 
636 634
 
637 635
 JingleSession.prototype.addSource = function (elem) {
638
-    console.log('addssrc', new Date().getTime());
639
-    console.log('ice', this.peerconnection.iceConnectionState);
640
-    var sdp = new SDP(this.peerconnection.remoteDescription.sdp);
641 636
 
642
-    var self = this;
643
-    $(elem).each(function (idx, content) {
644
-        var name = $(content).attr('name');
645
-        var lines = '';
646
-        tmp = $(content).find('>source[xmlns="urn:xmpp:jingle:apps:rtp:ssma:0"]');
647
-        tmp.each(function () {
648
-            var ssrc = $(this).attr('ssrc');
649
-            $(this).find('>parameter').each(function () {
650
-                lines += 'a=ssrc:' + ssrc + ' ' + $(this).attr('name');
651
-                if ($(this).attr('value') && $(this).attr('value').length)
652
-                    lines += ':' + $(this).attr('value');
653
-                lines += '\r\n';
654
-            });
655
-        });
656
-        sdp.media.forEach(function(media, idx) {
657
-            if (!SDPUtil.find_line(media, 'a=mid:' + name))
658
-                return;
659
-            sdp.media[idx] += lines;
660
-            if (!self.addssrc[idx]) self.addssrc[idx] = '';
661
-            self.addssrc[idx] += lines;
662
-        });
663
-        sdp.raw = sdp.session + sdp.media.join('');
664
-    });
665
-    this.modifySources();
637
+    this.peerconnection.addSource(elem);
666 638
 };
667 639
 
668 640
 JingleSession.prototype.removeSource = function (elem) {
669
-    console.log('removessrc', new Date().getTime());
670
-    console.log('ice', this.peerconnection.iceConnectionState);
671
-    var sdp = new SDP(this.peerconnection.remoteDescription.sdp);
672 641
 
673
-    var self = this;
674
-    $(elem).each(function (idx, content) {
675
-        var name = $(content).attr('name');
676
-        var lines = '';
677
-        tmp = $(content).find('>source[xmlns="urn:xmpp:jingle:apps:rtp:ssma:0"]');
678
-        tmp.each(function () {
679
-            var ssrc = $(this).attr('ssrc');
680
-            $(this).find('>parameter').each(function () {
681
-                lines += 'a=ssrc:' + ssrc + ' ' + $(this).attr('name');
682
-                if ($(this).attr('value') && $(this).attr('value').length)
683
-                    lines += ':' + $(this).attr('value');
684
-                lines += '\r\n';
685
-            });
686
-        });
687
-        sdp.media.forEach(function(media, idx) {
688
-            if (!SDPUtil.find_line(media, 'a=mid:' + name))
689
-                return;
690
-            sdp.media[idx] += lines;
691
-            if (!self.removessrc[idx]) self.removessrc[idx] = '';
692
-            self.removessrc[idx] += lines;
693
-        });
694
-        sdp.raw = sdp.session + sdp.media.join('');
695
-    });
696
-    this.modifySources();
642
+    this.peerconnection.removeSource(elem);
697 643
 };
698 644
 
699 645
 JingleSession.prototype.modifySources = function() {
700 646
     var self = this;
701
-    if (this.peerconnection.signalingState == 'closed') return;
702
-    if (!(this.addssrc.length || this.removessrc.length || this.pendingop !== null)) return;
703
-    if (!(this.peerconnection.signalingState == 'stable' && this.peerconnection.iceConnectionState == 'connected')) {
704
-        console.warn('modifySources not yet', this.peerconnection.signalingState, this.peerconnection.iceConnectionState);
705
-        this.wait = true;
706
-        window.setTimeout(function() { self.modifySources(); }, 250);
707
-        return;
708
-    }
709
-    if (this.wait) {
710
-        window.setTimeout(function() { self.modifySources(); }, 2500);
711
-        this.wait = false;
712
-        return;
713
-    }
714
-
715
-    var sdp = new SDP(this.peerconnection.remoteDescription.sdp);
716
-
717
-    // add sources
718
-    this.addssrc.forEach(function(lines, idx) {
719
-        sdp.media[idx] += lines;
720
-    });
721
-    this.addssrc = [];
722
-
723
-    // remove sources
724
-    this.removessrc.forEach(function(lines, idx) {
725
-        lines = lines.split('\r\n');
726
-        lines.pop(); // remove empty last element;
727
-        lines.forEach(function(line) {
728
-            sdp.media[idx] = sdp.media[idx].replace(line + '\r\n', '');
729
-        });
647
+    this.peerconnection.modifySources(function(){
648
+        $(document).trigger('setLocalDescription.jingle', [self.sid]);
730 649
     });
731
-    this.removessrc = [];
732
-
733
-    sdp.raw = sdp.session + sdp.media.join('');
734
-    this.peerconnection.setRemoteDescription(new RTCSessionDescription({type: 'offer', sdp: sdp.raw}),
735
-        function() {
736
-            self.peerconnection.createAnswer(
737
-                function(modifiedAnswer) {
738
-                    // change video direction, see https://github.com/jitsi/jitmeet/issues/41
739
-                    if (self.pendingop !== null) {
740
-                        var sdp = new SDP(modifiedAnswer.sdp);
741
-                        if (sdp.media.length > 1) {
742
-                            switch(self.pendingop) {
743
-                                case 'mute':
744
-                                    sdp.media[1] = sdp.media[1].replace('a=sendrecv', 'a=recvonly');
745
-                                    break;
746
-                                case 'unmute':
747
-                                    sdp.media[1] = sdp.media[1].replace('a=recvonly', 'a=sendrecv');
748
-                                    break;
749
-                            }
750
-                            sdp.raw = sdp.session + sdp.media.join('');
751
-                            modifiedAnswer.sdp = sdp.raw;
752
-                        }
753
-                        self.pendingop = null;
754
-                    }
755
-
756
-                    self.peerconnection.setLocalDescription(modifiedAnswer,
757
-                        function() {
758
-                            //console.log('modified setLocalDescription ok');
759
-                            $(document).trigger('setLocalDescription.jingle', [self.sid]);
760
-                        },
761
-                        function(error) {
762
-                            console.log('modified setLocalDescription failed');
763
-                        }
764
-                    );
765
-                },
766
-                function(error) {
767
-                    console.log('modified answer failed');
768
-                }
769
-            );
770
-        },
771
-        function(error) {
772
-            console.log('modify failed');
773
-        }
774
-    );
775 650
 };
776 651
 
777 652
 // SDP-based mute by going recvonly/sendrecv
778 653
 // FIXME: should probably black out the screen as well
779 654
 JingleSession.prototype.hardMuteVideo = function (muted) {
780
-    this.pendingop = muted ? 'mute' : 'unmute';
781
-    this.modifySources();
655
+
656
+    this.peerconnection.hardMuteVideo(muted);
782 657
 
783 658
     this.connection.jingle.localStream.getVideoTracks().forEach(function (track) {
784 659
         track.enabled = !muted;

読み込み中…
キャンセル
保存