mirror of
https://github.com/ossrs/srs.git
synced 2025-02-13 11:51:57 +00:00
SRT: fix srt stream play map error (#1890)
* fix url_sz memory out of bounds * fix srt play map error Co-authored-by: pengyouwei <pengyouwei@comtom.cn>
This commit is contained in:
parent
f86d6fd073
commit
7abc9b640a
2 changed files with 21 additions and 13 deletions
|
@ -97,14 +97,13 @@ void srt_handle::close_pull_conn(SRTSOCKET srtsocket, std::string stream_id) {
|
|||
|
||||
auto streamid_iter = _streamid_map.find(stream_id);
|
||||
if (streamid_iter != _streamid_map.end()) {
|
||||
auto srtsocket_map = streamid_iter->second;
|
||||
if (srtsocket_map.size() == 0) {
|
||||
if (streamid_iter->second.size() == 0) {
|
||||
_streamid_map.erase(stream_id);
|
||||
} else if (srtsocket_map.size() == 1) {
|
||||
srtsocket_map.erase(srtsocket);
|
||||
} else if (streamid_iter->second.size() == 1) {
|
||||
streamid_iter->second.erase(srtsocket);
|
||||
_streamid_map.erase(stream_id);
|
||||
} else {
|
||||
srtsocket_map.erase(srtsocket);
|
||||
streamid_iter->second.erase(srtsocket);
|
||||
}
|
||||
} else {
|
||||
assert(0);
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
@ -258,7 +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::stringstream url_ss;
|
||||
|
||||
std::vector<std::string> ip_ports = _srs_config->get_listens();
|
||||
int port = 0;
|
||||
|
@ -272,21 +273,29 @@ 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());
|
||||
url_ss << "rtmp://127.0.0.1:" << port
|
||||
<< "/" << _appname
|
||||
<< "/" << _streamname;
|
||||
} else {
|
||||
sprintf(url_sz, "rtmp://127.0.0.1:%d/%s?vhost=%s/%s", port,
|
||||
_appname.c_str(), _vhost.c_str(), _streamname.c_str());
|
||||
if (_appname.find("?") == std::string::npos) {
|
||||
url_ss << "rtmp://127.0.0.1:" << port
|
||||
<< "/" << _appname << "?vhost=" << _vhost
|
||||
<< "/" << _streamname;
|
||||
} else {
|
||||
url_ss << "rtmp://127.0.0.1:" << port
|
||||
<< "/" << _appname << "&vhost=" << _vhost
|
||||
<< "/" << _streamname;
|
||||
}
|
||||
}
|
||||
|
||||
_url = url_sz;
|
||||
_url = 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_ss.str().c_str());
|
||||
}
|
||||
|
||||
rtmp_client::~rtmp_client() {
|
||||
|
|
Loading…
Reference in a new issue