Skip to content

Normalize SIP codec preferences for PJSIP enumerations - #77

Merged
vaheed merged 1 commit into
mainfrom
vaheed/fix-502-bad-gateway-error
Sep 20, 2025
Merged

Normalize SIP codec preferences for PJSIP enumerations#77
vaheed merged 1 commit into
mainfrom
vaheed/fix-502-bad-gateway-error

Conversation

@vaheed

@vaheed vaheed commented Sep 20, 2025

Copy link
Copy Markdown
Owner

Summary

  • normalise SIP codec preference handling so friendly aliases map onto the codec identifiers returned by pjsua and record applied or missing codecs in the monitor log
  • document the codec alias behaviour in the README and sample environment file
  • cover the codec preference helper with a unit test

Testing

  • make test

https://chatgpt.com/codex/tasks/task_b_68ce5780d484832daf06ab4ad9f270cc

@vaheed
vaheed merged commit a2fe523 into main Sep 20, 2025
4 checks passed

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Codex Review: Here are some suggestions.

Reply with @codex fix comments to fix any unresolved comments.

About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you open a pull request for review, mark a draft as ready, or comment "@codex review". If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex fix this CI failure" or "@codex address that feedback".

Comment thread app/agent.py
Comment on lines +217 to +223
lookup_key = requested_name.lower()
matched_codec = available_exact.get(lookup_key)

if not matched_codec:
base_key = lookup_key.split("/")[0]
matched_codec = available_base.get(base_key)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[P1] Avoid silently aliasing full codec IDs to other variants

The alias fallback in _apply_codec_preferences splits every unmatched request at / and then uses the base token to pick any available codec with that prefix (lines 217‑223). If an operator provides a fully qualified codec identifier such as opus/16000/2 that is not advertised by PJSIP, this code will still match the first opus variant (e.g. opus/48000/2) and apply it without warning. The previous implementation only applied exact matches, so misconfigured or unavailable variants were clearly logged. With the new behaviour the system may negotiate a different sample rate than requested while logging the codec as successfully applied, making configuration mistakes hard to diagnose. Consider limiting the base-name fallback to requests that do not contain /, or emit a warning when a full ID falls back to a different variant.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant