From ffa34428fc15738910c8cd98dc8eaaf7549a715b Mon Sep 17 00:00:00 2001 From: Alessandro Ros Date: Fri, 1 Sep 2023 23:15:27 +0200 Subject: [PATCH] fix bug that prevented multiple readers from accessing the same stream (#2281) (#2282) --- internal/core/webrtc_outgoing_track.go | 4 +--- internal/stream/stream_format.go | 3 ++- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/internal/core/webrtc_outgoing_track.go b/internal/core/webrtc_outgoing_track.go index 4e1d5a6a687..745f383d49a 100644 --- a/internal/core/webrtc_outgoing_track.go +++ b/internal/core/webrtc_outgoing_track.go @@ -363,7 +363,5 @@ func (t *webRTCOutgoingTrack) start( } }() - stream.AddReader(writer, t.media, t.format, func(u unit.Unit) error { - return t.cb(u) - }) + stream.AddReader(writer, t.media, t.format, t.cb) } diff --git a/internal/stream/stream_format.go b/internal/stream/stream_format.go index 0dc19e91547..0cfa14a302f 100644 --- a/internal/stream/stream_format.go +++ b/internal/stream/stream_format.go @@ -80,8 +80,9 @@ func (sf *streamFormat) writeUnit(s *Stream, medi *description.Media, u unit.Uni } for writer, cb := range sf.readers { + ccb := cb writer.Push(func() error { - return cb(u) + return ccb(u) }) } }