Data: Check for empty tracks map during data gathering or rebroadcasts fail on Windows#39
Data: Check for empty tracks map during data gathering or rebroadcasts fail on Windows#39danrossi wants to merge 1 commit into
Conversation
…f the video tracks map is filled or new broadcasts fail on Windows. - Clear the bytes total sent on stop.
WalkthroughThis pull request adds two defensive improvements to the MoQOutput class in 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
✨ Simplify code
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/moq-output.cpp`:
- Around line 153-156: The early return when video_tracks.empty() causes the
first video packet (and thus track initialization in VideoData()) to be dropped
and prevents any future initialization; instead of returning from that block,
change the logic to avoid discarding the first packets—either remove the return
and skip only shutdown/failure paths, or replace the return with a
no-op/continue and only perform the guard after VideoData() runs (or after a
dedicated initialized flag is set). Locate the guard referencing video_tracks
(and the VideoData() consumer) and adjust it so the check does not run before
track initialization completes, ensuring VideoData() can populate video_tracks
on the first packet.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
| // OBS tries to gather data on signalling a stop success. Check once if the video tracks map is filled or new broadcasts fail on Windows. | ||
| if (video_tracks.empty()) { | ||
| return; | ||
| } |
There was a problem hiding this comment.
Guard drops the first video packet and prevents track initialization forever.
This return runs before VideoData(), so video_tracks never gets initialized and all packets are skipped indefinitely.
Suggested fix
- // OBS tries to gather data on signalling a stop success. Check once if the video tracks map is filled or new broadcasts fail on Windows.
- if (video_tracks.empty()) {
+ // Ignore non-video packets until at least one video track is initialized.
+ // This still allows the first video packet through to create the track.
+ if (video_tracks.empty() && packet->type != OBS_ENCODER_VIDEO) {
return;
}🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@src/moq-output.cpp` around lines 153 - 156, The early return when
video_tracks.empty() causes the first video packet (and thus track
initialization in VideoData()) to be dropped and prevents any future
initialization; instead of returning from that block, change the logic to avoid
discarding the first packets—either remove the return and skip only
shutdown/failure paths, or replace the return with a no-op/continue and only
perform the guard after VideoData() runs (or after a dedicated initialized flag
is set). Locate the guard referencing video_tracks (and the VideoData()
consumer) and adjust it so the check does not run before track initialization
completes, ensuring VideoData() can populate video_tracks on the first packet.
Related: #38
OBS tries to gather data on signalling a stop success. Check once if the video tracks map is filled during data gathering or new broadcasts fail on Windows. Data gathering continues on signal stop and causes an error. Which then affects video track data on rebroadcasting causing a "decode failed: moq: protocol violation"
Other plugins check if video and audio data is set but just the one map check before should be fine.
The bytes total sent is now reset on stop.