Преглед на файлове

Removes local streams from the connection object.

j8
hristoterezov преди 10 години
родител
ревизия
e6fbb0934e

+ 15
- 46
app.js Целия файл

58
 }
58
 }
59
 
59
 
60
 function connect(jid, password) {
60
 function connect(jid, password) {
61
-    var localAudio, localVideo;
62
-    if (connection && connection.jingle) {
63
-        localAudio = connection.jingle.localAudio;
64
-        localVideo = connection.jingle.localVideo;
65
-    }
66
     connection = new Strophe.Connection(document.getElementById('boshURL').value || config.bosh || '/http-bind');
61
     connection = new Strophe.Connection(document.getElementById('boshURL').value || config.bosh || '/http-bind');
67
 
62
 
68
     var settings = UI.getSettings();
63
     var settings = UI.getSettings();
86
         if (!connection.jingle.pc_constraints.optional) connection.jingle.pc_constraints.optional = [];
81
         if (!connection.jingle.pc_constraints.optional) connection.jingle.pc_constraints.optional = [];
87
         connection.jingle.pc_constraints.optional.push({googIPv6: true});
82
         connection.jingle.pc_constraints.optional.push({googIPv6: true});
88
     }
83
     }
89
-    if (localAudio) connection.jingle.localAudio = localAudio;
90
-    if (localVideo) connection.jingle.localVideo = localVideo;
91
 
84
 
92
     if(!password)
85
     if(!password)
93
         password = document.getElementById('password').value;
86
         password = document.getElementById('password').value;
127
 
120
 
128
 function maybeDoJoin() {
121
 function maybeDoJoin() {
129
     if (connection && connection.connected && Strophe.getResourceFromJid(connection.jid) // .connected is true while connecting?
122
     if (connection && connection.connected && Strophe.getResourceFromJid(connection.jid) // .connected is true while connecting?
130
-        && (connection.jingle.localAudio || connection.jingle.localVideo)) {
123
+        && (RTC.localAudio || RTC.localVideo)) {
131
         doJoin();
124
         doJoin();
132
     }
125
     }
133
 }
126
 }
