Skip to content

Commit

Permalink
WebRTC: Negotiate publish/play error and print sdp info.
Browse files Browse the repository at this point in the history
  • Loading branch information
chundonglinlin committed Mar 6, 2023
1 parent dc7be76 commit 0850cc9
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
4 changes: 2 additions & 2 deletions trunk/src/app/srs_app_rtc_conn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1896,7 +1896,7 @@ srs_error_t SrsRtcConnection::add_publisher(SrsRtcUserConfig* ruc, SrsSdp& local

// TODO: FIXME: Change to api of stream desc.
if ((err = negotiate_publish_capability(ruc, stream_desc)) != srs_success) {
return srs_error_wrap(err, "publish negotiate, offer=%s", ruc->remote_sdp_str_.c_str());
return srs_error_wrap(err, "publish negotiate, offer=%s", srs_string_replace(ruc->remote_sdp_str_.c_str(), "\r\n", "\\r\\n").c_str());
}

if ((err = generate_publish_local_sdp(req, local_sdp, stream_desc, ruc->remote_sdp_.is_unified(), ruc->audio_before_video_)) != srs_success) {
Expand Down Expand Up @@ -1935,7 +1935,7 @@ srs_error_t SrsRtcConnection::add_player(SrsRtcUserConfig* ruc, SrsSdp& local_sd

std::map<uint32_t, SrsRtcTrackDescription*> play_sub_relations;
if ((err = negotiate_play_capability(ruc, play_sub_relations)) != srs_success) {
return srs_error_wrap(err, "play negotiate, offer=%s", ruc->remote_sdp_str_.c_str());
return srs_error_wrap(err, "play negotiate, offer=%s", srs_string_replace(ruc->remote_sdp_str_.c_str(), "\r\n", "\\r\\n").c_str());
}

if (!play_sub_relations.size()) {
Expand Down
12 changes: 6 additions & 6 deletions trunk/src/kernel/srs_kernel_error.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -264,8 +264,8 @@ SrsCplxError* SrsCplxError::create(const char* func, const char* file, int line,

va_list ap;
va_start(ap, fmt);
static char buffer[4096];
int r0 = vsnprintf(buffer, sizeof(buffer), fmt, ap);
static char* buffer = new char[maxLogBuf];
int r0 = vsnprintf(buffer, maxLogBuf, fmt, ap);
va_end(ap);

SrsCplxError* err = new SrsCplxError();
Expand All @@ -275,7 +275,7 @@ SrsCplxError* SrsCplxError::create(const char* func, const char* file, int line,
err->line = line;
err->code = code;
err->rerrno = rerrno;
if (r0 > 0 && r0 < (int)sizeof(buffer)) {
if (r0 > 0 && r0 < maxLogBuf) {
err->msg = string(buffer, r0);
}
err->wrapped = NULL;
Expand All @@ -291,8 +291,8 @@ SrsCplxError* SrsCplxError::wrap(const char* func, const char* file, int line, S

va_list ap;
va_start(ap, fmt);
static char buffer[4096];
int r0 = vsnprintf(buffer, sizeof(buffer), fmt, ap);
static char* buffer = new char[maxLogBuf];
int r0 = vsnprintf(buffer, maxLogBuf, fmt, ap);
va_end(ap);

SrsCplxError* err = new SrsCplxError();
Expand All @@ -304,7 +304,7 @@ SrsCplxError* SrsCplxError::wrap(const char* func, const char* file, int line, S
err->code = v->code;
}
err->rerrno = rerrno;
if (r0 > 0 && r0 < (int)sizeof(buffer)) {
if (r0 > 0 && r0 < maxLogBuf) {
err->msg = string(buffer, r0);
}
err->wrapped = v;
Expand Down
2 changes: 2 additions & 0 deletions trunk/src/kernel/srs_kernel_error.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,8 @@ enum SrsErrorCode {
};
#undef SRS_ERRNO_GEN

const int maxLogBuf = 4 * 1024 * 1024;

// Whether the error code is an system control error.
// TODO: FIXME: Remove it from underlayer for confused with error and logger.
extern bool srs_is_system_control_error(srs_error_t err);
Expand Down

0 comments on commit 0850cc9

Please sign in to comment.