Skip to content

Fix output publish timing and Windows FFmpeg lookup#40

Open
YogiSotho wants to merge 1 commit into
moq-dev:mainfrom
YogiSotho:fix/moq-output-connect-publish
Open

Fix output publish timing and Windows FFmpeg lookup#40
YogiSotho wants to merge 1 commit into
moq-dev:mainfrom
YogiSotho:fix/moq-output-connect-publish

Conversation

@YogiSotho
Copy link
Copy Markdown

Summary

  • publish the broadcast from the session status callback once the session reports connected
  • replace the hardcoded Windows FFmpeg .deps path with CMake-based header/library discovery

Why

The output path currently publishes the broadcast before the session has reported a successful connection. This patch moves publication into the session-connected callback so the output path acts only after the session is established, which also matches the general pattern already used by the source path.

On Windows, the plugin build also depended on a pinned .deps/obs-deps-... directory name for FFmpeg. That works locally, but it is brittle across dependency revisions. Switching to CMake discovery keeps the build tied to the configured dependency search path instead of one extracted folder name.

Notes

This change is intentionally scoped to the dependency contract currently vendored by this plugin build. I am not trying to make a broader claim about all libmoq versions or callback semantics outside the version this repository is building against.

If there is a preferred repo-specific pattern for FFmpeg discovery on Windows, I’m happy to adjust the CMake side to match it.

Validation

  • built successfully on Windows with:
    cmake --build build_x64_26100 --config Release --target obs-moq

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jun 4, 2026

Review Change Stack

Walkthrough

This PR introduces two independent changes. First, the CMake build system is updated to detect FFmpeg dependencies conditionally: on Windows, it directly locates FFmpeg headers and individual libraries (avcodec, avutil, swscale, swresample) using find_path and find_library; on other platforms, it continues using pkg-config results. Second, the MoQOutput class defers broadcast publishing from the Start() method to the MoQ session connection callback. A new PublishBroadcast() helper ensures the broadcast publishes exactly once, guarded by a broadcast_published flag, and signals an error if publication fails.

🚥 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 accurately and concisely summarizes the two main changes: fixing output publish timing and updating Windows FFmpeg lookup, matching the primary objectives of the changeset.
Description check ✅ Passed The description clearly explains the rationale and specifics of both changes (broadcast publish timing and FFmpeg discovery), providing sufficient context and validation details related to the changeset.
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
✨ Simplify code
  • Create PR with simplified code

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 Infer (1.2.0)
src/moq-output.cpp

src/moq-output.cpp:1:10: fatal error: 'obs.hpp' file not found
1 | #include <obs.hpp>
| ^~~~~~~~~
1 error generated.
src/moq-output.cpp:38:2-9: ERROR translating statement 'ReturnStmt'
Aborting translation of method 'MoQOutput::PublishBroadcast' in file 'src/moq-output.cpp': "Assert_failure src/clang/cAst_utils.ml:249:53"
Uncaught Internal Error: "Assert_failure src/clang/cAst_utils.ml:249:53"
Error backtrace:
Raised at ClangFrontend__CAst_utils.get_decl_from_typ_ptr in file "src/clang/cAst_utils.ml", line 249, characters 53-65
Called from ClangFrontend__CTrans.CTrans_funct.get_destructor_decl_ref in file "src/clang/cTrans.ml", line 658, characters 12-59
Called from ClangFrontend__CTrans.CTrans_funct.destructor_calls.(fun) in file "src/clang/cTrans.ml", line 2048, characters 12-69
Called from Base__List.rev_filter_map.loop in file "src/list.ml", line 944, characters 13-17
Called from Base__List.filter_map in file "src/list.ml" (inlined), line 951, characters 26-47
Ca

... [truncated 2200 characters] ...

tend__CTrans.CTrans_funct.instruction in file "src/clang/cTrans.ml" (inlined), line 4765, characters 38-71
Called from ClangFrontend__CTrans.CTrans_funct.exec_with_node_creation in file "src/clang/cTrans.ml" (inlined), line 104, characters 20-38
Called from ClangFrontend__CTrans.CTrans_funct.get_clang_stmt_trans in file "src/clang/cTrans.ml" (inlined), line 5395, characters 4-69
Called from ClangFrontend__CTrans.CTrans_funct.get_custom_stmt_trans in file "src/clang/cTrans.ml", line 5401, characters 8-55
Called from ClangFrontend__CTrans.CTrans_funct.exec_trans_instrs.exec_trans_instrs_rev in file "src/clang/cTrans.ml" (inlined), line 5365, characters 28-54
Called from ClangFrontend__CTrans.CTrans_funct.exec_trans_instrs in file "src/clang/cTrans.ml" (inlined), line 5389, characters 6-70
Ca


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: 2

