mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
Refactor code for RTC
This commit is contained in:
parent
e65b6283df
commit
03289012fd
4 changed files with 12 additions and 12 deletions
|
@ -884,7 +884,7 @@ srs_error_t SrsGoApiRtcPlay::do_serve_http(ISrsHttpResponseWriter* w, ISrsHttpMe
|
||||||
// TODO: FIXME: It seems remote_sdp doesn't represents the full SDP information.
|
// TODO: FIXME: It seems remote_sdp doesn't represents the full SDP information.
|
||||||
SrsSdp remote_sdp;
|
SrsSdp remote_sdp;
|
||||||
if ((err = remote_sdp.parse(remote_sdp_str)) != srs_success) {
|
if ((err = remote_sdp.parse(remote_sdp_str)) != srs_success) {
|
||||||
return srs_error_wrap(err, "parse sdp failed");
|
return srs_error_wrap(err, "parse sdp failed: %s", remote_sdp_str.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((err = check_remote_sdp(remote_sdp)) != srs_success) {
|
if ((err = check_remote_sdp(remote_sdp)) != srs_success) {
|
||||||
|
@ -921,7 +921,7 @@ srs_error_t SrsGoApiRtcPlay::do_serve_http(ISrsHttpResponseWriter* w, ISrsHttpMe
|
||||||
res->set("sdp", SrsJsonAny::str(local_sdp_str.c_str()));
|
res->set("sdp", SrsJsonAny::str(local_sdp_str.c_str()));
|
||||||
res->set("sessionid", SrsJsonAny::str(rtc_session->id().c_str()));
|
res->set("sessionid", SrsJsonAny::str(rtc_session->id().c_str()));
|
||||||
|
|
||||||
srs_trace("RTC sid=%s, answer=%dB", rtc_session->id().c_str(), local_sdp_str.length());
|
srs_trace("RTC sid=%s, offer=%dB, answer=%dB", rtc_session->id().c_str(), remote_sdp_str.length(), local_sdp_str.length());
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
@ -1006,8 +1006,8 @@ srs_error_t SrsGoApiRtcPlay::exchange_sdp(const std::string& app, const std::str
|
||||||
std::vector<SrsMediaPayloadType> payloads = remote_media_desc.find_media_with_encoding_name("H264");
|
std::vector<SrsMediaPayloadType> payloads = remote_media_desc.find_media_with_encoding_name("H264");
|
||||||
for (std::vector<SrsMediaPayloadType>::iterator iter = payloads.begin(); iter != payloads.end(); ++iter) {
|
for (std::vector<SrsMediaPayloadType>::iterator iter = payloads.begin(); iter != payloads.end(); ++iter) {
|
||||||
H264SpecificParam h264_param;
|
H264SpecificParam h264_param;
|
||||||
if (parse_h264_fmtp(iter->format_specific_param_, h264_param) != 0) {
|
if ((err = parse_h264_fmtp(iter->format_specific_param_, h264_param)) != srs_success) {
|
||||||
continue;
|
srs_error_reset(err); continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (h264_param.packetization_mode == 1 && h264_param.level_asymmerty_allow == 1) {
|
if (h264_param.packetization_mode == 1 && h264_param.level_asymmerty_allow == 1) {
|
||||||
|
|
|
@ -1124,7 +1124,7 @@ SrsRtcSession* SrsRtcServer::create_rtc_session(const SrsRequest& req, const Srs
|
||||||
local_sdp.set_ice_pwd(local_pwd);
|
local_sdp.set_ice_pwd(local_pwd);
|
||||||
local_sdp.set_fingerprint_algo("sha-256");
|
local_sdp.set_fingerprint_algo("sha-256");
|
||||||
local_sdp.set_fingerprint(SrsDtls::instance()->get_fingerprint());
|
local_sdp.set_fingerprint(SrsDtls::instance()->get_fingerprint());
|
||||||
std::vector<string> candidate_ips = get_candidate_ips();
|
std::vector<string> candidate_ips = get_candidate_ips();
|
||||||
for (int i = 0; i < (int)candidate_ips.size(); ++i) {
|
for (int i = 0; i < (int)candidate_ips.size(); ++i) {
|
||||||
local_sdp.add_candidate(candidate_ips[i], _srs_config->get_rtc_server_listen(), "host");
|
local_sdp.add_candidate(candidate_ips[i], _srs_config->get_rtc_server_listen(), "host");
|
||||||
}
|
}
|
||||||
|
|
|
@ -416,7 +416,7 @@ srs_error_t SrsMediaDesc::parse_attr_rtpmap(const std::string& value)
|
||||||
|
|
||||||
std::vector<std::string> vec = split_str(word, "/");
|
std::vector<std::string> vec = split_str(word, "/");
|
||||||
if (vec.size() < 2) {
|
if (vec.size() < 2) {
|
||||||
return srs_error_new(ERROR_RTC_SDP_DECODE, "invalid rtpmap line=%s", value);
|
return srs_error_new(ERROR_RTC_SDP_DECODE, "invalid rtpmap line=%s", value.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
payload->encoding_name_ = vec[0];
|
payload->encoding_name_ = vec[0];
|
||||||
|
@ -525,7 +525,7 @@ srs_error_t SrsMediaDesc::parse_attr_ssrc(const std::string& value)
|
||||||
} else if (ssrc_attr == "msid") {
|
} else if (ssrc_attr == "msid") {
|
||||||
std::vector<std::string> vec = split_str(ssrc_value, " ");
|
std::vector<std::string> vec = split_str(ssrc_value, " ");
|
||||||
if (vec.empty()) {
|
if (vec.empty()) {
|
||||||
return srs_error_new(ERROR_RTC_SDP_DECODE, "invalid ssrc line=%s", value);
|
return srs_error_new(ERROR_RTC_SDP_DECODE, "invalid ssrc line=%s", value.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
ssrc_info.msid_ = vec[0];
|
ssrc_info.msid_ = vec[0];
|
||||||
|
@ -611,7 +611,7 @@ srs_error_t SrsSdp::parse(const std::string& sdp_str)
|
||||||
while (getline(is, line)) {
|
while (getline(is, line)) {
|
||||||
srs_trace("%s", line.c_str());
|
srs_trace("%s", line.c_str());
|
||||||
if (line.size() < 2 || line[1] != '=') {
|
if (line.size() < 2 || line[1] != '=') {
|
||||||
return srs_error_new(ERROR_RTC_SDP_DECODE, "invalid sdp line=%s", line);
|
return srs_error_new(ERROR_RTC_SDP_DECODE, "invalid sdp line=%s", line.c_str());
|
||||||
}
|
}
|
||||||
if (! line.empty() && line[line.size()-1] == '\r') {
|
if (! line.empty() && line[line.size()-1] == '\r') {
|
||||||
line.erase(line.size()-1, 1);
|
line.erase(line.size()-1, 1);
|
||||||
|
|
|
@ -36,7 +36,7 @@ class SrsSessionInfo
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
SrsSessionInfo();
|
SrsSessionInfo();
|
||||||
~SrsSessionInfo();
|
virtual ~SrsSessionInfo();
|
||||||
|
|
||||||
srs_error_t parse_attribute(const std::string& attribute, const std::string& value);
|
srs_error_t parse_attribute(const std::string& attribute, const std::string& value);
|
||||||
srs_error_t encode(std::ostringstream& os);
|
srs_error_t encode(std::ostringstream& os);
|
||||||
|
@ -84,7 +84,7 @@ class SrsMediaPayloadType
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
SrsMediaPayloadType(int payload_type);
|
SrsMediaPayloadType(int payload_type);
|
||||||
~SrsMediaPayloadType();
|
virtual ~SrsMediaPayloadType();
|
||||||
|
|
||||||
srs_error_t encode(std::ostringstream& os);
|
srs_error_t encode(std::ostringstream& os);
|
||||||
public:
|
public:
|
||||||
|
@ -109,7 +109,7 @@ class SrsMediaDesc
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
SrsMediaDesc(const std::string& type);
|
SrsMediaDesc(const std::string& type);
|
||||||
~SrsMediaDesc();
|
virtual ~SrsMediaDesc();
|
||||||
public:
|
public:
|
||||||
srs_error_t parse_line(const std::string& line);
|
srs_error_t parse_line(const std::string& line);
|
||||||
srs_error_t encode(std::ostringstream& os);
|
srs_error_t encode(std::ostringstream& os);
|
||||||
|
@ -157,7 +157,7 @@ class SrsSdp
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
SrsSdp();
|
SrsSdp();
|
||||||
~SrsSdp();
|
virtual ~SrsSdp();
|
||||||
public:
|
public:
|
||||||
srs_error_t parse(const std::string& sdp_str);
|
srs_error_t parse(const std::string& sdp_str);
|
||||||
srs_error_t encode(std::ostringstream& os);
|
srs_error_t encode(std::ostringstream& os);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue