import 'react-native'; import type { NativeModule } from 'react-native'; import type { AudioDevicesState, AudioRole, DeviceEndpointType, IOSAudioSessionState, } from './types'; export interface CallManager extends NativeModule { /** * Sets the audio role for the call. This should be done before calling **start()**. * * @param role The audio role to set. It can be one of the following: * - `'communicator'`: (Default) For use cases like video or voice calls. * It prioritizes low latency and allows manual audio device switching. * Audio routing is controlled by the SDK. * - `'listener'`: For use cases like livestream viewing. * It prioritizes high-quality stereo audio streaming. * Audio routing is controlled by the OS and manual switching is not supported. */ setAudioRole: (role: AudioRole) => void; /** * Sets the default audio device endpoint type for the call. This should be done before calling **start()**. * @param type The default audio device endpoint type to set. It can be one of the following: * - `'speaker'`: (Default) For normal video or voice calls. * - `'earpiece'`: For voice only mobile call type scenarios. */ setDefaultAudioDeviceEndpointType: (type: DeviceEndpointType) => void; /** * Enables/disables Telecom-managed mode (Android). Must be set before **start()**. * When enabled, audio focus, mode and device routing are owned by the Android * Telecom stack (via callingx); StreamInCallManager only keeps proximity, * keep-screen-on and mic/output mute. */ setTelecomManagedMode: (enabled: boolean) => void; /** * Opt out of the Android 11+ communication-mode keep-alive workaround. * * On Android 11+ (API 30) the OS resets `MODE_IN_COMMUNICATION` ~6s after it is * set when there is no active voice-communication playback/recording, which * breaks audio routing and AEC. By default the SDK plays a silent * voice-communication track for the duration of a communicator-role call to * prevent this. Pass `true` to disable it. Sticky for the process lifetime. * * No-op on iOS and on Android below API 30. See * https://issuetracker.google.com/issues/209493718 */ setDisableCommunicationModeWorkaround: (disabled: boolean) => void; /** * Choose an audio device endpoint by its stable id. * @param deviceId - The id of the audio device to choose (`AudioDevice.id`). */ chooseAudioDeviceEndpoint: (deviceId: string) => void; /** * Re-applies the current audio output pick (iOS). Used to restore a Bluetooth/wired * route after an interruption ends, where the ephemeral route override is lost. * No-op if no explicit pick has been made. */ reapplyAudioRoute: () => void; /** * Get the current audio device state (available devices + selected one). * @returns The audio devices state. */ getAudioDeviceStatus: () => Promise; /** * Shows the iOS audio route picker. */ showAudioRoutePicker: () => void; /** * Start the in call manager. */ start: () => void; /** * Stop the in call manager. */ stop: () => void; /** * Re-activates the SDK-owned iOS audio session when iOS cleared it. * Resolves whether the session is active afterwards; rejects with the * AVAudioSession error. iOS-only. */ reactivateAudioSession: () => Promise; /** * Snapshot of the shared iOS audio session (sync). iOS-only. */ getAudioSessionState: () => IOSAudioSessionState; /** * Mutes the speaker */ muteAudioOutput: () => void; /** * Unmutes the speaker */ unmuteAudioOutput: () => void; /** * Forces speakerphone on/off. */ setForceSpeakerphoneOn: (boolean) => void; /** * Enables or disables stereo audio output. * @param enable - Whether to enable stereo audio output. */ setEnableStereoAudioOutput: (enable: boolean) => void; /** * Sets the microphone mute mode on the call's ADM. No-ops when no call ADM is active. iOS-only. * @param mode - The `AudioEngineMuteMode` value. */ setMuteMode: (mode: number) => void; /** * Keeps the recording chain prepared while muted so the engine stays * full-duplex. No-ops when no call ADM is active. iOS-only. * @param enabled - Whether to keep recording always prepared. */ setRecordingAlwaysPreparedMode: (enabled: boolean) => void; /** * Log the current audio state natively. * Meant for debugging purposes. */ logAudioState: () => void; /** * Get the current audio state as a string. * Meant for debugging purposes. * @returns A string containing the current audio state information. */ getAudioStateLog: () => string; } declare module 'react-native' { interface NativeModulesStatic { StreamInCallManager: CallManager; } }