Add USB microphone input device support#1611
Merged
aleksandar-apostolov merged 4 commits intodevelopfrom Feb 10, 2026
Merged
Conversation
## Goal **NOTE: This is a DRAFT PR for testing purposes only.** Add support for detecting and selecting USB audio input devices (microphones) that are not recognized by Twilio AudioSwitch. ## Problem USB microphones that are input-only (e.g., Rode Wireless Go II) are not detected by AudioSwitch because it uses ACTION_HEADSET_PLUG broadcast which only fires for devices with both input AND output capabilities. This causes professional USB microphones to be invisible to the SDK, and the app always falls back to the phone's built-in microphone. ## Solution 1. Add UsbAudioInputDevice class to represent USB input devices using Android's native AudioDeviceInfo API 2. Add AudioDeviceCallback in MicrophoneManager to detect USB devices: - usbInputDevices: StateFlow - detected devices - selectedUsbDevice: StateFlow - current selection - listUsbDevices() - get available USB input devices - selectUsbDevice(device) - route audio to USB device - clearUsbDeviceSelection() - restore default routing 3. Expose setPreferredAudioInputDevice() in StreamPeerConnectionFactory to route WebRTC audio capture to the selected device via JavaAudioDeviceModule.setPreferredInputDevice() ## Requirements - Android M (API 23) or higher for USB device detection - USB device must be connected before/during the call
Contributor
PR checklist ✅All required conditions are satisfied:
🎉 Great job! This PR is ready for review. |
Contributor
SDK Size Comparison 📏
|
…elected by app when microphone manager's setup is called
|
PratimMallick
approved these changes
Feb 10, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Goal
Add support for detecting and selecting USB audio input devices (microphones) that are not recognized by Twilio AudioSwitch.
Problem: USB microphones that are input-only (e.g., Rode Wireless Go II) are not detected by AudioSwitch because it uses
ACTION_HEADSET_PLUGbroadcast which only fires for devices with both input AND output capabilities. This causes professional USB microphones to be invisible to the SDK.Reported issue: Live streaming feature on Patreon doesn't detect Rode Wireless Go II mics on OnePlus Nord 4, while the same mics work fine with the native Camera app.
Implementation
Use Android's native
AudioDeviceCallbackAPI (API 23+) to detect USB input devices, then route audio viaJavaAudioDeviceModule.setPreferredInputDevice().Changes:
New
UsbAudioInputDeviceclass - WrapsAudioDeviceInfofor USB input devicesMicrophoneManageradditions:usbInputDevices: StateFlow<List<UsbAudioInputDevice>>- detected USB devicesselectedUsbDevice: StateFlow<UsbAudioInputDevice?>- current selectionlistUsbDevices()- get available USB input devicesselectUsbDevice(device)- route audio to specific USB deviceclearUsbDeviceSelection()- restore default routingStreamPeerConnectionFactoryadditions:setPreferredAudioInputDevice(AudioDeviceInfo?)- expose WebRTC device routingUsage:
Testing