tencent_rtc_sdk. Obtain the instance via TRTCCloud's getDeviceManager() and then call the APIs.Platform Category | Applicable Platforms | Return Value on Unsupported Platforms |
Mobile only | Android / iOS / HarmonyOS | int/double returns -1.bool returns false. |
Desktop only | Windows / macOS | int returns -1.bool returns false.List returns an empty list.TXDeviceInfo returns an empty object. |
Windows only | Windows | int returns -1. |
API | Description |
Queries whether the front camera is being used (mobile only). | |
Switches between the front and rear cameras (mobile only). | |
Gets the maximum zoom ratio of the camera (mobile only). | |
Sets the zoom ratio of the camera (mobile only). | |
Queries whether automatic face position recognition is supported (mobile only). | |
Enables auto focus (mobile only). | |
Sets the focus position of the camera (mobile only). | |
Turns on/off the flash, i.e., the torch mode (mobile only). | |
Sets the audio route (mobile only). |
API | Description |
Gets the device list (desktop only). | |
Sets the device to use (desktop only). | |
Gets the device currently in use (desktop only). | |
Sets the volume of the current device (desktop only). | |
Gets the volume of the current device (desktop only). | |
Sets the mute status of the current device (desktop only). | |
Queries whether the current device is muted (desktop only). | |
Sets the audio device used by the SDK to follow the system default device (desktop only). |
API | Description |
Starts camera test (desktop only). | |
Stops camera test (desktop only). | |
Starts microphone test (desktop only). | |
Starts microphone test, with the option to play back the microphone sound (desktop only). | |
Stops microphone test (desktop only). | |
Starts speaker test (desktop only). | |
Stops speaker test (desktop only). |
API | Description |
Sets the volume of the current process in the Windows volume mixer (Windows only). | |
Gets the volume of the current process in the Windows volume mixer (Windows only). | |
Sets the mute status of the current process in the Windows volume mixer (Windows only). | |
Gets the mute status of the current process in the Windows volume mixer (Windows only). |
API | Description |
Sets camera capture preferences. | |
Sets the device status change callback ( onDeviceChanged). |
bool isFrontCamera()
true: The front camera is being used.false: The rear camera is being used, or this API is not supported on the current platform.int switchCamera(bool frontCamera)
Parameter | Type | Description |
frontCamera | bool | true: Front camera.false: Rear camera. |
-1 if not supported on the current platform.double getCameraZoomMaxRatio()
-1 if not supported on the current platform.int setCameraZoomRatio(double ratio)
Parameter | Type | Description |
ratio | double | Zoom ratio. Value range: 1 - 5. 1: Widest view (normal lens).5: Closest view (zoomed-in lens).It is recommended that the maximum value not exceed 5; beyond that, the image becomes blurry. |
-1 if not supported on the current platform.bool isAutoFocusEnabled()
true: Supported.false: Not supported, or this API is not supported on the current platform.int enableCameraAutoFocus(bool enabled)
Parameter | Type | Description |
enabled | bool | true: Enable.false: Disable. |
-1 if not supported on the current platform.int setCameraFocusPosition(double x, double y)
Parameter | Type | Description |
x | double | X coordinate of the desired focus point. |
y | double | Y coordinate of the desired focus point. |
0: Operation succeeded.-1 if not supported on the current platform).int enableCameraTorch(bool enabled)
Parameter | Type | Description |
enabled | bool | true: Enable.false: Disable. |
-1 if not supported on the current platform.int setAudioRoute(TXAudioRoute route)
Parameter | Type | Description |
route |
-1 if not supported on the current platform.List<TXDeviceInfo> getDevicesList(TXMediaDeviceType type)
Parameter | Type | Description |
type |
List<TXDeviceInfo> cameras = deviceManager.getDevicesList(TXMediaDeviceType.camera);for (TXDeviceInfo device in cameras) {debugPrint('${device.deviceName} (${device.devicePid})');}
int setCurrentDevice(TXMediaDeviceType type, String deviceId)
Parameter | Type | Description |
type | ||
deviceId | String |
0: Operation succeeded.-1 if not supported on the current platform).TXDeviceInfo getCurrentDevice(TXMediaDeviceType type)
Parameter | Type | Description |
type |
int setCurrentDeviceVolume(TXMediaDeviceType type, int volume)
Parameter | Type | Description |
type | ||
volume | int | Volume. Value range: 0 - 100. Default value: 100. |
-1 if not supported on the current platform.int getCurrentDeviceVolume(TXMediaDeviceType type)
Parameter | Type | Description |
type |
-1 if not supported on the current platform.int setCurrentDeviceMute(TXMediaDeviceType type, bool mute)
Parameter | Type | Description |
type | ||
mute | bool | true: Mute.false: Unmute. |
-1 if not supported on the current platform.bool getCurrentDeviceMute(TXMediaDeviceType type)
Parameter | Type | Description |
type |
true: The current device is muted.false: The current device is not muted, or this API is not supported on the current platform.int enableFollowingDefaultAudioDevice(TXMediaDeviceType type, bool enable)
Parameter | Type | Description |
type | ||
enable | bool | Whether to follow the system default audio device. true: Follow. When the system default audio device changes or a new audio device is plugged in, the SDK switches the audio device immediately.false: Do not follow. When the system default audio device changes or a new audio device is plugged in, the SDK does not switch the audio device. |
-1 if not supported on the current platform.int startCameraDeviceTest(int viewId)
Parameter | Type | Description |
viewId | int | ID of the control for rendering the camera test image. |
-1 if not supported on the current platform.void stopCameraDeviceTest()
int startMicDeviceTest(int interval)
onTestMicVolume callback in TRTCCloudListener.Parameter | Type | Description |
interval | int | Interval of the volume callback. |
-1 if not supported on the current platform.int startMicDeviceTestAndPlayback(int interval, bool playback)
onTestMicVolume callback in TRTCCloudListener.Parameter | Type | Description |
interval | int | Interval of the volume callback. |
playback | bool | Whether to play back the microphone sound. If true, the user will hear their own voice when testing the microphone. |
-1 if not supported on the current platform.void stopMicDeviceTest()
int startSpeakerDeviceTest(String filePath)
onTestSpeakerVolume callback in TRTCCloudListener.Parameter | Type | Description |
filePath | String | Path of the audio file. |
-1 if not supported on the current platform.void stopSpeakerDeviceTest()
int setApplicationPlayVolume(int volume)
Parameter | Type | Description |
volume | int | Volume of the current process. |
-1 if not supported on the current platform.int getApplicationPlayVolume()
-1 if not supported on the current platform.int setApplicationMuteState(bool mute)
Parameter | Type | Description |
mute | bool | true: Mute.false: Unmute. |
-1 if not supported on the current platform.int getApplicationMuteState()
-1 if not supported on the current platform.void setCameraCaptureParam(TXCameraCaptureParam params)
Parameter | Type | Description |
params |
deviceManager.setCameraCaptureParam(TXCameraCaptureParam(mode: TXCameraCaptureMode.manual,width: 1280,height: 720,));
int setDeviceObserver(TXDeviceObserver? observer)
onDeviceChanged).Parameter | Type | Description |
observer | TXDeviceObserver? | Device status change callback object. For details, see TXDeviceObserver. Pass null to remove the callback. |
0: Set successfully.deviceManager.setDeviceObserver(TXDeviceObserver(onDeviceChanged: (String deviceId, TXMediaDeviceType type, TXMediaDeviceState state) {debugPrint('device changed: $deviceId, $type, $state');},));
Enum Value | Value | Description |
unknown | -1 | Unknown. The default routing device is used. |
speakerPhone | 0 | Speaker: Plays through the speaker at the bottom of the phone (i.e., "hands-free") at a high volume, suitable for playing music aloud. |
earpiece | 1 | Earpiece: Plays through the earpiece at the top of the phone at a low volume, suitable for call scenarios requiring privacy. |
wiredHeadset | 2 | Wired headset. |
bluetoothHeadset | 3 | Bluetooth headset. |
soundCard | 4 | Sound card. |
Enum Value | Value | Description |
unknown | -1 | Undefined device type. |
mic | 0 | Microphone. |
speaker | 1 | Speaker or earpiece. |
camera | 2 | Camera. |
onDeviceChanged callback.Enum Value | Value | Description |
add | 0 | The device has been plugged in. |
remove | 1 | The device has been removed. |
active | 2 | The device has been enabled. |
defaultDeviceChanged | 3 | The system default device has changed. |
Enum Value | Value | Description |
auto | 0 | Automatically adjusts capture parameters. The SDK selects appropriate camera output parameters based on the actual capture device performance and network conditions, balancing device performance and video preview quality. |
performance | 1 | Prioritizes device performance. The SDK selects the camera output parameters closest to the encoder resolution and frame rate set by the user, thereby ensuring device performance. |
highQuality | 2 | Prioritizes video preview quality. The SDK selects higher camera output parameters to improve the quality of the preview video. In this case, more CPU and memory are consumed for video pre-processing. |
manual | 3 | Allows the user to set the width and height of the video captured by the local camera. |
Field | Type | Default Value | Description |
mode | TXCameraCaptureMode.auto | ||
width | int | 640 | Width of the captured image. |
height | int | 360 | Height of the captured image. |
Field | Type | Default Value | Description |
deviceName | String | '' | Device name. |
devicePid | String | '' | Device ID. |
deviceProperties | String | '' | Device properties. |
final void Function(String deviceId, TXMediaDeviceType type, TXMediaDeviceState state) onDeviceChanged
Parameter | Type | Description |
deviceId | String | Device ID. |
type | ||
state |
피드백