From 8ac8ae1c2ebab2f002c87d2be84afa8aedf8e6f2 Mon Sep 17 00:00:00 2001 From: winlin Date: Fri, 9 Sep 2022 16:19:47 +0800 Subject: [PATCH] Fix #3093: WebRTC: Error when SDP not matched. --- trunk/src/app/srs_app_rtc_conn.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/trunk/src/app/srs_app_rtc_conn.cpp b/trunk/src/app/srs_app_rtc_conn.cpp index c07332aa89..99a423a2d8 100644 --- a/trunk/src/app/srs_app_rtc_conn.cpp +++ b/trunk/src/app/srs_app_rtc_conn.cpp @@ -3035,6 +3035,11 @@ srs_error_t SrsRtcConnection::negotiate_publish_capability(SrsRtcUserConfig* ruc //local_media_desc.payload_types_.back().rtcp_fb_.push_back("rrtr"); } + // Error if track desc is invalid, that is failed to match SDP, for example, we require H264 but no H264 found. + if (track_desc->type_.empty() || !track_desc->media_) { + return srs_error_new(ERROR_RTC_SDP_EXCHANGE, "no match for track=%s, mid=%s, tracker=%s", remote_media_desc.type_.c_str(), remote_media_desc.mid_.c_str(), remote_media_desc.msid_tracker_.c_str()); + } + // TODO: FIXME: use one parse payload from sdp. track_desc->create_auxiliary_payload(remote_media_desc.find_media_with_encoding_name("red"));