合并代码,去除冗余代码

This commit is contained in:
ziyue
2021-04-02 16:23:40 +08:00
8 changed files with 45 additions and 51 deletions

View File

@@ -88,6 +88,17 @@ std::string WebRtcTransport::getAnswerSdp(const string &offer){
RtcConfigure configure;
configure.setDefaultSetting(ice_server_->GetUsernameFragment(), ice_server_->GetPassword(), RtpDirection::recvonly, fingerprint);
SdpAttrCandidate candidate;
candidate.foundation = "udpcandidate";
candidate.component = 1;
candidate.transport = "udp";
candidate.priority = getSSRC();
candidate.address = getIP();
candidate.port = getPort();
candidate.type = "host";
configure.addCandidate(candidate);
_answer_sdp = configure.createAnswer(*_offer_sdp);
//设置远端dtls签名
@@ -104,23 +115,6 @@ std::string WebRtcTransport::getAnswerSdp(const string &offer){
throw std::invalid_argument("支持group BUNDLE模式");
}
SdpAttrCandidate candidate;
candidate.foundation = "udpcandidate";
candidate.component = 1;
candidate.transport = "udp";
candidate.priority = getSSRC();
candidate.address = getIP();
candidate.port = getPort();
candidate.type = "host";
for (auto &m :_answer_sdp->media) {
m.candidate.emplace_back(candidate);
m.port = getPort();
m.rtcp_addr.address = getIP();
m.rtcp_addr.port = getPort();
m.addr.address = getIP();
}
_answer_sdp->connection.address = getIP();
auto str = _answer_sdp->toString();
InfoL << "\r\n" << str;
return str;
@@ -156,12 +150,10 @@ void WebRtcTransport::OnInputDataPacket(char *buf, size_t len, RTC::TransportTup
}
if (is_rtp(buf)) {
RtpHeader *header = (RtpHeader *) buf;
InfoL << "rtp:" << header->dumpString(len);
return;
}
if (is_rtcp(buf)) {
RtcpHeader *header = (RtcpHeader *) buf;
// InfoL << "rtcp:" << header->dumpString();
return;
}
}