Skip to content

fix: sync callkit audio config with webrtc config#2095

Merged
greenfrvr merged 14 commits intofeat/callkit-telecom-integrationfrom
audio-callkit
Jan 28, 2026
Merged

fix: sync callkit audio config with webrtc config#2095
greenfrvr merged 14 commits intofeat/callkit-telecom-integrationfrom
audio-callkit

Conversation

@santhoshvai
Copy link
Copy Markdown
Member

@santhoshvai santhoshvai commented Jan 23, 2026

Overview

When CallKit activates the audio session and we must forward this via audioSessionDidActivate, WebRTC:

  • Increments its internal activation count
  • Sets isActive = YES
  • Clears any interruption state
  • Notifies delegates that audio can resume

This ensures WebRTC knows the session is already active and won't try to activate it again.

In this PR, we ensure that callkit audio config matches with our intended webrtc audio config. To avoid clashes and that webrtc audio unit always starts/resumes.

Why this matters:

  1. WebRTC stores its own configuration preferences in RTCAudioSessionConfiguration.webRTC()
  2. When WebRTC later needs to reconfigure audio (e.g., after interruptions), it uses these stored settings
  3. If you only configure AVAudioSession directly without updating WebRTC's stored config, there could be mismatches during audio route changes or interruptions

Summary by CodeRabbit

  • Chores
    • Added WebRTC dependency to improve audio session management across the platform.
    • Enhanced audio configuration handling to align with industry standards.
    • Simplified internal audio session lifecycle event handling for improved stability.
    • Updated package dependencies to support latest WebRTC integration.

✏️ Tip: You can customize this high-level summary in your review settings.

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Jan 23, 2026

⚠️ No Changeset found

Latest commit: 7b3cf05

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.

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

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Jan 23, 2026

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

  • 🔍 Trigger a full review
📝 Walkthrough

Walkthrough

The PR integrates WebRTC audio session management into the calling packages. It adds the stream-react-native-webrtc dependency, refactors AudioSessionManager to use RTCAudioSession APIs instead of manual AVAudioSession configuration, forwards CallKit lifecycle events from CallingxImpl to RTCAudioSession, adds conditional bypass logic in StreamInCallManager when CallingX is active, and removes redundant audio session event handling from setupCallingExpEvents.

Changes

Cohort / File(s) Summary
Dependency declarations
packages/react-native-callingx/Callingx.podspec, packages/react-native-callingx/package.json
Adds stream-react-native-webrtc as CocoaPods dependency, devDependency (v137.1.0), and peerDependency (>=137.1.0)
CallingX audio session integration
packages/react-native-callingx/ios/AudioSessionManager.swift
Replaces manual AVAudioSession configuration with RTCAudioSession.sharedInstance() API calls; applies WebRTC-derived sample rate and IO buffer duration via lock/unlock pattern
CallingX lifecycle event forwarding
packages/react-native-callingx/ios/CallingxImpl.swift
Adds RTCAudioSession lifecycle forwarding in didActivate/didDeactivate handlers; manages idle timer state via UIApplication on main thread
StreamInCallManager WebRTC integration
packages/react-native-sdk/ios/StreamInCallManager.swift
Applies WebRTC configuration (sample rate and IO buffer duration) to AVAudioSession during audio session category setup
StreamInCallManager bypass logic
packages/react-native-sdk/src/utils/internal/registerSDKGlobals.ts
Adds Platform-aware bypass checks for CallKit/CallingX in StreamInCallManager setup/start/stop methods to prevent conflicting audio session management
Audio session event cleanup
packages/react-native-sdk/src/utils/push/setupCallingExpEvents.ts
Removes didActivateAudioSession/didDeactivateAudioSession event listeners and handlers (now handled by CallingxImpl)

Sequence Diagram

sequenceDiagram
    participant CallKit
    participant CallingxImpl
    participant RTCAudioSession
    participant StreamInCallManager
    participant AVAudioSession

    CallKit->>CallingxImpl: didActivate audioSession
    CallingxImpl->>RTCAudioSession: audioSessionDidActivate()
    CallingxImpl->>AVAudioSession: manage idle timer
    CallingxImpl->>CallingxImpl: emit didActivateAudioSession

    Note over StreamInCallManager: registerSDKGlobals checks<br/>shouldBypassForCallKit()

    alt CallingX is managing audio
        StreamInCallManager->>StreamInCallManager: bypass setup/start/stop
    else CallingX inactive
        StreamInCallManager->>RTCAudioSession: apply WebRTC config
        RTCAudioSession->>AVAudioSession: configure sample rate & IO buffer
    end

    CallKit->>CallingxImpl: didDeactivate audioSession
    CallingxImpl->>RTCAudioSession: audioSessionDidDeactivate()
    CallingxImpl->>AVAudioSession: restore idle timer
    CallingxImpl->>CallingxImpl: emit didDeactivateAudioSession
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • oliverlaz
  • greenfrvr

Poem

🐰 Whiskers twitch with WebRTC delight,
Audio sessions now flow just right,
CallKit and RTCAudioSession align,
No more conflicts—the harmony's fine!
The streams flow smoother, bugs take flight. 🎧

🚥 Pre-merge checks | ✅ 1 | ❌ 2
❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Description check ⚠️ Warning The pull request description is missing entirely. The template requires at least an Overview section and implementation notes, but no description was provided by the author. Add a pull request description following the repository template, including an Overview section explaining the changes and Implementation notes detailing how the audio config synchronization was achieved.
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.
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main objective of the changeset: synchronizing CallKit audio configuration with WebRTC configuration, which is reflected throughout all modified files.

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


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.

…' into audio-callkit

# Conflicts:
#	packages/react-native-callingx/ios/CallingxImpl.swift
@santhoshvai
Copy link
Copy Markdown
Member Author

@coderabbitai full review

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Jan 23, 2026

✅ Actions performed

Full review triggered.

Copy link
Copy Markdown
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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
packages/react-native-callingx/ios/AudioSessionManager.swift (1)

3-39: RTCAudioSessionConfiguration API is not available in stream-react-native-webrtc v137.x—refactor to use AVAudioSession directly or Stream's callManager.

RTCAudioSessionConfiguration was removed in react-native-webrtc 111.x and is not present in v137.x. The calls to RTCAudioSessionConfiguration.webRTC(), .setWebRTC(), and related configuration will fail at runtime.

Two recommended approaches:

  1. Use Stream's callManager (preferred): configure audio via callManager.start({ audioRole: "communicator", deviceEndpointType: "speaker" }) and callManager.stop(). This is Stream SDK's supported pattern and avoids manual WebRTC audio management.
  2. Use AVAudioSession directly (if manual control is required): configure category, mode, and options on AVAudioSession.sharedInstance() and set active state appropriately for background operation. Avoid the removed RTCAudioSessionConfiguration API entirely.

Additionally, ensure background audio capability is enabled in Info.plist (Background Modes: Audio, AirPlay, and Picture in Picture) to maintain the audio connection in background as mentioned in the design notes.

🤖 Fix all issues with AI agents
In `@packages/react-native-sdk/src/utils/internal/registerSDKGlobals.ts`:
- Around line 30-49: Wrap each call to StreamInCallManagerNativeModule in
try/catch so native errors don’t bubble up: in the setup, start, and stop
methods (while keeping the shouldBypassForCallKit() early-return) surround calls
to setDefaultAudioDeviceEndpointType and setup inside a try/catch in setup, and
wrap StreamInCallManagerNativeModule.start() and
StreamInCallManagerNativeModule.stop() each in their own try/catch; on catch,
log a non-fatal warning (e.g., console.warn or processLogger.warn) with a clear
tag like "[StreamInCallManager.<method>]" and the error, then continue.

santhoshvai and others added 9 commits January 23, 2026 13:43
…ew (#2093)

### 💡 Overview

This PR fixes an issue where the screen share overlay styling was
applied to camera thumbnails of participants sharing their screen, so it
now only affects the screen share track.

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

* **Bug Fixes**
* Enhanced screen-share track detection in debug participant views for
more accurate display state identification.

<sub>✏️ Tip: You can customize this high-level summary in your review
settings.</sub>

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
…2092)

Switch to `partialUpdateUser`, as `upsertUser` seems to be overwriting
previously set custom props.
…2096)

### 💡 Overview

This PR aligns the default audio output device selection from server
settings as per native [iOS
SDK](https://github.com/GetStream/stream-video-swift/blob/12c2342e62a7d5d1f2f3516b57843bf367d3ea53/Sources/StreamVideo/Models/Extensions/CallSettingsResponse%2BSettingsPriority.swift#L19).

### 📝 Implementation notes

```
    /// The priority order is as follows:
    /// 1. If video camera is set to be on by default, speaker is enabled
    /// 2. If audio speaker is set to be on by default, speaker is enabled
    /// 3. If the default audio device is set to speaker, speaker is enabled
```

🎫 Ticket: https://linear.app/stream/issue/RN-338

📑 Docs: https://github.com/GetStream/docs-content/pull/<id>


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

* **Refactor**
  * Enhanced audio device configuration management within the SDK.
  * Improved consistency in audio output device selection handling.
* Optimized internal device setup processes for better maintainability.

<sub>✏️ Tip: You can customize this high-level summary in your review
settings.</sub>

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
@greenfrvr greenfrvr merged commit 4132308 into feat/callkit-telecom-integration Jan 28, 2026
19 checks passed
@greenfrvr greenfrvr deleted the audio-callkit branch January 28, 2026 14:55
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.

4 participants