mirror of
https://github.com/ossrs/srs.git
synced 2025-02-15 04:42:04 +00:00
SRT: Refine parse SRT listen ip and port.
This commit is contained in:
parent
3616c9976a
commit
b507a080b2
1 changed files with 13 additions and 19 deletions
|
@ -188,27 +188,21 @@ srs_error_t SrsSrtServer::listen_srt_mpegts()
|
|||
if (! _srs_config->get_srt_enabled()) {
|
||||
return err;
|
||||
}
|
||||
|
||||
// TODO: FIXME: bad code, refine it.
|
||||
std::vector<std::string> ip_ports;
|
||||
std::stringstream ss;
|
||||
ss << _srs_config->get_srt_listen_port();
|
||||
ip_ports.push_back(ss.str());
|
||||
|
||||
close_listeners(SrsSrtListenerMpegts);
|
||||
|
||||
for (int i = 0; i < (int)ip_ports.size(); i++) {
|
||||
SrsSrtAcceptor* acceptor = new SrsSrtMessageAcceptor(this, SrsSrtListenerMpegts);
|
||||
acceptors_.push_back(acceptor);
|
||||
|
||||
int port; string ip;
|
||||
srs_parse_endpoint(ip_ports[i], ip, port);
|
||||
|
||||
if ((err = acceptor->listen(ip, port)) != srs_success) {
|
||||
return srs_error_wrap(err, "srt listen %s:%d", ip.c_str(), port);
|
||||
}
|
||||
// Close all listener for SRT if exists.
|
||||
close_listeners(SrsSrtListenerMpegts);
|
||||
|
||||
// Start a listener for SRT, we might need multiple listeners in the future.
|
||||
SrsSrtAcceptor* acceptor = new SrsSrtMessageAcceptor(this, SrsSrtListenerMpegts);
|
||||
acceptors_.push_back(acceptor);
|
||||
|
||||
int port; string ip;
|
||||
srs_parse_endpoint(srs_int2str(_srs_config->get_srt_listen_port()), ip, port);
|
||||
|
||||
if ((err = acceptor->listen(ip, port)) != srs_success) {
|
||||
return srs_error_wrap(err, "srt listen %s:%d", ip.c_str(), port);
|
||||
}
|
||||
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue