Coverage Report

Created: 2025-10-10 06:50

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/gpac/include/gpac/tools.h
Line
Count
Source
1
/*
2
 *      GPAC - Multimedia Framework C SDK
3
 *
4
 *      Authors: Jean Le Feuvre
5
 *      Copyright (c) Telecom ParisTech 2000-2025
6
 *          All rights reserved
7
 *
8
 *  This file is part of GPAC / common tools sub-project
9
 *
10
 *  GPAC is free software; you can redistribute it and/or modify
11
 *  it under the terms of the GNU Lesser General Public License as published by
12
 *  the Free Software Foundation; either version 2, or (at your option)
13
 *  any later version.
14
 *
15
 *  GPAC is distributed in the hope that it will be useful,
16
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
17
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18
 *  GNU Lesser General Public License for more details.
19
 *
20
 *  You should have received a copy of the GNU Lesser General Public
21
 *  License along with this library; see the file COPYING.  If not, write to
22
 *  the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
23
 *
24
 */
25
26
#ifndef _GF_TOOLS_H_
27
#define _GF_TOOLS_H_
28
29
#ifdef __cplusplus
30
extern "C" {
31
#endif
32
33
#include <gpac/setup.h>
34
#include <gpac/version.h>
35
#include <time.h>
36
37
38
/*!
39
\file "gpac/tools.h"
40
\brief Core definitions and tools of GPAC.
41
42
This file contains basic functions and core definitions of the GPAC framework. This file is
43
usually included by all GPAC header files since it contains the error definitions.
44
*/
45
46
/*!
47
\addtogroup utils_grp Core Tools
48
\brief Core definitions and tools of GPAC.
49
50
You will find in this module the documentation of the core tools used in GPAC.
51
*/
52
53
/*!
54
\addtogroup setup_grp
55
@{
56
 */
57
58
/*!
59
\brief Stringizer
60
\hideinitializer
61
62
Macro transforming its input name into a string
63
*/
64
#define gf_stringizer(x) #x
65
66
/*!
67
\brief 4CC Formatting
68
\hideinitializer
69
70
Macro formatting a 4-character code (or 4CC) "abcd" as 0xAABBCCDD
71
*/
72
#ifndef GF_4CC
73
762k
#define GF_4CC(a,b,c,d) ((((u32)a)<<24)|(((u32)b)<<16)|(((u32)c)<<8)|((u32)d))
74
#endif
75
76
/*! Macro formatting 4CC from compiler-constant string of 4 characters
77
\hideinitializer
78
 */
79
0
#define GF_4CC_CSTR(s) GF_4CC(s[0],s[1],s[2],s[3])
80
81
/*! minimum buffer size to hold any 4CC in string format*/
82
0
#define GF_4CC_MSIZE  10
83
84
/*! converts four character code to string
85
\param type a four character code
86
\return a printable form of the code
87
*/
88
const char *gf_4cc_to_str(u32 type);
89
90
/*! converts four character code to string in the provided buffer - thread-safe version of \ref gf_4cc_to_str
91
\param type a four character code
92
\param szType buffer to write the code to
93
\return the onput buffer
94
*/
95
const char *gf_4cc_to_str_safe(u32 type, char szType[GF_4CC_MSIZE]);
96
97
/*! converts a 4CC string to its 32 bits value
98
\param val  four character string
99
\return code value or 0 if error
100
*/
101
u32 gf_4cc_parse(const char *val);
102
103
/*! @} */
104
105
/*!
106
\addtogroup errors_grp
107
\brief Error Types
108
109
This section documents all error codes used in the GPAC framework. Most of the GPAC's functions will use these as
110
 return values, and some of these errors are also used for state communication with the different modules of the framework.
111
112
@{
113
 */
114
115
/*! GPAC Error
116
\hideinitializer
117
118
Positive values are warning and info, 0 means no error and negative values are errors
119
 */
120
typedef enum
121
{
122
  /*!Message from any scripting engine used in the presentation (ECMAScript, MPEG-J, ...) (Info).*/
123
  GF_SCRIPT_INFO                                          = 3,
124
  /*!Indicates a send packet is not dispatched due to pending connections.*/
125
  GF_PENDING_PACKET         = 2,
126
  /*!Indicates the end of a stream or of a file (Info).*/
127
  GF_EOS                = 1,
128
  /*!
129
  \n\n
130
  */
131
  /*!Operation success (no error).*/
132
  GF_OK               = 0,
133
  /*!\n*/
134
  /*!One of the input parameter is not correct or cannot be used in the current operating mode of the framework.*/
135
  GF_BAD_PARAM              = -1,
136
  /*! Memory allocation failure.*/
137
  GF_OUT_OF_MEM             = -2,
138
  /*! Input/Output failure (disk access, system call failures)*/
139
  GF_IO_ERR               = -3,
140
  /*! The desired feature or operation is not supported by the framework*/
141
  GF_NOT_SUPPORTED            = -4,
142
  /*! Input data has been corrupted*/
143
  GF_CORRUPTED_DATA           = -5,
144
  /*! A modification was attempted on a scene node which could not be found*/
145
  GF_SG_UNKNOWN_NODE            = -6,
146
  /*! The PROTO node interface does not match the nodes using it*/
147
  GF_SG_INVALID_PROTO           = -7,
148
  /*! An error occured in the scripting engine*/
149
  GF_SCRIPT_ERROR             = -8,
150
  /*! Buffer is too small to contain decoded data. Decoders shall use this error whenever they need to resize their output memory buffers*/
151
  GF_BUFFER_TOO_SMALL           = -9,
152
  /*! The bitstream is not compliant to the specfication it refers to*/
153
  GF_NON_COMPLIANT_BITSTREAM        = -10,
154
  /*! No filter could be found to handle the desired media type*/
155
  GF_FILTER_NOT_FOUND           = -11,
156
  /*! The URL is not properly formatted or cannot be found*/
157
  GF_URL_ERROR              = -12,
158
  /*! An service error has occured at the local side*/
159
  GF_SERVICE_ERROR            = -13,
160
  /*! A service error has occured at the remote (server) side*/
161
  GF_REMOTE_SERVICE_ERROR         = -14,
162
  /*! The desired stream could not be found in the service*/
163
  GF_STREAM_NOT_FOUND           = -15,
164
    /*! The URL no longer exists*/
165
    GF_URL_REMOVED                          = -16,
166
167
  /*! The IsoMedia file is not a valid one*/
168
  GF_ISOM_INVALID_FILE          = -20,
169
  /*! The IsoMedia file is not complete. Either the file is being downloaded, or it has been truncated*/
170
  GF_ISOM_INCOMPLETE_FILE         = -21,
171
  /*! The media in this IsoMedia track is not valid (usually due to a broken stream description)*/
172
  GF_ISOM_INVALID_MEDIA         = -22,
173
  /*! The requested operation cannot happen in the current opening mode of the IsoMedia file*/
174
  GF_ISOM_INVALID_MODE          = -23,
175
  /*! This IsoMedia track refers to media outside the file in an unknown way*/
176
  GF_ISOM_UNKNOWN_DATA_REF        = -24,
177
178
  /*! An invalid MPEG-4 Object Descriptor was found*/
179
  GF_ODF_INVALID_DESCRIPTOR       = -30,
180
  /*! An MPEG-4 Object Descriptor was found or added to a forbidden descriptor*/
181
  GF_ODF_FORBIDDEN_DESCRIPTOR       = -31,
182
  /*! An invalid MPEG-4 BIFS command was detected*/
183
  GF_ODF_INVALID_COMMAND          = -32,
184
  /*! The scene has been encoded using an unknown BIFS version*/
185
  GF_BIFS_UNKNOWN_VERSION         = -33,
186
187
  /*! The remote IP address could not be solved*/
188
  GF_IP_ADDRESS_NOT_FOUND         = -40,
189
  /*! The connection to the remote peer has failed*/
190
  GF_IP_CONNECTION_FAILURE        = -41,
191
  /*! The network operation has failed*/
192
  GF_IP_NETWORK_FAILURE         = -42,
193
  /*! The network connection has been closed*/
194
  GF_IP_CONNECTION_CLOSED         = -43,
195
  /*! The network operation has failed because no data is available*/
196
  GF_IP_NETWORK_EMPTY           = -44,
197
198
  /*! UDP connection did not receive any data at all. Signaled by client services to reconfigure network if possible*/
199
  GF_IP_UDP_TIMEOUT           = -46,
200
201
  /*! Authentication with the remote host has failed*/
202
  GF_AUTHENTICATION_FAILURE       = -50,
203
  /*! Not ready for execution, later retry is needed */
204
  GF_NOT_READY            = -51,
205
  /*! Bad configuration for the current context */
206
  GF_INVALID_CONFIGURATION        = -52,
207
  /*! The element has not been found */
208
  GF_NOT_FOUND              = -53,
209
  /*! Unexpected format of data */
210
  GF_PROFILE_NOT_SUPPORTED        = -54,
211
  /*! filter PID config requires new instance of filter */
212
  GF_REQUIRES_NEW_INSTANCE = -56,
213
  /*! filter PID config cannot be supported by this filter, no use trying to find an alternate input filter chain*/
214
  GF_FILTER_NOT_SUPPORTED = -57,
215
  /*! server does not support range requests: response with status=200 to a request with byte range*/
216
  GF_IO_BYTE_RANGE_NOT_SUPPORTED = -58,
217
} GF_Err;
218
219
/*!
220
\brief Error Printing
221
222
Returns a printable version of a given error
223
\param e Error code requested
224
\return String representing the error
225
*/
226
const char *gf_error_to_string(GF_Err e);
227
228
/*! @} */
229
230
231
/*!
232
\addtogroup mem_grp
233
@{
234
 */
235
236
/*!
237
\brief Memory allocation for a structure
238
\hideinitializer
239
240
Macro allocating memory and zero-ing it
241
*/
242
9.53M
#define GF_SAFEALLOC(__ptr, __struct) {\
243
9.53M
    (__ptr) = (__struct *) gf_malloc(sizeof(__struct));\
244
9.53M
    if (__ptr) {\
245
9.53M
      memset((void *) (__ptr), 0, sizeof(__struct));\
246
9.53M
    }\
247
9.53M
  }
248
249
/*!
250
\brief Memory allocation for an array of n structs
251
\hideinitializer
252
253
Macro allocating memory for n structures and zero-ing it
254
*/
255
0
#define GF_SAFE_ALLOC_N(__ptr, __n, __struct) {\
256
0
    (__ptr) = (__struct *) gf_malloc( __n * sizeof(__struct));\
257
0
    if (__ptr) {\
258
0
      memset((void *) (__ptr), 0, __n * sizeof(__struct));\
259
0
    }\
260
0
  }
261
262
263
/*!
264
\brief dynamic string concatenation
265
266
Dynamic concatenation of string with optional separator
267
\param str pointer to destination string pointer
268
\param to_append string to append
269
\param sep optional separator string to insert before concatenation. If set and initial string is NULL, will not be appended
270
\return error code
271
 */
272
GF_Err gf_dynstrcat(char **str, const char *to_append, const char *sep);
273
274
275
/*!
276
\brief fraction parsing
277
278
Parse a 64 bit fraction from string
279
\param str string to parse
280
\param frac fraction to fill
281
\return GF_TRUE if success, GF_FALSE otherwise ( fraction being set to {0,0} )
282
 */
283
Bool gf_parse_lfrac(const char *str, GF_Fraction64 *frac);
284
285
/*!
286
\brief fraction parsing
287
288
Parse a 32 bit fraction from string
289
\param str string to parse
290
\param frac fraction to fill
291
\return GF_TRUE if success, GF_FALSE otherwise ( fraction being set to {0,0} )
292
 */
293
Bool gf_parse_frac(const char *str, GF_Fraction *frac);
294
295
/*!
296
\brief search string without case
297
298
Search a substring in a string without checking for case
299
\param text text to search
300
\param subtext string to find
301
\param subtext_len length of string to find
302
\return GF_TRUE if success, GF_FALSE otherwise
303
 */
304
Bool gf_strnistr(const char *text, const char *subtext, u32 subtext_len);
305
306
/*!
307
\brief search string in buffer
308
309
Search for a substring in a memory buffer of characters that may not be null-terminated
310
\param data buffer of chars in which to search
311
\param data_size size of data buffer
312
\param pat pattern to search for as a null-terminated string
313
\return a pointer to the first occurrence of pat in data, or null if not found (may not be null-terminated)
314
 */
315
const char* gf_strmemstr(const char *data, u32 data_size, const char *pat);
316
317
/*!
318
\brief safe timestamp rescale
319
320
Rescale a 64 bit timestamp value to new timescale, i.e. performs value * new_timescale / timescale
321
\param value value to rescale. A value of -1 means no timestamp defined and is returned unmodified
322
\param timescale timescale of value. Assumed to be less than 0xFFFFFFFF
323
\param new_timescale new timescale? Assumed to be less than 0xFFFFFFFF
324
\return new value
325
 */
326
u64 gf_timestamp_rescale(u64 value, u64 timescale, u64 new_timescale);
327
328
/*!
329
\brief safe signed timestamp rescale
330
331
Rescale a 64 bit timestamp value to new timescale, i.e. performs value * new_timescale / timescale
332
\param value value to rescale
333
\param timescale timescale of value. Assumed to be less than 0xFFFFFFFF
334
\param new_timescale new timescale. Assumed to be less than 0xFFFFFFFF
335
\return new value
336
 */
337
s64 gf_timestamp_rescale_signed(s64 value, u64 timescale, u64 new_timescale);
338
339
/*!
340
\brief compare timestamps
341
342
Compares two timestamps
343
\param value1 value to rescale
344
\param timescale1 timescale of value. Assumed to be less than 0xFFFFFFFF
345
\param value2 value to rescale
346
\param timescale2 timescale of value. Assumed to be less than 0xFFFFFFFF
347
\return GF_TRUE if (value1 / timescale1) is stricly less than (value2 / timescale2)
348
 */
349
Bool gf_timestamp_less(u64 value1, u64 timescale1, u64 value2, u64 timescale2);
350
351
/*!
352
\brief compare timestamps
353
354
Compares two timestamps
355
\param value1 value to rescale
356
\param timescale1 timescale of value. Assumed to be less than 0xFFFFFFFF
357
\param value2 value to rescale
358
\param timescale2 timescale of value. Assumed to be less than 0xFFFFFFFF
359
\return GF_TRUE if (value1 / timescale1) is stricly less than or equal to (value2 / timescale2)
360
 */
361
Bool gf_timestamp_less_or_equal(u64 value1, u64 timescale1, u64 value2, u64 timescale2);
362
363
/*!
364
\brief compare timestamps
365
366
Compares two timestamps
367
\param value1 value to rescale
368
\param timescale1 timescale of value. Assumed to be less than 0xFFFFFFFF
369
\param value2 value to rescale
370
\param timescale2 timescale of value. Assumed to be less than 0xFFFFFFFF
371
\return GF_TRUE if (value1 / timescale1) is stricly greater than (value2 / timescale2)
372
 */
373
Bool gf_timestamp_greater(u64 value1, u64 timescale1, u64 value2, u64 timescale2);
374
375
/*!
376
\brief compare timestamps
377
378
Compares two timestamps
379
\param value1 value to rescale
380
\param timescale1 timescale of value. Assumed to be less than 0xFFFFFFFF
381
\param value2 value to rescale
382
\param timescale2 timescale of value. Assumed to be less than 0xFFFFFFFF
383
\return GF_TRUE if (value1 / timescale1) is stricly greater than or equal to (value2 / timescale2)
384
 */
385
Bool gf_timestamp_greater_or_equal(u64 value1, u64 timescale1, u64 value2, u64 timescale2);
386
387
/*!
388
\brief compare timestamps
389
390
Compares two timestamps
391
\param value1 value to rescale
392
\param timescale1 timescale of value. Assumed to be less than 0xFFFFFFFF
393
\param value2 value to rescale
394
\param timescale2 timescale of value. Assumed to be less than 0xFFFFFFFF
395
\return GF_TRUE if (value1 / timescale1) is equal to (value2 / timescale2)
396
 */
397
Bool gf_timestamp_equal(u64 value1, u64 timescale1, u64 value2, u64 timescale2);
398
399
/*!
400
\brief strict convert str into integer
401
402
Validate and parse str into integer
403
\param str text to convert to integer
404
\param ans integer to fill
405
\return GF_TRUE if str represents an integer without any leading space nor extra chars
406
 */
407
Bool gf_strict_atoi(const char* str, s32* ans);
408
409
/*!
410
\brief strict convert str into unsigned integer
411
412
Validate and parse str into integer
413
\param str text to convert to integer
414
\param ans unsigned integer to fill
415
\return GF_TRUE if str represents an unsigned integer without any leading space nor extra chars
416
*/
417
Bool gf_strict_atoui(const char* str, u32* ans);
418
419
/*!
420
\brief formats a duration
421
422
Formats a duration into a string
423
\param dur duration expressed in timescale
424
\param timescale number of ticks per second in duration
425
\param szDur the buffer to format
426
\return the formated input buffer
427
*/
428
const char *gf_format_duration(u64 dur, u32 timescale, char szDur[100]);
429
430
/*!
431
\brief timecode type
432
 */
433
typedef struct
434
{
435
  Float max_fps;
436
  u16 n_frames;
437
  u8 hours, minutes, seconds;
438
  u8 drop_frame, negative;
439
  u8 counting_type;
440
} GF_TimeCode;
441
442
/*!
443
\brief formats a timecode
444
445
Formats a timecode into a string
446
\param tc timecode to format
447
\param szTimecode the buffer to format
448
\return the formated input buffer
449
*/
450
const char* gf_format_timecode(GF_TimeCode *tc, char szTimecode[100]);
451
452
/*!
453
\brief converts a timecode to timestamp
454
455
Converts a timecode to a timestamp in the given timescale
456
\param tc timecode to convert
457
\param timescale timescale to convert to
458
\return the timestamp in the given timescale
459
*/
460
u64 gf_timecode_to_timestamp(GF_TimeCode *tc, u32 timescale);
461
462
/*!
463
\brief compare timecodes
464
465
Compares two timecodes
466
\param value1 value to compare
467
\param value2 value to compare
468
\return GF_TRUE if value1 is stricly less than value2
469
 */
470
Bool gf_timecode_less(GF_TimeCode *value1, GF_TimeCode *value2);
471
472
/*!
473
\brief compare timecodes
474
475
Compares two timecodes
476
\param value1 value to compare
477
\param value2 value to compare
478
\return GF_TRUE if value1 is stricly less than or equal to value2
479
 */
480
Bool gf_timecode_less_or_equal(GF_TimeCode *value1, GF_TimeCode *value2);
481
482
/*!
483
\brief compare timecodes
484
485
Compares two timecodes
486
\param value1 value to compare
487
\param value2 value to compare
488
\return GF_TRUE if value1 is stricly greater than value2
489
 */
490
Bool gf_timecode_greater(GF_TimeCode *value1, GF_TimeCode *value2);
491
492
/*!
493
\brief compare timecodes
494
495
Compares two timecodes
496
\param value1 value to compare
497
\param value2 value to compare
498
\return GF_TRUE if value1 is stricly greater than or equal to value2
499
 */
500
Bool gf_timecode_greater_or_equal(GF_TimeCode *value1, GF_TimeCode *value2);
501
502
/*!
503
\brief compare timecodes
504
505
Compares two timecodes
506
\param value1 value to compare
507
\param value2 value to compare
508
\return GF_TRUE if value1 is equal to value2
509
 */
510
Bool gf_timecode_equal(GF_TimeCode *value1, GF_TimeCode *value2);
511
512
/*! @} */
513
514
/*!
515
\addtogroup libsys_grp
516
\brief Library configuration
517
518
These functions are used to initialize, shutdown and configure libgpac.
519
520
The library shall be initialized using \ref gf_sys_init and terminated using gf_sys_close
521
522
The library can usually be configured from command line if your program uses \ref gf_sys_set_args.
523
524
The library can also be configured from your program using \ref gf_opts_set_key and related functions right after initializing the library.
525
526
For more information on configuration options, see \code gpac -hx core \endcode and https://wiki.gpac.io/Filters/core_options
527
528
For more information on filters configuration options, see https://wiki.gpac.io/Filters/Filters
529
530
@{
531
 */
532
533
/*!
534
Selection flags for memory tracker
535
\hideinitializer
536
 */
537
typedef enum
538
{
539
    /*! No memory tracking*/
540
    GF_MemTrackerNone = 0,
541
    /*! Memory tracking without backtrace*/
542
    GF_MemTrackerSimple,
543
    /*! Memory tracking with backtrace*/
544
    GF_MemTrackerBackTrace,
545
} GF_MemTrackerType;
546
547
/*!
548
\brief System setup
549
550
Inits system tools (GPAC global config, high-resolution clock if any, CPU usage manager, random number, ...).
551
552
You MUST call this function before calling any libgpac function, typically only once at startup.
553
554
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.
555
\note This can be called several times but only the first call will result in system setup.
556
557
\param mem_tracker_type memory tracking mode
558
\param profile name of the profile to load, NULL for default.
559
\return Error code if any
560
 */
561
GF_Err gf_sys_init(GF_MemTrackerType mem_tracker_type, const char *profile);
562
563
/*!
564
\brief System closing
565
566
Closes allocated system resources opened by \ref gf_sys_init.
567
\note This can be called several times but systems resources will be closed when no more users are accounted for.
568
569
When JavaScript APIs are loaded, the JS runtime is destroyed in this function call.
570
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.
571
To prevent destruction, make sure you have called
572
 \code gf_opts_set_key("temp", "static-jsrt", "true"); \endcode
573
574
before calling \ref gf_sys_close. For example:
575
576
\code
577
gf_sys_init(GF_MemTrackerNone, NULL);
578
//run your code, eg a filter session
579
580
//prevent JSRT destruction
581
gf_opts_set_key("temp", "static-jsrt", "true");
582
gf_sys_close();
583
584
//The JSRT is still valid
585
586
gf_sys_init(GF_MemTrackerNone, NULL);
587
//run your code, eg another filter session
588
589
//do NOT prevent JSRT, parent app will exit after this call
590
gf_sys_close();
591
592
\endcode
593
594
 */
595
void gf_sys_close();
596
597
598
#if defined(GPAC_CONFIG_ANDROID)
599
600
/*!
601
\brief Android paths setup
602
603
Sets application data and external storage paths for android, to be called by JNI wrappers BEFORE \ref gf_sys_init is called.
604
If not set, default are:
605
- app_data is /data/data/io.gpac.gpac
606
- ext_storage is /sdcard
607
608
The default profile used on android is located in $ext_storage/GPAC/ if that directory exists, otherwise in $app_data/GPAC
609
610
\param app_data application data path, with no trailing path separator
611
\param ext_storage external storage location, with no trailing path separator
612
*/
613
void gf_sys_set_android_paths(const char *app_data, const char *ext_storage);
614
615
#endif // GPAC_CONFIG_ANDROID
616
617
618
/*!
619
\brief System arguments
620
621
Sets the user app arguments (used by GUI mode)
622
\param argc Number of arguments
623
\param argv Array of arguments - the first string is ignored (considered to be the executable name)
624
\return error code if any, GF_OK otherwise
625
 */
626
GF_Err gf_sys_set_args(s32 argc, const char **argv);
627
628
/*!
629
\brief Get number of args
630
631
Gets the number of argument of the user application if any
632
\return number of argument of the user application
633
 */
634
u32 gf_sys_get_argc();
635
636
/*!
637
\brief Get program arguments
638
639
Gets the arguments of the user application if any
640
\return  argument of the user application
641
 */
642
const char **gf_sys_get_argv();
643
644
/*!
645
\brief Get number of args
646
647
Gets the number of argument of the user application if any
648
\param arg Index of argument to retrieve
649
\return number of argument of the user application
650
 */
651
const char *gf_sys_get_arg(u32 arg);
652
653
/*!
654
\brief Locate a global filter arg
655
656
Looks for a filter option specified as global argument
657
\param arg name of option to search, without "--" or "-+" specififers
658
\return argument value string, empty string for booleans or NULL if not found
659
 */
660
const char *gf_sys_find_global_arg(const char *arg);
661
662
/*!
663
\brief Mark arg as used
664
665
Marks the argument at given index as used. By default all args are marked as not used when assigning args
666
\param arg_idx Index of argument to mark
667
\param used flag to set
668
*/
669
void gf_sys_mark_arg_used(s32 arg_idx, Bool used);
670
671
/*!
672
\brief Check if arg is marked as used
673
674
Marks the argument at given index as used
675
\param arg_idx Index of argument to mark
676
\return used flag of the arg
677
*/
678
Bool gf_sys_is_arg_used(s32 arg_idx);
679
680
/*!
681
\brief checks if test mode is enabled
682
683
Checks if test mode is enabled (no date nor GPAC version should be written).
684
\return GF_TRUE if test mode is enabled, GF_FALSE otherwise.
685
 */
686
Bool gf_sys_is_test_mode();
687
688
/*!
689
\brief checks if compatibility with old arch is enabled
690
691
Checks if compatibility with old arch is enabled - this function will be removed when master will be moved to filters branch
692
\return GF_TRUE if old arch compat is enabled, GF_FALSE otherwise.
693
 */
694
Bool gf_sys_old_arch_compat();
695
696
#ifdef GPAC_ENABLE_COVERAGE
697
/*!
698
\brief checks if coverage tests are enabled
699
700
Checks if coverage tests are enabled
701
\return GF_TRUE if coverage is enabled, GF_FALSE otherwise.
702
 */
703
Bool gf_sys_is_cov_mode();
704
#endif
705
706
/*!
707
\brief checks if running in quiet mode
708
709
Checks if quiet mode is enabled
710
\return 2 if quiet mode is enabled, 1 if quiet mode not enabled but progress is disabled, 0 otherwise.
711
 */
712
u32 gf_sys_is_quiet();
713
714
/*! gets GPAC feature list in this GPAC build
715
\param disabled if GF_TRUE, gets disabled features, otherwise gets enabled features
716
\return the list of features.
717
*/
718
const char *gf_sys_features(Bool disabled);
719
720
/*! solves path starting with replacement keywords:
721
 - $GDOCS: replaced by path to user document , OS-specific
722
   - application document directory for iOS
723
   - EXTERNAL_STORAGE environment variable if present or '/sdcard'  otherwise for Android
724
   - user home directory for other platforms
725
 - $GCFG: replaced by path to GPAC config directory for the current profile
726
727
\param tpl_path url to translate, must start with $GDOCS or $GCFG
728
\param szPath path to store the result
729
\return GF_TRUE if success, GF_FALSE otherwise.
730
*/
731
Bool gf_sys_solve_path(const char *tpl_path, char szPath[GF_MAX_PATH]);
732
733
/*! Enables or disables the rmt websocket monitoring server
734
\param start If true starts the webserver, if false stops it
735
\return GF_OK if success, GF_BAD_PARAM if error, GF_NOT_SUPPORTED if ws server not supported
736
*/
737
GF_Err gf_sys_enable_rmtws(Bool start);
738
739
740
/*!
741
GPAC Log tools
742
\hideinitializer
743
744
Describes the color code for console print
745
 */
746
typedef enum
747
{
748
  /*!reset color*/
749
  GF_CONSOLE_RESET=0,
750
  /*!set text to red*/
751
  GF_CONSOLE_RED,
752
  /*!set text to green*/
753
  GF_CONSOLE_GREEN,
754
  /*!set text to blue*/
755
  GF_CONSOLE_BLUE,
756
  /*!set text to yellow*/
757
  GF_CONSOLE_YELLOW,
758
  /*!set text to cyan*/
759
  GF_CONSOLE_CYAN,
760
  /*!set text to white*/
761
  GF_CONSOLE_WHITE,
762
  /*!set text to magenta*/
763
  GF_CONSOLE_MAGENTA,
764
  /*!reset all console text*/
765
  GF_CONSOLE_CLEAR,
766
  /*!save console state*/
767
  GF_CONSOLE_SAVE,
768
  /*!restore console state*/
769
  GF_CONSOLE_RESTORE,
770
771
  /*!set text to bold modifier*/
772
  GF_CONSOLE_BOLD = 1<<16,
773
  /*!set text to italic*/
774
  GF_CONSOLE_ITALIC = 1<<17,
775
  /*!set text to underlined*/
776
  GF_CONSOLE_UNDERLINED = 1<<18,
777
  /*!set text to strikethrough*/
778
  GF_CONSOLE_STRIKE = 1<<19
779
} GF_ConsoleCodes;
780
781
/*! sets console code
782
\param std the output stream (stderr or stdout)
783
\param code the console code to set
784
*/
785
void gf_sys_set_console_code(FILE *std, GF_ConsoleCodes code);
786
787
788
/*! @} */
789
790
791
/*!
792
\addtogroup log_grp
793
\brief Logging System
794
795
@{
796
*/
797
798
/*!
799
\brief GPAC Log Levels
800
\hideinitializer
801
802
These levels describes messages priority used when filtering logs
803
*/
804
typedef enum
805
{
806
  /*! Disable all Log message*/
807
  GF_LOG_QUIET = 0,
808
  /*! Log message describes an error*/
809
  GF_LOG_ERROR,
810
  /*! Log message describes a warning*/
811
  GF_LOG_WARNING,
812
  /*! Log message is informational (state, etc..)*/
813
  GF_LOG_INFO,
814
  /*! Log message is a debug info*/
815
  GF_LOG_DEBUG
816
} GF_LOG_Level;
817
818
/*!
819
\brief Log exits at first error assignment
820
821
When GF_LOG_ERROR happens, program leaves with instruction exit(1);
822
\param strict strict behavior when encoutering a serious error.
823
\return old value before the call.
824
 */
825
Bool gf_log_set_strict_error(Bool strict);
826
827
/*!
828
\brief gets string-formatted log tools
829
830
Gets the string-formatted log tools and levels. Returned string shall be freed by the caller.
831
\return string-formatted log tools.
832
 */
833
char *gf_log_get_tools_levels(void);
834
835
/*!
836
\brief GPAC Log tools
837
\hideinitializer
838
839
These flags describes which sub-part of GPAC generates the log and are used when filtering logs
840
 */
841
typedef enum
842
{
843
  /*! Log message from the core library (init, threads, network calls, etc)*/
844
  GF_LOG_CORE = 0,
845
  /*! Log message from a raw media parser (BIFS, LASeR, A/V formats)*/
846
  GF_LOG_CODING,
847
  /*! Log message from a bitstream parser (IsoMedia, MPEG-2 TS, OGG, ...)*/
848
  GF_LOG_CONTAINER,
849
  /*! Log message from the network/service stack (messages & co)*/
850
  GF_LOG_NETWORK,
851
  /*! Log message from the HTTP stack*/
852
  GF_LOG_HTTP,
853
  /*! Log message from the RTP/RTCP stack (TS info) and packet structure & hinting (debug)*/
854
  GF_LOG_RTP,
855
  /*! Log message from a codec*/
856
  GF_LOG_CODEC,
857
  /*! Log message from any textual (XML, ...) parser (context loading, etc)*/
858
  GF_LOG_PARSER,
859
  /*! Generic log message from a filter (not from filter core library)*/
860
  GF_LOG_MEDIA,
861
  /*! Log message from the scene graph/scene manager (handling of nodes and attribute modif, DOM core)*/
862
  GF_LOG_SCENE,
863
  /*! Log message from the scripting engine APIs - does not cover alert() in the script code itself*/
864
  GF_LOG_SCRIPT,
865
  /*! Log message from event handling*/
866
  GF_LOG_INTERACT,
867
  /*! Log message from compositor*/
868
  GF_LOG_COMPOSE,
869
  /*! Log message from the compositor, indicating media object state*/
870
  GF_LOG_COMPTIME,
871
  /*! Log for video object cache */
872
  GF_LOG_CACHE,
873
  /*! Log message from multimedia I/O devices (audio/video input/output, ...)*/
874
  GF_LOG_MMIO,
875
  /*! Log for runtime info (times, memory, CPU usage)*/
876
  GF_LOG_RTI,
877
  /*! Log for memory tracker*/
878
  GF_LOG_MEMORY,
879
  /*! Log for audio compositor*/
880
  GF_LOG_AUDIO,
881
  /*! Generic Log for modules*/
882
  GF_LOG_MODULE,
883
  /*! Log for threads and mutexes */
884
  GF_LOG_MUTEX,
885
  /*! Log for threads and condition */
886
  GF_LOG_CONDITION,
887
  /*! Log for all HTTP streaming */
888
  GF_LOG_DASH,
889
  /*! Log for all messages from filter core library (not from a filter) */
890
  GF_LOG_FILTER,
891
  /*! Log for filter scheduler only */
892
  GF_LOG_SCHEDULER,
893
  /*! Log for all ROUTE message */
894
  GF_LOG_ROUTE,
895
  /*! Log for all messages coming from script*/
896
  GF_LOG_CONSOLE,
897
  /*! Log for all messages coming the application, not used by libgpac or the modules*/
898
  GF_LOG_APP,
899
  /*! Log for all info regarding the rmt_ws server and bindings*/
900
  GF_LOG_RMTWS,
901
902
  /*! special value used to set a level for all tools*/
903
  GF_LOG_ALL,
904
  GF_LOG_TOOL_MAX = GF_LOG_ALL,
905
  GF_LOG_TOOL_UNDEFINED
906
} GF_LOG_Tool;
907
908
/*!
909
\brief Log modules assignment
910
911
Sets the tools to be checked for log filtering. By default no logging is performed.
912
\param log_tool the tool to be logged
913
\param log_level the level of logging for this tool
914
 *
915
 */
916
void gf_log_set_tool_level(GF_LOG_Tool log_tool, GF_LOG_Level log_level);
917
918
/*!
919
\brief Log Message Callback
920
921
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 stderr
922
\param cbck Opaque user data.
923
\param log_level level of the log. This value is not guaranteed in multi-threaded context.
924
\param log_tool tool emitting the log. This value is not guaranteed in multi-threaded context.
925
\param fmt message log format.
926
\param vlist message log param.
927
 *
928
 */
929
typedef void (*gf_log_cbk)(void *cbck, GF_LOG_Level log_level, GF_LOG_Tool log_tool, const char* fmt, va_list vlist);
930
931
/*!
932
\brief Log overwrite
933
934
Assigns a user-defined callback for printing log messages. By default all logs are redirected to stderr
935
\param usr_cbk Opaque user data
936
\param cbk     Callback log function
937
\return previous callback function
938
*/
939
gf_log_cbk gf_log_set_callback(void *usr_cbk, gf_log_cbk cbk);
940
941
942
/*!
943
 \cond DUMMY_DOXY_SECTION
944
*/
945
#ifndef GPAC_DISABLE_LOG
946
/*\note
947
  - to turn log on, change to GPAC_ENABLE_LOG
948
  - to turn log off, change to GPAC_DISABLE_LOG
949
  this is needed by configure+sed to modify this file directly
950
*/
951
#define GPAC_ENABLE_LOG
952
#endif
953
954
/*!
955
 \endcond
956
*/
957
958
959
/*! \cond PRIVATE */
960
void gf_log(const char *fmt, ...);
961
void gf_log_lt(GF_LOG_Level ll, GF_LOG_Tool lt);
962
void gf_log_va_list(GF_LOG_Level level, GF_LOG_Tool tool, const char *fmt, va_list vl);
963
/*! \endcond */
964
965
/*!
966
\brief Log level checking
967
968
Checks if a given tool is logged for the given level
969
\param log_tool tool to check
970
\param log_level level to check
971
\return 1 if logged, 0 otherwise
972
*/
973
Bool gf_log_tool_level_on(GF_LOG_Tool log_tool, GF_LOG_Level log_level);
974
975
/*!
976
\brief Log tool name
977
978
Gets log  tool name
979
\param log_tool tool to check
980
\return name, or "unknown" if not known
981
*/
982
const char *gf_log_tool_name(GF_LOG_Tool log_tool);
983
984
/*!
985
\brief Log level getter
986
987
Gets log level of a given tool
988
\param log_tool tool to check
989
\return log level of tool
990
*/
991
u32 gf_log_get_tool_level(GF_LOG_Tool log_tool);
992
993
/*!
994
\brief Set log tools and levels
995
996
Set log tools and levels according to the log_tools_levels string.
997
\param log_tools_levels string specifying the tools and levels. It is formatted as logToolX\@logLevelX:logToolZ\@logLevelZ:...
998
\param reset_all if GF_TRUE, all previous log settings are discarded.
999
\return GF_OK or GF_BAD_PARAM
1000
*/
1001
GF_Err gf_log_set_tools_levels(const char *log_tools_levels, Bool reset_all);
1002
1003
/*!
1004
\brief Modify log tools and levels
1005
1006
Modify log tools and levels according to the log_tools_levels string. Previous log settings are kept.
1007
\param val string specifying the tools and levels. It is formatted as logToolX\@logLevelX:logToolZ\@logLevelZ:...
1008
\return GF_OK or GF_BAD_PARAM
1009
*/
1010
GF_Err gf_log_modify_tools_levels(const char *val);
1011
1012
/*!
1013
\brief Checks if color logs is enabled
1014
1015
Checks if color logs is enabled
1016
\return GF_TRUE if color logs are used
1017
*/
1018
Bool gf_log_use_color();
1019
1020
/*!
1021
\brief Checks if logs are stored to file
1022
1023
Checks if logs are stored to file
1024
\return GF_TRUE if logs are stored to file
1025
*/
1026
Bool gf_log_use_file();
1027
1028
/*!
1029
\brief Parses a log tool
1030
1031
Parses a log tool by name
1032
\param logs the name to parse
1033
\return log tool value
1034
*/
1035
u32 gf_log_parse_tool(const char *logs);
1036
1037
#ifdef GPAC_DISABLE_LOG
1038
void gf_log_check_error(u32 ll, u32 lt);
1039
#define GF_LOG(_ll, _lm, __args) gf_log_check_error(_ll, _lm);
1040
#else
1041
/*!
1042
\brief Message logging
1043
\hideinitializer
1044
1045
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.
1046
*/
1047
212M
#define GF_LOG(_log_level, _log_tools, __args) if (gf_log_tool_level_on(_log_tools, _log_level) ) { gf_log_lt(_log_level, _log_tools); gf_log __args ;}
1048
#endif
1049
1050
/*!
1051
\brief Resets log file
1052
Resets log file if any log file name was specified, by closing and reopening a new file.
1053
*/
1054
void gf_log_reset_file();
1055
1056
//! Extra log instructions
1057
typedef struct log_extra
1058
{
1059
  //! number of tools and levels
1060
  u32 nb_tools;
1061
  //! additionnal  tools
1062
  GF_LOG_Tool *tools;
1063
  //! additionnal  levels for the tools
1064
  GF_LOG_Level *levels;
1065
  //! exit if error
1066
  Bool strict;
1067
} GF_LogExtra;
1068
1069
/*! Register a new extra log levels
1070
 \param log extra levels to add - may be NULL but shall be valid until call to \ref gf_log_pop_extra or \ref gf_log_reset_extras or  end of app
1071
*/
1072
void gf_log_push_extra(const GF_LogExtra *log);
1073
/*! Unregister an extra log levels
1074
 \param log extra levels to add - may be NULL
1075
*/
1076
void gf_log_pop_extra(const GF_LogExtra *log);
1077
/*! Unregister all  extra log levels
1078
*/
1079
void gf_log_reset_extras();
1080
1081
/*! @} */
1082
1083
/*!
1084
\addtogroup miscsys_grp
1085
\brief System time CPU
1086
1087
This section documents time functionalities and CPU management in GPAC.
1088
1089
@{
1090
 */
1091
1092
1093
/*!
1094
\brief PseudoRandom Integer Generation Initialization
1095
1096
Sets the starting point for generating a series of pseudorandom integers.
1097
\param Reset Re-initializes the random number generator
1098
*/
1099
void gf_rand_init(Bool Reset);
1100
/*! PseudoRandom integer generation
1101
\return a pseudorandom integer
1102
*/
1103
u32 gf_rand();
1104
1105
/*! gets user name
1106
\param buf buffer set to current user (login) name if available.
1107
*/
1108
void gf_get_user_name(char buf[1024]);
1109
1110
/*!
1111
\brief Progress formatting
1112
1113
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.
1114
\param title title string of the progress, or NULL for no progress
1115
\param done Current amount performed of the action.
1116
\param total Total amount of the action.
1117
 */
1118
void gf_set_progress(const char *title, u64 done, u64 total);
1119
1120
/*!
1121
\brief Progress Callback
1122
1123
The gf_on_progress_cbk type is the type for the callback of the \ref gf_set_progress_callback function
1124
\param cbck Opaque user data.
1125
\param title preogress title.
1126
\param done Current amount performed of the action
1127
\param total Total amount of the action.
1128
 *
1129
 */
1130
typedef void (*gf_on_progress_cbk)(const void *cbck, const char *title, u64 done, u64 total);
1131
1132
/*!
1133
\brief Progress overwriting
1134
Overwrites the progress signaling function by a user-defined one.
1135
\param user_cbk Opaque user data
1136
\param prog_cbk new callback function to use. Passing NULL restore default GPAC stderr notification.
1137
 */
1138
void gf_set_progress_callback(void *user_cbk, gf_on_progress_cbk prog_cbk);
1139
1140
1141
/*!
1142
\brief Prompt checking
1143
1144
Checks if a character is pending in the prompt buffer.
1145
\return 1 if a character is ready to be fetched, 0 otherwise.
1146
\note Function not available under WindowsCE nor SymbianOS
1147
*/
1148
Bool gf_prompt_has_input();
1149
1150
/*!
1151
\brief Prompt character flush
1152
1153
Gets the current character entered at prompt if any.
1154
\return value of the character.
1155
\note Function not available under WindowsCE nor SymbianOS
1156
*/
1157
char gf_prompt_get_char();
1158
1159
/*!
1160
\brief Get prompt TTY size
1161
1162
Gets the stdin prompt size (columns and rows)
1163
\param width set to number of rows in the TTY
1164
\param height set to number of columns in the TTY
1165
\return error if any
1166
*/
1167
GF_Err gf_prompt_get_size(u32 *width, u32 *height);
1168
1169
/*!
1170
\brief turns prompt echo on/off
1171
1172
Turns the prompt character echo on/off - this is useful when entering passwords.
1173
\param echo_off indicates whether echo should be turned on or off.
1174
\note Function not available under WindowsCE nor SymbianOS
1175
*/
1176
void gf_prompt_set_echo_off(Bool echo_off);
1177
1178
/*! @} */
1179
1180
1181
/*! gets battery state
1182
\param onBattery set to GF_TRUE if running on battery
1183
\param onCharge set to GF_TRUE if battery is charging
1184
\param level set to battery charge percent
1185
\param batteryLifeTime set to battery lifetime
1186
\param batteryFullLifeTime set to battery full lifetime
1187
\return GF_TRUE if success
1188
*/
1189
Bool gf_sys_get_battery_state(Bool *onBattery, u32 *onCharge, u32 *level, u32 *batteryLifeTime, u32 *batteryFullLifeTime);
1190
1191
1192
/*!
1193
\brief parses 128 bit from string
1194
1195
Parses 128 bit from string
1196
\param string the string containing the value in hexa. Non alphanum characters are skipped
1197
\param value the value parsed
1198
\return error code if any
1199
 */
1200
GF_Err gf_bin128_parse(const char *string, bin128 value);
1201
1202
1203
/*! blob range status */
1204
typedef enum
1205
{
1206
  /*! blob range is valid */
1207
  GF_BLOB_RANGE_VALID=0,
1208
  /*! blob range is not valid, still in transfer */
1209
  GF_BLOB_RANGE_IN_TRANSFER,
1210
  /*! blob range is not in transfer and is (partially or completely) lost */
1211
  GF_BLOB_RANGE_CORRUPTED,
1212
} GF_BlobRangeStatus;
1213
1214
/*! blob flags*/
1215
enum
1216
{
1217
  /*! blob is in transfer */
1218
    GF_BLOB_IN_TRANSFER = 1,
1219
  /*! blob is corrupted */
1220
    GF_BLOB_CORRUPTED = 1<<1,
1221
  /*! blob is parsable (valid mux format) but had partial repair only (media holes) */
1222
    GF_BLOB_PARTIAL_REPAIR = 1<<2
1223
};
1224
1225
/*!
1226
 * Blob structure used to pass data pointer around
1227
 */
1228
typedef struct __gf_blob
1229
{
1230
  /*! data block of blob */
1231
  u8 *data;
1232
  /*! size of blob */
1233
  u32 size;
1234
    /*! blob flags */
1235
    u32 flags;
1236
#ifdef GPAC_DISABLE_THREADS
1237
    void *mx;
1238
#else
1239
    /*! blob mutex for multi-thread access */
1240
    struct __tag_mutex *mx;
1241
#endif
1242
    /*! last blob modification time (write access) in microsec , 0 if unknown*/
1243
    u64 last_modification_time;
1244
  /*! function used to query if a range of a blob in transfer is valid. If NULL, any range is invalid until transfer is done
1245
  when set this function overrides the blob flags for gf_blob_query_range
1246
  size is updated to the maximum number of consecutive bytes starting from the goven offset */
1247
  GF_BlobRangeStatus (*range_valid)(struct __gf_blob *blob, u64 start, u32 *size);
1248
  /*! private data for range_valid function*/
1249
  void *range_udta;
1250
} GF_Blob;
1251
1252
/*!
1253
 * Retrieves data associated with a blob url. If success, \ref gf_blob_release must be called after this
1254
\param blob_url URL of blob object (ie gmem://%p)
1255
\param out_data if success, set to blob data pointer
1256
\param out_size if success, set to blob data size
1257
\param blob_flags if success, set to blob flags - may be NULL
1258
\return error code
1259
 */
1260
GF_Err gf_blob_get(const char *blob_url, u8 **out_data, u32 *out_size, u32 *blob_flags);
1261
1262
/*!
1263
 * Checks if a given byte range is valid in blob
1264
\param blob  blob object
1265
\param start_offset start offset of data to check in blob
1266
\param size size of data to check in blob
1267
\return blob range status
1268
 */
1269
GF_BlobRangeStatus gf_blob_query_range(GF_Blob *blob, u64 start_offset, u32 size);
1270
1271
/*!
1272
 * Releases blob data
1273
\param blob_url URL of blob object (ie gmem://%p)
1274
\return error code
1275
 */
1276
GF_Err gf_blob_release(const char *blob_url);
1277
1278
1279
/*!
1280
 * Retrieves data associated with a blob. If success, \ref gf_blob_release_ex must be called after this
1281
\param blob the blob object
1282
\param out_data if success, set to blob data pointer
1283
\param out_size if success, set to blob data size
1284
\param blob_flags if success, set to blob flags - may be NULL
1285
\return error code
1286
 */
1287
GF_Err gf_blob_get_ex(GF_Blob *blob, u8 **out_data, u32 *out_size, u32 *blob_flags);
1288
/*!
1289
 * Releases blob data
1290
\param blob the blob object
1291
\return error code
1292
 */
1293
GF_Err gf_blob_release_ex(GF_Blob *blob);
1294
1295
/*!
1296
 * Registers a new blob
1297
\param blob  blob object
1298
\return URL of blob object (ie gmem://%p), must be freed by user
1299
 */
1300
char *gf_blob_register(GF_Blob *blob);
1301
1302
/*!
1303
 * Unegisters a blob. This must be called before destroying a registered blob
1304
\param blob  blob object
1305
 */
1306
void gf_blob_unregister(GF_Blob *blob);
1307
1308
/*!
1309
\brief Portable getch()
1310
1311
Returns immediately a typed char from stdin
1312
\return the typed char
1313
*/
1314
int gf_getch();
1315
1316
/*!
1317
\brief Reads a line of input from stdin
1318
\param line the buffer to fill
1319
\param maxSize the maximum size of the line to read
1320
\param showContent boolean indicating if the line read should be printed on stderr or not
1321
\return GF_TRUE if some content was read, GF_FALSE otherwise
1322
*/
1323
Bool gf_read_line_input(char * line, int maxSize, Bool showContent);
1324
1325
1326
/*!
1327
\addtogroup time_grp
1328
\brief Time manipulation tools
1329
@{
1330
*/
1331
1332
/*!
1333
\brief System clock query
1334
1335
Gets the system clock time.
1336
\return System clock value since GPAC initialization in milliseconds.
1337
 */
1338
u32 gf_sys_clock();
1339
1340
/*!
1341
\brief High precision system clock query
1342
1343
Gets the hight precision system clock time.
1344
\return System clock value since GPAC initialization in microseconds.
1345
 */
1346
u64 gf_sys_clock_high_res();
1347
1348
/*!
1349
\brief Sleeps thread/process
1350
1351
Locks calling thread/process execution for a given time.
1352
\param ms Amount of time to sleep in milliseconds.
1353
 */
1354
void gf_sleep(u32 ms);
1355
1356
#ifdef WIN32
1357
/*!
1358
\brief WINCE time constant
1359
\hideinitializer
1360
1361
time between jan 1, 1601 and jan 1, 1970 in units of 100 nanoseconds
1362
*/
1363
#define TIMESPEC_TO_FILETIME_OFFSET (((LONGLONG)27111902 << 32) + (LONGLONG)3577643008)
1364
1365
#endif
1366
1367
/*!
1368
\brief gets UTC time in milliseconds
1369
1370
Gets UTC clock in milliseconds
1371
\return UTC time in milliseconds
1372
 */
1373
u64 gf_net_get_utc();
1374
1375
/*!
1376
\brief converts an ntp timestamp into UTC time in milliseconds
1377
1378
Converts NTP 64-bit timestamp to UTC clock in milliseconds
1379
\param ntp NTP timestamp
1380
\return UTC time in milliseconds
1381
 */
1382
u64 gf_net_ntp_to_utc(u64 ntp);
1383
1384
/*!
1385
\brief parses date
1386
1387
Parses date and gets UTC value for this date. Date format is an XSD dateTime format or any of the supported formats from HTTP 1.1:
1388
  Sun, 06 Nov 1994 08:49:37 GMT  ; RFC 822, updated by RFC 1123
1389
  Sunday, 06-Nov-94 08:49:37 GMT ; RFC 850, obsoleted by RFC 1036
1390
  Sun Nov  6 08:49:37 1994       ; ANSI C's asctime() formatgets UTC time in milliseconds
1391
1392
\param date string containing the date to parse
1393
\return UTC time in milliseconds
1394
 */
1395
u64 gf_net_parse_date(const char *date);
1396
1397
/*!
1398
\brief returns 64-bit UTC timestamp from year, month, day, hour, min and sec
1399
\param year the year
1400
\param month the month, from 0 to 11
1401
\param day the day
1402
\param hour the hour
1403
\param min the min
1404
\param sec the sec
1405
\return UTC time in milliseconds
1406
 */
1407
u64 gf_net_get_utc_ts(u32 year, u32 month, u32 day, u32 hour, u32 min, u32 sec);
1408
1409
/*!
1410
\brief gets timezone adjustment in seconds
1411
1412
Gets timezone adjustment in seconds, with localtime - timezone = UTC time
1413
\return timezone shift in seconds
1414
 */
1415
s32 gf_net_get_timezone();
1416
1417
/*!
1418
\brief gets timezone daylight saving time status
1419
1420
Gets timezone daylight saving time
1421
\return GF_TRUE if DST is active
1422
 */
1423
Bool gf_net_time_is_dst();
1424
1425
/*!
1426
\brief gets time from UTC timestamp
1427
1428
Gets time from UTC timestamp
1429
\param time timestamp value - see gmtime
1430
\return time description structure - see gmtime
1431
 */
1432
struct tm *gf_gmtime(const time_t *time);
1433
1434
/*! @} */
1435
1436
/*!
1437
\addtogroup thr_grp
1438
\brief Time manipulation tools
1439
@{
1440
*/
1441
1442
/*!
1443
\brief Gets process ID
1444
1445
Gets ID of the process running this gpac instance.
1446
\return the ID of the main process
1447
*/
1448
u32 gf_sys_get_process_id();
1449
1450
1451
/*! lockfile status*/
1452
typedef enum {
1453
  /*! lockfile creation failed*/
1454
  GF_LOCKFILE_FAILED=0,
1455
  /*! lockfile creation succeeded, creating a new lock file*/
1456
  GF_LOCKFILE_NEW,
1457
  /*! lockfile creation succeeded, lock file was already present and created by this process*/
1458
  GF_LOCKFILE_REUSE
1459
} GF_LockStatus;
1460
1461
/*!
1462
\brief Creates a lock file
1463
1464
Creates a lock file for the current process. A lockfile contains a single string giving the creator process ID
1465
If a lock file exists with a process ID no longer running, the lock file will be granted to the caller.
1466
Lock files are removed using \ref gf_file_delete
1467
\param lockfile name of the lockfile
1468
\return return status
1469
*/
1470
GF_LockStatus gf_sys_create_lockfile(const char *lockfile);
1471
1472
/*!
1473
\brief Checks a process is valid
1474
1475
Checks if a process is running by its ID
1476
\param process_id process ID
1477
\return GF_TRUE if process is running, GF_FALSE otherwise
1478
*/
1479
Bool gf_sys_check_process_id(u32 process_id);
1480
1481
1482
/*!\brief run-time system info object
1483
1484
The Run-Time Info object is used to get CPU and memory occupation of the calling process.
1485
All time values are expressed in milliseconds (accuracy is not guaranteed).
1486
*/
1487
typedef struct
1488
{
1489
  /*!start of the sampling period*/
1490
  u32 sampling_instant;
1491
  /*!duration of the sampling period*/
1492
  u32 sampling_period_duration;
1493
  /*!total amount of time (User+kernel) spent in CPU for all processes as evaluated at the end of the sampling period*/
1494
  u32 total_cpu_time;
1495
  /*!total amount of time (User+kernel) spent in CPU for the calling process as evaluated at the end of the sampling period*/
1496
  u32 process_cpu_time;
1497
  /*!amount of time (User+kernel) spent in CPU for all processes during the sampling period*/
1498
  u32 total_cpu_time_diff;
1499
  /*!total amount of time (User+kernel) spent in CPU for the calling process during the sampling period*/
1500
  u32 process_cpu_time_diff;
1501
  /*!total amount of idle time during the sampling period.*/
1502
  u32 cpu_idle_time;
1503
  /*!percentage (from 0 to 100) of CPU usage during the sampling period.*/
1504
  u32 total_cpu_usage;
1505
  /*!percentage (from 0 to 100) of the CPU usage by the calling process during the sampling period.*/
1506
  u32 process_cpu_usage;
1507
  /*!calling process ID*/
1508
  u32 pid;
1509
  /*!calling process thread count if known*/
1510
  u32 thread_count;
1511
  /*!size of calling process allocated heaps*/
1512
  u64 process_memory;
1513
  /*!total physical memory in system*/
1514
  u64 physical_memory;
1515
  /*!available physical memory in system*/
1516
  u64 physical_memory_avail;
1517
  /*!total memory currently allocated by gpac*/
1518
  u64 gpac_memory;
1519
  /*!total number of cores on the system*/
1520
  u32 nb_cores;
1521
} GF_SystemRTInfo;
1522
1523
/*!
1524
Selection flags for run-time info retrieval
1525
\hideinitializer
1526
 */
1527
enum
1528
{
1529
  /*!Indicates all processes' times must be fetched. If not set, only the current process times will be retrieved, and the
1530
  thread count and total times won't be available*/
1531
  GF_RTI_ALL_PROCESSES_TIMES = 1,
1532
  /*!Indicates the process allocated heap size must be fetch. If not set, only the system physical memory is fetched.
1533
  Fetching the entire ocess  allocated memory can have a large impact on performances*/
1534
  GF_RTI_PROCESS_MEMORY = 1<<1,
1535
  /*!Indicates that only system memory should be fetched. When set, all refreshing info is ignored*/
1536
  GF_RTI_SYSTEM_MEMORY_ONLY = 1<<2
1537
};
1538
1539
/*!
1540
\brief Gets Run-Time info
1541
1542
Gets CPU and memory usage info for the calling process and the system. Information gathering is controled through timeout values.
1543
\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.
1544
\param rti holder to the run-time info structure to update.
1545
\param flags specify which info is to be retrieved.
1546
\return 1 if info has been updated, 0 otherwise.
1547
\note You should not try to use a too small refresh time. Typical values are 500 ms or one second.
1548
 */
1549
Bool gf_sys_get_rti(u32 refresh_time_ms, GF_SystemRTInfo *rti, u32 flags);
1550
1551
/*! @} */
1552
1553
/*!
1554
\addtogroup osfile_grp
1555
\brief File System tools
1556
1557
This section documents file system tools used in GPAC.
1558
1559
FILE objects are wrapped in GPAC for direct memory or callback operations. All file functions not using stderr/stdout must use the gf_ prefixed versions, eg:
1560
\code
1561
//bad design, will fail when using wrapped memory IOs
1562
FILE *t = fopen(url, "rb");
1563
fputs(t, mystring);
1564
fclose(t);
1565
1566
//good design, will work fine when using wrapped memory IOs
1567
FILE *t = gf_fopen(url, "rb");
1568
gf_fputs(t, mystring);
1569
gf_fclose(t);
1570
\endcode
1571
1572
@{
1573
 */
1574
1575
/*!
1576
\brief reads a file into memory
1577
1578
Reads a local file into memory, in binary open mode.
1579
\param file_name path on disk of the file to read
1580
\param out_data pointer to allocted address, to be freed by caller
1581
\param out_size pointer to allocted size
1582
\return error code if any
1583
 */
1584
GF_Err gf_file_load_data(const char *file_name, u8 **out_data, u32 *out_size);
1585
1586
/*!
1587
\brief reads a file into memory
1588
1589
Reads a local file into memory, in binary open mode.
1590
\param file stream object to read (no seek is performed)
1591
\param out_data pointer to allocted address, to be freed by caller
1592
\param out_size pointer to allocted size
1593
\return error code if any
1594
 */
1595
GF_Err gf_file_load_data_filep(FILE *file, u8 **out_data, u32 *out_size);
1596
1597
/*!
1598
\brief Delete Directory
1599
1600
Delete a  dir within the full path.
1601
\param DirPathName the file path name.
1602
\return error if any
1603
 */
1604
GF_Err gf_rmdir(const char *DirPathName);
1605
1606
/*!
1607
\brief Create Directory
1608
1609
Create a directory within the full path.
1610
\param DirPathName the dir path name.
1611
\return error if any
1612
 */
1613
GF_Err gf_mkdir(const char* DirPathName);
1614
1615
/*!
1616
\brief Check Directory Exists
1617
1618
Create a directory within the full path.
1619
\param DirPathName the dir path name.
1620
\return GF_TRUE if directory exists
1621
 */
1622
Bool gf_dir_exists(const char *DirPathName);
1623
1624
/*!
1625
\brief Create Directory
1626
1627
Cleanup a directory within the full path, removing all the files and the directories.
1628
\param DirPathName the dir path name.
1629
\return error if any
1630
 */
1631
GF_Err gf_dir_cleanup(const char* DirPathName);
1632
1633
1634
/**
1635
Gets a newly allocated string containing the default cache directory.
1636
It is the responsibility of the caller to free the string.
1637
\return a fully qualified path to the default cache directory
1638
 */
1639
const char * gf_get_default_cache_directory();
1640
1641
/**
1642
Gets the number of open file handles (gf_fopen/gf_fclose only).
1643
\return  number of open file handles
1644
 */
1645
u32 gf_file_handles_count();
1646
1647
/*!
1648
\brief file writing helper
1649
1650
Wrapper to properly handle calls to fwrite(), ensuring proper error handling is invoked when it fails.
1651
\param ptr data buffer to write
1652
\param nb_bytes number of bytes to write
1653
\param stream stream object
1654
\return number of bytes to written
1655
*/
1656
size_t gf_fwrite(const void *ptr, size_t nb_bytes, FILE *stream);
1657
1658
/*!
1659
\brief file reading helper
1660
1661
Wrapper to properly handle calls to fread()
1662
\param ptr data buffer to read
1663
\param nbytes number of bytes to read
1664
\param stream stream object
1665
\return number of bytes read
1666
*/
1667
size_t gf_fread(void *ptr, size_t nbytes, FILE *stream);
1668
1669
/*!
1670
\brief file reading helper
1671
1672
Wrapper to properly handle calls to fgets()
1673
\param buf same as fgets
1674
\param size same as fgets
1675
\param stream same as fgets
1676
\return same as fgets
1677
*/
1678
char *gf_fgets(char *buf, size_t size, FILE *stream);
1679
/*!
1680
\brief file reading helper
1681
1682
Wrapper to properly handle calls to fgetc()
1683
\param stream same as fgetc
1684
\return same as fgetc
1685
*/
1686
int gf_fgetc(FILE *stream);
1687
/*!
1688
\brief file writing helper
1689
1690
Wrapper to properly handle calls to fputc()
1691
\param val same as fputc
1692
\param stream same as fputc
1693
\return same as fputc
1694
*/
1695
int gf_fputc(int val, FILE *stream);
1696
/*!
1697
\brief file writing helper
1698
1699
Wrapper to properly handle calls to fputs()
1700
\param buf same as fputs
1701
\param stream same as fputs
1702
\return same as fputs
1703
*/
1704
int gf_fputs(const char *buf, FILE *stream);
1705
/*!
1706
\brief file writing helper
1707
1708
Wrapper to properly handle calls to fprintf()
1709
\param stream same as fprintf
1710
\param format same as fprintf
1711
\return same as fprintf
1712
*/
1713
int gf_fprintf(FILE *stream, const char *format, ...);
1714
1715
/*!
1716
\brief file writing helper
1717
1718
Wrapper to properly handle calls to vfprintf()
1719
\param stream same as vfprintf
1720
\param format same as vfprintf
1721
\param args same as vfprintf
1722
\return same as fprintf
1723
*/
1724
int gf_vfprintf(FILE *stream, const char *format, va_list args);
1725
1726
/*!
1727
\brief file flush helper
1728
1729
Wrapper to properly handle calls to fflush()
1730
\param stream same as fflush
1731
\return same as fflush
1732
*/
1733
int gf_fflush(FILE *stream);
1734
/*!
1735
\brief end of file helper
1736
1737
Wrapper to properly handle calls to feof()
1738
\param stream same as feof
1739
\return same as feof
1740
*/
1741
int gf_feof(FILE *stream);
1742
/*!
1743
\brief file error helper
1744
1745
Wrapper to properly handle calls to ferror()
1746
\param stream same as ferror
1747
\return same as ferror
1748
*/
1749
int gf_ferror(FILE *stream);
1750
1751
/*!
1752
\brief file size helper
1753
1754
Gets the file size given a FILE object. The FILE object position will be reset to 0 after this call
1755
\param fp FILE object to check
1756
\return file size in bytes
1757
*/
1758
u64 gf_fsize(FILE *fp);
1759
1760
/*!
1761
\brief file size helper for a file descriptor
1762
1763
Gets the file size given a file descriptor.
1764
\param fd file descriptor to check
1765
\return file size in bytes
1766
*/
1767
u64 gf_fd_fsize(int fd);
1768
1769
/*!
1770
\brief file IO checker
1771
1772
Checks if the given FILE object is a native FILE or a GF_FileIO wrapper.
1773
\param fp FILE object to check
1774
\return GF_TRUE if the FILE object is a wrapper to GF_FileIO
1775
*/
1776
Bool gf_fileio_check(FILE *fp);
1777
1778
/*! FileIO write state*/
1779
typedef enum
1780
{
1781
  /*! FileIO object is ready for write operations*/
1782
  GF_FIO_WRITE_READY=0,
1783
  /*! FileIO object is not yet ready for write operations*/
1784
  GF_FIO_WRITE_WAIT,
1785
  /*! FileIO object has been canceled*/
1786
  GF_FIO_WRITE_CANCELED,
1787
} GF_FileIOWriteState;
1788
/*!
1789
\brief file IO write checker
1790
1791
Checks if the given FILE object is ready for write.
1792
\param fp FILE object to check
1793
\return write state of GF_FileIO object, GF_FIO_WRITE_READY if not a GF_FileIO object
1794
*/
1795
GF_FileIOWriteState gf_fileio_write_ready(FILE *fp);
1796
1797
/*!
1798
\brief file opening
1799
1800
Opens a file, potentially bigger than 4GB. if filename identifies a blob (gmem://), the blob will be opened
1801
\param file_name same as fopen
1802
\param mode same as fopen
1803
\return stream handle of the file object
1804
*/
1805
FILE *gf_fopen(const char *file_name, const char *mode);
1806
1807
/*!
1808
\brief file opening
1809
1810
Opens a file, potentially using file IO if the parent URL is a File IO wrapper
1811
1812
\note If a parent GFIO file is used and file_name was obtained without using \ref gf_url_concatenate on the parent GFIO, make sur to call \ref gf_fileio_open_url in "url" mode to prevent further concatenations by the GFIO handler.
1813
1814
\param file_name same as fopen
1815
\param parent_url URL of parent file. If not a file io wrapper (gfio://), the function is equivalent to gf_fopen
1816
\param mode same as fopen - value "mkdir" checks if parent dir(s) need to be created, create them if needed and returns NULL (no file open)
1817
\param no_warn if GF_TRUE, do not throw log message if failure
1818
\return stream habdle of the file or file IO object*/
1819
FILE *gf_fopen_ex(const char *file_name, const char *parent_url, const char *mode, Bool no_warn);
1820
1821
/*!
1822
\brief file closing
1823
1824
Closes a file
1825
\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.
1826
\param file file to close
1827
\return same as flcose
1828
*/
1829
s32 gf_fclose(FILE *file);
1830
1831
/*!
1832
\brief large file position query
1833
1834
Queries the current read/write position in a large file
1835
\param f Same semantics as gf_ftell
1836
\return position in the file
1837
\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.
1838
*/
1839
u64 gf_ftell(FILE *f);
1840
/*!
1841
\brief large file seeking
1842
1843
Seeks the current read/write position in a large file
1844
\param f Same semantics as fseek
1845
\param pos Same semantics as fseek
1846
\param whence Same semantics as fseek
1847
\return 0 if success, -1 if error
1848
\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.
1849
*/
1850
s32 gf_fseek(FILE *f, s64 pos, s32 whence);
1851
1852
1853
/*! gets basename from filename/path
1854
\param filename Path of the file, can be an absolute path
1855
\return a pointer to the start of a filepath basename or null
1856
*/
1857
char* gf_file_basename(const char* filename);
1858
1859
/*! gets extension from filename
1860
\param filename Path of the file, can be an absolute path
1861
\return a pointer to the start of a filepath extension or null
1862
*/
1863
char* gf_file_ext_start(const char* filename);
1864
1865
/*!\brief FileEnum info object
1866
1867
The FileEnumInfo object is used to get file attributes upon enumeration of a directory.
1868
*/
1869
typedef struct
1870
{
1871
  /*!File is marked as hidden*/
1872
  Bool hidden;
1873
  /*!File is a directory*/
1874
  Bool directory;
1875
  /*!File is a drive mountpoint*/
1876
  Bool drive;
1877
  /*!File is a system file*/
1878
  Bool system;
1879
  /*!File size in bytes*/
1880
  u64 size;
1881
  /*!File last modif time in UTC seconds*/
1882
  u64 last_modified;
1883
} GF_FileEnumInfo;
1884
1885
/*!
1886
\brief Directory Enumeration Callback
1887
1888
The gf_enum_dir_item type is the type for the callback of the \ref gf_enum_directory function
1889
\param cbck Opaque user data.
1890
\param item_name File or directory name.
1891
\param item_path File or directory full path and name from filesystem root.
1892
\param file_info information for the file or directory.
1893
\return 1 to abort enumeration, 0 to continue enumeration.
1894
 *
1895
 */
1896
typedef Bool (*gf_enum_dir_item)(void *cbck, char *item_name, char *item_path, GF_FileEnumInfo *file_info);
1897
/*!
1898
\brief Directory enumeration
1899
1900
Enumerates a directory content. Feedback is provided by the enum_dir_item function
1901
\param dir Directory to enumerate
1902
\param enum_directory If set, only directories will be enumerated, otherwise only files are.
1903
\param enum_dir gf_enum_dir_item callback function for enumeration.
1904
\param cbck Opaque user data passed to callback function.
1905
\param filter optional filter for file extensions. If a file extension without the dot '.' character is not found in the
1906
 *  filter the file will be skipped.
1907
\return error if any
1908
 */
1909
GF_Err gf_enum_directory(const char *dir, Bool enum_directory, gf_enum_dir_item enum_dir, void *cbck, const char *filter);
1910
1911
1912
/*!
1913
\brief File Deletion
1914
1915
Deletes a file from the disk.
1916
\param fileName absolute name of the file or name relative to the current working directory.
1917
\return error if any
1918
*/
1919
GF_Err gf_file_delete(const char *fileName);
1920
1921
/*!
1922
\brief File Move
1923
1924
Moves or renames a file or directory.
1925
\param fileName absolute path of the file / directory to move or rename
1926
\param newFileName absolute new path/name of the file / directory
1927
\return error if any
1928
*/
1929
GF_Err gf_file_move(const char *fileName, const char *newFileName);
1930
1931
/*!
1932
\brief Temporary File Creation
1933
1934
Creates a new temporary file in binary mode
1935
\param fileName if not NULL, strdup() of the temporary filename when created by GPAC (NULL otherwise as the system automatically removes its own tmp files)
1936
\return stream handle to the new file ressoucre
1937
 */
1938
FILE *gf_file_temp(char ** const fileName);
1939
1940
1941
/*!
1942
\brief File Modification Time
1943
1944
Gets the UTC modification time of the given file in microseconds
1945
\param filename file to check
1946
\return modification time of the file
1947
 */
1948
u64 gf_file_modification_time(const char *filename);
1949
1950
/*!
1951
\brief File existence check
1952
1953
Checks if file with given name exists
1954
\param fileName path of the file to check
1955
\return GF_TRUE if file exists */
1956
Bool gf_file_exists(const char *fileName);
1957
1958
/*!
1959
\brief File existence check
1960
1961
Checks if file with given name exists, for regular files or File IO wrapper
1962
\param file_name path of the file to check
1963
\param par_name  name of the parent file
1964
\return GF_TRUE if file exists */
1965
Bool gf_file_exists_ex(const char *file_name, const char *par_name);
1966
1967
/*!
1968
\brief Open file descriptor
1969
1970
Opens a file descriptor - this is simply a wrapper aroun open taking care of UTF8 for windows
1971
\param file_name path of the file to check
1972
\param oflags same parameters as open flags for open
1973
\param pflags same parameters as permission flags for open
1974
\return file descriptor, -1 if error*/
1975
s32 gf_fd_open(const char *file_name, u32 oflags, u32 pflags);
1976
1977
/*! File IO wrapper object*/
1978
typedef struct __gf_file_io GF_FileIO;
1979
1980
1981
/*! open proc for memory file IO
1982
\param fileio_ref reference file_io. A file can be opened multiple times for the same reference, your code must handle this
1983
\param url target file name.
1984
\param mode opening mode of file, same as fopen mode. The following additional modes are defined:
1985
  - "ref": indicates this FileIO object is used by some part of the code and must not be destroyed upon closing of the file. Associated URL is null
1986
  - "unref": indicates this FileIO object is not used by some part of the code and may be destroyed if no more references to this object are set. Associated URL is null
1987
  - "url": indicates to create a new FileIO object for the given URL without opening the output file. The resulting FileIO object must be garbage collected by the app in case it is never used by the callers
1988
  - "probe": checks if the file exists, but no need to open the file. The function should return NULL in this case. If file does not exist, set out_error to GF_URL_ERROR
1989
  - "close": indicates the fileIO object is being closed (fclose)
1990
\param out_error must be set to error code if any (never NULL)
1991
\return the opened GF_FileIO if success, or NULL otherwise
1992
 */
1993
typedef GF_FileIO *(*gfio_open_proc)(GF_FileIO *fileio_ref, const char *url, const char *mode, GF_Err *out_error);
1994
1995
/*! seek proc for memory file IO
1996
\param fileio target file IO object
1997
\param offset offset in file
1998
\param whence position from offset, same as fseek
1999
\return error if any
2000
 */
2001
typedef GF_Err (*gfio_seek_proc)(GF_FileIO *fileio, u64 offset, s32 whence);
2002
2003
/*! read proc for memory file IO
2004
\param fileio target file IO object
2005
\param buffer buffer to read.
2006
\param bytes number of bytes to read.
2007
\return number of bytes read, 0 if error.
2008
 */
2009
typedef u32 (*gfio_read_proc)(GF_FileIO *fileio, u8 *buffer, u32 bytes);
2010
2011
/*! write proc for memory file IO
2012
\param fileio target file IO object
2013
\param buffer buffer to write.
2014
\param bytes number of bytes to write. If 0, acts as fflush
2015
\return number of bytes write, 0 if error
2016
 */
2017
typedef u32 (*gfio_write_proc)(GF_FileIO *fileio, u8 *buffer, u32 bytes);
2018
2019
/*! positon tell proc for memory file IO
2020
\param fileio target file IO object
2021
\return position in bytes from file start
2022
 */
2023
typedef s64 (*gfio_tell_proc)(GF_FileIO *fileio);
2024
/*! end of file proc for memory file IO
2025
\param fileio target file IO object
2026
\return GF_TRUE if end of file, GF_FALSE otherwise
2027
 */
2028
typedef Bool (*gfio_eof_proc)(GF_FileIO *fileio);
2029
/*! printf proc for memory file IO
2030
\param fileio target file IO object
2031
\param format format string to use
2032
\param args variable argument list for printf, already initialized (va_start called)
2033
\return same as vfprint
2034
 */
2035
typedef int (*gfio_printf_proc)(GF_FileIO *fileio, const char *format, va_list args);
2036
2037
/*! Creates a new file IO object
2038
2039
There is no guarantee that the corresponding resource will be opened by the framework, it is therefore the caller responsibility to track objects created by
2040
gf_fileio_new or as a response to open with mode "url".
2041
2042
\param url the original URL this file IO object wraps
2043
\param udta opaque data for caller
2044
\param open open proc for IO, must not be NULL
2045
\param seek seek proc for IO, must not be NULL
2046
\param read read proc for IO - if NULL the file is considered write only
2047
\param write write proc for IO - if NULL the file is considered read only
2048
\param tell tell proc for IO, must not be NULL
2049
\param eof eof proc for IO, must not be NULL
2050
\param printf printf proc for IO, may be NULL
2051
\return the newly created file IO wrapper
2052
 */
2053
GF_FileIO *gf_fileio_new(char *url, void *udta,
2054
  gfio_open_proc open,
2055
  gfio_seek_proc seek,
2056
  gfio_read_proc read,
2057
  gfio_write_proc write,
2058
  gfio_tell_proc tell,
2059
  gfio_eof_proc eof,
2060
  gfio_printf_proc printf);
2061
2062
/*! Deletes a new fileIO object
2063
\param fileio the File IO object to delete
2064
*/
2065
void gf_fileio_del(GF_FileIO *fileio);
2066
2067
/*! Gets associated user data of a fileIO object
2068
\param fileio target file IO object
2069
\return the associated user data
2070
*/
2071
void *gf_fileio_get_udta(GF_FileIO *fileio);
2072
2073
/*! Gets URL of a fileIO object.
2074
 The url uses the protocol scheme "gfio://"
2075
\param fileio target file IO object
2076
\return the file IO url to use
2077
*/
2078
const char * gf_fileio_url(GF_FileIO *fileio);
2079
2080
/*! Gets a fileIO object from memory - the resulting fileIO can only be opened once at any time but can be closed/reopen.
2081
\param URL of source data, may be null
2082
\param data memory, must be valid until next close
2083
\param size memory size
2084
\return new file IO - use gf_fclose() on this object to close it
2085
*/
2086
GF_FileIO *gf_fileio_from_mem(const char *URL, const u8 *data, u32 size);
2087
2088
/*! Cache state for file IO object*/
2089
typedef enum
2090
{
2091
  /*! File caching is in progress*/
2092
  GF_FILEIO_CACHE_IN_PROGRESS=0,
2093
  /*! File caching is done */
2094
  GF_FILEIO_CACHE_DONE,
2095
  /*! No file caching (file is not stored to disk)) */
2096
  GF_FILEIO_NO_CACHE,
2097
} GF_FileIOCacheState;
2098
2099
2100
/*! Sets statistics on a fileIO object.
2101
\param fileio target file IO object
2102
\param bytes_done number of bytes fetched for this file
2103
\param file_size total size of this file, 0 if unknown
2104
\param cache_state if GF_TRUE, means the file is completely available
2105
\param bytes_per_sec reception bytes per second, 0 if unknown
2106
*/
2107
void gf_fileio_set_stats(GF_FileIO *fileio, u64 bytes_done, u64 file_size, GF_FileIOCacheState cache_state, u32 bytes_per_sec);
2108
2109
/*! Gets statistics on a fileIO object.
2110
\param fileio target file IO object
2111
\param bytes_done number of bytes fetched for this file (may be NULL)
2112
\param file_size total size of this file, 0 if unknown (may be NULL)
2113
\param cache_state set to caching state for this object (may be NULL)
2114
\param bytes_per_sec reception bytes per second, 0 if unknown (may be NULL)
2115
\return GF_TRUE if success, GF_FALSE otherwise
2116
*/
2117
Bool gf_fileio_get_stats(GF_FileIO *fileio, u64 *bytes_done, u64 *file_size, GF_FileIOCacheState *cache_state, u32 *bytes_per_sec);
2118
2119
/*! Sets write state of a  fileIO object.
2120
\param fileio target file IO object
2121
\param write_state the state to set
2122
*/
2123
void gf_fileio_set_write_state(GF_FileIO *fileio, GF_FileIOWriteState write_state);
2124
2125
/*! Checks if a FileIO object can write
2126
\param fileio target file IO object
2127
\param url the original resource URL to open
2128
\param mode the desired open mode
2129
\param out_err set to error code if any, must not be NULL
2130
\return file IO object for this resource
2131
*/
2132
GF_FileIO *gf_fileio_open_url(GF_FileIO *fileio, const char *url, const char *mode, GF_Err *out_err);
2133
2134
2135
/*! Tags a FileIO object to be accessed from main thread only
2136
\param fileio target file IO object
2137
\return error if any
2138
*/
2139
GF_Err gf_fileio_tag_main_thread(GF_FileIO *fileio);
2140
2141
/*! Check if a FileIO object is to be accessed from main thread only
2142
2143
 \note Filters accessing FileIO objects by other means that a filter option must manually tag themselves as main thread, potentially rescheduling a configure call to next process. Not doing so can result in binding crashes in multi-threaded mode.
2144
2145
\param url target url
2146
\return GF_TRUE if object is tagged for main thread, GF_FALSE otherwise
2147
*/
2148
Bool gf_fileio_is_main_thread(const char *url);
2149
2150
/*! Gets GF_FileIO object from its URL
2151
 The url uses the protocol scheme "gfio://"
2152
\param url the URL of  the File IO object
2153
\return the file IO object
2154
*/
2155
GF_FileIO *gf_fileio_from_url(const char *url);
2156
2157
/*! Constructs a new GF_FileIO object from a URL
2158
 The url can be absolute or relative to the parent GF_FileIO. This is typcically needed by filters (dash input, dasher, NHML/NHNT writers...) generating or consuming additional files associated with the main file IO object but being written or read by other filters.
2159
 The function will not open the associated resource, only create the file IO wrapper for later usage
2160
 If you need to create a new fileIO to be opened immediately, use \ref gf_fopen_ex.
2161
2162
\param fileio parent file IO object
2163
\param new_res_url the original URL of  the new object to create
2164
\return the url (gfio://) of the created file IO object, NULL otherwise
2165
*/
2166
const char *gf_fileio_factory(GF_FileIO *fileio, const char *new_res_url);
2167
2168
/*! Translates a FileIO object URL into the original resource URL
2169
\param url the URL of  the File IO object
2170
\return the original resource URL associated with the file IO object
2171
*/
2172
const char * gf_fileio_translate_url(const char *url);
2173
/*! Gets a FileIO  original resource URL
2174
\param fileio target file IO object
2175
\return the original resource URL associated with the file IO object
2176
*/
2177
const char * gf_fileio_resource_url(GF_FileIO *fileio);
2178
2179
/*! Checks if a FileIO object can read
2180
\param fileio target file IO object
2181
\return GF_TRUE if read is enabled on this object
2182
*/
2183
Bool gf_fileio_read_mode(GF_FileIO *fileio);
2184
/*! Checks if a FileIO object can write
2185
\param fileio target file IO object
2186
\return GF_TRUE if write is enabled on this object
2187
*/
2188
Bool gf_fileio_write_mode(GF_FileIO *fileio);
2189
2190
/*! Function callback for GF_FileIO delete events. The callback is NOT thread-safe in GPAC, applications should take care of ensuring safety
2191
2192
\note Applications must make sure that the underlying gfio objects are defined as GPAC does not track allocated gfio objects.
2193
2194
 \param url a gfio:// url to be deleted or a regular  name if parent_gfio_url is NULL.
2195
 \param parent_gfio_url the parent GFIO associated with the URL string, or NULL if url is a gfio url
2196
 \return error code if any, GF_EOS if this callback is not handling this specific gfio
2197
*/
2198
typedef GF_Err (*gfio_delete_proc)(const char *url, const char *parent_gfio_url);
2199
2200
/*! Register a GF_FileIO delete callback. This function is NOT threadsafe, applications should take care of ensuring safety
2201
\param del_proc the calback to register. It MUST be valid until unregistered
2202
\return error if any
2203
*/
2204
GF_Err gf_fileio_register_delete_proc(gfio_delete_proc del_proc);
2205
2206
/*! Unregister a GF_FileIO delete callback. This function is NOT threadsafe, applications should take care of ensuring safety
2207
\param del_proc the calback to unregister.
2208
*/
2209
void gf_fileio_unregister_delete_proc(gfio_delete_proc del_proc);
2210
2211
/*! @} */
2212
2213
/*!
2214
\addtogroup hash_grp
2215
\brief Data hashing, integrity and generic compression
2216
2217
This section documents misc data functions such as integrity and parsing such as SHA-1 hashing CRC checksum, 128 bit ID parsing...
2218
2219
@{
2220
 */
2221
2222
2223
/*!
2224
\brief CRC32 compute
2225
2226
Computes the CRC32 value of a buffer.
2227
\param data buffer
2228
\param size buffer size
2229
\return computed CRC32
2230
 */
2231
u32 gf_crc_32(const u8 *data, u32 size);
2232
2233
2234
/**
2235
Compresses a data buffer in place using zlib/deflate. Buffer may be reallocated in the process.
2236
\param data pointer to the data buffer to be compressed
2237
\param data_len length of the data buffer to be compressed
2238
\param out_size pointer for output buffer size
2239
\return error if any
2240
 */
2241
GF_Err gf_gz_compress_payload(u8 **data, u32 data_len, u32 *out_size);
2242
2243
/**
2244
Compresses a data buffer in place using zlib/deflate. Buffer may be reallocated in the process.
2245
\param data pointer to the data buffer to be compressed
2246
\param data_len length of the data buffer to be compressed
2247
\param out_size pointer for output buffer size
2248
\param data_offset offset in source buffer - the input payload size is data_len - data_offset
2249
\param skip_if_larger if GF_TRUE, will not override source buffer if compressed version is larger than input data
2250
\param out_comp_data if not NULL, the compressed result is set in this pointer rather than doing inplace compression
2251
\param use_gz if true, GZ header is present
2252
\return error if any
2253
 */
2254
GF_Err gf_gz_compress_payload_ex(u8 **data, u32 data_len, u32 *out_size, u8 data_offset, Bool skip_if_larger, u8 **out_comp_data, Bool use_gz);
2255
2256
/**
2257
Decompresses a data buffer using zlib/inflate.
2258
\param data data buffer to be decompressed
2259
\param data_len length of the data buffer to be decompressed
2260
\param uncompressed_data pointer to the uncompressed data buffer. The resulting buffer is NULL-terminated. It is the responsibility of the caller to free this buffer.
2261
\param out_size size of the uncompressed buffer
2262
\return error if any
2263
 */
2264
GF_Err gf_gz_decompress_payload(u8 *data, u32 data_len, u8 **uncompressed_data, u32 *out_size);
2265
2266
/**
2267
Decompresses a data buffer using zlib/inflate.
2268
\param data data buffer to be decompressed
2269
\param data_len length of the data buffer to be decompressed
2270
\param uncompressed_data pointer to the uncompressed data buffer. The resulting buffer is NULL-terminated. It is the responsibility of the caller to free this buffer.
2271
\param out_size size of the uncompressed buffer
2272
\param use_gz if true, gz header is present
2273
\return error if any
2274
 */
2275
GF_Err gf_gz_decompress_payload_ex(u8 *data, u32 data_len, u8 **uncompressed_data, u32 *out_size, Bool use_gz);
2276
2277
2278
/**
2279
Compresses a data buffer in place using LZMA. Buffer may be reallocated in the process.
2280
\param data pointer to the data buffer to be compressed
2281
\param data_len length of the data buffer to be compressed
2282
\param out_size pointer for output buffer size
2283
\return error if any
2284
 */
2285
GF_Err gf_lz_compress_payload(u8 **data, u32 data_len, u32 *out_size);
2286
2287
/**
2288
Decompresses a data buffer using LZMA.
2289
\param data data buffer to be decompressed
2290
\param data_len length of the data buffer to be decompressed
2291
\param uncompressed_data pointer to the uncompressed data buffer. It is the responsibility of the caller to free this buffer.
2292
\param out_size size of the uncompressed buffer
2293
\return error if any
2294
 */
2295
GF_Err gf_lz_decompress_payload(u8 *data, u32 data_len, u8 **uncompressed_data, u32 *out_size);
2296
2297
2298
#ifndef GPAC_DISABLE_ZLIB
2299
/*! Wrapper around gzseek, same parameters
2300
\param file target gzfile
2301
\param offset offset in file
2302
\param whence same as gzseek
2303
\return same as gzseek
2304
*/
2305
u64 gf_gzseek(void *file, u64 offset, int whence);
2306
/*! Wrapper around gf_gztell, same parameters
2307
 \param file target gzfile
2308
 \return postion in file
2309
 */
