Add multi encoder output support#29
Conversation
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
WalkthroughThe output module was refactored from single scalar media track handles to per-encoder track maps ( 🚥 Pre-merge checks | ✅ 1 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 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-output.cpp (2)
158-166: Consider reducing redundant map lookups.The current pattern performs two
find()calls when the encoder is new. You could combine the check and retrieval usingtry_emplaceor cache the iterator.♻️ Optional: Single lookup pattern
- if (audio_tracks.find(encoder) == audio_tracks.end()) - AudioInit(encoder); - - auto it = audio_tracks.find(encoder); - if (it == audio_tracks.end() || it->second < 0) { + auto [it, inserted] = audio_tracks.try_emplace(encoder, -1); + if (inserted) + AudioInit(encoder); + + if (it->second < 0) { // We failed to initialize the audio track, so we can't write any data. return; }Note: This would require
AudioInitto update the existing map entry rather than insert.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/moq-output.cpp` around lines 158 - 166, The code does two audio_tracks.find(encoder) lookups; change to a single lookup and update path: call AudioInit(encoder) only when necessary and then obtain the iterator once, or use audio_tracks.try_emplace(encoder, /*default value*/ ) before inspecting the value so you can check and read the entry via the returned iterator. Ensure AudioInit either writes the map entry (so try_emplace is appropriate) or, if AudioInit performs initialization externally, call it conditionally and then call audio_tracks.find(encoder) only once to get the iterator (use the iterator result to check it->second and assign handle).
16-18: Initializer list order doesn't match declaration order.Members are initialized in declaration order (
origin,session,broadcast), but the init list specifiesbroadcastbeforesession. This mismatch may trigger-Wreorderwarnings and is misleading to readers.♻️ Proposed fix to match declaration order
MoQOutput::MoQOutput(obs_data_t *, obs_output_t *output) : output(output), server_url(), path(), total_bytes_sent(0), connect_time_ms(0), origin(moq_origin_create()), - broadcast(moq_publish_create()), - session(0) + session(0), + broadcast(moq_publish_create()) { }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/moq-output.cpp` around lines 16 - 18, The initializer list orders members as origin, broadcast, session but the class declares them as origin, session, broadcast; reorder the initializer list to match declaration order by placing session(0) before broadcast(moq_publish_create()) so the members are initialized in the declared sequence (adjust the constructor that currently initializes origin, broadcast, session accordingly).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@src/moq-output.cpp`:
- Around line 158-166: The code does two audio_tracks.find(encoder) lookups;
change to a single lookup and update path: call AudioInit(encoder) only when
necessary and then obtain the iterator once, or use
audio_tracks.try_emplace(encoder, /*default value*/ ) before inspecting the
value so you can check and read the entry via the returned iterator. Ensure
AudioInit either writes the map entry (so try_emplace is appropriate) or, if
AudioInit performs initialization externally, call it conditionally and then
call audio_tracks.find(encoder) only once to get the iterator (use the iterator
result to check it->second and assign handle).
- Around line 16-18: The initializer list orders members as origin, broadcast,
session but the class declares them as origin, session, broadcast; reorder the
initializer list to match declaration order by placing session(0) before
broadcast(moq_publish_create()) so the members are initialized in the declared
sequence (adjust the constructor that currently initializes origin, broadcast,
session accordingly).
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 385986ea-3ef3-4740-917c-ea7bf03f043e
📒 Files selected for processing (2)
src/moq-output.cppsrc/moq-output.h
Reorder constructor initializer list to match member declaration order (origin, session, broadcast). Reduce double find() calls in AudioData and VideoData to a single lookup each. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
thanks mr @Qizot |
No description provided.