添加部分对象定义

This commit is contained in:
ziyue 2021-03-29 10:54:18 +08:00
parent 7726caa7f2
commit 2643269581
2 changed files with 79 additions and 11 deletions

View File

@ -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<SdpAttr>(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) {

View File

@ -421,7 +421,7 @@ public:
const char* getKey() const override { return "candidate";}
};
class RtcMedia {
class RtcMediaSdp {
public:
vector<SdpItem::Ptr> items;
string toString() const;
@ -430,15 +430,83 @@ public:
RtpDirection getDirection() const;
};
class RtcSdp {
class RtcSessionSdp {
public:
vector<SdpItem::Ptr> items;
vector<RtcMedia> medias;
vector<RtcMediaSdp> 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<std::pair<string/*key*/, string/*value*/> > fmtp;
vector<string> rtcp_fb;
};
//rtc 媒体描述
class RtcCodec{
public:
TrackType type;
string mid;
uint16_t port;
string proto;
//////// rtp ////////
vector<RtcPlan> 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<SdpAttrCandidate> candidate;
//////// dtls ////////
DtlsRole role;
SdpAttrFingerprint fingerprint;
//////// extmap ////////
vector<SdpAttrExtmap> extmap;
};