mirror of
https://github.com/ossrs/srs.git
synced 2025-02-13 03:41:55 +00:00
Refine set_recv_timeout in time unit
This commit is contained in:
parent
38bbf6b111
commit
d3dc45f357
20 changed files with 45 additions and 46 deletions
|
@ -181,7 +181,7 @@ srs_error_t SrsBandwidth::do_bandwidth_check(SrsKbpsLimit* limit)
|
|||
|
||||
// timeout for a packet.
|
||||
_rtmp->set_send_timeout(play_sample.duration_ms * 2 * SRS_UTIME_MILLISECONDS);
|
||||
_rtmp->set_recv_timeout(publish_sample.duration_ms * 2);
|
||||
_rtmp->set_recv_timeout(publish_sample.duration_ms * 2 * SRS_UTIME_MILLISECONDS);
|
||||
|
||||
// start test.
|
||||
srs_utime_t start_time = srs_update_system_time();
|
||||
|
|
|
@ -144,7 +144,7 @@ void SrsEdgeRtmpUpstream::close()
|
|||
srs_freep(sdk);
|
||||
}
|
||||
|
||||
void SrsEdgeRtmpUpstream::set_recv_timeout(int64_t tm)
|
||||
void SrsEdgeRtmpUpstream::set_recv_timeout(srs_utime_t tm)
|
||||
{
|
||||
sdk->set_recv_timeout(tm);
|
||||
}
|
||||
|
@ -294,7 +294,7 @@ srs_error_t SrsEdgeIngester::ingest()
|
|||
SrsAutoFree(SrsPithyPrint, pprint);
|
||||
|
||||
// set to larger timeout to read av data from origin.
|
||||
upstream->set_recv_timeout(srsu2ms(SRS_EDGE_INGESTER_TMMS));
|
||||
upstream->set_recv_timeout(SRS_EDGE_INGESTER_TMMS);
|
||||
|
||||
while (true) {
|
||||
srs_error_t err = srs_success;
|
||||
|
@ -533,7 +533,7 @@ srs_error_t SrsEdgeForwarder::do_cycle()
|
|||
{
|
||||
srs_error_t err = srs_success;
|
||||
|
||||
sdk->set_recv_timeout(srsu2ms(SRS_CONSTS_RTMP_PULSE));
|
||||
sdk->set_recv_timeout(SRS_CONSTS_RTMP_PULSE);
|
||||
|
||||
SrsPithyPrint* pprint = SrsPithyPrint::create_edge();
|
||||
SrsAutoFree(SrsPithyPrint, pprint);
|
||||
|
|
|
@ -86,7 +86,7 @@ public:
|
|||
virtual srs_error_t decode_message(SrsCommonMessage* msg, SrsPacket** ppacket) = 0;
|
||||
virtual void close() = 0;
|
||||
public:
|
||||
virtual void set_recv_timeout(int64_t tm) = 0;
|
||||
virtual void set_recv_timeout(srs_utime_t tm) = 0;
|
||||
virtual void kbps_sample(const char* label, int64_t age) = 0;
|
||||
};
|
||||
|
||||
|
@ -107,7 +107,7 @@ public:
|
|||
virtual srs_error_t decode_message(SrsCommonMessage* msg, SrsPacket** ppacket);
|
||||
virtual void close();
|
||||
public:
|
||||
virtual void set_recv_timeout(int64_t tm);
|
||||
virtual void set_recv_timeout(srs_utime_t tm);
|
||||
virtual void kbps_sample(const char* label, int64_t age);
|
||||
};
|
||||
|
||||
|
|
|
@ -242,7 +242,7 @@ srs_error_t SrsForwarder::forward()
|
|||
{
|
||||
srs_error_t err = srs_success;
|
||||
|
||||
sdk->set_recv_timeout(srsu2ms(SRS_CONSTS_RTMP_PULSE));
|
||||
sdk->set_recv_timeout(SRS_CONSTS_RTMP_PULSE);
|
||||
|
||||
SrsPithyPrint* pprint = SrsPithyPrint::create_forwarder();
|
||||
SrsAutoFree(SrsPithyPrint, pprint);
|
||||
|
|
|
@ -116,7 +116,7 @@ srs_error_t SrsRecvThread::cycle()
|
|||
}
|
||||
|
||||
// reset the timeout to pulse mode.
|
||||
rtmp->set_recv_timeout(timeout * 1000);
|
||||
rtmp->set_recv_timeout(timeout * SRS_UTIME_MILLISECONDS);
|
||||
|
||||
pumper->on_stop();
|
||||
|
||||
|
|
|
@ -166,7 +166,7 @@ srs_error_t SrsRtmpConn::do_cycle()
|
|||
}
|
||||
#endif
|
||||
|
||||
rtmp->set_recv_timeout(srsu2ms(SRS_CONSTS_RTMP_TIMEOUT));
|
||||
rtmp->set_recv_timeout(SRS_CONSTS_RTMP_TIMEOUT);
|
||||
rtmp->set_send_timeout(SRS_CONSTS_RTMP_TIMEOUT);
|
||||
|
||||
if ((err = rtmp->handshake()) != srs_success) {
|
||||
|
@ -411,7 +411,7 @@ srs_error_t SrsRtmpConn::service_cycle()
|
|||
if (srs_error_code(err) == ERROR_CONTROL_REPUBLISH) {
|
||||
// set timeout to a larger value, wait for encoder to republish.
|
||||
rtmp->set_send_timeout(SRS_REPUBLISH_RECV_TMMS);
|
||||
rtmp->set_recv_timeout(srsu2ms(SRS_REPUBLISH_SEND_TMMS));
|
||||
rtmp->set_recv_timeout(SRS_REPUBLISH_SEND_TMMS);
|
||||
|
||||
srs_trace("rtmp: retry for republish");
|
||||
srs_freep(err);
|
||||
|
@ -425,7 +425,7 @@ srs_error_t SrsRtmpConn::service_cycle()
|
|||
// @see: https://github.com/ossrs/srs/issues/39
|
||||
// set timeout to a larger value, for user paused.
|
||||
rtmp->set_recv_timeout(SRS_PAUSED_RECV_TMMS);
|
||||
rtmp->set_send_timeout(srsu2ms(SRS_PAUSED_SEND_TMMS));
|
||||
rtmp->set_send_timeout(SRS_PAUSED_SEND_TMMS);
|
||||
|
||||
srs_trace("rtmp: retry for close");
|
||||
srs_freep(err);
|
||||
|
@ -498,7 +498,7 @@ srs_error_t SrsRtmpConn::stream_service_cycle()
|
|||
}
|
||||
|
||||
// client is identified, set the timeout to service timeout.
|
||||
rtmp->set_recv_timeout(srsu2ms(SRS_CONSTS_RTMP_TIMEOUT));
|
||||
rtmp->set_recv_timeout(SRS_CONSTS_RTMP_TIMEOUT);
|
||||
rtmp->set_send_timeout(SRS_CONSTS_RTMP_TIMEOUT);
|
||||
|
||||
// find a source to serve.
|
||||
|
@ -1183,7 +1183,7 @@ srs_error_t SrsRtmpConn::do_token_traverse_auth(SrsRtmpClient* client)
|
|||
SrsRequest* req = info->req;
|
||||
srs_assert(client);
|
||||
|
||||
client->set_recv_timeout(srsu2ms(SRS_CONSTS_RTMP_TIMEOUT));
|
||||
client->set_recv_timeout(SRS_CONSTS_RTMP_TIMEOUT);
|
||||
client->set_send_timeout(SRS_CONSTS_RTMP_TIMEOUT);
|
||||
|
||||
if ((err = client->handshake()) != srs_success) {
|
||||
|
|
|
@ -377,10 +377,10 @@ srs_error_t SimpleSocketStream::read(void* buf, size_t size, ssize_t* nread)
|
|||
}
|
||||
|
||||
// ISrsProtocolReader
|
||||
void SimpleSocketStream::set_recv_timeout(int64_t tm)
|
||||
void SimpleSocketStream::set_recv_timeout(SrsQueueRecvThread tm)
|
||||
{
|
||||
srs_assert(io);
|
||||
srs_hijack_io_set_recv_timeout(io, tm);
|
||||
srs_hijack_io_set_recv_timeout(io, srsu2ms(tm));
|
||||
}
|
||||
|
||||
int64_t SimpleSocketStream::get_recv_timeout()
|
||||
|
|
|
@ -54,7 +54,7 @@ public:
|
|||
virtual srs_error_t read(void* buf, size_t size, ssize_t* nread);
|
||||
// ISrsProtocolReader
|
||||
public:
|
||||
virtual void set_recv_timeout(int64_t tm);
|
||||
virtual void set_recv_timeout(srs_utime_t tm);
|
||||
virtual int64_t get_recv_timeout();
|
||||
virtual int64_t get_recv_bytes();
|
||||
// ISrsProtocolWriter
|
||||
|
|
|
@ -572,7 +572,7 @@ int srs_rtmp_set_timeout(srs_rtmp_t rtmp, int recv_timeout_ms, int send_timeout_
|
|||
context->stimeout = send_timeout_ms;
|
||||
context->rtimeout = recv_timeout_ms;
|
||||
|
||||
context->skt->set_recv_timeout(context->rtimeout);
|
||||
context->skt->set_recv_timeout(context->rtimeout * SRS_UTIME_MILLISECONDS);
|
||||
context->skt->set_send_timeout(context->stimeout * SRS_UTIME_MILLISECONDS);
|
||||
|
||||
return ret;
|
||||
|
@ -641,7 +641,7 @@ int srs_rtmp_connect_server(srs_rtmp_t rtmp)
|
|||
}
|
||||
if (context->rtimeout == SRS_UTIME_NO_TIMEOUT) {
|
||||
context->rtimeout = SRS_SOCKET_DEFAULT_TMMS;
|
||||
context->skt->set_recv_timeout(context->rtimeout);
|
||||
context->skt->set_recv_timeout(context->rtimeout * SRS_UTIME_MILLISECONDS);
|
||||
}
|
||||
|
||||
if ((ret = srs_librtmp_context_connect(context)) != ERROR_SUCCESS) {
|
||||
|
|
|
@ -84,9 +84,9 @@ public:
|
|||
virtual ~ISrsProtocolReader();
|
||||
// for protocol
|
||||
public:
|
||||
// Set the timeout tm in ms for recv bytes from peer.
|
||||
// Set the timeout tm in srs_utime_t for recv bytes from peer.
|
||||
// @remark Use SRS_UTIME_NO_TIMEOUT to never timeout.
|
||||
virtual void set_recv_timeout(int64_t tm) = 0;
|
||||
virtual void set_recv_timeout(srs_utime_t tm) = 0;
|
||||
// Get the timeout in ms for recv bytes from peer.
|
||||
virtual int64_t get_recv_timeout() = 0;
|
||||
// For handshake.
|
||||
|
|
|
@ -304,7 +304,7 @@ void SrsProtocol::set_recv_buffer(int buffer_size)
|
|||
}
|
||||
#endif
|
||||
|
||||
void SrsProtocol::set_recv_timeout(int64_t tm)
|
||||
void SrsProtocol::set_recv_timeout(srs_utime_t tm)
|
||||
{
|
||||
return skt->set_recv_timeout(tm);
|
||||
}
|
||||
|
@ -1815,7 +1815,7 @@ SrsRtmpClient::~SrsRtmpClient()
|
|||
srs_freep(hs_bytes);
|
||||
}
|
||||
|
||||
void SrsRtmpClient::set_recv_timeout(int64_t tm)
|
||||
void SrsRtmpClient::set_recv_timeout(srs_utime_t tm)
|
||||
{
|
||||
protocol->set_recv_timeout(tm);
|
||||
}
|
||||
|
@ -2210,7 +2210,7 @@ void SrsRtmpServer::set_recv_buffer(int buffer_size)
|
|||
}
|
||||
#endif
|
||||
|
||||
void SrsRtmpServer::set_recv_timeout(int64_t tm)
|
||||
void SrsRtmpServer::set_recv_timeout(srs_utime_t tm)
|
||||
{
|
||||
protocol->set_recv_timeout(tm);
|
||||
}
|
||||
|
@ -2408,7 +2408,7 @@ srs_error_t SrsRtmpServer::response_connect_app(SrsRequest *req, const char* ser
|
|||
return err;
|
||||
}
|
||||
|
||||
#define SRS_RTMP_REDIRECT_TMMS 3000
|
||||
#define SRS_RTMP_REDIRECT_TMMS (3 * SRS_UTIME_SECONDS)
|
||||
srs_error_t SrsRtmpServer::redirect(SrsRequest* r, string host, int port, bool& accepted)
|
||||
{
|
||||
srs_error_t err = srs_success;
|
||||
|
|
|
@ -304,11 +304,10 @@ public:
|
|||
#endif
|
||||
public:
|
||||
/**
|
||||
* set/get the recv timeout in ms.
|
||||
* set/get the recv timeout in srs_utime_t.
|
||||
* 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 void set_recv_timeout(srs_utime_t tm);
|
||||
virtual int64_t get_recv_timeout();
|
||||
/**
|
||||
* set/get the send timeout in srs_utime_t.
|
||||
|
@ -688,7 +687,7 @@ public:
|
|||
virtual ~SrsRtmpClient();
|
||||
// protocol methods proxy
|
||||
public:
|
||||
virtual void set_recv_timeout(int64_t tm);
|
||||
virtual void set_recv_timeout(srs_utime_t tm);
|
||||
virtual void set_send_timeout(srs_utime_t tm);
|
||||
virtual int64_t get_recv_bytes();
|
||||
virtual int64_t get_send_bytes();
|
||||
|
@ -805,10 +804,10 @@ public:
|
|||
virtual void set_recv_buffer(int buffer_size);
|
||||
#endif
|
||||
/**
|
||||
* set/get the recv timeout in ms.
|
||||
* set/get the recv timeout in srs_utime_t.
|
||||
* if timeout, recv/send message return ERROR_SOCKET_TIMEOUT.
|
||||
*/
|
||||
virtual void set_recv_timeout(int64_t tm);
|
||||
virtual void set_recv_timeout(srs_utime_t tm);
|
||||
virtual int64_t get_recv_timeout();
|
||||
/**
|
||||
* set/get the send timeout in srs_utime_t.
|
||||
|
|
|
@ -186,7 +186,7 @@ srs_error_t SrsHttpClient::get(string path, string req, ISrsHttpMessage** ppmsg)
|
|||
return err;
|
||||
}
|
||||
|
||||
void SrsHttpClient::set_recv_timeout(int64_t tm)
|
||||
void SrsHttpClient::set_recv_timeout(srs_utime_t tm)
|
||||
{
|
||||
transport->set_recv_timeout(tm);
|
||||
}
|
||||
|
@ -227,7 +227,7 @@ srs_error_t SrsHttpClient::connect()
|
|||
}
|
||||
|
||||
// Set the recv/send timeout in ms.
|
||||
transport->set_recv_timeout(timeout);
|
||||
transport->set_recv_timeout(timeout * SRS_UTIME_MILLISECONDS);
|
||||
transport->set_send_timeout(timeout * SRS_UTIME_MILLISECONDS);
|
||||
|
||||
kbps->set_io(transport, transport);
|
||||
|
|
|
@ -101,7 +101,7 @@ public:
|
|||
*/
|
||||
virtual srs_error_t get(std::string path, std::string req, ISrsHttpMessage** ppmsg);
|
||||
private:
|
||||
virtual void set_recv_timeout(int64_t tm);
|
||||
virtual void set_recv_timeout(srs_utime_t tm);
|
||||
public:
|
||||
virtual void kbps_sample(const char* label, int64_t age);
|
||||
private:
|
||||
|
|
|
@ -74,7 +74,7 @@ srs_error_t SrsBasicRtmpClient::connect()
|
|||
return srs_error_wrap(err, "connect");
|
||||
}
|
||||
|
||||
client->set_recv_timeout(stream_timeout);
|
||||
client->set_recv_timeout(stream_timeout * SRS_UTIME_MILLISECONDS);
|
||||
client->set_send_timeout(stream_timeout * SRS_UTIME_MILLISECONDS);
|
||||
|
||||
// connect to vhost/app
|
||||
|
@ -234,7 +234,7 @@ srs_error_t SrsBasicRtmpClient::send_and_free_message(SrsSharedPtrMessage* msg)
|
|||
return client->send_and_free_message(msg, stream_id);
|
||||
}
|
||||
|
||||
void SrsBasicRtmpClient::set_recv_timeout(int64_t timeout)
|
||||
void SrsBasicRtmpClient::set_recv_timeout(srs_utime_t timeout)
|
||||
{
|
||||
transport->set_recv_timeout(timeout);
|
||||
}
|
||||
|
|
|
@ -87,7 +87,7 @@ public:
|
|||
virtual srs_error_t send_and_free_messages(SrsSharedPtrMessage** msgs, int nb_msgs);
|
||||
virtual srs_error_t send_and_free_message(SrsSharedPtrMessage* msg);
|
||||
public:
|
||||
virtual void set_recv_timeout(int64_t timeout);
|
||||
virtual void set_recv_timeout(srs_utime_t timeout);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -251,7 +251,7 @@ bool SrsStSocket::is_never_timeout(int64_t tm)
|
|||
return tm == SRS_UTIME_NO_TIMEOUT;
|
||||
}
|
||||
|
||||
void SrsStSocket::set_recv_timeout(int64_t tm)
|
||||
void SrsStSocket::set_recv_timeout(srs_utime_t tm)
|
||||
{
|
||||
rtm = tm;
|
||||
}
|
||||
|
@ -465,7 +465,7 @@ bool SrsTcpClient::is_never_timeout(int64_t tm)
|
|||
return io->is_never_timeout(tm);
|
||||
}
|
||||
|
||||
void SrsTcpClient::set_recv_timeout(int64_t tm)
|
||||
void SrsTcpClient::set_recv_timeout(srs_utime_t tm)
|
||||
{
|
||||
io->set_recv_timeout(tm);
|
||||
}
|
||||
|
|
|
@ -126,7 +126,7 @@ public:
|
|||
virtual srs_error_t initialize(srs_netfd_t fd);
|
||||
public:
|
||||
virtual bool is_never_timeout(int64_t tm);
|
||||
virtual void set_recv_timeout(int64_t tm);
|
||||
virtual void set_recv_timeout(srs_utime_t tm);
|
||||
virtual int64_t get_recv_timeout();
|
||||
virtual void set_send_timeout(srs_utime_t tm);
|
||||
virtual srs_utime_t get_send_timeout();
|
||||
|
@ -189,7 +189,7 @@ private:
|
|||
// interface ISrsProtocolReadWriter
|
||||
public:
|
||||
virtual bool is_never_timeout(int64_t tm);
|
||||
virtual void set_recv_timeout(int64_t tm);
|
||||
virtual void set_recv_timeout(srs_utime_t tm);
|
||||
virtual int64_t get_recv_timeout();
|
||||
virtual void set_send_timeout(srs_utime_t tm);
|
||||
virtual srs_utime_t get_send_timeout();
|
||||
|
|
|
@ -58,7 +58,7 @@ srs_error_t MockEmptyIO::write(void* /*buf*/, size_t /*size*/, ssize_t* /*nwrite
|
|||
return srs_success;
|
||||
}
|
||||
|
||||
void MockEmptyIO::set_recv_timeout(int64_t /*tm*/)
|
||||
void MockEmptyIO::set_recv_timeout(srs_utime_t /*tm*/)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -142,7 +142,7 @@ srs_error_t MockBufferIO::write(void* buf, size_t size, ssize_t* nwrite)
|
|||
return srs_success;
|
||||
}
|
||||
|
||||
void MockBufferIO::set_recv_timeout(int64_t tm)
|
||||
void MockBufferIO::set_recv_timeout(srs_utime_t tm)
|
||||
{
|
||||
rtm = tm;
|
||||
}
|
||||
|
@ -693,8 +693,8 @@ VOID TEST(ProtocolStackTest, ProtocolTimeout)
|
|||
EXPECT_TRUE(SRS_UTIME_NO_TIMEOUT == proto.get_recv_timeout());
|
||||
EXPECT_TRUE(SRS_UTIME_NO_TIMEOUT == proto.get_send_timeout());
|
||||
|
||||
proto.set_recv_timeout(10);
|
||||
EXPECT_TRUE(10 == proto.get_recv_timeout());
|
||||
proto.set_recv_timeout(10 * SRS_UTIME_MILLISECONDS);
|
||||
EXPECT_TRUE(10 * SRS_UTIME_MILLISECONDS == proto.get_recv_timeout());
|
||||
|
||||
proto.set_send_timeout(10 * SRS_UTIME_MILLISECONDS);
|
||||
EXPECT_TRUE(10 * SRS_UTIME_MILLISECONDS == proto.get_send_timeout());
|
||||
|
|
|
@ -55,7 +55,7 @@ public:
|
|||
virtual srs_error_t write(void* buf, size_t size, ssize_t* nwrite);
|
||||
// for protocol
|
||||
public:
|
||||
virtual void set_recv_timeout(int64_t tm);
|
||||
virtual void set_recv_timeout(srs_utime_t tm);
|
||||
virtual int64_t get_recv_timeout();
|
||||
virtual int64_t get_recv_bytes();
|
||||
// for protocol
|
||||
|
@ -96,7 +96,7 @@ public:
|
|||
virtual srs_error_t write(void* buf, size_t size, ssize_t* nwrite);
|
||||
// for protocol
|
||||
public:
|
||||
virtual void set_recv_timeout(int64_t tm);
|
||||
virtual void set_recv_timeout(srs_utime_t tm);
|
||||
virtual int64_t get_recv_timeout();
|
||||
virtual int64_t get_recv_bytes();
|
||||
// for protocol
|
||||
|
|
Loading…
Reference in a new issue