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; }