Improve play audio on RTSP backchannel

This commit is contained in:
Alex X
2024-05-19 11:56:33 +03:00
parent 50f9913c41
commit bc8295baee
3 changed files with 49 additions and 29 deletions
+10 -6
View File
@@ -2,6 +2,8 @@ package streams
import (
"errors"
"time"
"github.com/AlexxIT/go2rtc/pkg/core"
)
@@ -80,18 +82,20 @@ func (s *Stream) Play(source string) error {
s.AddInternalProducer(src)
s.AddInternalConsumer(cons)
go func() {
_ = src.Start()
_ = dst.Stop()
s.RemoveProducer(src)
}()
go func() {
_ = dst.Start()
_ = src.Stop()
s.RemoveInternalConsumer(cons)
}()
go func() {
_ = src.Start()
// little timeout before stop dst, so the buffer can be transferred
time.Sleep(time.Second)
_ = dst.Stop()
s.RemoveProducer(src)
}()
return nil
}