From 26cd5660cd58737e8a949369a375f7e9aefa264e Mon Sep 17 00:00:00 2001 From: xia-chu <771730766@qq.com> Date: Tue, 27 Apr 2021 01:16:01 +0800 Subject: [PATCH] =?UTF-8?q?sdp=E8=BF=94=E5=9B=9E=E7=9C=9F=E5=AE=9Eip?= =?UTF-8?q?=E5=92=8C=E7=AB=AF=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- webrtc/Sdp.h | 4 ++++ webrtc/WebRtcTransport.cpp | 17 ++++++++++++++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/webrtc/Sdp.h b/webrtc/Sdp.h index 6a20fc40..df3e529a 100644 --- a/webrtc/Sdp.h +++ b/webrtc/Sdp.h @@ -97,6 +97,10 @@ public: } virtual const char* getKey() const = 0; + void reset() { + value.clear(); + } + protected: mutable string value; }; diff --git a/webrtc/WebRtcTransport.cpp b/webrtc/WebRtcTransport.cpp index 1a13c656..80b3d6ae 100644 --- a/webrtc/WebRtcTransport.cpp +++ b/webrtc/WebRtcTransport.cpp @@ -408,7 +408,22 @@ void WebRtcTransportImp::onStartWebRTC() { void WebRtcTransportImp::onCheckSdp(SdpType type, RtcSession &sdp){ WebRtcTransport::onCheckSdp(type, sdp); - if (type != SdpType::answer || !canSendRtp()) { + if (type != SdpType::answer) { + return; + } + + GET_CONFIG(string, extern_ip, RTC::kExternIP); + for (auto &m : sdp.media) { + m.addr.reset(); + m.addr.address = extern_ip.empty() ? SockUtil::get_local_ip() : extern_ip; + m.rtcp_addr.reset(); + m.rtcp_addr.address = m.addr.address; + m.rtcp_addr.port = _socket->get_local_port(); + m.port = m.rtcp_addr.port; + sdp.origin.address = m.addr.address; + } + + if (!canSendRtp()) { return; }