From efa839c60b615fd20f73bf79484f3b5104f60922 Mon Sep 17 00:00:00 2001 From: ziyue <1213642868@qq.com> Date: Fri, 15 Oct 2021 17:37:51 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A1=AE=E4=BF=9D=E5=AE=8C=E5=85=A8=E5=BF=BD?= =?UTF-8?q?=E7=95=A5webrtc=E5=AE=A2=E6=88=B7=E7=AB=AF=E4=B8=8D=E6=94=AF?= =?UTF-8?q?=E6=8C=81=E7=9A=84rtp?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- webrtc/WebRtcPlayer.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/webrtc/WebRtcPlayer.cpp b/webrtc/WebRtcPlayer.cpp index d24bb923..7531332d 100644 --- a/webrtc/WebRtcPlayer.cpp +++ b/webrtc/WebRtcPlayer.cpp @@ -33,6 +33,12 @@ void WebRtcPlayer::onStartWebRTC() { CHECK(_play_src); WebRtcTransportImp::onStartWebRTC(); if (canSendRtp()) { + //确保该rtp codec类型对方支持 + memset(_can_send_rtp, 0, sizeof(_can_send_rtp)); + for (auto &m : _answer_sdp->media) { + _can_send_rtp[m.type] = m.direction == RtpDirection::sendonly || m.direction == RtpDirection::sendrecv; + } + _play_src->pause(false); _reader = _play_src->getRing()->attach(getPoller(), true); weak_ptr weak_self = static_pointer_cast(shared_from_this()); @@ -53,12 +59,6 @@ void WebRtcPlayer::onStartWebRTC() { } strongSelf->onShutdown(SockException(Err_shutdown, "rtsp ring buffer detached")); }); - - //确保该rtp codec类型对方支持 - memset(_can_send_rtp, 0, sizeof(_can_send_rtp)); - for (auto &m : _answer_sdp->media) { - _can_send_rtp[m.type] = m.direction == RtpDirection::sendonly || m.direction == RtpDirection::sendrecv; - } } //使用完毕后,释放强引用,这样确保推流器断开后能及时注销媒体 _play_src = nullptr;