RTC: Fix the SDP encode issue

pull/1895/head
winlin 5 years ago
parent c659098f71
commit baceb7f6b0

@ -195,6 +195,8 @@ srs_error_t SrsGoApiRtcPlay::do_serve_http(ISrsHttpResponseWriter* w, ISrsHttpMe
} }
string local_sdp_str = os.str(); string local_sdp_str = os.str();
// Filter the \r\n to \\r\\n for JSON.
local_sdp_str = srs_string_replace(local_sdp_str.c_str(), "\r\n", "\\r\\n");
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()));
@ -207,7 +209,7 @@ srs_error_t SrsGoApiRtcPlay::do_serve_http(ISrsHttpResponseWriter* w, ISrsHttpMe
srs_trace("RTC username=%s, offer=%dB, answer=%dB", session->username().c_str(), srs_trace("RTC username=%s, offer=%dB, answer=%dB", session->username().c_str(),
remote_sdp_str.length(), local_sdp_str.length()); remote_sdp_str.length(), local_sdp_str.length());
srs_trace("RTC remote offer: %s", srs_string_replace(remote_sdp_str.c_str(), "\r\n", "\\r\\n").c_str()); srs_trace("RTC remote offer: %s", srs_string_replace(remote_sdp_str.c_str(), "\r\n", "\\r\\n").c_str());
srs_trace("RTC local answer: %s", srs_string_replace(local_sdp_str.c_str(), "\r\n", "\\r\\n").c_str()); srs_trace("RTC local answer: %s", local_sdp_str.c_str());
return err; return err;
} }
@ -545,6 +547,8 @@ srs_error_t SrsGoApiRtcPublish::do_serve_http(ISrsHttpResponseWriter* w, ISrsHtt
} }
string local_sdp_str = os.str(); string local_sdp_str = os.str();
// Filter the \r\n to \\r\\n for JSON.
local_sdp_str = srs_string_replace(local_sdp_str.c_str(), "\r\n", "\\r\\n");
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()));
@ -557,7 +561,7 @@ srs_error_t SrsGoApiRtcPublish::do_serve_http(ISrsHttpResponseWriter* w, ISrsHtt
srs_trace("RTC username=%s, offer=%dB, answer=%dB", session->username().c_str(), srs_trace("RTC username=%s, offer=%dB, answer=%dB", session->username().c_str(),
remote_sdp_str.length(), local_sdp_str.length()); remote_sdp_str.length(), local_sdp_str.length());
srs_trace("RTC remote offer: %s", srs_string_replace(remote_sdp_str.c_str(), "\r\n", "\\r\\n").c_str()); srs_trace("RTC remote offer: %s", srs_string_replace(remote_sdp_str.c_str(), "\r\n", "\\r\\n").c_str());
srs_trace("RTC local answer: %s", srs_string_replace(local_sdp_str.c_str(), "\r\n", "\\r\\n").c_str()); srs_trace("RTC local answer: %s", local_sdp_str.c_str());
return err; return err;
} }

@ -34,7 +34,7 @@ using namespace std;
#include <srs_kernel_log.hpp> #include <srs_kernel_log.hpp>
// TODO: FIXME: Maybe we should use json.encode to escape it? // TODO: FIXME: Maybe we should use json.encode to escape it?
const std::string kCRLF = "\\r\\n"; const std::string kCRLF = "\r\n";
#define FETCH(is,word) \ #define FETCH(is,word) \
if (!(is >> word)) {\ if (!(is >> word)) {\

Loading…
Cancel
Save