libgpac
Documentation of the core library of GPAC
os_divers.c File Reference
#include <gpac/tools.h>
#include <gpac/network.h>
#include <gpac/config_file.h>
#include <time.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <dirent.h>
#include <unistd.h>
#include <sys/times.h>
#include <sys/resource.h>
#include <errno.h>
#include <locale.h>
#include <gpac/revision.h>
#include <termios.h>
#include <sys/ioctl.h>
#include <gpac/thread.h>
#include <gpac/list.h>
#include <fcntl.h>
#include <gpac/token.h>
+ Include dependency graph for os_divers.c:

Macros

#define SLEEP_ABS_SELECT   1
 
#define GPAC_FULL_VERSION   GPAC_VERSION "-rev" GPAC_GIT_REVISION
 
#define GPAC_COPYRIGHT   "(c) 2000-2024 Telecom Paris distributed under LGPL v2.1+ - https://gpac.io"
 

Functions

GF_EXPORT const char * gf_gpac_version ()
 
GF_EXPORT const char * gf_gpac_copyright ()
 
GF_EXPORT const char * gf_gpac_copyright_cite ()
 
GF_EXPORT u32 gf_gpac_abi_major ()
 
GF_EXPORT u32 gf_gpac_abi_minor ()
 
GF_EXPORT u32 gf_gpac_abi_micro ()
 
GF_EXPORT u32 gf_sys_clock ()
 System clock query. More...
 
GF_EXPORT u64 gf_sys_clock_high_res ()
 High precision system clock query. More...
 
GF_Err gf_sys_enable_rmtws (Bool start)
 
GF_EXPORT void gf_sleep (u32 ms)
 Sleeps thread/process. More...
 
GF_EXPORT void gf_rand_init (Bool Reset)
 PseudoRandom Integer Generation Initialization. More...
 
GF_EXPORT u32 gf_rand ()
 
GF_EXPORT void gf_utc_time_since_1970 (u32 *sec, u32 *msec)
 gets UTC time More...
 
GF_EXPORT void gf_get_user_name (char buf[1024])
 
GF_EXPORT char * my_str_upr (char *str)
 
GF_EXPORT char * my_str_lwr (char *str)
 
static void init_keyboard ()
 
static void close_keyboard (Bool new_line)
 
GF_EXPORT void gf_prompt_set_echo_off (Bool echo_off)
 turns prompt echo on/off More...
 
GF_EXPORT Bool gf_prompt_has_input ()
 Prompt checking. More...
 
GF_EXPORT char gf_prompt_get_char ()
 Prompt character flush. More...
 
GF_EXPORT GF_Err gf_prompt_get_size (u32 *width, u32 *height)
 Get prompt TTY size. More...
 
GF_EXPORT struct tm * gf_gmtime (const time_t *time)
 gets time from UTC timestamp More...
 
GF_EXPORT Bool gf_log_use_file ()
 Checks if logs are stored to file. More...
 
static void progress_quiet (const void *cbck, const char *title, u64 done, u64 total)
 
void gpac_disable_progress ()
 
GF_EXPORT Bool gf_sys_is_test_mode ()
 checks if test mode is enabled More...
 
GF_EXPORT Bool gf_sys_old_arch_compat ()
 checks if compatibility with old arch is enabled More...
 
GF_EXPORT void gf_log_reset_file ()
 Resets log file Resets log file if any log file name was specified, by closing and reopening a new file. More...
 
Bool gf_sys_has_filter_global_args ()
 
Bool gf_sys_has_filter_global_meta_args ()
 
GF_EXPORT GF_Err gf_sys_set_args (s32 argc, const char **argv)
 System arguments. More...
 
GF_EXPORT void gf_sys_mark_arg_used (s32 arg_idx, Bool used)
 Mark arg as used. More...
 
GF_EXPORT Bool gf_sys_is_arg_used (s32 arg_idx)
 Check if arg is marked as used. More...
 
GF_EXPORT u32 gf_sys_is_quiet ()
 checks if running in quiet mode More...
 
GF_EXPORT u32 gf_sys_get_argc ()
 Get number of args. More...
 
GF_EXPORT const char ** gf_sys_get_argv ()
 Get program arguments. More...
 
GF_EXPORT const char * gf_sys_get_arg (u32 arg)
 Get number of args. More...
 
GF_EXPORT const char * gf_sys_find_global_arg (const char *arg)
 Locate a global filter arg. More...
 
GF_EXPORT GF_Err gf_blob_get_ex (GF_Blob *blob, u8 **out_data, u32 *out_size, u32 *out_flags)
 
GF_EXPORT GF_Err gf_blob_get (const char *blob_url, u8 **out_data, u32 *out_size, u32 *out_flags)
 
GF_EXPORT GF_Err gf_blob_release_ex (GF_Blob *blob)
 
GF_EXPORT GF_Err gf_blob_release (const char *blob_url)
 
GF_EXPORT char * gf_blob_register (GF_Blob *blob)
 
GF_EXPORT void gf_blob_unregister (GF_Blob *blob)
 
GF_EXPORT GF_BlobRangeStatus gf_blob_query_range (GF_Blob *blob, u64 start_offset, u32 size)
 
void gf_init_global_config (const char *profile)
 
void gf_uninit_global_config (Bool discard_config)
 
GF_Config * gf_sys_get_lang_file ()
 
GF_EXPORT const char * gf_sys_localized (const char *sec_name, const char *key_name, const char *def_val)
 
static void gf_sys_refresh_cache ()
 
GF_EXPORT GF_Err gf_sys_init (GF_MemTrackerType mem_tracker_type, const char *profile)
 System setup. More...
 
void gf_net_close_capture ()
 
GF_EXPORT void gf_sys_close ()
 System closing. More...
 
Bool gf_sys_get_rti_os (u32 refresh_time_ms, GF_SystemRTInfo *rti, u32 flags)
 
GF_EXPORT Bool gf_sys_get_rti (u32 refresh_time_ms, GF_SystemRTInfo *rti, u32 flags)
 Gets Run-Time info. More...
 
const char * gf_get_default_cache_directory_ex (Bool do_create)
 
GF_EXPORT const char * gf_get_default_cache_directory ()
 
GF_EXPORT Bool gf_sys_get_battery_state (Bool *onBattery, u32 *onCharge, u32 *level, u32 *batteryLifeTime, u32 *batteryFullLifeTime)
 
GF_EXPORT void gf_net_set_ntp_shift (s32 shift)
 offsets NTP time by a given amount of seconds More...
 
GF_EXPORT void gf_net_get_ntp (u32 *sec, u32 *frac)
 gets NTP time More...
 
GF_EXPORT u64 gf_net_get_ntp_ts ()
 gets NTP time More...
 
GF_EXPORT s32 gf_net_ntp_diff_ms (u64 ntp_a, u64 ntp_b)
 
GF_EXPORT s32 gf_net_get_ntp_diff_ms (u64 ntp)
 
GF_EXPORT u64 gf_net_ntp_add_usec (u64 ntp, s32 usec)
 
GF_EXPORT u64 gf_net_get_ntp_ms ()
 gets NTP time in milliseconds More...
 
GF_EXPORT s32 gf_net_get_timezone ()
 gets timezone adjustment in seconds More...
 
GF_EXPORT Bool gf_net_time_is_dst ()
 gets timezone daylight saving time status More...
 
static time_t gf_mktime_utc (struct tm *tm)
 
GF_EXPORT u64 gf_net_parse_date (const char *val)
 parses date More...
 
GF_EXPORT 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...
 
GF_EXPORT u64 gf_net_ntp_to_utc (u64 ntp)
 converts an ntp timestamp into UTC time in milliseconds More...
 
GF_EXPORT u64 gf_net_get_utc ()
 gets UTC time in milliseconds More...
 
GF_EXPORT GF_Err gf_bin128_parse (const char *string, bin128 value)
 parses 128 bit from string More...
 
GF_EXPORT GF_Err gf_file_load_data_filep (FILE *file, u8 **out_data, u32 *out_size)
 reads a file into memory More...
 
GF_EXPORT GF_Err gf_file_load_data (const char *file_name, u8 **out_data, u32 *out_size)
 reads a file into memory More...
 
GF_EXPORT u32 gf_sys_get_process_id ()
 Gets process ID. More...
 
GF_EXPORT Bool gf_sys_check_process_id (u32 pid)
 Checks a process is valid. More...
 
GF_EXPORT GF_LockStatus gf_sys_create_lockfile (const char *lockname)
 Creates a lock file. More...
 
GF_EXPORT int gf_getch ()
 Portable getch() More...
 
GF_EXPORT Bool gf_read_line_input (char *line, int maxSize, Bool showContent)
 Reads a line of input from stdin. More...
 
GF_EXPORT GF_Err gf_creds_check_password (const char *user, char *password)
 
GF_EXPORT Bool gf_creds_check_membership (const char *username, const char *users, const char *groups)
 

Variables

static u32 sys_start_time = 0
 
static u64 sys_start_time_hr = 0
 
static Bool gpac_disable_rti = GF_FALSE
 
static struct termios t_orig t_new
 
static s32 ch_peek = -1
 
static u32 sys_init = 0
 
static u32 last_update_time = 0
 
static u64 last_process_k_u_time = 0
 
GF_SystemRTInfo the_rti
 
static u64 last_cpu_u_k_time = 0
 
static u64 last_cpu_idle_time = 0
 
static u64 mem_at_startup = 0
 
static u64 memory_at_gpac_startup = 0
 
static u32 gpac_argc = 0
 
const char ** gpac_argv = NULL
 
Boolgpac_argv_state = NULL
 
static Bool gpac_test_mode = GF_FALSE
 
static Bool gpac_old_arch = GF_FALSE
 
static Bool gpac_discard_config = GF_FALSE
 
FILE * gpac_log_file
 
Bool gpac_log_time_start
 
Bool gpac_log_utc_time
 
const char * gpac_log_file_name =NULL
 
Bool gpac_log_dual
 
static Bool gpac_has_global_filter_args =GF_FALSE
 
static Bool gpac_has_global_filter_meta_args =GF_FALSE
 
GF_Mutex * logs_mx = NULL
 
static u32 gpac_quiet = 0
 
char gf_prog_lf = '\r'
 
Bool gpac_use_poll
 
RMT_WSrmtws_handle =NULL
 
GF_List * all_blobs = NULL
 
static GF_Config * gpac_lang_file = NULL
 
static const char * gpac_lang_code = NULL
 
static char szCacheDir [GF_MAX_PATH]
 
static u32 ntp_shift = GF_NTP_SEC_1900_TO_1970
 

Macro Definition Documentation

◆ SLEEP_ABS_SELECT

#define SLEEP_ABS_SELECT   1

◆ GPAC_FULL_VERSION

#define GPAC_FULL_VERSION   GPAC_VERSION "-rev" GPAC_GIT_REVISION

◆ GPAC_COPYRIGHT

#define GPAC_COPYRIGHT   "(c) 2000-2024 Telecom Paris distributed under LGPL v2.1+ - https://gpac.io"

Function Documentation

◆ init_keyboard()

static void init_keyboard ( )
static
+ Here is the caller graph for this function:

◆ close_keyboard()

static void close_keyboard ( Bool  new_line)
static
+ Here is the caller graph for this function:

◆ progress_quiet()

static void progress_quiet ( const void *  cbck,
const char *  title,
u64  done,
u64  total 
)
static
+ Here is the caller graph for this function:

◆ gpac_disable_progress()

void gpac_disable_progress ( )
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ gf_sys_has_filter_global_args()

Bool gf_sys_has_filter_global_args ( )
+ Here is the caller graph for this function:

◆ gf_sys_has_filter_global_meta_args()

Bool gf_sys_has_filter_global_meta_args ( )
+ Here is the caller graph for this function:

◆ gf_blob_get_ex()

GF_EXPORT GF_Err gf_blob_get_ex ( GF_Blob blob,
u8 **  out_data,
u32 out_size,
u32 blob_flags 
)

Retrieves data associated with a blob. If success, gf_blob_release_ex must be called after this

Parameters
blobthe blob object
out_dataif success, set to blob data pointer
out_sizeif success, set to blob data size
blob_flagsif success, set to blob flags - may be NULL
Returns
error code
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ gf_blob_get()

GF_EXPORT GF_Err gf_blob_get ( const char *  blob_url,
u8 **  out_data,
u32 out_size,
u32 blob_flags 
)

Retrieves data associated with a blob url. If success, gf_blob_release must be called after this

Parameters
blob_urlURL of blob object (ie gmem://p)
out_dataif success, set to blob data pointer
out_sizeif success, set to blob data size
blob_flagsif success, set to blob flags - may be NULL
Returns
error code
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ gf_blob_release_ex()

GF_EXPORT GF_Err gf_blob_release_ex ( GF_Blob blob)

Releases blob data

Parameters
blobthe blob object
Returns
error code
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ gf_blob_release()

GF_EXPORT GF_Err gf_blob_release ( const char *  blob_url)

Releases blob data

Parameters
blob_urlURL of blob object (ie gmem://p)
Returns
error code
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ gf_blob_register()

GF_EXPORT char* gf_blob_register ( GF_Blob blob)

Registers a new blob

Parameters
blobblob object
Returns
URL of blob object (ie gmem://p), must be freed by user
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ gf_blob_unregister()

GF_EXPORT void gf_blob_unregister ( GF_Blob blob)

Unegisters a blob. This must be called before destroying a registered blob

Parameters
blobblob object
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ gf_blob_query_range()

GF_EXPORT GF_BlobRangeStatus gf_blob_query_range ( GF_Blob blob,
u64  start_offset,
u32  size 
)

Checks if a given byte range is valid in blob

Parameters
blobblob object
start_offsetstart offset of data to check in blob
sizesize of data to check in blob
Returns
blob range status
+ Here is the caller graph for this function:

◆ gf_init_global_config()

void gf_init_global_config ( const char *  profile)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ gf_uninit_global_config()

void gf_uninit_global_config ( Bool  discard_config)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ gf_sys_get_lang_file()

GF_Config* gf_sys_get_lang_file ( )
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ gf_sys_refresh_cache()

static void gf_sys_refresh_cache ( )
static
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ gf_net_close_capture()

void gf_net_close_capture ( )
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ gf_sys_get_rti_os()

Bool gf_sys_get_rti_os ( u32  refresh_time_ms,
GF_SystemRTInfo rti,
u32  flags 
)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ gf_get_default_cache_directory_ex()

const char* gf_get_default_cache_directory_ex ( Bool  do_create)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ gf_sys_get_battery_state()

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

gets battery state

Parameters
onBatteryset to GF_TRUE if running on battery
onChargeset to GF_TRUE if battery is charging
levelset to battery charge percent
batteryLifeTimeset to battery lifetime
batteryFullLifeTimeset to battery full lifetime
Returns
GF_TRUE if success
+ Here is the caller graph for this function:

◆ gf_mktime_utc()

static time_t gf_mktime_utc ( struct tm *  tm)
static
+ Here is the caller graph for this function:

◆ gf_bin128_parse()

GF_EXPORT GF_Err gf_bin128_parse ( const char *  string,
bin128  value 
)

parses 128 bit from string

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:

◆ gf_getch()

GF_EXPORT int gf_getch ( )

Portable getch()

Returns immediately a typed char from stdin

Returns
the typed char
+ Here is the caller graph for this function:

◆ gf_read_line_input()

GF_EXPORT Bool gf_read_line_input ( char *  line,
int  maxSize,
Bool  showContent 
)

Reads a line of input from stdin.

Parameters
linethe buffer to fill
maxSizethe maximum size of the line to read
showContentboolean indicating if the line read should be printed on stderr or not
Returns
GF_TRUE if some content was read, GF_FALSE otherwise
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

◆ sys_start_time

u32 sys_start_time = 0
static

◆ sys_start_time_hr

u64 sys_start_time_hr = 0
static

◆ gpac_disable_rti

Bool gpac_disable_rti = GF_FALSE
static

◆ t_new

struct termios t_orig t_new
static

◆ ch_peek

s32 ch_peek = -1
static

◆ sys_init

u32 sys_init = 0
static

◆ last_update_time

u32 last_update_time = 0
static

◆ last_process_k_u_time

u64 last_process_k_u_time = 0
static

◆ the_rti

GF_SystemRTInfo the_rti

◆ last_cpu_u_k_time

u64 last_cpu_u_k_time = 0
static

◆ last_cpu_idle_time

u64 last_cpu_idle_time = 0
static

◆ mem_at_startup

u64 mem_at_startup = 0
static

◆ memory_at_gpac_startup

u64 memory_at_gpac_startup = 0
static

◆ gpac_argc

u32 gpac_argc = 0
static

◆ gpac_argv

const char** gpac_argv = NULL

◆ gpac_argv_state

Bool* gpac_argv_state = NULL

◆ gpac_test_mode

Bool gpac_test_mode = GF_FALSE
static

◆ gpac_old_arch

Bool gpac_old_arch = GF_FALSE
static

◆ gpac_discard_config

Bool gpac_discard_config = GF_FALSE
static

◆ gpac_log_file

FILE* gpac_log_file
extern

◆ gpac_log_time_start

Bool gpac_log_time_start
extern

◆ gpac_log_utc_time

Bool gpac_log_utc_time
extern

◆ gpac_log_file_name

const char* gpac_log_file_name =NULL

◆ gpac_log_dual

Bool gpac_log_dual
extern

◆ gpac_has_global_filter_args

Bool gpac_has_global_filter_args =GF_FALSE
static

◆ gpac_has_global_filter_meta_args

Bool gpac_has_global_filter_meta_args =GF_FALSE
static

◆ logs_mx

GF_Mutex* logs_mx = NULL

◆ gpac_quiet

u32 gpac_quiet = 0
static

◆ gf_prog_lf

char gf_prog_lf = '\r'

◆ gpac_use_poll

Bool gpac_use_poll
extern

◆ rmtws_handle

RMT_WS* rmtws_handle =NULL

◆ all_blobs

GF_List* all_blobs = NULL

◆ gpac_lang_file

GF_Config* gpac_lang_file = NULL
static

◆ gpac_lang_code

const char* gpac_lang_code = NULL
static

◆ szCacheDir

char szCacheDir[GF_MAX_PATH]
static

◆ ntp_shift

u32 ntp_shift = GF_NTP_SEC_1900_TO_1970
static