支持SDP munging方式simulicast

This commit is contained in:
cqm 2022-05-16 12:54:50 +08:00
parent ee15c571e0
commit 9d9315d8c6
2 changed files with 12 additions and 3 deletions

View File

@ -895,7 +895,7 @@ void RtcSession::loadFrom(const string &str) {
CHECK(rtc_media.rtp_rtx_ssrc.size() <= 1);
} else {
//simulcast的情况下要么没有指定ssrc要么指定的ssrc个数与rid个数一致
CHECK(rtc_media.rtp_ssrc_sim.empty() || rtc_media.rtp_ssrc_sim.size() == rtc_media.rtp_rids.size());
//CHECK(rtc_media.rtp_ssrc_sim.empty() || rtc_media.rtp_ssrc_sim.size() == rtc_media.rtp_rids.size());
}
auto rtpmap_arr = media.getAllItem<SdpAttrRtpMap>('a', "rtpmap");
@ -1290,7 +1290,7 @@ void RtcMedia::checkValid() const{
CHECK(type == TrackApplication || rtcp_mux, "只支持rtcp-mux模式");
bool send_rtp = (direction == RtpDirection::sendonly || direction == RtpDirection::sendrecv);
if (rtp_rids.empty() && rtp_ssrc_sim.empty()) {
if (!supportSimulcast()) {
//非simulcast时检查有没有指定rtp ssrc
CHECK(!rtp_rtx_ssrc.empty() || !send_rtp);
}
@ -1594,7 +1594,6 @@ RETRY:
#ifdef ENABLE_SCTP
answer_media.direction = matchDirection(offer_media.direction, configure.direction);
answer_media.candidate = configure.candidate;
#else
answer_media.direction = RtpDirection::inactive;
#endif
@ -1640,7 +1639,10 @@ RETRY:
answer_media.fingerprint = configure.fingerprint;
answer_media.ice_lite = configure.ice_lite;
answer_media.candidate = configure.candidate;
// copy simulicast setting
answer_media.rtp_rids = offer_media.rtp_rids;
answer_media.rtp_ssrc_sim = offer_media.rtp_ssrc_sim;
answer_media.role = mathDtlsRole(offer_media.role);
//如果codec匹配失败那么禁用该track

View File

@ -463,6 +463,13 @@ void WebRtcTransportImp::onStartWebRTC() {
if (m_offer->rtp_rids.size() > index) {
//支持firefox的simulcast, 提前映射好ssrc和rid的关系
track->rtp_ext_ctx->setRid(ssrc.ssrc, m_offer->rtp_rids[index]);
} else {
// SDP munging没有rid, 它通过group-ssrc:SIM给出ssrc列表;
// 系统又要有rid这里手工生成rid并为其绑定ssrc
std::string rid = "r" + std::to_string(index);
track->rtp_ext_ctx->setRid(ssrc.ssrc, rid);
if(ssrc.rtx_ssrc)
track->rtp_ext_ctx->setRid(ssrc.rtx_ssrc, rid);
}
++index;
}