Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
feat: Implement client-specific cursors for shared streams
This commit fixes an issue where multiple clients watching the same stream would cause picture distortion and interruptions. The problem was that all clients were consuming from the same shared buffer, leading to data being missed by some clients.
To solve this, I implemented a client-specific cursor for each stream. This cursor is stored in Redis and tracks the last segment that each client has received. The
getNextStreamSegmentsmethod inSharedStreamServicewas updated to use these cursors, ensuring that each client receives a complete and independent stream.I also updated the
removeClientmethod to clean up the client's cursor from Redis when they disconnect, and modified theBufferManagementjob to clean up segments that have been consumed by all clients.Fixes(cache): Ensure stream_key is always present in getAllActiveStreams
This commit fixes an 'Undefined array key "stream_key"' error that occurred when running the
app:flush-ffmpeg-process-cachecommand. The error was caused by thegetAllActiveStreamsmethod inSharedStreamServicenot including thestream_keyin the returned array when thestream_infofrom the database was null.I have modified the
getAllActiveStreamsmethod to ensure that thestream_keyis always present in the returned array, which resolves the issue.Fix(streaming): Use posix_getpgid to detect running processes
This commit fixes an issue where active streams were being incorrectly identified as phantom streams. This was caused by the
isProcessRunningmethod usingshell_execto check the process status, which was unreliable in some environments.I have updated the
isProcessRunningmethod to use theposix_getpgidfunction instead. This is a more reliable way to check if a process is running and should prevent the incorrect detection of phantom streams. I have also added a test case to verify the new implementation.