Skip to content

Comments

feat: Migrate WebRTC package namespace from org.webrtc to io.getstream.webrtc#1620

Open
PratimMallick wants to merge 12 commits intodevelop-v2from
repackaged_webrtc_branch
Open

feat: Migrate WebRTC package namespace from org.webrtc to io.getstream.webrtc#1620
PratimMallick wants to merge 12 commits intodevelop-v2from
repackaged_webrtc_branch

Conversation

@PratimMallick
Copy link
Contributor

@PratimMallick PratimMallick commented Feb 20, 2026

Goal

This PR replaces the upstream WebRTC dependency (org.webrtc) with a repackaged version published under the io.getstream.webrtc namespace.

Implementation

  • Replaces io.getstream:stream-video-webrtc-android with
    io.getstream:stream-video-webrtc-android-repackaged (v137.1.1)
  • Migrates all imports across 50 source files from org.webrtc.*
    io.getstream.webrtc.*
  • Updates ProGuard consumer rules and baseline profile includes to reflect
    the new namespace
  • Bumps streamNoiseCancellation from 1.0.42.0.0(having the same repackaged webrtc)
  • Baseline profile (build.gradle.kts): Updated class filter from
    org.webrtc.**io.getstream.webrtc.**
  • ProGuard rules (consumer-proguard-rules.pro): Updated keep rule
    from -keep class org.webrtc.**-keep class io.getstream.webrtc.**

Breaking Changes ⚠️

This is a breaking change for any app or library that:

  1. Directly imports org.webrtc.* — All such imports must be updated
    to io.getstream.webrtc.*

  2. Uses public APIs that expose WebRTC types — The following public
    APIs have changed their parameter/return types from org.webrtc.*
    to io.getstream.webrtc.*

Testing

  • ./gradlew :stream-video-android-core:assembleDebug — confirms
    successful compilation with the new package
  • ./gradlew :stream-video-android-core:test — unit tests pass
    with repackaged WebRTC classes
  • ./gradlew :stream-video-android-core:connectedDebugAndroidTest
    instrumented tests pass on a real device (validates WebRTC at runtime)
  • Manually verify a video call works end-to-end (camera, mic,
    screen share)
  • Verify VideoFilter / AudioFilter custom implementations compile
    against the new namespace

☑️Contributor Checklist

General

  • I have signed the Stream CLA (required)
  • Assigned a person / code owner group (required)
  • Thread with the PR link started in a respective Slack channel (required internally)
  • PR targets the develop branch
  • PR is linked to the GitHub issue it resolves

Code & documentation

  • Changelog is updated with client-facing changes
  • New code is covered by unit tests
  • Comparison screenshots added for visual changes
  • Affected documentation updated (KDocs, docusaurus, tutorial)
  • Tutorial starter kit updated
  • Examples/guides starter kits updated (stream-video-examples)

☑️Reviewer Checklist

  • XML sample runs & works
  • Compose sample runs & works
  • Tutorial starter kit
  • Example starter kits work
  • UI Changes correct (before & after images)
  • Bugs validated (bugfixes)
  • New feature tested and works
  • Release notes and docs clearly describe changes
  • All code we touched has new or updated KDocs
  • Check the SDK Size Comparison table in the CI logs

🎉 GIF

Please provide a suitable gif that describes your work on this pull request

Summary by CodeRabbit

  • Bug Fixes

    • Fixed Bluetooth audio device handling to work with current Android APIs
    • Improved audio device enumeration and selection logic
  • Dependencies

    • Removed audioswitch dependency
    • Updated noise cancellation to version 2.0.0
  • Improvements

    • Enhanced audio device management compatibility across Android versions

PratimMallick and others added 12 commits November 13, 2025 16:35
…amespace = "io.getstream.webrtc" instead of "org.webrtc"
…m-video-android into repackaged_webrtc_branch

# Conflicts:
#	build.gradle.kts
…nto repackaged_webrtc_branch

# Conflicts:
#	build.gradle.kts
#	demo-app/src/main/kotlin/io/getstream/video/android/util/StreamVideoInitHelper.kt
#	stream-video-android-core/api/stream-video-android-core.api
#	stream-video-android-core/src/main/kotlin/io/getstream/video/android/core/call/RtcSession.kt
#	stream-video-android-core/src/main/kotlin/io/getstream/video/android/core/call/video/FilterVideoProcessor.kt
#	stream-video-android-core/src/test/kotlin/io/getstream/video/android/core/rtc/RtcSessionTest2.kt
…d into repackaged_webrtc_branch

# Conflicts:
#	stream-video-android-core/build.gradle.kts
@PratimMallick PratimMallick requested a review from a team as a code owner February 20, 2026 07:16
@github-actions
Copy link
Contributor

github-actions bot commented Feb 20, 2026

PR checklist ✅

All required conditions are satisfied:

  • Title length is OK (or ignored by label).
  • At least one pr: label exists.
  • Sections ### Goal, ### Implementation, and ### Testing are filled.

🎉 Great job! This PR is ready for review.

@PratimMallick PratimMallick changed the base branch from develop to develop-v2 February 20, 2026 07:16
@coderabbitai
Copy link

coderabbitai bot commented Feb 20, 2026

Caution

Review failed

Failed to post review comments

Walkthrough

This PR replaces Twilio's AudioSwitch library with a custom audio management system, migrates WebRTC dependencies from org.webrtc to io.getstream.webrtc packages, updates Bluetooth permission handling, and refactors audio device selection logic using new AudioDeviceManager interface with API-specific implementations.

Changes

Cohort / File(s) Summary
Build & Dependency Management
gradle/libs.versions.toml, demo-app/build.gradle.kts, stream-video-android-core/build.gradle.kts
Removed audioswitch dependency, updated streamNoiseCancellation version to 2.0.0, renamed stream-webrtc library to stream-video-webrtc-android-repackaged.
WebRTC Package Migration
stream-video-android-core/api/stream-video-android-core.api, stream-video-android-core/consumer-proguard-rules.pro, scripts/repackage/*, stream-video-android-core/src/main/kotlin/io/getstream/video/android/core/.../connection/*, stream-video-android-core/src/main/kotlin/io/getstream/webrtc/android/ui/*, stream-video-android-core/src/main/kotlin/io/getstream/video/android/core/call/*, stream-video-android-ui-compose/*, stream-video-android-ui-core/*, stream-video-android-ui-xml/*
Updated 60+ files to import WebRTC classes from io.getstream.webrtc instead of org.webrtc; updated ProGuard rules and API definitions accordingly.
Audio Device Management (New Interfaces)
stream-video-android-core/src/main/kotlin/io/getstream/video/android/core/audio/AudioDeviceManager.kt, AudioHandler.kt, StreamAudioDevice.kt, StreamAudioManager.kt
Introduced AudioDeviceManager interface, refactored AudioHandler interface (removed AudioSwitchHandler), updated StreamAudioDevice to use AudioDeviceInfo instead of AudioDevice, and added StreamAudioManager compatibility layer for API-level differences.
Audio Device Management (New Implementations)
stream-video-android-core/src/main/kotlin/io/getstream/video/android/core/audio/LegacyAudioDeviceManager.kt, ModernAudioDeviceManager.kt, StreamAudioSwitch.kt, StreamAudioSwitchHandler.kt
Added LegacyAudioDeviceManager (API 24-30) with Bluetooth SCO and legacy listener management, ModernAudioDeviceManager (API 31+) using modern communication device APIs, StreamAudioSwitch for centralized native audio routing, and StreamAudioSwitchHandler as delegating orchestrator.
Audio Management Integration
stream-video-android-core/src/main/kotlin/io/getstream/video/android/core/MediaManager.kt, Call.kt, stream-video-android-core/src/test/kotlin/.../audio/*
Updated MediaManager to use StreamAudioSwitchHandler with AudioDeviceManager, adjusted device selection logic with preferredDeviceList, added comprehensive unit tests for LegacyAudioDeviceManager and ModernAudioDeviceManager.
Permissions & Manifest Changes
stream-video-android-core/src/main/AndroidManifest.xml, stream-video-android-core/src/androidTest/AndroidManifest.xml, demo-app/src/androidTestE2etestingDebug/kotlin/io/getstream/video/android/tests/StreamTestCase.kt, stream-video-android-core/src/androidTest/kotlin/.../MediaManagerTest.kt, stream-video-android-ui-compose/src/main/kotlin/io/getstream/video/android/compose/permission/*
Replaced BLUETOOTH_CONNECT with BLUETOOTH (maxSdkVersion="30"), removed BLUETOOTH_CONNECT from test permissions, removed rememberBluetoothPermissionState composable and associated Bluetooth permission handling.
Audio Device UI & Selection
demo-app/src/main/kotlin/io/getstream/video/android/ui/menu/SettingsMenu.kt, stream-video-android-core/src/main/kotlin/io/getstream/video/android/core/call/state/CallAction.kt
Refined audio device selection logic to use ID-based comparison when available, falling back to type-based; removed SelectAudioDevice action class.
WebRTC Import Updates (Tests)
stream-video-android-core/src/androidTest/kotlin/.../AndroidDeviceTest.kt, stream-video-android-core/src/test/kotlin/.../ReconnectTest.kt, stream-video-android-core/src/test/kotlin/.../CameraManagerTest.kt, stream-video-android-core/src/test/kotlin/.../*Test.kt
Updated test imports from org.webrtc to io.getstream.webrtc, adjusted test object construction and mock verification to align with AudioHandler instead of AudioSwitchHandler.
Utility & Configuration Updates
stream-video-android-core/src/main/kotlin/io/getstream/video/android/core/StreamVideoBuilder.kt, StreamVideoClient.kt, CallStats.kt, RtcMapper.kt, stream-video-android-previewdata/*, stream-video-android-core/todo.md
Updated WebRTC imports in utility files, removed Bluetooth permission error milestone from todo, updated preview data utilities.

Sequence Diagram(s)

sequenceDiagram
    participant App as Application
    participant MediaMgr as MediaManager
    participant AudioSwitch as StreamAudioSwitch
    participant AudioDevMgr as AudioDeviceManager<br/>(Modern/Legacy)
    participant AudioMgr as Android AudioManager
    
    App->>MediaMgr: Initialize audio
    MediaMgr->>MediaMgr: Create preferredDeviceList
    MediaMgr->>AudioSwitch: new StreamAudioSwitch(context, preferredDeviceList)
    MediaMgr->>AudioSwitch: start(listener)
    AudioSwitch->>AudioDevMgr: Delegate to appropriate implementation
    AudioDevMgr->>AudioMgr: Query available devices
    AudioMgr-->>AudioDevMgr: Return AudioDeviceInfo list
    AudioDevMgr-->>AudioSwitch: Return StreamAudioDevice list
    AudioSwitch-->>MediaMgr: onDeviceSelected callback
    
    App->>MediaMgr: selectDevice(StreamAudioDevice)
    MediaMgr->>AudioSwitch: selectDevice(device)
    AudioSwitch->>AudioDevMgr: selectDevice(device)
    AudioDevMgr->>AudioMgr: setCommunicationDevice (API 31+) or manage SCO (API 24-30)
    AudioMgr-->>AudioDevMgr: Success/Failure
    AudioDevMgr-->>AudioSwitch: Update selected device state
    AudioSwitch-->>MediaMgr: Invoke onDeviceSelected callback
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

Suggested labels

pr:improvement, audio-management, webrtc-migration, refactoring

Poem

🐰 Out with AudioSwitch from Twilio's keep,
In with StreamAudioSwitch, our secrets to reap!
WebRTC repackaged, permissions refined,
Audio management elegantly designed,
Legacy and Modern dance in sync with glee! 🎵

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 37.39% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarizes the primary change: migrating the WebRTC package namespace from org.webrtc to io.getstream.webrtc, which is the main objective of this changeset.
Description check ✅ Passed The description is comprehensive and well-structured. It includes Goal, Implementation details with specific version changes, Breaking Changes section documenting API changes, Testing section with verification steps, and contributor/reviewer checklists. All required template sections are present and filled in meaningfully.

✏️ 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 repackaged_webrtc_branch

Tip

Issue Planner is now in beta. Read the docs and try it out! Share your feedback on Discord.


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.

@github-actions
Copy link
Contributor

SDK Size Comparison 📏

SDK Before After Difference Status
stream-video-android-core 12.00 MB 11.99 MB -0.02 MB 🚀
stream-video-android-ui-xml 5.68 MB 5.68 MB 0.00 MB 🟢
stream-video-android-ui-compose 6.28 MB 6.27 MB -0.02 MB 🚀

@sonarqubecloud
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
25.0% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube Cloud

@PratimMallick PratimMallick added pr:breaking-change API-breaking or behavioral change pr:dependencies Dependency updates labels Feb 20, 2026
replace_string_in_directory(
directory_path=project_root,
search_string="org.webrtc",
search_string="io.getstream.webrtc",
Copy link
Contributor

Choose a reason for hiding this comment

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

Both repackage scripts now replace io.getstream.webrtc with io.getstream.webrtc — same string. Are these scripts still needed, or can they be removed now that the repackaging is handled by the pre-built artifact?

ituDate = { group = "com.ethlo.time", name = "itu", version.ref = "itu" }

stream-webrtc = { group = "io.getstream", name = "stream-video-webrtc-android", version.ref = "streamWebRTC" }
stream-webrtc = { group = "io.getstream", name = "stream-video-webrtc-android-repackaged", version.ref = "streamWebRTC" }
Copy link
Contributor

@aleksandar-apostolov aleksandar-apostolov Feb 23, 2026

Choose a reason for hiding this comment

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

The dependency points to stream-video-webrtc-android-repackaged on Maven, but there's also a libs/libwebrtc_repackaged.aar binary committed to git. Shall we remove the AAR?

Copy link
Contributor

@aleksandar-apostolov aleksandar-apostolov left a comment

Choose a reason for hiding this comment

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

LGTM — clean namespace migration. Left two questions about the repackage scripts and the local AAR.

Copy link
Contributor

@aleksandar-apostolov aleksandar-apostolov left a comment

Choose a reason for hiding this comment

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

LGTM — clean namespace migration. Left two questions about the repackage scripts and the local AAR.

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

Labels

pr:breaking-change API-breaking or behavioral change pr:dependencies Dependency updates

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants