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

add annotation about some sdp line

This commit is contained in:
xiaozhihong 2020-04-01 14:38:00 +08:00
parent f4067bcb4d
commit 14421a7f0b
3 changed files with 31 additions and 6 deletions

View file

@ -911,7 +911,7 @@ srs_error_t SrsGoApiRtcPlay::do_serve_http(ISrsHttpResponseWriter* w, ISrsHttpMe
string local_sdp_str = os.str(); string local_sdp_str = os.str();
srs_trace("local_sdp=%s", local_sdp_str.c_str()); srs_verbose("local_sdp=%s", local_sdp_str.c_str());
res->set("code", SrsJsonAny::integer(ERROR_SUCCESS)); res->set("code", SrsJsonAny::integer(ERROR_SUCCESS));
res->set("server", SrsJsonAny::integer(SrsStatistic::instance()->server_id())); res->set("server", SrsJsonAny::integer(SrsStatistic::instance()->server_id()));
@ -1036,8 +1036,6 @@ srs_error_t SrsGoApiRtcPlay::exchange_sdp(const std::string& app, const std::str
local_media_desc.session_info_.setup_ = "passive"; local_media_desc.session_info_.setup_ = "passive";
} }
local_sdp.media_descs_.back().session_info_.ice_options_ = "trickle";
if (remote_media_desc.sendonly_) { if (remote_media_desc.sendonly_) {
local_media_desc.recvonly_ = true; local_media_desc.recvonly_ = true;
} else if (remote_media_desc.recvonly_) { } else if (remote_media_desc.recvonly_) {
@ -1047,9 +1045,11 @@ srs_error_t SrsGoApiRtcPlay::exchange_sdp(const std::string& app, const std::str
} }
local_media_desc.rtcp_mux_ = true; local_media_desc.rtcp_mux_ = true;
local_media_desc.rtcp_rsize_ = true;
SrsSSRCInfo ssrc_info; SrsSSRCInfo ssrc_info;
ssrc_info.ssrc_ = ++ssrc_num; ssrc_info.ssrc_ = ++ssrc_num;
// TODO:use formated cname
ssrc_info.cname_ = "test_sdp_cname"; ssrc_info.cname_ = "test_sdp_cname";
local_media_desc.ssrc_infos_.push_back(ssrc_info); local_media_desc.ssrc_infos_.push_back(ssrc_info);
} }

View file

