mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
SRT: Decouple publish with play url (#2893). v4.0.251
This commit is contained in:
parent
41e35155f7
commit
76ed0200b4
6 changed files with 29 additions and 14 deletions
|
@ -8,6 +8,7 @@ The changelog for SRS.
|
||||||
|
|
||||||
## SRS 4.0 Changelog
|
## SRS 4.0 Changelog
|
||||||
|
|
||||||
|
* v4.0, 2022-03-19, For [#2893](https://github.com/ossrs/srs/pull/2893): SRT: Decouple publish with play url (#2893). v4.0.251
|
||||||
* v4.0, 2022-03-19, Merge [#2908](https://github.com/ossrs/srs/pull/2908): SRT: url supports multiple QueryStrings (#2908). v4.0.250
|
* v4.0, 2022-03-19, Merge [#2908](https://github.com/ossrs/srs/pull/2908): SRT: url supports multiple QueryStrings (#2908). v4.0.250
|
||||||
* v4.0, 2022-03-17, SRT: Support debug and run with CLion. v4.0.249
|
* v4.0, 2022-03-17, SRT: Support debug and run with CLion. v4.0.249
|
||||||
* v4.0, 2022-03-15, Merge [#2966](https://github.com/ossrs/srs/pull/2966): Bugfix: Fix rtcp nack blp encode bug (#2966). v4.0.248
|
* v4.0, 2022-03-15, Merge [#2966](https://github.com/ossrs/srs/pull/2966): Bugfix: Fix rtcp nack blp encode bug (#2966). v4.0.248
|
||||||
|
|
|
@ -9,6 +9,6 @@
|
||||||
|
|
||||||
#define VERSION_MAJOR 4
|
#define VERSION_MAJOR 4
|
||||||
#define VERSION_MINOR 0
|
#define VERSION_MINOR 0
|
||||||
#define VERSION_REVISION 250
|
#define VERSION_REVISION 251
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -219,6 +219,17 @@ std::string srt_conn::get_streamid() {
|
||||||
return _streamid;
|
return _streamid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string srt_conn::get_path() {
|
||||||
|
if (!_url_path.empty()) {
|
||||||
|
return _url_path;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t pos = _url_subpath.find("?");
|
||||||
|
_url_path = (pos != std::string::npos) ? _url_subpath.substr(0, pos) : _url_subpath;
|
||||||
|
|
||||||
|
return _url_path;
|
||||||
|
}
|
||||||
|
|
||||||
std::string srt_conn::get_subpath() {
|
std::string srt_conn::get_subpath() {
|
||||||
return _url_subpath;
|
return _url_subpath;
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,6 +37,7 @@ public:
|
||||||
SRTSOCKET get_conn();
|
SRTSOCKET get_conn();
|
||||||
int get_mode();
|
int get_mode();
|
||||||
std::string get_streamid();
|
std::string get_streamid();
|
||||||
|
std::string get_path();
|
||||||
std::string get_subpath();
|
std::string get_subpath();
|
||||||
std::string get_vhost();
|
std::string get_vhost();
|
||||||
int read(unsigned char* data, int len);
|
int read(unsigned char* data, int len);
|
||||||
|
@ -49,6 +50,7 @@ public:
|
||||||
private:
|
private:
|
||||||
SRTSOCKET _conn_fd;
|
SRTSOCKET _conn_fd;
|
||||||
std::string _streamid;
|
std::string _streamid;
|
||||||
|
std::string _url_path;
|
||||||
std::string _url_subpath;
|
std::string _url_subpath;
|
||||||
std::string _vhost;
|
std::string _vhost;
|
||||||
int _mode;
|
int _mode;
|
||||||
|
|
|
@ -160,7 +160,7 @@ void srt_handle::add_newconn(SRT_CONN_PTR conn_ptr, int events) {
|
||||||
srt_log_trace("srt h264 sei filter is %s.", _srs_config->get_srt_sei_filter() ? "enable" : "disable");
|
srt_log_trace("srt h264 sei filter is %s.", _srs_config->get_srt_sei_filter() ? "enable" : "disable");
|
||||||
|
|
||||||
if (conn_ptr->get_mode() == PULL_SRT_MODE) {
|
if (conn_ptr->get_mode() == PULL_SRT_MODE) {
|
||||||
add_new_puller(conn_ptr, conn_ptr->get_subpath());
|
add_new_puller(conn_ptr, conn_ptr->get_path());
|
||||||
} else {
|
} else {
|
||||||
if(add_new_pusher(conn_ptr) == false) {
|
if(add_new_pusher(conn_ptr) == false) {
|
||||||
srt_log_trace("push connection is repeated and rejected, fd:%d, streamid:%s",
|
srt_log_trace("push connection is repeated and rejected, fd:%d, streamid:%s",
|
||||||
|
@ -179,7 +179,7 @@ void srt_handle::add_newconn(SRT_CONN_PTR conn_ptr, int events) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
void srt_handle::handle_push_data(SRT_SOCKSTATUS status, const std::string& subpath, SRTSOCKET conn_fd) {
|
void srt_handle::handle_push_data(SRT_SOCKSTATUS status, const std::string& path, const std::string& subpath, SRTSOCKET conn_fd) {
|
||||||
SRT_CONN_PTR srt_conn_ptr;
|
SRT_CONN_PTR srt_conn_ptr;
|
||||||
unsigned char data[DEF_DATA_SIZE];
|
unsigned char data[DEF_DATA_SIZE];
|
||||||
int ret;
|
int ret;
|
||||||
|
@ -222,7 +222,7 @@ void srt_handle::handle_push_data(SRT_SOCKSTATUS status, const std::string& subp
|
||||||
|
|
||||||
//send data to subscriber(players)
|
//send data to subscriber(players)
|
||||||
//streamid, play map<SRTSOCKET, SRT_CONN_PTR>
|
//streamid, play map<SRTSOCKET, SRT_CONN_PTR>
|
||||||
auto streamid_iter = _streamid_map.find(subpath);
|
auto streamid_iter = _streamid_map.find(path);
|
||||||
if (streamid_iter == _streamid_map.end()) {//no puler
|
if (streamid_iter == _streamid_map.end()) {//no puler
|
||||||
srt_log_info("receive data size(%d) from pusher(%d) but no puller", ret, conn_fd);
|
srt_log_info("receive data size(%d) from pusher(%d) but no puller", ret, conn_fd);
|
||||||
return;
|
return;
|
||||||
|
@ -294,8 +294,8 @@ void srt_handle::check_alive() {
|
||||||
close_push_conn(conn_ptr->get_conn());
|
close_push_conn(conn_ptr->get_conn());
|
||||||
} else if (conn_ptr->get_mode() == PULL_SRT_MODE) {
|
} else if (conn_ptr->get_mode() == PULL_SRT_MODE) {
|
||||||
srt_log_warn("check alive close pull connection fd:%d, streamid:%s",
|
srt_log_warn("check alive close pull connection fd:%d, streamid:%s",
|
||||||
conn_ptr->get_conn(), conn_ptr->get_subpath().c_str());
|
conn_ptr->get_conn(), conn_ptr->get_path().c_str());
|
||||||
close_pull_conn(conn_ptr->get_conn(), conn_ptr->get_subpath());
|
close_pull_conn(conn_ptr->get_conn(), conn_ptr->get_path());
|
||||||
} else {
|
} else {
|
||||||
srt_log_error("check_alive get unkown srt mode:%d, fd:%d",
|
srt_log_error("check_alive get unkown srt mode:%d, fd:%d",
|
||||||
conn_ptr->get_mode(), conn_ptr->get_conn());
|
conn_ptr->get_mode(), conn_ptr->get_conn());
|
||||||
|
@ -309,7 +309,7 @@ void srt_handle::close_push_conn(SRTSOCKET srtsocket) {
|
||||||
|
|
||||||
if (iter != _conn_map.end()) {
|
if (iter != _conn_map.end()) {
|
||||||
SRT_CONN_PTR conn_ptr = iter->second;
|
SRT_CONN_PTR conn_ptr = iter->second;
|
||||||
auto push_iter = _push_conn_map.find(conn_ptr->get_subpath());
|
auto push_iter = _push_conn_map.find(conn_ptr->get_path());
|
||||||
if (push_iter != _push_conn_map.end()) {
|
if (push_iter != _push_conn_map.end()) {
|
||||||
_push_conn_map.erase(push_iter);
|
_push_conn_map.erase(push_iter);
|
||||||
}
|
}
|
||||||
|
@ -324,14 +324,14 @@ void srt_handle::close_push_conn(SRTSOCKET srtsocket) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool srt_handle::add_new_pusher(SRT_CONN_PTR conn_ptr) {
|
bool srt_handle::add_new_pusher(SRT_CONN_PTR conn_ptr) {
|
||||||
auto push_iter = _push_conn_map.find(conn_ptr->get_subpath());
|
auto push_iter = _push_conn_map.find(conn_ptr->get_path());
|
||||||
if (push_iter != _push_conn_map.end()) {
|
if (push_iter != _push_conn_map.end()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
_push_conn_map.insert(std::make_pair(conn_ptr->get_subpath(), conn_ptr));
|
_push_conn_map.insert(std::make_pair(conn_ptr->get_path(), conn_ptr));
|
||||||
_conn_map.insert(std::make_pair(conn_ptr->get_conn(), conn_ptr));
|
_conn_map.insert(std::make_pair(conn_ptr->get_conn(), conn_ptr));
|
||||||
srt_log_trace("srt_handle add new pusher streamid:%s, subpath:%s",
|
srt_log_trace("srt_handle add new pusher streamid:%s, subpath:%s, sid:%s",
|
||||||
conn_ptr->get_streamid().c_str(), conn_ptr->get_subpath().c_str());
|
conn_ptr->get_streamid().c_str(), conn_ptr->get_subpath().c_str(), conn_ptr->get_path().c_str());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -358,6 +358,7 @@ void srt_handle::handle_srt_socket(SRT_SOCKSTATUS status, SRTSOCKET conn_fd)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string path = conn_ptr->get_path();
|
||||||
std::string subpath = conn_ptr->get_subpath();
|
std::string subpath = conn_ptr->get_subpath();
|
||||||
|
|
||||||
int mode = conn_ptr->get_mode();
|
int mode = conn_ptr->get_mode();
|
||||||
|
@ -366,7 +367,7 @@ void srt_handle::handle_srt_socket(SRT_SOCKSTATUS status, SRTSOCKET conn_fd)
|
||||||
{
|
{
|
||||||
case SRTS_CONNECTED:
|
case SRTS_CONNECTED:
|
||||||
{
|
{
|
||||||
handle_push_data(status, subpath, conn_fd);
|
handle_push_data(status, path, subpath, conn_fd);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case SRTS_BROKEN:
|
case SRTS_BROKEN:
|
||||||
|
@ -392,7 +393,7 @@ void srt_handle::handle_srt_socket(SRT_SOCKSTATUS status, SRTSOCKET conn_fd)
|
||||||
{
|
{
|
||||||
srt_log_warn("srt pull disconnected fd:%d, streamid:%s",
|
srt_log_warn("srt pull disconnected fd:%d, streamid:%s",
|
||||||
conn_fd, conn_ptr->get_streamid().c_str());
|
conn_fd, conn_ptr->get_streamid().c_str());
|
||||||
close_pull_conn(conn_fd, subpath);
|
close_pull_conn(conn_fd, path);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -37,7 +37,7 @@ private:
|
||||||
//get srt conn object by srt socket
|
//get srt conn object by srt socket
|
||||||
SRT_CONN_PTR get_srt_conn(SRTSOCKET conn_srt_socket);
|
SRT_CONN_PTR get_srt_conn(SRTSOCKET conn_srt_socket);
|
||||||
|
|
||||||
void handle_push_data(SRT_SOCKSTATUS status, const std::string& subpath, SRTSOCKET conn_fd);
|
void handle_push_data(SRT_SOCKSTATUS status, const std::string& path, const std::string& subpath, SRTSOCKET conn_fd);
|
||||||
void handle_pull_data(SRT_SOCKSTATUS status, const std::string& subpath, SRTSOCKET conn_fd);
|
void handle_pull_data(SRT_SOCKSTATUS status, const std::string& subpath, SRTSOCKET conn_fd);
|
||||||
|
|
||||||
//add new puller into puller list and conn_map
|
//add new puller into puller list and conn_map
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue