Browse Source

修改URL地址形式

v4
dexter 2 years ago
parent
commit
4213e3a685
  1. 45
      README.md
  2. 5
      go.mod
  3. 4
      go.sum
  4. 8
      main.go

45
README.md

@ -1,13 +1,42 @@
# webrtc 插件
# WebRTC 插件
提供通过网页发布视频到monibuca,以及从monibuca拉流通过webrtc进行播放的功能
提供通过网页发布视频到monibuca,以及从monibuca拉流通过webrtc进行播放的功能,遵循WHIP规范
# 基本原理
## 插件地址
https://github.com/Monibuca/plugin-webtrc
## 插件引入
```go
import ( _ "m7s.live/plugin/webrtc/v4" )
```
## 基本原理
通过浏览器和monibuca交换sdp信息,然后读取rtp包或者发送rtp的方式进行
# API
- /api/webrtc/play?streamPath=live/rtc
用于播放live/rtc的流,需要在请求的body中放入sdp的json数据,这个接口会返回服务端的sdp数据
- /api/webrtc/publish?streamPath=live/rtc
同上
## API
### 播放地址
`/webrtc/play/[streamPath]`
Body: `SDP`
Content-Type: `application/sdp`
Response Body: `SDP`
### 推流地址
`/webrtc/push/[streamPath]`
Body: `SDP`
Content-Type: `application/sdp`
Response Body: `SDP`
## WHIP
WebRTC-HTTP ingestion protocol
用于WebRTC交换SDP信息的规范
[WHIP ietf](https://datatracker.ietf.org/doc/html/draft-ietf-wish-whip-02)

5
go.mod

@ -5,7 +5,6 @@ go 1.18
require (
github.com/pion/interceptor v0.1.10
github.com/pion/rtcp v1.2.9
github.com/pion/rtp v1.7.9
github.com/pion/webrtc/v3 v3.1.25
)
@ -17,6 +16,7 @@ require (
github.com/pion/logging v0.2.2 // indirect
github.com/pion/mdns v0.0.5 // indirect
github.com/pion/randutil v0.1.0 // indirect
github.com/pion/rtp v1.7.9 // indirect
github.com/pion/sctp v1.8.2 // indirect
github.com/pion/sdp/v3 v3.0.4 // indirect
github.com/pion/srtp/v2 v2.0.5 // indirect
@ -26,6 +26,7 @@ require (
github.com/pion/udp v0.1.1 // indirect
golang.org/x/crypto v0.0.0-20220131195533-30dcbda58838 // indirect
golang.org/x/net v0.0.0-20220225172249-27dd8689420f // indirect
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e // indirect
golang.org/x/sys v0.0.0-20220111092808-5a964db01320 // indirect
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
)

4
go.sum

@ -116,8 +116,8 @@ golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/sys v0.0.0-20210112080510-489259a85091/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e h1:fLOSk5Q00efkSvAm+4xcoXD+RRmLmmulPn5I3Y9F2EM=
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220111092808-5a964db01320 h1:0jf+tOCoZ3LyutmCOWpVni1chK4VfFLhRsDK7MhqGRY=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
@ -148,5 +148,5 @@ gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo=

8
main.go

@ -81,9 +81,9 @@ func (conf *WebRTCConfig) OnEvent(event any) {
}
}
func (conf *WebRTCConfig) API_play(w http.ResponseWriter, r *http.Request) {
func (conf *WebRTCConfig) Play_(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/sdp")
streamPath := r.URL.Query().Get("streamPath")
streamPath := r.URL.Path[12:]
bytes, err := ioutil.ReadAll(r.Body)
var suber WebRTCSubscriber
suber.SDP = string(bytes)
@ -111,9 +111,9 @@ func (conf *WebRTCConfig) API_play(w http.ResponseWriter, r *http.Request) {
}
}
func (conf *WebRTCConfig) API_publish(w http.ResponseWriter, r *http.Request) {
func (conf *WebRTCConfig) Push_(w http.ResponseWriter, r *http.Request) {
streamPath := r.URL.Path[12:]
w.Header().Set("Content-Type", "application/sdp")
streamPath := r.URL.Query().Get("streamPath")
bytes, err := ioutil.ReadAll(r.Body)
var puber WebRTCPublisher
puber.SDP = string(bytes)

Loading…
Cancel
Save