> ## 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.

# Device checks (pre-meeting / in-meeting preview)

> Check the camera, microphone, and speaker before or during a meeting: list devices, preview without publishing via requestOpenCamera(publish: false), use isCameraOpened to decide whether to close, and the limits and workarounds for mic level and speaker tests on Apple platforms

### Overview

A pre-meeting device check page and an in-meeting settings page both need to "turn the device on to take a look without sending it to anyone". How each check works on the Swift meeting layer:

| Check | How | Support |
| - | - | - |
| Device list | `getDevices(kind:)` | iOS / macOS |
| Camera preview | `requestOpenCamera(publish: false)` | iOS / macOS, before and during a meeting, since 1.9.0 |
| Mic level | After opening the mic in a meeting, read your own entry in `activeSpeakersDidChange` | **Testing the mic outside a meeting or capture-only isn't supported yet**; see below |
| Speaker test | On macOS, choose the device with `setAudioOutput(deviceId:)`; play the test sound yourself | The SDK has no speaker test API |

***

### Device list

```swift theme={null}
let cameras = meeting.getDevices(kind: .videoInput)
let microphones = meeting.getDevices(kind: .audioInput)
let speakers = meeting.getDevices(kind: .audioOutput)
```

For device hot-plugging and switching, see [Device management](https://docs.stmlink.com/en/meeting/swift/advanced/device-management.md).

***

### Camera preview

With `publish: false`, `requestOpenCamera` only captures and previews: it doesn't ask the meeting for permission, doesn't publish, and doesn't fire camera state events, and you can call it before or during a meeting. The host turning off your camera or disabling cameras for everyone doesn't affect a preview-only track.

```swift theme={null}
// Open the preview (pass view in UIKit / AppKit; in SwiftUI pass nil and render with SRTCVideoView(track:))
let track = try await meeting.requestOpenCamera(
    view: previewView,
    deviceId: selectedCameraId,
    publish: false
)

// The user picked another camera on the check page: call it again with the new deviceId
try await meeting.requestOpenCamera(view: previewView, deviceId: newCameraId, publish: false)

// Close the preview: close only a preview-only camera; leave the meeting camera alone
if !meeting.isCameraOpened {
    await meeting.closeCamera()
}
```

What happens in each combination:

* **Deciding to turn the camera on after previewing**: call `requestOpenCamera()` again with the default `publish: true`. It asks the meeting for permission and publishes **the same track**, without restarting capture, so the picture doesn't flicker.
* **Opening a preview while the meeting camera is already on**: `publish: false` just returns the track in use and doesn't start another capture. `isCameraOpened` is then `true`, so don't call `closeCamera()` when closing the preview.
* **A camera opened with default parameters before entering a meeting**: calling `requestOpenCamera()` again after entering publishes it to the meeting.

***

### Mic level

`requestOpenMic` on the Swift meeting layer has **no** `publish: false`, so testing the mic outside a meeting or capture-only without publishing isn't supported yet. This is a limit of the audio pipeline on Apple platforms: the microphone stays muted until it is published, and the recording pipeline outside a meeting doesn't start until you enter one, so no valid level can be read.

After opening the mic in a meeting, you can show your own level from your entry (`isLocal == true`) in the active speaker event:

```swift theme={null}
func meeting(_ meeting: SMeetingEngine, activeSpeakersDidChange snapshot: ActiveSpeakersSnapshot) {
    let myLevel = snapshot.speakers.first(where: { $0.isLocal })?.level ?? 0
    micLevelView.update(myLevel)   // 0–1
}
```

If a pre-meeting check page really needs a mic test, capture a short sample yourself with the system `AVAudioRecorder` / `AVAudioEngine` to read the level, and release it before entering the meeting.

***

### Speaker test

The SDK has no API for playing a test sound; play it yourself with `AVAudioPlayer`:

* **macOS**: first select the output device to test with `try meeting.setAudioOutput(deviceId:)`, then play the test sound.
* **iOS**: the output route is decided by the system. Use `setSpeakerOutputEnabled(_:)` to switch between the speaker and the earpiece, and leave external devices such as Bluetooth to the system route picker; see [Audio routing](https://docs.stmlink.com/en/meeting/swift/advanced/audio-routing.md).

***

### Related pages

* [Device management](https://docs.stmlink.com/en/meeting/swift/advanced/device-management.md)
* [Media control API](https://docs.stmlink.com/en/meeting/swift/api-reference/media-control.md)


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