📄 tools.h
字号:
/*! * \brief Log Message Callback * * The gf_log_cbk type is the type for the callback of the \ref gf_log_set_callback function. By default all logs are redirected to stdout * \param cbck Opaque user data. * \param log_level level of the log. This value is not guaranteed in multi-threaded context. * \param log_tool tool emitting the log. This value is not guaranteed in multi-threaded context. * \param fmt message log format. * \param vlist message log param. * */typedef void (*gf_log_cbk)(void *cbck, u32 log_level, u32 log_tool, const char* fmt, va_list vlist);/*! * \brief Log overwrite * * Assigns a user-defined callback for printing log messages. By default all logs are redirected to stdout * \param usr_cbk Opaque user data * \param cbk callback log function * \return previous callback function*/gf_log_cbk gf_log_set_callback(void *usr_cbk, gf_log_cbk cbk);/*! \cond DUMMY_DOXY_SECTION*/#ifndef GPAC_DISABLE_LOG/*note: to turn log on, change to GPAC_ENABLE_LOG to turn log off, change to GPAC_DISABLE_LOG this is needed by configure+sed to modify this file directly*/#define GPAC_ENABLE_LOG#endif/*! \endcond*//*this is all a bit ugly, but most compilers don't properly handle variadic macros...*/void gf_log(const char *fmt, ...);void gf_log_lt(u32 ll, u32 lt);u32 gf_log_get_level();u32 gf_log_get_tools();#ifdef GPAC_DISABLE_LOG#define GF_LOG(_ll, _lm, __args) #else/*! * \brief Message logging * \hideinitializer * * Macro for logging messages. Usage is GF_LOG(log_lev, log_module, (fmt, ...)). The log function is only called if log filtering allows it. This avoids fetching logged parameters when the tool is not being logged.*/#define GF_LOG(_log_level, _log_tools, __args) if ((gf_log_get_level() >= (_log_level)) && (gf_log_get_tools() & (_log_tools))) { gf_log_lt(_log_level, _log_tools); gf_log __args ;}#endif/*! @} *//*! \addtogroup tools_grp * @{ *//*! * \brief PseudoRandom Integer Generation Initialization * * Sets the starting point for generating a series of pseudorandom integers. * \param Reset Re-initializes the random number generator*/void gf_rand_init(Bool Reset);/*! * \brief PseudoRandom Integer Generation * * Returns a pseudorandom integer.*/u32 gf_rand();/*! * \brief user name * * Gets current user (login) name.*/void gf_get_user_name(char *buf, u32 buf_size);/*! * \brief Directory Enumeration Callback * * The gf_enum_dir_item type is the type for the callback of the \ref gf_enum_directory function * \param cbck Opaque user data. * \param item_name File or directory name. * \param item_path File or directory full path and name from filesystem root. * \return 1 to abort enumeration, 0 to continue enumeration. * */typedef Bool (*gf_enum_dir_item)(void *cbck, char *item_name, char *item_path);/*! * \brief Directory enumeration * * Enumerates a directory content. Feedback is provided by the enum_dir_item function * \param dir Directory to enumerate * \param enum_directory If set, only directories will be enumerated, otherwise only files are. * \param enum_dir \ref gf_enum_dir_item callback function for enumeration. * \param cbck Opaque user data passed to callback function. * \param filter optional filter for file extensions. If a file extension without the dot '.' character is not found in the * filter the file will be skipped.*/GF_Err gf_enum_directory(const char *dir, Bool enum_directory, gf_enum_dir_item enum_dir, void *cbck, const char *filter);/*! * \brief File Deletion * * Deletes a file from the disk. * \param fileName absolute name of the file or name relative to the current working directory.*/void gf_delete_file(char *fileName);/*! * \brief File Deletion * * Creates a new temporary file in binary mode * \return stream handle to the new file ressoucre */FILE *gf_temp_file_new();/*! * \brief Progress formatting * * Signals progress in GPAC's operations. Note that progress signaling with this function is not thread-safe, the main purpose is to use it for authoring tools only. * \param title title string of the progress, or NULL for no progress * \param done Current amount performed of the action. * \param total Total amount of the action. */void gf_set_progress(char *title, u32 done, u32 total);/*! * \brief Progress Callback * * The gf_on_progress_cbk type is the type for the callback of the \ref gf_set_progress_callback function * \param cbck Opaque user data. * \param title preogress title. * \param done Current amount performed of the action * \param total Total amount of the action. * */typedef void (*gf_on_progress_cbk)(void *cbck, char *title, u32 done, u32 total);/*! * \brief Progress overwriting * * Iverwrites the progress signaling function by a user-defined one. * \param user_cbk Opaque user data * \param prog_cbk new callback function to use. Passing NULL restore default GPAC stdout notification. */void gf_set_progress_callback(void *user_cbk, gf_on_progress_cbk prog_cbk);/*! * \brief Prompt checking * * Checks if a character is pending in the prompt buffer. * \return 1 if a character is ready to be fetched, 0 otherwise. * \note Function not available under WindowsCE nor SymbianOS*/Bool gf_prompt_has_input();/*! * \brief Prompt character flush * * Returns the current character entered at prompt if any. * \return value of the character. * \note Function not available under WindowsCE nor SymbianOS*/char gf_prompt_get_char();/*! * \brief turns prompt echo on/off * * Turns the prompt character echo on/off - this is usefull when entering passwords. * \param echo_off indicates whether echo should be turned on or off. * \note Function not available under WindowsCE nor SymbianOS*/void gf_prompt_set_echo_off(Bool echo_off);/*! *\addtogroup cpu_grp Time tools *\ingroup utils_grp *\brief System time and CPU functions * *This section documents time functionalities and CPU management in GPAC. * @{ *//*! * \brief System setup * * 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. */void gf_sys_init();/*! * \brief System closing * * 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. */void gf_sys_close();/*! * \brief System clock query * * Gets the system clock time. * \return System clock value since initialization in milliseconds. */u32 gf_sys_clock();/*! * \brief Sleeps thread/process * * Locks calling thread/process execution for a given time. * \param ms Amount of time to sleep in milliseconds. */void gf_sleep(u32 ms);/*!\brief run-time system info object * *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).*/typedef struct{ /*!start of the sampling period*/ u32 sampling_instant; /*!duration of the sampling period*/ u32 sampling_period_duration; /*!total amount of time (User+kernel) spent in CPU for all processes as evaluated at the end of the sampling period*/ u32 total_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 process_cpu_time; /*!amount of time (User+kernel) spent in CPU for all processes during the sampling period*/ u32 total_cpu_time_diff; /*!total amount of time (User+kernel) spent in CPU for the calling process during the sampling period*/ u32 process_cpu_time_diff; /*!total amount of idle time during the sampling period.*/ u32 cpu_idle_time; /*!percentage (from 0 to 100) of CPU usage during the sampling period.*/ u32 total_cpu_usage; /*!percentage (from 0 to 100) of the CPU usage by the calling process during the sampling period.*/ u32 process_cpu_usage; /*!calling process ID*/ u32 pid; /*!calling process thread count if known*/ u32 thread_count; /*!size of calling process allocated heaps*/ u64 process_memory; /*!total physical memory in system*/ u64 physical_memory; /*!available physical memory in system*/ u64 physical_memory_avail; /*!total memory currently allocated by gpac*/ u64 gpac_memory;} GF_SystemRTInfo;/*! * Selection flags for run-time info retrieval * \hideinitializer */enum{ /*!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_ALL_PROCESSES_TIMES = 1, /*!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_PROCESS_MEMORY = 1<<1, /*!Indicates that only system memory should be fetched. When set, all refreshing info is ignored*/ GF_RTI_SYSTEM_MEMORY_ONLY = 1<<2,};/*! * \brief Gets Run-Time info * * Gets CPU and memory usage info for the calling process and the system. Information gathering * is controled through timeout values. * \param refresh_time_ms refresh time period in milliseconds. If the last sampling was done less than this period ago, the function aborts. * \param rti holder to the run-time info structure to update. * \param flags specify which info is to be retrieved. * \return 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. */Bool gf_sys_get_rti(u32 refresh_time_ms, GF_SystemRTInfo *rti, u32 flags);Bool gf_sys_get_battery_state(Bool *onBattery, u32 *state, u32*level);/*! @} *//*! @} */#ifdef __cplusplus}#endif#endif /*_GF_CORE_H_*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -