tencent cloud

Tencent Real-Time Communication

소식 및 공지 사항
제품 업데이트
Tencent Cloud 오디오/비디오 단말 SDK 재생 업그레이드 및 권한 부여 인증 추가
TRTC 월간 구독 패키지 출시 관련 안내
제품 소개
제품 개요
기본 개념
제품 기능
제품 장점
응용 시나리오
성능 데이터
구매 가이드
Billing Overview
무료 시간 안내
Monthly subscription
Pay-as-you-go
TRTC Overdue and Suspension Policy
과금 FAQ
Refund Instructions
신규 사용자 가이드
Demo 체험
Call
개요(TUICallKit)
Activate the Service
Run Demo
빠른 통합(TUICallKit)
오프라인 푸시
Conversational Chat
온클라우드 녹화(TUICallKit)
AI Noise Reduction
UI 사용자 정의
Calls integration to Chat
Additional Features
No UI Integration
Server APIs
Client APIs
Solution
ErrorCode
릴리스 노트
FAQs
라이브 스트리밍
Billing of Video Live Component
Overview
Activating the Service (TUILiveKit)
Demo 실행
No UI Integration
UI Customization
Live Broadcast Monitoring
Video Live Streaming
Voice Chat Room
Advanced Features
Client APIs
Server APIs
Error Codes
Release Notes
FAQs
RTC Engine
Activate Service
SDK 다운로드
API 코드 예시
Usage Guidelines
API 클라이언트 API
고급 기능
RTC RESTFUL API
History
Introduction
API Category
Room Management APIs
Stream mixing and relay APIs
On-cloud recording APIs
Data Monitoring APIs
Pull stream Relay Related interface
Web Record APIs
AI Service APIs
Cloud Slicing APIs
Cloud Moderation APIs
Making API Requests
Call Quality Monitoring APIs
Usage Statistics APIs
Data Types
Appendix
Error Codes
콘솔 가이드
애플리케이션 관리
사용량 통계
모니터링 대시보드
개발 보조
Solution
Real-Time Chorus
FAQs
과금 개요
기능 관련
UserSig 관련
방화벽 제한 처리
설치 패키지 용량 축소 관련 질문
Andriod 및 iOS 관련
Web 관련
Flutter 관련
Electron 관련
TRTCCalling Web 관련
멀티미디어 품질 관련
기타 질문
Protocols and Policies
컴플라이언스 인증
보안 백서
정보 보안에 관한 참고 사항
Service Level Agreement
Apple Privacy Policy: PrivacyInfo.xcprivacy
TRTC 정책
개인 정보 보호 정책
데이터 처리 및 보안 계약
용어집

DeviceStore

PDF
포커스 모드
폰트 크기
마지막 업데이트 시간: 2026-03-05 17:06:13

Introduction

DeviceStore provides a comprehensive set of APIs to manage audio and video devices, including microphone, camera and screen sharing features.
Important:
Use shared singleton to get the DeviceStore instance. Do not attempt to initialize directly.
Note:
Device state updates are delivered through the state 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
Microphone status.
microphoneLastError
Microphone error, used to extract error information when an error occurs.
captureVolume
Int
Capture volume, range [0, 100].
currentMicVolume
Int
Current user's actual output volume.
outputVolume
Int
Maximum output volume, range [0, 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.

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

shared

Singleton object

Microphone Operations

openLocalMicrophone

Open local microphone
public func openLocalMicrophone(completion: CompletionClosure?) {
fatalError("\\(#function) must be overridden by subclass")
}
Version
Supported since version 3.5.
Parameters
Parameter
Type
Required
Description
completion
Required
Whether operation succeeded.

closeLocalMicrophone

Close local microphone
public func closeLocalMicrophone() {
fatalError("\\(#function) must be overridden by subclass")
}
Version
Supported since version 3.5.

setCaptureVolume

Set capture volume
public func setCaptureVolume(volume: Int) {
fatalError("\\(#function) must be overridden by subclass")
}
Version
Supported since version 3.5.
Parameters
Parameter
Type
Required
Description
volume
Int
Required
Capture volume, range [0, 100].

setOutputVolume

Set maximum output volume
public func setOutputVolume(_ volume: Int) {
fatalError("\\(#function) must be overridden by subclass")
}
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
public func setAudioRoute(_ route: AudioRoute) {
fatalError("\\(#function) must be overridden by subclass")
}
Version
Supported since version 3.5.
Parameters
Parameter
Type
Required
Description
route
Required
Route location.

Camera Operations

startCameraTest

Start camera test, if camera opens successfully, the view will be rendered to the set CameraView
public func startCameraTest(
cameraView: UIView,
completion: CompletionClosure?
) {
fatalError("\\(#function) must be overridden by subclass")
}
Version
Supported since version 3.5.
Parameters
Parameter
Type
Required
Description
cameraView
UIView
Required
Rendering view for camera capture.
completion
Required
Whether operation succeeded.

stopCameraTest

Stop camera test
public func stopCameraTest() {
fatalError("\\(#function) must be overridden by subclass")
}
Version
Supported since version 3.5.

openLocalCamera

Open local camera
public func openLocalCamera(
isFront: Bool,
completion: CompletionClosure?
) {
fatalError("\\(#function) must be overridden by subclass")
}
Version
Supported since version 3.5.
Parameters
Parameter
Type
Required
Description
isFront
Bool
Required
Whether front camera.
completion
Required
Whether operation succeeded.

closeLocalCamera

Close local camera
public func closeLocalCamera() {
fatalError("\\(#function) must be overridden by subclass")
}
Version
Supported since version 3.5.

switchCamera

Switch camera
public func switchCamera(isFront: Bool) {
fatalError("\\(#function) must be overridden by subclass")
}
Version
Supported since version 3.5.
Parameters
Parameter
Type
Required
Description
isFront
Bool
Required
Whether front camera.

switchMirror

Switch mirror state
public func switchMirror(mirrorType: MirrorType) {
fatalError("\\(#function) must be overridden by subclass")
}
Version
Supported since version 3.5.
Parameters
Parameter
Type
Required
Description
mirrorType
Required
Mirror state.

updateVideoQuality

Update video quality
public func updateVideoQuality(_ quality: VideoQuality) {
fatalError("\\(#function) must be overridden by subclass")
}
Version
Supported since version 3.5.
Parameters
Parameter
Type
Required
Description
quality
Required
Video quality.

Screen Sharing

startScreenShare

Start screen sharing
public func startScreenShare(appGroup: String) {
fatalError("\\(#function) must be overridden by subclass")
}
Version
Supported since version 3.5.
Parameters
Parameter
Type
Required
Description
appGroup
String
Required
App Group ID.

stopScreenShare

Stop screen capture
public func stopScreenShare() {
fatalError("\\(#function) must be overridden by subclass")
}
Version
Supported since version 3.5.

Reset

reset

Reset to default state
public func reset() {
fatalError("\\(#function) must be overridden by subclass")
}
Version
Supported since version 3.5.

Data Structures

DeviceType

Device type
Enum Value
Value
Description
microphone
0
Microphone type.
camera
1
Camera type.
screenShare
2
Screen sharing type.

DeviceError

Device related error codes
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.

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
quality360P
1
360P.
quality540P
2
540P.
quality720P
3
720P.
quality1080P
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.
veryBad
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
UInt32
Uplink packet loss rate, range [0, 100].
downLoss
UInt32
Downlink packet loss rate, range [0, 100].
delay
UInt32
Latency (unit: milliseconds).

DeviceState

Device state
Property
Type
Description
microphoneStatus
Microphone status.
microphoneLastError
Microphone error, used to extract error information when an error occurs.
captureVolume
Int
Capture volume, range [0, 100].
currentMicVolume
Int
Current user's actual output volume.
outputVolume
Int
Maximum output volume, range [0, 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.

Usage Example

// Get singleton instance
let store = DeviceStore.shared

// Subscribe to state changes
store.state.subscribe { state in
print("Microphone status: \\(state.microphoneStatus)")
print("Camera status: \\(state.cameraStatus)")
print("Network quality: \\(state.networkInfo.quality)")
}

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

// Open front camera
store.openLocalCamera(isFront: true) { code, message in
if code == 0 {
print("Camera opened successfully")
}
}


도움말 및 지원

문제 해결에 도움이 되었나요?

피드백