本文介绍: rtc/v1/whip-play/,这是拉流接口,作用是也是交换 SDP,只是采用的 是WebRTC 的标准信令,由 SrsGoApiRtcWhip::serve_http() 来处理。/rtc/v1/whip/,这也是推流接口,作用是也是交换 SDP,只是采用的 是WebRTC 的标准信令,由 SrsGoApiRtcWhip::serve_http() 来处理。可以看到获得了这个2个客户端详细的信息,他们的ip,name,id等,没有。这个是srs自定义的信令,更多详细见上文给到的官网

关于webrtc的流信令只有四个

/rtc/v1/publish/,这是推流接口,是推流客户端跟SRS交换SDP的接口
/rtc/v1/play/,这是拉流接口,是拉流客户端跟SRS交换SDP的接口
/rtc/v1/whip/,这也是推流接口,作用是也是交换SDP,只是采用的是WebRTC 的标准信令
/rtc/v1/whep/,这是拉流接口,作用是也是交换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=0rn......rna=ssrc:2064016335 label:c8243ce9-ace5-4d17-9184-41a2543101b5rn"
}

返回如下

{
  "code": 0
  "sdp": "v=0rn......rna=candidate:1 1 udp 2130706431 172.18.0.4 8000 typ host generation 0rn"
  "sessionid": "186tj710:hMub"
}

这个是srs自定义的信令,更多详细见上文给到的官网
关于whip和whep,webrtc官方没有指定标准信令,但这个几乎快成为公认的webrtc信令了,obs最新版也开始支持whip信令推流webrtc了。
什么是whip
全称: WebRTC-HTTP ingestion protocol (WHIP).
rfc地址: rfc-draft-murillo-whip-00
srs中推流url如下:

http://youip:1985/rtc/v1/whip/?app=live&stream=livestream

其中live和livestream是可以自定义的。
返回http中body也只有answerSDP。详细见whip和whep
whip协议也就是推流和拉流中,无论是offer还是answer,他们的body只能有sdp,至于像上面的url,是服务器自定义的,与whip无关。点击推流按钮,点击左侧name项,查看http的playload。
在这里插入图片描述

除此之外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/
在这里插入图片描述
webrtc是音视频必备,但即使从业数年,它似乎依然有无穷的秘密,感兴趣添加笔者微信:YQW1163720468,加入webrtc微信群讨论。但记得备注:webrtc爱好者



原文地址:https://blog.csdn.net/weixin_43466192/article/details/134564155

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。

如若转载,请注明出处:http://www.7code.cn/show_1078.html

如若内容造成侵权/违法违规/事实不符,请联系代码007邮箱:suwngjj01@126.com进行投诉反馈,一经查实,立即删除

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注