• 서비스
  • 가격
  • 리소스
  • 기술지원
이 페이지는 현재 영어로만 제공되며 한국어 버전은 곧 제공될 예정입니다. 기다려 주셔서 감사드립니다.

DeviceStore

Introduction

DeviceStore provides a comprehensive set of APIs to manage audio and video devices, including microphone, camera and screen sharing features.
Important:
Use DeviceStore.shared singleton to get the DeviceStore instance. Do not attempt to initialize directly.
Note:
Device state updates are delivered through the deviceState publisher. Subscribe to it to receive real-time updates about microphone, camera, network and other states.

Features

Microphone Management:Open/close microphone, set capture volume and output volume
Camera Management:Open/close camera, switch front/rear camera, set mirror and video quality
Audio Route:Switch between speaker and earpiece
Screen Sharing:Start and stop screen sharing feature
Network Status:Real-time monitoring of network quality information

Subscribable Data

DeviceState fields are described below:
Property
Type
Description
microphoneStatus
StateFlow<DeviceStatus>
Microphone status.
microphoneLastError
StateFlow<DeviceError>
Microphone error, used to extract error information when an error occurs.
captureVolume
StateFlow<Int>
Capture volume, range [0, 100].
currentMicVolume
StateFlow<Int>
Current user's actual output volume.
outputVolume
StateFlow<Int>
Maximum output volume, range [0, 100].
cameraStatus
StateFlow<DeviceStatus>
Camera status.
cameraLastError
StateFlow<DeviceError>
Camera error, used to extract error information when an error occurs.
isFrontCamera
StateFlow<Boolean>
Whether it's front camera.
localMirrorType
StateFlow<MirrorType>
Mirror state.
localVideoQuality
StateFlow<VideoQuality>
Local video quality.
currentAudioRoute
StateFlow<AudioRoute>
Current audio route location.
screenStatus
StateFlow<DeviceStatus>
Screen sharing status.
networkInfo
StateFlow<NetworkInfo>
Network information.

API List

Function
Description
Singleton object.
Open local microphone.
Close local microphone.
Set capture volume.
Set output volume.
Set audio route.
Start camera test.
Stop camera test.
Open local camera.
Close local camera.
Switch camera.
Switch mirror state.
Update video quality.
Start screen sharing.
Stop screen sharing.
Reset to default state.

Getting Instance

DeviceStore.shared

Singleton object

Microphone Operations

openLocalMicrophone

Open local microphone
abstract fun openLocalMicrophone(completion: CompletionHandler?)
Version
Supported since version 3.5.
Parameters
Parameter
Type
Required
Description
completion
Required
Whether operation succeeded.

closeLocalMicrophone

Close local microphone
abstract fun closeLocalMicrophone()
Version
Supported since version 3.5.

setCaptureVolume

Set capture volume
abstract fun setCaptureVolume(volume: Int)
Version
Supported since version 3.5.
Parameters
Parameter
Type
Required
Description
volume
Int
Required
Capture volume, range [0, 100].

setOutputVolume

Set maximum output volume
abstract fun setOutputVolume(volume: Int)
Version
Supported since version 3.5.
Parameters
Parameter
Type
Required
Description
volume
Int
Required
Maximum volume, range [0, 100].

Audio Route

setAudioRoute

Set audio route
abstract fun setAudioRoute(audioRoute: AudioRoute)
Version
Supported since version 3.5.
Parameters
Parameter
Type
Required
Description
audioRoute
Required
Route location.

Camera Operations

startCameraTest

Start camera test, if camera opens successfully, the view will be rendered to the set CameraView
abstract fun startCameraTest(cameraView: CameraView, completion: CompletionHandler?)
Version
Supported since version 3.5.
Parameters
Parameter
Type
Required
Description
cameraView
Required
Rendering view for camera capture.
completion
Required
Whether operation succeeded.

stopCameraTest

Stop camera test
abstract fun stopCameraTest()
Version
Supported since version 3.5.

openLocalCamera

Open local camera
abstract fun openLocalCamera(isFront: Boolean, completion: CompletionHandler?)
Version
Supported since version 3.5.
Parameters
Parameter
Type
Required
Description
isFront
Boolean
Required
Whether front camera.
completion
Required
Whether operation succeeded.

closeLocalCamera

Close local camera
abstract fun closeLocalCamera()
Version
Supported since version 3.5.

switchCamera

Switch camera
abstract fun switchCamera(isFront: Boolean)
Version
Supported since version 3.5.
Parameters
Parameter
Type
Required
Description
isFront
Boolean
Required
Whether front camera.

switchMirror

