修复sdp中没ssrc时触发的bug

This commit is contained in:
ziyue 2021-04-06 18:29:14 +08:00
parent 8edd093d68
commit 9c552128a7

View File

@ -841,8 +841,10 @@ void RtcSession::loadFrom(const string &str, bool check) {
if (rtc_ssrc_map.size() > 1) { if (rtc_ssrc_map.size() > 1) {
throw std::invalid_argument("sdp中不存在a=ssrc-group:FID字段,但是ssrc却有多个"); throw std::invalid_argument("sdp中不存在a=ssrc-group:FID字段,但是ssrc却有多个");
} }
if (rtc_ssrc_map.size() == 1) {
ssrc_rtp = rtc_ssrc_map.begin()->second.ssrc; ssrc_rtp = rtc_ssrc_map.begin()->second.ssrc;
} }
}
for (auto &pr : rtc_ssrc_map) { for (auto &pr : rtc_ssrc_map) {
auto &rtc_ssrc = pr.second; auto &rtc_ssrc = pr.second;
if (rtc_ssrc.ssrc == ssrc_rtp) { if (rtc_ssrc.ssrc == ssrc_rtp) {
@ -982,6 +984,7 @@ string RtcSession::toRtspSdp() const{
} }
} }
copy.session_name = "zlmediakit rtsp stream from webrtc";
auto sdp = copy.toRtcSessionSdp(); auto sdp = copy.toRtcSessionSdp();
toRtsp(sdp->items); toRtsp(sdp->items);
int i = 0; int i = 0;