Parcourir la source

fix: Avoid sending two presences if start muted and then screen share. (#1771)

* fix: Avoid sending two presences if start muted and then screen share.

* squash: Drop some changes and simplify sending presence.

* squash: Always send presence when sourceNameSignalingEnabled.
tags/v0.0.2
Дамян Минков il y a 4 ans
Parent
révision
64b2267d1b
Aucun compte lié à l'adresse e-mail de l'auteur
1 fichiers modifiés avec 37 ajouts et 7 suppressions
  1. 37
    7
      JitsiConference.js

+ 37
- 7
JitsiConference.js Voir le fichier

@@ -1275,13 +1275,19 @@ JitsiConference.prototype._setupNewTrack = function(newTrack) {
1275 1275
                 RTC.getEventDataForActiveDevice(device));
1276 1276
         }
1277 1277
     }
1278
+
1279
+    let videoTypeChanged = false;
1280
+
1278 1281
     if (newTrack.isVideoTrack()) {
1279
-        this._sendNewVideoType(newTrack);
1282
+        videoTypeChanged = this._setNewVideoType(newTrack);
1280 1283
     }
1281 1284
     this.rtc.addLocalTrack(newTrack);
1282 1285
 
1283 1286
     // ensure that we're sharing proper "is muted" state
1284
-    this._setTrackMuteStatus(newTrack, newTrack.isMuted());
1287
+    if (this._setTrackMuteStatus(newTrack, newTrack.isMuted()) || videoTypeChanged) {
1288
+        // send presence if it was changed with vide type or mute status
1289
+        this.room.sendPresence();
1290
+    }
1285 1291
 
1286 1292
     newTrack.muteHandler = this._fireMuteChangeEvent.bind(this, newTrack);
1287 1293
     newTrack.audioLevelHandler = this._fireAudioLevelChangeEvent.bind(this);
@@ -1297,7 +1303,13 @@ JitsiConference.prototype._setupNewTrack = function(newTrack) {
1297 1303
     this.eventEmitter.emit(JitsiConferenceEvents.TRACK_ADDED, newTrack);
1298 1304
 };
1299 1305
 
1300
-JitsiConference.prototype._sendNewVideoType = function(track) {
1306
+/**
1307
+ * Sets the video type.
1308
+ * @param track
1309
+ * @return <tt>true</tt> if video type was changed in presence.
1310
+ * @private
1311
+ */
1312
+JitsiConference.prototype._setNewVideoType = function(track) {
1301 1313
     if (FeatureFlags.isSourceNameSignalingEnabled()) {
1302 1314
         // FIXME once legacy signaling using 'sendCommand' is removed, signalingLayer.setTrackVideoType must be adjusted
1303 1315
         // to send the presence (not just modify it).
@@ -1308,16 +1320,30 @@ JitsiConference.prototype._sendNewVideoType = function(track) {
1308 1320
                 0
1309 1321
             ),
1310 1322
             track.videoType);
1323
+
1324
+        // TODO: Optimize to detect whether presence was changed, for now always report changed to send presence
1325
+        return true;
1311 1326
     }
1312 1327
 
1313 1328
     const videoTypeTagName = 'videoType';
1314 1329
 
1315 1330
     // if video type is camera and there is no videoType in presence, we skip adding it, as this is the default one
1316 1331
     if (track.videoType !== VideoType.CAMERA || this.room.getFromPresence(videoTypeTagName)) {
1317
-        this.sendCommand(videoTypeTagName, { value: track.videoType });
1332
+        // we will not use this.sendCommand here to avoid sending the presence immediately, as later we may also set
1333
+        // and the mute status
1334
+        return this.room.addOrReplaceInPresence(videoTypeTagName, { value: track.videoType });
1318 1335
     }
1336
+
1337
+    return false;
1319 1338
 };
1320 1339
 
1340
+/**
1341
+ * Sets mute status.
1342
+ * @param localTrack
1343
+ * @param isMuted
1344
+ * @param <tt>true</tt> when presence was changed, <tt>false</tt> otherwise.
1345
+ * @private
1346
+ */
1321 1347
 JitsiConference.prototype._setTrackMuteStatus = function(localTrack, isMuted) {
1322 1348
     if (FeatureFlags.isSourceNameSignalingEnabled()) {
1323 1349
         // TODO When legacy signaling part is removed, remember to adjust signalingLayer.setTrackMuteStatus, so that
@@ -1328,11 +1354,15 @@ JitsiConference.prototype._setTrackMuteStatus = function(localTrack, isMuted) {
1328 1354
         );
1329 1355
     }
1330 1356
 
1357
+    if (!this.room) {
1358
+        return false;
1359
+    }
1360
+
1331 1361
     if (localTrack.isAudioTrack()) {
1332
-        this.room && this.room.setAudioMute(isMuted);
1333
-    } else {
1334
-        this.room && this.room.setVideoMute(isMuted);
1362
+        return this.room.addAudioInfoToPresence(isMuted);
1335 1363
     }
1364
+
1365
+    return this.room.addVideoInfoToPresence(isMuted);
1336 1366
 };
1337 1367
 
1338 1368
 /**

Chargement…
Annuler
Enregistrer