正在显示
8 个修改的文件
包含
41 行增加
和
13 行删除
| @@ -273,8 +273,8 @@ int SrsDynamicHttpConn::connect() | @@ -273,8 +273,8 @@ int SrsDynamicHttpConn::connect() | ||
| 273 | } | 273 | } |
| 274 | 274 | ||
| 275 | // connect host. | 275 | // connect host. |
| 276 | - if ((ret = srs_socket_connect(req->host, ::atoi(req->port.c_str()), ST_UTIME_NO_TIMEOUT, &stfd)) != ERROR_SUCCESS) { | ||
| 277 | - srs_error("mpegts: connect server %s:%s failed. ret=%d", req->host.c_str(), req->port.c_str(), ret); | 276 | + if ((ret = srs_socket_connect(req->host, req->port, ST_UTIME_NO_TIMEOUT, &stfd)) != ERROR_SUCCESS) { |
| 277 | + srs_error("mpegts: connect server %s:%d failed. ret=%d", req->host.c_str(), req->port, ret); | ||
| 278 | return ret; | 278 | return ret; |
| 279 | } | 279 | } |
| 280 | io = new SrsStSocket(stfd); | 280 | io = new SrsStSocket(stfd); |
| @@ -308,7 +308,7 @@ int SrsDynamicHttpConn::connect() | @@ -308,7 +308,7 @@ int SrsDynamicHttpConn::connect() | ||
| 308 | } | 308 | } |
| 309 | 309 | ||
| 310 | // TODO: FIXME: refine the connect_app. | 310 | // TODO: FIXME: refine the connect_app. |
| 311 | -int SrsDynamicHttpConn::connect_app(string ep_server, string ep_port) | 311 | +int SrsDynamicHttpConn::connect_app(string ep_server, int ep_port) |
| 312 | { | 312 | { |
| 313 | int ret = ERROR_SUCCESS; | 313 | int ret = ERROR_SUCCESS; |
| 314 | 314 |
| @@ -104,7 +104,7 @@ private: | @@ -104,7 +104,7 @@ private: | ||
| 104 | // connect to rtmp output url. | 104 | // connect to rtmp output url. |
| 105 | // @remark ignore when not connected, reconnect when disconnected. | 105 | // @remark ignore when not connected, reconnect when disconnected. |
| 106 | virtual int connect(); | 106 | virtual int connect(); |
| 107 | - virtual int connect_app(std::string ep_server, std::string ep_port); | 107 | + virtual int connect_app(std::string ep_server, int ep_port); |
| 108 | // close the connected io and rtmp to ready to be re-connect. | 108 | // close the connected io and rtmp to ready to be re-connect. |
| 109 | virtual void close(); | 109 | virtual void close(); |
| 110 | }; | 110 | }; |
| @@ -616,8 +616,8 @@ int SrsMpegtsOverUdp::connect() | @@ -616,8 +616,8 @@ int SrsMpegtsOverUdp::connect() | ||
| 616 | } | 616 | } |
| 617 | 617 | ||
| 618 | // connect host. | 618 | // connect host. |
| 619 | - if ((ret = srs_socket_connect(req->host, ::atoi(req->port.c_str()), ST_UTIME_NO_TIMEOUT, &stfd)) != ERROR_SUCCESS) { | ||
| 620 | - srs_error("mpegts: connect server %s:%s failed. ret=%d", req->host.c_str(), req->port.c_str(), ret); | 619 | + if ((ret = srs_socket_connect(req->host, req->port, ST_UTIME_NO_TIMEOUT, &stfd)) != ERROR_SUCCESS) { |
| 620 | + srs_error("mpegts: connect server %s:%d failed. ret=%d", req->host.c_str(), req->port, ret); | ||
| 621 | return ret; | 621 | return ret; |
| 622 | } | 622 | } |
| 623 | io = new SrsStSocket(stfd); | 623 | io = new SrsStSocket(stfd); |
| @@ -651,7 +651,7 @@ int SrsMpegtsOverUdp::connect() | @@ -651,7 +651,7 @@ int SrsMpegtsOverUdp::connect() | ||
| 651 | } | 651 | } |
| 652 | 652 | ||
| 653 | // TODO: FIXME: refine the connect_app. | 653 | // TODO: FIXME: refine the connect_app. |
| 654 | -int SrsMpegtsOverUdp::connect_app(string ep_server, string ep_port) | 654 | +int SrsMpegtsOverUdp::connect_app(string ep_server, int ep_port) |
| 655 | { | 655 | { |
| 656 | int ret = ERROR_SUCCESS; | 656 | int ret = ERROR_SUCCESS; |
| 657 | 657 |
| @@ -126,7 +126,7 @@ private: | @@ -126,7 +126,7 @@ private: | ||
| 126 | // connect to rtmp output url. | 126 | // connect to rtmp output url. |
| 127 | // @remark ignore when not connected, reconnect when disconnected. | 127 | // @remark ignore when not connected, reconnect when disconnected. |
| 128 | virtual int connect(); | 128 | virtual int connect(); |
| 129 | - virtual int connect_app(std::string ep_server, std::string ep_port); | 129 | + virtual int connect_app(std::string ep_server, int ep_port); |
| 130 | // close the connected io and rtmp to ready to be re-connect. | 130 | // close the connected io and rtmp to ready to be re-connect. |
| 131 | virtual void close(); | 131 | virtual void close(); |
| 132 | }; | 132 | }; |
| @@ -648,7 +648,8 @@ int SrsRtspConn::connect() | @@ -648,7 +648,8 @@ int SrsRtspConn::connect() | ||
| 648 | 648 | ||
| 649 | // parse uri | 649 | // parse uri |
| 650 | if (!req) { | 650 | if (!req) { |
| 651 | - std::string schema, host, vhost, app, port, param; | 651 | + std::string schema, host, vhost, app, param; |
| 652 | + int port; | ||
| 652 | srs_discovery_tc_url(rtsp_tcUrl, schema, host, vhost, app, port, param); | 653 | srs_discovery_tc_url(rtsp_tcUrl, schema, host, vhost, app, port, param); |
| 653 | 654 | ||
| 654 | // generate output by template. | 655 | // generate output by template. |
| @@ -662,8 +663,8 @@ int SrsRtspConn::connect() | @@ -662,8 +663,8 @@ int SrsRtspConn::connect() | ||
| 662 | } | 663 | } |
| 663 | 664 | ||
| 664 | // connect host. | 665 | // connect host. |
| 665 | - if ((ret = srs_socket_connect(req->host, ::atoi(req->port.c_str()), ST_UTIME_NO_TIMEOUT, &stfd)) != ERROR_SUCCESS) { | ||
| 666 | - srs_error("rtsp: connect server %s:%s failed. ret=%d", req->host.c_str(), req->port.c_str(), ret); | 666 | + if ((ret = srs_socket_connect(req->host, req->port, ST_UTIME_NO_TIMEOUT, &stfd)) != ERROR_SUCCESS) { |
| 667 | + srs_error("rtsp: connect server %s:%d failed. ret=%d", req->host.c_str(), req->port, ret); | ||
| 667 | return ret; | 668 | return ret; |
| 668 | } | 669 | } |
| 669 | io = new SrsStSocket(stfd); | 670 | io = new SrsStSocket(stfd); |
| @@ -697,7 +698,7 @@ int SrsRtspConn::connect() | @@ -697,7 +698,7 @@ int SrsRtspConn::connect() | ||
| 697 | } | 698 | } |
| 698 | 699 | ||
| 699 | // TODO: FIXME: refine the connect_app. | 700 | // TODO: FIXME: refine the connect_app. |
| 700 | -int SrsRtspConn::connect_app(string ep_server, string ep_port) | 701 | +int SrsRtspConn::connect_app(string ep_server, int ep_port) |
| 701 | { | 702 | { |
| 702 | int ret = ERROR_SUCCESS; | 703 | int ret = ERROR_SUCCESS; |
| 703 | 704 |
| @@ -181,7 +181,7 @@ private: | @@ -181,7 +181,7 @@ private: | ||
| 181 | // connect to rtmp output url. | 181 | // connect to rtmp output url. |
| 182 | // @remark ignore when not connected, reconnect when disconnected. | 182 | // @remark ignore when not connected, reconnect when disconnected. |
| 183 | virtual int connect(); | 183 | virtual int connect(); |
| 184 | - virtual int connect_app(std::string ep_server, std::string ep_port); | 184 | + virtual int connect_app(std::string ep_server, int ep_port); |
| 185 | }; | 185 | }; |
| 186 | 186 | ||
| 187 | /** | 187 | /** |
| @@ -23,6 +23,9 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | @@ -23,6 +23,9 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
| 23 | 23 | ||
| 24 | #include <srs_app_st.hpp> | 24 | #include <srs_app_st.hpp> |
| 25 | 25 | ||
| 26 | +#include <string> | ||
| 27 | +using namespace std; | ||
| 28 | + | ||
| 26 | #include <srs_kernel_error.hpp> | 29 | #include <srs_kernel_error.hpp> |
| 27 | #include <srs_kernel_log.hpp> | 30 | #include <srs_kernel_log.hpp> |
| 28 | 31 | ||
| @@ -406,6 +409,20 @@ int SrsStSocket::writev(const iovec *iov, int iov_size, ssize_t* nwrite) | @@ -406,6 +409,20 @@ int SrsStSocket::writev(const iovec *iov, int iov_size, ssize_t* nwrite) | ||
| 406 | return ret; | 409 | return ret; |
| 407 | } | 410 | } |
| 408 | 411 | ||
| 412 | +SrsTcpClient::SrsTcpClient() | ||
| 413 | +{ | ||
| 414 | +} | ||
| 415 | + | ||
| 416 | +SrsTcpClient::~SrsTcpClient() | ||
| 417 | +{ | ||
| 418 | +} | ||
| 419 | + | ||
| 420 | +int SrsTcpClient::connect(string host, int port, int64_t timeout) | ||
| 421 | +{ | ||
| 422 | + int ret = ERROR_SUCCESS; | ||
| 423 | + return ret; | ||
| 424 | +} | ||
| 425 | + | ||
| 409 | #ifdef __linux__ | 426 | #ifdef __linux__ |
| 410 | #include <sys/epoll.h> | 427 | #include <sys/epoll.h> |
| 411 | 428 |
| @@ -30,6 +30,8 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | @@ -30,6 +30,8 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
| 30 | 30 | ||
| 31 | #include <srs_core.hpp> | 31 | #include <srs_core.hpp> |
| 32 | 32 | ||
| 33 | +#include <string> | ||
| 34 | + | ||
| 33 | #include <st.h> | 35 | #include <st.h> |
| 34 | 36 | ||
| 35 | #include <srs_app_st.hpp> | 37 | #include <srs_app_st.hpp> |
| @@ -211,6 +213,14 @@ class SrsTcpClient | @@ -211,6 +213,14 @@ class SrsTcpClient | ||
| 211 | public: | 213 | public: |
| 212 | SrsTcpClient(); | 214 | SrsTcpClient(); |
| 213 | virtual ~SrsTcpClient(); | 215 | virtual ~SrsTcpClient(); |
| 216 | +public: | ||
| 217 | + /** | ||
| 218 | + * connect to server over TCP. | ||
| 219 | + * @param host the ip or hostname of server. | ||
| 220 | + * @param port the port to connect to. | ||
| 221 | + * @param timeout the timeout in us. | ||
| 222 | + */ | ||
| 223 | + virtual int connect(std::string host, int port, int64_t timeout); | ||
| 214 | }; | 224 | }; |
| 215 | 225 | ||
| 216 | // initialize st, requires epoll. | 226 | // initialize st, requires epoll. |
-
请 注册 或 登录 后发表评论