/
libgpac.py
5070 lines (4401 loc) · 179 KB
/
libgpac.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#
# GPAC - Multimedia Framework C SDK
#
# Authors: Jean Le Feuvre
# Copyright (c) Telecom Paris 2020-2024
# All rights reserved
#
# Python ctypes bindings for GPAC (core initialization and filters API only)
#
# GPAC is free software; you can redistribute it and/or modify
# it under the terfsess of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# GPAC is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; see the file COPYING. If not, write to
# the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
#
##
# \defgroup pyapi_grp Python APIs
# \brief Python API for libgpac.
#
# # Foreword
# This module provides [ctypes](https://docs.python.org/3/library/ctypes.html) bindings for libgpac. These bindings currently allow:
# - initializing libgpac, setting global arguments for the library
# - creation, running and destruction of a filter session in blocking mode or non-blocking mode
# - inspection of filters in a session
# - user tasks scheduling
# - Creation of custom filters in Python
#
# \note This is an initial work and more bindings might be needed, feel free to contribute/PR on https://github.com/gpac/gpac
#
# # Error handling
#
# Errors are handled through raising exceptions, except callback methods wich must return a \ref GF_Err value.
# # Properties handling
#
# Properties types are automatically converted to and from string. If the property name is not a built-in property type, the property is assumed to be a user-defined property.
# For example, when querying or setting a stream type property, use the property name `StreamType`.
# See [`gpac -h props`](https://wiki.gpac.io/Filters/filters_properties/) for the complete list of built-in property names.
#
# Properties values are automatically converted to or from python types whenever possible. Types with no python equivalent (vectors, fractions) are defined as classes in python.
# For example:
# - when setting a UIntList property, pass a python list of ints
# - when reading a UIntList property, a python list of ints will be returned
# - when setting a PropVec2i property, pass a PropVec2i object
# - when setting a PropVec2iList property, pass a python list of PropVec2i
#
# 4CCs are handled as strings in python, and list of 4CCs are handled as list of strings
#
# The following builtin property types are always handled as strings in Python instead of int in libgpac :
# - StreamType: string containing the streamtype name
# - CodecID: string containing the codec name
# - Enumeration properties (PixelFormat, AudioFormat, ...): string containing the corresponding name
#
# # Basic setup
#
# You can initialize libgpac before any other calls to set memory tracker or profile. When importing the module, libgpac is by default initialized with no memory tracking and using the default profile.
# You currently must uninintialize it after everything gpac-related is done.
# You also must destroy explicitly the filter session, as otherwise the garbage collection on the filter session object could happen after libgpac shutdown and will likely crash
#
# \code
# import libgpac as gpac
# gpac.init()
# #create a session in blocking mode
# fs = gpac.FilterSession()
# #setup all your filters
# ...
# #run the session
# fs.run()
# fs.delete()
# gpac.close()
# \endcode
#
# You can specify global options of libgpac and filters (e.g. --opt) by assigning arguments to libgpac:
# \code
# #set global arguments, here inherited from command line
# gpac.set_args(sys.argv)
# \endcode
#
# You can also specify the log levels you want
# \code
# gpac.set_logs("all@info")
# \endcode
# # Session using built-in filters
#
# Filters are loaded as usual in gpac as a string description
# \code
# src = fs.load_src("$URL:opt:opt2=val")
# dst = fs.load_dst("$URL2:opt3:opt4=val")
# f = fs.load("filtername:optX")
# \endcode
#
# By default the filter session will run with implicit linking.
#
# It is possible to assign sources of a filter (much like the `@` command in `gpac`):
# \code
# dst.set_source(f)
# \endcode
#
#
# # Posting user tasks
#
# You can post tasks to the session scheduler to get called back (useful when running the session in blocking mode)
# Tasks must derive FilterTask class and implement their own `execute` method
# \code
# class MyTask(FilterTask):
# def exectute(self):
# do_something()
# #last scheduled task (session is over), abort
# if self.session.last_task:
# return -1
# //keep task active, reschedule in 500 ms
# return 500
#
# task = MyTask('CustomTask')
# fs.post_task(task)
# \endcode
#
# # Creating custom filters
#
# A custom filter allows your application to interact closely with the media pipeline, but cannot be used in graph resolution.
# Custom filters can be sources, sinks, or intermediate filters. The following limitations however exist:
#- custom filters will not be cloned
#- custom filters cannot be used as sources of filters loading a source filter graph dynamically, such as the dashin filter.
#- custom filters cannot be used as destination of filters loading a destination filter graph dynamically, such as the dasher filters.
#
# A custom filter must implement the \ref FilterCustom class, and optionally provide the following methods
# - configure_pid: callback for PID configuration, mandatory if your filter is not a source
# - process: callback for processing
# - process_event: callback for processing and event
# - probe_data: callback for probing a data format
# - reconfigure_output: callback for output reconfiguration (PID capability negotiation)
#
# A custom filter must also declare its capabilities, input and output, using push_cap method
# \code
# class MyFilter(FilterTask):
# def __init__(self, session):
# # !! call constructor of parent class first !!
# gpac.FilterCustom.__init__(self, session, "PYnspect")
# #indicate what we accept and produce - this can be done either in the constructor or after, but before calling \ref run or \ref run_step
# #here we indicate we accept anything of type visual, and produce anything of type visual
# self.push_cap("StreamType", "Visual", gpac.GF_CAPS_INPUT_OUTPUT)
#
# #we accept input pids, we must configure them
# #def configure_pid(self, pid, is_remove):
# #do something, return value is a GF_Err value
# #pid being removed
# if is_remove:
# #pid being reconfigured
# elif pid in self.ipids:
# #pid first connection
# else:
#
# #process
# #def process(self):
# #do something, return value is a GF_Err value
#
# #process_event takes a \ref FilterEvent parameter
# #def process_event(self, evt):
# #do something, return value is True (cancelled) or False
#
# #probe_data takes a NumPy array if numpy is available (and _size can be ignored) or a POINTER(c_ubyte) otherwise
# #def probe_data(self, data, _size):
# #do something, return value is mime type or None
#
# #probe_data takes the target output pid as parameter
# #def reconfigure_output(self, opid):
# #do something, return value is a GF_Err value
#
# \endcode
#
# \note
# The \ref FilterCustom object has a list of input and output PIDs created. Before a callback to configure_pid, the input PID is not registered to the list
# of input PIDs if this is the first time the PID is configured.
#
# \code
# src = fs.load_src("$URL:opt:opt2=val")
# dst = fs.load_dst("$URL2:opt3:opt4=val")
# #load a custom filter
# my_filter = MyFilter(fs)
# #make sure dst only consumes from our custom filter
# dst.set_source(f)
# \endcode
# @{
#
##
# \defgroup pycore_grp libgpac core tools
# \ingroup pyapi_grp Python APIs
# \brief Core tools for libgpac.
#
# @{
from ctypes import *
from ctypes.util import find_library
import datetime
import types
import os
import copy
## set to True if numpy was successfully loaded
##\hideinitializer
numpy_support=True
try:
import numpy as np
except ImportError:
numpy_support = False
print("\nWARNING! numpy not present, packet data type is ctypes POINTER(c_ubyte)\n")
##ctypes instance of libgpac
##\hideinitializer
_libgpac=None
## \cond private
#load libgpac
try:
dll_path = find_library("libgpac.dll")
if not dll_path:
raise OSError("No libgpac.dll")
_libgpac = cdll.LoadLibrary(os.path.abspath(dll_path))
except OSError:
try:
_libgpac = cdll.LoadLibrary("libgpac.so")
except OSError:
try:
_libgpac = cdll.LoadLibrary("libgpac.dylib")
except OSError:
print('Failed to locate libgpac (.so/.dll/.dylib) - make sure it is in your system path')
os._exit(1)
#change this to reflect API we encapsulate. An incomatibility in either of these will throw a warning
GF_ABI_MAJOR=12
GF_ABI_MINOR=14
gpac_abi_major=_libgpac.gf_gpac_abi_major()
gpac_abi_minor=_libgpac.gf_gpac_abi_minor()
## \endcond private
## Set to true if mismatch was detected between the ABI version the Python wrapper was designed and the libgpac shared library ABI version
# A warning is thrown if mismatched, but it is left up to the pythin script to decide whether it still wants to use libgpac wrapper
_libgpac_abi_mismatch=False
## \cond private
if (gpac_abi_major != GF_ABI_MAJOR) or (gpac_abi_minor != GF_ABI_MINOR):
abi_mismatch=True
print('WARNING: this python wrapper is for GPAC ABI ' + str(GF_ABI_MAJOR) + '.' + str(GF_ABI_MINOR) + ' but native libgpac ABI is ' + str(gpac_abi_major) + '.' + str(gpac_abi_minor) + '\n\tUndefined behavior or crashes might happen, please update libgpac.py')
## \endcond private
#
# Type definitions
#
##\cond private
_gf_filter_session = c_void_p
_gf_filter = c_void_p
_gf_filter_pid = c_void_p
_gf_filter_packet = c_void_p
_gf_property_entry = c_void_p
_gf_list = c_void_p
gf_bool = c_uint
##\endcond
##\cond private
#error to string helper
_libgpac.gf_error_to_string.argtypes = [c_int]
_libgpac.gf_error_to_string.restype = c_char_p
_libgpac.gf_gpac_version.restype = c_char_p
_libgpac.gf_gpac_copyright.restype = c_char_p
_libgpac.gf_gpac_copyright_cite.restype = c_char_p
_libgpac.gf_sys_set_args.argtypes = [c_int, POINTER(POINTER(c_char))]
_libgpac.gf_sys_init.argtypes = [c_int, c_char_p]
_libgpac.gf_log_set_tools_levels.argtypes = [c_char_p, c_int]
_libgpac.gf_props_get_type_name.argtypes = [c_uint]
_libgpac.gf_props_get_type_name.restype = c_char_p
_libgpac.gf_sys_clock.restype = c_uint
_libgpac.gf_sys_clock_high_res.restype = c_ulonglong
_libgpac.gf_sys_profiler_log.argtypes = [c_char_p]
_libgpac.gf_sys_profiler_send.argtypes = [c_char_p]
_libgpac.gf_sys_profiler_sampling_enabled.restype = gf_bool
_libgpac.gf_sys_profiler_enable_sampling.argtypes = [gf_bool]
_libgpac.gf_4cc_to_str.argtypes = [c_uint]
_libgpac.gf_4cc_to_str.restype = c_char_p
_libgpac.gf_4cc_parse.argtypes = [c_char_p]
_libgpac.gf_4cc_parse.restype = c_uint
_libgpac.gf_sleep.argtypes = [c_uint]
_libgpac.gf_sleep.restype = c_uint
_libgpac.gf_props_enum_name.argtypes = [c_uint, c_uint]
_libgpac.gf_props_enum_name.restype = c_char_p
#default init of libgpac
_libgpac.user_init = False
err = _libgpac.gf_sys_init(0, None)
if err<0:
raise Exception('Failed to initialize libgpac: ' + e2s(err))
#\endcond
##libgpac version (string)
#\hideinitializer
version = _libgpac.gf_gpac_version().decode("utf-8")
##libgpac copyright notice (string)
#\hideinitializer
copyright = _libgpac.gf_gpac_copyright().decode("utf-8")
##libgpac full copyright notice (string)
#\hideinitializer
copyright_cite = _libgpac.gf_gpac_copyright_cite().decode("utf-8")
## convert error value to string message
# \param err gpac error code (int)
# \return string
def e2s(err):
return _libgpac.gf_error_to_string(err).decode('utf-8')
## initialize libgpac - see \ref gf_sys_init
# \param mem_track
# \param profile
# \return
#
def init(mem_track=0, profile=None):
if _libgpac.user_init:
return
_libgpac.user_init = True
_libgpac.gf_sys_close()
err = _libgpac.gf_sys_init(mem_track, profile)
if err<0:
raise Exception('Failed to initialize libgpac: ' + e2s(err))
## close libgpac - see \ref gf_sys_close
# \note Make sure you have destroyed all associated gpac resources before calling this !
# \return
#
def close():
_libgpac.gf_sys_close()
if hasattr(_libgpac, 'gf_memory_size'):
if _libgpac.gf_memory_size() or _libgpac.gf_file_handles_count():
set_logs("mem@info")
_libgpac.gf_memory_print()
return 2
return 0
## set log tools and levels - see \ref gf_log_set_tools_levels
# \note Make sure you have destroyed all associated gpac resources before calling this !
# \param logs
# \param reset if true, resets all logs to default
# \return
def set_logs(logs, reset=False):
_libgpac.gf_log_set_tools_levels(logs.encode('utf-8'), reset)
## get clock - see \ref gf_sys_clock
# \return clock in milliseconds
def sys_clock():
return _libgpac.gf_sys_clock()
## get high res clock - see \ref gf_sys_clock_high_res
# \return clock in microseconds
def sys_clock_high_res():
return _libgpac.gf_sys_clock_high_res()
##\cond private
#keep args at libgpac level to avoid python GC
_libgpac._args=None
##\endcond private
## set libgpac arguments - see \ref gf_sys_set_args
# \param args list of strings, the first string is ignored (considered to be the executable name)
# \return
def set_args(args):
_libgpac.user_init = True
nb_args = len(args)
_libgpac._args = (POINTER(c_char)*nb_args)()
for i, arg in enumerate(args):
enc_arg = arg.encode('utf-8')
_libgpac._args[i] = create_string_buffer(enc_arg)
_libgpac.gf_sys_set_args(nb_args, cast(_libgpac._args, POINTER(POINTER(c_char))) )
##\cond private
_libgpac.gf_sys_profiler_set_callback.argtypes = [py_object, c_void_p]
@CFUNCTYPE(c_int, c_void_p, c_char_p)
def rmt_fun_cbk(_udta, text):
obj = cast(_udta, py_object).value
obj.on_rmt_event(text.decode('utf-8'))
return 0
##\endcond private
## set profiler (Remotery) callback - see \ref gf_sys_profiler_set_callback
# \param callback_obj object to call back, must have a method `on_rmt_event` taking a single string parameter
# \return True if success, False if no Remotery support
def set_rmt_fun(callback_obj):
_libgpac.user_init = True
if hasattr(callback_obj, 'on_rmt_event')==False:
raise Exception('No on_rmt_event function on callback')
err = _libgpac.gf_sys_profiler_set_callback(py_object(callback_obj), rmt_fun_cbk)
if err<0:
return False
return True
## send message to profiler (Remotery) - see \ref gf_sys_profiler_log
# \param text text to send
# \return True if success, False if no Remotery support
def rmt_log(text):
err = _libgpac.gf_sys_profiler_log(text.encode('utf-8'))
if err<0:
return False
return True
## send message to profiler (Remotery) - see \ref gf_sys_profiler_send
# \param text text to send
# \return True if success, False if no Remotery support
def rmt_send(text):
err = _libgpac.gf_sys_profiler_send(text.encode('utf-8'))
if err<0:
return False
return True
## check if profiler (Remotery) sampling is enabled - see \ref gf_sys_profiler_sampling_enabled
# \return True if enabled, False otherwise
def rmt_on():
return _libgpac.gf_sys_profiler_sampling_enabled()
## enable or disable sampling in profiler (Remotery) - see \ref gf_sys_profiler_enable_sampling
# \param value enable or disable sampling
# \return
def rmt_enable(value):
_libgpac.user_init = True
_libgpac.gf_sys_profiler_enable_sampling(value)
## sleep for given time in milliseconds
# \param value time to sleep
# \return
def sleep(value):
_libgpac.gf_sleep(value)
## @}
##
# \defgroup pystruct_grp Structure Wrappers
# \ingroup pyapi_grp
# \brief Python Structures
#
# Python Wrappers for gpac C structures used in this API
#
# @{
## fraction object, as defined in libgpac and usable as a Python object
#Fields have the same types, names and semantics as \ref GF_Fraction
class Fraction(Structure):
## \cond private
def __init(self, num, den):
self.num = num
self.den = den
_fields_ = [ ("num", c_int), ("den", c_uint)]
def __str__(self):
return str(self.num)+'/' + str(self.den)
## \endcond
## large fraction object, as defined in libgpac and usable as a Python object
#Fields have the same types, names and semantics as \ref GF_Fraction64
class Fraction64(Structure):
## \cond private
_fields_ = [("num", c_longlong), ("den", c_ulonglong)]
def __str__(self):
return str(self.num)+'/' + str(self.den)
## \endcond
## filter statistics object, as defined in libgpac and usable as a Python object
#Fields have the same types, names and semantics as \ref GF_FilterStats
class FilterStats(Structure):
## \cond private
_fields_ = [
("filter", _gf_filter),
("filter_alias", _gf_filter),
("nb_tasks_done", c_ulonglong),
("nb_pck_processed", c_ulonglong),
("nb_bytes_processed", c_ulonglong),
("nb_pck_sent", c_ulonglong),
("nb_hw_pck_sent", c_ulonglong),
("nb_errors", c_uint),
("nb_bytes_sent", c_ulonglong),
("time_process", c_ulonglong),
("percent", c_int),
("status", c_char_p),
("report_updated", gf_bool),
("name", c_char_p),
("reg_name", c_char_p),
("filter_id", c_char_p),
("done", gf_bool),
("nb_pid_in", c_uint),
("nb_in_pck", c_ulonglong),
("nb_pid_out", c_uint),
("nb_out_pck", c_ulonglong),
("in_eos", gf_bool),
("type", c_int),
("stream_type", c_int),
("codecid", c_int),
("last_ts_sent", Fraction64),
("last_ts_drop", Fraction64)
]
## \endcond
## filter pid statistics object, as defined in libgpac and usable as a Python object
#Fields have the same types, names and semantics as \ref GF_FilterPidStatistics
class FilterPidStatistics(Structure):
## \cond private
_fields_ = [
("disconnected", c_uint),
("average_process_rate", c_uint),
("max_process_rate", c_uint),
("average_bitrate", c_uint),
("max_bitrate", c_uint),
("nb_processed", c_uint),
("max_process_time", c_uint),
("total_process_time", c_ulonglong),
("first_process_time", c_ulonglong),
("last_process_time", c_ulonglong),
("min_frame_dur", c_uint),
("nb_saps", c_uint),
("max_sap_process_time", c_uint),
("total_sap_process_time", c_ulonglong),
("max_buffer_time", c_ulonglong),
("max_playout_time", c_ulonglong),
("min_playout_time", c_ulonglong),
("buffer_time", c_ulonglong),
("nb_buffer_units", c_uint),
("last_rt_report", c_ulonglong),
("rtt", c_uint),
("jitter", c_uint),
("loss_rate", c_uint),
("last_ts_drop", Fraction64),
("last_ts_sent", Fraction64)
]
## \endcond
## filter argument object, as defined in libgpac and usable as a Python object
#Fields have the same types, names and semantics as \ref GF_FilterArgs
class FilterArg(Structure):
## \cond private
_fields_ = [
("name", c_char_p),
("reserved", c_int),
("description", c_char_p),
("type", c_int),
("default", c_char_p),
("min_max_enum", c_char_p),
("flags", c_uint)
]
def __str__(self):
res = '- ' + self.name.decode('utf-8') + ' (' + _libgpac.gf_props_get_type_name(self.type).decode('utf-8') + '): ' + self.description.decode('utf-8')
if self.default or self.min_max_enum:
res += ' ('
if self.default:
res += 'default: ' + self.default.decode('utf-8')
if self.min_max_enum:
res += ' min_max_enum: ' + self.min_max_enum.decode('utf-8')
res += ')'
return res
## \endcond
## filter prop type, as defined in libgpac and usable as a Python object
#Fields have the same types, names and semantics as \ref GF_PropVec2i
class PropVec2i(Structure):
## \cond private
_fields_ = [("x", c_int), ("y", c_int)]
def __str__(self):
return str(self.x)+'x' + str(self.y)
## \endcond
## filter prop type, as defined in libgpac and usable as a Python object
#Fields have the same types, names and semantics as \ref GF_PropVec2
class PropVec2(Structure):
## \cond private
_fields_ = [("x", c_double),("y", c_double)]
def __str__(self):
return str(self.x)+'x' + str(self.y)
## \endcond
## filter prop type, as defined in libgpac and usable as a Python object
#Fields have the same types, names and semantics as \ref GF_PropVec3i
class PropVec3i(Structure):
## \cond private
_fields_ = [("x", c_int), ("y", c_int), ("z", c_int)]
def __str__(self):
return str(self.x)+'x' + str(self.y)+'x' + str(self.z)
## \endcond
## filter prop type, as defined in libgpac and usable as a Python object
#Fields have the same types, names and semantics as \ref GF_PropVec4i
class PropVec4i(Structure):
## \cond private
_fields_ = [("x", c_int), ("y", c_int), ("z", c_int), ("w", c_int)]
def __str__(self):
return str(self.x)+'x' + str(self.y)+'x' + str(self.z)+'x' + str(self.w)
## \endcond
## filter prop type, as defined in libgpac and usable as a Python object
#Fields have the same types, names and semantics as \ref GF_PropData
class PropData(Structure):
## \cond private
_fields_ = [("ptr", c_void_p), ("size", c_uint)]
def __str__(self):
return 'data,size:'+str(self.size)
## \endcond
## filter prop type, as defined in libgpac and usable as a Python object
#Fields have the same types, names and semantics as \ref GF_PropUIntList
class PropStringList(Structure):
## \cond private
_fields_ = [("vals", POINTER(c_char_p)), ("nb_items", c_uint)]
def __str__(self):
res=''
for i in range(self.nb_items):
if i:
res += ','
res += self.vals[i].decode('utf-8')
return res
## \endcond private
## \cond private
## filter prop type, as defined in libgpac and usable as a Python object
#Fields have the same types, names and semantics as \ref GF_PropUIntList
class PropUIntList(Structure):
_fields_ = [("vals", POINTER(c_uint)), ("nb_items", c_uint)]
def __str__(self):
res=''
for i in range(self.nb_items):
if i:
res += ','
res += str(self.vals[i])
return res
## filter prop type, as defined in libgpac and usable as a Python object
#Fields have the same types, names and semantics as \ref GF_PropIntList
class PropIntList(Structure):
_fields_ = [("vals", POINTER(c_int)), ("nb_items", c_uint)]
def __str__(self):
res=''
for i in range(self.nb_items):
if i:
res += ','
res += str(self.vals[i])
return res
## filter prop type, as defined in libgpac and usable as a Python object
#Fields have the same types, names and semantics as \ref GF_PropVec2iList
class PropVec2iList(Structure):
_fields_ = [("vals", POINTER(PropVec2i)), ("nb_items", c_uint)]
def __str__(self):
res=''
for i in range(self.nb_items):
if i:
res += ','
res += str(self.vals[i].x) + 'x' + str(self.vals[i].y)
return res
## filter property union value, as defined in libgpac and usable as a Python object
#Fields have the same types, names and semantics as GF_PropertyValue
class PropertyValueUnion(Union):
_fields_ = [
("longuint", c_ulonglong),
("longsint", c_longlong),
("sint", c_int),
("uint", c_uint),
("boolean", gf_bool),
("frac", Fraction),
("lfrac", Fraction64),
("fnumber", c_float),
("number", c_double),
("vec2i", PropVec2i),
("vec2", PropVec2),
("vec3i", PropVec3i),
("vec4i", PropVec3i),
("data", PropData),
("string", c_char_p),
("ptr", c_void_p),
("string_list", PropStringList),
("uint_list", PropUIntList),
("sint_list", PropIntList),
("v2i_list", PropVec2iList)
]
## filter property value, as defined in libgpac and usable as a Python object
#Fields have the same types, names and semantics as GF_PropertyValue
class PropertyValue(Structure):
_fields_ = [
("type", c_uint),
("value", PropertyValueUnion)
]
## \endcond
## event value, as defined in libgpac and usable as a Python object
#Fields have the same types, names and semantics as \ref GF_FEVT_Base
class FEVT_Base(Structure):
## \cond private
_fields_ = [("type", c_uint), ("on_pid", _gf_filter_pid)]
## \endcond
## event value, as defined in libgpac and usable as a Python object
#Fields have the same types, names and semantics as \ref GF_FEVT_Play
class FEVT_Play(Structure):
## \cond private
_fields_ = [
("type", c_uint),
("on_pid", _gf_filter_pid),
("start_range", c_double),
("end_range", c_double),
("speed", c_double),
("from_pck", c_uint),
("hw_buffer_reset", c_ubyte),
("initial_broadcast_play", c_ubyte),
("timestamp_based", c_ubyte),
("full_file_only", c_ubyte),
("forced_dash_segment_switch", c_ubyte),
("drop_non_ref", c_ubyte),
("no_byterange_forward", c_ubyte),
("to_pck", c_uint),
("orig_delay", c_uint),
("hint_first_dts", c_ulonglong),
("hint_start_offset", c_ulonglong),
("hint_end_offset", c_ulonglong)
]
## \endcond
## event value, as defined in libgpac and usable as a Python object
#Fields have the same types, names and semantics as \ref GF_FEVT_SourceSeek
class FEVT_SourceSeek(Structure):
## \cond private
_fields_ = [
("type", c_uint),
("on_pid", _gf_filter_pid),
("start_offset", c_ulonglong),
("end_offset", c_ulonglong),
("source_switch", c_char_p),
("is_init_segment", c_ubyte),
("skip_cache_expiration", c_ubyte),
("hint_block_size", c_uint)
]
## \endcond
## event value, as defined in libgpac and usable as a Python object
#Fields have the same types, names and semantics as \ref GF_FEVT_SegmentSize
class FEVT_SegmentSize(Structure):
## \cond private
_fields_ = [
("type", c_uint),
("on_pid", _gf_filter_pid),
("seg_url", c_char_p),
("is_init", gf_bool),
("media_range_start", c_ulonglong),
("media_range_end", c_ulonglong),
("idx_range_start", c_ulonglong),
("idx_range_end", c_ulonglong),
("is_init", c_ubyte),
("is_shift", c_ubyte)
]
## \endcond
## event value, as defined in libgpac and usable as a Python object
#Fields have the same types, names and semantics as \ref GF_FEVT_FragmentSize
class FEVT_FragmentSize(Structure):
## \cond private
_fields_ = [
("type", c_uint),
("on_pid", _gf_filter_pid),
("is_last", gf_bool),
("offset", c_ulonglong),
("size", c_ulonglong),
("duration", Fraction64),
("independent", gf_bool),
]
## \endcond
## event value, as defined in libgpac and usable as a Python object
#Fields have the same types, names and semantics as \ref GF_FEVT_AttachScene
class FEVT_AttachScene(Structure):
## \cond private
_fields_ = [
("type", c_uint),
("on_pid", _gf_filter_pid),
("odm", c_void_p),
("node", c_void_p)
]
## \endcond
## event value, as defined in libgpac and usable as a Python object
#Fields have the same types, names and semantics as \ref GF_FEVT_QualitySwitch
class FEVT_QualitySwitch(Structure):
## \cond private
_fields_ = [
("type", c_uint),
("on_pid", _gf_filter_pid),
("up", gf_bool),
("dependent_group_index", c_uint),
("q_idx", c_int),
("set_tile_mode_plus_one", c_uint),
("quality_degradation", c_uint)
]
## \endcond
#TODO GF_FEVT_Event;
## event value, as defined in libgpac and usable as a Python object
#Fields have the same types, names and semantics as \ref GF_FEVT_FileDelete
class FEVT_FileDelete(Structure):
## \cond private
_fields_ = [
("type", c_uint),
("on_pid", _gf_filter_pid),
("url", c_char_p)
]
## \endcond
## event value, as defined in libgpac and usable as a Python object
#Fields have the same types, names and semantics as \ref GF_FEVT_VisibilityHint
class FEVT_VisibilityHint(Structure):
## \cond private
_fields_ = [
("type", c_uint),
("on_pid", _gf_filter_pid),
("min_x", c_uint),
("max_x", c_uint),
("min_y", c_uint),
("max_y", c_uint),
("is_gaze", gf_bool)
]
## \endcond
## event value, as defined in libgpac and usable as a Python object
#Fields have the same types, names and semantics as \ref GF_FEVT_BufferRequirement
class FEVT_BufferRequirement(Structure):
## \cond private
_fields_ = [
("type", c_uint),
("on_pid", _gf_filter_pid),
("max_buffer_us", c_uint),
("max_playout_us", c_uint),
("min_playout_us", c_uint),
("pid_only", gf_bool)
]
## \endcond
## event value, as defined in libgpac and usable as a Python object
#Fields have the same types, names and semantics as \ref GF_FEVT_EncodeHints
class FEVT_EncodeHints(Structure):
## \cond private
_fields_ = [
("type", c_uint),
("on_pid", _gf_filter_pid),
("intra_period", Fraction),
("gen_dsi_only", gf_bool)
]
## \endcond
## event value, as defined in libgpac and usable as a Python object
#Fields have the same types, names and semantics as \ref GF_FEVT_NTPRef
class FEVT_NTPRef(Structure):
## \cond private
_fields_ = [
("type", c_uint),
("on_pid", _gf_filter_pid),
("ntp", c_ulonglong)
]
## \endcond
## event value, as defined in libgpac and usable as a Python object
#Fields have the same types, names and semantics as \ref GF_EventMouse
class EVT_mouse(Structure):
## \cond private
_fields_ = [
("type", c_ubyte),
("x", c_int),
("y", c_int),
("wheel", c_float),
("button", c_int),
("keys", c_uint),
("window_id", c_uint)
]
## \endcond
## event value, as defined in libgpac and usable as a Python object
#Fields have the same types, names and semantics as \ref GF_EventMultiTouch
class EVT_mtouch(Structure):
## \cond private
_fields_ = [
("type", c_ubyte),
("x", c_float),
("y", c_float),
("rotation", c_float),
("pinch", c_float),
("num_fingers", c_uint),
("window_id", c_uint)
]
## \endcond
## event value, as defined in libgpac and usable as a Python object
#Fields have the same types, names and semantics as \ref GF_EventKey
class EVT_keys(Structure):
## \cond private
_fields_ = [
("type", c_ubyte),
("key_code", c_uint),
("hw_code", c_uint),
("flags", c_uint),
("window_id", c_uint)
]
## \endcond
## event value, as defined in libgpac and usable as a Python object
#Fields have the same types, names and semantics as \ref GF_EventChar
class EVT_char(Structure):
## \cond private
_fields_ = [
("type", c_ubyte),
("unicode_char", c_uint),
("window_id", c_uint)
]
## \endcond
## event value, as defined in libgpac and usable as a Python object
#Fields have the same types, names and semantics as \ref GF_EventSize
class EVT_size(Structure):
## \cond private
_fields_ = [
("type", c_ubyte),
("width", c_uint),
("height", c_uint),
("orientation", c_uint),
("window_id", c_uint)
]
## \endcond
## event value, as defined in libgpac and usable as a Python object
#Fields have the same types, names and semantics as \ref GF_EventShow
class EVT_show(Structure):
## \cond private
_fields_ = [
("type", c_ubyte),
("show_type", c_uint),
("window_id", c_uint)
]
## \endcond
## event value, as defined in libgpac and usable as a Python object
#Fields have the same types, names and semantics as GF_Event
#only common events from GPAC video ouput are mapped
class EVT_base(Union):
## \cond private
_fields_ = [
("type", c_ubyte),
("mouse", EVT_mouse),
("mtouch", EVT_mtouch),
("keys", EVT_keys),
("char", EVT_char),
("size", EVT_size),
("show", EVT_show)
]
## \endcond
## event value, as defined in libgpac and usable as a Python object
#Fields have the same types, names and semantics as \ref GF_FEVT_Event
class FEVT_UserEvent(Structure):