修改streamPath获取方式

This commit is contained in:
dexter
2022-05-12 09:12:01 +08:00
parent 5deb9986d0
commit 5688742450
2 changed files with 5 additions and 5 deletions

View File

@@ -22,7 +22,7 @@ webtransport:
## API接口
- `/webtransport/play/[streamPath]` 用来播放
- `/webtransport/push/[streamPath]` 用来推流
- `/play/[streamPath]` 用来播放
- `/push/[streamPath]` 用来推流
建立双向流后传输flv格式的数据

View File

@@ -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{