Commit 9433a0c3 by ziyue

重写webrtc sdp校验逻辑,确保无有效track时抛异常:#1157

parent b10fc523
...@@ -641,8 +641,6 @@ public: ...@@ -641,8 +641,6 @@ public:
uint32_t sctp_port{0}; uint32_t sctp_port{0};
void checkValid() const; void checkValid() const;
//offer sdp,如果指定了发送rtp,那么应该指定ssrc
void checkValidSSRC() const;
const RtcCodecPlan *getPlan(uint8_t pt) const; const RtcCodecPlan *getPlan(uint8_t pt) const;
const RtcCodecPlan *getPlan(const char *codec) const; const RtcCodecPlan *getPlan(const char *codec) const;
const RtcCodecPlan *getRelatedRtxPlan(uint8_t pt) const; const RtcCodecPlan *getRelatedRtxPlan(uint8_t pt) const;
...@@ -651,7 +649,7 @@ public: ...@@ -651,7 +649,7 @@ public:
bool supportSimulcast() const; bool supportSimulcast() const;
}; };
class RtcSession{ class RtcSession {
public: public:
using Ptr = std::shared_ptr<RtcSession>; using Ptr = std::shared_ptr<RtcSession>;
...@@ -666,15 +664,11 @@ public: ...@@ -666,15 +664,11 @@ public:
vector<RtcMedia> media; vector<RtcMedia> media;
SdpAttrGroup group; SdpAttrGroup group;
void loadFrom(const string &sdp, bool check = true); void loadFrom(const string &sdp);
void checkValid() const; void checkValid() const;
void checkSdp() const;
//offer sdp,如果指定了发送rtp,那么应该指定ssrc
void checkValidSSRC() const;
string toString() const; string toString() const;
string toRtspSdp() const; string toRtspSdp() const;
const RtcMedia *getMedia(TrackType type) const; const RtcMedia *getMedia(TrackType type) const;
bool haveSSRC() const;
bool supportRtcpFb(const string &name, TrackType type = TrackType::TrackVideo) const; bool supportRtcpFb(const string &name, TrackType type = TrackType::TrackVideo) const;
bool supportSimulcast() const; bool supportSimulcast() const;
......
...@@ -187,6 +187,7 @@ std::string WebRtcTransport::getAnswerSdp(const string &offer){ ...@@ -187,6 +187,7 @@ std::string WebRtcTransport::getAnswerSdp(const string &offer){
_offer_sdp = std::make_shared<RtcSession>(); _offer_sdp = std::make_shared<RtcSession>();
_offer_sdp->loadFrom(offer); _offer_sdp->loadFrom(offer);
onCheckSdp(SdpType::offer, *_offer_sdp); onCheckSdp(SdpType::offer, *_offer_sdp);
_offer_sdp->checkValid();
setRemoteDtlsFingerprint(*_offer_sdp); setRemoteDtlsFingerprint(*_offer_sdp);
//// sdp 配置 //// //// sdp 配置 ////
...@@ -201,6 +202,7 @@ std::string WebRtcTransport::getAnswerSdp(const string &offer){ ...@@ -201,6 +202,7 @@ std::string WebRtcTransport::getAnswerSdp(const string &offer){
//// 生成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);
_answer_sdp->checkValid();
return _answer_sdp->toString(); return _answer_sdp->toString();
} catch (exception &ex) { } catch (exception &ex) {
onShutdown(SockException(Err_shutdown, ex.what())); onShutdown(SockException(Err_shutdown, ex.what()));
...@@ -457,10 +459,9 @@ void WebRtcTransportImp::onCheckAnswer(RtcSession &sdp) { ...@@ -457,10 +459,9 @@ void WebRtcTransportImp::onCheckAnswer(RtcSession &sdp) {
} }
void WebRtcTransportImp::onCheckSdp(SdpType type, RtcSession &sdp) { void WebRtcTransportImp::onCheckSdp(SdpType type, RtcSession &sdp) {
sdp.checkSdp();
switch (type) { switch (type) {
case SdpType::answer: onCheckAnswer(sdp); break; case SdpType::answer: onCheckAnswer(sdp); break;
case SdpType::offer: sdp.checkValidSSRC(); break; case SdpType::offer: break;
default: /*不可达*/ assert(0); break; default: /*不可达*/ assert(0); break;
} }
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论