1
0
Fork 0
mirror of https://github.com/ossrs/srs.git synced 2025-03-09 15:49:59 +00:00

rtc: sdp support decode and encode extmap

This commit is contained in:
jinxue.cgh 2020-05-19 18:12:58 +08:00 committed by winlin
parent 705843b512
commit b116632357
2 changed files with 23 additions and 2 deletions

View file

@ -330,6 +330,9 @@ srs_error_t SrsMediaDesc::encode(std::ostringstream& os)
os << kCRLF;
}
for(map<int, string>::iterator it = extmaps_.begin(); it != extmaps_.end(); ++it) {
os << "a=extmap:"<< it->first<< " "<< it->second<< kCRLF;
}
if (sendonly_) {
os << "a=sendonly" << kCRLF;
}
@ -399,8 +402,7 @@ srs_error_t SrsMediaDesc::parse_attribute(const std::string& content)
}
if (attribute == "extmap") {
// TODO:We don't parse "extmap" currently.
return 0;
return parse_attr_extmap(value);
} else if (attribute == "rtpmap") {
return parse_attr_rtpmap(value);
} else if (attribute == "rtcp") {
@ -435,6 +437,20 @@ srs_error_t SrsMediaDesc::parse_attribute(const std::string& content)
return err;
}
srs_error_t SrsMediaDesc::parse_attr_extmap(const std::string& value)
{
srs_error_t err = srs_success;
std::istringstream is(value);
int id = 0;
FETCH(is, id);
if(extmaps_.end() != extmaps_.find(id)) {
return srs_error_new(ERROR_RTC_SDP_DECODE, "duplicate ext id: %d", id);
}
string ext;
FETCH(is, ext);
extmaps_[id] = ext;
return err;
}
srs_error_t SrsMediaDesc::parse_attr_rtpmap(const std::string& value)
{