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

fix isse #35: the gettimeofday jitter, log warn message

This commit is contained in:
winlin 2014-03-21 17:56:27 +08:00
parent 4f284b20f0
commit fdad7c25f0
9 changed files with 185 additions and 113 deletions

View file

@ -24,30 +24,9 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include <srs_core.hpp>
#include <string.h>
#include <sys/time.h>
#include <netdb.h>
#include <arpa/inet.h>
static int64_t _srs_system_time_us_cache = 0;
int64_t srs_get_system_time_ms()
{
return _srs_system_time_us_cache / 1000;
}
void srs_update_system_time_ms()
{
timeval now;
gettimeofday(&now, NULL);
// @see: https://github.com/winlinvip/simple-rtmp-server/issues/35
// we must convert the tv_sec/tv_usec to int64_t.
_srs_system_time_us_cache = ((int64_t)now.tv_sec) * 1000 * 1000 + (int64_t)now.tv_usec;
_srs_system_time_us_cache = srs_max(0, _srs_system_time_us_cache);
}
std::string srs_replace(std::string str, std::string old_str, std::string new_str)
{
std::string ret = str;