Преглед на файлове

feat: SourceVideoTypeMessage message

Sends the source name to video type mapping to the jvb
in a new bridge channel message.
tags/v0.0.2
Pawel Domas преди 4 години
родител
ревизия
a65e79b841
променени са 3 файла, в които са добавени 67 реда и са изтрити 6 реда
  1. 26
    1
      JitsiConference.js
  2. 17
    0
      modules/RTC/BridgeChannel.js
  3. 24
    5
      modules/RTC/RTC.js

+ 26
- 1
JitsiConference.js Целия файл

@@ -55,6 +55,7 @@ import {
55 55
 import BridgeVideoType from './service/RTC/BridgeVideoType';
56 56
 import CodecMimeType from './service/RTC/CodecMimeType';
57 57
 import * as MediaType from './service/RTC/MediaType';
58
+import RTCEvents from './service/RTC/RTCEvents';
58 59
 import { getSourceNameForJitsiTrack } from './service/RTC/SignalingLayer';
59 60
 import VideoType from './service/RTC/VideoType';
60 61
 import {
@@ -400,6 +401,9 @@ JitsiConference.prototype._init = function(options = {}) {
400 401
     if (!this.rtc) {
401 402
         this.rtc = new RTC(this, options);
402 403
         this.eventManager.setupRTCListeners();
404
+        if (FeatureFlags.isSourceNameSignalingEnabled()) {
405
+            this._registerRtcListeners(this.rtc);
406
+        }
403 407
     }
404 408
 
405 409
     this.receiveVideoController = new ReceiveVideoController(this, this.rtc);
@@ -718,6 +722,20 @@ JitsiConference.prototype._getMediaSessions = function() {
718 722
     return sessions;
719 723
 };
720 724
 
725
+/**
726
+ * Registers event listeners on the RTC instance.
727
+ * @param {RTC} rtc - the RTC module instance used by this conference.
728
+ * @private
729
+ * @returns {void}
730
+ */
731
+JitsiConference.prototype._registerRtcListeners = function(rtc) {
732
+    rtc.addListener(RTCEvents.DATA_CHANNEL_OPEN, () => {
733
+        for (const localTrack of this.rtc.localTracks) {
734
+            localTrack.isVideoTrack() && this._sendBridgeVideoTypeMessage(localTrack);
735
+        }
736
+    });
737
+};
738
+
721 739
 /**
722 740
  * Sends the 'VideoTypeMessage' to the bridge on the bridge channel so that the bridge can make bitrate allocation
723 741
  * decisions based on the video type of the local source.
@@ -733,7 +751,14 @@ JitsiConference.prototype._sendBridgeVideoTypeMessage = function(localtrack) {
733 751
         videoType = BridgeVideoType.DESKTOP_HIGH_FPS;
734 752
     }
735 753
 
736
-    this.rtc.setVideoType(videoType);
754
+    if (FeatureFlags.isSourceNameSignalingEnabled()) {
755
+        this.rtc.sendSourceVideoType(
756
+            getSourceNameForJitsiTrack(this.myUserId(), MediaType.VIDEO, 0),
757
+            videoType
758
+        );
759
+    } else {
760
+        this.rtc.setVideoType(videoType);
761
+    }
737 762
 };
738 763
 
739 764
 /**

+ 17
- 0
modules/RTC/BridgeChannel.js Целия файл

@@ -263,6 +263,7 @@ export default class BridgeChannel {
263 263
      * Sends a 'VideoTypeMessage' message via the bridge channel.
264 264
      *
265 265
      * @param {string} videoType 'camera', 'desktop' or 'none'.
266
+     * @deprecated to be replaced with sendSourceVideoTypeMessage
266 267
      */
267 268
     sendVideoTypeMessage(videoType) {
268 269
         logger.debug(`Sending VideoTypeMessage with video type as ${videoType}`);
@@ -272,6 +273,22 @@ export default class BridgeChannel {
272 273
         });
273 274
     }
274 275
 
276
+    /**
277
+     * Sends a 'VideoTypeMessage' message via the bridge channel.
278
+     *
279
+     * @param {BridgeVideoType} videoType - the video type.
280
+     * @param {SourceName} sourceName - the source name of the video track.
281
+     * @returns {void}
282
+     */
283
+    sendSourceVideoTypeMessage(sourceName, videoType) {
284
+        logger.info(`Sending SourceVideoTypeMessage with video type ${sourceName}: ${videoType}`);
285
+        this._send({
286
+            colibriClass: 'SourceVideoTypeMessage',
287
+            sourceName,
288
+            videoType
289
+        });
290
+    }
291
+
275 292
     /**
276 293
      * Set events on the given RTCDataChannel or WebSocket instance.
277 294
      */

+ 24
- 5
modules/RTC/RTC.js Целия файл

@@ -5,6 +5,7 @@ import BridgeVideoType from '../../service/RTC/BridgeVideoType';
5 5
 import * as MediaType from '../../service/RTC/MediaType';
6 6
 import RTCEvents from '../../service/RTC/RTCEvents';
7 7
 import browser from '../browser';
8
+import FeatureFlags from '../flags/FeatureFlags';
8 9
 import Statistics from '../statistics/statistics';
9 10
 import GlobalOnErrorHandler from '../util/GlobalOnErrorHandler';
10 11
 import Listenable from '../util/Listenable';
@@ -149,7 +150,12 @@ export default class RTC extends Listenable {
149 150
         this._updateAudioOutputForAudioTracks
150 151
             = this._updateAudioOutputForAudioTracks.bind(this);
151 152
 
152
-        // The default video type assumed by the bridge.
153
+        /**
154
+         * The default video type assumed by the bridge.
155
+         * @deprecated this will go away with multiple streams support
156
+         * @type {BridgeVideoType}
157
+         * @private
158
+         */
153 159
         this._videoType = BridgeVideoType.NONE;
154 160
 
155 161
         // Switch audio output device on all remote audio tracks. Local audio
@@ -256,10 +262,12 @@ export default class RTC extends Listenable {
256 262
                     logError(error, 'LastNChangedEvent', this._lastN);
257 263
                 }
258 264
             }
259
-            try {
260
-                this._channel.sendVideoTypeMessage(this._videoType);
261
-            } catch (error) {
262
-                logError(error, 'VideoTypeMessage', this._videoType);
265
+            if (!FeatureFlags.isSourceNameSignalingEnabled()) {
266
+                try {
267
+                    this._channel.sendVideoTypeMessage(this._videoType);
268
+                } catch (error) {
269
+                    logError(error, 'VideoTypeMessage', this._videoType);
270
+                }
263 271
             }
264 272
 
265 273
             this.removeListener(RTCEvents.DATA_CHANNEL_OPEN, this._channelOpenListener);
@@ -384,6 +392,17 @@ export default class RTC extends Listenable {
384 392
         }
385 393
     }
386 394
 
395
+    /**
396
+     * Sends the track's  video type to the JVB.
397
+     * @param {SourceName} sourceName - the track's source name.
398
+     * @param {BridgeVideoType} videoType - the track's video type.
399
+     */
400
+    sendSourceVideoType(sourceName, videoType) {
401
+        if (this._channel && this._channel.isOpen()) {
402
+            this._channel.sendSourceVideoTypeMessage(sourceName, videoType);
403
+        }
404
+    }
405
+
387 406
     /**
388 407
      * Elects the participants with the given ids to be the selected
389 408
      * participants in order to always receive video for this participant (even

Loading…
Отказ
Запис