mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
fix bug, use system utility
This commit is contained in:
parent
69cc01b696
commit
20fcfb3eee
8 changed files with 41 additions and 13 deletions
|
@ -273,8 +273,8 @@ int SrsDynamicHttpConn::connect()
|
||||||
}
|
}
|
||||||
|
|
||||||
// connect host.
|
// connect host.
|
||||||
if ((ret = srs_socket_connect(req->host, ::atoi(req->port.c_str()), ST_UTIME_NO_TIMEOUT, &stfd)) != ERROR_SUCCESS) {
|
if ((ret = srs_socket_connect(req->host, req->port, ST_UTIME_NO_TIMEOUT, &stfd)) != ERROR_SUCCESS) {
|
||||||
srs_error("mpegts: connect server %s:%s failed. ret=%d", req->host.c_str(), req->port.c_str(), ret);
|
srs_error("mpegts: connect server %s:%d failed. ret=%d", req->host.c_str(), req->port, ret);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
io = new SrsStSocket(stfd);
|
io = new SrsStSocket(stfd);
|
||||||
|
@ -308,7 +308,7 @@ int SrsDynamicHttpConn::connect()
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: FIXME: refine the connect_app.
|
// TODO: FIXME: refine the connect_app.
|
||||||
int SrsDynamicHttpConn::connect_app(string ep_server, string ep_port)
|
int SrsDynamicHttpConn::connect_app(string ep_server, int ep_port)
|
||||||
{
|
{
|
||||||
int ret = ERROR_SUCCESS;
|
int ret = ERROR_SUCCESS;
|
||||||
|
|
||||||
|
|
|
@ -104,7 +104,7 @@ private:
|
||||||
// connect to rtmp output url.
|
// connect to rtmp output url.
|
||||||
// @remark ignore when not connected, reconnect when disconnected.
|
// @remark ignore when not connected, reconnect when disconnected.
|
||||||
virtual int connect();
|
virtual int connect();
|
||||||
virtual int connect_app(std::string ep_server, std::string ep_port);
|
virtual int connect_app(std::string ep_server, int ep_port);
|
||||||
// close the connected io and rtmp to ready to be re-connect.
|
// close the connected io and rtmp to ready to be re-connect.
|
||||||
virtual void close();
|
virtual void close();
|
||||||
};
|
};
|
||||||
|
|
|
@ -616,8 +616,8 @@ int SrsMpegtsOverUdp::connect()
|
||||||
}
|
}
|
||||||
|
|
||||||
// connect host.
|
// connect host.
|
||||||
if ((ret = srs_socket_connect(req->host, ::atoi(req->port.c_str()), ST_UTIME_NO_TIMEOUT, &stfd)) != ERROR_SUCCESS) {
|
if ((ret = srs_socket_connect(req->host, req->port, ST_UTIME_NO_TIMEOUT, &stfd)) != ERROR_SUCCESS) {
|
||||||
srs_error("mpegts: connect server %s:%s failed. ret=%d", req->host.c_str(), req->port.c_str(), ret);
|
srs_error("mpegts: connect server %s:%d failed. ret=%d", req->host.c_str(), req->port, ret);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
io = new SrsStSocket(stfd);
|
io = new SrsStSocket(stfd);
|
||||||
|
@ -651,7 +651,7 @@ int SrsMpegtsOverUdp::connect()
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: FIXME: refine the connect_app.
|
// TODO: FIXME: refine the connect_app.
|
||||||
int SrsMpegtsOverUdp::connect_app(string ep_server, string ep_port)
|
int SrsMpegtsOverUdp::connect_app(string ep_server, int ep_port)
|
||||||
{
|
{
|
||||||
int ret = ERROR_SUCCESS;
|
int ret = ERROR_SUCCESS;
|
||||||
|
|
||||||
|
|
|
@ -126,7 +126,7 @@ private:
|
||||||
// connect to rtmp output url.
|
// connect to rtmp output url.
|
||||||
// @remark ignore when not connected, reconnect when disconnected.
|
// @remark ignore when not connected, reconnect when disconnected.
|
||||||
virtual int connect();
|
virtual int connect();
|
||||||
virtual int connect_app(std::string ep_server, std::string ep_port);
|
virtual int connect_app(std::string ep_server, int ep_port);
|
||||||
// close the connected io and rtmp to ready to be re-connect.
|
// close the connected io and rtmp to ready to be re-connect.
|
||||||
virtual void close();
|
virtual void close();
|
||||||
};
|
};
|
||||||
|
|
|
@ -648,7 +648,8 @@ int SrsRtspConn::connect()
|
||||||
|
|
||||||
// parse uri
|
// parse uri
|
||||||
if (!req) {
|
if (!req) {
|
||||||
std::string schema, host, vhost, app, port, param;
|
std::string schema, host, vhost, app, param;
|
||||||
|
int port;
|
||||||
srs_discovery_tc_url(rtsp_tcUrl, schema, host, vhost, app, port, param);
|
srs_discovery_tc_url(rtsp_tcUrl, schema, host, vhost, app, port, param);
|
||||||
|
|
||||||
// generate output by template.
|
// generate output by template.
|
||||||
|
@ -662,8 +663,8 @@ int SrsRtspConn::connect()
|
||||||
}
|
}
|
||||||
|
|
||||||
// connect host.
|
// connect host.
|
||||||
if ((ret = srs_socket_connect(req->host, ::atoi(req->port.c_str()), ST_UTIME_NO_TIMEOUT, &stfd)) != ERROR_SUCCESS) {
|
if ((ret = srs_socket_connect(req->host, req->port, ST_UTIME_NO_TIMEOUT, &stfd)) != ERROR_SUCCESS) {
|
||||||
srs_error("rtsp: connect server %s:%s failed. ret=%d", req->host.c_str(), req->port.c_str(), ret);
|
srs_error("rtsp: connect server %s:%d failed. ret=%d", req->host.c_str(), req->port, ret);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
io = new SrsStSocket(stfd);
|
io = new SrsStSocket(stfd);
|
||||||
|
@ -697,7 +698,7 @@ int SrsRtspConn::connect()
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: FIXME: refine the connect_app.
|
// TODO: FIXME: refine the connect_app.
|
||||||
int SrsRtspConn::connect_app(string ep_server, string ep_port)
|
int SrsRtspConn::connect_app(string ep_server, int ep_port)
|
||||||
{
|
{
|
||||||
int ret = ERROR_SUCCESS;
|
int ret = ERROR_SUCCESS;
|
||||||
|
|
||||||
|
|
|
@ -181,7 +181,7 @@ private:
|
||||||
// connect to rtmp output url.
|
// connect to rtmp output url.
|
||||||
// @remark ignore when not connected, reconnect when disconnected.
|
// @remark ignore when not connected, reconnect when disconnected.
|
||||||
virtual int connect();
|
virtual int connect();
|
||||||
virtual int connect_app(std::string ep_server, std::string ep_port);
|
virtual int connect_app(std::string ep_server, int ep_port);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -23,6 +23,9 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
#include <srs_app_st.hpp>
|
#include <srs_app_st.hpp>
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
#include <srs_kernel_error.hpp>
|
#include <srs_kernel_error.hpp>
|
||||||
#include <srs_kernel_log.hpp>
|
#include <srs_kernel_log.hpp>
|
||||||
|
|
||||||
|
@ -406,6 +409,20 @@ int SrsStSocket::writev(const iovec *iov, int iov_size, ssize_t* nwrite)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SrsTcpClient::SrsTcpClient()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
SrsTcpClient::~SrsTcpClient()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
int SrsTcpClient::connect(string host, int port, int64_t timeout)
|
||||||
|
{
|
||||||
|
int ret = ERROR_SUCCESS;
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef __linux__
|
#ifdef __linux__
|
||||||
#include <sys/epoll.h>
|
#include <sys/epoll.h>
|
||||||
|
|
||||||
|
|
|
@ -30,6 +30,8 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
#include <srs_core.hpp>
|
#include <srs_core.hpp>
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
#include <st.h>
|
#include <st.h>
|
||||||
|
|
||||||
#include <srs_app_st.hpp>
|
#include <srs_app_st.hpp>
|
||||||
|
@ -211,6 +213,14 @@ class SrsTcpClient
|
||||||
public:
|
public:
|
||||||
SrsTcpClient();
|
SrsTcpClient();
|
||||||
virtual ~SrsTcpClient();
|
virtual ~SrsTcpClient();
|
||||||
|
public:
|
||||||
|
/**
|
||||||
|
* connect to server over TCP.
|
||||||
|
* @param host the ip or hostname of server.
|
||||||
|
* @param port the port to connect to.
|
||||||
|
* @param timeout the timeout in us.
|
||||||
|
*/
|
||||||
|
virtual int connect(std::string host, int port, int64_t timeout);
|
||||||
};
|
};
|
||||||
|
|
||||||
// initialize st, requires epoll.
|
// initialize st, requires epoll.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue