mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
Apply time unit
This commit is contained in:
parent
7037f6a197
commit
6239dfa489
15 changed files with 46 additions and 46 deletions
|
@ -37,17 +37,17 @@ using namespace std;
|
|||
#include <srs_protocol_kbps.hpp>
|
||||
#include <srs_app_st.hpp>
|
||||
|
||||
#define _SRS_BANDWIDTH_LIMIT_INTERVAL_MS 100
|
||||
#define _SRS_BANDWIDTH_LIMIT_INTERVAL 100 * SRS_UTIME_MILLISECONDS
|
||||
|
||||
// default sample duration, in ms
|
||||
#define _SRS_BANDWIDTH_SAMPLE_DURATION_MS 3000
|
||||
#define _SRS_BANDWIDTH_SAMPLE_DURATION 3000 * SRS_UTIME_MILLISECONDS
|
||||
|
||||
// wait for a while for flash to got all packets.
|
||||
#define _SRS_BANDWIDTH_FINAL_WAIT_MS 600
|
||||
#define _SRS_BANDWIDTH_FINAL_WAIT 600 * SRS_UTIME_MILLISECONDS
|
||||
|
||||
SrsBandwidthSample::SrsBandwidthSample()
|
||||
{
|
||||
duration_ms = _SRS_BANDWIDTH_SAMPLE_DURATION_MS;
|
||||
duration_ms = _SRS_BANDWIDTH_SAMPLE_DURATION;
|
||||
kbps = interval_ms = actual_duration_ms = bytes = 0;
|
||||
}
|
||||
|
||||
|
@ -223,7 +223,7 @@ srs_error_t SrsBandwidth::do_bandwidth_check(SrsKbpsLimit* limit)
|
|||
return srs_error_wrap(err, "final");
|
||||
}
|
||||
|
||||
srs_usleep(_SRS_BANDWIDTH_FINAL_WAIT_MS * 1000);
|
||||
srs_usleep(_SRS_BANDWIDTH_FINAL_WAIT);
|
||||
|
||||
return err;
|
||||
}
|
||||
|
@ -457,7 +457,7 @@ void SrsKbpsLimit::recv_limit()
|
|||
while (_kbps->get_recv_kbps() > _limit_kbps) {
|
||||
_kbps->sample();
|
||||
|
||||
srs_usleep(_SRS_BANDWIDTH_LIMIT_INTERVAL_MS * 1000);
|
||||
srs_usleep(_SRS_BANDWIDTH_LIMIT_INTERVAL);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -468,7 +468,7 @@ void SrsKbpsLimit::send_limit()
|
|||
while (_kbps->get_send_kbps() > _limit_kbps) {
|
||||
_kbps->sample();
|
||||
|
||||
srs_usleep(_SRS_BANDWIDTH_LIMIT_INTERVAL_MS * 1000);
|
||||
srs_usleep(_SRS_BANDWIDTH_LIMIT_INTERVAL);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -48,10 +48,10 @@ using namespace std;
|
|||
#include <srs_app_rtmp_conn.hpp>
|
||||
|
||||
// when edge timeout, retry next.
|
||||
#define SRS_EDGE_INGESTER_TMMS (5*1000)
|
||||
#define SRS_EDGE_INGESTER_TMMS (5 * SRS_UTIME_MILLISECONDS)
|
||||
|
||||
// when edge error, wait for quit
|
||||
#define SRS_EDGE_FORWARDER_TMMS (150)
|
||||
#define SRS_EDGE_FORWARDER_TMMS (150 * SRS_UTIME_MILLISECONDS)
|
||||
|
||||
SrsEdgeUpstream::SrsEdgeUpstream()
|
||||
{
|
||||
|
@ -114,7 +114,7 @@ srs_error_t SrsEdgeRtmpUpstream::connect(SrsRequest* r, SrsLbRoundRobin* lb)
|
|||
}
|
||||
|
||||
srs_freep(sdk);
|
||||
int64_t cto = SRS_EDGE_INGESTER_TMMS;
|
||||
int64_t cto = SRS_EDGE_INGESTER_TMMS / SRS_UTIME_MILLISECONDS;
|
||||
int64_t sto = SRS_CONSTS_RTMP_PULSE_TMMS;
|
||||
sdk = new SrsSimpleRtmpClient(url, cto, sto);
|
||||
|
||||
|
@ -218,7 +218,7 @@ string SrsEdgeIngester::get_curr_origin()
|
|||
}
|
||||
|
||||
// when error, edge ingester sleep for a while and retry.
|
||||
#define SRS_EDGE_INGESTER_CIMS (3*1000)
|
||||
#define SRS_EDGE_INGESTER_CIMS (3 * SRS_UTIME_MILLISECONDS)
|
||||
|
||||
srs_error_t SrsEdgeIngester::cycle()
|
||||
{
|
||||
|
@ -234,7 +234,7 @@ srs_error_t SrsEdgeIngester::cycle()
|
|||
return srs_error_wrap(err, "edge ingester");
|
||||
}
|
||||
|
||||
srs_usleep(SRS_EDGE_INGESTER_CIMS * 1000);
|
||||
srs_usleep(SRS_EDGE_INGESTER_CIMS);
|
||||
}
|
||||
|
||||
return err;
|
||||
|
@ -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(SRS_EDGE_INGESTER_TMMS);
|
||||
upstream->set_recv_timeout(SRS_EDGE_INGESTER_TMMS / SRS_UTIME_MILLISECONDS);
|
||||
|
||||
while (true) {
|
||||
srs_error_t err = srs_success;
|
||||
|
@ -474,7 +474,7 @@ srs_error_t SrsEdgeForwarder::start()
|
|||
|
||||
// open socket.
|
||||
srs_freep(sdk);
|
||||
int64_t cto = SRS_EDGE_FORWARDER_TMMS;
|
||||
int64_t cto = SRS_EDGE_FORWARDER_TMMS / SRS_UTIME_MILLISECONDS;
|
||||
int64_t sto = SRS_CONSTS_RTMP_TMMS;
|
||||
sdk = new SrsSimpleRtmpClient(url, cto, sto);
|
||||
|
||||
|
@ -505,7 +505,7 @@ void SrsEdgeForwarder::stop()
|
|||
}
|
||||
|
||||
// when error, edge ingester sleep for a while and retry.
|
||||
#define SRS_EDGE_FORWARDER_CIMS (3*1000)
|
||||
#define SRS_EDGE_FORWARDER_CIMS (3 * SRS_UTIME_MILLISECONDS)
|
||||
|
||||
srs_error_t SrsEdgeForwarder::cycle()
|
||||
{
|
||||
|
@ -520,7 +520,7 @@ srs_error_t SrsEdgeForwarder::cycle()
|
|||
return srs_error_wrap(err, "thread pull");
|
||||
}
|
||||
|
||||
srs_usleep(SRS_EDGE_FORWARDER_CIMS * 1000);
|
||||
srs_usleep(SRS_EDGE_FORWARDER_CIMS);
|
||||
}
|
||||
|
||||
return err;
|
||||
|
@ -545,7 +545,7 @@ srs_error_t SrsEdgeForwarder::do_cycle()
|
|||
}
|
||||
|
||||
if (send_error_code != ERROR_SUCCESS) {
|
||||
srs_usleep(SRS_EDGE_FORWARDER_TMMS * 1000);
|
||||
srs_usleep(SRS_EDGE_FORWARDER_TMMS);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
|
@ -87,7 +87,7 @@ void SrsEncoder::on_unpublish()
|
|||
}
|
||||
|
||||
// when error, encoder sleep for a while and retry.
|
||||
#define SRS_RTMP_ENCODER_CIMS (3000)
|
||||
#define SRS_RTMP_ENCODER_CIMS (3000 * SRS_UTIME_MILLISECONDS)
|
||||
|
||||
srs_error_t SrsEncoder::cycle()
|
||||
{
|
||||
|
@ -104,7 +104,7 @@ srs_error_t SrsEncoder::cycle()
|
|||
break;
|
||||
}
|
||||
|
||||
srs_usleep(SRS_RTMP_ENCODER_CIMS * 1000);
|
||||
srs_usleep(SRS_RTMP_ENCODER_CIMS);
|
||||
}
|
||||
|
||||
// kill ffmpeg when finished and it alive
|
||||
|
|
|
@ -174,7 +174,7 @@ srs_error_t SrsForwarder::on_video(SrsSharedPtrMessage* shared_video)
|
|||
}
|
||||
|
||||
// when error, forwarder sleep for a while and retry.
|
||||
#define SRS_FORWARDER_CIMS (3000)
|
||||
#define SRS_FORWARDER_CIMS (3000 * SRS_UTIME_MILLISECONDS)
|
||||
|
||||
srs_error_t SrsForwarder::cycle()
|
||||
{
|
||||
|
@ -190,7 +190,7 @@ srs_error_t SrsForwarder::cycle()
|
|||
return srs_error_wrap(err, "forwarder");
|
||||
}
|
||||
|
||||
srs_usleep(SRS_FORWARDER_CIMS * 1000);
|
||||
srs_usleep(SRS_FORWARDER_CIMS);
|
||||
}
|
||||
|
||||
return err;
|
||||
|
@ -213,7 +213,7 @@ srs_error_t SrsForwarder::do_cycle()
|
|||
}
|
||||
|
||||
srs_freep(sdk);
|
||||
int64_t cto = SRS_FORWARDER_CIMS;
|
||||
int64_t cto = SRS_FORWARDER_CIMS / SRS_UTIME_MILLISECONDS;
|
||||
int64_t sto = SRS_CONSTS_RTMP_TMMS;
|
||||
sdk = new SrsSimpleRtmpClient(url, cto, sto);
|
||||
|
||||
|
|
|
@ -46,7 +46,7 @@ using namespace std;
|
|||
#define SRS_HTTP_BODY_BUFFER (32 * 1024)
|
||||
|
||||
// the timeout for hls notify, in ms.
|
||||
#define SRS_HLS_NOTIFY_TMMS (10 * 1000)
|
||||
#define SRS_HLS_NOTIFY_TMMS (10 * SRS_UTIME_MILLISECONDS)
|
||||
|
||||
SrsHttpHooks::SrsHttpHooks()
|
||||
{
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
|
||||
#include <srs_app_http_stream.hpp>
|
||||
|
||||
#define SRS_STREAM_CACHE_CYCLE_SECONDS 30
|
||||
#define SRS_STREAM_CACHE_CYCLE (30 * SRS_UTIME_SECONDS)
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
|
@ -119,7 +119,7 @@ srs_error_t SrsBufferCache::cycle()
|
|||
|
||||
// TODO: FIXME: support reload.
|
||||
if (fast_cache <= 0) {
|
||||
srs_usleep(SRS_STREAM_CACHE_CYCLE_SECONDS * 1000 * 1000);
|
||||
srs_usleep(SRS_STREAM_CACHE_CYCLE);
|
||||
return err;
|
||||
}
|
||||
|
||||
|
@ -157,7 +157,7 @@ srs_error_t SrsBufferCache::cycle()
|
|||
if (count <= 0) {
|
||||
srs_info("http: sleep %dms for no msg", SRS_CONSTS_RTMP_PULSE_TMMS);
|
||||
// directly use sleep, donot use consumer wait.
|
||||
srs_usleep(SRS_CONSTS_RTMP_PULSE_TMMS * 1000);
|
||||
srs_usleep(SRS_CONSTS_RTMP_PULSE_TMMS * SRS_UTIME_MILLISECONDS);
|
||||
|
||||
// ignore when nothing got.
|
||||
continue;
|
||||
|
@ -622,7 +622,7 @@ srs_error_t SrsLiveStream::do_serve_http(ISrsHttpResponseWriter* w, ISrsHttpMess
|
|||
|
||||
if (count <= 0) {
|
||||
// Directly use sleep, donot use consumer wait, because we couldn't awake consumer.
|
||||
srs_usleep(mw_sleep * 1000);
|
||||
srs_usleep(mw_sleep * SRS_UTIME_MILLISECONDS);
|
||||
// ignore when nothing got.
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -168,7 +168,7 @@ void SrsIngester::fast_stop()
|
|||
|
||||
// when error, ingester sleep for a while and retry.
|
||||
// ingest never sleep a long time, for we must start the stream ASAP.
|
||||
#define SRS_AUTO_INGESTER_CIMS (3000)
|
||||
#define SRS_AUTO_INGESTER_CIMS (3000 * SRS_UTIME_MILLISECONDS)
|
||||
|
||||
srs_error_t SrsIngester::cycle()
|
||||
{
|
||||
|
@ -184,7 +184,7 @@ srs_error_t SrsIngester::cycle()
|
|||
return srs_error_wrap(err, "ingester");
|
||||
}
|
||||
|
||||
srs_usleep(SRS_AUTO_INGESTER_CIMS * 1000);
|
||||
srs_usleep(SRS_AUTO_INGESTER_CIMS);
|
||||
}
|
||||
|
||||
return err;
|
||||
|
|
|
@ -485,7 +485,7 @@ srs_error_t SrsKafkaProducer::on_close(int key)
|
|||
return worker->execute(new SrsKafkaMessage(this, key, obj));
|
||||
}
|
||||
|
||||
#define SRS_KAKFA_CIMS 3000
|
||||
#define SRS_KAKFA_CIMS (3000 * SRS_UTIME_MILLISECONDS)
|
||||
|
||||
srs_error_t SrsKafkaProducer::cycle()
|
||||
{
|
||||
|
@ -510,7 +510,7 @@ srs_error_t SrsKafkaProducer::cycle()
|
|||
return srs_error_wrap(err, "kafka cycle");
|
||||
}
|
||||
|
||||
srs_usleep(SRS_KAKFA_CIMS * 1000);
|
||||
srs_usleep(SRS_KAKFA_CIMS);
|
||||
}
|
||||
|
||||
return err;
|
||||
|
|
|
@ -174,7 +174,7 @@ srs_error_t SrsUdpListener::cycle()
|
|||
}
|
||||
|
||||
if (SrsUdpPacketRecvCycleMS > 0) {
|
||||
srs_usleep(SrsUdpPacketRecvCycleMS * 1000);
|
||||
srs_usleep(SrsUdpPacketRecvCycleMS * SRS_UTIME_MILLISECONDS);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -76,7 +76,7 @@ void SrsNgExec::on_unpublish()
|
|||
}
|
||||
|
||||
// when error, ng-exec sleep for a while and retry.
|
||||
#define SRS_RTMP_EXEC_CIMS (3000)
|
||||
#define SRS_RTMP_EXEC_CIMS (3000 * SRS_UTIME_MILLISECONDS)
|
||||
srs_error_t SrsNgExec::cycle()
|
||||
{
|
||||
srs_error_t err = srs_success;
|
||||
|
@ -92,7 +92,7 @@ srs_error_t SrsNgExec::cycle()
|
|||
break;
|
||||
}
|
||||
|
||||
srs_usleep(SRS_RTMP_EXEC_CIMS * 1000);
|
||||
srs_usleep(SRS_RTMP_EXEC_CIMS);
|
||||
}
|
||||
|
||||
std::vector<SrsProcess*>::iterator it;
|
||||
|
|
|
@ -64,15 +64,15 @@ using namespace std;
|
|||
|
||||
// the timeout in ms to wait encoder to republish
|
||||
// if timeout, close the connection.
|
||||
#define SRS_REPUBLISH_SEND_TMMS (3 * 60 * 1000)
|
||||
#define SRS_REPUBLISH_SEND_TMMS (3 * SRS_UTIME_MINUTES)
|
||||
// if timeout, close the connection.
|
||||
#define SRS_REPUBLISH_RECV_TMMS (3 * 60 * 1000)
|
||||
#define SRS_REPUBLISH_RECV_TMMS (3 * SRS_UTIME_MINUTES)
|
||||
|
||||
// the timeout in ms to wait client data, when client paused
|
||||
// if timeout, close the connection.
|
||||
#define SRS_PAUSED_SEND_TMMS (3 * 60 * 1000)
|
||||
#define SRS_PAUSED_SEND_TMMS (3 * SRS_UTIME_MINUTES)
|
||||
// if timeout, close the connection.
|
||||
#define SRS_PAUSED_RECV_TMMS (3 * 60 * 1000)
|
||||
#define SRS_PAUSED_RECV_TMMS (3 * SRS_UTIME_MINUTES)
|
||||
|
||||
// when edge timeout, retry next.
|
||||
#define SRS_EDGE_TOKEN_TRAVERSE_TMMS (3000)
|
||||
|
|
|
@ -60,7 +60,7 @@ using namespace std;
|
|||
// the meminfo canbe 6*x, for instance, 6*1=6s,
|
||||
// for performance refine, @see: https://github.com/ossrs/srs/issues/194
|
||||
// @remark, recomment to 1000ms.
|
||||
#define SRS_SYS_CYCLE_INTERVAL 1000
|
||||
#define SRS_SYS_CYCLE_INTERVAL (1000 * SRS_UTIME_MILLISECONDS)
|
||||
|
||||
// update time interval:
|
||||
// SRS_SYS_CYCLE_INTERVAL * SRS_SYS_TIME_RESOLUTION_MS_TIMES
|
||||
|
@ -910,13 +910,13 @@ srs_error_t SrsServer::do_cycle()
|
|||
}
|
||||
|
||||
// the interval in config.
|
||||
int heartbeat_max_resolution = (int)(_srs_config->get_heartbeat_interval() / SRS_SYS_CYCLE_INTERVAL);
|
||||
int heartbeat_max_resolution = (int)(_srs_config->get_heartbeat_interval() * SRS_UTIME_MILLISECONDS / SRS_SYS_CYCLE_INTERVAL);
|
||||
|
||||
// dynamic fetch the max.
|
||||
int dynamic_max = srs_max(max, heartbeat_max_resolution);
|
||||
|
||||
for (int i = 0; i < dynamic_max; i++) {
|
||||
srs_usleep(SRS_SYS_CYCLE_INTERVAL * 1000);
|
||||
srs_usleep(SRS_SYS_CYCLE_INTERVAL);
|
||||
|
||||
// asprocess check.
|
||||
if (asprocess && ::getppid() != ppid) {
|
||||
|
|
|
@ -226,7 +226,7 @@
|
|||
#define SRS_CONSTS_HTTP_QUERY_SEP '?'
|
||||
|
||||
// the default recv timeout.
|
||||
#define SRS_HTTP_RECV_TMMS (60 * 1000)
|
||||
#define SRS_HTTP_RECV_TMMS (60 * SRS_UTIME_SECONDS)
|
||||
|
||||
// 6.1.1 Status Code and Reason Phrase
|
||||
#define SRS_CONSTS_HTTP_Continue 100
|
||||
|
|
|
@ -216,7 +216,7 @@ int SrsIngestHlsInput::connect()
|
|||
int64_t now = srs_update_system_time_ms();
|
||||
if (now < next_connect_time) {
|
||||
srs_trace("input hls wait for %dms", next_connect_time - now);
|
||||
srs_usleep((next_connect_time - now) * 1000);
|
||||
srs_usleep((next_connect_time - now) * SRS_UTIME_MILLISECONDS);
|
||||
}
|
||||
|
||||
// set all ts to dirty.
|
||||
|
@ -559,7 +559,7 @@ int SrsIngestHlsInput::fetch_all_ts(bool fresh_m3u8)
|
|||
|
||||
// only wait for a duration of last piece.
|
||||
if (i == (int)pieces.size() - 1) {
|
||||
next_connect_time = srs_update_system_time_ms() + (int)tp->duration * 1000;
|
||||
next_connect_time = srs_update_system_time_ms() + (int)tp->duration * SRS_UTIME_MILLISECONDS;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -108,7 +108,7 @@ public:
|
|||
cid = _srs_context->get_id();
|
||||
|
||||
while (!quit && (r0 = trd->pull()) == srs_success && err == srs_success) {
|
||||
srs_usleep(10 * 1000);
|
||||
srs_usleep(10 * SRS_UTIME_MILLISECONDS);
|
||||
}
|
||||
|
||||
srs_cond_signal(exited);
|
||||
|
@ -297,7 +297,7 @@ VOID TEST(AppCoroutineTest, StartThread)
|
|||
|
||||
_ST_THREAD_CREATE_PFN ov = _pfn_st_thread_create;
|
||||
_pfn_st_thread_create = (_ST_THREAD_CREATE_PFN)mock_st_thread_create;
|
||||
|
||||
|
||||
srs_error_t err = sc.start();
|
||||
_pfn_st_thread_create = ov;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue