mirror of
https://github.com/Monibuca/plugin-webtransport.git
synced 2025-12-24 11:51:00 +08:00
修改streamPath获取方式
This commit is contained in:
@@ -22,7 +22,7 @@ webtransport:
|
||||
|
||||
## API接口
|
||||
|
||||
- `/webtransport/play/[streamPath]` 用来播放
|
||||
- `/webtransport/push/[streamPath]` 用来推流
|
||||
- `/play/[streamPath]` 用来播放
|
||||
- `/push/[streamPath]` 用来推流
|
||||
|
||||
建立双向流后传输flv格式的数据
|
||||
6
main.go
6
main.go
@@ -19,7 +19,7 @@ func (c *WebTransportConfig) OnEvent(event any) {
|
||||
case FirstConfig:
|
||||
mux := http.NewServeMux()
|
||||
mux.HandleFunc("/play/", func(w http.ResponseWriter, r *http.Request) {
|
||||
streamPath := r.URL.Path[5:]
|
||||
streamPath := r.URL.Path[len("/play/"):]
|
||||
session := r.Body.(*webtransport.Session)
|
||||
session.AcceptSession()
|
||||
defer session.CloseSession()
|
||||
@@ -39,7 +39,7 @@ func (c *WebTransportConfig) OnEvent(event any) {
|
||||
plugin.SubscribeBlock(streamPath, sub)
|
||||
})
|
||||
mux.HandleFunc("/push/", func(w http.ResponseWriter, r *http.Request) {
|
||||
streamPath := r.URL.Path[5:]
|
||||
streamPath := r.URL.Path[len("/push/"):]
|
||||
session := r.Body.(*webtransport.Session)
|
||||
session.AcceptSession()
|
||||
defer session.CloseSession()
|
||||
@@ -57,7 +57,7 @@ func (c *WebTransportConfig) OnEvent(event any) {
|
||||
pub.SetIO(s)
|
||||
pub.ID = strconv.FormatInt(int64(s.StreamID()), 10)
|
||||
if plugin.Publish(streamPath, pub) == nil {
|
||||
|
||||
|
||||
}
|
||||
})
|
||||
server := &webtransport.Server{
|
||||
|
||||
Reference in New Issue
Block a user