1
0
Fork 0
mirror of https://github.com/ossrs/srs.git synced 2025-03-09 15:49:59 +00:00

Refine srs_update_system_time in time unit

This commit is contained in:
winlin 2019-04-10 09:07:03 +08:00
parent 9b7c0802a9
commit 6c12aa0eca
26 changed files with 123 additions and 108 deletions

View file

@ -137,8 +137,7 @@ int SrsBandwidthClient::bandwidth_check(
) {
int ret = ERROR_SUCCESS;
srs_update_system_time();
*start_time = srs_get_system_time_ms();
*start_time = srsu2ms(srs_update_system_time());
// play
if ((ret = play_start()) != ERROR_SUCCESS) {
@ -193,8 +192,7 @@ int SrsBandwidthClient::bandwidth_check(
}
}
srs_update_system_time();
*end_time = srs_get_system_time_ms();
*end_time = srsu2ms(srs_update_system_time());
return ret;
}
@ -313,9 +311,8 @@ int SrsBandwidthClient::publish_checking(int duration_ms, int play_kbps)
}
int data_count = 1;
srs_update_system_time();
int64_t starttime = srs_get_system_time_ms();
while ((srs_get_system_time_ms() - starttime) < duration_ms) {
int64_t starttime = srsu2ms(srs_update_system_time());
while ((srsu2ms(srs_get_system_time()) - starttime) < duration_ms) {
// TODO: FIXME: use shared ptr message.
SrsBandwidthPacket* pkt = SrsBandwidthPacket::create_publishing();
@ -336,13 +333,12 @@ int SrsBandwidthClient::publish_checking(int duration_ms, int play_kbps)
}
// use the play kbps to control the publish
srs_update_system_time();
int elaps = (int)(srs_get_system_time_ms() - starttime);
int elaps = (int)(srsu2ms(srs_update_system_time()) - starttime);
if (elaps > 0) {
int current_kbps = (int)(_rtmp->get_send_bytes() * 8 / elaps);
while (current_kbps > play_kbps) {
srs_update_system_time();
elaps = (int)(srs_get_system_time_ms() - starttime);
elaps = (int)(srsu2ms(srs_get_system_time()) - starttime);
current_kbps = (int)(_rtmp->get_send_bytes() * 8 / elaps);
usleep(100 * 1000); // TODO: FIXME: magic number.
}