Real-Time Communication (RTC) SDK allows you to detect and manage devices. You can check whether hardware devices work as expected before you join a channel. This topic describes how to detect and manage devices.
Feature description
The RTC SDK provides internal methods to detect and manage devices. For example, you can query device information, check if the camera is working correctly, test audio recording and playback, set the camera direction, or switch between audio devices such as the microphone and speaker.
Implementation methods
This section lists common methods to detect and manage devices. For more information, see DingRtcEngine.
GetCameraList: queries a list of cameras.
AliEngineDeviceInfoList* GetCameraList();Response description
Returns a list of cameras.
GetCurrentCameraName: queries the name of the camera that is in use.
String GetCurrentCameraName();Response description
Returns the name of the camera that is in use.
SetCurrentCameraName: specifies the name of a camera.
int SetCurrentCameraName(const char* cameraName);Parameter description
Parameter
Type
Description
cameraName
const char*
The name of the camera.
Response description
A value of 0 indicates that the call was successful. A value other than 0 indicates that the call failed.
isCameraOn: queries whether the camera is enabled.
bool IsCameraOn();Response description
A value of true indicates that the camera is enabled. A value of false indicates that the camera is disabled.
GetRecordingDeviceList: queries a list of recording devices in the system.
RtcEngineDeviceInfoList* GetRecordingDeviceList();Response description
Returns a list of recording devices.
GetCurrentRecordingDeviceId: queries the ID of the recording device that is in use.
String GetCurrentRecordingDeviceId();Response description
Returns the ID of the recording device that is in use.
SetCurrentRecordingDeviceId: specifies the ID of a recording device.
int SetCurrentRecordingDeviceId(const char* deviceId);Parameter description
Parameter
Type
Description
deviceId
const char*
The ID of the recording device.
Response description
A value of 0 indicates that the call was successful. A value other than 0 indicates that the call failed.
GetPlayoutDeviceList: queries a list of speakers in the system.
RtcEngineDeviceInfoList* GetPlayoutDeviceList();Response description
Returns a list of speakers.
GetCurrentPlayoutDeviceId: queries the ID of the speaker that is in use.
String GetCurrentPlayoutDeviceId();Response description
Returns the ID of the speaker that is in use.
SetCurrentPlayoutDeviceId: specifies the ID of a speaker.
int SetCurrentPlayoutDeviceId(const char* deviceId);Parameter description
Parameter
Type
Description
deviceId
const char*
The ID of the speaker.
Response description
A value of 0 indicates that the call was successful. A value other than 0 indicates that the call failed.