生成answer sdp失败时,立即销毁对象

This commit is contained in:
xiongziliang 2021-04-07 20:41:17 +08:00
parent fb9eefca69
commit 1650f63af5

View File

@ -154,24 +154,30 @@ void WebRtcTransport::onCheckSdp(SdpType type, RtcSession &sdp){
} }
std::string WebRtcTransport::getAnswerSdp(const string &offer){ std::string WebRtcTransport::getAnswerSdp(const string &offer){
//// 解析offer sdp //// try {
_offer_sdp = std::make_shared<RtcSession>(); //// 解析offer sdp ////
_offer_sdp->loadFrom(offer); _offer_sdp = std::make_shared<RtcSession>();
onCheckSdp(SdpType::offer, *_offer_sdp); _offer_sdp->loadFrom(offer);
setRemoteDtlsFingerprint(*_offer_sdp); onCheckSdp(SdpType::offer, *_offer_sdp);
setRemoteDtlsFingerprint(*_offer_sdp);
//// sdp 配置 //// //// sdp 配置 ////
SdpAttrFingerprint fingerprint; SdpAttrFingerprint fingerprint;
fingerprint.algorithm = _offer_sdp->media[0].fingerprint.algorithm; fingerprint.algorithm = _offer_sdp->media[0].fingerprint.algorithm;
fingerprint.hash = getFingerprint(fingerprint.algorithm, _dtls_transport); fingerprint.hash = getFingerprint(fingerprint.algorithm, _dtls_transport);
RtcConfigure configure; RtcConfigure configure;
configure.setDefaultSetting(_ice_server->GetUsernameFragment(), _ice_server->GetPassword(), RtpDirection::sendrecv, fingerprint); configure.setDefaultSetting(_ice_server->GetUsernameFragment(), _ice_server->GetPassword(),
onRtcConfigure(configure); RtpDirection::sendrecv, fingerprint);
onRtcConfigure(configure);
//// 生成answer sdp //// //// 生成answer sdp ////
_answer_sdp = configure.createAnswer(*_offer_sdp); _answer_sdp = configure.createAnswer(*_offer_sdp);
onCheckSdp(SdpType::answer, *_answer_sdp); onCheckSdp(SdpType::answer, *_answer_sdp);
return _answer_sdp->toString(); return _answer_sdp->toString();
} catch (exception &ex) {
onShutdown(SockException(Err_shutdown, ex.what()));
throw;
}
} }
bool is_dtls(char *buf) { bool is_dtls(char *buf) {