Fix panic by CreateSenderReport before bind completed (#1397)

This commit is contained in:
cnderrauber
2023-02-08 17:02:19 +08:00
committed by GitHub
parent 4d8def2eb7
commit a04e7ce647
3 changed files with 9 additions and 9 deletions

View File

@@ -441,7 +441,7 @@ func (t *MediaTrackReceiver) AddSubscriber(sub types.LocalParticipant) (types.Su
}
tLogger := LoggerWithTrack(sub.GetLogger(), t.ID(), t.params.IsRelayed)
wrParams := NewWrappedReceiver(WrappedReceiverParams{
wr := NewWrappedReceiver(WrappedReceiverParams{
Receivers: receivers,
TrackID: t.ID(),
StreamId: streamId,
@@ -449,7 +449,7 @@ func (t *MediaTrackReceiver) AddSubscriber(sub types.LocalParticipant) (types.Su
Logger: tLogger,
DisableRed: t.trackInfo.GetDisableRed(),
})
return t.MediaTrackSubscriptions.AddSubscriber(sub, wrParams)
return t.MediaTrackSubscriptions.AddSubscriber(sub, wr)
}
// RemoveSubscriber removes participant from subscription

View File

@@ -127,7 +127,7 @@ func (t *MediaTrackSubscriptions) AddSubscriber(sub types.LocalParticipant, wr *
// Bind callback can happen from replaceTrack, so set it up early
var reusingTransceiver atomic.Bool
var dtState sfu.DownTrackState
downTrack.OnBind(func() {
downTrack.OnBinding(func() {
wr.DetermineReceiver(downTrack.Codec())
if reusingTransceiver.Load() {
downTrack.SeedState(dtState)

View File

@@ -158,7 +158,7 @@ type DownTrack struct {
writeStream webrtc.TrackLocalWriter
rtcpReader *buffer.RTCPReader
onCloseHandler func(willBeResumed bool)
onBind func()
onBinding func()
receiverReportListeners []ReceiverReportListener
listenerLock sync.RWMutex
isClosed atomic.Bool
@@ -331,12 +331,12 @@ func (d *DownTrack) Bind(t webrtc.TrackLocalContext) (webrtc.RTPCodecParameters,
d.sequencer = newSequencer(d.maxTrack, maxPadding, d.logger)
}
d.bound.Store(true)
d.codec = codec.RTPCodecCapability
d.forwarder.DetermineCodec(d.codec)
if d.onBind != nil {
d.onBind()
if d.onBinding != nil {
d.onBinding()
}
d.bound.Store(true)
d.bindLock.Unlock()
d.logger.Debugw("downtrack bound")
@@ -875,8 +875,8 @@ func (d *DownTrack) OnCloseHandler(fn func(willBeResumed bool)) {
d.onCloseHandler = fn
}
func (d *DownTrack) OnBind(fn func()) {
d.onBind = fn
func (d *DownTrack) OnBinding(fn func()) {
d.onBinding = fn
}
func (d *DownTrack) OnREMB(fn func(dt *DownTrack, remb *rtcp.ReceiverEstimatedMaximumBitrate)) {