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

feat(RTC): Signal video type and availability to bridge.

dev1
Jaya Allamsetty преди 4 години
родител
ревизия
3cd9d31b97
No account linked to committer's email address
променени са 4 файла, в които са добавени 69 реда и са изтрити 20 реда
  1. 22
    18
      JitsiConference.js
  2. 13
    0
      modules/RTC/BridgeChannel.js
  3. 27
    0
      modules/RTC/RTC.js
  4. 7
    2
      service/RTC/VideoType.js

+ 22
- 18
JitsiConference.js Целия файл

1120
             if (oldTrack) {
1120
             if (oldTrack) {
1121
                 this.onLocalTrackRemoved(oldTrack);
1121
                 this.onLocalTrackRemoved(oldTrack);
1122
             }
1122
             }
1123
+
1124
+            // Send 'VideoTypeMessage' on the bridge channel for the new track.
1123
             if (newTrack) {
1125
             if (newTrack) {
1124
-                // Now handle the addition of the newTrack at the
1125
-                // JitsiConference level
1126
+                // Now handle the addition of the newTrack at the JitsiConference level
1126
                 this._setupNewTrack(newTrack);
1127
                 this._setupNewTrack(newTrack);
1128
+                newTrack.isVideoTrack() && this.rtc.setVideoType(newTrack.videoType);
1129
+            } else {
1130
+                oldTrack && oldTrack.isVideoTrack() && this.rtc.setVideoType(VideoType.NONE);
1127
             }
1131
             }
1128
 
1132
 
1129
             return Promise.resolve();
1133
             return Promise.resolve();
1229
     if (this.jvbJingleSession) {
1233
     if (this.jvbJingleSession) {
1230
         addAsUnmutePromises.push(this.jvbJingleSession.addTrackAsUnmute(track));
1234
         addAsUnmutePromises.push(this.jvbJingleSession.addTrackAsUnmute(track));
1231
     } else {
1235
     } else {
1232
-        logger.info(
1233
-            'Add local MediaStream as unmute -'
1234
-                + ' no JVB Jingle session started yet');
1236
+        logger.debug('Add local MediaStream as unmute - no JVB Jingle session started yet');
1235
     }
1237
     }
1236
 
1238
 
1237
     if (this.p2pJingleSession) {
1239
     if (this.p2pJingleSession) {
1238
         addAsUnmutePromises.push(this.p2pJingleSession.addTrackAsUnmute(track));
1240
         addAsUnmutePromises.push(this.p2pJingleSession.addTrackAsUnmute(track));
1239
     } else {
1241
     } else {
1240
-        logger.info(
1241
-            'Add local MediaStream as unmute -'
1242
-                + ' no P2P Jingle session started yet');
1242
+        logger.debug('Add local MediaStream as unmute - no P2P Jingle session started yet');
1243
     }
1243
     }
1244
 
1244
 
1245
-    return Promise.all(addAsUnmutePromises);
1245
+    return Promise.allSettled(addAsUnmutePromises)
1246
+        .then(() => {
1247
+            // Signal the video type to the bridge.
1248
+            track.isVideoTrack() && this.rtc.setVideoType(track.videoType);
1249
+        });
1246
 };
1250
 };
1247
 
1251
 
1248
 /**
1252
 /**
1256
     const removeAsMutePromises = [];
1260
     const removeAsMutePromises = [];
1257
 
1261
 
1258
     if (this.jvbJingleSession) {
1262
     if (this.jvbJingleSession) {
1259
-        removeAsMutePromises.push(
1260
-            this.jvbJingleSession.removeTrackAsMute(track));
1263
+        removeAsMutePromises.push(this.jvbJingleSession.removeTrackAsMute(track));
1261
     } else {
1264
     } else {
1262
-        logger.info(
1263
-            'Remove local MediaStream - no JVB JingleSession started yet');
1265
+        logger.debug('Remove local MediaStream - no JVB JingleSession started yet');
1264
     }
1266
     }
1265
     if (this.p2pJingleSession) {
1267
     if (this.p2pJingleSession) {
1266
-        removeAsMutePromises.push(
1267
-            this.p2pJingleSession.removeTrackAsMute(track));
1268
+        removeAsMutePromises.push(this.p2pJingleSession.removeTrackAsMute(track));
1268
     } else {
1269
     } else {
1269
-        logger.info(
1270
-            'Remove local MediaStream - no P2P JingleSession started yet');
1270
+        logger.debug('Remove local MediaStream - no P2P JingleSession started yet');
1271
     }
1271
     }
1272
 
1272
 
1273
-    return Promise.all(removeAsMutePromises);
1273
+    return Promise.allSettled(removeAsMutePromises)
1274
+        .then(() => {
1275
+            // Signal the video type to the bridge.
1276
+            track.isVideoTrack() && this.rtc.setVideoType(VideoType.NONE);
1277
+        });
1274
 };
1278
 };
1275
 
1279
 
1276
 /**
1280
 /**

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

259
         });
259
         });
260
     }
260
     }
261
 
261
 
262
+    /**
263
+     * Sends a 'VideoTypeMessage' message via the bridge channel.
264
+     *
265
+     * @param {string} videoType 'camera', 'desktop' or 'none'.
266
+     */
267
+    sendVideoTypeMessage(videoType) {
268
+        logger.debug(`Sending VideoTypeMessage with video type as ${videoType}`);
269
+        this._send({
270
+            colibriClass: 'VideoTypeMessage',
271
+            videoType
272
+        });
273
+    }
274
+
262
     /**
275
     /**
263
      * Set events on the given RTCDataChannel or WebSocket instance.
276
      * Set events on the given RTCDataChannel or WebSocket instance.
264
      */
277
      */

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

181
         this._updateAudioOutputForAudioTracks
181
         this._updateAudioOutputForAudioTracks
182
             = this._updateAudioOutputForAudioTracks.bind(this);
182
             = this._updateAudioOutputForAudioTracks.bind(this);
183
 
183
 
184
+        // The default video type assumed by the bridge.
185
+        this._videoType = VideoType.CAMERA;
186
+
184
         // Switch audio output device on all remote audio tracks. Local audio
187
         // Switch audio output device on all remote audio tracks. Local audio
185
         // tracks handle this event by themselves.
188
         // tracks handle this event by themselves.
186
         if (RTCUtils.isDeviceChangeAvailable('output')) {
189
         if (RTCUtils.isDeviceChangeAvailable('output')) {
286
                 }
289
                 }
287
             }
290
             }
288
 
291
 
292
+            try {
293
+                this._channel.sendVideoTypeMessage(this._videoType);
294
+            } catch (error) {
295
+                GlobalOnErrorHandler.callErrorHandler(error);
296
+                logger.error(`Cannot send VideoTypeMessage ${this._videoType}`, error);
297
+            }
298
+
289
             this.removeListener(RTCEvents.DATA_CHANNEL_OPEN, this._channelOpenListener);
299
             this.removeListener(RTCEvents.DATA_CHANNEL_OPEN, this._channelOpenListener);
290
             this._channelOpenListener = null;
300
             this._channelOpenListener = null;
291
         };
301
         };
382
         }
392
         }
383
     }
393
     }
384
 
394
 
395
+    /**
396
+     * Sets the video type and availability for the local video source.
397
+     *
398
+     * @param {string} videoType 'camera' for camera, 'desktop' for screenshare and
399
+     * 'none' for when local video source is muted or removed from the peerconnection.
400
+     * @returns {void}
401
+     */
402
+    setVideoType(videoType) {
403
+        if (this._videoType !== videoType) {
404
+            this._videoType = videoType;
405
+
406
+            if (this._channel && this._channel.isOpen()) {
407
+                this._channel.sendVideoTypeMessage(videoType);
408
+            }
409
+        }
410
+    }
411
+
385
     /**
412
     /**
386
      * Elects the participants with the given ids to be the selected
413
      * Elects the participants with the given ids to be the selected
387
      * participants in order to always receive video for this participant (even
414
      * participants in order to always receive video for this participant (even

+ 7
- 2
service/RTC/VideoType.js Целия файл

1
 /* global module */
1
 /* global module */
2
 /**
2
 /**
3
  * Enumeration of the video types
3
  * Enumeration of the video types
4
- * @type {{CAMERA: string, DESKTOP: string}}
4
+ * @type {{CAMERA: string, DESKTOP: string, NONE: string}}
5
  */
5
  */
6
 const VideoType = {
6
 const VideoType = {
7
     /**
7
     /**
12
     /**
12
     /**
13
      * The desktop video type.
13
      * The desktop video type.
14
      */
14
      */
15
-    DESKTOP: 'desktop'
15
+    DESKTOP: 'desktop',
16
+
17
+    /**
18
+     * No local video source.
19
+     */
20
+    NONE: 'none'
16
 };
21
 };
17
 
22
 
18
 module.exports = VideoType;
23
 module.exports = VideoType;

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