@ -116,7 +116,9 @@ srs_error_t SrsSessionInfo::parse_attribute(const std::string& attribute, const
} else if (attribute == "setup") { } else if (attribute == "setup") {
// @see: https://tools.ietf.org/html/rfc4145#section-4 // @see: https://tools.ietf.org/html/rfc4145#section-4
setup_ = value; setup_ = value;
} } else {
srs_trace("ignore attribute=%s, value=%s", attribute.c_str(), value.c_str());
}
return err; return err;
} }
@ -132,6 +134,10 @@ srs_error_t SrsSessionInfo::encode(std::ostringstream& os)
} }
if (! ice_options_.empty()) { if (! ice_options_.empty()) {
os << "a=ice-options:" << ice_options_ << kCRLF; os << "a=ice-options:" << ice_options_ << kCRLF;
} else {
// @see: https://webrtcglossary.com/trickle-ice/
// Trickle ICE is an optimization of the ICE specification for NAT traversal.
os << "a=ice-options:trickle" << kCRLF;
} }
if (! fingerprint_algo_.empty() && ! fingerprint_.empty()) { if (! fingerprint_algo_.empty() && ! fingerprint_.empty()) {
os << "a=fingerprint:" << fingerprint_algo_ << " " << fingerprint_ << kCRLF; os << "a=fingerprint:" << fingerprint_algo_ << " " << fingerprint_ << kCRLF;
@ -325,6 +331,10 @@ srs_error_t SrsMediaDesc::encode(std::ostringstream& os)
os << "a=rtcp-mux" << kCRLF; os << "a=rtcp-mux" << kCRLF;
} }
if (rtcp_rsize_) {
os << "a=rtcp-rsize" << kCRLF;
}
for (std::vector<SrsMediaPayloadType>::iterator iter = payload_types_.begin(); iter != payload_types_.end(); ++iter) { for (std::vector<SrsMediaPayloadType>::iterator iter = payload_types_.begin(); iter != payload_types_.end(); ++iter) {
if ((err = iter->encode(os)) != srs_success) { if ((err = iter->encode(os)) != srs_success) {
return srs_error_wrap(err, "encode media payload failed"); return srs_error_wrap(err, "encode media payload failed");
@ -366,6 +376,8 @@ srs_error_t SrsMediaDesc::parse_attribute(const std::string& content)
return 0; return 0;
} else if (attribute == "rtpmap") { } else if (attribute == "rtpmap") {
return parse_attr_rtpmap(value); return parse_attr_rtpmap(value);
} else if (attribute == "rtcp") {
return parse_attr_rtcp(value);
} else if (attribute == "rtcp-fb") { } else if (attribute == "rtcp-fb") {
return parse_attr_rtcp_fb(value); return parse_attr_rtcp_fb(value);
} else if (attribute == "fmtp") { } else if (attribute == "fmtp") {
@ -380,6 +392,8 @@ srs_error_t SrsMediaDesc::parse_attribute(const std::string& content)
return parse_attr_ssrc_group(value); return parse_attr_ssrc_group(value);
} else if (attribute == "rtcp-mux") { } else if (attribute == "rtcp-mux") {
rtcp_mux_ = true; rtcp_mux_ = true;
} else if (attribute == "rtcp-rsize") {
rtcp_rsize_ = true;
} else if (attribute == "recvonly") { } else if (attribute == "recvonly") {
recvonly_ = true; recvonly_ = true;
} else if (attribute == "sendonly") { } else if (attribute == "sendonly") {
@ -429,6 +443,15 @@ srs_error_t SrsMediaDesc::parse_attr_rtpmap(const std::string& value)
return err; return err;
} }
srs_error_t SrsMediaDesc::parse_attr_rtcp(const std::string& value)
{
srs_error_t err = srs_success;
// TODO:parse rtcp attribute
return err;
}
srs_error_t SrsMediaDesc::parse_attr_rtcp_fb(const std::string& value) srs_error_t SrsMediaDesc::parse_attr_rtcp_fb(const std::string& value)
{ {
srs_error_t err = srs_success; srs_error_t err = srs_success;
@ -633,7 +656,7 @@ srs_error_t SrsSdp::encode(std::ostringstream& os)
os << "o=" << username_ << " " << session_id_ << " " << session_version_ << " " << nettype_ << " " << addrtype_ << " " << unicast_address_ << kCRLF; os << "o=" << username_ << " " << session_id_ << " " << session_version_ << " " << nettype_ << " " << addrtype_ << " " << unicast_address_ << kCRLF;
os << "s=" << session_name_ << kCRLF; os << "s=" << session_name_ << kCRLF;
os << "t=" << start_time_ << " " << end_time_ << kCRLF; os << "t=" << start_time_ << " " << end_time_ << kCRLF;
// TODO: ice options // @see: ice-lite is a minimal version of the ICE specification, intended for servers running on a public IP address.
os << "a=ice-lite" << kCRLF; os << "a=ice-lite" << kCRLF;
if (! groups_.empty()) { if (! groups_.empty()) {
@ -656,7 +679,7 @@ srs_error_t SrsSdp::encode(std::ostringstream& os)
for (std::vector<SrsMediaDesc>::iterator iter = media_descs_.begin(); iter != media_descs_.end(); ++iter) { for (std::vector<SrsMediaDesc>::iterator iter = media_descs_.begin(); iter != media_descs_.end(); ++iter) {
if ((err = (*iter).encode(os)) != srs_success) { if ((err = (*iter).encode(os)) != srs_success) {
return srs_error_wrap(err, "encode media failed"); return srs_error_wrap(err, "encode media description failed");
} }
} }

View file

@ -121,6 +121,7 @@ public:
private: private:
srs_error_t parse_attribute(const std::string& content); srs_error_t parse_attribute(const std::string& content);
srs_error_t parse_attr_rtpmap(const std::string& value); srs_error_t parse_attr_rtpmap(const std::string& value);
srs_error_t parse_attr_rtcp(const std::string& value);
srs_error_t parse_attr_rtcp_fb(const std::string& value); srs_error_t parse_attr_rtcp_fb(const std::string& value);
srs_error_t parse_attr_fmtp(const std::string& value); srs_error_t parse_attr_fmtp(const std::string& value);
srs_error_t parse_attr_mid(const std::string& value); srs_error_t parse_attr_mid(const std::string& value);
@ -136,6 +137,7 @@ public:
int port_; int port_;
bool rtcp_mux_; bool rtcp_mux_;
bool rtcp_rsize_;
bool sendonly_; bool sendonly_;
bool recvonly_; bool recvonly_;