Move MP4 mutex from HTTP to Muxer

This commit is contained in:
Alexey Khit
2023-04-20 13:20:52 +03:00
parent c07ddb8309
commit 5f9788209d
2 changed files with 12 additions and 11 deletions
+1 -7
View File
@@ -4,7 +4,6 @@ import (
"net/http"
"strconv"
"strings"
"sync"
"time"
"github.com/AlexxIT/go2rtc/cmd/api"
@@ -110,14 +109,9 @@ func handlerMP4(w http.ResponseWriter, r *http.Request) {
Medias: core.ParseQuery(r.URL.Query()),
}
var mu sync.Mutex
cons.Listen(func(msg any) {
if data, ok := msg.([]byte); ok {
mu.Lock()
_, err := w.Write(data)
mu.Unlock()
if err != nil && exit != nil {
if _, err := w.Write(data); err != nil && exit != nil {
select {
case exit <- err:
default: