Update MP4 links query

This commit is contained in:
Alexey Khit
2023-04-20 21:32:16 +03:00
parent e985ad23a2
commit 5939c8acba
3 changed files with 55 additions and 11 deletions
+10 -4
View File
@@ -9,7 +9,6 @@ import (
"github.com/AlexxIT/go2rtc/cmd/api"
"github.com/AlexxIT/go2rtc/cmd/app"
"github.com/AlexxIT/go2rtc/cmd/streams"
"github.com/AlexxIT/go2rtc/pkg/core"
"github.com/AlexxIT/go2rtc/pkg/mp4"
"github.com/AlexxIT/go2rtc/pkg/tcp"
"github.com/rs/zerolog"
@@ -106,12 +105,15 @@ func handlerMP4(w http.ResponseWriter, r *http.Request) {
cons := &mp4.Consumer{
RemoteAddr: tcp.RemoteAddr(r),
UserAgent: r.UserAgent(),
Medias: core.ParseQuery(r.URL.Query()),
Medias: mp4.ParseQuery(r.URL.Query()),
}
cons.Listen(func(msg any) {
if exit == nil {
return
}
if data, ok := msg.([]byte); ok {
if _, err := w.Write(data); err != nil && exit != nil {
if _, err := w.Write(data); err != nil {
select {
case exit <- err:
default:
@@ -151,7 +153,10 @@ func handlerMP4(w http.ResponseWriter, r *http.Request) {
if i, _ := strconv.Atoi(s); i > 0 {
duration = time.AfterFunc(time.Second*time.Duration(i), func() {
if exit != nil {
exit <- nil
select {
case exit <- nil:
default:
}
exit = nil
}
})
@@ -159,6 +164,7 @@ func handlerMP4(w http.ResponseWriter, r *http.Request) {
}
err = <-exit
exit = nil
log.Trace().Err(err).Caller().Send()