浏览代码

Merge pull request #360 from saghul/set-lastn

feat(lastN): Add ability to dynamically change lasN
dev1
bgrozev 8 年前
父节点
当前提交
73dbf4fec8
共有 3 个文件被更改,包括 47 次插入0 次删除
  1. 18
    0
      JitsiConference.js
  2. 14
    0
      modules/RTC/DataChannels.js
  3. 15
    0
      modules/RTC/RTC.js

+ 18
- 0
JitsiConference.js 查看文件

@@ -659,6 +659,24 @@ JitsiConference.prototype.pinParticipant = function(participantId) {
659 659
     this.rtc.pinEndpoint(participantId);
660 660
 };
661 661
 
662
+/**
663
+ * Selects a new value for "lastN". The requested amount of videos are going
664
+ * to be delivered after the value is in effect. Set to -1 for unlimited or
665
+ * all available videos.
666
+ * @param lastN the new number of videos the user would like to receive.
667
+ * @throws Error or RangeError if the given value is not a number or is smaller
668
+ * than -1.
669
+ */
670
+JitsiConference.prototype.setLastN = function(lastN) {
671
+    if (!Number.isInteger(lastN) && !Number.parseInt(lastN)) {
672
+        throw new Error('Invalid value for lastN: ' + lastN);
673
+    }
674
+    if (lastN < -1) {
675
+        throw new RangeError('lastN cannot be smaller than -1');
676
+    }
677
+    this.rtc.setLastN(lastN | 0);
678
+};
679
+
662 680
 /**
663 681
  * @return Array<JitsiParticipant> an array of all participants in this
664 682
  * conference.

+ 14
- 0
modules/RTC/DataChannels.js 查看文件

@@ -283,4 +283,18 @@ DataChannels.prototype.sendDataChannelMessage = function (to, payload) {
283 283
     });
284 284
 };
285 285
 
286
+/**
287
+ * Sends a "lastN value changed" message via the data channel.
288
+ * @param value {int} The new value for lastN. -1 means unlimited.
289
+ */
290
+DataChannels.prototype.sendSetLastNMessage = function (value) {
291
+    const jsonObject = {
292
+        colibriClass : 'LastNChangedEvent',
293
+        lastN : value
294
+    };
295
+
296
+    this.send(jsonObject);
297
+    logger.log('Channel lastN set to: ' + value);
298
+};
299
+
286 300
 module.exports = DataChannels;

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

@@ -552,4 +552,19 @@ export default class RTC extends Listenable {
552 552
             throw new Error("Data channels support is disabled!");
553 553
         }
554 554
     }
555
+
556
+    /**
557
+     * Selects a new value for "lastN". The requested amount of videos are going
558
+     * to be delivered after the value is in effect. Set to -1 for unlimited or
559
+     * all available videos.
560
+     * @param value {int} the new value for lastN.
561
+     * @trows Error if there is no data channel created.
562
+     */
563
+    setLastN (value) {
564
+        if (this.dataChannels) {
565
+            this.dataChannels.sendSetLastNMessage(value);
566
+        } else {
567
+            throw new Error("Data channels support is disabled!");
568
+        }
569
+    }
555 570
 }

正在加载...
取消
保存