Skip to content

Make stream key (path) optional, defaulting to empty broadcast#33

Open
kixelated wants to merge 1 commit intomainfrom
claude/optional-stream-key-r7er0
Open

Make stream key (path) optional, defaulting to empty broadcast#33
kixelated wants to merge 1 commit intomainfrom
claude/optional-stream-key-r7er0

Conversation

@kixelated
Copy link
Copy Markdown
Collaborator

The Path field on the MoQ service was effectively required: if a user
left it blank, obs_service_get_connect_info could return null, which
the output then assigned to a std::string — undefined behaviour that
manifested as a hang at start-of-stream.

  • Treat the key/path as optional and default to "" via get_defaults.
  • Null-guard the values returned by obs_data_get_string and
    obs_service_get_connect_info before assigning to std::string.
  • Relabel the property as "Path (optional)" in the UI.

https://claude.ai/code/session_01AH2RwNCd5nPs8hNHYmMv97

The Path field on the MoQ service was effectively required: if a user
left it blank, obs_service_get_connect_info could return null, which
the output then assigned to a std::string — undefined behaviour that
manifested as a hang at start-of-stream.

- Treat the key/path as optional and default to "" via get_defaults.
- Null-guard the values returned by obs_data_get_string and
  obs_service_get_connect_info before assigning to std::string.
- Relabel the property as "Path (optional)" in the UI.

https://claude.ai/code/session_01AH2RwNCd5nPs8hNHYmMv97
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 6, 2026

Walkthrough

This pull request enhances NULL safety in the MoQ service implementation and adds support for default settings. Changes include: guarding against NULL results when retrieving server URL and stream key in MoQOutput::Start(), adding a new Defaults() function to register default settings values, updating the Update() function to safely read string settings with null checks, and registering a new get_defaults callback in the service info. Additionally, the UI label for the key field is updated from "Path" to "Path (optional)" for clarity.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title directly describes the main change: making the stream key/path optional with empty string defaults, which aligns with the primary objective of the PR.
Description check ✅ Passed The description is directly related to the changeset, explaining the problem being solved and the specific changes made across all modified files.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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 docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/optional-stream-key-r7er0
✨ Simplify code
  • Create PR with simplified code
  • Commit simplified code in branch claude/optional-stream-key-r7er0

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.

🧹 Nitpick comments (2)
src/moq-service.cpp (2)

21-25: 💤 Low value

Defaults() sets empty-string defaults that are already the libobs fallback.

obs_data_set_default_string(settings, "server", "") and the "key" counterpart are no-ops in practice — obs_data_get_string already falls back to "" for unset keys. The real value of registering get_defaults is framework-level (OBS resets and profile creation), but a non-trivial default (e.g., a placeholder URL) would give this more practical benefit. As-is it's harmless but worth reconsidering if a sensible default server URL exists for this backend.

🤖 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-service.cpp` around lines 21 - 25, The Defaults method currently
calls obs_data_set_default_string(settings, "server", "") and
obs_data_set_default_string(settings, "key", "") which are no-ops because
obs_data_get_string already defaults to ""—either remove these lines (or the
Defaults override) or set a non-trivial default value; update
MoQService::Defaults to either drop the empty-string defaults or replace the
"server" default with a sensible placeholder URL (e.g., "https://example.com")
and populate "key" with a meaningful placeholder if appropriate so the
get_defaults call provides practical benefit.

14-19: 💤 Low value

obs_data_get_string does not return NULL for a valid obs_data_t *.

The null checks (server_value ? server_value : "") in Update() are safe but likely redundant. Per OBS libobs convention, obs_data_get_string returns "" — not NULL — when a key is missing from a valid obs_data_t object. The actual null risk that was causing the hang lived in obs_service_get_connect_info() (now guarded in moq-output.cpp). These guards in Update() don't hurt, but they may mislead future readers into thinking this API can return NULL.

Does obs_data_get_string return NULL or empty string when the key is not found in libobs?
🤖 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-service.cpp` around lines 14 - 19, The Update() method currently does
redundant NULL checks around obs_data_get_string (server_value and key_value)
even though obs_data_get_string returns an empty string for missing keys;
simplify by assigning server and path directly from obs_data_get_string without
the ternary fallbacks (refer to Update(), server, path, and obs_data_get_string)
and keep the real NULL guard that was added around
obs_service_get_connect_info() in moq-output.cpp to handle the actual null risk.
🤖 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.

Nitpick comments:
In `@src/moq-service.cpp`:
- Around line 21-25: The Defaults method currently calls
obs_data_set_default_string(settings, "server", "") and
obs_data_set_default_string(settings, "key", "") which are no-ops because
obs_data_get_string already defaults to ""—either remove these lines (or the
Defaults override) or set a non-trivial default value; update
MoQService::Defaults to either drop the empty-string defaults or replace the
"server" default with a sensible placeholder URL (e.g., "https://example.com")
and populate "key" with a meaningful placeholder if appropriate so the
get_defaults call provides practical benefit.
- Around line 14-19: The Update() method currently does redundant NULL checks
around obs_data_get_string (server_value and key_value) even though
obs_data_get_string returns an empty string for missing keys; simplify by
assigning server and path directly from obs_data_get_string without the ternary
fallbacks (refer to Update(), server, path, and obs_data_get_string) and keep
the real NULL guard that was added around obs_service_get_connect_info() in
moq-output.cpp to handle the actual null risk.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: a773c95e-cc9f-4628-8b9e-423d1d06b449

📥 Commits

Reviewing files that changed from the base of the PR and between ae7df7a and 4714a35.

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

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