Browse Source

feat(conference) Implement audio/video mute disable when sender limit is reached.

Jicofo sends a presence when the audio/video sender limit is reaced in the conference. The client can then proceed to disable the audio and video mute buttons when this occurs.
dev1
Jaya Allamsetty 3 years ago
parent
commit
b9ac97438f
3 changed files with 49 additions and 7 deletions
  1. 30
    3
      JitsiConference.js
  2. 12
    0
      JitsiConferenceEvents.js
  3. 7
    4
      modules/xmpp/ChatRoom.js

+ 30
- 3
JitsiConference.js View File

@@ -285,6 +285,20 @@ export default function JitsiConference(options) {
285 285
 
286 286
         this._e2eEncryption = new E2EEncryption(this);
287 287
     }
288
+
289
+    /**
290
+     * Flag set to <tt>true</tt> when Jicofo sends a presence message indicating that the max audio sender limit has
291
+     * been reached for the call. Once this is set, unmuting audio will be disabled from the client until it gets reset
292
+     * again by Jicofo.
293
+     */
294
+    this._audioSenderLimitReached = undefined;
295
+
296
+    /**
297
+     * Flag set to <tt>true</tt> when Jicofo sends a presence message indicating that the max video sender limit has
298
+     * been reached for the call. Once this is set, unmuting video will be disabled from the client until it gets reset
299
+     * again by Jicofo.
300
+     */
301
+    this._videoSenderLimitReached = undefined;
288 302
 }
289 303
 
290 304
 // FIXME convert JitsiConference to ES6 - ASAP !
@@ -3151,9 +3165,22 @@ JitsiConference.prototype._updateProperties = function(properties = {}) {
3151 3165
 
3152 3166
     this.properties = properties;
3153 3167
     if (changed) {
3154
-        this.eventEmitter.emit(
3155
-            JitsiConferenceEvents.PROPERTIES_CHANGED,
3156
-            this.properties);
3168
+        this.eventEmitter.emit(JitsiConferenceEvents.PROPERTIES_CHANGED, this.properties);
3169
+
3170
+        const audioLimitReached = this.properties['audio-limit-reached'] === 'true';
3171
+        const videoLimitReached = this.properties['video-limit-reached'] === 'true';
3172
+
3173
+        if (this._audioSenderLimitReached !== audioLimitReached) {
3174
+            this._audioSenderLimitReached = audioLimitReached;
3175
+            this.eventEmitter.emit(JitsiConferenceEvents.AUDIO_UNMUTE_PERMISSIONS_CHANGED, audioLimitReached);
3176
+            logger.info(`Audio unmute permissions set by Jicofo to ${audioLimitReached}`);
3177
+        }
3178
+
3179
+        if (this._videoSenderLimitReached !== videoLimitReached) {
3180
+            this._videoSenderLimitReached = videoLimitReached;
3181
+            this.eventEmitter.emit(JitsiConferenceEvents.VIDEO_UNMUTE_PERMISSIONS_CHANGED, videoLimitReached);
3182
+            logger.info(`Video unmute permissions set by Jicofo to ${videoLimitReached}`);
3183
+        }
3157 3184
 
3158 3185
         // Some of the properties need to be added to analytics events.
3159 3186
         const analyticsKeys = [

+ 12
- 0
JitsiConferenceEvents.js View File

@@ -8,6 +8,12 @@
8 8
  */
9 9
 export const AUDIO_INPUT_STATE_CHANGE = 'conference.audio_input_state_changed';
10 10
 
11
+/**
12
+ * Event indicates that the permission for unmuting audio has changed based on the number of audio senders in the call
13
+ * and the audio sender limit configured in Jicofo.
14
+ */
15
+export const AUDIO_UNMUTE_PERMISSIONS_CHANGED = 'conference.audio_unmute_permissions_changed';
16
+
11 17
 /**
12 18
  * Indicates that authentication status changed.
13 19
  */
@@ -362,6 +368,12 @@ export const USER_ROLE_CHANGED = 'conference.roleChanged';
362 368
  */
363 369
 export const USER_STATUS_CHANGED = 'conference.statusChanged';
364 370
 
371
+/**
372
+ * Event indicates that the permission for unmuting video has changed based on the number of video senders in the call
373
+ * and the video sender limit configured in Jicofo.
374
+ */
375
+export const VIDEO_UNMUTE_PERMISSIONS_CHANGED = 'conference.video_unmute_permissions_changed';
376
+
365 377
 /**
366 378
  * Event indicates that the bot participant type changed.
367 379
  */

+ 7
- 4
modules/xmpp/ChatRoom.js View File

@@ -741,11 +741,14 @@ export default class ChatRoom extends Listenable {
741 741
                         }
742 742
                     }
743 743
 
744
-                    this.eventEmitter.emit(
745
-                        XMPPEvents.CONFERENCE_PROPERTIES_CHANGED, properties);
744
+                    this.eventEmitter.emit(XMPPEvents.CONFERENCE_PROPERTIES_CHANGED, properties);
746 745
 
747
-                    this.restartByTerminateSupported = properties['support-terminate-restart'] === 'true';
748
-                    logger.info(`Jicofo supports restart by terminate: ${this.supportsRestartByTerminate()}`);
746
+                    // Log if Jicofo supports restart by terminate only once. This conference property does not change
747
+                    // during the call.
748
+                    if (typeof this.restartByTerminateSupported === 'undefined') {
749
+                        this.restartByTerminateSupported = properties['support-terminate-restart'] === 'true';
750
+                        logger.info(`Jicofo supports restart by terminate: ${this.supportsRestartByTerminate()}`);
751
+                    }
749 752
                 }
750 753
                 break;
751 754
             case 'transcription-status': {

Loading…
Cancel
Save