tencent cloud

Tencent Real-Time Communication

お知らせ・リリースノート
製品アップデート情報
Tencent Cloudオーディオビデオ端末SDKの再生アップグレードおよび承認チェック追加に関するお知らせ
TRTCアプリケーションのサブスクリプションパッケージサービスのリリースに関する説明について
製品の説明
製品概要
基礎概念
製品の機能
製品の強み
ユースケース
性能データ
購入ガイド
Billing Overview
無料時間の説明
Monthly subscription
Pay-as-you-go
TRTC Overdue and Suspension Policy
課金に関するよくあるご質問
Refund Instructions
初心者ガイド
Demo体験
Call
コンポーネントの説明(TUICallKit)
Activate the Service
Run Demo
クイック導入
オフライン通知
Conversational Chat
クラウドレコーディング(TUICallKit)
AI Noise Reduction
インターフェースのカスタマイズ
Calls integration to Chat
Additional Features
No UI Integration
Server APIs
Client APIs
Solution
ErrorCode
公開ログ
よくある質問
ライブ配信
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
高度な機能
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
よくあるご質問
課金関連問題
機能関連
UserSig関連
ファイアウォールの制限の対応関連
インストールパッケージの圧縮に関するご質問
AndriodおよびiOS関連
Web端末関連
Flutter関連
Electron関連
TRTCCalling Web関連
オーディオビデオ品質関連
その他のご質問
旧バージョンのドキュメント
TUIRoom(Web)の統合
TUIRoom (Android)の統合
TUIRoom (iOS)の統合
TUIRoom (Flutter)の統合
TUIRoom (Electron)の統合
TUIRoom APIのクエリー
クラウドレコーディングと再生の実現(旧)
Protocols and Policies
セキュリティコンプライアンス認証
セキュリティホワイトペーパー
情報セキュリティの説明
Service Level Agreement
Apple Privacy Policy: PrivacyInfo.xcprivacy
TRTC ポリシー
プライバシーポリシー
データ処理とセキュリティ契約
用語集

DeviceStore

PDF
フォーカスモード
フォントサイズ
最終更新日: 2026-03-05 16:32:08

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
ValueListenable<DeviceStatus>
Microphone status.
microphoneLastError
ValueListenable<DeviceError>
Microphone error, used to extract error information when an error occurs.
captureVolume
ValueListenable<int>
Capture volume, range [0, 100].
currentMicVolume
ValueListenable<int>
Current user's actual output volume.
outputVolume
ValueListenable<int>
Maximum output volume, range [0, 100].
cameraStatus
ValueListenable<DeviceStatus>
Camera status.
cameraLastError
ValueListenable<DeviceError>
Camera error, used to extract error information when an error occurs.
isFrontCamera
ValueListenable<bool>
Whether it's front camera.
localMirrorType
ValueListenable<MirrorType>
Mirror state.
localVideoQuality
ValueListenable<VideoQuality>
Local video quality.
currentAudioRoute
ValueListenable<AudioRoute>
Current audio route location.
screenStatus
ValueListenable<DeviceStatus>
Screen sharing status.
networkInfo
ValueListenable<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
Future<CompletionHandler> openLocalMicrophone();
Version
Supported since version 3.5.
Parameters
Parameter
Type
Required
Description
completion
CompletionClosure?
Required
Whether operation succeeded.

closeLocalMicrophone

Close local microphone
void closeLocalMicrophone();
Version
Supported since version 3.5.

setCaptureVolume

Set capture volume
void setCaptureVolume(int volume);
Version
Supported since version 3.5.
Parameters
Parameter
Type
Required
Description
volume
int
Required
Capture volume, range [0, 100].

setOutputVolume

Set maximum output volume
void setOutputVolume(int volume);
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
void setAudioRoute(AudioRoute route);
Version
Supported since version 3.5.
Parameters
Parameter
Type
Required
Description
route
Required
Route location.

Camera Operations

startCameraTest(cameraView:completion:)

Start camera test

stopCameraTest()

Stop camera test

openLocalCamera

Open local camera
Future<CompletionHandler> openLocalCamera(bool isFront);
Version
Supported since version 3.5.
Parameters
Parameter
Type
Required
Description
isFront
bool
Required
Whether front camera.
completion
CompletionClosure?
Required
Whether operation succeeded.

closeLocalCamera

Close local camera
void closeLocalCamera();
Version
Supported since version 3.5.

switchCamera

Switch camera
void switchCamera(bool isFront);
Version
Supported since version 3.5.
Parameters
Parameter
Type
Required
Description
isFront
bool
Required
Whether front camera.

switchMirror

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

updateVideoQuality

Update video quality
void updateVideoQuality(VideoQuality quality);
Version
Supported since version 3.5.
Parameters
Parameter
Type
Required
Description
quality
Required
Video quality.

Screen Sharing

startScreenShare

Start screen sharing
void startScreenShare();
Version
Supported since version 3.5.

stopScreenShare

Stop screen capture
void stopScreenShare();
Version
Supported since version 3.5.

Reset

reset

Reset to default state
void reset();
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
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
ValueListenable<DeviceStatus>
Microphone status.
microphoneLastError
ValueListenable<DeviceError>
Microphone error, used to extract error information when an error occurs.
captureVolume
ValueListenable<int>
Capture volume, range [0, 100].
currentMicVolume
ValueListenable<int>
Current user's actual output volume.
outputVolume
ValueListenable<int>
Maximum output volume, range [0, 100].
cameraStatus
ValueListenable<DeviceStatus>
Camera status.
cameraLastError
ValueListenable<DeviceError>
Camera error, used to extract error information when an error occurs.
isFrontCamera
ValueListenable<bool>
Whether it's front camera.
localMirrorType
ValueListenable<MirrorType>
Mirror state.
localVideoQuality
ValueListenable<VideoQuality>
Local video quality.
currentAudioRoute
ValueListenable<AudioRoute>
Current audio route location.
screenStatus
ValueListenable<DeviceStatus>
Screen sharing status.
networkInfo
ValueListenable<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")
}
}


ヘルプとサポート

この記事はお役に立ちましたか?

フィードバック