mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2024-11-26 12:37:09 +08:00
开始提取汇总sdp信息
This commit is contained in:
parent
b714dfddda
commit
ba06def4d8
@ -190,7 +190,7 @@ SdpItem::Ptr RtcSdpBase::getItem(char key, const char *attr_key) const {
|
|||||||
}
|
}
|
||||||
auto attr = dynamic_pointer_cast<SdpAttr>(item);
|
auto attr = dynamic_pointer_cast<SdpAttr>(item);
|
||||||
if (attr && attr->detail->getKey() == attr_key) {
|
if (attr && attr->detail->getKey() == attr_key) {
|
||||||
return item;
|
return attr->detail;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -869,3 +869,32 @@ void test_sdp(){
|
|||||||
InfoL << sdp1.toString();
|
InfoL << sdp1.toString();
|
||||||
InfoL << sdp2.toString();
|
InfoL << sdp2.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RtcSession::loadFrom(const string &str) {
|
||||||
|
RtcSessionSdp sdp;
|
||||||
|
sdp.parse(str);
|
||||||
|
|
||||||
|
version = sdp.getVersion();
|
||||||
|
origin = sdp.getOrigin();
|
||||||
|
session_name = sdp.getSessionName();
|
||||||
|
session_info = sdp.getSessionInfo();
|
||||||
|
connection = sdp.getConnection();
|
||||||
|
bandwidth = sdp.getBandwidth();
|
||||||
|
auto group = sdp.getItemClass<SdpAttrGroup>('a', "group");
|
||||||
|
auto mids = group.mids;
|
||||||
|
|
||||||
|
for (auto &media : sdp.medias) {
|
||||||
|
auto mline = media.getItemClass<SdpMedia>('m');
|
||||||
|
switch (mline.type) {
|
||||||
|
case TrackVideo:
|
||||||
|
case TrackAudio:
|
||||||
|
case TrackApplication:
|
||||||
|
break;
|
||||||
|
default: throw std::invalid_argument(StrPrinter << "不识别的media类型:" << mline.toString());
|
||||||
|
}
|
||||||
|
RtcMedia rtc_media;
|
||||||
|
rtc_media.type = mline.type;
|
||||||
|
rtc_media.mid = media.getStringItem('a', "mid");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
@ -444,9 +444,6 @@ public:
|
|||||||
string getRepeatTimes() const;
|
string getRepeatTimes() const;
|
||||||
RtpDirection getDirection() const;
|
RtpDirection getDirection() const;
|
||||||
|
|
||||||
private:
|
|
||||||
SdpItem::Ptr getItem(char key, const char *attr_key = nullptr) const;
|
|
||||||
|
|
||||||
template<typename cls>
|
template<typename cls>
|
||||||
cls getItemClass(char key, const char *attr_key = nullptr) const{
|
cls getItemClass(char key, const char *attr_key = nullptr) const{
|
||||||
auto item = dynamic_pointer_cast<cls>(getItem(key, attr_key));
|
auto item = dynamic_pointer_cast<cls>(getItem(key, attr_key));
|
||||||
@ -463,6 +460,9 @@ private:
|
|||||||
}
|
}
|
||||||
return item->toString();
|
return item->toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
SdpItem::Ptr getItem(char key, const char *attr_key = nullptr) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
class RtcSessionSdp : public RtcSdpBase{
|
class RtcSessionSdp : public RtcSdpBase{
|
||||||
@ -551,6 +551,8 @@ public:
|
|||||||
SdpBandwidth bandwidth;
|
SdpBandwidth bandwidth;
|
||||||
set<TrackType> group_bundle;
|
set<TrackType> group_bundle;
|
||||||
vector<RtcMedia> media;
|
vector<RtcMedia> media;
|
||||||
|
|
||||||
|
void loadFrom(const string &sdp);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user