Przeglądaj źródła

Fixes start muted implementation.

release-8443
hristoterezov 10 lat temu
rodzic
commit
3ecbed2347
6 zmienionych plików z 949 dodań i 1300 usunięć
  1. 37
    48
      JitsiConference.js
  2. 12
    6
      doc/API.md
  3. 882
    1226
      lib-jitsi-meet.js
  4. 12
    13
      lib-jitsi-meet.min.js
  5. 4
    6
      modules/RTC/RTC.js
  6. 2
    1
      modules/xmpp/TraceablePeerConnection.js

+ 37
- 48
JitsiConference.js Wyświetl plik

@@ -46,7 +46,7 @@ function JitsiConference(options) {
46 46
     this.authIdentity;
47 47
     this.startAudioMuted = false;
48 48
     this.startVideoMuted = false;
49
-    this.tracks = [];
49
+    this.startMutedPolicy = {audio: false, video: false};
50 50
 }
51 51
 
52 52
 /**
@@ -253,16 +253,9 @@ JitsiConference.prototype.setDisplayName = function(name) {
253 253
 JitsiConference.prototype.addTrack = function (track) {
254 254
     this.room.addStream(track.getOriginalStream(), function () {
255 255
         this.rtc.addLocalStream(track);
256
-        if (this.startAudioMuted && track.isAudioTrack()) {
257
-            track.mute();
258
-        }
259
-        if (this.startVideoMuted && track.isVideoTrack()) {
260
-            track.mute();
261
-        }
262 256
         if (track.startMuted) {
263 257
             track.mute();
264 258
         }
265
-        this.tracks.push(track);
266 259
         var muteHandler = this._fireMuteChangeEvent.bind(this, track);
267 260
         var stopHandler = this.removeTrack.bind(this, track);
268 261
         var audioLevelHandler = this._fireAudioLevelChangeEvent.bind(this);
@@ -304,10 +297,6 @@ JitsiConference.prototype._fireMuteChangeEvent = function (track) {
304 297
  * @param track the JitsiLocalTrack object.
305 298
  */
