Hello team, We want to publish audio from an exter...
# ask-ai
q
Hello team, We want to publish audio from an external Bluetooth device (PCM). The PCM is available in Android native code as a
ShortArray
. We do not want to use the device microphone. In
@livekit/react-native
, is there an official/supported API to: override WebRTC’s audio capture via a custom
AudioDeviceModule
, or • push raw PCM frames into the capture path (e.g., for
LocalAudioTrack
)?
LiveKitReactNative.setup()
appears to set the ADM internally—can it be replaced, and if yes, how?
t
Thanks for reaching out, Balaji. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Thanks — I’m looking at your questions about publishing PCM from an external Bluetooth device into @livekit/react-native and whether you can replace the internal audio capture (AudioDeviceModule) or push raw PCM into a LocalAudioTrack. Quick answer • There is no documented, built-in API in @livekit/react-native to directly push raw PCM frames into the capture path or to swap out the internal WebRTC AudioDeviceModule from JS. • To accomplish this you’ll need to handle it on the native side (Android/iOS): capture or receive your PCM in native code and feed it into WebRTC’s capture pipeline there. I can help with concrete native options — please tell me which platforms you need (Android, iOS, or both) and whether you already have a native module that provides the Bluetooth PCM as a ShortArray. A few native approaches you can use • Android (recommended approach): ◦ Implement a custom WebRTC capture path in your Android native layer that consumes the ShortArray frames and provides them to the PeerConnection’s audio source. This typically means replacing or extending the WebRTC audio capture on the native side (a custom AudioDeviceModule or a custom AudioRecord-like provider) and wiring it into the PeerConnectionFactory used by the SDK. ◦ Ensure the LiveKit React Native native module uses your PeerConnectionFactory / AudioDeviceModule. That requires modifying the native LiveKit integration so the setup step uses your custom audio module instead of the default. • iOS: ◦ Implement a custom audio source using WebRTC’s native APIs and feed PCM into the capture callback used by the WebRTC audio pipeline. Then ensure the LiveKit native client uses that audio source. • Alternative: Create a native "virtual microphone" that exposes your PCM as an audio input device to the OS and let the existing capture path use that virtual device. This can be simpler in some environments but platform support and permissions vary. Questions so I can give precise next steps 1. Which platforms do you need to support (Android, iOS, or both)? 2. Do you already have native code that produces PCM frames (you mentioned Android ShortArray) and can modify the native LiveKitReactNative module? 3. Do you prefer modifying LiveKit’s native client to use a custom ADM, or would a virtual-mic approach be acceptable? What I can provide next • If you want to modify the native LiveKit module, I can outline the exact native steps and show the key code snippets for Android (how to create/use a custom AudioDeviceModule or custom audio capture and wire it into PeerConnectionFactory used by LiveKit RN). • If you prefer a virtual-mic route, I can list options and trade-offs for Android/iOS. Tell me platform(s) and whether you can modify native code, and I’ll give the targeted implementation steps.
q
Platform: Android only Native PCM: Yes - we have
ShortArray
PCM (16kHz, mono) from Bluetooth device in native code. We can modify native LiveKit module. Approach: Modify LiveKit native client to use custom
AudioDeviceModule
(not virtual-mic). Request: Please provide exact Android steps and code snippets for: 1. Creating custom ADM that accepts
ShortArray
PCM frames 2. Wiring it into
PeerConnectionFactory
used by LiveKit RN 3. Ensuring
LiveKitReactNative.setup()
uses our custom ADM Context: Audio arrives as 16kHz mono ShortArray, we'll resample to 48kHz, need to feed 10ms frames at stable rate.
t
I don't have the answer you're looking for. You could also try asking your question: • in one of the other Slack channels or • to https://deepwiki.com/livekit/livekit_composite which is trained on all LiveKit source code If you find the answer, please post it here to help others!