> ## Documentation Index
> Fetch the complete documentation index at: https://docs.stmlink.com/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> 对外开放的服务端接口有两组前缀，都用同一套鉴权：`/server/v1/...`（SRTC 与 SMeeting 的主接口）和 `/stm/srvapi/v1/...`（SMeeting 的用户体系，服务端极简对接会用到）。鉴权是 app_id + nonce + timestamp + signature 四个请求头，用 app_key 做 HMAC-SHA256 签名，只能从业务方自己的后端调用。除这两组前缀外的接口均为内部接口，不要建议客户调用。 Public server APIs use two path prefixes with the same authentication: `/server/v1/...` (the main APIs of both SRTC and SMeeting) and `/stm/srvapi/v1/...` (the SMeeting user system, used by server-side low-code integration). Authenticate with four request headers, app_id + nonce + timestamp + signature, where signature is HMAC-SHA256 keyed with app_key; call these APIs only from the customer's own backend. Any other path is internal: never suggest calling it.
> app_key 是服务端密钥，绝不能出现在客户端代码、前端配置或移动 App 里。客户端加入频道用的 token 必须由业务方后端签发后下发（SRTC 走 `/server/v1/channel/grant`，SMeeting 走 `/stm/srvapi/v1/member/grant`）。 app_key is a server-side secret and must never appear in client code, frontend config, or a mobile app. The token a client uses to join must be issued by the customer's backend and passed down to the client (SRTC: `/server/v1/channel/grant`; SMeeting: `/stm/srvapi/v1/member/grant`).
> SRTC 与 SMeeting 是上下两层不同的产品，术语不通用：SRTC 是音视频底座，说「频道 channel」「加入 / 退出」；SMeeting 建在 SRTC 之上，说「房间 room」「会议 meeting」「进入 / 退出」。回答时按用户所在的层用对应术语，不要把「房间」「会议」安到 SRTC 的接口上，也不要用「频道」「加入 / 离开」描述 SMeeting 的概念（接口标识符原样保留）。 SRTC and SMeeting are two separate layers with different terminology. SRTC is the audio/video foundation: it has channels, and users join and leave a channel. SMeeting is built on top of SRTC: it has rooms and meetings, and members enter and exit a meeting. Answer in the terms of the layer the user is working with: never apply "room" or "meeting" to SRTC APIs, and never describe SMeeting concepts in prose with "channel", "join", or "leave" (API identifiers such as `force_join` keep their literal names).
> 同一能力在各端 SDK 里的包名、类名、方法名并不相同。写示例代码时请使用文档中该端自己的 API，不要把一个端的写法套到另一个端上。苹果平台每个产品都有两套 SDK（Swift 原生与 Objective-C），两套 API 不能混用。 Package, class, and method names differ between platform SDKs for the same capability. In sample code, use the API documented for that platform; never carry one platform's code over to another. On Apple platforms each product ships two SDKs (native Swift and Objective-C) whose APIs must not be mixed.

# 设备检测（会前 / 会中预览）

> 在入会前或会中做摄像头、麦克风、扬声器检测：枚举设备、requestOpenCamera 的 publish = false 只预览不推流、isCameraOpened 判断要不要关、麦克风音量只能在会中发布后读、扬声器走音频路由

### 概述

入会前的设备检测页、会中的设置页，都需要「打开设备看一眼，但不推给其他人」。各项检测在鸿蒙会议层的做法：

| 检测项 | 做法 | 支持情况 |
| - | - | - |
| 设备列表 | `getDevices(kind)` | 支持 |
| 摄像头预览 | `requestOpenCamera(preset, false, undefined, false)` | 会前会中都支持（1.6.0 起） |
| 麦克风音量 | `getLocalAudioLevel()` | 只能在会中开麦（已发布）后读 |
| 扬声器 | 外放 / 听筒切换，测试音由业务自己播 | 不能指定任意输出设备 |

***

### 设备列表

```typescript theme={null}
import { DeviceKind, DeviceInfo } from 'srtc';

const cams: DeviceInfo[] = await meeting.getDevices(DeviceKind.videoInput);
const mics: DeviceInfo[] = await meeting.getDevices(DeviceKind.audioInput);
```

摄像头没有插拔事件，进检测页时重新调一次 `getDevices()`。详见[外设管理](https://docs.stmlink.com/zh/meeting/harmony/advanced/device-management.md)。

***

### 摄像头预览

```typescript theme={null}
import { cameraPreset720p, SRTCVideoView } from 'srtc';

// 只采集预览：不请求会控、不发布、不发摄像头状态事件，会中打开也不会推给其他人
const track = await meeting.requestOpenCamera(cameraPreset720p(), false, undefined, false);

// 渲染：SRTCVideoView({ track: meeting.cameraTrack, trackKey: track.id })

// 离开检测页：只关预览打开的；会中摄像头本来就开着（isCameraOpened）就别关
if (!meeting.isCameraOpened) {
  await meeting.closeCamera();
}
```

* 摄像头已作为会议摄像头打开时，`publish = false` 直接返回正在用的轨，预览看到的就是正在发布的画面
* 预览之后要正式开摄像头，调 `requestOpenCamera()`（默认 `publish = true`），会发布同一条轨、不重新采集
* 主持人关摄像头 / 全员禁用不影响只预览的轨
* 切设备用 `switchCameraDevice(deviceId)`，预览轨同样生效

***

### 麦克风音量

`getLocalAudioLevel()` 读的是发送统计，**只有会中开麦（轨道已发布）后才有值**，未开麦 / 不在会中返回 `undefined`。
所以鸿蒙会议层目前做不了「会前只采集不发布地测麦」，`requestOpenMic` 也没有 `publish` 参数。

```typescript theme={null}
// 会中：开麦后按 ≤10Hz 轮询
await meeting.requestOpenMic();
const level: number | undefined = await meeting.getLocalAudioLevel();   // 0~1，线性
```

***

### 扬声器

鸿蒙不支持指定任意输出设备，只能在外放与听筒之间切换（`setSpeakerOutputEnabled` / 音频路由），蓝牙等外设交给系统。
试听测试音需要业务自己用系统播放器播一段音频。详见[音频路由](https://docs.stmlink.com/zh/meeting/harmony/advanced/audio-routing.md)。

***

### 相关阅读

* [媒体控制](https://docs.stmlink.com/zh/meeting/harmony/advanced/media-control.md)
* [媒体控制接口](https://docs.stmlink.com/zh/meeting/harmony/api-reference/media-control.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.