306 299
 JitsiConference.prototype.removeTrack = function (track) {
307
-    var pos = this.tracks.indexOf(track);
308
-    if (pos > -1) {
309
-        this.tracks.splice(pos, 1);
310
-    }
311 300
     if(!this.room){
312 301
         if(this.rtc)
313 302
             this.rtc.removeLocalStream(track);
@@ -670,25 +659,34 @@ JitsiConference.prototype.getConnectionState = function () {
670 659
 
671 660
 /**
672 661
  * Make all new participants mute their audio/video on join.
673
- * @param {boolean} audioMuted if audio should be muted.
674
- * @param {boolean} videoMuted if video should be muted.
662
+ * @param policy {Object} object with 2 boolean properties for video and audio:
663
+ * @param {boolean} audio if audio should be muted.
664
+ * @param {boolean} video if video should be muted.
675 665
  */
676
-JitsiConference.prototype.setStartMuted = function (audioMuted, videoMuted) {
666
+JitsiConference.prototype.setStartMutedPolicy = function (policy) {
677 667
     if (!this.isModerator()) {
678 668
         return;
679 669
     }
680
-
670
+    this.startMutedPolicy = policy;
681 671
     this.room.removeFromPresence("startmuted");
682 672
     this.room.addToPresence("startmuted", {
683 673
         attributes: {
684
-            audio: audioMuted,
685
-            video: videoMuted,
674
+            audio: policy.audio,
675
+            video: policy.video,
686 676
             xmlns: 'http://jitsi.org/jitmeet/start-muted'
687 677
         }
688 678
     });
689 679
     this.room.sendPresence();
690 680
 };
691 681
 
682
+/**
683
+ * Returns current start muted policy
684
+ * @returns {Object} with 2 proprties - audio and video.
685
+ */
686
+JitsiConference.prototype.getStartMutedPolicy = function () {
687
+    return this.startMutedPolicy;
688
+};
689
+
692 690
 /**
693 691
  * Check if audio is muted on join.
694 692
  */
@@ -818,30 +816,23 @@ function setupListeners(conference) {
818 816
         conference.eventEmitter.emit(JitsiConferenceErrors.PASSWORD_REQUIRED);
819 817
     });
820 818
 
821
-    conference.xmpp.addListener(XMPPEvents.START_MUTED_FROM_FOCUS, function (audioMuted, videoMuted) {
822
-        conference.startAudioMuted = audioMuted;
823
-        conference.startVideoMuted = videoMuted;
824
-
825
-        // mute existing local tracks because this is initial mute from Jicofo
826
-        conference.tracks.forEach(function (track) {
827
-            if (conference.startAudioMuted && track.isAudioTrack()) {
828
-                track.mute();
829
-            }
830
-            if (conference.startVideoMuted && track.isVideoTrack()) {
831
-                track.mute();
832
-            }
819
+    conference.xmpp.addListener(XMPPEvents.START_MUTED_FROM_FOCUS,
820
+        function (audioMuted, videoMuted) {
821
+            conference.startAudioMuted = audioMuted;
822
+            conference.startVideoMuted = videoMuted;
823
+
824
+            // mute existing local tracks because this is initial mute from
825
+            // Jicofo
826
+            conference.getLocalTracks().forEach(function (track) {
827
+                if (conference.startAudioMuted && track.isAudioTrack()) {
828
+                    track.mute();
829
+                }
830
+                if (conference.startVideoMuted && track.isVideoTrack()) {
831
+                    track.mute();
832
+                }
833
+            });
833 834
         });
834 835
 
835
-        var initiallyMuted = audioMuted || videoMuted;
836
-
837
-        conference.eventEmitter.emit(
838
-            JitsiConferenceEvents.START_MUTED,
839
-            conference.startAudioMuted,
840
-            conference.startVideoMuted,
841
-            initiallyMuted
842
-        );
843
-    });
844
-
845 836
     conference.room.addPresenceListener("startmuted", function (data, from) {
846 837
         var isModerator = false;
847 838
         if (conference.myUserId() === from && conference.isModerator()) {
@@ -862,22 +853,20 @@ function setupListeners(conference) {
862 853
 
863 854
         var updated = false;
864 855
 
865
-        if (startAudioMuted !== conference.startAudioMuted) {
866
-            conference.startAudioMuted = startAudioMuted;
856
+        if (startAudioMuted !== conference.startMutedPolicy.audio) {
857
+            conference.startMutedPolicy.audio = startAudioMuted;
867 858
             updated = true;
868 859
         }
869 860
 
870
-        if (startVideoMuted !== conference.startVideoMuted) {
871
-            conference.startVideoMuted = startVideoMuted;
861
+        if (startVideoMuted !== conference.startMutedPolicy.video) {
862
+            conference.startMutedPolicy.video = startVideoMuted;
872 863
             updated = true;
873 864
         }
874 865
 
875 866
         if (updated) {
876 867
             conference.eventEmitter.emit(
877
-                JitsiConferenceEvents.START_MUTED,
878
-                conference.startAudioMuted,
879
-                conference.startVideoMuted,
880
-                false
868
+                JitsiConferenceEvents.START_MUTED_POLICY_CHANGED,
869
+                conference.startMutedPolicy
881 870
             );
882 871
         }
883 872
     });

+ 12
- 6
doc/API.md Wyświetl plik

@@ -90,7 +90,7 @@ JitsiMeetJS.setLogLevel(JitsiMeetJS.logLevels.ERROR);
90 90
         - USER_ROLE_CHANGED - notifies that role of some user changed. (parameters - id(string), role(string))
91 91
         - CONFERENCE_FAILED - notifies that user failed to join the conference. (parameters - errorCode(JitsiMeetJS.errors.conference))
92 92
         - KICKED - notifies that user has been kicked from the conference.
93
-        - START_MUTED - notifies that all new participants will join with muted audio/video stream (parameters - audioMuted(boolean), videoMuted(boolean))
93
+        - START_MUTED_POLICY_CHANGED - notifies that all new participants will join with muted audio/video stream (parameters - JS object with 2 properties - audio(boolean), video(boolean))
94 94
 
95 95
     2. connection
96 96
         - CONNECTION_FAILED - indicates that the server connection failed.
@@ -254,15 +254,21 @@ The object represents a conference. We have the following methods to control the
254 254
 24. kick(id) - Kick participant from the conference
255 255
     - id - string participant id
256 256
 
257
-25. setStartMuted(audioMuted, videoMuted) - make all new participants join with muted audio/video
258
-    - audioMuted - boolean if audio stream should be muted
259
-    - videoMuted - boolean if video stream should be muted
257
+25. setStartMutedPolicy(policy) - make all new participants join with muted audio/video
258
+    - policy - JS object with following properties
259
+        - audio - boolean if audio stream should be muted
260
+        - video - boolean if video stream should be muted
260 261
 
261 262
     Note: available only for moderator
262 263
 
263
-26. isStartAudioMuted() - check if audio is muted on join
264
+26. getStartMutedPolicy() - returns the current policy with JS object:
265
+    - policy - JS object with following properties
266
+        - audio - boolean if audio stream should be muted
267
+        - video - boolean if video stream should be muted
264 268
 
265
-27. isStartVideoMuted() - check if video is muted on join
269
+27. isStartAudioMuted() - check if audio is muted on join
270
+
271
+28. isStartVideoMuted() - check if video is muted on join
266 272
 
267 273
 JitsiTrack
268 274
 ======

+ 882
- 1226
lib-jitsi-meet.js
Plik diff jest za duży
Wyświetl plik


+ 12
- 13
lib-jitsi-meet.min.js
Plik diff jest za duży
Wyświetl plik


+ 4
- 6
modules/RTC/RTC.js Wyświetl plik

@@ -136,12 +136,10 @@ RTC.prototype.setAudioMute = function (value) {
136 136
     }
137 137
 }
138 138
 
139
-RTC.prototype.removeLocalStream = function (stream) {
140
-    for(var i = 0; i < this.localStreams.length; i++) {
141
-        if(this.localStreams[i].getOriginalStream() === stream) {
142
-            delete this.localStreams[i];
143
-            return;
144
-        }
139
+RTC.prototype.removeLocalStream = function (track) {
140
+    var pos = this.localStreams.indexOf(track);
141
+    if (pos > -1) {
142
+        this.localStreams.splice(pos, 1);
145 143
     }
146 144
 };
147 145
 

+ 2
- 1
modules/xmpp/TraceablePeerConnection.js Wyświetl plik

@@ -225,7 +225,8 @@ var getters = {
225 225
         // if we're running on FF, transform to Plan B first.
226 226
         if (RTCBrowserType.usesUnifiedPlan()) {
227 227
             desc = this.interop.toPlanB(desc);
228
-            this.trace('getLocalDescription::postTransform (Plan B)', dumpSDP(desc));
228
+            this.trace('getLocalDescription::postTransform (Plan B)',
229
+                dumpSDP(desc));
229 230
         }
230 231
         return desc;
231 232
     },

Ładowanie…
Anuluj
Zapisz