feat: improve stream active state detection
- Use 'active' field from streams array to detect camera on/off - Remove inactive stream SSRCs from mapping when camera turns off - Enhanced logging to show active stream count and status - Better detection of camera state changes using both video_ssrc and active field - Should now properly detect when user turns camera on/off
This commit is contained in:
parent
f9a0e46c59
commit
6b5b3d1867
2 changed files with 24 additions and 13 deletions
|
|
@ -1 +1 @@
|
||||||
Subproject commit 9d6ca7a1b9fbc7362ffcb3732487ed78f2ff9769
|
Subproject commit 943f9e54add4eda8983d83f78e0942ed9e137387
|
||||||
|
|
@ -468,11 +468,20 @@ class WebcamRecordingService {
|
||||||
textChannel
|
textChannel
|
||||||
) {
|
) {
|
||||||
// Listen for streaming events to detect when camera is turned off
|
// Listen for streaming events to detect when camera is turned off
|
||||||
connection.on("startStreaming", ({ video_ssrc, user_id, audio_ssrc }) => {
|
connection.on(
|
||||||
// Check if this is our target user and they turned off their camera
|
"startStreaming",
|
||||||
if (user_id === targetUserId && (video_ssrc === 0 || !video_ssrc)) {
|
({ video_ssrc, user_id, audio_ssrc, streams }) => {
|
||||||
|
// Check if this is our target user
|
||||||
|
if (user_id === targetUserId) {
|
||||||
|
// Check if any stream is active for video
|
||||||
|
const hasActiveVideo =
|
||||||
|
streams &&
|
||||||
|
streams.some((stream) => stream.active && stream.type === "video");
|
||||||
|
|
||||||
|
// Stop recording if no active video streams or video_ssrc is 0
|
||||||
|
if (!hasActiveVideo || video_ssrc === 0 || !video_ssrc) {
|
||||||
console.log(
|
console.log(
|
||||||
`[Docker] Target user ${targetUserId} turned off camera, stopping webcam recording`
|
`[Docker] Target user ${targetUserId} turned off camera (active video: ${hasActiveVideo}, video_ssrc: ${video_ssrc}), stopping webcam recording`
|
||||||
);
|
);
|
||||||
this.stopRecording(
|
this.stopRecording(
|
||||||
voiceChannelId,
|
voiceChannelId,
|
||||||
|
|
@ -480,7 +489,9 @@ class WebcamRecordingService {
|
||||||
"🎥 Webcam recording stopped - user turned off camera."
|
"🎥 Webcam recording stopped - user turned off camera."
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
// Listen for user disconnect events
|
// Listen for user disconnect events
|
||||||
connection.on("disconnect", (userId) => {
|
connection.on("disconnect", (userId) => {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue