# Audio Management

Audio device management mainly uses the methods in the JCMediaDevice class, as follows:

# Select the audio input device

Before you start a call or join a channel, you can set it up audioParam (opens new window) property to select the audio input device.


//1. Use the default audio source
mMediaDevice.audioParam.audioInputDevice = JCMediaDevice.JCMediaDeviceAudioParam.INPUT_DEFAULT;
//2. When a call is initiated, the startAudio() method is automatically called to turn on audio
mCall.call("userID",true , new JCCall.CallParam("extraParam", "ticket"));

Audio input devices are divided into the following types:

Static variable name The value is Meaning
INPUT_DEFAULT DEFAULT The default audio source
INPUT_MIC MIC Microphone audio source
INPUT_VOICE_UPLINK VOICE_UPLINK Voice calls uplink (Tx) audio source
INPUT_VOICE_DOWNLINK VOICE_DOWNLINK Voice Call Downstream (Rx) Audio Source
INPUT_VOICE_CALL VOICE_CALL Voice call uplink plus downlink audio source
INPUT_CAMCORDER CAMCORDER Adjusted the microphone audio source used for video recording, the same orientation as the camera (if any)
INPUT_VOICE_RECOGNITION VOICE_RECOGNITION The microphone sound source is tuned for speech recognition
INPUT_VOICE_COMMUNICATION IVOICE_COMMUNICATION Microphone audio sources have been tuned for voice communication such as VoIP. For example, if available, it will use echo cancellation or automatic gain control

# Audio Device Management

Audio device management mainly uses the methods in the JCMediaDevice class, as follows:

# Get audio route type

/**
 * Audio route type
 *
 * @return Audio route type
 */
public abstract int getAudioRouteType();

The audio output type (AudioRouteType) has the following:

/** handset  */
public static final int AUDIO_ROUTE_RECEIVER = 0;
/** speaker  */
public static final int AUDIO_ROUTE_SPEAKER = 1;
/** Wired headset */
public static final int AUDIO_ROUTE_HEADSET = 2;
/** Bluetooth earphone */
public static final int AUDIO_ROUTE_BLUETOOTH = 3;

# Turn on/off the speaker

/**
 * Turn on/off the speaker
 *
 * @param enable Turn on/off
 */
public abstract void enableSpeaker(boolean enable);

# Turn on/off audio devices

/**
 * Start audio (generally need to call this interface before starting a call)
 *
 * @return return true/false
 */
public abstract boolean startAudio();

/**
 * Stop audio (usually be called at the end of the call)
 *
 * @return return true/false
 */
public abstract boolean stopAudio();

Sample code:

// Turn on the speaker
mediaDevice.enableSpeaker(true);
// Turn on the audio device
mediaDevice.startAudio();
// Turn off the audio device
mediaDevice.stopAudio();
最后更新时间: 1/17/2023, 5:17:17 PM