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

# Cloud recording and live streaming guide

> How cloud recording, stream mixing, and live streaming work for meetings: combining task types, when tasks start automatically, layouts and grid assignment, and how to get recording files and live stream URLs. Read this before integrating meeting recording.

This page covers how cloud recording and live streaming work as a whole. For the parameters and response structure of each endpoint, see [Meeting recording and live streaming](/en/meeting/server-api/mcu).

## One task, four capabilities

`task_type` is a **bit mask**. Each of the four independent capabilities takes one bit; add the values of the ones you want at the same time:

| Value | Capability | Output | How to get it |
| - | - | - | - |
| 1 | Video recording | Recording files (possibly several segments) | [Get the playback URL of a recording file](/en/meeting/server-api/mcu#get-the-playback-url-of-a-recording-file) |
| 2 | Stream mixing | Mixes multiple streams into one | Re-streaming, for downstream systems that don't support multiple streams |
| 4 | Audio recording | Audio-only file | Same as video recording |
| 8 | Live stream | Live stream playback URL | [Get live stream URLs](/en/meeting/server-api/mcu#get-live-stream-urls) |

So `3` = video recording + stream mixing, `9` = video recording + live stream, and `15` = all four.

<Warning>Don't treat `3` as a separate "hybrid mode" type. Earlier docs listed the values as "1 recording, 2 mixing, 3 hybrid", which was wrong—it left out audio recording and live stream, and misrepresented how the values combine.</Warning>

## Some tasks start automatically

This is where SMeeting differs most from the underlying SRTC: **not every recording needs you to call start manually**.
When the first person enters the meeting, the server decides whether to start a task based on the meeting's own settings:

| Meeting | Automatically started `task_type` |
| - | - |
| Regular meeting, `auto_record` off | None |
| Regular meeting, `auto_record` on | `1` video recording |
| **Scheduled** meeting in composite mode, `auto_record` off | `2` stream mixing |
| **Scheduled** meeting in composite mode, `auto_record` on | `3` video recording + stream mixing |

If live streaming is enabled in your deployment, `8` (live stream) is added to every row above—for example, a regular meeting with
`auto_record` on actually starts `9`. This switch is set by the deployment, not by the API. If you're not sure, ask us.

Automatically started tasks use the meeting's own `layout_data` for the layout, or `auto` if none is set.

So: **set `auto_record` to `true` when you create the meeting, and you don't need to manage starting and stopping recording in your business logic.**
Calling [start](/en/meeting/server-api/mcu#start-or-update-a-recording-task) manually is for cases like "deciding to record partway through the meeting".

## Calling start again for the same meeting updates the task instead of creating one

A meeting has only one in-progress task per type. Calling `start` again with different parameters changes the existing task
(for example, switching the layout). It doesn't create another task or a second recording file.

## Key differences between video recording and live streaming

| | Video recording | Live streaming |
| - | - | - |
| When the URL is available | After you receive the `mcu_record_done` callback | While the task is **in progress** |
| Use | Playback and archiving afterward | Distributing the video to an audience that doesn't take part in the interaction |
| URL expiration | Yes; get a new URL before each playback | Yes |

<Note>To get playback URLs, wait for the [`mcu_record_done` callback](/en/meeting/server-api/guides/callbacks). Don't request them as soon as the task ends—transcoding usually isn't finished yet.</Note>

## Choosing a layout

`layout_data.layout` determines the video layout. `auto` picks a grid automatically based on the number of online members, which **works for most cases**;
specify a layout only when you need a fixed one:

| Value | Description |
| - | - |
| `auto` | Automatic, picks a grid based on the number of online members |
| `full` | Single full-screen view |
| `grids_N` | Equal grid, where N is 2, 3, 4, 5, 6, 8, 9, 12, 16, 20, or 25 (`grids_3` is a pyramid layout) |
| `right_4` / `top_4` | Main view + small views on the right / at the top |
| `br_7` / `tl_7` | Bottom L-shape / top L-shape |
| `tb_8` | Side-by-side layout |

Note that N in `grids_N` is **not continuous** (there is no 7, 10, or 11). Passing an unsupported value returns an error.

If you don't want to pass the layout every time, put a common watermark, labels, and layout policy in the [recording settings](/en/meeting/server-api/mcu#save-recording-settings).

## Pinning members to specific views

`layout_data.div_list` pins specific users to specific views. Views without an assignment are filled automatically in the order members entered the meeting.

* `cells[].idx` is the view index, in the same order as `<td>` cells in an HTML table (left to right, top to bottom)
* **Leaving `uids` empty** means "the remaining online users rotate through these views" (global rotation); **listing several** means those users rotate through these views (group rotation)
* `polling_dur` is the rotation interval in seconds; `0` means no rotation
* When `cells[].bind_share` is `true`, the view is bound to the in-meeting screen sharing stream first

A typical use is "host pinned to the large view, everyone else rotating through the small views": put the host's
`user_id` in the large view's `cells`, and leave `uids` empty in the small views' `cells` with `polling_dur` set.

## Behavior when no one is in the meeting

`layout_data.nobody_text` determines what happens when no one is in the meeting:

* **Empty** → recording pauses (recommended, to avoid long stretches of black video)
* **Text set** → recording continues and shows the text

## Watermark and member name labels

* `watermark.type`: `0` default, `1` none, `2` single row, `3` multiple rows. If `watermark.text` is empty, the meeting title is used as the watermark
* The position of member name labels is written as a combination of letters: `L` left, `R` right, `T` top, `B` bottom, which can be combined (`LB` = bottom left). **Empty means no labels**
* Leave font size, color, and outline at their defaults; set them only when you have specific visual requirements

## Full sequence

```text theme={null}
1. Optional: configure the app's default recording settings    POST /server/v1/mcu/save-record-config
2. Set auto_record when creating the meeting                   POST /server/v1/meet/create
   → the task starts automatically when the first person enters; skip to step 5
   Or: start manually partway through the meeting              POST /server/v1/mcu/start        → task_id
3. task_type includes 8 → live stream URL available right away POST /server/v1/mcu/live-url
4. End                                                         POST /server/v1/mcu/stop
5. Get playback after the mcu_record_done callback             POST /server/v1/mcu/vod-url   (one segment by record_id)
   For all segments of the meeting                             POST /server/v1/mcu/vods-url
```

## One recording produces multiple files

**Recording is not "one recording, one file".** Two situations split it into multiple files:

* The recording is longer than the segment limit (1 hour by default): when transcoding after the task ends, it is split into rolling segments by duration, with continuous time between segments
* The underlying recording stops automatically partway through because there has been no audio or video for 30 seconds, and is then restarted: a new segment starts, **with a time gap between segments**

So keep three things in mind when integrating:

1. **Get URLs by `record_id`, not `task_id`.** The `mcu_record_done` callback is sent per file, so one recording sends several,
   each with its own `record_id`. `task_id` identifies the whole task and only locates the task.
2. **`vods-url` returns all segments of the meeting in one call**, sorted by segment number. Each segment includes `record_id` / `seq` / `began_at` /
   `duration` / `offset_ms`. For continuous playback, play in `seq` order and use `offset_ms` to build the progress bar.
3. **There is a time gap between a `reason=2` segment and the previous one** (recording was interrupted). Continuous playback jumps there, so it's worth showing a hint in your UI.

The four `vods-url` fields `url` / `size` / `mcu_at` / `mcu_dur` keep their meaning (`mcu_at` is this segment's start time,
`mcu_dur` is this segment's duration). If you already integrated with these fields, you don't need to change anything.

<Note>
  Recording files start transcoding and uploading only **after the task ends**. So there is a wait between stopping the recording and being able to play it,
  and longer for long recordings. To tell when a recording is playable, rely on the `mcu_record_done` callback (`is_last` is `true` on the last one),
  not on the task status changing to "ended".
</Note>

## Billing note

Video recording, audio recording, and live streaming are server-side capabilities that incur ongoing costs. Leaving `auto_record` on means every meeting is recorded—
confirm that's what you want before going live. For manually started tasks, it's best to explicitly call stop in your meeting-ending flow.
