瀏覽代碼

added "start muted"

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

+ 3
- 2
.gitattributes 查看文件

@@ -1,2 +1,3 @@
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,6 +44,9 @@ function JitsiConference(options) {
44 44
     this.somebodySupportsDTMF = false;
45 45
     this.authEnabled = false;
46 46
     this.authIdentity;
47
+    this.startAudioMuted = false;
48
+    this.startVideoMuted = false;
49
+    this.tracks = [];
47 50
 }
48 51
 
49 52
 /**
@@ -250,6 +253,16 @@ JitsiConference.prototype.setDisplayName = function(name) {
250 253
 JitsiConference.prototype.addTrack = function (track) {
251 254
     this.room.addStream(track.getOriginalStream(), function () {
252 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 266
         var muteHandler = this._fireMuteChangeEvent.bind(this, track);
254 267
         var stopHandler = this.removeTrack.bind(this, track);
255 268
         var audioLevelHandler = this._fireAudioLevelChangeEvent.bind(this);
@@ -291,6 +304,10 @@ JitsiConference.prototype._fireMuteChangeEvent = function (track) {
291 304
  * @param track the JitsiLocalTrack object.
292 305
  */
293 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 311
     if(!this.room){
295 312
         if(this.rtc)
296 313
             this.rtc.removeLocalStream(track);
@@ -411,12 +428,13 @@ JitsiConference.prototype.muteParticipant = function (id) {
411 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 432
     var id = Strophe.getResourceFromJid(jid);
416 433
     if (id === 'focus' || this.myUserId() === id) {
417 434
        return;
418 435
     }
419 436
     var participant = new JitsiParticipant(jid, this, nick);
437
+    participant._role = role;
420 438
     this.participants[id] = participant;
421 439
     this.eventEmitter.emit(JitsiConferenceEvents.USER_JOINED, id, participant);
422 440
     this.xmpp.connection.disco.info(
@@ -650,6 +668,41 @@ JitsiConference.prototype.getConnectionState = function () {
650 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 707
  * Setups the listeners needed for the conference.
655 708
  * @param conference the conference
@@ -691,6 +744,9 @@ function setupListeners(conference) {
691 744
     conference.room.addListener(XMPPEvents.AUTHENTICATION_REQUIRED, function () {
692 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 750
 //    FIXME
695 751
 //    conference.room.addListener(XMPPEvents.MUC_JOINED, function () {
696 752
 //        conference.eventEmitter.emit(JitsiConferenceEvents.CONFERENCE_LEFT);
@@ -762,6 +818,70 @@ function setupListeners(conference) {
762 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 885
     if(conference.statistics) {
766 886
         //FIXME: Maybe remove event should not be associated with the conference.
767 887
         conference.statistics.addAudioLevelListener(function (ssrc, level) {

+ 4
- 0
JitsiConferenceEvents.js 查看文件

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

+ 11
- 0
doc/API.md 查看文件

@@ -90,6 +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 94
 
94 95
     2. connection
95 96
         - CONNECTION_FAILED - indicates that the server connection failed.
@@ -253,6 +254,16 @@ The object represents a conference. We have the following methods to control the
253 254
 24. kick(id) - Kick participant from the conference
254 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 267
 JitsiTrack
257 268
 ======
258 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,6 +33,9 @@ JitsiLocalTrack.prototype.constructor = JitsiLocalTrack;
33 33
  * @param mute {boolean} if true the track will be muted. Otherwise the track will be unmuted.
34 34
  */
35 35
 JitsiLocalTrack.prototype._setMute = function (mute) {
36
+    if (this.isMuted() === mute) {
37
+        return;
38
+    }
36 39
     if(!this.rtc) {
37 40
         this.startMuted = mute;
38 41
         return;

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

@@ -262,7 +262,7 @@ ChatRoom.prototype.onPresence = function (pres) {
262 262
         }
263 263
         else {
264 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 267
     } else {
268 268
         // Presence update for existing participant

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

@@ -1,9 +1,4 @@
1 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 3
      * An event which indicates that the jidesha extension for Firefox is
9 4
      * needed to proceed with screen sharing, and that it is not installed.

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

@@ -59,9 +59,6 @@ var XMPPEvents = {
59 59
     // Designates an event indicating that the focus has asked us to mute our
60 60
     // audio.
61 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 62
     // Designates an event indicating that we should join the conference with
66 63
     // audio and/or video muted.
67 64
     START_MUTED_FROM_FOCUS: "xmpp.start_muted_from_focus",

Loading…
取消
儲存