libgpac
Documentation of the core library of GPAC
Library configuration

Library configuration. More...

+ Collaboration diagram for Library configuration:

Typedefs

typedef void(* gf_rmt_user_callback) (void *udta, const char *text)
 

Enumerations

enum  GF_MemTrackerType { GF_MemTrackerNone = 0 , GF_MemTrackerSimple , GF_MemTrackerBackTrace }
 
enum  GF_ConsoleCodes {
  GF_CONSOLE_RESET =0 , GF_CONSOLE_RED , GF_CONSOLE_GREEN , GF_CONSOLE_BLUE ,
  GF_CONSOLE_YELLOW , GF_CONSOLE_CYAN , GF_CONSOLE_WHITE , GF_CONSOLE_MAGENTA ,
  GF_CONSOLE_CLEAR , GF_CONSOLE_SAVE , GF_CONSOLE_RESTORE , GF_CONSOLE_BOLD = 1<<16 ,
  GF_CONSOLE_ITALIC = 1<<17 , GF_CONSOLE_UNDERLINED = 1<<18 , GF_CONSOLE_STRIKE = 1<<19
}
 

Functions

GF_Err gf_sys_init (GF_MemTrackerType mem_tracker_type, const char *profile)
 System setup. More...
 
void gf_sys_close ()
 System closing. More...
 
GF_Err gf_sys_set_args (s32 argc, const char **argv)
 System arguments. More...
 
u32 gf_sys_get_argc ()
 Get number of args. More...
 
const char ** gf_sys_get_argv ()
 Get program arguments. More...
 
const char * gf_sys_get_arg (u32 arg)
 Get number of args. More...
 
const char * gf_sys_find_global_arg (const char *arg)
 Locate a global filter arg. More...
 
void gf_sys_mark_arg_used (s32 arg_idx, Bool used)
 Mark arg as used. More...
 
Bool gf_sys_is_arg_used (s32 arg_idx)
 Check if arg is marked as used. More...
 
Bool gf_sys_is_test_mode ()
 checks if test mode is enabled More...
 
Bool gf_sys_old_arch_compat ()
 checks if compatibility with old arch is enabled More...
 
u32 gf_sys_is_quiet ()
 checks if running in quiet mode More...
 
const char * gf_sys_features (Bool disabled)
 
GF_Err gf_sys_profiler_set_callback (void *udta, gf_rmt_user_callback rmt_usr_cbk)
 
GF_Err gf_sys_profiler_log (const char *msg)
 
GF_Err gf_sys_profiler_send (const char *msg)
 
void gf_sys_profiler_enable_sampling (Bool enable)
 
Bool gf_sys_profiler_sampling_enabled ()
 
void gf_sys_set_console_code (FILE *std, GF_ConsoleCodes code)
 
const char * gf_opts_get_key (const char *secName, const char *keyName)
 
GF_Err gf_opts_set_key (const char *secName, const char *keyName, const char *keyValue)
 
void gf_opts_del_section (const char *secName)
 
u32 gf_opts_get_section_count ()
 
const char * gf_opts_get_section_name (u32 secIndex)
 
u32 gf_opts_get_key_count (const char *secName)
 
const char * gf_opts_get_key_name (const char *secName, u32 keyIndex)
 
Bool gf_opts_get_bool (const char *secName, const char *keyName)
 
u32 gf_opts_get_int (const char *secName, const char *keyName)
 
const char * gf_opts_get_key_restricted (const char *secName, const char *keyName)
 
GF_Err gf_opts_discard_changes ()
 
GF_Err gf_opts_save ()
 
const char * gf_opts_get_filename ()
 
Bool gf_opts_default_shared_directory (char *path_buffer)
 
GF_Err gf_creds_check_password (const char *username, char *password)
 
Bool gf_creds_check_membership (const char *username, const char *users, const char *groups)
 

Detailed Description

These functions are used to initialize, shutdown and configure libgpac.

The library shall be initialized using gf_sys_init and terminated using gf_sys_close

The library can usually be configured from command line if your program uses gf_sys_set_args.

The library can also be configured from your program using gf_opts_set_key and related functions right after initializing the library.

For more information on configuration options, see

gpac -hx core

and https://wiki.gpac.io/Filters/core_options

For more information on filters configuration options, see https://wiki.gpac.io/Filters/Filters

Typedef Documentation

◆ gf_rmt_user_callback

typedef void(* gf_rmt_user_callback) (void *udta, const char *text)

callback function for remotery profiler

Parameters
udtauser data passed by gf_sys_profiler_set_callback
textstring sent by webbrowser client

Enumeration Type Documentation

◆ GF_MemTrackerType

Selection flags for memory tracker

Enumerator
GF_MemTrackerNone 

No memory tracking

GF_MemTrackerSimple 

Memory tracking without backtrace

GF_MemTrackerBackTrace 

Memory tracking with backtrace

◆ GF_ConsoleCodes

GPAC Log tools

Describes the color code for console print

Enumerator
GF_CONSOLE_RESET 

reset color

GF_CONSOLE_RED 

set text to red

GF_CONSOLE_GREEN 

set text to green

GF_CONSOLE_BLUE 

set text to blue

GF_CONSOLE_YELLOW 

set text to yellow

GF_CONSOLE_CYAN 

set text to cyan

GF_CONSOLE_WHITE 

set text to white

GF_CONSOLE_MAGENTA 

set text to magenta

GF_CONSOLE_CLEAR 

reset all console text

GF_CONSOLE_SAVE 

save console state

GF_CONSOLE_RESTORE 

restore console state

GF_CONSOLE_BOLD 

set text to bold modifier

GF_CONSOLE_ITALIC 

set text to italic

GF_CONSOLE_UNDERLINED 

set text to underlined

GF_CONSOLE_STRIKE 

set text to strikethrough

Function Documentation

◆ gf_sys_init()

GF_Err gf_sys_init ( GF_MemTrackerType  mem_tracker_type,
const char *  profile 
)

Inits system tools (GPAC global config, high-resolution clock if any, CPU usage manager, random number, ...).

You MUST call this function before calling any libgpac function, typically only once at startup.

The profile allows using a different global config file than the default, and may be a name (without / or \) or point to an existing config file.

Note
This can be called several times but only the first call will result in system setup.
Parameters
mem_tracker_typememory tracking mode
profilename of the profile to load, NULL for default.
Returns
Error code if any
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ gf_sys_close()

void gf_sys_close ( )

Closes allocated system resources opened by gf_sys_init.

Note
This can be called several times but systems resources will be closed when no more users are accounted for.

When JavaScript APIs are loaded, the JS runtime is destroyed in this function call. If your application needs to reload GPAC a second time after this, you MUST prevent JS runtime destruction otherwise the application will crash due to static JS class definitions refering to freed memory. To prevent destruction, make sure you have called

gf_opts_set_key("temp", "static-jsrt", "true");
GF_Err gf_opts_set_key(const char *secName, const char *keyName, const char *keyValue)
Definition: os_config_init.c:1338

before calling gf_sys_close. For example:

//run your code, eg a filter session
//prevent JSRT destruction
gf_opts_set_key("temp", "static-jsrt", "true");
//The JSRT is still valid
//run your code, eg another filter session
//do NOT prevent JSRT, parent app will exit after this call
void gf_sys_close()
System closing.
Definition: os_divers.c:1630
GF_Err gf_sys_init(GF_MemTrackerType mem_tracker_type, const char *profile)
System setup.
Definition: os_divers.c:1491
@ GF_MemTrackerNone
Definition: tools.h:458
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ gf_sys_set_args()

GF_Err gf_sys_set_args ( s32  argc,
const char **  argv 
)

Sets the user app arguments (used by GUI mode)

Parameters
argcNumber of arguments
argvArray of arguments - the first string is ignored (considered to be the executable name)
Returns
error code if any, GF_OK otherwise
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ gf_sys_get_argc()

u32 gf_sys_get_argc ( )

Gets the number of argument of the user application if any

Returns
number of argument of the user application
+ Here is the caller graph for this function:

◆ gf_sys_get_argv()

const char** gf_sys_get_argv ( )

Gets the arguments of the user application if any

Returns
argument of the user application
+ Here is the caller graph for this function:

◆ gf_sys_get_arg()

const char* gf_sys_get_arg ( u32  arg)

Gets the number of argument of the user application if any

Parameters
argIndex of argument to retrieve
Returns
number of argument of the user application
+ Here is the caller graph for this function:

◆ gf_sys_find_global_arg()

const char* gf_sys_find_global_arg ( const char *  arg)

Looks for a filter option specified as global argument

Parameters
argname of option to search, without "--" or "-+" specififers
Returns
argument value string, empty string for booleans or NULL if not found
+ Here is the caller graph for this function:

◆ gf_sys_mark_arg_used()

void gf_sys_mark_arg_used ( s32  arg_idx,
Bool  used 
)

Marks the argument at given index as used. By default all args are marked as not used when assigning args

Parameters
arg_idxIndex of argument to mark
usedflag to set
+ Here is the caller graph for this function:

◆ gf_sys_is_arg_used()

Bool gf_sys_is_arg_used ( s32  arg_idx)

Marks the argument at given index as used

Parameters
arg_idxIndex of argument to mark
Returns
used flag of the arg
+ Here is the caller graph for this function:

◆ gf_sys_is_test_mode()

Bool gf_sys_is_test_mode ( )

Checks if test mode is enabled (no date nor GPAC version should be written).

Returns
GF_TRUE if test mode is enabled, GF_FALSE otherwise.
+ Here is the caller graph for this function:

◆ gf_sys_old_arch_compat()

Bool gf_sys_old_arch_compat ( )

Checks if compatibility with old arch is enabled - this function will be removed when master will be moved to filters branch

Returns
GF_TRUE if old arch compat is enabled, GF_FALSE otherwise.
+ Here is the caller graph for this function:

◆ gf_sys_is_quiet()

u32 gf_sys_is_quiet ( )

Checks if quiet mode is enabled

Returns
2 if quiet mode is enabled, 1 if quiet mode not enabled but progress is disabled, 0 otherwise.
+ Here is the caller graph for this function:

◆ gf_sys_features()

const char* gf_sys_features ( Bool  disabled)

gets GPAC feature list in this GPAC build

Parameters
disabledif GF_TRUE, gets disabled features, otherwise gets enabled features
Returns
the list of features.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ gf_sys_profiler_set_callback()

GF_Err gf_sys_profiler_set_callback ( void *  udta,
gf_rmt_user_callback  rmt_usr_cbk 
)

Enables remotery profiler callback. If remotery is enabled, commands sent via webbrowser client will be forwarded to the callback function specified

Parameters
udtauser data
rmt_usr_cbkcallback function
Returns
GF_OK if success, GF_BAD_PARAM if profiler is not running, GF_NOT_SUPPORTED if profiler not supported
+ Here is the caller graph for this function:

◆ gf_sys_profiler_log()

GF_Err gf_sys_profiler_log ( const char *  msg)

Sends a log message to remotery web client

Parameters
msgtext message to send. The message format should be json
Returns
GF_OK if success, GF_BAD_PARAM if profiler is not running, GF_NOT_SUPPORTED if profiler not supported

◆ gf_sys_profiler_send()

GF_Err gf_sys_profiler_send ( const char *  msg)

Sends a message to remotery web client

Parameters
msgtext message to send. The message format should be json
Returns
GF_OK if success, GF_BAD_PARAM if profiler is not running, GF_NOT_SUPPORTED if profiler not supported

◆ gf_sys_profiler_enable_sampling()

void gf_sys_profiler_enable_sampling ( Bool  enable)

Enables sampling times in RMT

Parameters
enableif GF_TRUE, sampling will be enabled, otherwise disabled

◆ gf_sys_profiler_sampling_enabled()

Bool gf_sys_profiler_sampling_enabled ( )

Checks if sampling is enabled in RMT. Sampling is by default enabled when enabling remotery

Returns
GF_TRUE if sampling is enabled, GF_FALSE otherwise
+ Here is the caller graph for this function:

◆ gf_sys_set_console_code()

void gf_sys_set_console_code ( FILE *  std,
GF_ConsoleCodes  code 
)

sets console code

Parameters
stdthe output stream (stderr or stdout)
codethe console code to set
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ gf_opts_get_key()

const char* gf_opts_get_key ( const char *  secName,
const char *  keyName 
)

gets a global config key value from its section and name.

Parameters
secNamethe desired key parent section name
keyNamethe desired key name
Returns
the desired key value if found, NULL otherwise.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ gf_opts_set_key()

GF_Err gf_opts_set_key ( const char *  secName,
const char *  keyName,
const char *  keyValue 
)

sets a global config key value from its section and name.

Parameters
secNamethe desired key parent section name
keyNamethe desired key name
keyValuethe desired key value
Note
this will also create both section and key if they are not found in the configuration file
Returns
error if any
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ gf_opts_del_section()

void gf_opts_del_section ( const char *  secName)

removes all entries in the given section of the global config

Parameters
secNamethe target section
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ gf_opts_get_section_count()

u32 gf_opts_get_section_count ( )

gets the number of sections in the global config

Returns
the number of sections
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ gf_opts_get_section_name()

const char* gf_opts_get_section_name ( u32  secIndex)

gets a section name based on its index in the global config

Parameters
secIndex0-based index of the section to query
Returns
the section name if found, NULL otherwise
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ gf_opts_get_key_count()

u32 gf_opts_get_key_count ( const char *  secName)

gets the number of keys in a section of the global config

Parameters
secNamethe target section
Returns
the number of keys in the section
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ gf_opts_get_key_name()

const char* gf_opts_get_key_name ( const char *  secName,
u32  keyIndex 
)

gets the number of keys in a section of the global config

Parameters
secNamethe target section
keyIndex0-based index of the key in the section
Returns
the key name if found, NULL otherwise
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ gf_opts_get_bool()

Bool gf_opts_get_bool ( const char *  secName,
const char *  keyName 
)

gets a global config boolean value from its section and name.

Parameters
secNamethe desired key parent section name
keyNamethe desired key name
Returns
the desired key value if found, GF_FALSE otherwise.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ gf_opts_get_int()

u32 gf_opts_get_int ( const char *  secName,
const char *  keyName 
)

gets a global config integer value from its section and name.

Parameters
secNamethe desired key parent section name
keyNamethe desired key name
Returns
the desired key value if found, 0 otherwise.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ gf_opts_get_key_restricted()

const char* gf_opts_get_key_restricted ( const char *  secName,
const char *  keyName 
)

gets a global config key value from its section and name.

Parameters
secNamethe desired key parent section name
keyNamethe desired key name
Returns
the desired key value if found and if the key is not restricted, NULL otherwise.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ gf_opts_discard_changes()

GF_Err gf_opts_discard_changes ( )

Do not save modification to global options

Returns
error code
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ gf_opts_save()

GF_Err gf_opts_save ( )

Force immediate write of config

Returns
error code
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ gf_opts_get_filename()

const char* gf_opts_get_filename ( )

Returns file name of global config

Returns
file name of global config or NULL if libgpac is not initialized
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ gf_opts_default_shared_directory()

Bool gf_opts_default_shared_directory ( char *  path_buffer)

Gets GPAC shared directory (gui, shaders, etc ..)

Parameters
path_bufferGF_MAX_PATH buffer to store output
Returns
GF_TRUE if success, GF_FALSE otherwise
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ gf_creds_check_password()

GF_Err gf_creds_check_password ( const char *  username,
char *  password 
)

Checks given user and password are valid

Parameters
usernameuser name
passwordpassword
Returns
GF_OK if success, GF_NOT_FOUND if no such user or GF_AUTHENTICATION_FAILURE if wrong password
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ gf_creds_check_membership()

Bool gf_creds_check_membership ( const char *  username,
const char *  users,
const char *  groups 
)

Checks given user belongs to list of users or groups.

Parameters
usernameuser name
userscomma-seprated list of users to check, may be NULL
groupscomma-seprated list of groups to check, may be NULL
Returns
GF_TRUE if success, GF_FALSE otherwise
+ Here is the call graph for this function:
+ Here is the caller graph for this function: