Skip to content

Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.

fix(conference): add the recorder tracks which arrive before presence

damencho254436952739
diff --git a/conference.js b/conference.js
index 530ae911cf..20e8e750aa 100644
--- a/conference.js
+++ b/conference.js
@@ -132,6 +132,7 @@ import {
getLocalJitsiAudioTrack,
getLocalJitsiVideoTrack,
getLocalVideoTrack,
+ getTrackByJitsiTrack,
isLocalTrackMuted,
isUserInteractionRequiredForUnmute
} from './react/features/base/tracks/functions';
@@ -193,6 +194,22 @@ function sendData(command, value) {
room.sendCommand(command, { value });
}
+/**
+ * Checks if the recorder must skip a remote track of a participant.
+ *
+ * @param {JitsiParticipant} participant - The participant who owns the track.
+ * @param {JitsiRemoteTrack} track - The remote track.
+ * @returns {boolean}
+ */
+function isTrackHiddenFromRecorder(participant, track) {
+ if (participant.isHiddenFromRecorder()) {
+ return true;
+ }
+
+ // Only the video of this participant is hidden from the recorder. Its audio is still recorded.
+ return Boolean(participant.isVideoHiddenFromRecorder?.() && track.isVideoTrack());
+}
+
/**
* A queue for the async replaceLocalTrack action so that multiple audio
* replacements cannot happen simultaneously. This solves the issue where
@@ -1387,6 +1404,16 @@ export default {
commonUserJoinedHandling(APP.store, room, user);
}
+ // Add the tracks which the recorder skipped because their source signaling arrived before this presence
+ // (see TRACK_ADDED below). lib-jitsi-meet does not emit TRACK_ADDED again for them.
+ if (config.iAmRecorder) {
+ const tracks = APP.store.getState()['features/base/tracks'];
+
+ user.getTracks()
+ .filter(track => !isTrackHiddenFromRecorder(user, track) && !getTrackByJitsiTrack(tracks, track))
+ .forEach(track => APP.store.dispatch(trackAdded(track)));
+ }
+
if (user.isHidden() || videoHiddenFromRecorder) {
return;
}
@@ -1443,12 +1470,15 @@ export default {
if (config.iAmRecorder) {
const participant = room.getParticipantById(track.getParticipantId());
- if (participant.isHiddenFromRecorder()) {
+ // The source signaling can arrive before the presence of the participant. Then we cannot know yet
+ // if the participant is hidden from the recorder. The track is added on USER_JOINED.
+ if (!participant) {
+ logger.info(`Track ${track.getSourceName()} added before presence, waiting for USER_JOINED`);
+
return;
}
- // Only the video of this participant is hidden from the recorder. Its audio is still recorded.
- if (participant.isVideoHiddenFromRecorder?.() && track.isVideoTrack()) {
+ if (isTrackHiddenFromRecorder(participant, track)) {
return;
}
}