remove close check in downtrack.bind (#819)
* remove close check in downtrack.bind * return nil but do nothing
This commit is contained in:
@@ -260,9 +260,6 @@ func NewDownTrack(
|
|||||||
// This asserts that the code requested is supported by the remote peer.
|
// This asserts that the code requested is supported by the remote peer.
|
||||||
// If so it sets up all the state (SSRC and PayloadType) to have a call
|
// If so it sets up all the state (SSRC and PayloadType) to have a call
|
||||||
func (d *DownTrack) Bind(t webrtc.TrackLocalContext) (webrtc.RTPCodecParameters, error) {
|
func (d *DownTrack) Bind(t webrtc.TrackLocalContext) (webrtc.RTPCodecParameters, error) {
|
||||||
if d.IsClosed() {
|
|
||||||
return webrtc.RTPCodecParameters{}, ErrDownTrackClosed
|
|
||||||
}
|
|
||||||
if d.bound.Load() {
|
if d.bound.Load() {
|
||||||
return webrtc.RTPCodecParameters{}, ErrDownTrackAlreadyBound
|
return webrtc.RTPCodecParameters{}, ErrDownTrackAlreadyBound
|
||||||
}
|
}
|
||||||
@@ -278,8 +275,14 @@ func (d *DownTrack) Bind(t webrtc.TrackLocalContext) (webrtc.RTPCodecParameters,
|
|||||||
if codec.MimeType == "" {
|
if codec.MimeType == "" {
|
||||||
return webrtc.RTPCodecParameters{}, webrtc.ErrUnsupportedCodec
|
return webrtc.RTPCodecParameters{}, webrtc.ErrUnsupportedCodec
|
||||||
}
|
}
|
||||||
d.logger.Debugw("DownTrack.Bind", "codecs", d.upstreamCodecs, "matchCodec", codec)
|
|
||||||
|
|
||||||
|
// if a downtrack is closed before bind, it already unsubscribed from client, don't do subsequent operation and return here.
|
||||||
|
if d.IsClosed() {
|
||||||
|
d.logger.Debugw("DownTrack closed before bind")
|
||||||
|
return codec, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
d.logger.Debugw("DownTrack.Bind", "codecs", d.upstreamCodecs, "matchCodec", codec)
|
||||||
d.ssrc = uint32(t.SSRC())
|
d.ssrc = uint32(t.SSRC())
|
||||||
d.payloadType = uint8(codec.PayloadType)
|
d.payloadType = uint8(codec.PayloadType)
|
||||||
d.writeStream = t.WriteStream()
|
d.writeStream = t.WriteStream()
|
||||||
|
|||||||
Reference in New Issue
Block a user