Response with error on codec negotiation

This commit is contained in:
Alexey Khit
2023-01-02 16:32:08 +03:00
parent bdf5654c01
commit 4157a53dd8
2 changed files with 13 additions and 6 deletions
+9 -2
View File
@@ -99,11 +99,18 @@ func (s *Stream) AddConsumer(cons streamer.Consumer) (err error) {
if len(producers) == 0 {
s.stopProducers()
if len(codecs) > 0 {
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()