300
     if (isVideo &&
293
     if (isVideo &&
301
         data.peerjid && sess.peerjid === data.peerjid &&
294
         data.peerjid && sess.peerjid === data.peerjid &&
302
         data.stream.getVideoTracks().length === 0 &&
295
         data.stream.getVideoTracks().length === 0 &&
303
-        connection.jingle.localVideo.getVideoTracks().length > 0) {
296
+        RTC.localVideo.getTracks().length > 0) {
304
         //
297
         //
305
         window.setTimeout(function () {
298
         window.setTimeout(function () {
306
             sendKeyframe(sess.peerconnection);
299
             sendKeyframe(sess.peerconnection);
621
  * contrast to an automatic decision taken by the application logic)
614
  * contrast to an automatic decision taken by the application logic)
622
  */
615
  */
623
 function setVideoMute(mute, options) {
616
 function setVideoMute(mute, options) {
624
-    if (connection && connection.jingle.localVideo) {
625
-        var session = activecall;
626
-
627
-        if (session) {
628
-            session.setVideoMute(
617
+    if (connection && RTC.localVideo) {
618
+        if (activecall) {
619
+            activecall.setVideoMute(
629
                 mute,
620
                 mute,
630
                 function (mute) {
621
                 function (mute) {
631
                     var video = $('#video');
622
                     var video = $('#video');
659
 function toggleVideo() {
650
 function toggleVideo() {
660
     buttonClick("#video", "icon-camera icon-camera-disabled");
651
     buttonClick("#video", "icon-camera icon-camera-disabled");
661
 
652
 
662
-    if (connection && connection.jingle.localVideo) {
663
-        var session = activecall;
664
-
665
-        if (session) {
666
-            setVideoMute(!session.isVideoMute());
667
-        }
653
+    if (connection && activecall && RTC.localVideo ) {
654
+        setVideoMute(!RTC.localVideo.isMuted());
668
     }
655
     }
669
 }
656
 }
670
 
657
 
672
  * Mutes / unmutes audio for the local participant.
659
  * Mutes / unmutes audio for the local participant.
673
  */
660
  */
674
 function toggleAudio() {
661
 function toggleAudio() {
675
-    setAudioMuted(!isAudioMuted());
662
+    setAudioMuted(!RTC.localAudio.isMuted());
676
 }
663
 }
677
 
664
 
678
 /**
665
 /**
679
  * Sets muted audio state for the local participant.
666
  * Sets muted audio state for the local participant.
680
  */
667
  */
681
 function setAudioMuted(mute) {
668
 function setAudioMuted(mute) {
682
-    if (!(connection && connection.jingle.localAudio)) {
669
+    if (!(connection && RTC.localAudio)) {
683
         preMuted = mute;
670
         preMuted = mute;
684
         // We still click the button.
671
         // We still click the button.
685
         buttonClick("#mute", "icon-microphone icon-mic-disabled");
672
         buttonClick("#mute", "icon-microphone icon-mic-disabled");
693
         forceMuted = false;
680
         forceMuted = false;
694
     }
681
     }
695
 
682
 
696
-    if (mute == isAudioMuted()) {
683
+    if (mute == RTC.localAudio.isMuted()) {
697
         // Nothing to do
684
         // Nothing to do
698
         return;
685
         return;
699
     }
686
     }
701
     // It is not clear what is the right way to handle multiple tracks.
688
     // It is not clear what is the right way to handle multiple tracks.
702
     // So at least make sure that they are all muted or all unmuted and
689
     // So at least make sure that they are all muted or all unmuted and
703
     // that we send presence just once.
690
     // that we send presence just once.
704
-    var localAudioTracks = connection.jingle.localAudio.getAudioTracks();
705
-    if (localAudioTracks.length > 0) {
706
-        for (var idx = 0; idx < localAudioTracks.length; idx++) {
707
-            localAudioTracks[idx].enabled = !mute;
708
-        }
709
-    }
691
+    RTC.localAudio.mute();
710
     // isMuted is the opposite of audioEnabled
692
     // isMuted is the opposite of audioEnabled
711
     connection.emuc.addAudioInfoToPresence(mute);
693
     connection.emuc.addAudioInfoToPresence(mute);
712
     connection.emuc.sendPresence();
694
     connection.emuc.sendPresence();
715
     buttonClick("#mute", "icon-microphone icon-mic-disabled");
697
     buttonClick("#mute", "icon-microphone icon-mic-disabled");
716
 }
698
 }
717
 
699
 
718
-/**
719
- * Checks whether the audio is muted or not.
720
- * @returns {boolean} true if audio is muted and false if not.
721
- */
722
-function isAudioMuted()
723
-{
724
-    var localAudio = connection.jingle.localAudio;
725
-    for (var idx = 0; idx < localAudio.getAudioTracks().length; idx++) {
726
-        if(localAudio.getAudioTracks()[idx].enabled === true)
727
-            return false;
728
-    }
729
-    return true;
730
-}
731
 
700
 
732
 $(document).ready(function () {
701
 $(document).ready(function () {
733
 
702
 
780
     if (handler && handler.peerconnection) {
749
     if (handler && handler.peerconnection) {
781
         // FIXME: probably removing streams is not required and close() should
750
         // FIXME: probably removing streams is not required and close() should
782
         // be enough
751
         // be enough
783
-        if (connection.jingle.localAudio) {
784
-            handler.peerconnection.removeStream(connection.jingle.localAudio, onUnload);
752
+        if (RTC.localAudio) {
753
+            handler.peerconnection.removeStream(RTC.localAudio.getOriginalStream(), onUnload);
785
         }
754
         }
786
-        if (connection.jingle.localVideo) {
787
-            handler.peerconnection.removeStream(connection.jingle.localVideo, onUnload);
755
+        if (RTC.localVideo) {
756
+            handler.peerconnection.removeStream(RTC.localVideo.getOriginalStream(), onUnload);
788
         }
757
         }
789
         handler.peerconnection.close();
758
         handler.peerconnection.close();
790
     }
759
     }

+ 2
- 2
desktopsharing.js Целия файл

254
 
254
 
255
 function newStreamCreated(stream) {
255
 function newStreamCreated(stream) {
256
 
256
 
257
-    var oldStream = connection.jingle.localVideo;
257
+    var oldStream = RTC.localVideo.getOriginalStream();
258
 
258
 
259
-    connection.jingle.localVideo = stream;
259
+    RTC.localVideo.stream = stream;
260
 
260
 
261
     UI.changeLocalVideo(stream, !isUsingScreenStream);
261
     UI.changeLocalVideo(stream, !isUsingScreenStream);
262
 
262
 

+ 8
- 8
index.html Целия файл

15
     <script src="libs/strophe/strophe.min.js?v=1"></script>
15
     <script src="libs/strophe/strophe.min.js?v=1"></script>
16
     <script src="libs/strophe/strophe.disco.min.js?v=1"></script>
16
     <script src="libs/strophe/strophe.disco.min.js?v=1"></script>
17
     <script src="libs/strophe/strophe.caps.jsonly.min.js?v=1"></script>
17
     <script src="libs/strophe/strophe.caps.jsonly.min.js?v=1"></script>
18
-    <script src="libs/strophe/strophe.jingle.js?v=2"></script>
19
-    <script src="libs/strophe/strophe.jingle.sdp.js?v=4"></script>
20
-    <script src="libs/strophe/strophe.jingle.session.js?v=4"></script>
18
+    <script src="libs/strophe/strophe.jingle.js?v=3"></script>
19
+    <script src="libs/strophe/strophe.jingle.sdp.js?v=5"></script>
20
+    <script src="libs/strophe/strophe.jingle.session.js?v=5"></script>
21
     <script src="libs/strophe/strophe.util.js"></script>
21
     <script src="libs/strophe/strophe.util.js"></script>
22
     <script src="libs/jquery-ui.js"></script>
22
     <script src="libs/jquery-ui.js"></script>
23
     <script src="libs/rayo.js?v=1"></script>
23
     <script src="libs/rayo.js?v=1"></script>
29
     <script src="service/RTC/RTCBrowserType.js?v=1"></script>
29
     <script src="service/RTC/RTCBrowserType.js?v=1"></script>
30
     <script src="service/RTC/StreamEventTypes.js?v=1"></script>
30
     <script src="service/RTC/StreamEventTypes.js?v=1"></script>
31
     <script src="service/RTC/MediaStreamTypes.js?v=1"></script>
31
     <script src="service/RTC/MediaStreamTypes.js?v=1"></script>
32
-    <script src="libs/modules/simulcast.bundle.js?v=1"></script>
32
+    <script src="libs/modules/simulcast.bundle.js?v=2"></script>
33
     <script src="libs/modules/connectionquality.bundle.js?v=1"></script>
33
     <script src="libs/modules/connectionquality.bundle.js?v=1"></script>
34
-    <script src="libs/modules/UI.bundle.js?v=2"></script>
34
+    <script src="libs/modules/UI.bundle.js?v=3"></script>
35
     <script src="libs/modules/statistics.bundle.js?v=1"></script>
35
     <script src="libs/modules/statistics.bundle.js?v=1"></script>
36
-    <script src="libs/modules/RTC.bundle.js?v=1"></script>
36
+    <script src="libs/modules/RTC.bundle.js?v=2"></script>
37
     <script src="muc.js?v=17"></script><!-- simple MUC library -->
37
     <script src="muc.js?v=17"></script><!-- simple MUC library -->
38
     <script src="estos_log.js?v=2"></script><!-- simple stanza logger -->
38
     <script src="estos_log.js?v=2"></script><!-- simple stanza logger -->
39
     <script src="desktopsharing.js?v=3"></script><!-- desktop sharing -->
39
     <script src="desktopsharing.js?v=3"></script><!-- desktop sharing -->
40
-    <script src="app.js?v=24"></script><!-- application logic -->
40
+    <script src="app.js?v=25"></script><!-- application logic -->
41
     <script src="libs/modules/API.bundle.js?v=1"></script>
41
     <script src="libs/modules/API.bundle.js?v=1"></script>
42
     <script src="util.js?v=7"></script><!-- utility functions -->
42
     <script src="util.js?v=7"></script><!-- utility functions -->
43
     <script src="moderatemuc.js?v=4"></script><!-- moderator plugin -->
43
     <script src="moderatemuc.js?v=4"></script><!-- moderator plugin -->
44
     <script src="analytics.js?v=1"></script><!-- google analytics plugin -->
44
     <script src="analytics.js?v=1"></script><!-- google analytics plugin -->
45
     <script src="moderator.js?v=2"></script><!-- media stream -->
45
     <script src="moderator.js?v=2"></script><!-- media stream -->
46
     <script src="tracking.js?v=1"></script><!-- tracking -->
46
     <script src="tracking.js?v=1"></script><!-- tracking -->
47
-    <script src="keyboard_shortcut.js?v=3"></script>
47
+    <script src="keyboard_shortcut.js?v=4"></script>
48
     <link rel="stylesheet" href="css/font.css?v=6"/>
48
     <link rel="stylesheet" href="css/font.css?v=6"/>
49
     <link rel="stylesheet" href="css/toastr.css?v=1">
49
     <link rel="stylesheet" href="css/toastr.css?v=1">
50
     <link rel="stylesheet" type="text/css" media="screen" href="css/main.css?v=30"/>
50
     <link rel="stylesheet" type="text/css" media="screen" href="css/main.css?v=30"/>

+ 2
- 2
keyboard_shortcut.js Целия файл

19
         84: {
19
         84: {
20
             character: "T",
20
             character: "T",
21
             function: function() {
21
             function: function() {
22
-                if(!isAudioMuted()) {
22
+                if(!RTC.localAudio.isMuted()) {
23
                     toggleAudio();
23
                     toggleAudio();
24
                 }
24
                 }
25
             }
25
             }
52
     window.onkeydown = function(e) {
52
     window.onkeydown = function(e) {
53
         if(!($(":focus").is("input[type=text]") || $(":focus").is("input[type=password]") || $(":focus").is("textarea"))) {
53
         if(!($(":focus").is("input[type=text]") || $(":focus").is("input[type=password]") || $(":focus").is("textarea"))) {
54
             if(e.which === "T".charCodeAt(0)) {
54
             if(e.which === "T".charCodeAt(0)) {
55
-                if(isAudioMuted()) {
55
+                if(RTC.localAudio.isMuted()) {
56
                     toggleAudio();
56
                     toggleAudio();
57
                 }
57
                 }
58
             }
58
             }

+ 47
- 15
libs/modules/RTC.bundle.js Целия файл

243
     this.stream = stream;
243
     this.stream = stream;
244
     this.eventEmitter = eventEmitter;
244
     this.eventEmitter = eventEmitter;
245
     this.type = type;
245
     this.type = type;
246
-
247
     var self = this;
246
     var self = this;
247
+    if(type == "audio")
248
+    {
249
+        this.getTracks = function () {
250
+            return self.stream.getAudioTracks();
251
+        };
252
+    }
253
+    else
254
+    {
255
+        this.getTracks = function () {
256
+            return self.stream.getVideoTracks();
257
+        };
258
+    }
259
+
248
     this.stream.onended = function()
260
     this.stream.onended = function()
249
     {
261
     {
250
         self.streamEnded();
262
         self.streamEnded();
262
 
274
 
263
 LocalStream.prototype.isAudioStream = function () {
275
 LocalStream.prototype.isAudioStream = function () {
264
     return (this.stream.getAudioTracks() && this.stream.getAudioTracks().length > 0);
276
     return (this.stream.getAudioTracks() && this.stream.getAudioTracks().length > 0);
265
-}
277
+};
266
 
278
 
267
 LocalStream.prototype.mute = function()
279
 LocalStream.prototype.mute = function()
268
 {
280
 {
269
     var ismuted = false;
281
     var ismuted = false;
270
-    var tracks = [];
271
-    if(this.type = "audio")
272
-    {
273
-        tracks = this.stream.getAudioTracks();
274
-    }
275
-    else
276
-    {
277
-        tracks = this.stream.getVideoTracks();
278
-    }
282
+    var tracks = this.getTracks();
279
 
283
 
280
     for (var idx = 0; idx < tracks.length; idx++) {
284
     for (var idx = 0; idx < tracks.length; idx++) {
281
         ismuted = !tracks[idx].enabled;
285
         ismuted = !tracks[idx].enabled;
282
-        tracks[idx].enabled = !tracks[idx].enabled;
286
+        tracks[idx].enabled = ismuted;
283
     }
287
     }
284
     return ismuted;
288
     return ismuted;
285
-}
289
+};
290
+
291
+LocalStream.prototype.setMute = function(mute)
292
+{
293
+    var tracks = this.getTracks();
294
+
295
+    for (var idx = 0; idx < tracks.length; idx++) {
296
+        tracks[idx].enabled = mute;
297
+    }
298
+};
286
 
299
 
287
 LocalStream.prototype.isMuted = function () {
300
 LocalStream.prototype.isMuted = function () {
288
     var tracks = [];
301
     var tracks = [];
289
-    if(this.type = "audio")
302
+    if(this.type == "audio")
290
     {
303
     {
291
         tracks = this.stream.getAudioTracks();
304
         tracks = this.stream.getAudioTracks();
292
     }
305
     }
301
     return true;
314
     return true;
302
 }
315
 }
303
 
316
 
317
+LocalStream.prototype.getId = function () {
318
+    return this.stream.getTracks()[0].id;
319
+}
320
+
321
+
322
+
304
 module.exports = LocalStream;
323
 module.exports = LocalStream;
305
 
324
 
306
 },{}],3:[function(require,module,exports){
325
 },{}],3:[function(require,module,exports){
394
     createLocalStream: function (stream, type) {
413
     createLocalStream: function (stream, type) {
395
 
414
 
396
         var localStream =  new LocalStream(stream, type, eventEmitter);
415
         var localStream =  new LocalStream(stream, type, eventEmitter);
397
-        this.localStreams.push(localStream);
416
+        //in firefox we have only one stream object
417
+        if(this.localStreams.length == 0 ||
418
+            this.localStreams[0].getOriginalStream() != stream)
419
+            this.localStreams.push(localStream);
398
         if(type == "audio")
420
         if(type == "audio")
399
         {
421
         {
400
             this.localAudio = localStream;
422
             this.localAudio = localStream;
484
             return true;
506
             return true;
485
         }
507
         }
486
         return false;
508
         return false;
509
+    },
510
+    switchVideoStreams: function (new_stream) {
511
+        this.localVideo.stream = new_stream;
512
+
513
+        this.localStreams = [];
514
+
515
+        //in firefox we have only one stream object
516
+        if(this.localAudio.getOriginalStream() != new_stream)
517
+            this.localStreams.push(this.localAudio);
518
+        this.localStreams.push(this.localVideo);
487
     }
519
     }
488
 
520
 
489
 };
521
 };

+ 1
- 5
libs/modules/UI.bundle.js Целия файл

84
         if(jid === statistics.LOCAL_JID)
84
         if(jid === statistics.LOCAL_JID)
85
         {
85
         {
86
             resourceJid = AudioLevels.LOCAL_LEVEL;
86
             resourceJid = AudioLevels.LOCAL_LEVEL;
87
-            if(isAudioMuted())
87
+            if(RTC.localAudio.isMuted())
88
             {
88
             {
89
                 audioLevel = 0;
89
                 audioLevel = 0;
90
             }
90
             }
4591
     };
4591
     };
4592
 
4592
 
4593
     my.changeLocalStream = function (stream) {
4593
     my.changeLocalStream = function (stream) {
4594
-        connection.jingle.localAudio = stream;
4595
         VideoLayout.changeLocalVideo(stream, true);
4594
         VideoLayout.changeLocalVideo(stream, true);
4596
     };
4595
     };
4597
 
4596
 
4598
     my.changeLocalAudio = function(stream) {
4597
     my.changeLocalAudio = function(stream) {
4599
-        connection.jingle.localAudio = stream;
4600
         RTC.attachMediaStream($('#localAudio'), stream);
4598
         RTC.attachMediaStream($('#localAudio'), stream);
4601
         document.getElementById('localAudio').autoplay = true;
4599
         document.getElementById('localAudio').autoplay = true;
4602
         document.getElementById('localAudio').volume = 0;
4600
         document.getElementById('localAudio').volume = 0;
4607
     };
4605
     };
4608
 
4606
 
4609
     my.changeLocalVideo = function(stream, flipX) {
4607
     my.changeLocalVideo = function(stream, flipX) {
4610
-        connection.jingle.localVideo = stream;
4611
-
4612
         var localVideo = document.createElement('video');
4608
         var localVideo = document.createElement('video');
4613
         localVideo.id = 'localVideo_' + RTC.getStreamID(stream);
4609
         localVideo.id = 'localVideo_' + RTC.getStreamID(stream);
4614
         localVideo.autoplay = true;
4610
         localVideo.autoplay = true;

+ 1
- 1
libs/modules/simulcast.bundle.js Целия файл

369
     return (this.displayedLocalVideoStream != null)
369
     return (this.displayedLocalVideoStream != null)
370
         ? this.displayedLocalVideoStream
370
         ? this.displayedLocalVideoStream
371
         // in case we have no simulcast at all, i.e. we didn't perform the GUM
371
         // in case we have no simulcast at all, i.e. we didn't perform the GUM
372
-        : connection.jingle.localVideo;
372
+        : RTC.localVideo.getOriginalStream();
373
 };
373
 };
374
 
374
 
375
 function NativeSimulcastSender() {
375
 function NativeSimulcastSender() {

+ 0
- 17
libs/strophe/strophe.jingle.js Целия файл

31
         }
31
         }
32
         // MozDontOfferDataChannel: true when this is firefox
32
         // MozDontOfferDataChannel: true when this is firefox
33
     },
33
     },
34
-    localAudio: null,
35
-    localVideo: null,
36
-
37
     init: function (conn) {
34
     init: function (conn) {
38
         this.connection = conn;
35
         this.connection = conn;
39
         if (this.connection.disco) {
36
         if (this.connection.disco) {
108
                 sess = new JingleSession($(iq).attr('to'), $(iq).find('jingle').attr('sid'), this.connection);
105
                 sess = new JingleSession($(iq).attr('to'), $(iq).find('jingle').attr('sid'), this.connection);
109
                 // configure session
106
                 // configure session
110
 
107
 
111
-                //in firefox we have only one stream object
112
-                if (this.localAudio != this.localVideo) {
113
-                    sess.localStreams.push(this.localAudio);
114
-                }
115
-                if (this.localVideo) {
116
-                    sess.localStreams.push(this.localVideo);
117
-                }
118
                 sess.media_constraints = this.media_constraints;
108
                 sess.media_constraints = this.media_constraints;
119
                 sess.pc_constraints = this.pc_constraints;
109
                 sess.pc_constraints = this.pc_constraints;
120
                 sess.ice_config = this.ice_config;
110
                 sess.ice_config = this.ice_config;
195
             this.connection);
185
             this.connection);
196
         // configure session
186
         // configure session
197
 
187
 
198
-        //in firefox we have only one stream
199
-        if (this.localAudio != this.localVideo) {
200
-            sess.localStreams.push(this.localAudio);
201
-        }
202
-        if (this.localVideo) {
203
-            sess.localStreams.push(this.localVideo);
204
-        }
205
         sess.media_constraints = this.media_constraints;
188
         sess.media_constraints = this.media_constraints;
206
         sess.pc_constraints = this.pc_constraints;
189
         sess.pc_constraints = this.pc_constraints;
207
         sess.ice_config = this.ice_config;
190
         sess.ice_config = this.ice_config;

+ 2
- 2
libs/strophe/strophe.jingle.sdp.js Целия файл

396
                     var msid = null;
396
                     var msid = null;
397
                     if(mline.media == "audio")
397
                     if(mline.media == "audio")
398
                     {
398
                     {
399
-                        msid = connection.jingle.localAudio.getAudioTracks()[0].id;
399
+                        msid = RTC.localAudio.getId();
400
                     }
400
                     }
401
                     else
401
                     else
402
                     {
402
                     {
403
-                        msid = connection.jingle.localVideo.getVideoTracks()[0].id;
403
+                        msid = RTC.localVideo.getId();
404
                     }
404
                     }
405
                     if(msid != null)
405
                     if(msid != null)
406
                     {
406
                     {

+ 7
- 19
libs/strophe/strophe.jingle.session.js Целия файл

11
     this.state = null;
11
     this.state = null;
12
     this.localSDP = null;
12
     this.localSDP = null;
13
     this.remoteSDP = null;
13
     this.remoteSDP = null;
14
-    this.localStreams = [];
15
     this.relayedStreams = [];
14
     this.relayedStreams = [];
16
     this.remoteStreams = [];
15
     this.remoteStreams = [];
17
     this.startTime = null;
16
     this.startTime = null;
103
         $(document).trigger('iceconnectionstatechange.jingle', [self.sid, self]);
102
         $(document).trigger('iceconnectionstatechange.jingle', [self.sid, self]);
104
     };
103
     };
105
     // add any local and relayed stream
104
     // add any local and relayed stream
106
-    this.localStreams.forEach(function(stream) {
107
-        self.peerconnection.addStream(stream);
105
+    RTC.localStreams.forEach(function(stream) {
106
+        self.peerconnection.addStream(stream.getOriginalStream());
108
     });
107
     });
109
     this.relayedStreams.forEach(function(stream) {
108
     this.relayedStreams.forEach(function(stream) {
110
         self.peerconnection.addStream(stream);
109
         self.peerconnection.addStream(stream);
934
         self.peerconnection.addStream(new_stream);
933
         self.peerconnection.addStream(new_stream);
935
     }
934
     }
936
 
935
 
937
-    self.connection.jingle.localVideo = new_stream;
938
-
939
-    self.connection.jingle.localStreams = [];
940
-
941
-    //in firefox we have only one stream object
942
-    if(self.connection.jingle.localAudio != self.connection.jingle.localVideo)
943
-        self.connection.jingle.localStreams.push(self.connection.jingle.localAudio);
944
-    self.connection.jingle.localStreams.push(self.connection.jingle.localVideo);
936
+    RTC.switchVideoStreams(new_stream, oldStream);
945
 
937
 
946
     // Conference is not active
938
     // Conference is not active
947
     if(!oldSdp || !self.peerconnection) {
939
     if(!oldSdp || !self.peerconnection) {
1031
  * disabled; otherwise, <tt>false</tt>
1023
  * disabled; otherwise, <tt>false</tt>
1032
  */
1024
  */
1033
 JingleSession.prototype.isVideoMute = function () {
1025
 JingleSession.prototype.isVideoMute = function () {
1034
-    var tracks = connection.jingle.localVideo.getVideoTracks();
1026
+    var tracks = RTC.localVideo.getVideoTracks();
1035
     var mute = true;
1027
     var mute = true;
1036
 
1028
 
1037
     for (var i = 0; i < tracks.length; ++i) {
1029
     for (var i = 0; i < tracks.length; ++i) {
1075
     } else if (this.videoMuteByUser) {
1067
     } else if (this.videoMuteByUser) {
1076
         return;
1068
         return;
1077
     }
1069
     }
1078
-    if (mute == this.isVideoMute())
1070
+    if (mute == RTC.localVideo.isMuted())
1079
     {
1071
     {
1080
         // Even if no change occurs, the specified callback is to be executed.
1072
         // Even if no change occurs, the specified callback is to be executed.
1081
         // The specified callback may, optionally, return a successCallback
1073
         // The specified callback may, optionally, return a successCallback
1086
             successCallback();
1078
             successCallback();
1087
         }
1079
         }
1088
     } else {
1080
     } else {
1089
-        var tracks = connection.jingle.localVideo.getVideoTracks();
1090
-
1091
-        for (var i = 0; i < tracks.length; ++i) {
1092
-            tracks[i].enabled = !mute;
1093
-        }
1081
+        RTC.localVideo.setMute(!mute);
1094
 
1082
 
1095
         this.hardMuteVideo(mute);
1083
         this.hardMuteVideo(mute);
1096
 
1084
 
1101
 // SDP-based mute by going recvonly/sendrecv
1089
 // SDP-based mute by going recvonly/sendrecv
1102
 // FIXME: should probably black out the screen as well
1090
 // FIXME: should probably black out the screen as well
1103
 JingleSession.prototype.toggleVideoMute = function (callback) {
1091
 JingleSession.prototype.toggleVideoMute = function (callback) {
1104
-    setVideoMute(isVideoMute(), callback);
1092
+    setVideoMute(RTC.localVideo.isMuted(), callback);
1105
 };
1093
 };
1106
 
1094
 
1107
 JingleSession.prototype.hardMuteVideo = function (muted) {
1095
 JingleSession.prototype.hardMuteVideo = function (muted) {

+ 33
- 14
modules/RTC/LocalStream.js Целия файл

5
     this.stream = stream;
5
     this.stream = stream;
6
     this.eventEmitter = eventEmitter;
6
     this.eventEmitter = eventEmitter;
7
     this.type = type;
7
     this.type = type;
8
-
9
     var self = this;
8
     var self = this;
9
+    if(type == "audio")
10
+    {
11
+        this.getTracks = function () {
12
+            return self.stream.getAudioTracks();
13
+        };
14
+    }
15
+    else
16
+    {
17
+        this.getTracks = function () {
18
+            return self.stream.getVideoTracks();
19
+        };
20
+    }
21
+
10
     this.stream.onended = function()
22
     this.stream.onended = function()
11
     {
23
     {
12
         self.streamEnded();
24
         self.streamEnded();
24
 
36
 
25
 LocalStream.prototype.isAudioStream = function () {
37
 LocalStream.prototype.isAudioStream = function () {
26
     return (this.stream.getAudioTracks() && this.stream.getAudioTracks().length > 0);
38
     return (this.stream.getAudioTracks() && this.stream.getAudioTracks().length > 0);
27
-}
39
+};
28
 
40
 
29
 LocalStream.prototype.mute = function()
41
 LocalStream.prototype.mute = function()
30
 {
42
 {
31
     var ismuted = false;
43
     var ismuted = false;
32
-    var tracks = [];
33
-    if(this.type = "audio")
34
-    {
35
-        tracks = this.stream.getAudioTracks();
36
-    }
37
-    else
38
-    {
39
-        tracks = this.stream.getVideoTracks();
40
-    }
44
+    var tracks = this.getTracks();
41
 
45
 
42
     for (var idx = 0; idx < tracks.length; idx++) {
46
     for (var idx = 0; idx < tracks.length; idx++) {
43
         ismuted = !tracks[idx].enabled;
47
         ismuted = !tracks[idx].enabled;
44
-        tracks[idx].enabled = !tracks[idx].enabled;
48
+        tracks[idx].enabled = ismuted;
45
     }
49
     }
46
     return ismuted;
50
     return ismuted;
47
-}
51
+};
52
+
53
+LocalStream.prototype.setMute = function(mute)
54
+{
55
+    var tracks = this.getTracks();
56
+
57
+    for (var idx = 0; idx < tracks.length; idx++) {
58
+        tracks[idx].enabled = mute;
59
+    }
60
+};
48
 
61
 
49
 LocalStream.prototype.isMuted = function () {
62
 LocalStream.prototype.isMuted = function () {
50
     var tracks = [];
63
     var tracks = [];
51
-    if(this.type = "audio")
64
+    if(this.type == "audio")
52
     {
65
     {
53
         tracks = this.stream.getAudioTracks();
66
         tracks = this.stream.getAudioTracks();
54
     }
67
     }
63
     return true;
76
     return true;
64
 }
77
 }
65
 
78
 
79
+LocalStream.prototype.getId = function () {
80
+    return this.stream.getTracks()[0].id;
81
+}
82
+
83
+
84
+
66
 module.exports = LocalStream;
85
 module.exports = LocalStream;

+ 14
- 1
modules/RTC/RTC.js Целия файл

27
     createLocalStream: function (stream, type) {
27
     createLocalStream: function (stream, type) {
28
 
28
 
29
         var localStream =  new LocalStream(stream, type, eventEmitter);
29
         var localStream =  new LocalStream(stream, type, eventEmitter);
30
-        this.localStreams.push(localStream);
30
+        //in firefox we have only one stream object
31
+        if(this.localStreams.length == 0 ||
32
+            this.localStreams[0].getOriginalStream() != stream)
33
+            this.localStreams.push(localStream);
31
         if(type == "audio")
34
         if(type == "audio")
32
         {
35
         {
33
             this.localAudio = localStream;
36
             this.localAudio = localStream;
117
             return true;
120
             return true;
118
         }
121
         }
119
         return false;
122
         return false;
123
+    },
124
+    switchVideoStreams: function (new_stream) {
125
+        this.localVideo.stream = new_stream;
126
+
127
+        this.localStreams = [];
128
+
129
+        //in firefox we have only one stream object
130
+        if(this.localAudio.getOriginalStream() != new_stream)
131
+            this.localStreams.push(this.localAudio);
132
+        this.localStreams.push(this.localVideo);
120
     }
133
     }
121
 
134
 
122
 };
135
 };

+ 1
- 1
modules/UI/UI.js Целия файл

83
         if(jid === statistics.LOCAL_JID)
83
         if(jid === statistics.LOCAL_JID)
84
         {
84
         {
85
             resourceJid = AudioLevels.LOCAL_LEVEL;
85
             resourceJid = AudioLevels.LOCAL_LEVEL;
86
-            if(isAudioMuted())
86
+            if(RTC.localAudio.isMuted())
87
             {
87
             {
88
                 audioLevel = 0;
88
                 audioLevel = 0;
89
             }
89
             }

+ 0
- 4
modules/UI/videolayout/VideoLayout.js Целия файл

414
     };
414
     };
415
 
415
 
416
     my.changeLocalStream = function (stream) {
416
     my.changeLocalStream = function (stream) {
417
-        connection.jingle.localAudio = stream;
418
         VideoLayout.changeLocalVideo(stream, true);
417
         VideoLayout.changeLocalVideo(stream, true);
419
     };
418
     };
420
 
419
 
421
     my.changeLocalAudio = function(stream) {
420
     my.changeLocalAudio = function(stream) {
422
-        connection.jingle.localAudio = stream;
423
         RTC.attachMediaStream($('#localAudio'), stream);
421
         RTC.attachMediaStream($('#localAudio'), stream);
424
         document.getElementById('localAudio').autoplay = true;
422
         document.getElementById('localAudio').autoplay = true;
425
         document.getElementById('localAudio').volume = 0;
423
         document.getElementById('localAudio').volume = 0;
430
     };
428
     };
431
 
429
 
432
     my.changeLocalVideo = function(stream, flipX) {
430
     my.changeLocalVideo = function(stream, flipX) {
433
-        connection.jingle.localVideo = stream;
434
-
435
         var localVideo = document.createElement('video');
431
         var localVideo = document.createElement('video');
436
         localVideo.id = 'localVideo_' + RTC.getStreamID(stream);
432
         localVideo.id = 'localVideo_' + RTC.getStreamID(stream);
437
         localVideo.autoplay = true;
433
         localVideo.autoplay = true;

+ 1
- 1
modules/simulcast/SimulcastSender.js Целия файл

32
     return (this.displayedLocalVideoStream != null)
32
     return (this.displayedLocalVideoStream != null)
33
         ? this.displayedLocalVideoStream
33
         ? this.displayedLocalVideoStream
34
         // in case we have no simulcast at all, i.e. we didn't perform the GUM
34
         // in case we have no simulcast at all, i.e. we didn't perform the GUM
35
-        : connection.jingle.localVideo;
35
+        : RTC.localVideo.getOriginalStream();
36
 };
36
 };
37
 
37
 
38
 function NativeSimulcastSender() {
38
 function NativeSimulcastSender() {

Loading…
Отказ
Запис