From 8352f119f28d7eefae0f8bda83a1404e1848cf6a Mon Sep 17 00:00:00 2001 From: ziyue <1213642868@qq.com> Date: Tue, 7 Sep 2021 16:33:57 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dwebrtc=20MediaTrack=E5=AF=B9?= =?UTF-8?q?=E8=B1=A1=E5=BE=AA=E7=8E=AF=E5=BC=95=E7=94=A8=E5=AF=BC=E8=87=B4?= =?UTF-8?q?=E5=86=85=E5=AD=98=E6=B3=84=E9=9C=B2=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- webrtc/WebRtcTransport.cpp | 18 +++++++++--------- webrtc/WebRtcTransport.h | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/webrtc/WebRtcTransport.cpp b/webrtc/WebRtcTransport.cpp index dd6b40c5..43c75d47 100644 --- a/webrtc/WebRtcTransport.cpp +++ b/webrtc/WebRtcTransport.cpp @@ -441,7 +441,7 @@ void WebRtcTransportImp::onStartWebRTC() { //ssrc --> MediaTrack auto track = weak_track.lock(); assert(track); - _ssrc_to_track[ssrc] = track; + _ssrc_to_track[ssrc] = std::move(track); InfoL << "get rtp, pt:" << (int) pt << ", ssrc:" << ssrc << ", rid:" << rid; }); @@ -750,20 +750,20 @@ void WebRtcTransportImp::onRtcp(const char *buf, size_t len) { /////////////////////////////////////////////////////////////////// -void WebRtcTransportImp::createRtpChannel(const string &rid, uint32_t ssrc, const MediaTrack::Ptr &track) { +void WebRtcTransportImp::createRtpChannel(const string &rid, uint32_t ssrc, MediaTrack &track) { //rid --> RtpReceiverImp - auto &ref = track->rtp_channel[rid]; + 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, weak_self, ssrc](const FCI_NACK &nack) mutable { + ref = std::make_shared(getPoller(), [&track, this, rid](RtpPacket::Ptr rtp) mutable { + onSortedRtp(track, rid, std::move(rtp)); + }, [&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); + strong_self->onSendNack(track, nack, ssrc); } }); - InfoL << "create rtp receiver of ssrc:" << ssrc << ", rid:" << rid << ", codec:" << track->plan_rtp->codec; + InfoL << "create rtp receiver of ssrc:" << ssrc << ", rid:" << rid << ", codec:" << track.plan_rtp->codec; } void WebRtcTransportImp::onRtp(const char *buf, size_t len) { @@ -792,7 +792,7 @@ void WebRtcTransportImp::onRtp(const char *buf, size_t len) { WarnL << "unknown rtx rtp, rid:" << rid << ", ssrc:" << ssrc << ", codec:" << track->plan_rtp->codec << ", seq:" << ntohs(rtp->seq); return; } - createRtpChannel(rid, ssrc, track); + createRtpChannel(rid, ssrc, *track); } if (!is_rtx) { diff --git a/webrtc/WebRtcTransport.h b/webrtc/WebRtcTransport.h index d96a8939..94e9c8ec 100644 --- a/webrtc/WebRtcTransport.h +++ b/webrtc/WebRtcTransport.h @@ -216,7 +216,7 @@ private: void onSortedRtp(MediaTrack &track, const string &rid, RtpPacket::Ptr rtp); void onSendNack(MediaTrack &track, const FCI_NACK &nack, uint32_t ssrc); - void createRtpChannel(const string &rid, uint32_t ssrc, const MediaTrack::Ptr &track); + void createRtpChannel(const string &rid, uint32_t ssrc, MediaTrack &track); private: bool _simulcast = false;