Sfoglia il codice sorgente

ref(JitsiConference): allow only 1 track per media type

Only one audio or video track is correctly supported by lib-jitsi-meet.
This is an attempt to mitigate an issue reported by the community
where the user's audio is played in the conference even though the UI
shows the user as muted.
dev1
Pawel Domas 4 anni fa
parent
commit
ae45a0648f
1 ha cambiato i file con 11 aggiunte e 15 eliminazioni
  1. 11
    15
      JitsiConference.js

+ 11
- 15
JitsiConference.js Vedi File

@@ -942,27 +942,23 @@ JitsiConference.prototype.getTranscriptionStatus = function() {
942 942
 
943 943
 /**
944 944
  * Adds JitsiLocalTrack object to the conference.
945
- * @param track the JitsiLocalTrack object.
945
+ * @param {JitsiLocalTrack} track the JitsiLocalTrack object.
946 946
  * @returns {Promise<JitsiLocalTrack>}
947 947
  * @throws {Error} if the specified track is a video track and there is already
948 948
  * another video track in the conference.
949 949
  */
950 950
 JitsiConference.prototype.addTrack = function(track) {
951
-    if (track.isVideoTrack()) {
952
-        // Ensure there's exactly 1 local video track in the conference.
953
-        const localVideoTrack = this.rtc.getLocalVideoTrack();
954
-
955
-        if (localVideoTrack) {
956
-            // Don't be excessively harsh and severe if the API client happens
957
-            // to attempt to add the same local video track twice.
958
-            if (track === localVideoTrack) {
959
-                return Promise.resolve(track);
960
-            }
961
-
962
-            return Promise.reject(new Error(
963
-                'cannot add second video track to the conference'));
964
-
951
+    const mediaType = track.getType();
952
+    const localTracks = this.rtc.getLocalTracks(mediaType);
953
+
954
+    // Ensure there's exactly 1 local track of each media type in the conference.
955
+    if (localTracks.length > 0) {
956
+        // Don't be excessively harsh and severe if the API client happens to attempt to add the same local track twice.
957
+        if (track === localTracks[0]) {
958
+            return Promise.resolve(track);
965 959
         }
960
+
961
+        return Promise.reject(new Error(`Cannot add second ${mediaType} track to the conference`));
966 962
     }
967 963
 
968 964
     return this.replaceTrack(null, track);

Loading…
Annulla
Salva