Fix external producers

This commit is contained in:
Alexey Khit
2022-11-13 21:33:09 +03:00
parent 220b9ca318
commit e6d3939c78
4 changed files with 51 additions and 25 deletions
+7 -7
View File
@@ -14,6 +14,7 @@ const (
stateMedias
stateTracks
stateStart
stateExternal
)
type Producer struct {
@@ -71,11 +72,6 @@ func (p *Producer) GetTrack(media *streamer.Media, codec *streamer.Codec) *strea
}
}
// can't get new tracks after start
if p.state == stateStart {
return nil
}
track := p.element.GetTrack(media, codec)
if track == nil {
return nil
@@ -162,6 +158,12 @@ func (p *Producer) reconnect() {
func (p *Producer) stop() {
p.mu.Lock()
defer p.mu.Unlock()
if p.state == stateExternal {
log.Debug().Msgf("[streams] can't stop external producer")
return
}
log.Debug().Msgf("[streams] stop producer url=%s", p.url)
@@ -176,6 +178,4 @@ func (p *Producer) stop() {
p.state = stateNone
p.tracks = nil
p.mu.Unlock()
}