diff --git a/webrtc/WebRtcTransport.cpp b/webrtc/WebRtcTransport.cpp index 54314e4e..7d40cbeb 100644 --- a/webrtc/WebRtcTransport.cpp +++ b/webrtc/WebRtcTransport.cpp @@ -760,10 +760,15 @@ void WebRtcTransportImp::onRtcp(const char *buf, size_t len) { void WebRtcTransportImp::createRtpChannel(const string &rid, uint32_t ssrc, const MediaTrack::Ptr &track) { //rid --> RtpReceiverImp auto &ref = track->rtp_channel[rid]; + weak_ptr weak_self = dynamic_pointer_cast(shared_from_this()); ref = std::make_shared(getPoller(),[track, this, rid](RtpPacket::Ptr rtp) mutable { onSortedRtp(*track, rid, std::move(rtp)); - }, [track, this, ssrc](const FCI_NACK &nack) mutable { - onSendNack(*track, nack, ssrc); + }, [track, weak_self, ssrc](const FCI_NACK &nack) mutable { + //nack发送可能由定时器异步触发 + auto strong_self = weak_self.lock(); + if (strong_self) { + strong_self->onSendNack(*track, nack, ssrc); + } }); InfoL << "create rtp receiver of ssrc:" << ssrc << ", rid:" << rid << ", codec:" << track->plan_rtp->codec; }