From 92980a0ca265b3c041bd49ab009db7050be9ac38 Mon Sep 17 00:00:00 2001 From: winlin Date: Thu, 11 Apr 2019 09:18:20 +0800 Subject: [PATCH] Refine SRS_CONSTS_RTMP_TMMS in time unit --- trunk/src/app/srs_app_caster_flv.cpp | 2 +- trunk/src/app/srs_app_edge.cpp | 3 ++- trunk/src/app/srs_app_forward.cpp | 3 ++- trunk/src/app/srs_app_mpegts_udp.cpp | 2 +- trunk/src/app/srs_app_rtmp_conn.cpp | 12 ++++++------ trunk/src/app/srs_app_rtsp.cpp | 2 +- trunk/src/kernel/srs_kernel_consts.hpp | 6 +++--- trunk/src/main/srs_main_ingest_hls.cpp | 2 +- trunk/src/protocol/srs_rtmp_stack.hpp | 1 + trunk/src/service/srs_service_st.cpp | 1 + 10 files changed, 19 insertions(+), 15 deletions(-) diff --git a/trunk/src/app/srs_app_caster_flv.cpp b/trunk/src/app/srs_app_caster_flv.cpp index 788c77cf8..086afdcde 100644 --- a/trunk/src/app/srs_app_caster_flv.cpp +++ b/trunk/src/app/srs_app_caster_flv.cpp @@ -192,7 +192,7 @@ srs_error_t SrsDynamicHttpConn::do_proxy(ISrsHttpResponseReader* rr, SrsFlvDecod srs_freep(sdk); - int64_t cto = SRS_CONSTS_RTMP_TMMS; + int64_t cto = srsu2ms(SRS_CONSTS_RTMP_TIMEOUT); int64_t sto = srsu2ms(SRS_CONSTS_RTMP_PULSE); sdk = new SrsSimpleRtmpClient(output, cto, sto); diff --git a/trunk/src/app/srs_app_edge.cpp b/trunk/src/app/srs_app_edge.cpp index 74ae5b156..a6d53508d 100644 --- a/trunk/src/app/srs_app_edge.cpp +++ b/trunk/src/app/srs_app_edge.cpp @@ -474,8 +474,9 @@ srs_error_t SrsEdgeForwarder::start() // open socket. srs_freep(sdk); + // TODO: FIXME: Should switch cto with sto? int64_t cto = srsu2ms(SRS_EDGE_FORWARDER_TMMS); - int64_t sto = SRS_CONSTS_RTMP_TMMS; + int64_t sto = srsu2ms(SRS_CONSTS_RTMP_TIMEOUT); sdk = new SrsSimpleRtmpClient(url, cto, sto); if ((err = sdk->connect()) != srs_success) { diff --git a/trunk/src/app/srs_app_forward.cpp b/trunk/src/app/srs_app_forward.cpp index cc1e20734..11295349b 100755 --- a/trunk/src/app/srs_app_forward.cpp +++ b/trunk/src/app/srs_app_forward.cpp @@ -213,8 +213,9 @@ srs_error_t SrsForwarder::do_cycle() } srs_freep(sdk); + // TODO: FIXME: Should switch cto with sto? int64_t cto = srsu2ms(SRS_FORWARDER_CIMS); - int64_t sto = SRS_CONSTS_RTMP_TMMS; + int64_t sto = srsu2ms(SRS_CONSTS_RTMP_TIMEOUT); sdk = new SrsSimpleRtmpClient(url, cto, sto); if ((err = sdk->connect()) != srs_success) { diff --git a/trunk/src/app/srs_app_mpegts_udp.cpp b/trunk/src/app/srs_app_mpegts_udp.cpp index b0de52b07..f6a4ebbf2 100644 --- a/trunk/src/app/srs_app_mpegts_udp.cpp +++ b/trunk/src/app/srs_app_mpegts_udp.cpp @@ -615,7 +615,7 @@ srs_error_t SrsMpegtsOverUdp::connect() return err; } - int64_t cto = SRS_CONSTS_RTMP_TMMS; + int64_t cto = srsu2ms(SRS_CONSTS_RTMP_TIMEOUT); int64_t sto = srsu2ms(SRS_CONSTS_RTMP_PULSE); sdk = new SrsSimpleRtmpClient(output, cto, sto); diff --git a/trunk/src/app/srs_app_rtmp_conn.cpp b/trunk/src/app/srs_app_rtmp_conn.cpp index 467fb0d3b..4e9323ca5 100644 --- a/trunk/src/app/srs_app_rtmp_conn.cpp +++ b/trunk/src/app/srs_app_rtmp_conn.cpp @@ -166,8 +166,8 @@ srs_error_t SrsRtmpConn::do_cycle() } #endif - rtmp->set_recv_timeout(SRS_CONSTS_RTMP_TMMS); - rtmp->set_send_timeout(SRS_CONSTS_RTMP_TMMS); + rtmp->set_recv_timeout(srsu2ms(SRS_CONSTS_RTMP_TIMEOUT)); + rtmp->set_send_timeout(srsu2ms(SRS_CONSTS_RTMP_TIMEOUT)); if ((err = rtmp->handshake()) != srs_success) { return srs_error_wrap(err, "rtmp handshake"); @@ -498,8 +498,8 @@ srs_error_t SrsRtmpConn::stream_service_cycle() } // client is identified, set the timeout to service timeout. - rtmp->set_recv_timeout(SRS_CONSTS_RTMP_TMMS); - rtmp->set_send_timeout(SRS_CONSTS_RTMP_TMMS); + rtmp->set_recv_timeout(srsu2ms(SRS_CONSTS_RTMP_TIMEOUT)); + rtmp->set_send_timeout(srsu2ms(SRS_CONSTS_RTMP_TIMEOUT)); // find a source to serve. SrsSource* source = NULL; @@ -1183,8 +1183,8 @@ srs_error_t SrsRtmpConn::do_token_traverse_auth(SrsRtmpClient* client) SrsRequest* req = info->req; srs_assert(client); - client->set_recv_timeout(SRS_CONSTS_RTMP_TMMS); - client->set_send_timeout(SRS_CONSTS_RTMP_TMMS); + client->set_recv_timeout(srsu2ms(SRS_CONSTS_RTMP_TIMEOUT)); + client->set_send_timeout(srsu2ms(SRS_CONSTS_RTMP_TIMEOUT)); if ((err = client->handshake()) != srs_success) { return srs_error_wrap(err, "rtmp: handshake"); diff --git a/trunk/src/app/srs_app_rtsp.cpp b/trunk/src/app/srs_app_rtsp.cpp index f71ae3ca4..0502a0324 100644 --- a/trunk/src/app/srs_app_rtsp.cpp +++ b/trunk/src/app/srs_app_rtsp.cpp @@ -649,7 +649,7 @@ srs_error_t SrsRtspConn::connect() } // connect host. - int64_t cto = SRS_CONSTS_RTMP_TMMS; + int64_t cto = srsu2ms(SRS_CONSTS_RTMP_TIMEOUT); int64_t sto = srsu2ms(SRS_CONSTS_RTMP_PULSE); sdk = new SrsSimpleRtmpClient(url, cto, sto); diff --git a/trunk/src/kernel/srs_kernel_consts.hpp b/trunk/src/kernel/srs_kernel_consts.hpp index 3cc830d6c..e003c46d5 100644 --- a/trunk/src/kernel/srs_kernel_consts.hpp +++ b/trunk/src/kernel/srs_kernel_consts.hpp @@ -69,9 +69,9 @@ // @see ST_UTIME_NO_TIMEOUT #define SRS_CONSTS_NO_TMMS ((int64_t) -1LL) -// the common io timeout, for both recv and send. -// TODO: FIXME: use ms for timeout. -#define SRS_CONSTS_RTMP_TMMS (30*1000) +// the common io timeout, for connect, recv or send. +// TODO: FIXME: Maybe change to larger value, such as 90ms? +#define SRS_CONSTS_RTMP_TIMEOUT (30 * SRS_UTIME_MILLISECONDS) // the timeout to wait for client control message, // if timeout, we generally ignore and send the data to client, diff --git a/trunk/src/main/srs_main_ingest_hls.cpp b/trunk/src/main/srs_main_ingest_hls.cpp index 5a21e742d..f8cc61795 100644 --- a/trunk/src/main/srs_main_ingest_hls.cpp +++ b/trunk/src/main/srs_main_ingest_hls.cpp @@ -1276,7 +1276,7 @@ int SrsIngestHlsOutput::connect() srs_trace("connect output=%s", url.c_str()); // connect host. - int64_t cto = SRS_CONSTS_RTMP_TMMS; + int64_t cto = srsu2ms(SRS_CONSTS_RTMP_TIMEOUT); int64_t sto = srsu2ms(SRS_CONSTS_RTMP_PULSE); sdk = new SrsBasicRtmpClient(url, cto, sto); diff --git a/trunk/src/protocol/srs_rtmp_stack.hpp b/trunk/src/protocol/srs_rtmp_stack.hpp index 1466c96f8..b1a0bac51 100644 --- a/trunk/src/protocol/srs_rtmp_stack.hpp +++ b/trunk/src/protocol/srs_rtmp_stack.hpp @@ -307,6 +307,7 @@ public: * set/get the recv timeout in ms. * if timeout, recv/send message return ERROR_SOCKET_TIMEOUT. */ + // TODO: FIXME: Refine tm in time unit. virtual void set_recv_timeout(int64_t tm); virtual int64_t get_recv_timeout(); /** diff --git a/trunk/src/service/srs_service_st.cpp b/trunk/src/service/srs_service_st.cpp index f294ef6f4..fdb489da9 100644 --- a/trunk/src/service/srs_service_st.cpp +++ b/trunk/src/service/srs_service_st.cpp @@ -104,6 +104,7 @@ srs_thread_t srs_thread_self() return (srs_thread_t)st_thread_self(); } +// TODO: FXIME: Refine tm in time unit. srs_error_t srs_socket_connect(string server, int port, int64_t tm, srs_netfd_t* pstfd) { st_utime_t timeout = ST_UTIME_NO_TIMEOUT;