From 1650f63af533a92a74f5d5fcd13655a284d1bb95 Mon Sep 17 00:00:00 2001 From: xiongziliang <771730766@qq.com> Date: Wed, 7 Apr 2021 20:41:17 +0800 Subject: [PATCH] =?UTF-8?q?=E7=94=9F=E6=88=90answer=20sdp=E5=A4=B1?= =?UTF-8?q?=E8=B4=A5=E6=97=B6=EF=BC=8C=E7=AB=8B=E5=8D=B3=E9=94=80=E6=AF=81?= =?UTF-8?q?=E5=AF=B9=E8=B1=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- webrtc/WebRtcTransport.cpp | 38 ++++++++++++++++++++++---------------- 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/webrtc/WebRtcTransport.cpp b/webrtc/WebRtcTransport.cpp index 0126590c..7d6548b6 100644 --- a/webrtc/WebRtcTransport.cpp +++ b/webrtc/WebRtcTransport.cpp @@ -154,24 +154,30 @@ void WebRtcTransport::onCheckSdp(SdpType type, RtcSession &sdp){ } std::string WebRtcTransport::getAnswerSdp(const string &offer){ - //// 解析offer sdp //// - _offer_sdp = std::make_shared(); - _offer_sdp->loadFrom(offer); - onCheckSdp(SdpType::offer, *_offer_sdp); - setRemoteDtlsFingerprint(*_offer_sdp); + try { + //// 解析offer sdp //// + _offer_sdp = std::make_shared(); + _offer_sdp->loadFrom(offer); + onCheckSdp(SdpType::offer, *_offer_sdp); + setRemoteDtlsFingerprint(*_offer_sdp); - //// sdp 配置 //// - SdpAttrFingerprint fingerprint; - fingerprint.algorithm = _offer_sdp->media[0].fingerprint.algorithm; - fingerprint.hash = getFingerprint(fingerprint.algorithm, _dtls_transport); - RtcConfigure configure; - configure.setDefaultSetting(_ice_server->GetUsernameFragment(), _ice_server->GetPassword(), RtpDirection::sendrecv, fingerprint); - onRtcConfigure(configure); + //// sdp 配置 //// + SdpAttrFingerprint fingerprint; + fingerprint.algorithm = _offer_sdp->media[0].fingerprint.algorithm; + fingerprint.hash = getFingerprint(fingerprint.algorithm, _dtls_transport); + RtcConfigure configure; + configure.setDefaultSetting(_ice_server->GetUsernameFragment(), _ice_server->GetPassword(), + RtpDirection::sendrecv, fingerprint); + onRtcConfigure(configure); - //// 生成answer sdp //// - _answer_sdp = configure.createAnswer(*_offer_sdp); - onCheckSdp(SdpType::answer, *_answer_sdp); - return _answer_sdp->toString(); + //// 生成answer sdp //// + _answer_sdp = configure.createAnswer(*_offer_sdp); + onCheckSdp(SdpType::answer, *_answer_sdp); + return _answer_sdp->toString(); + } catch (exception &ex) { + onShutdown(SockException(Err_shutdown, ex.what())); + throw; + } } bool is_dtls(char *buf) {