check if we already listen to requested stream. (#13)

This commit is contained in:
Miroslav Šedivý 2022-10-23 11:31:25 +02:00 committed by GitHub
parent 5ad5daa6bb
commit d608e312eb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -100,6 +100,11 @@ func (t *Track) SetStream(stream types.StreamSinkManager) error {
t.streamMu.Lock()
defer t.streamMu.Unlock()
// if we already listen to the stream, do nothing
if t.stream == stream {
return nil
}
var err error
if t.stream != nil {
err = t.stream.MoveListenerTo(&t.listener, stream)