From bd908e209de88979e89768f39306b612cd44cc85 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 18 Feb 2023 03:22:41 +0000 Subject: [PATCH 1/3] Bump golang.org/x/net from 0.2.0 to 0.7.0 Bumps [golang.org/x/net](https://github.com/golang/net) from 0.2.0 to 0.7.0. - [Release notes](https://github.com/golang/net/releases) - [Commits](https://github.com/golang/net/compare/v0.2.0...v0.7.0) --- updated-dependencies: - dependency-name: golang.org/x/net dependency-type: indirect ... Signed-off-by: dependabot[bot] --- go.mod | 4 ++-- go.sum | 9 +++++---- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/go.mod b/go.mod index f017ac8..b038d76 100644 --- a/go.mod +++ b/go.mod @@ -48,9 +48,9 @@ require ( golang.org/x/crypto v0.3.0 // indirect golang.org/x/exp v0.0.0-20221126150942-6ab00d035af9 // indirect golang.org/x/mod v0.7.0 // indirect - golang.org/x/net v0.2.0 // indirect + golang.org/x/net v0.7.0 // indirect golang.org/x/sync v0.1.0 // indirect - golang.org/x/sys v0.2.0 // indirect + golang.org/x/sys v0.5.0 // indirect golang.org/x/tools v0.3.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/go.sum b/go.sum index 3025fe1..3653c55 100644 --- a/go.sum +++ b/go.sum @@ -196,8 +196,8 @@ golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4/go.mod h1:CfG3xpIq0wQ8r1q4Su golang.org/x/net v0.0.0-20220531201128-c960675eff93/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= golang.org/x/net v0.1.0/go.mod h1:Cx3nUiGt4eDBEyega/BKRp+/AlGL8hYe7U9odMt2Cco= -golang.org/x/net v0.2.0 h1:sZfSu1wtKLGlWI4ZZayP0ck9Y73K1ynO6gqzTdBVdPU= -golang.org/x/net v0.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY= +golang.org/x/net v0.7.0 h1:rJrUqqhjsgNp7KqAIc25s9pZnjU7TUcSY7HcVZjdn1g= +golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -230,8 +230,9 @@ golang.org/x/sys v0.0.0-20220608164250-635b8c9b7f68/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220622161953-175b2fd9d664/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.2.0 h1:ljd4t30dBnAvMZaQCevtY0xLLD0A+bRZXbgLMLU1F/A= golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.5.0 h1:MUK/U/4lj1t1oPg0HfuXDN/Z1wv31ZJ/YcPiGccS4DU= +golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= 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= @@ -240,8 +241,8 @@ golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= -golang.org/x/text v0.4.0 h1:BrVqGRd7+k1DiOgtnFvAkoQEWQvBc25ouMJM6429SFg= golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= +golang.org/x/text v0.7.0 h1:4BRB4x83lYWy72KwLD/qYDuTu7q9PjSagHvijDw7cLo= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= From 5526f1e44cab2fa82f7e041a59a29c00aad2f5b3 Mon Sep 17 00:00:00 2001 From: dexter <178529795@qq.com> Date: Tue, 21 Feb 2023 08:20:47 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E4=BF=AE=E5=A4=8DpayloadType=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- batcher.go | 4 ++-- main.go | 14 +++++--------- publisher.go | 4 ++-- 3 files changed, 9 insertions(+), 13 deletions(-) diff --git a/batcher.go b/batcher.go index 8f008aa..880c00a 100644 --- a/batcher.go +++ b/batcher.go @@ -80,7 +80,7 @@ func (suber *WebRTCBatcher) Start() (err error) { } } else { go func() { - ticker := time.NewTicker(time.Millisecond * webrtcConfig.PLI) + ticker := time.NewTicker(webrtcConfig.PLI) for { select { case <-ticker.C: @@ -92,7 +92,7 @@ func (suber *WebRTCBatcher) Start() (err error) { } } }() - puber.VideoTrack = NewH264(puber.Stream) + puber.VideoTrack = NewH264(puber.Stream, byte(codec.PayloadType)) for { b := make([]byte, 1460) if i, _, err := track.Read(b); err == nil { diff --git a/main.go b/main.go index e627d98..e8aeb9e 100644 --- a/main.go +++ b/main.go @@ -55,10 +55,10 @@ type WebRTCConfig struct { PortMin uint16 PortMax uint16 - InvitePortFixed bool - IceUdpMux int + InvitePortFixed bool `default:"true"` // 设备将流发送的端口,是否固定 on 发送流到多路复用端口 如9000 off 自动从 mix_port - max_port 之间的值中 选一个可以用的端口 + IceUdpMux int `default:"9000"` // 接收设备端rtp流的多路复用端口 - PLI time.Duration + PLI time.Duration `default:"2s"` // 视频流丢包后,发送PLI请求 m MediaEngine s SettingEngine api *API @@ -168,13 +168,9 @@ func (conf *WebRTCConfig) Push_(w http.ResponseWriter, r *http.Request) { } } -var webrtcConfig = &WebRTCConfig{ - InvitePortFixed: true, // 设备将流发送的端口,是否固定 on 发送流到多路复用端口 如9000 off 自动从 mix_port - max_port 之间的值中 选一个可以用的端口 - IceUdpMux: 9000, // 接收设备端rtp流的多路复用端口 - PLI: time.Second * 2, -} +var webrtcConfig WebRTCConfig -var WebRTCPlugin = engine.InstallPlugin(webrtcConfig) +var WebRTCPlugin = engine.InstallPlugin(&webrtcConfig) func (conf *WebRTCConfig) Batch(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "application/sdp") diff --git a/publisher.go b/publisher.go index d8ea90b..1588c41 100644 --- a/publisher.go +++ b/publisher.go @@ -48,7 +48,7 @@ func (puber *WebRTCPublisher) OnEvent(event any) { } } else { go func() { - ticker := time.NewTicker(time.Millisecond * webrtcConfig.PLI) + ticker := time.NewTicker(webrtcConfig.PLI) for { select { case <-ticker.C: @@ -61,7 +61,7 @@ func (puber *WebRTCPublisher) OnEvent(event any) { } }() if puber.Equal(v) { - puber.VideoTrack = NewH264(puber.Stream) + puber.VideoTrack = NewH264(puber.Stream, byte(codec.PayloadType)) } for { b := make([]byte, 1460) From 89ebf28810020bd57b010d11a0da0e0d4be494d6 Mon Sep 17 00:00:00 2001 From: dexter <178529795@qq.com> Date: Tue, 21 Feb 2023 21:29:53 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E5=8A=A0=E5=85=A5=E6=B5=8B=E8=AF=95?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 5 +++++ main.go | 11 ++++++++++- publish.html | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 70 insertions(+), 1 deletion(-) create mode 100644 publish.html diff --git a/README.md b/README.md index f16762f..eb38207 100644 --- a/README.md +++ b/README.md @@ -50,6 +50,11 @@ Body: `SDP` Content-Type: `application/sdp` Response Body: `SDP` + +### 推流测试页面 + +`/webrtc/test/publish` + ## WHIP WebRTC-HTTP ingestion protocol 用于WebRTC交换SDP信息的规范 diff --git a/main.go b/main.go index e8aeb9e..d604555 100644 --- a/main.go +++ b/main.go @@ -10,8 +10,9 @@ import ( "go.uber.org/zap" "m7s.live/engine/v4" - "github.com/pion/interceptor" + _ "embed" + "github.com/pion/interceptor" . "github.com/pion/webrtc/v3" "m7s.live/engine/v4/config" "m7s.live/plugin/webrtc/v4/webrtc" @@ -43,6 +44,10 @@ import ( // conn *net.UDPConn // port int // } + +//go:embed publish.html +var publishHTML []byte + var ( reg_level = regexp.MustCompile("profile-level-id=(4.+f)") ) @@ -168,6 +173,10 @@ func (conf *WebRTCConfig) Push_(w http.ResponseWriter, r *http.Request) { } } +func (conf *WebRTCConfig) Test_Publish(w http.ResponseWriter, r *http.Request) { + w.Write(publishHTML) +} + var webrtcConfig WebRTCConfig var WebRTCPlugin = engine.InstallPlugin(&webrtcConfig) diff --git a/publish.html b/publish.html new file mode 100644 index 0000000..dc702a9 --- /dev/null +++ b/publish.html @@ -0,0 +1,55 @@ + + + + + + + + 测试WebRTC推流 + + + +