mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
Refine set_send_timeout in time unit
This commit is contained in:
parent
a1398892d0
commit
f4bee37e76
14 changed files with 34 additions and 34 deletions
|
@ -180,7 +180,7 @@ srs_error_t SrsBandwidth::do_bandwidth_check(SrsKbpsLimit* limit)
|
|||
SrsBandwidthSample publish_sample;
|
||||
|
||||
// timeout for a packet.
|
||||
_rtmp->set_send_timeout(play_sample.duration_ms * 2);
|
||||
_rtmp->set_send_timeout(play_sample.duration_ms * 2 * SRS_UTIME_MILLISECONDS);
|
||||
_rtmp->set_recv_timeout(publish_sample.duration_ms * 2);
|
||||
|
||||
// start test.
|
||||
|
|
|
@ -167,7 +167,7 @@ srs_error_t SrsRtmpConn::do_cycle()
|
|||
#endif
|
||||
|
||||
rtmp->set_recv_timeout(srsu2ms(SRS_CONSTS_RTMP_TIMEOUT));
|
||||
rtmp->set_send_timeout(srsu2ms(SRS_CONSTS_RTMP_TIMEOUT));
|
||||
rtmp->set_send_timeout(SRS_CONSTS_RTMP_TIMEOUT);
|
||||
|
||||
if ((err = rtmp->handshake()) != srs_success) {
|
||||
return srs_error_wrap(err, "rtmp handshake");
|
||||
|
@ -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(SRS_REPUBLISH_SEND_TMMS);
|
||||
rtmp->set_recv_timeout(srsu2ms(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(SRS_PAUSED_SEND_TMMS);
|
||||
rtmp->set_send_timeout(srsu2ms(SRS_PAUSED_SEND_TMMS));
|
||||
|
||||
srs_trace("rtmp: retry for close");
|
||||
srs_freep(err);
|
||||
|
@ -499,7 +499,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_send_timeout(srsu2ms(SRS_CONSTS_RTMP_TIMEOUT));
|
||||
rtmp->set_send_timeout(SRS_CONSTS_RTMP_TIMEOUT);
|
||||
|
||||
// find a source to serve.
|
||||
SrsSource* source = NULL;
|
||||
|
@ -1184,7 +1184,7 @@ srs_error_t SrsRtmpConn::do_token_traverse_auth(SrsRtmpClient* client)
|
|||
srs_assert(client);
|
||||
|
||||
client->set_recv_timeout(srsu2ms(SRS_CONSTS_RTMP_TIMEOUT));
|
||||
client->set_send_timeout(srsu2ms(SRS_CONSTS_RTMP_TIMEOUT));
|
||||
client->set_send_timeout(SRS_CONSTS_RTMP_TIMEOUT);
|
||||
|
||||
if ((err = client->handshake()) != srs_success) {
|
||||
return srs_error_wrap(err, "rtmp: handshake");
|
||||
|
|
|
@ -396,10 +396,10 @@ int64_t SimpleSocketStream::get_recv_bytes()
|
|||
}
|
||||
|
||||
// ISrsProtocolWriter
|
||||
void SimpleSocketStream::set_send_timeout(int64_t tm)
|
||||
void SimpleSocketStream::set_send_timeout(srs_utime_t tm)
|
||||
{
|
||||
srs_assert(io);
|
||||
srs_hijack_io_set_send_timeout(io, tm);
|
||||
srs_hijack_io_set_send_timeout(io, srsu2ms(tm));
|
||||
}
|
||||
|
||||
int64_t SimpleSocketStream::get_send_timeout()
|
||||
|
|
|
@ -59,7 +59,7 @@ public:
|
|||
virtual int64_t get_recv_bytes();
|
||||
// ISrsProtocolWriter
|
||||
public:
|
||||
virtual void set_send_timeout(int64_t tm);
|
||||
virtual void set_send_timeout(srs_utime_t tm);
|
||||
virtual int64_t get_send_timeout();
|
||||
virtual int64_t get_send_bytes();
|
||||
virtual srs_error_t writev(const iovec *iov, int iov_size, ssize_t* nwrite);
|
||||
|
|
|
@ -573,7 +573,7 @@ int srs_rtmp_set_timeout(srs_rtmp_t rtmp, int recv_timeout_ms, int send_timeout_
|
|||
context->rtimeout = recv_timeout_ms;
|
||||
|
||||
context->skt->set_recv_timeout(context->rtimeout);
|
||||
context->skt->set_send_timeout(context->stimeout);
|
||||
context->skt->set_send_timeout(context->stimeout * SRS_UTIME_MILLISECONDS);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
@ -637,7 +637,7 @@ int srs_rtmp_connect_server(srs_rtmp_t rtmp)
|
|||
// set timeout if user not set.
|
||||
if (context->stimeout == SRS_UTIME_NO_TIMEOUT) {
|
||||
context->stimeout = SRS_SOCKET_DEFAULT_TMMS;
|
||||
context->skt->set_send_timeout(context->stimeout);
|
||||
context->skt->set_send_timeout(context->stimeout * SRS_UTIME_MILLISECONDS);
|
||||
}
|
||||
if (context->rtimeout == SRS_UTIME_NO_TIMEOUT) {
|
||||
context->rtimeout = SRS_SOCKET_DEFAULT_TMMS;
|
||||
|
|
|
@ -117,10 +117,10 @@ public:
|
|||
// for protocol
|
||||
public:
|
||||
/**
|
||||
* Set the timeout tm in ms for send bytes to peer.
|
||||
* Set the timeout tm in srs_utime_t for send bytes to peer.
|
||||
* @remark Use SRS_UTIME_NO_TIMEOUT to never timeout.
|
||||
*/
|
||||
virtual void set_send_timeout(int64_t tm) = 0;
|
||||
virtual void set_send_timeout(srs_utime_t tm) = 0;
|
||||
/**
|
||||
* Get the timeout in ms for send bytes to peer.
|
||||
*/
|
||||
|
|
|
@ -314,7 +314,7 @@ int64_t SrsProtocol::get_recv_timeout()
|
|||
return skt->get_recv_timeout();
|
||||
}
|
||||
|
||||
void SrsProtocol::set_send_timeout(int64_t tm)
|
||||
void SrsProtocol::set_send_timeout(srs_utime_t tm)
|
||||
{
|
||||
return skt->set_send_timeout(tm);
|
||||
}
|
||||
|
@ -1820,7 +1820,7 @@ void SrsRtmpClient::set_recv_timeout(int64_t tm)
|
|||
protocol->set_recv_timeout(tm);
|
||||
}
|
||||
|
||||
void SrsRtmpClient::set_send_timeout(int64_t tm)
|
||||
void SrsRtmpClient::set_send_timeout(srs_utime_t tm)
|
||||
{
|
||||
protocol->set_send_timeout(tm);
|
||||
}
|
||||
|
@ -2220,7 +2220,7 @@ int64_t SrsRtmpServer::get_recv_timeout()
|
|||
return protocol->get_recv_timeout();
|
||||
}
|
||||
|
||||
void SrsRtmpServer::set_send_timeout(int64_t tm)
|
||||
void SrsRtmpServer::set_send_timeout(srs_utime_t tm)
|
||||
{
|
||||
protocol->set_send_timeout(tm);
|
||||
}
|
||||
|
|
|
@ -311,10 +311,10 @@ public:
|
|||
virtual void set_recv_timeout(int64_t tm);
|
||||
virtual int64_t get_recv_timeout();
|
||||
/**
|
||||
* set/get the send timeout in ms.
|
||||
* set/get the send timeout in srs_utime_t.
|
||||
* if timeout, recv/send message return ERROR_SOCKET_TIMEOUT.
|
||||
*/
|
||||
virtual void set_send_timeout(int64_t tm);
|
||||
virtual void set_send_timeout(srs_utime_t tm);
|
||||
virtual int64_t get_send_timeout();
|
||||
/**
|
||||
* get recv/send bytes.
|
||||
|
@ -689,7 +689,7 @@ public:
|
|||
// protocol methods proxy
|
||||
public:
|
||||
virtual void set_recv_timeout(int64_t tm);
|
||||
virtual void set_send_timeout(int64_t tm);
|
||||
virtual void set_send_timeout(srs_utime_t tm);
|
||||
virtual int64_t get_recv_bytes();
|
||||
virtual int64_t get_send_bytes();
|
||||
virtual srs_error_t recv_message(SrsCommonMessage** pmsg);
|
||||
|
@ -811,10 +811,10 @@ public:
|
|||
virtual void set_recv_timeout(int64_t tm);
|
||||
virtual int64_t get_recv_timeout();
|
||||
/**
|
||||
* set/get the send timeout in ms.
|
||||
* set/get the send timeout in srs_utime_t.
|
||||
* if timeout, recv/send message return ERROR_SOCKET_TIMEOUT.
|
||||
*/
|
||||
virtual void set_send_timeout(int64_t tm);
|
||||
virtual void set_send_timeout(srs_utime_t tm);
|
||||
virtual int64_t get_send_timeout();
|
||||
/**
|
||||
* get recv/send bytes.
|
||||
|
|
|
@ -228,7 +228,7 @@ srs_error_t SrsHttpClient::connect()
|
|||
|
||||
// Set the recv/send timeout in ms.
|
||||
transport->set_recv_timeout(timeout);
|
||||
transport->set_send_timeout(timeout);
|
||||
transport->set_send_timeout(timeout * SRS_UTIME_MILLISECONDS);
|
||||
|
||||
kbps->set_io(transport, transport);
|
||||
|
||||
|
|
|
@ -75,7 +75,7 @@ srs_error_t SrsBasicRtmpClient::connect()
|
|||
}
|
||||
|
||||
client->set_recv_timeout(stream_timeout);
|
||||
client->set_send_timeout(stream_timeout);
|
||||
client->set_send_timeout(stream_timeout * SRS_UTIME_MILLISECONDS);
|
||||
|
||||
// connect to vhost/app
|
||||
if ((err = client->handshake()) != srs_success) {
|
||||
|
|
|
@ -261,7 +261,7 @@ int64_t SrsStSocket::get_recv_timeout()
|
|||
return rtm;
|
||||
}
|
||||
|
||||
void SrsStSocket::set_send_timeout(int64_t tm)
|
||||
void SrsStSocket::set_send_timeout(srs_utime_t tm)
|
||||
{
|
||||
stm = tm;
|
||||
}
|
||||
|
@ -475,7 +475,7 @@ int64_t SrsTcpClient::get_recv_timeout()
|
|||
return io->get_recv_timeout();
|
||||
}
|
||||
|
||||
void SrsTcpClient::set_send_timeout(int64_t tm)
|
||||
void SrsTcpClient::set_send_timeout(srs_utime_t tm)
|
||||
{
|
||||
io->set_send_timeout(tm);
|
||||
}
|
||||
|
|
|
@ -128,7 +128,7 @@ public:
|
|||
virtual bool is_never_timeout(int64_t tm);
|
||||
virtual void set_recv_timeout(int64_t tm);
|
||||
virtual int64_t get_recv_timeout();
|
||||
virtual void set_send_timeout(int64_t tm);
|
||||
virtual void set_send_timeout(srs_utime_t tm);
|
||||
virtual int64_t get_send_timeout();
|
||||
virtual int64_t get_recv_bytes();
|
||||
virtual int64_t get_send_bytes();
|
||||
|
@ -191,7 +191,7 @@ public:
|
|||
virtual bool is_never_timeout(int64_t tm);
|
||||
virtual void set_recv_timeout(int64_t tm);
|
||||
virtual int64_t get_recv_timeout();
|
||||
virtual void set_send_timeout(int64_t tm);
|
||||
virtual void set_send_timeout(srs_utime_t tm);
|
||||
virtual int64_t get_send_timeout();
|
||||
virtual int64_t get_recv_bytes();
|
||||
virtual int64_t get_send_bytes();
|
||||
|
|
|
@ -72,7 +72,7 @@ int64_t MockEmptyIO::get_recv_bytes()
|
|||
return -1;
|
||||
}
|
||||
|
||||
void MockEmptyIO::set_send_timeout(int64_t /*tm*/)
|
||||
void MockEmptyIO::set_send_timeout(srs_utime_t /*tm*/)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -157,7 +157,7 @@ int64_t MockBufferIO::get_recv_bytes()
|
|||
return rbytes;
|
||||
}
|
||||
|
||||
void MockBufferIO::set_send_timeout(int64_t tm)
|
||||
void MockBufferIO::set_send_timeout(srs_utime_t tm)
|
||||
{
|
||||
stm = tm;
|
||||
}
|
||||
|
@ -696,8 +696,8 @@ VOID TEST(ProtocolStackTest, ProtocolTimeout)
|
|||
proto.set_recv_timeout(10);
|
||||
EXPECT_TRUE(10 == proto.get_recv_timeout());
|
||||
|
||||
proto.set_send_timeout(10);
|
||||
EXPECT_TRUE(10 == proto.get_send_timeout());
|
||||
proto.set_send_timeout(10 * SRS_UTIME_MILLISECONDS);
|
||||
EXPECT_TRUE(10 * SRS_UTIME_MILLISECONDS == proto.get_send_timeout());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -60,7 +60,7 @@ public:
|
|||
virtual int64_t get_recv_bytes();
|
||||
// for protocol
|
||||
public:
|
||||
virtual void set_send_timeout(int64_t tm);
|
||||
virtual void set_send_timeout(srs_utime_t tm);
|
||||
virtual int64_t get_send_timeout();
|
||||
virtual int64_t get_send_bytes();
|
||||
virtual srs_error_t writev(const iovec *iov, int iov_size, ssize_t* nwrite);
|
||||
|
@ -74,7 +74,7 @@ class MockBufferIO : public ISrsProtocolReadWriter
|
|||
public:
|
||||
// The send/recv timeout in ms.
|
||||
int64_t rtm;
|
||||
int64_t stm;
|
||||
srs_utime_t stm;
|
||||
// The send/recv data in bytes.
|
||||
int64_t rbytes;
|
||||
int64_t sbytes;
|
||||
|
@ -101,7 +101,7 @@ public:
|
|||
virtual int64_t get_recv_bytes();
|
||||
// for protocol
|
||||
public:
|
||||
virtual void set_send_timeout(int64_t tm);
|
||||
virtual void set_send_timeout(srs_utime_t tm);
|
||||
virtual int64_t get_send_timeout();
|
||||
virtual int64_t get_send_bytes();
|
||||
virtual srs_error_t writev(const iovec *iov, int iov_size, ssize_t* nwrite);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue