Skip to content

Commit

Permalink
Add callback.
Browse files Browse the repository at this point in the history
  • Loading branch information
winlinvip committed Oct 25, 2023
1 parent 8e5353e commit f9713bd
Show file tree
Hide file tree
Showing 4 changed files with 134 additions and 0 deletions.
File renamed without changes.
File renamed without changes.
67 changes: 67 additions & 0 deletions i18n/zh-cn/docusaurus-plugin-content-pages/faq-srs-stack.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
* [成本优化](#cost-opt):关于成本和成本优化。
* [OpenAPI](#openapi): 关于开放API,使用API获取相关信息。
* [功能列表](#features): 关于支持的功能清单。
* [HTTP Callback](#http-callback): 关于支持的HTTP回调。
* [版本规划](#changelog): 关于版本和里程碑。

你也可以在页面中搜索关键字。
Expand Down Expand Up @@ -575,6 +576,72 @@ SRS Stack的使用说明,请参考视频[SRS Stack:起步、购买和入门]

欢迎加群探讨SRS Stack的使用,这些SRS的周边服务都是开源的,可以自己定制后部署。

<a name='http-callback'></a><br/><br/><br/>

## HTTP Callback

所有请求的格式是json:

* `Content-Type: application-json`

所有响应都应该遵守:

* 成功:`Status: 200 OK` and `"code": 0`
* 其他代表失败或错误。

关于如何实现回调的处理,请参考[HTTP Callback](/docs/v6/doc/http-callback#go-example)

### HTTP Callback: on_publish

对于回调事件`on_publish`,协议定义如下:

```json
Request:
{
"action": "on_unpublish",
"opaque": "mytoken",
"vhost": "__defaultVhost__",
"app": "live",
"stream": "livestream",
"param": "?secret=8f7605d657c74d69b6b48f532c469bc9",
"server_id": "vid-f91k836",
"client_id": "e8d29ue3"
}

Response:
{
"code": 0
}
```

* 返回成功,则允许推流。
* 返回失败,则禁止推流。

### HTTP Callback: on_unpublish

对于回调事件`on_unpublish`,协议定义如下:

```json
Request:
{
"action": "on_unpublish",
"opaque": "mytoken",
"vhost": "__defaultVhost__",
"app": "live",
"stream": "livestream",
"param": "?secret=8f7605d657c74d69b6b48f532c469bc9",
"server_id": "vid-f91k836",
"client_id": "e8d29ue3"
}

Response:
{
"code": 0
}
```

* 错误时忽略。

<a name='changelog'></a><br/><br/><br/>

## Changelog
Expand Down
67 changes: 67 additions & 0 deletions src/pages/faq-srs-stack.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ Quick Content
* [Cost Optimization](#cost-opt): About cost and cost optimization.
* [OpenAPI](#openapi): About open API, using API to get related information.
* [Feature List](#features): About the list of supported features.
* [HTTP Callback](#http-callback): About HTTP callback.
* [Version Planning](#changelog): About versions and milestones.

You can also search for keywords on the page.
Expand Down Expand Up @@ -561,6 +562,72 @@ Currently, the scenarios and functions supported by SRS Stack, see [Features](ht

Welcome to join the group to discuss the use of SRS Stack. All these SRS peripheral services are open-source and can be customized and deployed by yourself.

<a name='http-callback'></a><br/><br/><br/>

## HTTP Callback

All requests should be:

* `Content-Type: application-json`

All responses should use:

* `Status: 200 OK` and `"code": 0` for success.
* Otherwise, error or fail.

See examples in [HTTP Callback](/docs/v6/doc/http-callback#go-example)

### HTTP Callback: on_publish

For HTTP callback `on_publish` event:

```json
Request:
{
"action": "on_unpublish",
"opaque": "mytoken",
"vhost": "__defaultVhost__",
"app": "live",
"stream": "livestream",
"param": "?secret=8f7605d657c74d69b6b48f532c469bc9",
"server_id": "vid-f91k836",
"client_id": "e8d29ue3"
}

Response:
{
"code": 0
}
```

* Allow publishing if response success.
* Reject publishing if response error.

### HTTP Callback: on_unpublish

For HTTP callback `on_unpublish` event:

```json
Request:
{
"action": "on_unpublish",
"opaque": "mytoken",
"vhost": "__defaultVhost__",
"app": "live",
"stream": "livestream",
"param": "?secret=8f7605d657c74d69b6b48f532c469bc9",
"server_id": "vid-f91k836",
"client_id": "e8d29ue3"
}

Response:
{
"code": 0
}
```

* Ignore any response error.

<a name='changelog'></a><br/><br/><br/>

## Changelog
Expand Down

0 comments on commit f9713bd

Please sign in to comment.