Switch mirror state
abstract fun switchMirror(mirrorType: MirrorType)
Version
Supported since version 3.5.
Parameters
Parameter
Type
Required
Description
mirrorType
Required
Mirror state.

updateVideoQuality

Update video quality
abstract fun updateVideoQuality(quality: VideoQuality)
Version
Supported since version 3.5.
Parameters
Parameter
Type
Required
Description
quality
Required
Video quality.

Screen Sharing

startScreenShare

Start screen sharing
abstract fun startScreenShare()
Version
Supported since version 3.5.

stopScreenShare

Stop screen capture
abstract fun stopScreenShare()
Version
Supported since version 3.5.

Reset

reset

Reset to default state
abstract fun reset()
Version
Supported since version 3.5.

Data Structures

DeviceType

Device type
Enum Value
Value
Description
MICROPHONE
0
Microphone type.
CAMERA
1
Camera type.
SCREEN_SHARE
2
Screen sharing type.

DeviceError

Device related error codes
Enum Value
Value
Description
NO_ERROR
0
Operation successful.
NO_DEVICE_DETECTED
1
No device detected.
NO_SYSTEM_PERMISSION
2
No system permission.
NOT_SUPPORT_CAPTURE
3
Capture not supported.
OCCUPIED_ERROR
4
Device occupied.
UNKNOWN_ERROR
5
Unknown error.

DeviceStatus

Device on/off status
Enum Value
Value
Description
OFF
0
Off.
ON
1
On.

AudioRoute

Audio route
Enum Value
Value
Description
SPEAKERPHONE
0
Speaker, using speaker to play (i.e., "hands-free"), located at the bottom of the phone, louder sound, suitable for playing music out loud.
EARPIECE
1
Earpiece, using earpiece to play, located at the top of the phone, quieter sound, suitable for private call scenarios.

VideoQuality

Video quality
Enum Value
Value
Description
QUALITY_360P
1
360P.
QUALITY_540P
2
540P.
QUALITY_720P
3
720P.
QUALITY_1080P
4
1080P.

NetworkQuality

Network quality
Enum Value
Value
Description
UNKNOWN
0
Unknown network.
EXCELLENT
1
Excellent.
GOOD
2
Good.
POOR
3
Poor.
BAD
4
Bad.
VERY_BAD
5
Very bad.
DOWN
6
Disconnected.

MirrorType

Camera mirror state
Enum Value
Value
Description
AUTO
0
Auto, front camera mirrored, rear camera not mirrored.
ENABLE
1
Both front and rear cameras mirrored.
DISABLE
2
Neither front nor rear camera mirrored.

DeviceFocusOwner

Device focus
Enum Value
Description
call
Voice call scenario.
live
Live streaming scenario.
none
Not set.

NetworkInfo

Network information
Property
Type
Description
userID
String
User unique ID.
quality
Network quality.
upLoss
Int
Uplink packet loss rate, range [0, 100].
downLoss
Int
Downlink packet loss rate, range [0, 100].
delay
Int
Latency (unit: milliseconds).

DeviceState

Device state
Property
Type
Description
microphoneStatus
StateFlow<DeviceStatus>
Microphone status.
microphoneLastError
StateFlow<DeviceError>
Microphone error, used to extract error information when an error occurs.
captureVolume
StateFlow<Int>
Capture volume, range [0, 100].
currentMicVolume
StateFlow<Int>
Current user's actual output volume.
outputVolume
StateFlow<Int>
Maximum output volume, range [0, 100].
cameraStatus
StateFlow<DeviceStatus>
Camera status.
cameraLastError
StateFlow<DeviceError>
Camera error, used to extract error information when an error occurs.
isFrontCamera
StateFlow<Boolean>
Whether it's front camera.
localMirrorType
StateFlow<MirrorType>
Mirror state.
localVideoQuality
StateFlow<VideoQuality>
Local video quality.
currentAudioRoute
StateFlow<AudioRoute>
Current audio route location.
screenStatus
StateFlow<DeviceStatus>
Screen sharing status.
networkInfo
StateFlow<NetworkInfo>
Network information.

Usage Example

// Get singleton instance
val store = DeviceStore.shared()

// Subscribe to state changes
lifecycleScope.launch {
store.deviceState.microphoneStatus.collect { status ->
println("Microphone status: $status")
}
}

lifecycleScope.launch {
store.deviceState.cameraStatus.collect { status ->
println("Camera status: $status")
}
}

// Open microphone
store.openLocalMicrophone { code, message ->
if (code == 0) {
println("Microphone opened successfully")
}
}

// Open front camera
store.openLocalCamera(isFront = true) { code, message ->
if (code == 0) {
println("Camera opened successfully")
}
}