Commit 81966f2c by Dw9 Committed by GitHub

修复未开启sctp时,webrtc datachannel sdp交换相关bug (#2791)

主要优化如下:
1、通过设置port为0 声明不支持datachannel(而不是inactive)。
2、设置正确的ice用户名和密码,防止ice建联失败。
3、group attribute移除datachannel的mid。
3、datachannel 相关sdp移除rtcp相关描述。
parent 0844f09e
...@@ -1555,7 +1555,10 @@ shared_ptr<RtcSession> RtcConfigure::createAnswer(const RtcSession &offer) const ...@@ -1555,7 +1555,10 @@ shared_ptr<RtcSession> RtcConfigure::createAnswer(const RtcSession &offer) const
//设置音视频端口复用 //设置音视频端口复用
if (!offer.group.mids.empty()) { if (!offer.group.mids.empty()) {
for (auto &m : ret->media) { for (auto &m : ret->media) {
ret->group.mids.emplace_back(m.mid); //The remote end has rejected (port 0) the m-section, so it should not be putting its mid in the group attribute.
if (m.port) {
ret->group.mids.emplace_back(m.mid);
}
} }
} }
return ret; return ret;
...@@ -1613,15 +1616,15 @@ RETRY: ...@@ -1613,15 +1616,15 @@ RETRY:
if (offer_media.type == TrackApplication) { if (offer_media.type == TrackApplication) {
RtcMedia answer_media = offer_media; RtcMedia answer_media = offer_media;
answer_media.role = mathDtlsRole(offer_media.role); answer_media.role = mathDtlsRole(offer_media.role);
#ifdef ENABLE_SCTP
answer_media.direction = matchDirection(offer_media.direction, configure.direction);
answer_media.candidate = configure.candidate;
answer_media.ice_ufrag = configure.ice_ufrag; answer_media.ice_ufrag = configure.ice_ufrag;
answer_media.ice_pwd = configure.ice_pwd; answer_media.ice_pwd = configure.ice_pwd;
answer_media.fingerprint = configure.fingerprint; answer_media.fingerprint = configure.fingerprint;
answer_media.ice_lite = configure.ice_lite; answer_media.ice_lite = configure.ice_lite;
#ifdef ENABLE_SCTP
answer_media.candidate = configure.candidate;
#else #else
answer_media.direction = RtpDirection::inactive; answer_media.port = 0;
WarnL << "answer sdp忽略application mline, 请安装usrsctp后再测试datachannel功能";
#endif #endif
ret->media.emplace_back(answer_media); ret->media.emplace_back(answer_media);
return; return;
......
...@@ -564,8 +564,10 @@ void WebRtcTransportImp::onCheckAnswer(RtcSession &sdp) { ...@@ -564,8 +564,10 @@ void WebRtcTransportImp::onCheckAnswer(RtcSession &sdp) {
GET_CONFIG(uint16_t, udp_port, Rtc::kPort); GET_CONFIG(uint16_t, udp_port, Rtc::kPort);
GET_CONFIG(uint16_t, tcp_port, Rtc::kTcpPort); GET_CONFIG(uint16_t, tcp_port, Rtc::kTcpPort);
m.rtcp_addr.port = udp_port ? udp_port : tcp_port; m.port = m.port ? (udp_port ? udp_port : tcp_port) : 0;
m.port = m.rtcp_addr.port; if (m.type != TrackApplication) {
m.rtcp_addr.port = m.port;
}
sdp.origin.address = m.addr.address; sdp.origin.address = m.addr.address;
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论