libgpac
Documentation of the core library of GPAC
Local and Network time

Time manipulation tools. More...

+ Collaboration diagram for Local and Network time:

Macros

#define GF_NTP_SEC_1900_TO_1970
 NTP seconds from 1900 to 1970. More...
 

Functions

void gf_utc_time_since_1970 (u32 *sec, u32 *msec)
 gets UTC time More...
 
void gf_net_get_ntp (u32 *sec, u32 *frac)
 gets NTP time More...
 
u64 gf_net_get_ntp_ms ()
 gets NTP time in milliseconds More...
 
void gf_net_set_ntp_shift (s32 sec)
 offsets NTP time by a given amount of seconds More...
 
u64 gf_net_get_ntp_ts ()
 gets NTP time More...
 
s32 gf_net_get_ntp_diff_ms (u64 ntp)
 
s32 gf_net_ntp_diff_ms (u64 ntp_a, u64 ntp_b)
 
u32 gf_sys_clock ()
 System clock query. More...
 
u64 gf_sys_clock_high_res ()
 High precision system clock query. More...
 
void gf_sleep (u32 ms)
 Sleeps thread/process. More...
 
u64 gf_net_get_utc ()
 gets UTC time in milliseconds More...
 
u64 gf_net_ntp_to_utc (u64 ntp)
 converts an ntp timestamp into UTC time in milliseconds More...
 
u64 gf_net_parse_date (const char *date)
 parses date More...
 
u64 gf_net_get_utc_ts (u32 year, u32 month, u32 day, u32 hour, u32 min, u32 sec)
 returns 64-bit UTC timestamp from year, month, day, hour, min and sec More...
 
s32 gf_net_get_timezone ()
 gets timezone adjustment in seconds More...
 
Bool gf_net_time_is_dst ()
 gets timezone daylight saving time status More...
 
struct tm * gf_gmtime (const time_t *time)
 gets time from UTC timestamp More...
 

Detailed Description

Macro Definition Documentation

◆ GF_NTP_SEC_1900_TO_1970

#define GF_NTP_SEC_1900_TO_1970

Macro giving the number of seconds from 1900 to 1970

Function Documentation

◆ gf_utc_time_since_1970()

void gf_utc_time_since_1970 ( u32 sec,
u32 msec 
)

Gets UTC time since midnight Jan 1970

Parameters
secnumber of seconds
msecnumber of milliseconds

◆ gf_net_get_ntp()

void gf_net_get_ntp ( u32 sec,
u32 frac 
)

Gets NTP (Network Time Protocol) in seconds and fractional side

Parameters
secNTP time in seconds
fracfractional NTP time expressed in 1 / (1<<32 - 1) seconds units

◆ gf_net_get_ntp_ms()

u64 gf_net_get_ntp_ms ( )
Returns
NTP time in milliseconds

◆ gf_net_set_ntp_shift()

void gf_net_set_ntp_shift ( s32  sec)

Offsets NTP time of the system by a given amount of seconds in the future or the past (default value is 0).

Parameters
secseconds to add or remove to the system NTP

◆ gf_net_get_ntp_ts()

u64 gf_net_get_ntp_ts ( )

Gets NTP (Network Time Protocol) timestamp (high 32 bit is seconds, low 32 bit is fraction)

Returns
NTP timestamp

◆ gf_net_get_ntp_diff_ms()

s32 gf_net_get_ntp_diff_ms ( u64  ntp)

Gets diff in milliseconds between NTP time and current time

Parameters
ntpNTP timestamp
Returns
diff in milliseconds with the current time

◆ gf_net_ntp_diff_ms()

s32 gf_net_ntp_diff_ms ( u64  ntp_a,
u64  ntp_b 
)

Gets diff in milliseconds between two NTP times time and current time

Parameters
ntp_afirst NTP timestamp
ntp_bsecond NTP timestamp
Returns
diff ntp_a minus ntp_b in milliseconds

◆ gf_sys_clock()

u32 gf_sys_clock ( )

Gets the system clock time.

Returns
System clock value since GPAC initialization in milliseconds.

◆ gf_sys_clock_high_res()

u64 gf_sys_clock_high_res ( )

Gets the hight precision system clock time.

Returns
System clock value since GPAC initialization in microseconds.

◆ gf_sleep()

void gf_sleep ( u32  ms)

Locks calling thread/process execution for a given time.

Parameters
msAmount of time to sleep in milliseconds.

◆ gf_net_get_utc()

u64 gf_net_get_utc ( )

Gets UTC clock in milliseconds

Returns
UTC time in milliseconds

◆ gf_net_ntp_to_utc()

u64 gf_net_ntp_to_utc ( u64  ntp)

Converts NTP 64-bit timestamp to UTC clock in milliseconds

Parameters
ntpNTP timestamp
Returns
UTC time in milliseconds

◆ gf_net_parse_date()

u64 gf_net_parse_date ( const char *  date)

Parses date and gets UTC value for this date. Date format is an XSD dateTime format or any of the supported formats from HTTP 1.1: Sun, 06 Nov 1994 08:49:37 GMT ; RFC 822, updated by RFC 1123 Sunday, 06-Nov-94 08:49:37 GMT ; RFC 850, obsoleted by RFC 1036 Sun Nov 6 08:49:37 1994 ; ANSI C's asctime() formatgets UTC time in milliseconds

Parameters
datestring containing the date to parse
Returns
UTC time in milliseconds

◆ gf_net_get_utc_ts()

u64 gf_net_get_utc_ts ( u32  year,
u32  month,
u32  day,
u32  hour,
u32  min,
u32  sec 
)
Parameters
yearthe year
monththe month, from 0 to 11
daythe day
hourthe hour
minthe min
secthe sec
Returns
UTC time in milliseconds

◆ gf_net_get_timezone()

s32 gf_net_get_timezone ( )

Gets timezone adjustment in seconds, with localtime - timezone = UTC time

Returns
timezone shift in seconds

◆ gf_net_time_is_dst()

Bool gf_net_time_is_dst ( )

Gets timezone daylight saving time

Returns
GF_TRUE if DST is active

◆ gf_gmtime()

struct tm* gf_gmtime ( const time_t *  time)

Gets time from UTC timestamp

Parameters
timetimestamp value - see gmtime
Returns
time description structure - see gmtime