From d4ce5b0091412c96f183330b52347b7ca7b6dc4f Mon Sep 17 00:00:00 2001 From: xia-chu <771730766@qq.com> Date: Mon, 10 May 2021 17:35:22 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0ssrc=E7=9B=B8=E5=85=B3?= =?UTF-8?q?=E7=9A=84=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- webrtc/Sdp.cpp | 18 ++++++++++++++++++ webrtc/Sdp.h | 5 +++++ 2 files changed, 23 insertions(+) diff --git a/webrtc/Sdp.cpp b/webrtc/Sdp.cpp index 6f08007e..03cb5e9a 100644 --- a/webrtc/Sdp.cpp +++ b/webrtc/Sdp.cpp @@ -1290,6 +1290,9 @@ void RtcMedia::checkValid() const{ CHECK(!proto.empty()); CHECK(direction != RtpDirection::invalid || type == TrackApplication); CHECK(!plan.empty() || type == TrackApplication ); +} + +void RtcMedia::checkValidSSRC() const { bool send_rtp = (direction == RtpDirection::sendonly || direction == RtpDirection::sendrecv); if (rtp_rids.empty() && rtp_ssrc_sim.empty()) { //非simulcast时,检查有没有指定rtp ssrc @@ -1318,6 +1321,12 @@ void RtcSession::checkValid() const{ } } +void RtcSession::checkValidSSRC() const{ + for (auto &item : media) { + item.checkValidSSRC(); + } +} + const RtcMedia *RtcSession::getMedia(TrackType type) const{ for(auto &m : media){ if(m.type == type){ @@ -1327,6 +1336,15 @@ const RtcMedia *RtcSession::getMedia(TrackType type) const{ return nullptr; } +bool RtcSession::haveSSRC() const { + for (auto &m : media) { + if (!m.rtp_rtx_ssrc.empty()) { + return true; + } + } + return false; +} + bool RtcSession::supportRtcpFb(const string &name, TrackType type) const { auto media = getMedia(type); if (!media) { diff --git a/webrtc/Sdp.h b/webrtc/Sdp.h index 34c510ef..1ddfce94 100644 --- a/webrtc/Sdp.h +++ b/webrtc/Sdp.h @@ -640,6 +640,8 @@ public: uint32_t sctp_port{0}; void checkValid() const; + //offer sdp,如果指定了发送rtp,那么应该指定ssrc + void checkValidSSRC() const; const RtcCodecPlan *getPlan(uint8_t pt) const; const RtcCodecPlan *getPlan(const char *codec) const; const RtcCodecPlan *getRelatedRtxPlan(uint8_t pt) const; @@ -662,9 +664,12 @@ public: void loadFrom(const string &sdp, bool check = true); void checkValid() const; + //offer sdp,如果指定了发送rtp,那么应该指定ssrc + void checkValidSSRC() const; string toString() const; string toRtspSdp() const; const RtcMedia *getMedia(TrackType type) const; + bool haveSSRC() const; bool supportRtcpFb(const string &name, TrackType type = TrackType::TrackVideo) const; private: