OSDN Git Service

add tstools.
[rec10/rec10-git.git] / tstools / DtsEdit / src / gpac / tools.h
1 /*\r
2  *                      GPAC - Multimedia Framework C SDK\r
3  *\r
4  *                      Copyright (c) Jean Le Feuvre 2000-2005 \r
5  *                                      All rights reserved\r
6  *\r
7  *  This file is part of GPAC / common tools sub-project\r
8  *\r
9  *  GPAC is free software; you can redistribute it and/or modify\r
10  *  it under the terms of the GNU Lesser General Public License as published by\r
11  *  the Free Software Foundation; either version 2, or (at your option)\r
12  *  any later version.\r
13  *   \r
14  *  GPAC is distributed in the hope that it will be useful,\r
15  *  but WITHOUT ANY WARRANTY; without even the implied warranty of\r
16  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
17  *  GNU Lesser General Public License for more details.\r
18  *   \r
19  *  You should have received a copy of the GNU Lesser General Public\r
20  *  License along with this library; see the file COPYING.  If not, write to\r
21  *  the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. \r
22  *\r
23  */\r
24 \r
25 #ifndef _GF_TOOLS_H_\r
26 #define _GF_TOOLS_H_\r
27 \r
28 #ifdef __cplusplus\r
29 extern "C" {\r
30 #endif\r
31 \r
32 #include <gpac/setup.h>\r
33 \r
34 \r
35 /*! \file "gpac/tools.h"\r
36  *      \brief Base definitions and functions of GPAC.\r
37  *\r
38  * This file contains basic functions and core definitions of the GPAC framework. This file is\r
39  * usually included by all GPAC header files since it contains the error definitions.\r
40 */\r
41 \r
42 /*! \defgroup utils_grp utils\r
43  *      You will find in this module the documentation of all tools used in GPAC.\r
44 */\r
45 \r
46 /*! \addtogroup tools_grp base utils\r
47  *      \ingroup utils_grp\r
48  *      \brief Base definitions and functions of GPAC.\r
49  *\r
50  *      This section documents some very basic functions and core definitions of the GPAC framework.\r
51  *      @{\r
52  */\r
53 \r
54 /*!\r
55  *      \brief GPAC Version\r
56  *      \hideinitializer\r
57  *\r
58  *      Macro giving GPAC version expressed as a printable string\r
59 */\r
60 /*KEEP SPACE SEPARATORS FOR MAKE / GREP (SEE MAIN MAKEFILE)!!!, and NO SPACE in GPAC_VERSION for proper install*/\r
61 #define GPAC_VERSION       "0.4.6-DEV"\r
62 \r
63 #define GPAC_BUILD_NUMBER       "1"\r
64 #define GPAC_FULL_VERSION       GPAC_VERSION" (build "GPAC_BUILD_NUMBER")"\r
65 \r
66 /*!\r
67  *      \brief GPAC Version\r
68  *      \hideinitializer\r
69  *\r
70  *      Macro giving GPAC version expressed as an integer, where version X.Y.Z is coded as 0x00XXYYZZ\r
71 */\r
72 #define GPAC_VERSION_INT        0x00000406\r
73 \r
74 /*!\r
75  *      \brief Memory allocation\r
76  *      \hideinitializer\r
77  *\r
78  *      Macro allocating memory and zero-ing it\r
79 */\r
80 #define GF_SAFEALLOC(__ptr, __struct) { __ptr = (__struct *) malloc(sizeof(__struct)); if (__ptr) memset((void *) __ptr, 0, sizeof(__struct)); }\r
81 \r
82 /*!\r
83  *      \brief 4CC Formatting\r
84  *      \hideinitializer\r
85  *\r
86  *      Macro formating a 4-character code (or 4CC) "abcd" as 0xAABBCCDD\r
87 */\r
88 #define GF_4CC(a,b,c,d) (((a)<<24)|((b)<<16)|((c)<<8)|(d))\r
89 /*!\r
90  *      \brief 4CC Printing\r
91  *\r
92  *      returns a 4CC printable form\r
93 */\r
94 const char *gf_4cc_to_str(u32 type);\r
95 \r
96 /*!\r
97  *      \brief large file opening\r
98  *\r
99  *      Opens a large file (>4GB)\r
100  *      \param file_name Same semantics as fopen\r
101  *      \param mode Same semantics as fopen\r
102  *      \return stream handle of the file object\r
103  *      \note You only need to call this function if you're suspecting the file to be a large one (usually only media files), otherwise use regular stdio.\r
104 */\r
105 FILE *gf_f64_open(const char *file_name, const char *mode);\r
106 /*!\r
107  *      \brief large file position query\r
108  *\r
109  *      Queries the current read/write position in a large file\r
110  *      \param f Same semantics as ftell\r
111  *      \return position in the file\r
112  *      \note You only need to call this function if you're suspecting the file to be a large one (usually only media files), otherwise use regular stdio.\r
113 */\r
114 u64 gf_f64_tell(FILE *f);\r
115 /*!\r
116  *      \brief large file seeking\r
117  *\r
118  *      Seeks the current read/write position in a large file\r
119  *      \param f Same semantics as fseek\r
120  *      \param pos Same semantics as fseek\r
121  *      \param whence Same semantics as fseek\r
122  *      \return new position in the file\r
123  *      \note You only need to call this function if you're suspecting the file to be a large one (usually only media files), otherwise use regular stdio.\r
124 */\r
125 u64 gf_f64_seek(FILE *f, s64 pos, s32 whence);\r
126 \r
127 /*! @} */\r
128 \r
129 \r
130 /*! \addtogroup errors_grp error codes\r
131  *      \ingroup utils_grp\r
132  *      \brief Errors used in GPAC.\r
133  *\r
134  *      This section documents all error codes used in the GPAC framework. Most of the GPAC's functions will use these as \r
135  * return values, and some of these errors are also used for state communication with the different modules of the framework.\r
136  *      @{\r
137  */\r
138 \r
139 /*!\r
140  * GPAC Error\r
141  *      \hideinitializer\r
142  *\r
143  *      positive values are warning and info, 0 means no error and negative values are errors\r
144  */\r
145 typedef enum\r
146 {\r
147         /*!Message from any scripting engine used in the presentation (ECMAScript, MPEG-J, ...) (Info).*/\r
148         GF_SCRIPT_INFO                                          = 3,\r
149         /*!Indicates an data frame has several AU packed (not MPEG-4 compliant). This is used by decoders to force \r
150         multiple decoding of the same data frame (Info).*/\r
151         GF_PACKED_FRAMES                                        = 2,\r
152         /*!Indicates the end of a stream or of a file (Info).*/\r
153         GF_EOS                                                          = 1,\r
154         /*!\r
155         \n\n\r
156         */\r
157         /*!Operation success (no error).*/\r
158         GF_OK                                                           = 0,\r
159         /*!\n*/\r
160         /*!One of the input parameter is not correct or cannot be used in the current operating mode of the framework.*/\r
161         GF_BAD_PARAM                                                    = -1,\r
162         /*! Memory allocation failure.*/\r
163         GF_OUT_OF_MEM                                                   = -2,\r
164         /*! Input/Output failure (disk access, system call failures)*/\r
165         GF_IO_ERR                                                               = -3,\r
166         /*! The desired feature or operation is not supported by the framework*/\r
167         GF_NOT_SUPPORTED                                                = -4,\r
168         /*! Input data has been corrupted*/\r
169         GF_CORRUPTED_DATA                                               = -5,\r
170         /*! A modification was attempted on a scene node which could not be found*/\r
171         GF_SG_UNKNOWN_NODE                                              = -6,\r
172         /*! The PROTO node interface does not match the nodes using it*/\r
173         GF_SG_INVALID_PROTO                                             = -7,\r
174         /*! An error occured in the scripting engine*/\r
175         GF_SCRIPT_ERROR                                                 = -8,\r
176         /*! Buffer is too small to contain decoded data. Decoders shall use this error whenever they need to resize their output memory buffers*/\r
177         GF_BUFFER_TOO_SMALL                                             = -9,\r
178         /*! Bitstream is not compliant to the specfication it refers to*/\r
179         GF_NON_COMPLIANT_BITSTREAM                              = -10,\r
180         /*! No decoders could be found to handle the desired media type*/\r
181         GF_CODEC_NOT_FOUND                                              = -11,\r
182         /*! The URL is not properly formatted or cannot be found*/\r
183         GF_URL_ERROR                                                    = -12,\r
184         /*! An service error has occured at the local side*/\r
185         GF_SERVICE_ERROR                                                = -13,\r
186         /*! A service error has occured at the remote (server) side*/\r
187         GF_REMOTE_SERVICE_ERROR                                 = -14,\r
188         /*! The desired stream could not be found in the service*/\r
189         GF_STREAM_NOT_FOUND                                             = -15,\r
190         /*! The IsoMedia file is not a valid one*/\r
191         GF_ISOM_INVALID_FILE                                    = -20,\r
192         /*! The IsoMedia file is not complete. Either the file is being downloaded, or it has been truncated*/\r
193         GF_ISOM_INCOMPLETE_FILE                                 = -21,\r
194         /*! The media in this IsoMedia track is not valid (usually due to a broken stream description)*/\r
195         GF_ISOM_INVALID_MEDIA                                   = -22,\r
196         /*! The requested operation cannot happen in the current opening mode of the IsoMedia file*/\r
197         GF_ISOM_INVALID_MODE                                    = -23,\r
198         /*! This IsoMedia track refers to media outside the file in an unknown way*/\r
199         GF_ISOM_UNKNOWN_DATA_REF                                = -24,\r
200 \r
201         /*! An invalid MPEG-4 Object Descriptor was found*/\r
202         GF_ODF_INVALID_DESCRIPTOR                               = -30,\r
203         /*! An MPEG-4 Object Descriptor was found or added to a forbidden descriptor*/\r
204         GF_ODF_FORBIDDEN_DESCRIPTOR                             = -31,\r
205         /*! An invalid MPEG-4 BIFS command was detected*/\r
206         GF_ODF_INVALID_COMMAND                                  = -32,\r
207         /*! The scene has been encoded using an unknown BIFS version*/\r
208         GF_BIFS_UNKNOWN_VERSION                                 = -33,\r
209 \r
210         /*! The remote IP address could not be solved*/\r
211         GF_IP_ADDRESS_NOT_FOUND                                 = -40,\r
212         /*! The connection to the remote peer has failed*/\r
213         GF_IP_CONNECTION_FAILURE                                = -41,\r
214         /*! The network operation has failed*/\r
215         GF_IP_NETWORK_FAILURE                                   = -42,\r
216         /*! The network connection has been closed*/\r
217         GF_IP_CONNECTION_CLOSED                                 = -43,\r
218         /*! The network operation has failed because no data is available*/\r
219         GF_IP_NETWORK_EMPTY                                             = -44,\r
220         /*! The network operation has been discarded because it would be a blocking one*/\r
221         GF_IP_SOCK_WOULD_BLOCK                                  = -45,\r
222         /*! UDP connection did not receive any data at all. Signaled by client services to reconfigure network if possible*/\r
223         GF_IP_UDP_TIMEOUT                                               = -46,\r
224 \r
225         /*! Authentication with the remote host has failed*/\r
226         GF_AUTHENTICATION_FAILURE                               = -50,\r
227         /*! Script not ready for playback */\r
228         GF_SCRIPT_NOT_READY                                             = -51,\r
229 } GF_Err;\r
230 \r
231 /*!\r
232  *      \brief Error Printing\r
233  *\r
234  *      Returns a printable version of a given error\r
235  *      \param e Error code requested\r
236  *      \return String representing the error\r
237 */\r
238 const char *gf_error_to_string(GF_Err e);\r
239 \r
240 /*! @} */\r
241 \r
242 /*! \addtogroup log_grp logging tools\r
243  *      \ingroup utils_grp\r
244  *      @{\r
245  */\r
246 \r
247 /*!\r
248  * GPAC Log Levels\r
249  *      \hideinitializer\r
250  * \r
251  * These levels describes messages priority used when filtering logs\r
252  */\r
253 enum\r
254 {\r
255         /*! Log message describes an error*/\r
256         GF_LOG_ERROR = 1,\r
257         /*! Log message describes a warning*/\r
258         GF_LOG_WARNING,\r
259         /*! Log message is informational (state, etc..)*/\r
260         GF_LOG_INFO,\r
261         /*! Log message is a debug info*/\r
262         GF_LOG_DEBUG,\r
263 };\r
264 \r
265 /*!\r
266  *      \brief Log level assignment\r
267  *\r
268  * Sets the level used for log filtering. By default no log is performed\r
269  *      \param level log level used.\r
270  *\r
271  */\r
272 void gf_log_set_level(u32 level);\r
273 \r
274 \r
275 /*!\r
276  * GPAC Log tools\r
277  *      \hideinitializer\r
278  *\r
279  * These flags describes which sub-part of GPAC generates the log and are used when filtering logs\r
280  */\r
281 enum\r
282 {\r
283         /*! Log message from the core library (init, threads, network calls, etc)*/\r
284         GF_LOG_CORE = 1,\r
285         /*! Log message from a raw media parser (BIFS, LASeR, A/V formats)*/\r
286         GF_LOG_CODING= 1<<1,\r
287         /*! Log message from a bitstream parser (IsoMedia, MPEG-2 TS, OGG, ...)*/\r
288         GF_LOG_CONTAINER = 1<<2,\r
289         /*! Log message from the network/service stack (messages & co)*/\r
290         GF_LOG_NETWORK = 1<<3,\r
291         /*! Log message from the RTP/RTCP stack (TS info) and packet structure & hinting (debug)*/\r
292         GF_LOG_RTP = 1<<4,\r
293         /*! Log message from authoring subsystem (file manip, import/export)*/\r
294         GF_LOG_AUTHOR = 1<<5,\r
295         /*! Log message from the sync layer of the terminal*/\r
296         GF_LOG_SYNC = 1<<6,\r
297         /*! Log message from a codec*/\r
298         GF_LOG_CODEC = 1<<7,\r
299         /*! Log message from any XML parser (context loading, etc)*/\r
300         GF_LOG_PARSER = 1<<8,\r
301         /*! Log message from the terminal/compositor, indicating media object state*/\r
302         GF_LOG_MEDIA = 1<<9,\r
303         /*! Log message from the scene graph/scene manager (handling of nodes and attribute modif, DOM core)*/\r
304         GF_LOG_SCENE = 1<<10,\r
305         /*! Log message from the scripting engine*/\r
306         GF_LOG_SCRIPT = 1<<11,\r
307         /*! Log message from event handling*/\r
308         GF_LOG_INTERACT = 1<<12,\r
309         /*! Log message from compositor*/\r
310         GF_LOG_COMPOSE = 1<<13,\r
311         /*! Log for video object cache */\r
312         GF_LOG_CACHE = 1<<14,\r
313         /*! Log message from multimedia I/O devices (audio/video input/output, ...)*/\r
314         GF_LOG_MMIO = 1<<15,\r
315         /*! Log for runtime info (times, memory, CPU usage)*/\r
316         GF_LOG_RTI = 1<<16,\r
317         /*! Log for SMIL timing and animation*/\r
318         GF_LOG_SMIL = 1<<17,\r
319 \r
320 };\r
321 \r
322 /*!\r
323  *      \brief Log modules assignment\r
324  *\r
325  * Sets the modules to be checked for log filtering. By default no modules are logged.\r
326  *      \param tools log tools filtered. This is an OR'ed combinaison of log module flags\r
327  *\r
328  */\r
329 void gf_log_set_tools(u32 tools);\r
330 \r
331 /*!\r
332  *      \brief Log Message Callback\r
333  *\r
334  * 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\r
335  *      \param cbck Opaque user data.\r
336  *      \param log_level level of the log. This value is not guaranteed in multi-threaded context.\r
337  *      \param log_tool tool emitting the log. This value is not guaranteed in multi-threaded context.\r
338  *      \param fmt message log format.\r
339  *      \param vlist message log param.\r
340  *\r
341  */\r
342 typedef void (*gf_log_cbk)(void *cbck, u32 log_level, u32 log_tool, const char* fmt, va_list vlist);\r
343 \r
344 /*!\r
345  *      \brief Log overwrite\r
346  *\r
347  *      Assigns a user-defined callback for printing log messages. By default all logs are redirected to stdout\r
348  *      \param usr_cbk Opaque user data \r
349  *      \param cbk  callback log function\r
350  *      \return previous callback function\r
351 */\r
352 gf_log_cbk gf_log_set_callback(void *usr_cbk, gf_log_cbk cbk);\r
353 \r
354 /*!\r
355  \cond DUMMY_DOXY_SECTION\r
356 */\r
357 \r
358 #ifndef GPAC_DISABLE_LOG\r
359 /*note: \r
360                 to turn log on, change to GPAC_ENABLE_LOG\r
361                 to turn log off, change to GPAC_DISABLE_LOG\r
362         this is needed by configure+sed to modify this file directly\r
363 */\r
364 #define GPAC_ENABLE_LOG\r
365 #endif\r
366 \r
367 /*!\r
368  \endcond\r
369 */\r
370 \r
371 \r
372 /*this is all a bit ugly, but most compilers don't properly handle variadic macros...*/\r
373 void gf_log(const char *fmt, ...);\r
374 void gf_log_lt(u32 ll, u32 lt);\r
375 \r
376 u32 gf_log_get_level();\r
377 u32 gf_log_get_tools();\r
378 \r
379 #ifdef GPAC_DISABLE_LOG\r
380 #define GF_LOG(_ll, _lm, __args) \r
381 #else\r
382 /*!\r
383  *      \brief Message logging\r
384  *      \hideinitializer\r
385  *\r
386  *      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.\r
387 */\r
388 #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 ;}\r
389 #endif\r
390 \r
391 \r
392 /*! @} */\r
393 \r
394 /*! \addtogroup tools_grp\r
395  *      @{\r
396  */\r
397 \r
398 \r
399 /*!\r
400  *      \brief PseudoRandom Integer Generation Initialization\r
401  *\r
402  *      Sets the starting point for generating a series of pseudorandom integers.\r
403  *      \param Reset Re-initializes the random number generator\r
404 */\r
405 void gf_rand_init(Bool Reset);\r
406 /*!\r
407  *      \brief PseudoRandom Integer Generation\r
408  *\r
409  *      Returns a pseudorandom integer.\r
410 */\r
411 u32 gf_rand();\r
412 \r
413 /*!\r
414  *      \brief user name \r
415  *\r
416  *      Gets current user (login) name.\r
417 */\r
418 void gf_get_user_name(char *buf, u32 buf_size);\r
419 \r
420 /*!\r
421  *      \brief Directory Enumeration Callback\r
422  *\r
423  * The gf_enum_dir_item type is the type for the callback of the \ref gf_enum_directory function\r
424  *      \param cbck Opaque user data.\r
425  *      \param item_name File or directory name.\r
426  *      \param item_path File or directory full path and name from filesystem root.\r
427  *      \return 1 to abort enumeration, 0 to continue enumeration.\r
428  *\r
429  */\r
430 typedef Bool (*gf_enum_dir_item)(void *cbck, char *item_name, char *item_path);\r
431 /*!\r
432  *      \brief Directory enumeration\r
433  *\r
434  *      Enumerates a directory content. Feedback is provided by the enum_dir_item function\r
435  *      \param dir Directory to enumerate\r
436  *      \param enum_directory If set, only directories will be enumerated, otherwise only files are.\r
437  *      \param enum_dir \ref gf_enum_dir_item callback function for enumeration. \r
438  *      \param cbck Opaque user data passed to callback function.\r
439  *      \param filter optional filter for file extensions. If a file extension without the dot '.' character is not found in the\r
440  *      filter the file will be skipped.\r
441 */\r
442 GF_Err gf_enum_directory(const char *dir, Bool enum_directory, gf_enum_dir_item enum_dir, void *cbck, const char *filter);\r
443 \r
444 \r
445 /*!\r
446  *      \brief File Deletion\r
447  *\r
448  *      Deletes a file from the disk.\r
449  *      \param fileName absolute name of the file or name relative to the current working directory.\r
450 */\r
451 void gf_delete_file(char *fileName);\r
452 /*!\r
453  *      \brief File Deletion\r
454  *\r
455  *      Creates a new temporary file in binary mode\r
456  *      \return stream handle to the new file ressoucre\r
457  */\r
458 FILE *gf_temp_file_new();\r
459 \r
460 \r
461 /*!\r
462  *      \brief Progress formatting\r
463  *\r
464  *      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.\r
465  *      \param title title string of the progress, or NULL for no progress\r
466  *      \param done Current amount performed of the action.\r
467  *      \param total Total amount of the action.\r
468  */\r
469 void gf_set_progress(char *title, u32 done, u32 total);\r
470 \r
471 /*!\r
472  *      \brief Progress Callback\r
473  *\r
474  * The gf_on_progress_cbk type is the type for the callback of the \ref gf_set_progress_callback function\r
475  *      \param cbck Opaque user data.\r
476  *      \param title preogress title.\r
477  *      \param done Current amount performed of the action\r
478  *      \param total Total amount of the action.\r
479  *\r
480  */\r
481 typedef void (*gf_on_progress_cbk)(void *cbck, char *title, u32 done, u32 total);\r
482 \r
483 /*!\r
484  *      \brief Progress overwriting\r
485  *\r
486  *      Iverwrites the progress signaling function by a user-defined one.\r
487  *      \param user_cbk Opaque user data\r
488  *      \param prog_cbk new callback function to use. Passing NULL restore default GPAC stdout notification.\r
489  */\r
490 void gf_set_progress_callback(void *user_cbk, gf_on_progress_cbk prog_cbk);\r
491 \r
492 \r
493 /*!\r
494  *      \brief Prompt checking \r
495  *\r
496  *      Checks if a character is pending in the prompt buffer.\r
497  *      \return 1 if a character is ready to be fetched, 0 otherwise.\r
498  *      \note Function not available under WindowsCE nor SymbianOS\r
499 */\r
500 Bool gf_prompt_has_input();\r
501 \r
502 /*!\r
503  *      \brief Prompt character flush\r
504  *\r
505  *      Returns the current character entered at prompt if any.\r
506  *      \return value of the character.\r
507  *      \note Function not available under WindowsCE nor SymbianOS\r
508 */\r
509 char gf_prompt_get_char();\r
510 \r
511 \r
512 /*!\r
513  *      \brief turns prompt echo on/off\r
514  *\r
515  *      Turns the prompt character echo on/off - this is usefull when entering passwords.\r
516  *      \param echo_off indicates whether echo should be turned on or off.\r
517  *      \note Function not available under WindowsCE nor SymbianOS\r
518 */\r
519 void gf_prompt_set_echo_off(Bool echo_off);\r
520 \r
521 /*!\r
522  *\addtogroup cpu_grp Time tools\r
523  *\ingroup utils_grp\r
524  *\brief System time and CPU functions\r
525  *\r
526  *This section documents time functionalities and CPU management in GPAC.\r
527   *     @{\r
528  */\r
529 \r
530 \r
531 /*!\r
532  *      \brief System setup\r
533  *\r
534  *      Inits the system high-resolution clock if any, and CPU usage manager. It is strongly recommended to call this \r
535  * function before calling any other GPAC functions, since on some systems (like winCE) it may result in a better memory usage estimation.\r
536  *      \note This can be called several times but only the first call will result in system setup. \r
537  */\r
538 void gf_sys_init();\r
539 /*!\r
540  *      \brief System closing\r
541  *\r
542  *      Closes the system high-resolution clock and any CPU associated ressources.\r
543  *      \note This can be called several times but the system will be closed when no more users are counted.\r
544  */\r
545 void gf_sys_close();\r
546 /*!\r
547  *      \brief System clock query\r
548  *\r
549  *      Gets the system clock time.\r
550  *      \return System clock value since initialization in milliseconds.\r
551  */\r
552 u32 gf_sys_clock();\r
553 \r
554 /*!\r
555  *      \brief Sleeps thread/process\r
556  *\r
557  *      Locks calling thread/process execution for a given time.\r
558  *      \param ms Amount of time to sleep in milliseconds.\r
559  */\r
560 void gf_sleep(u32 ms);\r
561 \r
562 /*!\r
563  *      \brief CRC32 compute\r
564  *\r
565  *      Computes the CRC32 value of a buffer.\r
566  *      \param data buffer\r
567  *      \param size buffer size\r
568  *      \return computed CRC32\r
569  */\r
570 u32 gf_crc_32(char *data, u32 size);\r
571 \r
572 \r
573 /*!\brief run-time system info object\r
574  *\r
575  *The Run-Time Info object is used to get CPU and memory occupation of the calling process. \r
576  *All time values are expressed in milliseconds (accuracy is not guaranteed).\r
577 */\r
578 typedef struct\r
579 {\r
580         /*!start of the sampling period*/\r
581         u32 sampling_instant;\r
582         /*!duration of the sampling period*/\r
583         u32 sampling_period_duration;\r
584         /*!total amount of time (User+kernel) spent in CPU for all processes as evaluated at the end of the sampling period*/\r
585         u32 total_cpu_time;\r
586         /*!total amount of time (User+kernel) spent in CPU for the calling process as evaluated at the end of the sampling period*/\r
587         u32 process_cpu_time;\r
588         /*!amount of time (User+kernel) spent in CPU for all processes during the sampling period*/\r
589         u32 total_cpu_time_diff;\r
590         /*!total amount of time (User+kernel) spent in CPU for the calling process during the sampling period*/\r
591         u32 process_cpu_time_diff;\r
592         /*!total amount of idle time during the sampling period.*/\r
593         u32 cpu_idle_time;\r
594         /*!percentage (from 0 to 100) of CPU usage during the sampling period.*/\r
595         u32 total_cpu_usage;\r
596         /*!percentage (from 0 to 100) of the CPU usage by the calling process during the sampling period.*/\r
597         u32 process_cpu_usage;\r
598         /*!calling process ID*/\r
599         u32 pid;\r
600         /*!calling process thread count if known*/\r
601         u32 thread_count;\r
602         /*!size of calling process allocated heaps*/\r
603         u64 process_memory;\r
604         /*!total physical memory in system*/\r
605         u64 physical_memory;\r
606         /*!available physical memory in system*/\r
607         u64 physical_memory_avail;\r
608         /*!total memory currently allocated by gpac*/\r
609         u64 gpac_memory;\r
610 } GF_SystemRTInfo;\r
611 \r
612 /*!\r
613  * Selection flags for run-time info retrieval\r
614  *      \hideinitializer\r
615  */\r
616 enum\r
617 {\r
618         /*!Indicates all processes' times must be fetched. If not set, only the current process times will be retrieved, and the\r
619         thread count and total times won't be available*/\r
620         GF_RTI_ALL_PROCESSES_TIMES = 1,\r
621         /*!Indicates the process allocated heap size must be fetch. If not set, only the system physical memory is fetched. \r
622         Fetching the entire ocess  allocated memory can have a large impact on performances*/\r
623         GF_RTI_PROCESS_MEMORY = 1<<1,\r
624         /*!Indicates that only system memory should be fetched. When set, all refreshing info is ignored*/\r
625         GF_RTI_SYSTEM_MEMORY_ONLY = 1<<2,\r
626 };\r
627 \r
628 /*!\r
629  *      \brief Gets Run-Time info\r
630  *\r
631  *      Gets CPU and memory usage info for the calling process and the system. Information gathering\r
632  * is controled through timeout values.\r
633  *      \param refresh_time_ms refresh time period in milliseconds. If the last sampling was done less than this period ago, the run-time info is not refreshed.\r
634  *      \param rti holder to the run-time info structure to update.\r
635  *      \param flags specify which info is to be retrieved.\r
636  *      \return 1 if info has been updated, 0 otherwise.\r
637  *      \note You should not try to use a too small refresh time. Typical values are 500 ms or one second.\r
638  */\r
639 Bool gf_sys_get_rti(u32 refresh_time_ms, GF_SystemRTInfo *rti, u32 flags);\r
640 \r
641 \r
642 Bool gf_sys_get_battery_state(Bool *onBattery, u32 *onCharge, u32 *level);\r
643 \r
644 /*! @} */\r
645 \r
646 \r
647 /*! @} */\r
648 \r
649 #ifdef __cplusplus\r
650 }\r
651 #endif\r
652 \r
653 \r
654 #endif          /*_GF_CORE_H_*/\r
655 \r