2310
u64 gf_gztell(void *file);
2311
/*! Wrapper around gzrewind, same parameters
2312
 \param file target gzfile
2313
 \return same as gzrewind
2314
 */
2315
s64 gf_gzrewind(void *file);
2316
/*! Wrapper around gzeof, same parameters
2317
 \param file target gzfile
2318
 \return same as gzeof
2319
 */
2320
int gf_gzeof(void *file);
2321
/*! Wrapper around gzclose, same parameters
2322
\param file target gzfile
2323
\return same as gzclose
2324
*/
2325
int gf_gzclose(void *file);
2326
/*! Wrapper around gzerror, same parameters
2327
\param file target gzfile
2328
\param errnum same as gzerror
2329
\return same as gzerror
2330
 */
2331
const char * gf_gzerror (void *file, int *errnum);
2332
/*! Wrapper around gzclearerr, same parameters
2333
 \param file target gzfile
2334
 */
2335
void gf_gzclearerr(void *file);
2336
/*! Wrapper around gzopen, same parameters
2337
\param path the file name to open
2338
\param mode the file open mode
2339
\return open file
2340
 */
2341
void *gf_gzopen(const char *path, const char *mode);
2342
/*! Wrapper around gzread, same parameters
2343
 \param file target gzfile
2344
 \param buf same as gzread
2345
 \param len same as gzread
2346
 \return same as gzread
2347
 */
2348
int gf_gzread(void *file, void *buf, unsigned len);
2349
/*! Wrapper around gzdirect, same parameters
2350
 \param file target gzfile
2351
 \return same as gzdirect
2352
 */
2353
int gf_gzdirect(void *file);
2354
/*! Wrapper around gzgetc, same parameters
2355
 \param file target gzfile
2356
 \return same as gzgetc
2357
 */
2358
int gf_gzgetc(void *file);
2359
/*! Wrapper around gzgets, same parameters
2360
 \param file target gzfile
2361
 \param buf same as gzread
2362
 \param len same as gzread
2363
 \return same as gzgets
2364
*/
2365
char * gf_gzgets(void *file, char *buf, int len);
2366
#endif
2367
2368
2369
/*! SHA1 context*/
2370
typedef struct __sha1_context GF_SHA1Context;
2371
2372
/*! SHA1 message size */
2373
3.19k
#define GF_SHA1_DIGEST_SIZE   20
2374
2375
/*! create SHA-1 context
2376
\return the SHA1 context*/
2377
GF_SHA1Context *gf_sha1_starts();
2378
/*! adds byte to the SHA-1 context
2379
\param ctx the target SHA1 context
2380
\param input data to hash
2381
\param length size of data in bytes
2382
*/
2383
void gf_sha1_update(GF_SHA1Context *ctx, u8 *input, u32 length);
2384
/*! generates SHA-1 of all bytes ingested
2385
\param ctx the target SHA1 context
2386
\param digest buffer to store message digest
2387
*/
2388
void gf_sha1_finish(GF_SHA1Context *ctx, u8 digest[GF_SHA1_DIGEST_SIZE] );
2389
2390
/*! gets SHA1 message digest of a file
2391
\param filename name of file to hash
2392
\param digest buffer to store message digest
2393
\return error if any
2394
*/
2395
GF_Err gf_sha1_file(const char *filename, u8 digest[GF_SHA1_DIGEST_SIZE]);
2396
2397
/*! gets SHA1 message digest of a opened file
2398
\param file  handle to open file
2399
\param digest buffer to store message digest
2400
\return error if any
2401
*/
2402
GF_Err gf_sha1_file_ptr(FILE *file, u8 digest[GF_SHA1_DIGEST_SIZE] );
2403
2404
/*! gets SHA-1 of input buffer
2405
\param buf input buffer to hash
2406
\param buflen size of input buffer in bytes
2407
\param digest buffer to store message digest
2408
 */
2409
void gf_sha1_csum(u8 *buf, u32 buflen, u8 digest[GF_SHA1_DIGEST_SIZE]);
2410
/*! @} */
2411
2412
/*! checksum size for SHA-256*/
2413
0
#define GF_SHA256_DIGEST_SIZE 32
2414
/*! gets SHA-256 of input buffer
2415
\param buf input buffer to hash
2416
\param buflen size of input buffer in bytes
2417
\param digest buffer to store message digest
2418
 */
2419
void gf_sha256_csum(const void *buf, u64 buflen, u8 digest[GF_SHA256_DIGEST_SIZE]);
2420
2421
2422
/*! checksum size for MD5*/
2423
0
#define GF_MD5_DIGEST_SIZE  16
2424
2425
/*! gets MD5 of input buffer
2426
\param buf input buffer to hash
2427
\param buflen size of input buffer in bytes
2428
\param digest buffer to store message digest
2429
 */
2430
void gf_md5_csum(const void *buf, u32 buflen, u8 digest[GF_MD5_DIGEST_SIZE]);
2431
2432
/*!
2433
\addtogroup libsys_grp
2434
@{
2435
*/
2436
2437
/*! gets a global config key value from its section and name.
2438
\param secName the desired key parent section name
2439
\param keyName the desired key name
2440
\return the desired key value if found, NULL otherwise.
2441
*/
2442
const char *gf_opts_get_key(const char *secName, const char *keyName);
2443
2444
/*! sets a global config key value from its section and name.
2445
\param secName the desired key parent section name
2446
\param keyName the desired key name
2447
\param keyValue the desired key value
2448
\note this will also create both section and key if they are not found in the configuration file
2449
\return error if any
2450
*/
2451
GF_Err gf_opts_set_key(const char *secName, const char *keyName, const char *keyValue);
2452
2453
/*! removes all entries in the given section of the global config
2454
\param secName the target section
2455
*/
2456
void gf_opts_del_section(const char *secName);
2457
/*! gets the number of sections in the global config
2458
\return the number of sections
2459
*/
2460
u32 gf_opts_get_section_count();
2461
/*! gets a section name based on its index in the global config
2462
\param secIndex 0-based index of the section to query
2463
\return the section name if found, NULL otherwise
2464
*/
2465
const char *gf_opts_get_section_name(u32 secIndex);
2466
2467
/*! gets the number of keys in a section of the global config
2468
\param secName the target section
2469
\return the number of keys in the section
2470
*/
2471
u32 gf_opts_get_key_count(const char *secName);
2472
/*! gets the number of keys in a section of the global config
2473
\param secName the target section
2474
\param keyIndex 0-based index of the key in the section
2475
\return the key name if found, NULL otherwise
2476
*/
2477
const char *gf_opts_get_key_name(const char *secName, u32 keyIndex);
2478
2479
/*! gets a global config boolean value from its section and name.
2480
\param secName the desired key parent section name
2481
\param keyName the desired key name
2482
\return the desired key value if found, GF_FALSE otherwise.
2483
*/
2484
Bool gf_opts_get_bool(const char *secName, const char *keyName);
2485
2486
/*! gets a global config integer value from its section and name.
2487
\param secName the desired key parent section name
2488
\param keyName the desired key name
2489
\return the desired key value if found, 0 otherwise.
2490
*/
2491
u32 gf_opts_get_int(const char *secName, const char *keyName);
2492
2493
/*! gets a global config key value from its section and name.
2494
\param secName the desired key parent section name
2495
\param keyName the desired key name
2496
\return the desired key value if found and if the key is not restricted, NULL otherwise.
2497
*/
2498
const char *gf_opts_get_key_restricted(const char *secName, const char *keyName);
2499
2500
/*!
2501
 * Do not save modification to global options
2502
\return error code
2503
 */
2504
GF_Err gf_opts_discard_changes();
2505
2506
/*!
2507
 * Force immediate write of config
2508
\return error code
2509
 */
2510
GF_Err gf_opts_save();
2511
2512
/*!
2513
 * Returns file name of global config
2514
\return file name of global config or NULL if libgpac is not initialized
2515
 */
2516
const char *gf_opts_get_filename();
2517
2518
/*!
2519
 * Gets GPAC shared directory (gui, shaders, etc ..)
2520
\param path_buffer GF_MAX_PATH buffer to store output
2521
\return GF_TRUE if success, GF_FALSE otherwise
2522
 */
2523
Bool gf_opts_default_shared_directory(char *path_buffer);
2524
2525
2526
/*!
2527
 * Checks given user and password are valid
2528
\param username user name
2529
\param password password
2530
\return GF_OK if success, GF_NOT_FOUND if no such user or GF_AUTHENTICATION_FAILURE if wrong password
2531
 */
2532
GF_Err gf_creds_check_password(const char *username, char *password);
2533
2534
/*!
2535
 * Checks given user belongs to list of users or groups.
2536
\param username user name
2537
\param users comma-seprated list of users to check, may be NULL
2538
\param groups comma-seprated list of groups to check, may be NULL
2539
\return GF_TRUE if success, GF_FALSE otherwise
2540
 */
2541
Bool gf_creds_check_membership(const char *username, const char *users, const char *groups);
2542
2543
/*! @} */
2544
2545
2546
//! @cond Doxygen_Suppress
2547
2548
#ifdef GPAC_DISABLE_RMTWS
2549
#define RMT_ENABLED 0
2550
#endif
2551
2552
#include <gpac/rmt_ws.h>
2553
2554
//! @endcond
2555
2556
2557
/* \cond dummy */
2558
2559
/*to call whenever the OpenGL library is opened - this function is needed to load OpenGL extensions on windows
2560
not exported, and not included in src/compositor/gl_inc.h since it may be needed even when no OpenGL
2561
calls are made by the caller*/
2562
void gf_opengl_init();
2563
2564
typedef enum
2565
{
2566
  //pbo not enabled
2567
  GF_GL_PBO_NONE=0,
2568
  //pbo enabled, both push and glTexImage textures are done in gf_gl_txw_upload
2569
  GF_GL_PBO_BOTH,
2570
  //push only is done in gf_gl_txw_upload
2571
  GF_GL_PBO_PUSH,
2572
  // glTexImage textures only is done in gf_gl_txw_upload
2573
  GF_GL_PBO_TEXIMG,
2574
} GF_GLPBOState;
2575
2576
typedef struct _gl_texture_wrap
2577
{
2578
  u32 textures[4];
2579
  u32 PBOs[4];
2580
2581
  u32 nb_textures;
2582
  u32 width, height, pix_fmt, stride, uv_stride;
2583
  Bool is_yuv;
2584
  u32 bit_depth, uv_w, uv_h;
2585
  u32 scale_10bit;
2586
  u32 init_active_texture;
2587
2588
  u32 gl_format;
2589
  u32 bytes_per_pix;
2590
  Bool has_alpha;
2591
  Bool internal_textures;
2592
  Bool uniform_setup;
2593
  u32 memory_format;
2594
  struct _gf_filter_frame_interface *frame_ifce;
2595
  Bool first_tx_load;
2596
2597
  //PBO state - must be managed by caller, especially if using separated push and texImg steps through gf_gl_txw_setup calls
2598
  GF_GLPBOState pbo_state;
2599
  Bool flip;
2600
  //YUV is full video range
2601
  Bool fullrange;
2602
  s32 mx_cicp;
2603
2604
  u32 last_program;
2605
} GF_GLTextureWrapper;
2606
2607
Bool gf_gl_txw_insert_fragment_shader(u32 pix_fmt, const char *tx_name, char **f_source, Bool y_flip);
2608
Bool gf_gl_txw_setup(GF_GLTextureWrapper *tx, u32 pix_fmt, u32 width, u32 height, u32 stride, u32 uv_stride, Bool linear_interp, struct _gf_filter_frame_interface *frame_ifce, Bool full_range, s32 matrix_coef_or_neg);
2609
Bool gf_gl_txw_upload(GF_GLTextureWrapper *tx, const u8 *data, struct _gf_filter_frame_interface *frame_ifce);
2610
Bool gf_gl_txw_bind(GF_GLTextureWrapper *tx, const char *tx_name, u32 gl_program, u32 texture_unit);
2611
void gf_gl_txw_reset(GF_GLTextureWrapper *tx);
2612
2613
/* \endcond */
2614
2615
2616
/*! macros to get the size of an array of struct*/
2617
50.8M
#define GF_ARRAY_LENGTH(a) (sizeof(a) / sizeof((a)[0]))
2618
2619
#ifdef __cplusplus
2620
}
2621
#endif
2622
2623
2624
#endif    /*_GF_CORE_H_*/