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:
parent
705843b512
commit
b116632357
2 changed files with 23 additions and 2 deletions
|
@ -330,6 +330,9 @@ srs_error_t SrsMediaDesc::encode(std::ostringstream& os)
|
||||||
os << kCRLF;
|
os << kCRLF;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for(map<int, string>::iterator it = extmaps_.begin(); it != extmaps_.end(); ++it) {
|
||||||
|
os << "a=extmap:"<< it->first<< " "<< it->second<< kCRLF;
|
||||||
|
}
|
||||||
if (sendonly_) {
|
if (sendonly_) {
|
||||||
os << "a=sendonly" << kCRLF;
|
os << "a=sendonly" << kCRLF;
|
||||||
}
|
}
|
||||||
|
@ -399,8 +402,7 @@ srs_error_t SrsMediaDesc::parse_attribute(const std::string& content)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (attribute == "extmap") {
|
if (attribute == "extmap") {
|
||||||
// TODO:We don't parse "extmap" currently.
|
return parse_attr_extmap(value);
|
||||||
return 0;
|
|
||||||
} else if (attribute == "rtpmap") {
|
} else if (attribute == "rtpmap") {
|
||||||
return parse_attr_rtpmap(value);
|
return parse_attr_rtpmap(value);
|
||||||
} else if (attribute == "rtcp") {
|
} else if (attribute == "rtcp") {
|
||||||
|
@ -435,6 +437,20 @@ srs_error_t SrsMediaDesc::parse_attribute(const std::string& content)
|
||||||
|
|
||||||
return err;
|
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)
|
srs_error_t SrsMediaDesc::parse_attr_rtpmap(const std::string& value)
|
||||||
{
|
{
|
||||||
|
|
|
@ -31,6 +31,8 @@
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include <map>
|
||||||
|
const std::string kTWCCExt = "http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01";
|
||||||
|
|
||||||
class SrsSessionInfo
|
class SrsSessionInfo
|
||||||
{
|
{
|
||||||
|
@ -115,6 +117,7 @@ public:
|
||||||
srs_error_t encode(std::ostringstream& os);
|
srs_error_t encode(std::ostringstream& os);
|
||||||
SrsMediaPayloadType* find_media_with_payload_type(int payload_type);
|
SrsMediaPayloadType* find_media_with_payload_type(int payload_type);
|
||||||
std::vector<SrsMediaPayloadType> find_media_with_encoding_name(const std::string& encoding_name) const;
|
std::vector<SrsMediaPayloadType> find_media_with_encoding_name(const std::string& encoding_name) const;
|
||||||
|
const std::map<int, std::string>& get_extmaps() const { return extmaps_; }
|
||||||
|
|
||||||
bool is_audio() const { return type_ == "audio"; }
|
bool is_audio() const { return type_ == "audio"; }
|
||||||
bool is_video() const { return type_ == "video"; }
|
bool is_video() const { return type_ == "video"; }
|
||||||
|
@ -128,6 +131,7 @@ private:
|
||||||
srs_error_t parse_attr_msid(const std::string& value);
|
srs_error_t parse_attr_msid(const std::string& value);
|
||||||
srs_error_t parse_attr_ssrc(const std::string& value);
|
srs_error_t parse_attr_ssrc(const std::string& value);
|
||||||
srs_error_t parse_attr_ssrc_group(const std::string& value);
|
srs_error_t parse_attr_ssrc_group(const std::string& value);
|
||||||
|
srs_error_t parse_attr_extmap(const std::string& value);
|
||||||
private:
|
private:
|
||||||
SrsSSRCInfo& fetch_or_create_ssrc_info(uint32_t ssrc);
|
SrsSSRCInfo& fetch_or_create_ssrc_info(uint32_t ssrc);
|
||||||
|
|
||||||
|
@ -153,6 +157,7 @@ public:
|
||||||
std::vector<SrsCandidate> candidates_;
|
std::vector<SrsCandidate> candidates_;
|
||||||
std::vector<SrsSSRCGroup> ssrc_groups_;
|
std::vector<SrsSSRCGroup> ssrc_groups_;
|
||||||
std::vector<SrsSSRCInfo> ssrc_infos_;
|
std::vector<SrsSSRCInfo> ssrc_infos_;
|
||||||
|
std::map<int, std::string> extmaps_;
|
||||||
};
|
};
|
||||||
|
|
||||||
class SrsSdp
|
class SrsSdp
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue