mirror of
https://github.com/AlexxIT/go2rtc.git
synced 2025-10-07 01:03:07 +08:00
fix
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
|
@@ -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
|
||||
}
|
||||
|
Reference in New Issue
Block a user