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

# 媒体输出

> 拉流地址（HTTP-FLV / RTSP）与推流任务（RTMP / RTMPS）：画面取合成画面或任意一人，声音取会议混音或任意一人，可自由组合

## 申请拉流地址（HTTP-FLV / RTSP）

`POST /server/v1/stream/pull-url`

鉴权：需要（见[概览](https://docs.stmlink.com/zh/meeting/server-api/overview.md)）

申请会议内音视频的拉流地址（HTTP-FLV 或 RTSP）。画面与声音各自选来源：
画面取会议合成画面、某个用户的某路视频或不要；声音取会议混音、某个用户的某路音频或不要，默认跟随画面。
例如「主讲人画面 + 会议混音」即 video=user、video\_uid=主讲人、audio=mix。

* 用到合成画面或会议混音时，会议须有进行中的合流任务（录制任务 task\_type 含 2），否则返回错误码 1073
* flv：视频须为 H264（不转码，发布端使用 VP8 时拉不到画面），音频转成 AAC
* rtsp：只支持 RTSP over TCP（拉流端需用 TCP 方式，如 ffplay 加 `-rtsp_transport tcp`）；视频原样直通（H264 或 VP8），
  音频默认转成 AAC，传 rtsp\_audio=opus 可原样直通 Opus、省去服务端转码
* 地址自带签名，有效期内可被多个拉流端反复拉取；过期后新的拉流请求会被拒绝，已在播放的不受影响
* 有人来拉时才订阅，最后一个拉流端断开后自动退订，不拉不占资源；无需调用停止接口
* 会议须已开始（频道已开启），否则返回错误码 1024；会议不存在返回 2101
* 不校验用户是否在会；拉流时来源还没发布，拉流端会收到 404，需重试

实际有效期以返回的 expire\_at 为准（服务端配置的上限可能小于请求值）。

**请求参数**

**meeting\_id** `string` *required*

会议ID
示例：`jd8w2k`

**protocol** `string` *required*

拉流协议：flv（HTTP-FLV）、rtsp（RTSP over TCP）
示例：`flv`

**video** `string` *required*

画面来源：mcu 会议合成画面（须有进行中的合流任务）、user 某个用户的画面（配 video\_uid）、none 不要画面
示例：`mcu`

**video\_uid** `string`

video 为 user 时必填：取哪个用户的画面（会中用户ID）（最大长度 64）
示例：`1001`

**video\_desc** `string`

video 为 user 时可选：该用户同时发布多路视频（如摄像头与屏幕共享）时指定其中一路（按轨道描述精确匹配），不传取先到的那一路（最大长度 50）
示例：`camera`

**audio** `string`

声音来源：auto 跟随画面（默认；合成画面配会议混音，单人画面配该用户本人的声音，不要画面时不能用 auto）、 mix 会议混音（须有进行中的合流任务）、user 某个用户的声音（配 audio\_uid）、none 不要声音。画面与声音不能都是 none
示例：`auto`

**audio\_uid** `string`

audio 为 user 时必填：取哪个用户的声音（会中用户ID）（最大长度 64）
示例：`1002`

**audio\_desc** `string`

该用户发布多路音频时指定其中一路（按轨道描述精确匹配），不传取第一路；audio 为 user 或 auto 跟随单人画面时生效（最大长度 50）
示例：`mic`

**expire** `integer`

地址有效期（秒），不传时默认 24 小时，最长一天
示例：`86400`

**rtsp\_audio** `string`

RTSP 的音频编码，仅 protocol 为 rtsp 时生效：aac（默认，兼容 NVR、监控平台）、opus（原样直通，省服务端转码）
示例：`aac`

请求示例：

```json theme={null}
{
  "audio": "auto",
  "audio_desc": "mic",
  "audio_uid": "1002",
  "expire": 86400,
  "meeting_id": "jd8w2k",
  "protocol": "flv",
  "rtsp_audio": "aac",
  "video": "mcu",
  "video_desc": "camera",
  "video_uid": "1001"
}
```

**响应参数**

**url** `string`

拉流地址，自带签名，有效期内可被多个拉流端反复拉取
示例：`http://1.2.3.4:8080/f/eyJhcHBpZCI6....flv`

**expire\_at** `integer`

地址过期时间，秒级时间戳；过期后新的拉流请求会被拒绝，已在播放的不受影响
示例：`1718198266`

响应示例：

```json theme={null}
{
  "code": 0,
  "data": {
    "expire_at": 1718198266,
    "url": "http://1.2.3.4:8080/f/eyJhcHBpZCI6....flv"
  }
}
```

***

## 开始推流

`POST /server/v1/stream/push/start`

鉴权：需要（见[概览](https://docs.stmlink.com/zh/meeting/server-api/overview.md)）

开始推流：把会议内选定的画面与声音推到你的 RTMP 直播间（支持 rtmp\:// 与 rtmps\://），返回 push\_id。
来源参数与申请拉流地址相同，一场会议可以同时有多路推流（如合成画面推视频号、某位嘉宾的单人画面推另一个平台）。

* 会议须进行中（有人在会），会议不存在返回错误码 2101；会议结束、所有人离开后其下全部推流自动停止
* 同一会议对同一推流地址重复调用不会另起一路：来源不变时直接返回已有的 push\_id，来源变了则按新来源更新这一路
* 来源暂时不存在（如合流任务还没开、要推的人还没发布）时推流处于 waiting，不算失败，来源出现后自动开推
* 推流断线会自动重连；推流状态用推流任务列表查
* 没有可用的推流服务时返回错误码 1072，推流地址不合格返回 1075

**请求参数**

**meeting\_id** `string` *required*

会议ID，会议须进行中（有人在会）
示例：`jd8w2k`

**push\_url** `string` *required*

推流地址，支持 rtmp\:// 与 rtmps\://，须带推流码（如 rtmp\://host/app/ 这类流名为空的地址会被拒绝）（最大长度 1024）
示例：`rtmp://live.example.com/app/stream_key`

**video** `string` *required*

画面来源：mcu 会议合成画面（须有进行中的合流任务）、user 某个用户的画面（配 video\_uid）、none 不要画面
示例：`mcu`

**video\_uid** `string`

video 为 user 时必填：取哪个用户的画面（会中用户ID）（最大长度 64）
示例：`1001`

**video\_desc** `string`

video 为 user 时可选：该用户同时发布多路视频（如摄像头与屏幕共享）时指定其中一路（按轨道描述精确匹配），不传取先到的那一路（最大长度 50）
示例：`camera`

**audio** `string`

声音来源：auto 跟随画面（默认；合成画面配会议混音，单人画面配该用户本人的声音，不要画面时不能用 auto）、 mix 会议混音（须有进行中的合流任务）、user 某个用户的声音（配 audio\_uid）、none 不要声音。画面与声音不能都是 none
示例：`auto`

**audio\_uid** `string`

audio 为 user 时必填：取哪个用户的声音（会中用户ID）（最大长度 64）
示例：`1002`

**audio\_desc** `string`

该用户发布多路音频时指定其中一路（按轨道描述精确匹配），不传取第一路；audio 为 user 或 auto 跟随单人画面时生效（最大长度 50）
示例：`mic`

请求示例：

```json theme={null}
{
  "audio": "auto",
  "audio_desc": "mic",
  "audio_uid": "1002",
  "meeting_id": "jd8w2k",
  "push_url": "rtmp://live.example.com/app/stream_key",
  "video": "mcu",
  "video_desc": "camera",
  "video_uid": "1001"
}
```

**响应参数**

**push\_id** `string`

推流任务ID，停止推流、查询推流状态都用它
示例：`p7k2xq`

响应示例：

```json theme={null}
{
  "code": 0,
  "data": {
    "push_id": "p7k2xq"
  }
}
```

***

## 停止推流

`POST /server/v1/stream/push/stop`

鉴权：需要（见[概览](https://docs.stmlink.com/zh/meeting/server-api/overview.md)）

停止推流。已停止的推流再次停止视为成功；push\_id 不存在或不属于这场会议返回错误码 1074。

**请求参数**

**meeting\_id** `string` *required*

会议ID，推流须属于这场会议
示例：`jd8w2k`

**push\_id** `string` *required*

推流任务ID，取自开始推流的返回
示例：`p7k2xq`

请求示例：

```json theme={null}
{
  "meeting_id": "jd8w2k",
  "push_id": "p7k2xq"
}
```

**响应参数**

`data` 为 null

响应示例：

```json theme={null}
{
  "code": 0,
  "data": null
}
```

***

## 推流任务列表

`POST /server/v1/stream/push/list`

鉴权：需要（见[概览](https://docs.stmlink.com/zh/meeting/server-api/overview.md)）

查询会议的推流任务：来源、脱敏后的推流地址、推流状态与最近一次错误，按创建时间倒序。
不传 push\_id 时返回进行中的与最近一天内停止的推流。

状态 status：waiting 等待来源、connecting 正在连接直播平台、publishing 推流中、
retrying 推流失败正在重试（原因见 err）、stopped 已停止。

**请求参数**

**meeting\_id** `string` *required*

会议ID
示例：`jd8w2k`

**push\_id** `string`

推流任务ID，只看某一路时传；不传返回该会议进行中的与最近一天内停止的推流
示例：`p7k2xq`

请求示例：

```json theme={null}
{
  "meeting_id": "jd8w2k",
  "push_id": "p7k2xq"
}
```

**响应参数**

**push\_id** `string`

推流任务ID
示例：`p7k2xq`

**meeting\_id** `string`

会议ID
示例：`jd8w2k`

**video** `string`

画面来源：mcu 合成画面、user 某个用户、none 不要画面
示例：`mcu`

**video\_uid** `string`

video 为 user 时取谁的画面
示例：`1001`

**video\_desc** `string`

video 为 user 时该用户的哪路视频，空表示先到的那路
示例：`camera`

**audio** `string`

声音来源：auto 跟随画面、mix 会议混音、user 某个用户、none 不要声音
示例：`auto`

**audio\_uid** `string`

audio 为 user 时取谁的声音
示例：`1002`

**audio\_desc** `string`

该用户的哪路音频，空表示第一路
示例：`mic`

**push\_url** `string`

推流地址，推流码已脱敏（只保留协议、服务器与第一段路径）
示例：`rtmp://live.example.com/app/***`

**status** `string`

推流状态：waiting 等待来源（如合流任务还没开、要推的人还没发布，来源出现后自动开推，不算失败）、 connecting 正在连接直播平台、publishing 推流中、retrying 推流失败正在重试（原因见 err）、stopped 已停止
示例：`publishing`

**err** `string`

最近一次错误，正常时为空
示例：`connection refused`

**created\_at** `integer`

创建时间，秒级时间戳
示例：`1718194666`

**started\_at** `integer`

开始推流时间（首次进入 publishing 推流中的时刻），秒级时间戳；0 表示还没推起来过（如一直处于 waiting）
示例：`1718194667`

**ended\_at** `integer`

停止时间，秒级时间戳；0 表示未停止
示例：`1718198266`

响应示例：

```json theme={null}
{
  "code": 0,
  "data": [
    {
      "audio": "auto",
      "audio_desc": "mic",
      "audio_uid": "1002",
      "created_at": 1718194666,
      "ended_at": 1718198266,
      "err": "connection refused",
      "meeting_id": "jd8w2k",
      "push_id": "p7k2xq",
      "push_url": "rtmp://live.example.com/app/***",
      "started_at": 1718194667,
      "status": "publishing",
      "video": "mcu",
      "video_desc": "camera",
      "video_uid": "1001"
    }
  ]
}
```

***


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