소스 검색

Fixes start muted implementation.

release-8443
hristoterezov 10 년 전
부모
커밋
3ecbed2347
6개의 변경된 파일949개의 추가작업 그리고 1300개의 파일을 삭제
  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 파일 보기

46
     this.authIdentity;
46
     this.authIdentity;
47
     this.startAudioMuted = false;
47
     this.startAudioMuted = false;
48
     this.startVideoMuted = false;
48
     this.startVideoMuted = false;
49
-    this.tracks = [];
49
+    this.startMutedPolicy = {audio: false, video: false};
50
 }
50
 }
51
 
51
 
52
 /**
52
 /**
253
 JitsiConference.prototype.addTrack = function (track) {
253
 JitsiConference.prototype.addTrack = function (track) {
254
     this.room.addStream(track.getOriginalStream(), function () {
254
     this.room.addStream(track.getOriginalStream(), function () {
255
         this.rtc.addLocalStream(track);
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
         if (track.startMuted) {
256
         if (track.startMuted) {
263
             track.mute();
257
             track.mute();
264
         }
258
         }
265
-        this.tracks.push(track);
266
         var muteHandler = this._fireMuteChangeEvent.bind(this, track);
259
         var muteHandler = this._fireMuteChangeEvent.bind(this, track);
267
         var stopHandler = this.removeTrack.bind(this, track);
260
         var stopHandler = this.removeTrack.bind(this, track);
268
         var audioLevelHandler = this._fireAudioLevelChangeEvent.bind(this);
261
         var audioLevelHandler = this._fireAudioLevelChangeEvent.bind(this);
304
  * @param track the JitsiLocalTrack object.
297
  * @param track the JitsiLocalTrack object.
305
  */
298
  */
306
 JitsiConference.prototype.removeTrack = function (track) {
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
     if(!this.room){
300
     if(!this.room){
312
         if(this.rtc)
301
         if(this.rtc)
313
             this.rtc.removeLocalStream(track);
302
             this.rtc.removeLocalStream(track);
670
 
659
 
671
 /**
660
 /**
672
  * Make all new participants mute their audio/video on join.
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
     if (!this.isModerator()) {
667
     if (!this.isModerator()) {
678
         return;
668
         return;
679
     }
669
     }
680
-
670
+    this.startMutedPolicy = policy;
681
     this.room.removeFromPresence("startmuted");
671
     this.room.removeFromPresence("startmuted");
682
     this.room.addToPresence("startmuted", {
672
     this.room.addToPresence("startmuted", {
683
         attributes: {
673
         attributes: {
684
-            audio: audioMuted,
685
-            video: videoMuted,
674
+            audio: policy.audio,
675
+            video: policy.video,
686
             xmlns: 'http://jitsi.org/jitmeet/start-muted'
676
             xmlns: 'http://jitsi.org/jitmeet/start-muted'
687
         }
677
         }
688
     });
678
     });
689
     this.room.sendPresence();
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
  * Check if audio is muted on join.
691
  * Check if audio is muted on join.
694
  */
692
  */
818
         conference.eventEmitter.emit(JitsiConferenceErrors.PASSWORD_REQUIRED);
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
     conference.room.addPresenceListener("startmuted", function (data, from) {
836
     conference.room.addPresenceListener("startmuted", function (data, from) {
846
         var isModerator = false;
837
         var isModerator = false;
847
         if (conference.myUserId() === from && conference.isModerator()) {
838
         if (conference.myUserId() === from && conference.isModerator()) {
862
 
853
 
863
         var updated = false;
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
             updated = true;
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
             updated = true;
863
             updated = true;
873
         }
864
         }
874
 
865
 
875
         if (updated) {
866
         if (updated) {
876
             conference.eventEmitter.emit(
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 파일 보기

90
         - USER_ROLE_CHANGED - notifies that role of some user changed. (parameters - id(string), role(string))
90
         - USER_ROLE_CHANGED - notifies that role of some user changed. (parameters - id(string), role(string))
91
         - CONFERENCE_FAILED - notifies that user failed to join the conference. (parameters - errorCode(JitsiMeetJS.errors.conference))
91
         - CONFERENCE_FAILED - notifies that user failed to join the conference. (parameters - errorCode(JitsiMeetJS.errors.conference))
92
         - KICKED - notifies that user has been kicked from the conference.
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
     2. connection
95
     2. connection
96
         - CONNECTION_FAILED - indicates that the server connection failed.
96
         - CONNECTION_FAILED - indicates that the server connection failed.
254
 24. kick(id) - Kick participant from the conference
254
 24. kick(id) - Kick participant from the conference
255
     - id - string participant id
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
     Note: available only for moderator
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
 JitsiTrack
273
 JitsiTrack
268
 ======
274
 ======

+ 882
- 1226
lib-jitsi-meet.js
파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
파일 보기


+ 12
- 13
lib-jitsi-meet.min.js
파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
파일 보기


+ 4
- 6
modules/RTC/RTC.js 파일 보기

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 파일 보기

225
         // if we're running on FF, transform to Plan B first.
225
         // if we're running on FF, transform to Plan B first.
226
         if (RTCBrowserType.usesUnifiedPlan()) {
226
         if (RTCBrowserType.usesUnifiedPlan()) {
227
             desc = this.interop.toPlanB(desc);
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
         return desc;
231
         return desc;
231
     },
232
     },

Loading…
취소
저장