Bladeren bron

Fixes mute participant functionality

j8
hristoterezov 9 jaren geleden
bovenliggende
commit
3168c86f77
4 gewijzigde bestanden met toevoegingen van 100 en 11 verwijderingen
  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 Bestand weergeven

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

+ 93
- 10
libs/lib-jitsi-meet.js Bestand weergeven

401
     this.room.kick(participant.getJid());
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
 JitsiConference.prototype.onMemberJoined = function (jid, email, nick) {
416
 JitsiConference.prototype.onMemberJoined = function (jid, email, nick) {
405
     var id = Strophe.getResourceFromJid(jid);
417
     var id = Strophe.getResourceFromJid(jid);
406
     if (id === 'focus' || this.myUserId() === id) {
418
     if (id === 'focus' || this.myUserId() === id) {
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
     conference.room.addListener(XMPPEvents.MUC_JOINED, function () {
681
     conference.room.addListener(XMPPEvents.MUC_JOINED, function () {
664
         conference.eventEmitter.emit(JitsiConferenceEvents.CONFERENCE_JOINED);
682
         conference.eventEmitter.emit(JitsiConferenceEvents.CONFERENCE_JOINED);
665
     });
683
     });
907
     /**
925
     /**
908
      * Indicates that phone number changed.
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
 module.exports = JitsiConferenceEvents;
931
 module.exports = JitsiConferenceEvents;
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
 RTC.prototype.removeLocalStream = function (stream) {
2240
 RTC.prototype.removeLocalStream = function (stream) {
2213
     for(var i = 0; i < this.localStreams.length; i++) {
2241
     for(var i = 0; i < this.localStreams.length; i++) {
2214
         if(this.localStreams[i].getOriginalStream() === stream) {
2242
         if(this.localStreams[i].getOriginalStream() === stream) {
6824
     return this.session.getIceConnectionState();
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
 module.exports = ChatRoom;
6895
 module.exports = ChatRoom;
6828
 
6896
 
6829
 }).call(this,"/modules/xmpp/ChatRoom.js")
6897
 }).call(this,"/modules/xmpp/ChatRoom.js")
11246
         init: function (conn) {
11314
         init: function (conn) {
11247
             this.connection = conn;
11315
             this.connection = conn;
11248
             // add handlers (just once)
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
         createRoom: function (jid, password, options) {
11328
         createRoom: function (jid, password, options) {
11255
             var roomJid = Strophe.getBareJidFromJid(jid);
11329
             var roomJid = Strophe.getBareJidFromJid(jid);
11320
                 return;
11394
                 return;
11321
 
11395
 
11322
             room.setJingleSession(session);
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
 }).call(this,"/modules/xmpp/strophe.emuc.js")
11411
 }).call(this,"/modules/xmpp/strophe.emuc.js")
11329
 },{"./ChatRoom":26,"jitsi-meet-logger":48}],37:[function(require,module,exports){
11412
 },{"./ChatRoom":26,"jitsi-meet-logger":48}],37:[function(require,module,exports){
11330
 (function (__filename){
11413
 (function (__filename){

+ 1
- 1
modules/UI/videolayout/RemoteVideo.js Bestand weergeven

91
                 event.preventDefault();
91
                 event.preventDefault();
92
             }
92
             }
93
             var isMute = !!self.isMuted;
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
             popupmenuElement.setAttribute('style', 'display:none;');
96
             popupmenuElement.setAttribute('style', 'display:none;');
97
 
97
 

+ 1
- 0
service/UI/UIEvents.js Bestand weergeven

28
     ROOM_LOCK_CLICKED: "UI.room_lock_clicked",
28
     ROOM_LOCK_CLICKED: "UI.room_lock_clicked",
29
     USER_INVITED: "UI.user_invited",
29
     USER_INVITED: "UI.user_invited",
30
     USER_KICKED: "UI.user_kicked",
30
     USER_KICKED: "UI.user_kicked",
31
+    REMOTE_AUDIO_MUTED: "UI.remote_audio_muted",
31
     FULLSCREEN_TOGGLE: "UI.fullscreen_toggle",
32
     FULLSCREEN_TOGGLE: "UI.fullscreen_toggle",
32
     AUTH_CLICKED: "UI.auth_clicked",
33
     AUTH_CLICKED: "UI.auth_clicked",
33
     TOGGLE_CHAT: "UI.toggle_chat",
34
     TOGGLE_CHAT: "UI.toggle_chat",

Laden…
Annuleren
Opslaan