mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
Merge branch '4.0release' into xialixin-dev-28181
This commit is contained in:
commit
a342f460e7
29 changed files with 654 additions and 203 deletions
|
@ -124,7 +124,9 @@ srs_utime_t srs_get_system_startup_time()
|
|||
}
|
||||
|
||||
// For utest to mock it.
|
||||
#ifndef SRS_AUTO_OSX
|
||||
_srs_gettimeofday_t _srs_gettimeofday = ::gettimeofday;
|
||||
#endif
|
||||
|
||||
srs_utime_t srs_update_system_time()
|
||||
{
|
||||
|
@ -652,15 +654,20 @@ bool srs_path_exists(std::string path)
|
|||
string srs_path_dirname(string path)
|
||||
{
|
||||
std::string dirname = path;
|
||||
|
||||
// No slash, it must be current dir.
|
||||
size_t pos = string::npos;
|
||||
|
||||
if ((pos = dirname.rfind("/")) != string::npos) {
|
||||
if (pos == 0) {
|
||||
return "/";
|
||||
}
|
||||
dirname = dirname.substr(0, pos);
|
||||
if ((pos = dirname.rfind("/")) == string::npos) {
|
||||
return "./";
|
||||
}
|
||||
|
||||
|
||||
// Path under root.
|
||||
if (pos == 0) {
|
||||
return "/";
|
||||
}
|
||||
|
||||
// Fetch the directory.
|
||||
dirname = dirname.substr(0, pos);
|
||||
return dirname;
|
||||
}
|
||||
|
||||
|
|
|
@ -166,7 +166,11 @@ extern int srs_chunk_header_c3(int perfer_cid, uint32_t timestamp, char* cache,
|
|||
|
||||
// For utest to mock it.
|
||||
#include <sys/time.h>
|
||||
typedef int (*_srs_gettimeofday_t)(struct timeval* tv, struct timezone* tz);
|
||||
#ifdef SRS_AUTO_OSX
|
||||
#define _srs_gettimeofday gettimeofday
|
||||
#else
|
||||
typedef int (*_srs_gettimeofday_t) (struct timeval* tv, struct timezone* tz);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue