通话控制
被叫方接听来电,服务端返回 RTC 接入参数,被叫方凭此参数加入频道。
| 项目 | 内容 |
|---|---|
| Method | POST |
| URL | https://devapi.fengshengshou.com/api/calls/{callId}/accept |
| 鉴权 | 是,Bearer Token |
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
| callId | int | 是 | 路径参数,通话 ID |
| terminal_id | string | 是 | 终端标识,最长 64 字符 |
curl -X POST "https://devapi.fengshengshou.com/api/calls/5001/accept" \ -H "Authorization: Bearer your_token_here" \ -H "Content-Type: application/json" \ -d '{"terminal_id": "client-ios-xyz789"}'| 字段 | 类型 | 说明 |
|---|---|---|
| code | int | 状态码,0 表示成功 |
| message | string | 提示信息 |
| data.call_id | int | 通话 ID |
| data.status | string | 当前状态,固定为 accepted |
| data.channel_name | string | RTC 频道名 |
| data.app_id | string | RTC 应用 ID |
| data.callee_uid | string | 被叫 RTC 用户标识 |
| data.rtc_token | string | RTC 接入令牌 |
| data.expire_at | string|null | 令牌过期时间(ISO 8601),可为空 |
| data.version | int | 数据版本号 |
{ "code": 0, "message": "success", "data": { "call_id": 5001, "status": "accepted", "channel_name": "call_5001_1001", "app_id": "xxxxxxxxxxxxxxxx", "callee_uid": "20002", "rtc_token": "xxxxxxxxxxxxxxxxxxxxxx", "expire_at": "2026-07-05T12:30:00Z", "version": 2 }}{ "code": 41004, "message": "非被叫方", "data": null}{ "code": 41006, "message": "已被其他终端接听", "data": null}{ "code": 41007, "message": "通话已结束", "data": null}被叫方拒绝来电。
| 项目 | 内容 |
|---|---|
| Method | POST |
| URL | https://devapi.fengshengshou.com/api/calls/{callId}/reject |
| 鉴权 | 是,Bearer Token |
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
| callId | int | 是 | 路径参数,通话 ID |
| terminal_id | string | 是 | 终端标识,最长 64 字符 |
| reason | string | 否 | 拒绝原因,最长 50 字符,默认 user_reject |
curl -X POST "https://devapi.fengshengshou.com/api/calls/5001/reject" \ -H "Authorization: Bearer your_token_here" \ -H "Content-Type: application/json" \ -d '{"terminal_id": "client-ios-xyz789", "reason": "user_reject"}'| 字段 | 类型 | 说明 |
|---|---|---|
| code | int | 状态码,0 表示成功 |
| message | string | 提示信息 |
| data | object | 通话状态对象,详见通话状态 |
{ "code": 0, "message": "success", "data": { "call_id": 5001, "status": "rejected", "end_reason": "user_reject", "version": 3 }}{ "code": 41004, "message": "非被叫方", "data": null}主叫方在对方接听前取消本次通话。仅主叫方可调用。
| 项目 | 内容 |
|---|---|
| Method | POST |
| URL | https://devapi.fengshengshou.com/api/calls/{callId}/cancel |
| 鉴权 | 是,Bearer Token |
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
| callId | int | 是 | 路径参数,通话 ID |
| terminal_id | string | 是 | 终端标识,最长 64 字符 |
| reason | string | 否 | 取消原因,最长 50 字符,默认 caller_cancel |
curl -X POST "https://devapi.fengshengshou.com/api/calls/5001/cancel" \ -H "Authorization: Bearer your_token_here" \ -H "Content-Type: application/json" \ -d '{"terminal_id": "client-android-abc123", "reason": "caller_cancel"}'| 字段 | 类型 | 说明 |
|---|---|---|
| code | int | 状态码,0 表示成功 |
| message | string | 提示信息 |
| data | object | 通话状态对象,详见通话状态 |
{ "code": 0, "message": "success", "data": { "call_id": 5001, "status": "cancelled", "end_reason": "caller_cancel", "version": 3 }}{ "code": 41005, "message": "非主叫方", "data": null}通话任一参与方均可挂断正在进行的通话。
| 项目 | 内容 |
|---|---|
| Method | POST |
| URL | https://devapi.fengshengshou.com/api/calls/{callId}/hangup |
| 鉴权 | 是,Bearer Token |
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
| callId | int | 是 | 路径参数,通话 ID |
| terminal_id | string | 是 | 终端标识,最长 64 字符 |
| reason | string | 否 | 挂断原因,最长 50 字符,默认 local_hangup |
curl -X POST "https://devapi.fengshengshou.com/api/calls/5001/hangup" \ -H "Authorization: Bearer your_token_here" \ -H "Content-Type: application/json" \ -d '{"terminal_id": "client-android-abc123", "reason": "local_hangup"}'| 字段 | 类型 | 说明 |
|---|---|---|
| code | int | 状态码,0 表示成功 |
| message | string | 提示信息 |
| data | object | 通话状态对象,详见通话状态 |
{ "code": 0, "message": "success", "data": { "call_id": 5001, "status": "ended", "end_reason": "local_hangup", "version": 5 }}{ "code": 41010, "message": "非参与方", "data": null}媒体状态上报
Section titled “媒体状态上报”通话参与方上报本端媒体状态(如加入频道、网络质量变化等),服务端据此更新通话记录。
| 项目 | 内容 |
|---|---|
| Method | POST |
| URL | https://devapi.fengshengshou.com/api/calls/{callId}/media-state |
| 鉴权 | 是,Bearer Token |
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
| callId | int | 是 | 路径参数,通话 ID |
| terminal_id | string | 是 | 终端标识,最长 64 字符 |
| stage | string | 是 | 媒体阶段,最长 32 字符,如 joined |
| network_quality | string | 否 | 网络质量描述,最长 20 字符 |
curl -X POST "https://devapi.fengshengshou.com/api/calls/5001/media-state" \ -H "Authorization: Bearer your_token_here" \ -H "Content-Type: application/json" \ -d '{ "terminal_id": "client-android-abc123", "stage": "joined", "network_quality": "good" }'| 字段 | 类型 | 说明 |
|---|---|---|
| code | int | 状态码,0 表示成功 |
| message | string | 提示信息 |
| data.call_id | int | 通话 ID |
| data.status | string | 当前通话状态 |
| data.started_at | string|null | 首次 joined 时置位的通话开始时间(ISO 8601),可为空 |
| data.version | int | 数据版本号 |
{ "code": 0, "message": "success", "data": { "call_id": 5001, "status": "ongoing", "started_at": "2026-07-05T10:05:30Z", "version": 4 }}{ "code": 41010, "message": "非参与方", "data": null}