diff --git a/webrtc/Sdp.cpp b/webrtc/Sdp.cpp index 38875bcc..dae5d776 100644 --- a/webrtc/Sdp.cpp +++ b/webrtc/Sdp.cpp @@ -161,9 +161,9 @@ const char* getRtpDirectionString(RtpDirection val){ ////////////////////////////////////////////////////////////////////////////////////////// -void RtcSdp::parse(const string &str) { +void RtcSessionSdp::parse(const string &str) { static auto flag = registerAllItem(); - RtcMedia *media = nullptr; + RtcMediaSdp *media = nullptr; auto lines = split(str, "\n"); for(auto &line : lines){ trim(line); @@ -173,7 +173,7 @@ void RtcSdp::parse(const string &str) { auto key = line.substr(0, 1); auto value = line.substr(2); if (key == "m") { - medias.emplace_back(RtcMedia()); + medias.emplace_back(RtcMediaSdp()); media = &medias.back(); } @@ -193,7 +193,7 @@ void RtcSdp::parse(const string &str) { } } -string RtcSdp::toString() const { +string RtcSessionSdp::toString() const { _StrPrinter printer; for (auto &item : items) { printer << item->getKey() << "=" << item->toString() << "\r\n"; @@ -207,7 +207,7 @@ string RtcSdp::toString() const { ////////////////////////////////////////////////////////////////////// -string RtcMedia::toString() const { +string RtcMediaSdp::toString() const { _StrPrinter printer; for (auto &item : items) { printer << item->getKey() << "=" << item->toString() << "\r\n"; @@ -215,7 +215,7 @@ string RtcMedia::toString() const { return std::move(printer); } -RtpDirection RtcMedia::getDirection() const{ +RtpDirection RtcMediaSdp::getDirection() const{ for (auto &item : items) { auto attr = dynamic_pointer_cast(item); if (attr) { @@ -790,10 +790,10 @@ void test_sdp(){ "a=sctpmap:5000 webrtc-datachannel 1024\n" "a=sctp-port:5000"; - RtcSdp sdp1; + RtcSessionSdp sdp1; sdp1.parse(str1); - RtcSdp sdp2; + RtcSessionSdp sdp2; sdp2.parse(str2); for (auto media : sdp1.medias) { diff --git a/webrtc/Sdp.h b/webrtc/Sdp.h index 9c0d2740..325c11c0 100644 --- a/webrtc/Sdp.h +++ b/webrtc/Sdp.h @@ -421,7 +421,7 @@ public: const char* getKey() const override { return "candidate";} }; -class RtcMedia { +class RtcMediaSdp { public: vector items; string toString() const; @@ -430,15 +430,83 @@ public: RtpDirection getDirection() const; }; -class RtcSdp { +class RtcSessionSdp { public: vector items; - vector medias; + vector medias; void parse(const string &str); string toString() const; }; +////////////////////////////////////////////////////////////////// + +//ssrc类型 +enum class RtcSSRCType { + rtp = 0, + rtx, + sim_low, + sim_mid, + ssrc_high +}; + +//ssrc相关信息 +class RtcSSRC{ +public: + RtcSSRCType type; + string cname; + string msid; + string mslabel; + string label; +}; + +//rtc传输编码方案 +class RtcPlan{ +public: + uint8_t pt; + string codec; + uint32_t sample_rate; + //音频时有效 + uint32_t channel = 0; + vector > fmtp; + vector rtcp_fb; +}; + +//rtc 媒体描述 +class RtcCodec{ +public: + TrackType type; + string mid; + uint16_t port; + string proto; + + //////// rtp //////// + vector plan; + SdpConnection rtp_addr; + RtpDirection direction; + RtcSSRC ssrc; + + //////// rtx - rtcp //////// + bool rtcp_mux; + bool rtcp_rsize; + uint32_t rtx_ssrc; + SdpAttrRtcp rtcp_addr; + + //////// ice //////// + bool ice_trickle; + bool ice_lite; + bool ice_renomination; + string ice_ufrag; + string ice_pwd; + std::vector candidate; + + //////// dtls //////// + DtlsRole role; + SdpAttrFingerprint fingerprint; + + //////// extmap //////// + vector extmap; +};