mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2024-11-22 19:00:01 +08:00
调整优化webrtc sdp处理相关代码
This commit is contained in:
parent
757001ad8a
commit
b0f0bdb6ae
@ -286,9 +286,9 @@ void RtcSessionSdp::parse(const string &str) {
|
||||
item->parse(value);
|
||||
}
|
||||
if (media) {
|
||||
media->items.push_back(std::move(item));
|
||||
media->addItem(std::move(item));
|
||||
} else {
|
||||
items.push_back(std::move(item));
|
||||
addItem(std::move(item));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -953,7 +953,7 @@ void RtcSession::loadFrom(const string &str) {
|
||||
group = sdp.getItemClass<SdpAttrGroup>('a', "group");
|
||||
}
|
||||
|
||||
static void toRtsp(vector <SdpItem::Ptr> &items) {
|
||||
void RtcSdpBase::toRtsp() {
|
||||
for (auto it = items.begin(); it != items.end();) {
|
||||
switch ((*it)->getKey()[0]) {
|
||||
case 'v':
|
||||
@ -1010,10 +1010,10 @@ string RtcSession::toRtspSdp() const{
|
||||
|
||||
CHECK(!copy.media.empty());
|
||||
auto sdp = copy.toRtcSessionSdp();
|
||||
toRtsp(sdp->items);
|
||||
sdp->toRtsp();
|
||||
int i = 0;
|
||||
for (auto &m : sdp->medias) {
|
||||
toRtsp(m.items);
|
||||
m.toRtsp();
|
||||
m.addAttr(std::make_shared<SdpCommon>("control", string("trackID=") + to_string(i++)));
|
||||
}
|
||||
return sdp->toString();
|
||||
|
13
webrtc/Sdp.h
13
webrtc/Sdp.h
@ -490,18 +490,16 @@ public:
|
||||
|
||||
class RtcSdpBase {
|
||||
public:
|
||||
std::vector<SdpItem::Ptr> items;
|
||||
void addItem(SdpItem::Ptr item) { items.push_back(item); }
|
||||
void addItem(SdpItem::Ptr item) { items.push_back(std::move(item)); }
|
||||
void addAttr(SdpItem::Ptr attr) {
|
||||
auto item = std::make_shared<SdpAttr>();
|
||||
item->detail = std::move(attr);
|
||||
items.push_back(item);
|
||||
items.push_back(std::move(item));
|
||||
}
|
||||
SdpItem::Ptr findItem(char key) const { return getItem(key);}
|
||||
SdpItem::Ptr findAttr(const char* key) const { return getItem('a', key);}
|
||||
public:
|
||||
|
||||
virtual ~RtcSdpBase() = default;
|
||||
virtual std::string toString() const;
|
||||
void toRtsp();
|
||||
|
||||
RtpDirection getDirection() const;
|
||||
|
||||
@ -548,6 +546,9 @@ public:
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
private:
|
||||
std::vector<SdpItem::Ptr> items;
|
||||
};
|
||||
|
||||
class RtcSessionSdp : public RtcSdpBase{
|
||||
|
Loading…
Reference in New Issue
Block a user