diff --git a/webrtc/RtpExt.cpp b/webrtc/RtpExt.cpp index bf749fa9..7679abc7 100644 --- a/webrtc/RtpExt.cpp +++ b/webrtc/RtpExt.cpp @@ -579,6 +579,10 @@ string RtpExtContext::getRid(uint32_t ssrc) const{ return it->second; } +void RtpExtContext::setRid(uint32_t ssrc, const string &rid) { + _ssrc_to_rid[ssrc] = rid; +} + void RtpExtContext::changeRtpExtId(const RtpHeader *header, bool is_recv, string *rid_ptr) { string rid, repaired_rid; auto ext_map = RtpExt::getExtValue(header); diff --git a/webrtc/RtpExt.h b/webrtc/RtpExt.h index d7a90386..3671bc90 100644 --- a/webrtc/RtpExt.h +++ b/webrtc/RtpExt.h @@ -119,6 +119,7 @@ public: void setOnGetRtp(OnGetRtp cb); string getRid(uint32_t ssrc) const; + void setRid(uint32_t ssrc, const string &rid); void changeRtpExtId(const RtpHeader *header, bool is_recv, string *rid_ptr = nullptr); private: diff --git a/webrtc/WebRtcTransport.cpp b/webrtc/WebRtcTransport.cpp index 501e69d9..2eb7cb1f 100644 --- a/webrtc/WebRtcTransport.cpp +++ b/webrtc/WebRtcTransport.cpp @@ -432,6 +432,17 @@ void WebRtcTransportImp::onStartWebRTC() { _ssrc_to_track[ssrc] = track; InfoL << "get rtp, pt:" << (int) pt << ", ssrc:" << ssrc << ", rid:" << rid; }); + + int index = 0; + for (auto &ssrc : m_offer->rtp_ssrc_sim) { + //记录ssrc对应的MediaTrack + _ssrc_to_track[ssrc.ssrc] = track; + if (m_offer->rtp_rids.size() > index) { + //支持firefox的simulcast, 提前映射好ssrc和rid的关系 + track->rtp_ext_ctx->setRid(ssrc.ssrc, m_offer->rtp_rids[index]); + } + ++index; + } } }