關于webrtc的流信令只有四個
/rtc/v1/publish/,這是推流接口,是推流客戶端跟SRS交換SDP的接口
/rtc/v1/play/,這是拉流接口,是拉流客戶端跟SRS交換SDP的接口
/rtc/v1/whip/,這也是推流接口,作用是也是交換SDP,只是采用的是WebRTC 的標準信令
/rtc/v1/whip-play/,這是拉流接口,作用是也是交換SDP,只是采用的是WebRTC 的標準信令
POST /rtc/v1/publish/
Body in JSON:
{"api": "https://d.ossrs.net/rtc/v1/publish/""streamurl": "webrtc://d.ossrs.net/live/3abd9f34","sdp": "v=0\r\n......\r\na=ssrc:2064016335 label:c8243ce9-ace5-4d17-9184-41a2543101b5\r\n"
}
返回如下
{"code": 0"sdp": "v=0\r\n......\r\na=candidate:1 1 udp 2130706431 172.18.0.4 8000 typ host generation 0\r\n""sessionid": "186tj710:hMub"
}
這個是srs自定義的信令,更多詳細見上文給到的官網
關于whip和whep,webrtc官方沒有指定標準信令,但這個幾乎快成為公認的webrtc信令了,obs最新版也開始支持whip信令推流webrtc了。
什么是whip
全稱: WebRTC-HTTP ingestion protocol (WHIP).
rfc地址: rfc-draft-murillo-whip-00
webrtc publish/
方法: http post
uri: http://hostname:hostport/publish/roomId/uid
http post body: offerSdp
返回:
http body: answerSdp
這個srs官網沒有給出,因為他是公開的標準,詳細見:whip和whep
除此之外srs還有很多其他特別好用的信令,可以用curl命令執行這些信令作測試。
1.查看當前有多少人在推流拉流
GET http://yourip:1985/api/v1/streams
“clients”:2共有2個客戶端在推拉流,“send_bytes”,“recv_bytes”,srs總共收到了多少流和推出了多少流。publish,推流客戶端的id等。
{"code":0,"server":"vid-k73qd86","service":"d131vgjy","pid":"14885",
"streams":[{"id":"vid-31x2o91",
"name":"livestreamShow","vhost":"vid-5735q8a",
"app":"live",
"tcUrl":"webrtc://118.190.201.242:1990/live",
"url":"/live/livestreamShow","live_ms":1700663886254,
"clients":2,"frames":0,
"send_bytes":86035991,"recv_bytes":70223513,
"kbps":{"recv_30s":279,"send_30s":335},
"publish":{"active":true,"cid":"980tr2m6"},
"video":null,"audio":null}]}
2.可以看到獲得了這個2個客戶端詳細的信息,他們的ip,name,id等
GET http://yourip:1985/api/v1/clients
{"code":0,"server":"vid-k73qd86","service":"d131vgjy","pid":"14885","clients":[{"id":"980tr2m6","vhost":"vid-5735q8a","stream":"vid-31x2o91",
"ip":"111.32.97.245","pageUrl":"","swfUrl":"","tcUrl":"webrtc://118.190.201.242:1990/live",
"url":"/live/livestreamShow","name":"livestreamShow","type":"rtc-publish",
"publish":true,"alive":2355.50,"send_bytes":1607988,"recv_bytes":83824825,"kbps":{"recv_30s":263,"send_30s":5}},{"id":"flmxmk29","vhost":"vid-5735q8a","stream":"vid-31x2o91",
"ip":"111.32.97.245","pageUrl":"","swfUrl":"","tcUrl":"webrtc://118.190.201.242:1990/live",
"url":"/live/livestreamShow","name":"livestreamShow","type":"rtc-play",
"publish":false,"alive":2393.43,"send_bytes":102710561,"recv_bytes":2065048,"kbps":{"recv_30s":3,"send_30s":167}}]}
3.包括踢掉一些用戶:
DELETE /api/v1/clients/{id}
srs的控制臺踢人的按鈕,就是使用的這個信令。
4.以下兩條跟上面的功能相同,在/clients/id,查找特定id的信息
curl -v -X GET http://192.168.1.170:1985/api/v1/clients/426 && echo ""
curl -v -X DELETE http://192.168.1.170:1985/api/v1/clients/426 && echo ""
curl -v -X GET http://118.190.201.242:1985/api/v1/vhosts/ && echo “”
{"code":0,"server":"vid-k73qd86","service":"d131vgjy","pid":"14885",
"vhosts":[{"id":"vid-5735q8a","name":"__defaultVhost__","enabled":true,"clients":2,
"streams":1,"send_bytes":246360125,"recv_bytes":223127278,
"kbps":{"recv_30s":256,"send_30s":296},"hls":{"enabled":false}}]}
5.SRS提供系統的摘要信息接口,譬如當前的內存、CPU、網絡、負載使用率。
GET http://118.190.201.242:1985/api/v1/summaries/ && echo ""
{"code":0,"server":"vid-k73qd86","service":"d131vgjy","pid":"14885","urls":{"versions":"the version of SRS","summaries":"the summary(pid, argv, pwd, cpu, mem) of SRS","rusages":"the rusage of SRS","self_proc_stats":"the self process stats","system_proc_stats":"the system process stats","meminfos":"the meminfo of system","authors":"the license, copyright, authors and contributors","features":"the supported features of SRS","requests":"the request itself, for http debug","vhosts":"manage all vhosts or specified vhost","streams":"manage all streams or specified stream","clients":"manage all clients or specified client, default query top 10 clients","raw":"raw api for srs, support CUID srs for instance the config","clusters":"origin cluster server API","perf":"System performance stat","tcmalloc":"tcmalloc api with params ?page=summary|api"},"tests":{"requests":"show the request info","errors":"always return an error 100","redirects":"always redirect to /api/v1/test/errors","[vhost]":"http vhost for http://error.srs.com:1985/api/v1/tests/errors"}}
srs全部的api如下:
地址是:http://192.168.1.170:1985/api/v1,主要包含的子api有:
API Example Description
server 4481 服務器標識
versions /api/v1/versions 獲取服務器版本信息
summaries /api/v1/summaries 獲取服務器的摘要信息
rusages /api/v1/rusages 獲取服務器資源使用信息
self_proc_stats /api/v1/self_proc_stats 獲取服務器進程信息
system_proc_stats /api/v1/system_proc_stats 獲取服務器所有進程情況
meminfos /api/v1/meminfos 獲取服務器內存使用情況
authors /api/v1/authors 獲取作者、版權和License信息
features /api/v1/features 獲取系統支持的功能列表
requests /api/v1/requests 獲取請求的信息,即當前發起的請求的詳細信息
vhosts /api/v1/vhosts 獲取服務器上的vhosts信息
streams /api/v1/streams 獲取服務器的streams信息
clients /api/v1/clients 獲取服務器的clients信息,默認獲取前10個
configs /api/v1/configs CUID配置,RAW API
publish /rtc/v1/publish/ WebRTC推流的API
play /rtc/v1/play/ WebRTC播放流的API
詳細見官網:
http-api 信令https://ossrs.net/lts/zh-cn/docs/v4/doc/http-api
srs官網還有個在線的curl界面類型的工具
http://ossrs.net/srs.release/http-rest/