Package 

Class MicrophoneManager


  • 
    public final class MicrophoneManager
    
                        

    The Microphone manager makes it easy to use your microphone in a call

    • Method Detail

      • getUsbInputDevices

         final StateFlow<List<UsbAudioInputDevice>> getUsbInputDevices()

        List of detected USB audio input devices.

        These devices are detected using Android's AudioDeviceCallback API and include USB microphones that may not appear in devices because AudioSwitch only detects devices with both input and output capabilities.

        Requires Android M (API 23) or higher.

      • getAudioBitrateProfile

         final StateFlow<AudioBitrateProfile> getAudioBitrateProfile()

        The audio bitrate profile currently in force — observe this to drive a music/voice toggle.

        Only moves when the profile actually took. Set before joining it always does, since the pipeline is then built from it. On a running call it moves only if every reachable stage accepted the change; otherwise it keeps reporting the previous profile, so a toggle bound to it snaps back rather than claiming a switch the audio did not make, and setAudioBitrateProfile fails naming the stages that refused.

      • disable

         final Unit disable(Boolean fromUser)

        Disable the audio track. Audio is still captured, but not send. This allows for the "you are muted" toast to indicate you are talking while muted

      • setupUsbDeviceDetection

         final Unit setupUsbDeviceDetection()

        Sets up USB audio device detection using Android's AudioDeviceCallback.

        This detects USB input devices (microphones), such as the Rode Wireless Go II and other professional USB microphones.

        Requires Android M (API 23) or higher.

      • selectUsbDevice

         final Boolean selectUsbDevice(UsbAudioInputDevice device)

        Selects a USB input device as the preferred audio input source.

        This routes audio recording to the specified USB device, bypassing AudioSwitch's default device selection. Use this for USB microphones that don't appear in devices.

        Parameters:
        device - The USB device to use, or null to restore default routing.
      • clearUsbDeviceSelection

         final Unit clearUsbDeviceSelection()

        Clears the USB device selection, restoring default audio routing.

        Resets the state directly rather than going through selectUsbDevice with null, because the WebRTC ADM's setPreferredInputDevice does not accept null safely. When the USB device is physically removed, the system automatically falls back to default audio routing, so an explicit ADM call is unnecessary.

      • setAudioBitrateProfile

         final Result<Unit> setAudioBitrateProfile(AudioBitrateProfile profile)

        Sets the audio bitrate profile, before joining or on a running call, so a broadcaster who starts playing music can switch to MUSIC_HIGH_QUALITY without rejoining.

        Requires HiFi audio enabled in the dashboard settings. The Opus bitrate and channel count come from the server at join, so a mid-call switch does not renegotiate them.

        Expect a brief gap in captured audio on a mid-call switch: the platform rebuilds its capture path. The call is not interrupted otherwise.

        Echo cancellation goes off under MUSIC_HIGH_QUALITY, so treat music as a headphones setting. It also costs communication routing and Bluetooth capture — SCO only runs in communication mode.

        Read the profile in force back from audioBitrateProfile.