DeviceStore provides a comprehensive set of APIs to manage audio and video devices, including microphone, camera and screen sharing features.DeviceStore instance. Do not attempt to initialize directly.Property | Type | Description |
microphoneStatus | Microphone status. | |
microphoneLastError | Microphone error, used to extract error information when an error occurs. | |
captureVolume | Int | Capture volume, with a value range from 0 to 100. |
currentMicVolume | Int | Current user's actual output volume. |
outputVolume | Int | Maximum output volume, with a value range from 0 to 100. |
cameraStatus | Camera status. | |
cameraLastError | Camera error, used to extract error information when an error occurs. | |
isFrontCamera | Bool | Whether it's front camera. |
localMirrorType | Mirror state. | |
localVideoQuality | Local video quality. | |
currentAudioRoute | Current audio route location. | |
screenStatus | Screen sharing status. | |
networkInfo | Network information. | |
networkType | Current network type. | |
microphoneList | Current microphone device list. Only populated on desktop platforms, it is empty on mobile platforms. | |
currentMicrophone | Current microphone device, an empty deviceId means no microphone is selected. | |
microphoneVolume | Int | Microphone capture volume, with a value range from 0 to 100. |
microphoneInputLevel | Int | Real-time level value used to display the microphone volume bar, range 0-100. |
cameraList | Camera device list. On desktop platforms it contains all the cameras, on mobile platforms it
contains the logical front camera and rear camera. | |
currentCamera | Current camera device, an empty deviceId means no camera is selected. | |
speakerList | Speaker device list. On desktop platforms it contains all the speakers, on mobile platforms it
contains the logical speaker and earpiece. | |
currentSpeaker | Current speaker device, an empty deviceId means no speaker is selected. | |
speakerVolume | Int | Speaker playback volume, with a value range from 0 to 100. |
speakerOutputLevel | Int | Speaker real-time output level value, range 0-100. |
Function | Description |
Singleton object. | |
Open local microphone. | |
Close local microphone. | |
Set microphone capture volume. | |
Set speaker playback volume. | |
Select microphone device. | |
Start microphone test. | |
Stop microphone test. | |
Select speaker device. | |
Start speaker test. | |
Stop speaker test. | |
Start camera test. | |
Stop camera test. | |
Open local camera. | |
Close local camera. | |
Select camera device. | |
Switch mirror state. | |
Update video quality. | |
Set capture volume, use setMicrophoneVolume instead. | |
Set output volume, use setSpeakerVolume instead. | |
Set audio route, use setCurrentSpeaker instead. | |
Switch camera, use setCurrentCamera instead. | |
Reset to default state. |
public func openLocalMicrophone(completion: CompletionClosure?) {fatalError("\\(#function) must be overridden by subclass")}
Parameter | Type | Description |
completion | Whether operation succeeded. |
public func closeLocalMicrophone() {fatalError("\\(#function) must be overridden by subclass")}
public func setMicrophoneVolume(_ volume: Int) {fatalError("\\(#function) must be overridden by subclass")}
Parameter | Type | Description |
volume | Int | Capture volume, with a value range from 0 to 100. |
public func setSpeakerVolume(_ volume: Int) {fatalError("\\(#function) must be overridden by subclass")}
Parameter | Type | Description |
volume | Int | Playback volume, with a value range from 0 to 100. |
public func setCurrentMicrophone(_ microphone: DeviceInfo) {fatalError("\\(#function) must be overridden by subclass")}
Parameter | Type | Description |
microphone | Microphone device, an element of microphoneList. |
public func startMicrophoneTest(interval: Int) {fatalError("\\(#function) must be overridden by subclass")}
Parameter | Type | Description |
interval | Int | Capture interval in milliseconds. Default is 200ms. |
public func stopMicrophoneTest() {fatalError("\\(#function) must be overridden by subclass")}
public func setCurrentSpeaker(_ speaker: DeviceInfo) {fatalError("\\(#function) must be overridden by subclass")}
Parameter | Type | Description |
speaker | Speaker device, an element of speakerList. |
public func startSpeakerTest(filePath: String) {fatalError("\\(#function) must be overridden by subclass")}
Parameter | Type | Description |
filePath | String | Audio file path used for the test playback. Required; an empty value returns an invalid-parameter error. |
public func stopSpeakerTest() {fatalError("\\(#function) must be overridden by subclass")}
public func startCameraTest(cameraView: UIView,completion: CompletionClosure?) {fatalError("\\(#function) must be overridden by subclass")}
Parameter | Type | Description |
cameraView | UIView | Render view id for camera capture, obtained from CameraView.onViewCreated. Pass 0 to set no render target. |
completion | Whether operation succeeded. |
public func stopCameraTest() {fatalError("\\(#function) must be overridden by subclass")}
public func openLocalCamera(isFront: Bool,completion: CompletionClosure?) {fatalError("\\(#function) must be overridden by subclass")}
Parameter | Type | Description |
isFront | Bool | Whether front camera. |
completion | Whether operation succeeded. |
public func closeLocalCamera() {fatalError("\\(#function) must be overridden by subclass")}
public func setCurrentCamera(_ camera: DeviceInfo) {fatalError("\\(#function) must be overridden by subclass")}
Parameter | Type | Description |
camera | Camera device, an element of cameraList. |
public func switchMirror(mirrorType: MirrorType) {fatalError("\\(#function) must be overridden by subclass")}
Parameter | Type | Description |
mirrorType | Mirror state. |
public func updateVideoQuality(_ quality: VideoQuality, orientation: VideoOrientation = .portrait) {fatalError("\\(#function) must be overridden by subclass")}
Parameter | Type | Description |
quality | Video quality. | |
orientation | Video orientation. Defaults to portrait. Pass landscape to use the base (width x height) resolution. |
@available(*, deprecated, message: "Use setMicrophoneVolume instead. Will be removed in version 5.5.")public func setCaptureVolume(volume: Int) {fatalError("\\(#function) must be overridden by subclass")}
Parameter | Type | Description |
volume | Int | Capture volume, with a value range from 0 to 100. |
@available(*, deprecated, message: "Use setSpeakerVolume instead. Will be removed in version 5.5.")public func setOutputVolume(_ volume: Int) {fatalError("\\(#function) must be overridden by subclass")}
Parameter | Type | Description |
volume | Int | Maximum volume, with a value range from 0 to 100. |
@available(*, deprecated, message: "Use setCurrentSpeaker instead. Will be removed in version 5.5.")public func setAudioRoute(_ route: AudioRoute) {fatalError("\\(#function) must be overridden by subclass")}
Parameter | Type | Description |
route | Route location. |
@available(*, deprecated, message: "Use setCurrentCamera instead. Will be removed in version 5.5.")public func switchCamera(isFront: Bool) {fatalError("\\(#function) must be overridden by subclass")}
Parameter | Type | Description |
isFront | Bool | Whether front camera. |
public func reset() {fatalError("\\(#function) must be overridden by subclass")}
Enum Value | Value | Description |
microphone | 1 | Microphone type. |
camera | 2 | Camera type. |
screenShare | 3 | Screen sharing type. |
Enum Value | Value | Description |
noError | 0 | Operation successful. |
noDeviceDetected | 1 | No device detected. |
noSystemPermission | 2 | No system permission. |
notSupportCapture | 3 | Capture not supported. |
occupiedError | 4 | Device occupied. |
unknownError | 5 | Unknown error. |
Enum Value | Value | Description |
off | 0 | Off. |
on | 1 | On. |
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. |
Enum Value | Value | Description |
quality360P | 1 | 360P. Landscape resolution is 640 x 360; portrait (width and height swapped) is 360 x 640. |
quality540P | 2 | 540P. Landscape resolution is 960 x 540; portrait (width and height swapped) is 540 x 960. |
quality720P | 3 | 720P. Landscape resolution is 1280 x 720; portrait (width and height swapped) is 720 x 1280. |
quality1080P | 4 | 1080P. Landscape resolution is 1920 x 1080; portrait (width and height swapped) is 1080 x 1920. |
Enum Value | Value | Description |
landscape | 0 | Landscape, the encoding resolution width is greater than the height (e.g. 1280 x 720). |
portrait | 1 | Portrait, the encoding resolution height is greater than the width (e.g. 720 x 1280). |
Enum Value | Value | Description |
unknown | 0 | Unknown network. |
excellent | 1 | Excellent. |
good | 2 | Good. |
poor | 3 | Poor. |
bad | 4 | Bad. |
veryBad | 5 | Very bad. |
down | 6 | Disconnected. |
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. |
Enum Value | Value | Description |
unknown | 0 | Unknown or unidentified network type. |
wifi | 1 | WiFi network connection. |
cellular | 2 | Cellular/mobile data network connection. |
Property | Type | Description |
deviceId | String | Device ID. |
deviceName | String | Device name. |
Property | Type | Description |
userID | String | User unique ID. |
quality | Network quality. | |
upLoss | UInt32 | Uplink packet loss rate, with a value range from 0 to 100. |
downLoss | UInt32 | Downlink packet loss rate, with a value range from 0 to 100. |
delay | UInt32 | Latency (unit: milliseconds). |
Property | Type | Description |
microphoneStatus | Microphone status. | |
microphoneLastError | Microphone error, used to extract error information when an error occurs. | |
captureVolume | Int | Capture volume, with a value range from 0 to 100. |
currentMicVolume | Int | Current user's actual output volume. |
outputVolume | Int | Maximum output volume, with a value range from 0 to 100. |
cameraStatus | Camera status. | |
cameraLastError | Camera error, used to extract error information when an error occurs. | |
isFrontCamera | Bool | Whether it's front camera. |
localMirrorType | Mirror state. | |
localVideoQuality | Local video quality. | |
currentAudioRoute | Current audio route location. | |
screenStatus | Screen sharing status. | |
networkInfo | Network information. | |
networkType | Current network type. | |
microphoneList | Current microphone device list. Only populated on desktop platforms, it is empty on mobile platforms. | |
currentMicrophone | Current microphone device, an empty deviceId means no microphone is selected. | |
microphoneVolume | Int | Microphone capture volume, with a value range from 0 to 100. |
microphoneInputLevel | Int | Real-time level value used to display the microphone volume bar, range 0-100. |
cameraList | Camera device list. On desktop platforms it contains all the cameras, on mobile platforms it
contains the logical front camera and rear camera. | |
currentCamera | Current camera device, an empty deviceId means no camera is selected. | |
speakerList | Speaker device list. On desktop platforms it contains all the speakers, on mobile platforms it
contains the logical speaker and earpiece. | |
currentSpeaker | Current speaker device, an empty deviceId means no speaker is selected. | |
speakerVolume | Int | Speaker playback volume, with a value range from 0 to 100. |
speakerOutputLevel | Int | Speaker real-time output level value, range 0-100. |
// Get singleton instancelet store = DeviceStore.shared// Subscribe to state changesstore.state.subscribe { state inprint("Microphone status: \\(state.microphoneStatus)")print("Camera status: \\(state.cameraStatus)")print("Network quality: \\(state.networkInfo.quality)")}// Open microphonestore.openLocalMicrophone { code, message inif code == 0 {print("Microphone opened successfully")}}// Open front camerastore.openLocalCamera(isFront: true) { code, message inif code == 0 {print("Camera opened successfully")}}
Esta página foi útil?
Você também pode entrar em contato com a Equipe de vendas ou Enviar um tíquete em caso de ajuda.
comentários