Skip to content

Commit

Permalink
SRT: Fix srt2rtmp crash when streamid is too long(ossrs#2770)
Browse files Browse the repository at this point in the history
  • Loading branch information
akanchi committed Dec 11, 2021
1 parent 1a4249d commit 9d79f85
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions trunk/src/srt/srt_to_rtmp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include <srs_app_config.hpp>
#include <srs_kernel_stream.hpp>
#include <list>
#include <sstream>

std::shared_ptr<srt2rtmp> srt2rtmp::s_srt2rtmp_ptr;

Expand Down Expand Up @@ -258,8 +259,7 @@ rtmp_client::rtmp_client(std::string key_path):_key_path(key_path)
_appname = ret_vec[0];
_streamname = ret_vec[1];
}
char url_sz[128];


std::vector<std::string> ip_ports = _srs_config->get_listens();
int port = 0;
std::string ip;
Expand All @@ -271,22 +271,24 @@ rtmp_client::rtmp_client(std::string key_path):_key_path(key_path)
}
}
port = (port == 0) ? 1935 : port;
if (_vhost == DEF_VHOST) {
sprintf(url_sz, "rtmp://127.0.0.1:%d/%s/%s", port,
_appname.c_str(), _streamname.c_str());
} else {
sprintf(url_sz, "rtmp://127.0.0.1:%d/%s?vhost=%s/%s", port,
_appname.c_str(), _vhost.c_str(), _streamname.c_str());

std::stringstream ss;
ss << "rtmp://127.0.0.1";
ss << ":" << port;
ss << "/" << _appname;
if (_vhost != DEF_VHOST) {
ss << "?vhost=" << _vhost;
}

_url = url_sz;
ss << "/" << _streamname;

_url = ss.str();

_h264_sps_changed = false;
_h264_pps_changed = false;
_h264_sps_pps_sent = false;

_last_live_ts = now_ms();
srs_trace("rtmp client construct url:%s", url_sz);
srs_trace("rtmp client construct url:%s", _url.c_str());
}

rtmp_client::~rtmp_client() {
Expand Down

0 comments on commit 9d79f85

Please sign in to comment.