Response with error on codec negotiation
This commit is contained in:
@@ -24,6 +24,7 @@ type Producer struct {
|
|||||||
template string
|
template string
|
||||||
|
|
||||||
element streamer.Producer
|
element streamer.Producer
|
||||||
|
lastErr error
|
||||||
tracks []*streamer.Track
|
tracks []*streamer.Track
|
||||||
|
|
||||||
state state
|
state state
|
||||||
@@ -45,10 +46,9 @@ func (p *Producer) GetMedias() []*streamer.Media {
|
|||||||
if p.state == stateNone {
|
if p.state == stateNone {
|
||||||
log.Debug().Msgf("[streams] probe producer url=%s", p.url)
|
log.Debug().Msgf("[streams] probe producer url=%s", p.url)
|
||||||
|
|
||||||
var err error
|
p.element, p.lastErr = GetProducer(p.url)
|
||||||
p.element, err = GetProducer(p.url)
|
if p.lastErr != nil || p.element == nil {
|
||||||
if err != nil || p.element == nil {
|
log.Error().Err(p.lastErr).Caller().Send()
|
||||||
log.Error().Err(err).Caller().Send()
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -99,11 +99,18 @@ func (s *Stream) AddConsumer(cons streamer.Consumer) (err error) {
|
|||||||
|
|
||||||
if len(producers) == 0 {
|
if len(producers) == 0 {
|
||||||
s.stopProducers()
|
s.stopProducers()
|
||||||
|
|
||||||
if len(codecs) > 0 {
|
if len(codecs) > 0 {
|
||||||
return errors.New("codecs not match: " + codecs)
|
return errors.New("codecs not match: " + codecs)
|
||||||
} else {
|
|
||||||
return fmt.Errorf("sources unavailable: %d", len(s.producers))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for i, producer := range s.producers {
|
||||||
|
if producer.lastErr != nil {
|
||||||
|
return fmt.Errorf("source %d error: %w", i, producer.lastErr)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return fmt.Errorf("sources unavailable: %d", len(s.producers))
|
||||||
}
|
}
|
||||||
|
|
||||||
s.mu.Lock()
|
s.mu.Lock()
|
||||||
|
|||||||
Reference in New Issue
Block a user