sdp返回真实ip和端口

This commit is contained in:
xia-chu 2021-04-27 01:16:01 +08:00
parent 1d84bb5458
commit 26cd5660cd
2 changed files with 20 additions and 1 deletions

View File

@ -97,6 +97,10 @@ public:
} }
virtual const char* getKey() const = 0; virtual const char* getKey() const = 0;
void reset() {
value.clear();
}
protected: protected:
mutable string value; mutable string value;
}; };

View File

@ -408,7 +408,22 @@ void WebRtcTransportImp::onStartWebRTC() {
void WebRtcTransportImp::onCheckSdp(SdpType type, RtcSession &sdp){ void WebRtcTransportImp::onCheckSdp(SdpType type, RtcSession &sdp){
WebRtcTransport::onCheckSdp(type, 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; return;
} }