Make stream key (path) optional, defaulting to empty broadcast#33
Make stream key (path) optional, defaulting to empty broadcast#33
Conversation
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
WalkthroughThis 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 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 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.
🧹 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_stringalready falls back to""for unset keys. The real value of registeringget_defaultsis 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_stringdoes not returnNULLfor a validobs_data_t *.The null checks (
server_value ? server_value : "") inUpdate()are safe but likely redundant. Per OBS libobs convention,obs_data_get_stringreturns""— notNULL— when a key is missing from a validobs_data_tobject. The actual null risk that was causing the hang lived inobs_service_get_connect_info()(now guarded inmoq-output.cpp). These guards inUpdate()don't hurt, but they may mislead future readers into thinking this API can returnNULL.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
📒 Files selected for processing (3)
src/moq-output.cppsrc/moq-service.cppsrc/moq-service.h
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.
obs_service_get_connect_info before assigning to std::string.
https://claude.ai/code/session_01AH2RwNCd5nPs8hNHYmMv97