Skip to content

Data: Check for empty tracks map during data gathering or rebroadcasts fail on Windows#39

Open
danrossi wants to merge 1 commit into
moq-dev:mainfrom
danrossi:windows-stop-fix
Open

Data: Check for empty tracks map during data gathering or rebroadcasts fail on Windows#39
danrossi wants to merge 1 commit into
moq-dev:mainfrom
danrossi:windows-stop-fix

Conversation

@danrossi
Copy link
Copy Markdown
Contributor

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.

…f the video tracks map is filled or new broadcasts fail on Windows.

- Clear the bytes total sent on stop.
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 18, 2026

Review Change Stack

Walkthrough

This pull request adds two defensive improvements to the MoQOutput class in src/moq-output.cpp. The Stop() method now resets the total_bytes_sent counter to zero when stopping, ensuring clean state on shutdown. The Data() method adds an early-return guard that skips packet processing when video_tracks is empty, preventing unnecessary work in that condition.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: adding a check for empty tracks during data gathering to prevent rebroadcast failures on Windows.
Description check ✅ Passed The description is directly related to the changeset, explaining the issue, the fix applied, and additional changes like resetting bytes sent.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
✨ Simplify code
  • Create PR with simplified 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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 4f32fad7-788f-4792-9efd-d837167000d0

📥 Commits

Reviewing files that changed from the base of the PR and between 29a90c6 and 00e0ba5.

📒 Files selected for processing (1)
  • src/moq-output.cpp

Comment thread src/moq-output.cpp
Comment on lines +153 to +156
// 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;
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical | ⚡ Quick win

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant