瀏覽代碼

Fixes mute participant functionality

j8
hristoterezov 9 年之前
父節點
當前提交
3168c86f77
共有 4 個檔案被更改,包括 100 行新增11 行删除
  1. 5
    0
      app.js
  2. 93
    10
      libs/lib-jitsi-meet.js
  3. 1
    1
      modules/UI/videolayout/RemoteVideo.js
  4. 1
    0
      service/UI/UIEvents.js

+ 5
- 0
app.js 查看文件

@@ -505,6 +505,11 @@ function initConference(localTracks, connection) {
505 505
     APP.UI.addListener(UIEvents.USER_KICKED, function (id) {
506 506
         room.kickParticipant(id);
507 507
     });
508
+
509
+    APP.UI.addListener(UIEvents.REMOTE_AUDIO_MUTED, function (id) {
510
+        room.muteParticipant(id);
511
+    });
512
+
508 513
     room.on(ConferenceEvents.KICKED, function () {
509 514
         APP.UI.notifyKicked();
510 515
         // FIXME close

+ 93
- 10
libs/lib-jitsi-meet.js 查看文件

@@ -401,6 +401,18 @@ JitsiConference.prototype.kickParticipant = function (id) {
401 401
     this.room.kick(participant.getJid());
402 402
 };
403 403
 
404
+/**
405
+ * Kick participant from this conference.
406
+ * @param {string} id id of the participant to kick
407
+ */
408
+JitsiConference.prototype.muteParticipant = function (id) {
409
+    var participant = this.getParticipantById(id);
410
+    if (!participant) {
411
+        return;
412
+    }
413
+    this.room.muteParticipant(participant.getJid(), true);
414
+};
415
+
404 416
 JitsiConference.prototype.onMemberJoined = function (jid, email, nick) {
405 417
     var id = Strophe.getResourceFromJid(jid);
406 418
     if (id === 'focus' || this.myUserId() === id) {
@@ -660,6 +672,12 @@ function setupListeners(conference) {
660 672
         }
661 673
     );
662 674
 
675
+    conference.room.addListener(XMPPEvents.AUDIO_MUTED_BY_FOCUS,
676
+        function (value) {
677
+            conference.rtc.setAudioMute(value);
678
+        }
679
+    );
680
+
663 681
     conference.room.addListener(XMPPEvents.MUC_JOINED, function () {
664 682
         conference.eventEmitter.emit(JitsiConferenceEvents.CONFERENCE_JOINED);
665 683
     });
@@ -907,11 +925,7 @@ var JitsiConferenceEvents = {
907 925
     /**
908 926
      * Indicates that phone number changed.
909 927
      */
910
-    PHONE_NUMBER_CHANGED: "conference.phoneNumberChanged",
911
-    /**
912
-     * Indicates that recording status changed.
913
-     */
914
-    RECORDING_STATE_CHANGED: "conferenece.recordingStateChanged"
928
+    PHONE_NUMBER_CHANGED: "conference.phoneNumberChanged"
915 929
 };
916 930
 
917 931
 module.exports = JitsiConferenceEvents;
@@ -2209,6 +2223,20 @@ RTC.prototype.addLocalStream = function (stream) {
2209 2223
     }
2210 2224
 };
2211 2225
 
2226
+/**
2227
+ * Set mute for all local audio streams attached to the conference.
2228
+ * @param value the mute value
2229
+ */
2230
+RTC.prototype.setAudioMute = function (value) {
2231
+    for(var i = 0; i < this.localStreams.length; i++) {
2232
+        var stream = this.localStreams[i];
2233
+        if(stream.getType() !== "audio") {
2234
+            continue;
2235
+        }
2236
+        stream._setMute(value);
2237
+    }
2238
+}
2239
+
2212 2240
 RTC.prototype.removeLocalStream = function (stream) {
2213 2241
     for(var i = 0; i < this.localStreams.length; i++) {
2214 2242
         if(this.localStreams[i].getOriginalStream() === stream) {
@@ -6824,6 +6852,46 @@ ChatRoom.prototype.getConnectionState = function () {
6824 6852
     return this.session.getIceConnectionState();
6825 6853
 }
6826 6854
 
6855
+/**
6856
+ * Mutes remote participant.
6857
+ * @param jid of the participant
6858
+ * @param mute
6859
+ */
6860
+ChatRoom.prototype.muteParticipant = function (jid, mute) {
6861
+    logger.info("set mute", mute);
6862
+    var iqToFocus = $iq(
6863
+        {to: this.focusMucJid, type: 'set'})
6864
+        .c('mute', {
6865
+            xmlns: 'http://jitsi.org/jitmeet/audio',
6866
+            jid: jid
6867
+        })
6868
+        .t(mute.toString())
6869
+        .up();
6870
+
6871
+    this.connection.sendIQ(
6872
+        iqToFocus,
6873
+        function (result) {
6874
+            logger.log('set mute', result);
6875
+        },
6876
+        function (error) {
6877
+            logger.log('set mute error', error);
6878
+        });
6879
+}
6880
+
6881
+ChatRoom.prototype.onMute = function (iq) {
6882
+    var from = iq.getAttribute('from');
6883
+    if (from !== this.focusMucJid) {
6884
+        logger.warn("Ignored mute from non focus peer");
6885
+        return false;
6886
+    }
6887
+    var mute = $(iq).find('mute');
6888
+    if (mute.length) {
6889
+        var doMuteAudio = mute.text() === "true";
6890
+        this.eventEmitter.emit(XMPPEvents.AUDIO_MUTED_BY_FOCUS, doMuteAudio);
6891
+    }
6892
+    return true;
6893
+}
6894
+
6827 6895
 module.exports = ChatRoom;
6828 6896
 
6829 6897
 }).call(this,"/modules/xmpp/ChatRoom.js")
@@ -11246,10 +11314,16 @@ module.exports = function(XMPP) {
11246 11314
         init: function (conn) {
11247 11315
             this.connection = conn;
11248 11316
             // add handlers (just once)
11249
-            this.connection.addHandler(this.onPresence.bind(this), null, 'presence', null, null, null, null);
11250
-            this.connection.addHandler(this.onPresenceUnavailable.bind(this), null, 'presence', 'unavailable', null);
11251
-            this.connection.addHandler(this.onPresenceError.bind(this), null, 'presence', 'error', null);
11252
-            this.connection.addHandler(this.onMessage.bind(this), null, 'message', null, null);
11317
+            this.connection.addHandler(this.onPresence.bind(this), null,
11318
+                'presence', null, null, null, null);
11319
+            this.connection.addHandler(this.onPresenceUnavailable.bind(this),
11320
+                null, 'presence', 'unavailable', null);
11321
+            this.connection.addHandler(this.onPresenceError.bind(this), null,
11322
+                'presence', 'error', null);
11323
+            this.connection.addHandler(this.onMessage.bind(this), null,
11324
+                'message', null, null);
11325
+            this.connection.addHandler(this.onMute.bind(this),
11326
+                'http://jitsi.org/jitmeet/audio', 'iq', 'set',null,null);
11253 11327
         },
11254 11328
         createRoom: function (jid, password, options) {
11255 11329
             var roomJid = Strophe.getBareJidFromJid(jid);
@@ -11320,11 +11394,20 @@ module.exports = function(XMPP) {
11320 11394
                 return;
11321 11395
 
11322 11396
             room.setJingleSession(session);
11397
+        },
11398
+
11399
+        onMute: function(iq) {
11400
+            var from = iq.getAttribute('from');
11401
+            var room = this.rooms[Strophe.getBareJidFromJid(from)];
11402
+            if(!room)
11403
+                return;
11404
+
11405
+            room.onMute(iq);
11406
+            return true;
11323 11407
         }
11324 11408
     });
11325 11409
 };
11326 11410
 
11327
-
11328 11411
 }).call(this,"/modules/xmpp/strophe.emuc.js")
11329 11412
 },{"./ChatRoom":26,"jitsi-meet-logger":48}],37:[function(require,module,exports){
11330 11413
 (function (__filename){

+ 1
- 1
modules/UI/videolayout/RemoteVideo.js 查看文件

@@ -91,7 +91,7 @@ if (!interfaceConfig.filmStripOnly) {
91 91
                 event.preventDefault();
92 92
             }
93 93
             var isMute = !!self.isMuted;
94
-            self.emitter.emit(UIEvents.AUDIO_MUTED, !isMute);
94
+            self.emitter.emit(UIEvents.REMOTE_AUDIO_MUTED, self.id);
95 95
 
96 96
             popupmenuElement.setAttribute('style', 'display:none;');
97 97
 

+ 1
- 0
service/UI/UIEvents.js 查看文件

@@ -28,6 +28,7 @@ export default {
28 28
     ROOM_LOCK_CLICKED: "UI.room_lock_clicked",
29 29
     USER_INVITED: "UI.user_invited",
30 30
     USER_KICKED: "UI.user_kicked",
31
+    REMOTE_AUDIO_MUTED: "UI.remote_audio_muted",
31 32
     FULLSCREEN_TOGGLE: "UI.fullscreen_toggle",
32 33
     AUTH_CLICKED: "UI.auth_clicked",
33 34
     TOGGLE_CHAT: "UI.toggle_chat",

Loading…
取消
儲存