mirror of
https://github.com/ossrs/srs.git
synced 2025-02-13 11:51:57 +00:00
Refine get_publish_normal_timeout in time unit
This commit is contained in:
parent
170872135d
commit
9b1222a79c
5 changed files with 17 additions and 14 deletions
|
@ -4797,12 +4797,12 @@ srs_utime_t SrsConfig::get_publish_1stpkt_timeout(string vhost)
|
||||||
return (srs_utime_t)(::atoi(conf->arg0().c_str()) * SRS_UTIME_MILLISECONDS);
|
return (srs_utime_t)(::atoi(conf->arg0().c_str()) * SRS_UTIME_MILLISECONDS);
|
||||||
}
|
}
|
||||||
|
|
||||||
int SrsConfig::get_publish_normal_timeout(string vhost)
|
srs_utime_t SrsConfig::get_publish_normal_timeout(string vhost)
|
||||||
{
|
{
|
||||||
// the timeout for publish recv.
|
// the timeout for publish recv.
|
||||||
// we must use more smaller timeout, for the recv never know the status
|
// we must use more smaller timeout, for the recv never know the status
|
||||||
// of underlayer socket.
|
// of underlayer socket.
|
||||||
static int DEFAULT = 5000;
|
static srs_utime_t DEFAULT = 5 * SRS_UTIME_SECONDS;
|
||||||
|
|
||||||
SrsConfDirective* conf = get_vhost(vhost);
|
SrsConfDirective* conf = get_vhost(vhost);
|
||||||
if (!conf) {
|
if (!conf) {
|
||||||
|
@ -4819,7 +4819,7 @@ int SrsConfig::get_publish_normal_timeout(string vhost)
|
||||||
return DEFAULT;
|
return DEFAULT;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ::atoi(conf->arg0().c_str());
|
return (srs_utime_t)(::atoi(conf->arg0().c_str()) * SRS_UTIME_MILLISECONDS);
|
||||||
}
|
}
|
||||||
|
|
||||||
int SrsConfig::get_global_chunk_size()
|
int SrsConfig::get_global_chunk_size()
|
||||||
|
|
|
@ -809,9 +809,9 @@ public:
|
||||||
*/
|
*/
|
||||||
virtual srs_utime_t get_publish_1stpkt_timeout(std::string vhost);
|
virtual srs_utime_t get_publish_1stpkt_timeout(std::string vhost);
|
||||||
/**
|
/**
|
||||||
* the normal packet timeout in ms for encoder.
|
* the normal packet timeout in srs_utime_t for encoder.
|
||||||
*/
|
*/
|
||||||
virtual int get_publish_normal_timeout(std::string vhost);
|
virtual srs_utime_t get_publish_normal_timeout(std::string vhost);
|
||||||
private:
|
private:
|
||||||
/**
|
/**
|
||||||
* get the global chunk size.
|
* get the global chunk size.
|
||||||
|
|
|
@ -325,9 +325,9 @@ srs_error_t SrsRtmpConn::on_reload_vhost_publish(string vhost)
|
||||||
publish_1stpkt_timeout = p1stpt;
|
publish_1stpkt_timeout = p1stpt;
|
||||||
}
|
}
|
||||||
|
|
||||||
int pnt = _srs_config->get_publish_normal_timeout(req->vhost);
|
srs_utime_t pnt = _srs_config->get_publish_normal_timeout(req->vhost);
|
||||||
if (pnt != publish_normal_timeout) {
|
if (pnt != publish_normal_timeout) {
|
||||||
srs_trace("pnt changed %d=>%d", publish_normal_timeout, pnt);
|
srs_trace("pnt changed %d=>%d", srsu2msi(publish_normal_timeout), srsu2msi(pnt));
|
||||||
publish_normal_timeout = pnt;
|
publish_normal_timeout = pnt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -863,7 +863,8 @@ srs_error_t SrsRtmpConn::do_publishing(SrsSource* source, SrsPublishRecvThread*
|
||||||
bool mr = _srs_config->get_mr_enabled(req->vhost);
|
bool mr = _srs_config->get_mr_enabled(req->vhost);
|
||||||
srs_utime_t mr_sleep = _srs_config->get_mr_sleep(req->vhost);
|
srs_utime_t mr_sleep = _srs_config->get_mr_sleep(req->vhost);
|
||||||
srs_trace("start publish mr=%d/%d, p1stpt=%d, pnt=%d, tcp_nodelay=%d, rtcid=%d",
|
srs_trace("start publish mr=%d/%d, p1stpt=%d, pnt=%d, tcp_nodelay=%d, rtcid=%d",
|
||||||
mr, srsu2msi(mr_sleep), srsu2msi(publish_1stpkt_timeout), publish_normal_timeout, tcp_nodelay, receive_thread_cid);
|
mr, srsu2msi(mr_sleep), srsu2msi(publish_1stpkt_timeout), srsu2msi(publish_normal_timeout),
|
||||||
|
tcp_nodelay, receive_thread_cid);
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t nb_msgs = 0;
|
int64_t nb_msgs = 0;
|
||||||
|
@ -881,7 +882,7 @@ srs_error_t SrsRtmpConn::do_publishing(SrsSource* source, SrsPublishRecvThread*
|
||||||
// @see https://github.com/ossrs/srs/issues/441
|
// @see https://github.com/ossrs/srs/issues/441
|
||||||
rtrd->wait(srsu2msi(publish_1stpkt_timeout));
|
rtrd->wait(srsu2msi(publish_1stpkt_timeout));
|
||||||
} else {
|
} else {
|
||||||
rtrd->wait(publish_normal_timeout);
|
rtrd->wait(srsu2msi(publish_normal_timeout));
|
||||||
}
|
}
|
||||||
|
|
||||||
// check the thread error code.
|
// check the thread error code.
|
||||||
|
@ -892,7 +893,7 @@ srs_error_t SrsRtmpConn::do_publishing(SrsSource* source, SrsPublishRecvThread*
|
||||||
// when not got any messages, timeout.
|
// when not got any messages, timeout.
|
||||||
if (rtrd->nb_msgs() <= nb_msgs) {
|
if (rtrd->nb_msgs() <= nb_msgs) {
|
||||||
return srs_error_new(ERROR_SOCKET_TIMEOUT, "rtmp: publish timeout %dms, nb_msgs=%d",
|
return srs_error_new(ERROR_SOCKET_TIMEOUT, "rtmp: publish timeout %dms, nb_msgs=%d",
|
||||||
nb_msgs? publish_normal_timeout : srsu2msi(publish_1stpkt_timeout), (int)nb_msgs);
|
nb_msgs? srsu2msi(publish_normal_timeout) : srsu2msi(publish_1stpkt_timeout), (int)nb_msgs);
|
||||||
}
|
}
|
||||||
nb_msgs = rtrd->nb_msgs();
|
nb_msgs = rtrd->nb_msgs();
|
||||||
|
|
||||||
|
@ -912,7 +913,7 @@ srs_error_t SrsRtmpConn::do_publishing(SrsSource* source, SrsPublishRecvThread*
|
||||||
srs_trace("<- " SRS_CONSTS_LOG_CLIENT_PUBLISH " time=%d, okbps=%d,%d,%d, ikbps=%d,%d,%d, mr=%d/%d, p1stpt=%d, pnt=%d",
|
srs_trace("<- " SRS_CONSTS_LOG_CLIENT_PUBLISH " time=%d, okbps=%d,%d,%d, ikbps=%d,%d,%d, mr=%d/%d, p1stpt=%d, pnt=%d",
|
||||||
(int)pprint->age(), kbps->get_send_kbps(), kbps->get_send_kbps_30s(), kbps->get_send_kbps_5m(),
|
(int)pprint->age(), kbps->get_send_kbps(), kbps->get_send_kbps_30s(), kbps->get_send_kbps_5m(),
|
||||||
kbps->get_recv_kbps(), kbps->get_recv_kbps_30s(), kbps->get_recv_kbps_5m(), mr, srsu2msi(mr_sleep),
|
kbps->get_recv_kbps(), kbps->get_recv_kbps_30s(), kbps->get_recv_kbps_5m(), mr, srsu2msi(mr_sleep),
|
||||||
srsu2msi(publish_1stpkt_timeout), publish_normal_timeout);
|
srsu2msi(publish_1stpkt_timeout), srsu2msi(publish_normal_timeout));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -120,8 +120,8 @@ private:
|
||||||
double send_min_interval;
|
double send_min_interval;
|
||||||
// publish 1st packet timeout in srs_utime_t
|
// publish 1st packet timeout in srs_utime_t
|
||||||
srs_utime_t publish_1stpkt_timeout;
|
srs_utime_t publish_1stpkt_timeout;
|
||||||
// publish normal packet timeout in ms
|
// publish normal packet timeout in srs_utime_t
|
||||||
int publish_normal_timeout;
|
srs_utime_t publish_normal_timeout;
|
||||||
// whether enable the tcp_nodelay.
|
// whether enable the tcp_nodelay.
|
||||||
bool tcp_nodelay;
|
bool tcp_nodelay;
|
||||||
// About the rtmp client.
|
// About the rtmp client.
|
||||||
|
|
|
@ -1849,10 +1849,12 @@ VOID TEST(ConfigUnitTest, CheckDefaultValues)
|
||||||
EXPECT_EQ(350 * SRS_UTIME_MILLISECONDS, conf.get_mr_sleep(""));
|
EXPECT_EQ(350 * SRS_UTIME_MILLISECONDS, conf.get_mr_sleep(""));
|
||||||
EXPECT_EQ(350 * SRS_UTIME_MILLISECONDS, conf.get_mw_sleep(""));
|
EXPECT_EQ(350 * SRS_UTIME_MILLISECONDS, conf.get_mw_sleep(""));
|
||||||
EXPECT_EQ(20 * SRS_UTIME_SECONDS, conf.get_publish_1stpkt_timeout(""));
|
EXPECT_EQ(20 * SRS_UTIME_SECONDS, conf.get_publish_1stpkt_timeout(""));
|
||||||
|
EXPECT_EQ(5 * SRS_UTIME_SECONDS, conf.get_publish_normal_timeout(""));
|
||||||
|
|
||||||
EXPECT_TRUE(ERROR_SUCCESS == conf.parse(_MIN_OK_CONF"vhost v{publish{mr_latency 1000; firstpkt_timeout 100;} play{mw_latency 1000;}}"));
|
EXPECT_TRUE(ERROR_SUCCESS == conf.parse(_MIN_OK_CONF"vhost v{publish{mr_latency 1000; firstpkt_timeout 100; normal_timeout 100;} play{mw_latency 1000;}}"));
|
||||||
EXPECT_EQ(1000 * SRS_UTIME_MILLISECONDS, conf.get_mr_sleep("v"));
|
EXPECT_EQ(1000 * SRS_UTIME_MILLISECONDS, conf.get_mr_sleep("v"));
|
||||||
EXPECT_EQ(100 * SRS_UTIME_MILLISECONDS, conf.get_publish_1stpkt_timeout("v"));
|
EXPECT_EQ(100 * SRS_UTIME_MILLISECONDS, conf.get_publish_1stpkt_timeout("v"));
|
||||||
|
EXPECT_EQ(100 * SRS_UTIME_MILLISECONDS, conf.get_publish_normal_timeout("v"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue