GPAC
Open Source Multimedia Framework. For more information, check out http://gpac.wp.mines-telecom.fr
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups
Time tools

System time and CPU functions. More...

+ Collaboration diagram for Time tools:

Data Structures

struct  GF_SystemRTInfo
 run-time system info object More...
 

Enumerations

enum  { GF_RTI_ALL_PROCESSES_TIMES = 1, GF_RTI_PROCESS_MEMORY = 1<<1, GF_RTI_SYSTEM_MEMORY_ONLY = 1<<2 }
 

Functions

void gf_sys_init (Bool enable_memory_tracker)
 System setup. More...
 
void gf_sys_close ()
 System closing. More...
 
u32 gf_sys_clock ()
 System clock query. More...
 
void gf_sleep (u32 ms)
 Sleeps thread/process. More...
 
GF_Err gf_rmdir (char *DirPathName)
 Delete Directory. More...
 
GF_Err gf_mkdir (char *DirPathName)
 Create Directory. More...
 
GF_Err gf_cleanup_dir (char *DirPathName)
 Create Directory. More...
 
u32 gf_crc_32 (const char *data, u32 size)
 CRC32 compute. More...
 
u64 gf_net_get_utc ()
 gets UTC time in milliseconds More...
 
u64 gf_net_parse_date (const char *date)
 parses date and returns 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 More...
 
s32 gf_net_get_timezone ()
 gets timezone adjustment in seconds More...
 
GF_Err gf_bin128_parse (char *string, bin128 value)
 parses 128 bit from string More...
 
Bool gf_sys_get_rti (u32 refresh_time_ms, GF_SystemRTInfo *rti, u32 flags)
 Gets Run-Time info. More...
 
Bool gf_sys_get_battery_state (Bool *onBattery, u32 *onCharge, u32 *level, u32 *batteryLifeTime, u32 *batteryFullLifeTime)
 
GF_GlobalLockgf_global_resource_lock (const char *resourceName)
 
GF_Err gf_global_resource_unlock (GF_GlobalLock *lock)
 
char * gf_get_default_cache_directory ()
 
GF_Err gf_gz_compress_payload (char **data, u32 data_len, u32 *out_size)
 
GF_Err gf_gz_decompress_payload (char *data, u32 data_len, char **uncompressed_data, u32 *out_size)
 
GF_SHA1Context * gf_sha1_starts ()
 
void gf_sha1_update (GF_SHA1Context *ctx, u8 *input, u32 length)
 
void gf_sha1_finish (GF_SHA1Context *ctx, u8 digest[20])
 
int gf_sha1_file (const char *filename, u8 digest[20])
 
void gf_sha1_csum (u8 *buf, u32 buflen, u8 digest[20])
 
void gf_sha1_csum_hexa (u8 *buf, u32 buflen, u8 digest[41])
 

Detailed Description

This section documents time functionalities and CPU management in GPAC.


Data Structure Documentation

struct GF_SystemRTInfo

The Run-Time Info object is used to get CPU and memory occupation of the calling process. All time values are expressed in milliseconds (accuracy is not guaranteed).

+ Collaboration diagram for GF_SystemRTInfo:
Data Fields
u32 sampling_instant

start of the sampling period

u32 sampling_period_duration

duration of the sampling period

u32 total_cpu_time

total amount of time (User+kernel) spent in CPU for all processes as evaluated at the end of the sampling period

u32 process_cpu_time

total amount of time (User+kernel) spent in CPU for the calling process as evaluated at the end of the sampling period

u32 total_cpu_time_diff

amount of time (User+kernel) spent in CPU for all processes during the sampling period

u32 process_cpu_time_diff

total amount of time (User+kernel) spent in CPU for the calling process during the sampling period

u32 cpu_idle_time

total amount of idle time during the sampling period.

u32 total_cpu_usage

percentage (from 0 to 100) of CPU usage during the sampling period.

u32 process_cpu_usage

percentage (from 0 to 100) of the CPU usage by the calling process during the sampling period.

u32 pid

calling process ID

u32 thread_count

calling process thread count if known

u64 process_memory

size of calling process allocated heaps

u64 physical_memory

total physical memory in system

u64 physical_memory_avail

available physical memory in system

u64 gpac_memory

total memory currently allocated by gpac

u32 nb_cores

total number of cores on the system

Enumeration Type Documentation

anonymous enum

Selection flags for run-time info retrieval

Enumerator
GF_RTI_ALL_PROCESSES_TIMES 

Indicates all processes' times must be fetched. If not set, only the current process times will be retrieved, and the thread count and total times won't be available

GF_RTI_PROCESS_MEMORY 

Indicates the process allocated heap size must be fetch. If not set, only the system physical memory is fetched. Fetching the entire ocess allocated memory can have a large impact on performances

GF_RTI_SYSTEM_MEMORY_ONLY 

Indicates that only system memory should be fetched. When set, all refreshing info is ignored

Function Documentation

void gf_sys_init ( Bool  enable_memory_tracker)
 Inits the system high-resolution clock if any, and CPU usage manager. It is strongly recommended to call this

function before calling any other GPAC functions, since on some systems (like winCE) it may result in a better memory usage estimation.

Note
This can be called several times but only the first call will result in system setup.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void gf_sys_close ( )

Closes the system high-resolution clock and any CPU associated ressources.

Note
This can be called several times but the system will be closed when no more users are counted.

+ Here is the caller graph for this function:

u32 gf_sys_clock ( )

Gets the system clock time.

Returns
System clock value since initialization in milliseconds.
void gf_sleep ( u32  ms)

Locks calling thread/process execution for a given time.

Parameters
msAmount of time to sleep in milliseconds.

+ Here is the call graph for this function:

GF_Err gf_rmdir ( char *  DirPathName)

Delete a dir within the full path.

Parameters
DirPathNamethe file path name.

+ Here is the caller graph for this function:

GF_Err gf_mkdir ( char *  DirPathName)

Create a directory within the full path.

Parameters
DirPathNamethe dir path name.

+ Here is the caller graph for this function:

GF_Err gf_cleanup_dir ( char *  DirPathName)

Cleanup a directory within the full path, removing all the files and the directories.

Parameters
DirPathNamethe dir path name.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

u32 gf_crc_32 ( const char *  data,
u32  size 
)

Computes the CRC32 value of a buffer.

Parameters
databuffer
sizebuffer size
Returns
computed CRC32

+ Here is the caller graph for this function:

u64 gf_net_get_utc ( )

Gets UTC clock in milliseconds

Returns
UTC time in milliseconds

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

u64 gf_net_parse_date ( const char *  date)
Parameters
datestring containing the date to parse
Returns
UTC time in milliseconds

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

s32 gf_net_get_timezone ( )

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

Returns
timezone shift in seconds

+ Here is the caller graph for this function:

GF_Err gf_bin128_parse ( char *  string,
bin128  value 
)

Parses 128 bit from string

Parameters
stringthe string containing the value in hexa. Non alphanum characters are skipped
valuethe value parsed
Returns
error code if any

+ Here is the caller graph for this function:

Bool gf_sys_get_rti ( u32  refresh_time_ms,
GF_SystemRTInfo rti,
u32  flags 
)
 Gets CPU and memory usage info for the calling process and the system. Information gathering

is controled through timeout values.

Parameters
refresh_time_msrefresh time period in milliseconds. If the last sampling was done less than this period ago, the run-time info is not refreshed.
rtiholder to the run-time info structure to update.
flagsspecify which info is to be retrieved.
Returns
1 if info has been updated, 0 otherwise.
Note
You should not try to use a too small refresh time. Typical values are 500 ms or one second.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Bool gf_sys_get_battery_state ( Bool onBattery,
u32 onCharge,
u32 level,
u32 batteryLifeTime,
u32 batteryFullLifeTime 
)

+ Here is the caller graph for this function:

GF_GlobalLock* gf_global_resource_lock ( const char *  resourceName)

This function allows the user to create a global lock for all GPAC instances. This allow to disable some features for other instances for instance.

Parameters
resourceNameThe name of the resource to lock
Returns
false if resource has been locked, true if resource could not be locked

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

GF_Err gf_global_resource_unlock ( GF_GlobalLock lock)

Unlock a previouly locked resource

Parameters
lockThe resource to unlock
Returns
GF_OK if evertything went fine

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

char* gf_get_default_cache_directory ( )

Gets a newly allocated string containing the default cache directory. It is the responsibility of the caller to free the string.

Returns
a fully qualified path to the default cache directory

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

GF_Err gf_gz_compress_payload ( char **  data,
u32  data_len,
u32 out_size 
)

Compresses a data buffer in place using zlib. Buffer may be reallocated in the process.

Parameters
datapointer to the data buffer to be compressed
data_lenlength of the data buffer to be compressed
out_sizepointer for output buffer size
Returns
GF_OK if evertything went fine

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

GF_Err gf_gz_decompress_payload ( char *  data,
u32  data_len,
char **  uncompressed_data,
u32 out_size 
)

Decompresses a data buffer using zlib.

Parameters
datadata buffer to be decompressed
data_lenlength of the data buffer to be decompressed
uncompressed_datapointer to the uncompressed data buffer. It is the responsibility of the caller to free this buffer.
out_sizesize of the uncompressed buffer
Returns
GF_OK if evertything went fine

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

GF_SHA1Context* gf_sha1_starts ( )

+ Here is the caller graph for this function:

void gf_sha1_update ( GF_SHA1Context *  ctx,
u8 input,
u32  length 
)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void gf_sha1_finish ( GF_SHA1Context *  ctx,
u8  digest[20] 
)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int gf_sha1_file ( const char *  filename,
u8  digest[20] 
)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void gf_sha1_csum ( u8 buf,
u32  buflen,
u8  digest[20] 
)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void gf_sha1_csum_hexa ( u8 buf,
u32  buflen,
u8  digest[41] 
)

+ Here is the call graph for this function: