From 99a8154fa548f1b6166db839f5577ef3bf7bd229 Mon Sep 17 00:00:00 2001 From: xiongziliang <771730766@qq.com> Date: Sat, 10 Jul 2021 20:36:32 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dwebrtc=E5=8D=95track=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=E5=BC=82=E5=B8=B8=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 | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/webrtc/WebRtcTransport.cpp b/webrtc/WebRtcTransport.cpp index 27c9c2e0..3940cfc0 100644 --- a/webrtc/WebRtcTransport.cpp +++ b/webrtc/WebRtcTransport.cpp @@ -386,13 +386,27 @@ void WebRtcTransportImp::onSendSockData(const char *buf, size_t len, struct sock /////////////////////////////////////////////////////////////////// bool WebRtcTransportImp::canSendRtp() const{ - auto &sdp = getSdp(SdpType::answer); - return _play_src && (sdp.media[0].direction == RtpDirection::sendrecv || sdp.media[0].direction == RtpDirection::sendonly); + if (!_play_src) { + return false; + } + for (auto &m : getSdp(SdpType::answer).media) { + if (m.direction == RtpDirection::sendrecv || m.direction == RtpDirection::sendonly) { + return true; + } + } + return false; } bool WebRtcTransportImp::canRecvRtp() const{ - auto &sdp = getSdp(SdpType::answer); - return _push_src && (sdp.media[0].direction == RtpDirection::sendrecv || sdp.media[0].direction == RtpDirection::recvonly); + if (!_push_src) { + return false; + } + for (auto &m : getSdp(SdpType::answer).media) { + if (m.direction == RtpDirection::sendrecv || m.direction == RtpDirection::recvonly) { + return true; + } + } + return false; } void WebRtcTransportImp::onStartWebRTC() {