Skip to content

js: add Opus dtx for voice WIP#1583

Open
nuts-rice wants to merge 9 commits into
moq-dev:mainfrom
nuts-rice:opus_dtx
Open

js: add Opus dtx for voice WIP#1583
nuts-rice wants to merge 9 commits into
moq-dev:mainfrom
nuts-rice:opus_dtx

Conversation

@nuts-rice

Copy link
Copy Markdown

addresses #1445 by setting usedtx to true when kind is voice.
Adds 6 tests so far for capture-playback on different kinds and testing silence-frames. I had to move some imports around for testing.

Todos are probably for benching bandwidth on voice calls.

nuts-rice and others added 3 commits June 12, 2026 09:32
Resolve the merge with main and finish the DTX-for-voice work. Main has
since landed the usedtx knob and the kind->application/signal plumbing,
so the standalone encoder-config.ts extraction is no longer needed: fold
all kind-derived Opus settings into opusKindDefaults() inside encoder.ts
and add DTX to the voice defaults.

Voice now enables discontinuous transmission by default (speech has gaps
that DTX collapses to tiny comfort-noise packets); an explicit OpusConfig
knob still overrides it. Drops the orphaned encoder-config.ts and moves
the tests to encoder.test.ts.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@kixelated kixelated marked this pull request as ready for review June 19, 2026 03:41
The previous commit exported toEncoderConfig so the in-package test could
import it, but audio/index.ts re-exports the encoder module with `export *`,
which leaked it into @moq/publish's public surface as Audio.toEncoderConfig.
Switch that barrel to a named re-export so the published API is unchanged;
the symbol stays importable within the package for the test.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: b962c8ec-7173-4add-8ec0-dd3edb605f0e

📥 Commits

Reviewing files that changed from the base of the PR and between e20fe68 and 375e83e.

📒 Files selected for processing (1)
  • js/publish/src/audio/encoder.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • js/publish/src/audio/encoder.ts

Walkthrough

An internal opusKindDefaults(kind) helper function is added to encoder.ts that maps the audio Kind to Opus encoder default settings: voice returns application: "voip", signal: "voice", and usedtx: true; music returns application: "audio" and signal: "music"; otherwise returns an empty object. The toEncoderConfig function's Opus config construction is updated to spread these kind defaults first and then merge in caller-provided opusOptions, so explicit options override defaults. The module-level documentation in types.ts is updated to mention DTX alongside application/signal as part of the kind-driven defaults.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title 'js: add Opus dtx for voice WIP' directly addresses the main change: adding Opus DTX (discontinuous transmission) support for voice audio, which is the core objective of the PR.
Description check ✅ Passed The description explains the purpose (addressing #1445 by enabling DTX for voice), mentions the test coverage added, and notes organizational changes to imports, all relating to the changeset.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
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

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
js/publish/src/audio/index.ts (1)

1-12: ⚡ Quick win

Add a module-level doc comment with @module.

This file is an entrypoint for the audio module but lacks the required module-level documentation.

📝 Suggested module doc comment
+/**
+ * Public API surface for the audio encoder module.
+ *
+ * Re-exports codec types and the {`@link` Encoder} class. Internal helpers like
+ * `toEncoderConfig` are intentionally excluded; import them directly from
+ * `./encoder` for in-package testing only.
+ *
+ * `@module`
+ */
+
 // toEncoderConfig is intentionally omitted: it's exported from ./encoder only so the in-package test
 // can import it, not as part of the public API.

As per coding guidelines: "Add a module-level doc comment to every entrypoint (a /** ... @module */ block at the top of each JS entrypoint file)".

🤖 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 `@js/publish/src/audio/index.ts` around lines 1 - 12, The audio module
entrypoint at index.ts is missing a module-level documentation comment with the
`@module` tag as required by the coding guidelines. Add a module-level JSDoc
comment (/** `@module` */) at the very top of the file before the existing comment
about toEncoderConfig being omitted. This documentation block should describe
the purpose of the audio module exports and serve as the entry point
documentation for the module.

Source: Coding guidelines

🤖 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 `@js/publish/src/audio/index.ts`:
- Around line 1-12: The audio module entrypoint at index.ts is missing a
module-level documentation comment with the `@module` tag as required by the
coding guidelines. Add a module-level JSDoc comment (/** `@module` */) at the very
top of the file before the existing comment about toEncoderConfig being omitted.
This documentation block should describe the purpose of the audio module exports
and serve as the entry point documentation for the module.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 6e398d1c-9944-4362-934e-e1361257192e

📥 Commits

Reviewing files that changed from the base of the PR and between df9e58a and e20fe68.

📒 Files selected for processing (2)
  • js/publish/src/audio/encoder.ts
  • js/publish/src/audio/index.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • js/publish/src/audio/encoder.ts

The test only restated the opusKindDefaults table, so it added little
beyond what the code already says. Removing it lets toEncoderConfig go
back to private and restores the plain `export *` barrel, leaving the
public API untouched by this change.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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