This commit is contained in:
seydx
2025-06-06 03:11:28 +02:00
parent 91eeefec68
commit b6579122d1
2 changed files with 12 additions and 6 deletions

View File

@@ -140,14 +140,15 @@ func apiPreload(w http.ResponseWriter, r *http.Request) {
switch r.Method {
case "PUT":
// check if stream exists
if stream := Get(src); stream == nil {
stream := Get(src)
if stream == nil {
http.Error(w, "stream not found", http.StatusNotFound)
return
}
// check if consumer exists
if cons, ok := preloads[src]; ok {
cons.Stop()
stream.RemoveConsumer(cons)
delete(preloads, src)
}
@@ -172,7 +173,12 @@ func apiPreload(w http.ResponseWriter, r *http.Request) {
case "DELETE":
if cons, ok := preloads[src]; ok {
if stream := Get(src); stream != nil {
stream.RemoveConsumer(cons)
} else {
cons.Stop()
}
delete(preloads, src)
}

View File

@@ -9,7 +9,7 @@ import (
type Preload struct {
core.Connection
Closed core.Waiter
closed core.Waiter
}
func NewPreload(name string, query url.Values) *Preload {
@@ -74,7 +74,7 @@ func (p *Preload) GetTrack(media *core.Media, codec *core.Codec) (*core.Receiver
}
func (p *Preload) Start() error {
p.Closed.Wait()
p.closed.Wait()
return nil
}
@@ -85,6 +85,6 @@ func (p *Preload) Stop() error {
for _, sender := range p.Senders {
sender.Close()
}
p.Closed.Done(nil)
p.closed.Done(nil)
return nil
}