From 56887424506e5aad9d71d83ce46fb19b0f8b46ca Mon Sep 17 00:00:00 2001 From: dexter <178529795@qq.com> Date: Thu, 12 May 2022 09:12:01 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9streamPath=E8=8E=B7=E5=8F=96?= =?UTF-8?q?=E6=96=B9=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 4 ++-- main.go | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 8bdc0fb..b8e6220 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ webtransport: ## API接口 -- `/webtransport/play/[streamPath]` 用来播放 -- `/webtransport/push/[streamPath]` 用来推流 +- `/play/[streamPath]` 用来播放 +- `/push/[streamPath]` 用来推流 建立双向流后传输flv格式的数据 \ No newline at end of file diff --git a/main.go b/main.go index cbe1311..40db0c5 100644 --- a/main.go +++ b/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{