Skip to content

Conversation

@pierre-lehnen-rc
Copy link
Contributor

@pierre-lehnen-rc pierre-lehnen-rc commented Nov 4, 2025

Proposed changes (including videos or screenshots)

Issue(s)

VGA-39

Steps to test or reproduce

Further comments

Summary by CodeRabbit

  • New Features

    • Improved call negotiation logic to proactively align audio send/receive direction before and after offer/answer exchange, improving hold/unhold behavior.
  • Bug Fixes

    • Reduced redundant renegotiations and increased stability during call setup and answers by targeting audio tracks more precisely.

@dionisio-bot
Copy link
Contributor

dionisio-bot bot commented Nov 4, 2025

Looks like this PR is not ready to merge, because of the following issues:

  • This PR is targeting the wrong base branch. It should target 7.13.0, but it targets 7.12.0

Please fix the issues and try again

If you have any trouble, please check the PR guidelines

@changeset-bot
Copy link

changeset-bot bot commented Nov 4, 2025

⚠️ No Changeset found

Latest commit: 36dc40f

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@pierre-lehnen-rc pierre-lehnen-rc marked this pull request as ready for review November 4, 2025 17:36
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 4, 2025

Walkthrough

Adds audio-transceiver direction management around WebRTC negotiation: new helpers to get audio transceivers and to update their directions before and after SDP offer/answer flows; integrates these into createOffer, createAnswer, and setRemoteDescription paths with logging.

Changes

Cohort / File(s) Summary
Processor: audio transceiver direction logic
packages/media-signaling/src/lib/services/webrtc/Processor.ts
Adds getAudioTransceivers(), updateAudioDirectionBeforeNegotiation() and updateAudioDirectionAfterNegotiation(); uses them in createOffer, createAnswer, and setRemoteDescription; replaces direct transceiver queries with the helper; logs added/changed transceiver directions and preserves existing error handling.

Sequence Diagram(s)

sequenceDiagram
    participant App as Application
    participant Proc as MediaCallWebRTCProcessor
    participant PC as RTCPeerConnection
    participant T as Audio Transceivers

    App->>Proc: createOffer()
    Proc->>Proc: updateAudioDirectionBeforeNegotiation()
    Proc->>T: set desired directions (sendrecv/sendonly)
    Proc->>PC: createOffer()
    PC-->>Proc: SDP offer
    Proc->>PC: setLocalDescription(offer)
    Proc->>Proc: updateAudioDirectionAfterNegotiation()
    Proc->>T: reconcile directions
    Proc-->>App: return offer

    App->>Proc: setRemoteDescription(offer/answer)
    Proc->>Proc: (if offer) updateAudioDirectionBeforeNegotiation()
    Proc->>PC: setRemoteDescription()
    Proc->>Proc: (if answer) updateAudioDirectionAfterNegotiation()
    Proc-->>App: complete
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20–30 minutes

  • Single file with multiple new helper methods and integrations across negotiation paths.
  • Review focus:
    • Correctness/timing of pre- and post-negotiation direction updates.
    • getAudioTransceivers() filtering correctness for audio-only transceivers.
    • Edge cases: transceivers with direction "stopped", existing send/recv states, and logging paths.

Possibly related PRs

Suggested reviewers

  • gabriellsh
  • tassoevan

Poem

🐰 I nudged the transceivers, one by one,
Before the offer, then after it's done,
Directions tuned, no needless repeat,
Audio hops smoothly — clean and neat! 🎶🐇

Pre-merge checks and finishing touches

✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: updating audio direction handling based on call hold status, which aligns with the implementation of three new methods managing audio transceiver directions around WebRTC negotiation.
Linked Issues check ✅ Passed The PR implements dynamic audio direction negotiation reflecting audio track state through updateAudioDirectionBeforeNegotiation() and updateAudioDirectionAfterNegotiation() methods, directly addressing VGA-39's requirement.
Out of Scope Changes check ✅ Passed All changes are focused on audio direction management during WebRTC negotiation in the Processor.ts file, with no unrelated modifications detected beyond the scope of VGA-39.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch chore/sync-on-hold-audio-direction

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.

@codecov
Copy link

codecov bot commented Nov 4, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 67.85%. Comparing base (7367c89) to head (36dc40f).
⚠️ Report is 44 commits behind head on feat/voip-sync-audio-direction.

Additional details and impacted files

Impacted file tree graph

@@                        Coverage Diff                         @@
##           feat/voip-sync-audio-direction   #37381      +/-   ##
==================================================================
- Coverage                           68.03%   67.85%   -0.19%     
==================================================================
  Files                                3361     3345      -16     
  Lines                              115574   114470    -1104     
  Branches                            20796    20721      -75     
==================================================================
- Hits                                78636    77668     -968     
+ Misses                              34254    34124     -130     
+ Partials                             2684     2678       -6     
Flag Coverage Δ
e2e 57.57% <ø> (+0.08%) ⬆️
unit 71.87% <ø> (-0.25%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@pierre-lehnen-rc pierre-lehnen-rc added this to the 7.13.0 milestone Nov 4, 2025
@pierre-lehnen-rc pierre-lehnen-rc added the stat: QA assured Means it has been tested and approved by a company insider label Nov 4, 2025
@dionisio-bot dionisio-bot bot added the stat: ready to merge PR tested and approved waiting for merge label Nov 4, 2025
Copy link
Contributor

@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: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Jira integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between d94d8d1 and 36dc40f.

📒 Files selected for processing (1)
  • packages/media-signaling/src/lib/services/webrtc/Processor.ts (5 hunks)
🧰 Additional context used
🧠 Learnings (1)
📓 Common learnings
Learnt from: pierre-lehnen-rc
Repo: RocketChat/Rocket.Chat PR: 36718
File: packages/media-signaling/src/lib/Call.ts:633-642
Timestamp: 2025-09-23T00:27:05.438Z
Learning: In PR #36718, pierre-lehnen-rc prefers to maintain consistency with the old architecture patterns for DTMF handling rather than implementing immediate validation improvements, deferring enhancements to future work.
🔇 Additional comments (7)
packages/media-signaling/src/lib/services/webrtc/Processor.ts (7)

111-120: LGTM! Good refactoring to use the helper method.

The refactoring to use getAudioTransceivers() improves consistency, and the added logging will help with debugging.


122-123: Appropriate placement of direction update.

Calling updateAudioDirectionBeforeNegotiation() before ICE restart and offer creation correctly sets the desired direction based on current state.


173-173: LGTM! Consistent use of helper method.


195-199: LGTM! Proper reconciliation after answer.

Calling updateAudioDirectionAfterNegotiation() after setting the local answer appropriately reconciles the transceiver direction with the negotiated result.


213-221: LGTM! Correct direction management in remote description flow.

The placement of direction updates is appropriate:

  • Before processing a remote offer: set desired direction
  • After processing a remote answer: reconcile with negotiated result

331-355: Reconciliation logic looks sound, pending verification of desired direction.

The logic correctly avoids redundant renegotiations by adjusting direction to match currentDirection when the actual result is acceptable. The method appropriately:

  • Skips transceivers not set to desiredDirection
  • Skips when currentDirection is null, 'stopped', or already matches
  • Updates direction when currentDirection is an acceptableDirection

However, the correctness depends on the direction values set in updateAudioDirectionBeforeNegotiation() (see previous comment).


357-361: No issues found with the audio transceiver filter.

The filter correctly identifies audio transceivers in all scenarios. When addTransceiver('audio') is called at line 117, the resulting transceiver's receiver.track.kind is set to 'audio' immediately per the WebRTC specification, even before a sender track exists. The filter's OR logic (sender.track?.kind === 'audio' || receiver.track?.kind === 'audio') ensures newly created transceivers are caught by the receiver track condition. The optional chaining safely handles null sender tracks.

@pierre-lehnen-rc pierre-lehnen-rc merged commit 465e541 into feat/voip-sync-audio-direction Nov 5, 2025
20 checks passed
@pierre-lehnen-rc pierre-lehnen-rc deleted the chore/sync-on-hold-audio-direction branch November 5, 2025 14:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

stat: QA assured Means it has been tested and approved by a company insider stat: ready to merge PR tested and approved waiting for merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants