Quellcode durchsuchen

fix(TPC): Remove the existing track instead of overwriting.

When a second remote track of the same mediatype is received for an endpoint, remove the existing track before creating the new remote track.
dev1
Jaya Allamsetty vor 4 Jahren
Ursprung
Commit
4c668023b3
1 geänderte Dateien mit 12 neuen und 3 gelöschten Zeilen
  1. 12
    3
      modules/RTC/TraceablePeerConnection.js

+ 12
- 3
modules/RTC/TraceablePeerConnection.js Datei anzeigen

@@ -884,15 +884,24 @@ TraceablePeerConnection.prototype._createRemoteTrack = function(
884 884
     }
885 885
 
886 886
     if (existingTrack && existingTrack.getTrack() === track) {
887
-        // Ignore duplicated event which can originate either from
888
-        // 'onStreamAdded' or 'onTrackAdded'.
887
+        // Ignore duplicated event which can originate either from 'onStreamAdded' or 'onTrackAdded'.
889 888
         logger.info(
890 889
             `${this} ignored duplicated remote track added event for: `
891 890
                 + `${ownerEndpointId}, ${mediaType}`);
892 891
 
893 892
         return;
894 893
     } else if (existingTrack) {
895
-        logger.error(`${this} overwriting remote track for ${ownerEndpointId} ${mediaType}`);
894
+        logger.error(`${this} received a second remote track for ${ownerEndpointId} ${mediaType}, `
895
+            + 'deleting the existing track.');
896
+
897
+        // The exisiting track needs to be removed here. We can get here when Jicofo reverses the order of source-add
898
+        // and source-remove messages. Ideally, when a remote endpoint changes source, like switching devices, it sends
899
+        // a source-remove (for old ssrc) followed by a source-add (for new ssrc) and Jicofo then should forward these
900
+        // two messages to all the other endpoints in the conference in the same order. However, sometimes, these
901
+        // messages arrive at the client in the reverse order resulting in two remote tracks (of same media type) being
902
+        // created and in case of video, a black strip (that of the first track which has ended) appears over the live
903
+        // track obscuring it. Removing the existing track when that happens will fix this issue.
904
+        this._remoteTrackRemoved(existingTrack.getOriginalStream(), existingTrack.getTrack());
896 905
     }
897 906
 
898 907
     const remoteTrack

Laden…
Abbrechen
Speichern