🤖 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 29-33: Update the two logging calls to include the required
"[obs-moq]" prefix: change the LOG_INFO call that logs the publishing path and
the LOG_ERROR call inside the moq_origin_publish error branch so their messages
begin with "[obs-moq]". Locate the LOG_INFO("Publishing broadcast: %s",
path.c_str()) and LOG_ERROR("Failed to publish broadcast to session: %d",
result) statements (near the moq_origin_publish(origin, path.data(),
path.size(), broadcast) call) and prepend the prefix in their format strings so
they read e.g. LOG_INFO("[obs-moq] ...") and LOG_ERROR("[obs-moq] ...").
- Around line 23-39: The PublishBroadcast method currently short-circuits using
the instance-level flag broadcast_published, causing publishes to be skipped
across session restarts; fix by making the published state session-scoped —
either reset broadcast_published when a session stops/starts (e.g., in your
session Start/Stop handlers) or track the last published session (add a
last_published_session id member and compare it to the current origin/session
before skipping). Ensure PublishBroadcast (and moq_origin_publish call) uses the
current origin/session identity (origin, path) and sets the session-scoped flag
after a successful publish instead of relying on a single lifetime-initialized
broadcast_published.
🪄 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: a85dfec5-1420-459d-a966-0c9692b4bb46

📥 Commits

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

📒 Files selected for processing (3)
  • CMakeLists.txt
  • src/moq-output.cpp
  • src/moq-output.h

Comment thread src/moq-output.cpp
Comment on lines +23 to +39
bool MoQOutput::PublishBroadcast()
{
if (broadcast_published) {
return true;
}

LOG_INFO("Publishing broadcast: %s", path.c_str());

auto result = moq_origin_publish(origin, path.data(), path.size(), broadcast);
if (result < 0) {
LOG_ERROR("Failed to publish broadcast to session: %d", result);
return false;
}

broadcast_published = true;
return true;
}
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 | 🟠 Major | ⚡ Quick win

Reset publish state per session, not per object lifetime.

At Line 25, PublishBroadcast() permanently short-circuits once broadcast_published is true, but this flag is only initialized in the constructor (Line 19). On a later stop/start cycle with the same MoQOutput instance, the new session can skip moq_origin_publish(...).

Suggested fix
 bool MoQOutput::Start()
 {
@@
 	// Path (broadcast name) is optional; an empty string publishes to the unnamed broadcast.
 	const char *path_value = obs_service_get_connect_info(service, OBS_SERVICE_CONNECT_INFO_STREAM_KEY);
 	path = path_value ? path_value : "";
+	broadcast_published = false;
@@
 }
🤖 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 23 - 39, The PublishBroadcast method
currently short-circuits using the instance-level flag broadcast_published,
causing publishes to be skipped across session restarts; fix by making the
published state session-scoped — either reset broadcast_published when a session
stops/starts (e.g., in your session Start/Stop handlers) or track the last
published session (add a last_published_session id member and compare it to the
current origin/session before skipping). Ensure PublishBroadcast (and
moq_origin_publish call) uses the current origin/session identity (origin, path)
and sets the session-scoped flag after a successful publish instead of relying
on a single lifetime-initialized broadcast_published.

Comment thread src/moq-output.cpp
Comment on lines +29 to +33
LOG_INFO("Publishing broadcast: %s", path.c_str());

auto result = moq_origin_publish(origin, path.data(), path.size(), broadcast);
if (result < 0) {
LOG_ERROR("Failed to publish broadcast to session: %d", result);
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 | 🟡 Minor | ⚡ Quick win

Add the required [obs-moq] prefix to new log messages.

Line 29 and Line 33 use project logging macros but omit the required prefix, which makes filtering/attribution inconsistent.

Suggested fix
-	LOG_INFO("Publishing broadcast: %s", path.c_str());
+	LOG_INFO("[obs-moq] Publishing broadcast: %s", path.c_str());
@@
-		LOG_ERROR("Failed to publish broadcast to session: %d", result);
+		LOG_ERROR("[obs-moq] Failed to publish broadcast to session: %d", result);

As per coding guidelines, **/*.{cpp,h,hpp} must use LOG_DEBUG(), LOG_INFO(), LOG_WARNING(), LOG_ERROR() with [obs-moq] prefix.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
LOG_INFO("Publishing broadcast: %s", path.c_str());
auto result = moq_origin_publish(origin, path.data(), path.size(), broadcast);
if (result < 0) {
LOG_ERROR("Failed to publish broadcast to session: %d", result);
LOG_INFO("[obs-moq] Publishing broadcast: %s", path.c_str());
auto result = moq_origin_publish(origin, path.data(), path.size(), broadcast);
if (result < 0) {
LOG_ERROR("[obs-moq] Failed to publish broadcast to session: %d", result);
🤖 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 29 - 33, Update the two logging calls to
include the required "[obs-moq]" prefix: change the LOG_INFO call that logs the
publishing path and the LOG_ERROR call inside the moq_origin_publish error
branch so their messages begin with "[obs-moq]". Locate the LOG_INFO("Publishing
broadcast: %s", path.c_str()) and LOG_ERROR("Failed to publish broadcast to
session: %d", result) statements (near the moq_origin_publish(origin,
path.data(), path.size(), broadcast) call) and prepend the prefix in their
format strings so they read e.g. LOG_INFO("[obs-moq] ...") and
LOG_ERROR("[obs-moq] ...").

@danrossi
Copy link
Copy Markdown
Contributor

danrossi commented Jun 4, 2026

The Cmake config fixes is in this PR for windows and mac. As it seems to be auto-generated and tested for Linux pkgconfig resolving. These resolve from the OBS deps that is already pulled while configuring. There was other changes required for windows like a debug console window needed.

#31

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