瀏覽代碼

added "start muted"

master
isymchych 9 年之前
父節點
當前提交
3a5780af08

+ 3
- 2
.gitattributes 查看文件

1
-*.bundle.js -text -diff
2
-.editorconfig
1
+lib-jitsi-meet.min.js -text -diff
2
+lib-jitsi-meet.js -text -diff
3
+lib-jitsi-meet.js.map -text -diff

+ 121
- 1
JitsiConference.js 查看文件

44
     this.somebodySupportsDTMF = false;
44
     this.somebodySupportsDTMF = false;
45
     this.authEnabled = false;
45
     this.authEnabled = false;
46
     this.authIdentity;
46
     this.authIdentity;
47
+    this.startAudioMuted = false;
48
+    this.startVideoMuted = false;
49
+    this.tracks = [];
47
 }
50
 }
48
 
51
 
49
 /**
52
 /**
250
 JitsiConference.prototype.addTrack = function (track) {
253
 JitsiConference.prototype.addTrack = function (track) {
251
     this.room.addStream(track.getOriginalStream(), function () {
254
     this.room.addStream(track.getOriginalStream(), function () {
252
         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) {
263
+            track.mute();
264
+        }
265
+        this.tracks.push(track);
253
         var muteHandler = this._fireMuteChangeEvent.bind(this, track);
266
         var muteHandler = this._fireMuteChangeEvent.bind(this, track);
254
         var stopHandler = this.removeTrack.bind(this, track);
267
         var stopHandler = this.removeTrack.bind(this, track);
255
         var audioLevelHandler = this._fireAudioLevelChangeEvent.bind(this);
268
         var audioLevelHandler = this._fireAudioLevelChangeEvent.bind(this);
291
  * @param track the JitsiLocalTrack object.
304
  * @param track the JitsiLocalTrack object.
292
  */
305
  */
293
 JitsiConference.prototype.removeTrack = function (track) {
306
 JitsiConference.prototype.removeTrack = function (track) {
307
+    var pos = this.tracks.indexOf(track);
308
+    if (pos > -1) {
309
+        this.tracks.splice(pos, 1);
310
+    }
294
     if(!this.room){
311
     if(!this.room){
295
         if(this.rtc)
312
         if(this.rtc)
296
             this.rtc.removeLocalStream(track);
313
             this.rtc.removeLocalStream(track);
411
     this.room.muteParticipant(participant.getJid(), true);
428
     this.room.muteParticipant(participant.getJid(), true);
412
 };
429
 };
413
 
430
 
414
-JitsiConference.prototype.onMemberJoined = function (jid, nick) {
431
+JitsiConference.prototype.onMemberJoined = function (jid, nick, role) {
415
     var id = Strophe.getResourceFromJid(jid);
432
     var id = Strophe.getResourceFromJid(jid);
416
     if (id === 'focus' || this.myUserId() === id) {
433
     if (id === 'focus' || this.myUserId() === id) {
417
        return;
434
        return;
418
     }
435
     }
419
     var participant = new JitsiParticipant(jid, this, nick);
436
     var participant = new JitsiParticipant(jid, this, nick);
437
+    participant._role = role;
420
     this.participants[id] = participant;
438
     this.participants[id] = participant;
421
     this.eventEmitter.emit(JitsiConferenceEvents.USER_JOINED, id, participant);
439
     this.eventEmitter.emit(JitsiConferenceEvents.USER_JOINED, id, participant);
422
     this.xmpp.connection.disco.info(
440
     this.xmpp.connection.disco.info(
650
     return null;
668
     return null;
651
 }
669
 }
652
 
670
 
671
+/**
672
+ * 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.
675
+ */
676
+JitsiConference.prototype.setStartMuted = function (audioMuted, videoMuted) {
677
+    if (!this.isModerator()) {
678
+        return;
679
+    }
680
+
681
+    this.room.removeFromPresence("startmuted");
682
+    this.room.addToPresence("startmuted", {
683
+        attributes: {
684
+            audio: audioMuted,
685
+            video: videoMuted,
686
+            xmlns: 'http://jitsi.org/jitmeet/start-muted'
687
+        }
688
+    });
689
+    this.room.sendPresence();
690
+};
691
+
692
+/**
693
+ * Check if audio is muted on join.
694
+ */
695
+JitsiConference.prototype.isStartAudioMuted = function () {
696
+    return this.startAudioMuted;
697
+};
698
+
699
+/**
700
+ * Check if video is muted on join.
701
+ */
702
+JitsiConference.prototype.isStartVideoMuted = function () {
703
+    return this.startVideoMuted;
704
+};
705
+
653
 /**
706
 /**
654
  * Setups the listeners needed for the conference.
707
  * Setups the listeners needed for the conference.
655
  * @param conference the conference
708
  * @param conference the conference
691
     conference.room.addListener(XMPPEvents.AUTHENTICATION_REQUIRED, function () {
744
     conference.room.addListener(XMPPEvents.AUTHENTICATION_REQUIRED, function () {
692
         conference.eventEmitter.emit(JitsiConferenceEvents.CONFERENCE_FAILED, JitsiConferenceErrors.AUTHENTICATION_REQUIRED);
745
         conference.eventEmitter.emit(JitsiConferenceEvents.CONFERENCE_FAILED, JitsiConferenceErrors.AUTHENTICATION_REQUIRED);
693
     });
746
     });
747
+    conference.room.addListener(XMPPEvents.BRIDGE_DOWN, function () {
748
+        conference.eventEmitter.emit(JitsiConferenceEvents.CONFERENCE_FAILED, JitsiConferenceErrors.VIDEOBRIDGE_NOT_AVAILABLE);
749
+    });
694
 //    FIXME
750
 //    FIXME
695
 //    conference.room.addListener(XMPPEvents.MUC_JOINED, function () {
751
 //    conference.room.addListener(XMPPEvents.MUC_JOINED, function () {
696
 //        conference.eventEmitter.emit(JitsiConferenceEvents.CONFERENCE_LEFT);
752
 //        conference.eventEmitter.emit(JitsiConferenceEvents.CONFERENCE_LEFT);
762
         conference.eventEmitter.emit(JitsiConferenceErrors.PASSWORD_REQUIRED);
818
         conference.eventEmitter.emit(JitsiConferenceErrors.PASSWORD_REQUIRED);
763
     });
819
     });
764
 
820
 
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
+            }
833
+        });
834
+
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) {
846
+        var isModerator = false;
847
+        if (conference.myUserId() === from && conference.isModerator()) {
848
+            isModerator = true;
849
+        } else {
850
+            var participant = conference.getParticipantById(from);
851
+            if (participant && participant.isModerator()) {
852
+                isModerator = true;
853
+            }
854
+        }
855
+
856
+        if (!isModerator) {
857
+            return;
858
+        }
859
+
860
+        var startAudioMuted = data.attributes.audio === 'true';
861
+        var startVideoMuted = data.attributes.video === 'true';
862
+
863
+        var updated = false;
864
+
865
+        if (startAudioMuted !== conference.startAudioMuted) {
866
+            conference.startAudioMuted = startAudioMuted;
867
+            updated = true;
868
+        }
869
+
870
+        if (startVideoMuted !== conference.startVideoMuted) {
871
+            conference.startVideoMuted = startVideoMuted;
872
+            updated = true;
873
+        }
874
+
875
+        if (updated) {
876
+            conference.eventEmitter.emit(
877
+                JitsiConferenceEvents.START_MUTED,
878
+                conference.startAudioMuted,
879
+                conference.startVideoMuted,
880
+                false
881
+            );
882
+        }
883
+    });
884
+
765
     if(conference.statistics) {
885
     if(conference.statistics) {
766
         //FIXME: Maybe remove event should not be associated with the conference.
886
         //FIXME: Maybe remove event should not be associated with the conference.
767
         conference.statistics.addAudioLevelListener(function (ssrc, level) {
887
         conference.statistics.addAudioLevelListener(function (ssrc, level) {

+ 4
- 0
JitsiConferenceEvents.js 查看文件

84
      * You are kicked from the conference.
84
      * You are kicked from the conference.
85
      */
85
      */
86
     KICKED: "conferenece.kicked",
86
     KICKED: "conferenece.kicked",
87
+    /**
88
+     * Indicates that start muted settings changed.
89
+     */
90
+    START_MUTED: "conference.start_muted",
87
     /**
91
     /**
88
      * Indicates that DTMF support changed.
92
      * Indicates that DTMF support changed.
89
      */
93
      */

+ 11
- 0
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
 
94
 
94
     2. connection
95
     2. connection
95
         - CONNECTION_FAILED - indicates that the server connection failed.
96
         - CONNECTION_FAILED - indicates that the server connection failed.
253
 24. kick(id) - Kick participant from the conference
254
 24. kick(id) - Kick participant from the conference
254
     - id - string participant id
255
     - id - string participant id
255
 
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
260
+
261
+    Note: available only for moderator
262
+
263
+26. isStartAudioMuted() - check if audio is muted on join
264
+
265
+27. isStartVideoMuted() - check if video is muted on join
266
+
256
 JitsiTrack
267
 JitsiTrack
257
 ======
268
 ======
258
 The object represents single track - video or audio. They can be remote tracks ( from the other participants in the call) or local tracks (from the devices of the local participant).
269
 The object represents single track - video or audio. They can be remote tracks ( from the other participants in the call) or local tracks (from the devices of the local participant).

+ 1206
- 755
lib-jitsi-meet.js
文件差異過大導致無法顯示
查看文件


+ 13
- 12
lib-jitsi-meet.min.js
文件差異過大導致無法顯示
查看文件


+ 3
- 0
modules/RTC/JitsiLocalTrack.js 查看文件

33
  * @param mute {boolean} if true the track will be muted. Otherwise the track will be unmuted.
33
  * @param mute {boolean} if true the track will be muted. Otherwise the track will be unmuted.
34
  */
34
  */
35
 JitsiLocalTrack.prototype._setMute = function (mute) {
35
 JitsiLocalTrack.prototype._setMute = function (mute) {
36
+    if (this.isMuted() === mute) {
37
+        return;
38
+    }
36
     if(!this.rtc) {
39
     if(!this.rtc) {
37
         this.startMuted = mute;
40
         this.startMuted = mute;
38
         return;
41
         return;

+ 1
- 1
modules/xmpp/ChatRoom.js 查看文件

262
         }
262
         }
263
         else {
263
         else {
264
             this.eventEmitter.emit(
264
             this.eventEmitter.emit(
265
-                XMPPEvents.MUC_MEMBER_JOINED, from, member.nick);
265
+                XMPPEvents.MUC_MEMBER_JOINED, from, member.nick, member.role);
266
         }
266
         }
267
     } else {
267
     } else {
268
         // Presence update for existing participant
268
         // Presence update for existing participant

+ 0
- 5
service/desktopsharing/DesktopSharingEventTypes.js 查看文件

1
 var DesktopSharingEventTypes = {
1
 var DesktopSharingEventTypes = {
2
-    INIT: "ds.init",
3
-
4
-    SWITCHING_DONE: "ds.switching_done",
5
-
6
-    NEW_STREAM_CREATED: "ds.new_stream_created",
7
     /**
2
     /**
8
      * An event which indicates that the jidesha extension for Firefox is
3
      * An event which indicates that the jidesha extension for Firefox is
9
      * needed to proceed with screen sharing, and that it is not installed.
4
      * needed to proceed with screen sharing, and that it is not installed.

+ 0
- 3
service/xmpp/XMPPEvents.js 查看文件

59
     // Designates an event indicating that the focus has asked us to mute our
59
     // Designates an event indicating that the focus has asked us to mute our
60
     // audio.
60
     // audio.
61
     AUDIO_MUTED_BY_FOCUS: "xmpp.audio_muted_by_focus",
61
     AUDIO_MUTED_BY_FOCUS: "xmpp.audio_muted_by_focus",
62
-    // Designates an event indicating that a moderator in the room changed the
63
-    // "start muted" settings for the conference.
64
-    START_MUTED_SETTING_CHANGED: "xmpp.start_muted_setting_changed",
65
     // Designates an event indicating that we should join the conference with
62
     // Designates an event indicating that we should join the conference with
66
     // audio and/or video muted.
63
     // audio and/or video muted.
67
     START_MUTED_FROM_FOCUS: "xmpp.start_muted_from_focus",
64
     START_MUTED_FROM_FOCUS: "xmpp.start_muted_from_focus",

Loading…
取消
儲存