Skip to content

Generic sink#34

Merged
kixelated merged 3 commits intomainfrom
improve-sink
Mar 3, 2026
Merged

Generic sink#34
kixelated merged 3 commits intomainfrom
improve-sink

Conversation

@kixelated
Copy link
Collaborator

No description provided.

@coderabbitai
Copy link

coderabbitai bot commented Mar 3, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 78d81e3 and 373cf7d.

📒 Files selected for processing (2)
  • CLAUDE.md
  • src/sink/imp.rs

Walkthrough

The change removes the gst-base dependency and refactors MoqSink to extend gst::Element instead of gst_base::BaseSink. MoqSink's internal state shifts from Arc<Mutex> to Mutex<Option> and adds per-pad decoding with request-based pads. New methods include change_state, request_new_pad, and release_pad. The justfile introduces RUST_LOG defaults, adds GST_PLUGIN_PATH_1_0, and updates pipelines to use parsebin and moqsrc. Documentation and examples rename hang*/hangsrc/hangsink terminology to moq*/moqsrc/moqsink and adjust TLS/configuration and environment variable descriptions.

🚥 Pre-merge checks | ❌ 3

❌ Failed checks (2 warnings, 1 inconclusive)

Check name Status Explanation Resolution
Description check ⚠️ Warning No pull request description was provided, making it impossible to assess whether the description is related to the changeset. Add a description explaining the changes, such as the refactoring from BaseSink to Element, per-pad decoding pipeline, and other architectural modifications.
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.
Title check ❓ Inconclusive The title 'Generic sink' is vague and does not clearly describe the main change. While the PR does modify the sink implementation, the title lacks specificity about what was made generic or why. Use a more descriptive title such as 'Refactor MoqSink to use generic Element instead of BaseSink' to better convey the primary architectural change.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch improve-sink

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

@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

🧹 Nitpick comments (2)
src/sink/imp.rs (2)

14-20: Consider using new_current_thread() for true single-threaded runtime.

The coding guidelines specify "single-threaded Tokio worker pool." Using new_multi_thread() with worker_threads(1) creates a multi-threaded runtime constrained to one worker, which has different semantics than new_current_thread() (e.g., spawns a separate thread pool even with one worker).

♻️ Suggested change
 pub static RUNTIME: LazyLock<tokio::runtime::Runtime> = LazyLock::new(|| {
-	tokio::runtime::Builder::new_multi_thread()
+	tokio::runtime::Builder::new_current_thread()
 		.enable_all()
-		.worker_threads(1)
 		.build()
 		.unwrap()
 });

Based on learnings: "Use single-threaded Tokio worker pool for async runtime in plugin elements".

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/sink/imp.rs` around lines 14 - 20, The RUNTIME static is built with
tokio::runtime::Builder::new_multi_thread().worker_threads(1) which yields a
multi-threaded runtime constrained to one worker; change the construction of the
RUNTIME static (symbol: RUNTIME) to use a single-threaded runtime API (e.g.,
tokio::runtime::Builder::new_current_thread() or
tokio::runtime::Runtime::new_current_thread equivalent) and retain required
options (like enable_all()) so the runtime is truly single-threaded per the
"single-threaded Tokio worker pool" guideline; update the initialization closure
for RUNTIME accordingly and remove the multi_thread builder usage.

286-302: Consider logging when using default Opus parameters.

When channels or rate are not present in caps, the code silently falls back to defaults (2 channels, 48000 Hz). This could produce incorrect OpusHead if the actual stream differs. A debug log would help diagnose issues.

💡 Suggested enhancement
 			moq_mux::import::DecoderFormat::Opus => {
 				// Synthesize OpusHead from caps fields
-				let channels: i32 = structure.get("channels").unwrap_or(2);
-				let rate: i32 = structure.get("rate").unwrap_or(48000);
+				let channels: i32 = structure.get("channels").unwrap_or_else(|_| {
+					gst::debug!(CAT, obj = pad, "Opus caps missing channels, defaulting to 2");
+					2
+				});
+				let rate: i32 = structure.get("rate").unwrap_or_else(|_| {
+					gst::debug!(CAT, obj = pad, "Opus caps missing rate, defaulting to 48000");
+					48000
+				});
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/sink/imp.rs` around lines 286 - 302, The Opus branch
(moq_mux::import::DecoderFormat::Opus) currently silently uses defaults for
channels and rate via structure.get(...).unwrap_or(...); modify this to detect
when the caps fields are missing (e.g., check structure.get("channels") and
structure.get("rate") for None) and emit a debug/log message indicating which
default(s) are being used and their values before constructing opus_head and
calling decoder.initialize; reference the DecoderFormat::Opus match arm, the
local variables channels and rate, the structure lookup, and the
decoder.initialize(&mut data) call so the log is added in the correct place (and
add the appropriate logging import/level if the crate doesn't already provide
one).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@CLAUDE.md`:
- Line 87: The documentation line referencing GST_PLUGIN_PATH is out of sync
with the justfile which now uses GST_PLUGIN_PATH_1_0; update the CLAUDE.md entry
that currently says `GST_PLUGIN_PATH` to instead mention `GST_PLUGIN_PATH_1_0`
(or document both with a note that the justfile sets GST_PLUGIN_PATH_1_0) so the
docs and the justfile are consistent.

In `@src/sink/imp.rs`:
- Around line 282-284: The code currently calls map_readable().unwrap() which
can panic; replace the unwrap with proper error propagation by using
map_readable()? (or match/map_err to convert the mapping error into the
function's error type) and handle the Result before creating bytes::Bytes and
calling decoder.initialize(&mut data)?; update the variables map and data
accordingly so mapping failures return an error instead of panicking (affecting
the map_readable, data, and decoder.initialize calls).

---

Nitpick comments:
In `@src/sink/imp.rs`:
- Around line 14-20: The RUNTIME static is built with
tokio::runtime::Builder::new_multi_thread().worker_threads(1) which yields a
multi-threaded runtime constrained to one worker; change the construction of the
RUNTIME static (symbol: RUNTIME) to use a single-threaded runtime API (e.g.,
tokio::runtime::Builder::new_current_thread() or
tokio::runtime::Runtime::new_current_thread equivalent) and retain required
options (like enable_all()) so the runtime is truly single-threaded per the
"single-threaded Tokio worker pool" guideline; update the initialization closure
for RUNTIME accordingly and remove the multi_thread builder usage.
- Around line 286-302: The Opus branch (moq_mux::import::DecoderFormat::Opus)
currently silently uses defaults for channels and rate via
structure.get(...).unwrap_or(...); modify this to detect when the caps fields
are missing (e.g., check structure.get("channels") and structure.get("rate") for
None) and emit a debug/log message indicating which default(s) are being used
and their values before constructing opus_head and calling decoder.initialize;
reference the DecoderFormat::Opus match arm, the local variables channels and
rate, the structure lookup, and the decoder.initialize(&mut data) call so the
log is added in the correct place (and add the appropriate logging import/level
if the crate doesn't already provide one).

ℹ️ Review info

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c9e71aa and 78d81e3.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (5)
  • CLAUDE.md
  • Cargo.toml
  • justfile
  • src/sink/imp.rs
  • src/sink/mod.rs
💤 Files with no reviewable changes (1)
  • Cargo.toml

@kixelated kixelated merged commit 3d2999a into main Mar 3, 2026
1 check passed
@kixelated kixelated deleted the improve-sink branch March 3, 2026 18:47
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.

1 participant