Skip to content

Conversation

@kixelated
Copy link
Collaborator

No description provided.

@coderabbitai
Copy link

coderabbitai bot commented Dec 18, 2025

Walkthrough

This pull request refactors the MOQ output module from a broadcast-centric to an origin-centric publishing architecture. Key changes include: version bump to 0.2.0 in CMakePresets.json, restructured publishing flow in moq-output.cpp with new origin member and lifecycle management, updated API calls for session connection and media track operations, addition of a private origin field in moq-output.h, reduced codec support to AAC and H264 only in moq-service.cpp, and adjusted logging call signature in obs-moq.cpp to include string length parameter.

Pre-merge checks and finishing touches

❌ Failed checks (2 warnings, 1 inconclusive)
Check name Status Explanation Resolution
Title check ⚠️ Warning The title 'Use the new libmoq consume API' does not accurately reflect the main changes. The changeset primarily updates to use an origin-centric publishing flow, not a consume API. Update the title to reflect the actual changes, such as 'Refactor publishing to use origin-centric flow' or 'Update to new libmoq publish API'.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
Description check ❓ Inconclusive No pull request description was provided by the author. Add a description explaining the purpose of these changes, the origin-centric publishing refactor, and why this API migration improves the implementation.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch libmoq-consume

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

Copy link

@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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
src/moq-output.cpp (2)

10-22: Missing error handling for origin/broadcast creation.

moq_origin_create() and moq_publish_create() may return negative error codes on failure. The destructor unconditionally calls moq_publish_close(broadcast) and moq_origin_close(origin), which could cause undefined behavior if these handles are invalid.

🔎 Suggested approach

Consider validating the return values and either:

  1. Throw an exception if creation fails, or
  2. Add guards in the destructor similar to how session, video, and audio are guarded with > 0 checks in Stop().
 MoQOutput::~MoQOutput()
 {
-	moq_publish_close(broadcast);
-	moq_origin_close(origin);
+	if (broadcast > 0) {
+		moq_publish_close(broadcast);
+	}
+	if (origin > 0) {
+		moq_origin_close(origin);
+	}

 	Stop();
 }

108-128: Handles not reset after closing—potential double-close.

After closing session, video, and audio, their values remain positive. If Stop() is called multiple times (e.g., explicitly then via destructor), the handles will be closed again.

🔎 Suggested fix
 void MoQOutput::Stop(bool signal)
 {
 	// Close the session
 	if (session > 0) {
 		moq_session_close(session);
+		session = 0;
 	}

 	if (video > 0) {
 		moq_publish_media_close(video);
+		video = 0;
 	}

 	if (audio > 0) {
 		moq_publish_media_close(audio);
+		audio = 0;
 	}
🧹 Nitpick comments (1)
src/obs-moq.cpp (1)

38-39: Consider using strlen to avoid manual length synchronization.

Hardcoding the string length (4) is fragile—if the log level string changes, the length must be updated manually. Using strlen("info") makes this self-maintaining.

🔎 Suggested fix
 	// Use RUST_LOG env var for more verbose output
-	// The second argument is the string length of the first argument.
-	moq_log_level("info", 4);
+	moq_log_level("info", strlen("info"));
📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0f719e2 and f74d1d7.

📒 Files selected for processing (5)
  • CMakePresets.json (2 hunks)
  • src/moq-output.cpp (7 hunks)
  • src/moq-output.h (1 hunks)
  • src/moq-service.cpp (1 hunks)
  • src/obs-moq.cpp (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
src/moq-output.cpp (1)
src/moq-output.h (1)
  • MoQOutput (8-48)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: Build Project 🧱 / Build for macOS 🍏
  • GitHub Check: Build Project 🧱 / Build for Ubuntu 🐧 (ubuntu-24.04)
  • GitHub Check: Build Project 🧱 / Build for Windows 🪟
🔇 Additional comments (6)
CMakePresets.json (1)

16-16: LGTM!

Version bump to 0.2.0 is appropriate given the significant API refactor to the new origin-centric publishing architecture.

src/moq-service.cpp (1)

3-5: Verify intentional codec reduction.

The supported codecs have been reduced to only aac and h264, removing opus, hevc, and av1. This is a breaking change for users relying on the removed codecs.

Ensure this limitation is intentional and aligns with the new libmoq API capabilities. The TODO comment suggests this may be temporary.

src/moq-output.h (1)

43-43: LGTM!

The new origin member appropriately supports the origin-centric publishing flow and is consistently typed with other handle members.

src/moq-output.cpp (3)

85-101: LGTM!

The new origin-centric publish flow is correctly implemented. The session connects with the origin handle, and the broadcast is published to the origin.

Note: The TODO at line 96 about missing unpublish function is tracked.


156-164: LGTM!

The moq_publish_media_frame API is correctly used with proper error handling.


218-224: LGTM!

Good use of strlen(codec) for the length parameter—this is self-maintaining unlike hardcoded values.

Comment on lines 24 to 30
MoQOutput::~MoQOutput()
{
moq_broadcast_close(broadcast);
moq_publish_close(broadcast);
moq_origin_close(origin);

Stop();
}
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Resource cleanup order may be incorrect.

moq_publish_close(broadcast) is called before Stop(), but Stop() closes the video/audio tracks that were created under the broadcast. Closing the parent (broadcast) before its children (tracks) may cause issues.

Consider calling Stop() first:

🔎 Suggested fix
 MoQOutput::~MoQOutput()
 {
+	Stop();
+
 	moq_publish_close(broadcast);
 	moq_origin_close(origin);
-
-	Stop();
 }
🤖 Prompt for AI Agents
In src/moq-output.cpp around lines 24 to 30, the destructor currently calls
moq_publish_close(broadcast) and moq_origin_close(origin) before Stop(), which
can close the broadcast parent while its video/audio tracks are still open;
change the order so Stop() is called first to shut down and release tracks, then
call moq_publish_close(broadcast) and moq_origin_close(origin) afterward (retain
any existing null/validity checks and error handling when closing resources).

@kixelated kixelated merged commit 3de95a9 into master Dec 18, 2025
2 of 6 checks passed
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.

2 participants