Skip to content

Commit 7730d22

Browse files
committed
Fix Struct override handling
Closes #253
1 parent deb0e9d commit 7730d22

File tree

6 files changed

+248
-96
lines changed

6 files changed

+248
-96
lines changed

generated/3.0/setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from setuptools import setup
55

66
setup(name='python-vlc',
7-
version = '3.0.18121',
7+
version = '3.0.18122',
88
author='Olivier Aubert',
99
author_email='contact@olivieraubert.net',
1010
maintainer='Olivier Aubert',
@@ -35,5 +35,5 @@
3535
player. Note that it relies on an already present install of VLC.
3636
3737
It has been automatically generated from the include files of
38-
vlc 3.0.18, using generator 1.21.
38+
vlc 3.0.18, using generator 1.22.
3939
""")

generated/3.0/vlc.py

Lines changed: 32 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,10 @@
5151
import logging
5252
logger = logging.getLogger(__name__)
5353

54-
__version__ = "3.0.18121"
54+
__version__ = "3.0.18122"
5555
__libvlc_version__ = "3.0.18"
56-
__generator_version__ = "1.21"
57-
build_date = "Wed Nov 16 12:04:29 2022 3.0.18"
56+
__generator_version__ = "1.22"
57+
build_date = "Wed Apr 19 17:27:23 2023 3.0.18"
5858

5959
# The libvlc doc states that filenames are expected to be in UTF8, do
6060
# not rely on sys.getfilesystemencoding() which will be confused,
@@ -1060,6 +1060,28 @@ class MediaPlayerRole(_Enum):
10601060

10611061
# End of generated enum types #
10621062

1063+
class EventUnion(ctypes.Union):
1064+
_fields_ = [
1065+
('meta_type', ctypes.c_uint ),
1066+
('new_child', ctypes.c_uint ),
1067+
('new_duration', ctypes.c_longlong),
1068+
('new_status', ctypes.c_int ),
1069+
('media', ctypes.c_void_p ),
1070+
('new_state', ctypes.c_uint ),
1071+
# FIXME: Media instance
1072+
('new_cache', ctypes.c_float ),
1073+
('new_position', ctypes.c_float ),
1074+
('new_time', ctypes.c_longlong),
1075+
('new_title', ctypes.c_int ),
1076+
('new_seekable', ctypes.c_longlong),
1077+
('new_pausable', ctypes.c_longlong),
1078+
('new_scrambled', ctypes.c_longlong),
1079+
('new_count', ctypes.c_longlong),
1080+
# FIXME: Skipped MediaList and MediaListView...
1081+
('filename', ctypes.c_char_p ),
1082+
('new_length', ctypes.c_longlong),
1083+
]
1084+
10631085
# Generated structs #
10641086
class LogMessage(ctypes.Structure):
10651087
'''N/A
@@ -1096,11 +1118,13 @@ class Event(ctypes.Structure):
10961118
'''A libvlc event.
10971119
'''
10981120
pass
1099-
Event._fields_ = (
1100-
('type', ctypes.c_int),
1101-
('obj', ctypes.c_void_p),
1102-
('meta_type', Meta),
1103-
)
1121+
_fields_ = [
1122+
('type', EventType ),
1123+
('object', ctypes.c_void_p),
1124+
('u', EventUnion ),
1125+
]
1126+
1127+
11041128

11051129
class MediaStats(ctypes.Structure):
11061130
'''Note the order of libvlc_state_t enum must match exactly the order of

generated/dev/vlc.py

Lines changed: 172 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,10 @@
5151
import logging
5252
logger = logging.getLogger(__name__)
5353

54-
__version__ = "4.0.0-dev-20729-g085d1ae71b121"
55-
__libvlc_version__ = "4.0.0-dev-20729-g085d1ae71b"
56-
__generator_version__ = "1.21"
57-
build_date = "Wed Nov 16 12:04:29 2022 4.0.0-dev-20729-g085d1ae71b"
54+
__version__ = "4.0.0122"
55+
__libvlc_version__ = "4.0.0"
56+
__generator_version__ = "1.22"
57+
build_date = "Wed Apr 19 17:27:22 2023 4.0.0"
5858

5959
# The libvlc doc states that filenames are expected to be in UTF8, do
6060
# not rely on sys.getfilesystemencoding() which will be confused,
@@ -732,12 +732,14 @@ class MediaParseFlag(_Enum):
732732
0x2: 'fetch_local',
733733
0x4: 'fetch_network',
734734
0x8: 'do_interact',
735+
0x10: 'no_skip',
735736
}
736737
MediaParseFlag.do_interact = MediaParseFlag(0x8)
737738
MediaParseFlag.fetch_local = MediaParseFlag(0x2)
738739
MediaParseFlag.fetch_network = MediaParseFlag(0x4)
739740
MediaParseFlag.local = MediaParseFlag(0x0)
740741
MediaParseFlag.network = MediaParseFlag(0x1)
742+
MediaParseFlag.no_skip = MediaParseFlag(0x10)
741743

742744
class MediaParsedStatus(_Enum):
743745
'''Parse status used sent by libvlc_media_parse_request() or returned by
@@ -1015,23 +1017,43 @@ class VideoAdjustOption(_Enum):
10151017
VideoAdjustOption.Hue = VideoAdjustOption(3)
10161018
VideoAdjustOption.Saturation = VideoAdjustOption(4)
10171019

1018-
class AudioOutputChannel(_Enum):
1019-
'''Audio channels.
1020+
class AudioOutputStereomode(_Enum):
1021+
'''Audio stereo modes.
10201022
'''
10211023
_enum_names_ = {
1022-
-1: 'Error',
1023-
1: 'Stereo',
1024-
2: 'RStereo',
1025-
3: 'Left',
1026-
4: 'Right',
1027-
5: 'Dolbys',
1024+
0: 'AudioStereoMode_Unset',
1025+
1: 'AudioStereoMode_Stereo',
1026+
2: 'AudioStereoMode_RStereo',
1027+
3: 'AudioStereoMode_Left',
1028+
4: 'AudioStereoMode_Right',
1029+
5: 'AudioStereoMode_Dolbys',
1030+
7: 'AudioStereoMode_Mono',
10281031
}
1029-
AudioOutputChannel.Dolbys = AudioOutputChannel(5)
1030-
AudioOutputChannel.Error = AudioOutputChannel(-1)
1031-
AudioOutputChannel.Left = AudioOutputChannel(3)
1032-
AudioOutputChannel.RStereo = AudioOutputChannel(2)
1033-
AudioOutputChannel.Right = AudioOutputChannel(4)
1034-
AudioOutputChannel.Stereo = AudioOutputChannel(1)
1032+
AudioOutputStereomode.AudioStereoMode_Dolbys = AudioOutputStereomode(5)
1033+
AudioOutputStereomode.AudioStereoMode_Left = AudioOutputStereomode(3)
1034+
AudioOutputStereomode.AudioStereoMode_Mono = AudioOutputStereomode(7)
1035+
AudioOutputStereomode.AudioStereoMode_RStereo = AudioOutputStereomode(2)
1036+
AudioOutputStereomode.AudioStereoMode_Right = AudioOutputStereomode(4)
1037+
AudioOutputStereomode.AudioStereoMode_Stereo = AudioOutputStereomode(1)
1038+
AudioOutputStereomode.AudioStereoMode_Unset = AudioOutputStereomode(0)
1039+
1040+
class AudioOutputMixmode(_Enum):
1041+
'''Audio mix modes.
1042+
'''
1043+
_enum_names_ = {
1044+
0: 'AudioMixMode_Unset',
1045+
1: 'AudioMixMode_Stereo',
1046+
2: 'AudioMixMode_Binaural',
1047+
3: 'AudioMixMode_4_0',
1048+
4: 'AudioMixMode_5_1',
1049+
5: 'AudioMixMode_7_1',
1050+
}
1051+
AudioOutputMixmode.AudioMixMode_4_0 = AudioOutputMixmode(3)
1052+
AudioOutputMixmode.AudioMixMode_5_1 = AudioOutputMixmode(4)
1053+
AudioOutputMixmode.AudioMixMode_7_1 = AudioOutputMixmode(5)
1054+
AudioOutputMixmode.AudioMixMode_Binaural = AudioOutputMixmode(2)
1055+
AudioOutputMixmode.AudioMixMode_Stereo = AudioOutputMixmode(1)
1056+
AudioOutputMixmode.AudioMixMode_Unset = AudioOutputMixmode(0)
10351057

10361058
class MediaPlayerRole(_Enum):
10371059
'''Media player roles.
@@ -1149,6 +1171,28 @@ class PictureType(_Enum):
11491171

11501172
# End of generated enum types #
11511173

1174+
class EventUnion(ctypes.Union):
1175+
_fields_ = [
1176+
('meta_type', ctypes.c_uint ),
1177+
('new_child', ctypes.c_uint ),
1178+
('new_duration', ctypes.c_longlong),
1179+
('new_status', ctypes.c_int ),
1180+
('media', ctypes.c_void_p ),
1181+
('new_state', ctypes.c_uint ),
1182+
# FIXME: Media instance
1183+
('new_cache', ctypes.c_float ),
1184+
('new_position', ctypes.c_float ),
1185+
('new_time', ctypes.c_longlong),
1186+
('new_title', ctypes.c_int ),
1187+
('new_seekable', ctypes.c_longlong),
1188+
('new_pausable', ctypes.c_longlong),
1189+
('new_scrambled', ctypes.c_longlong),
1190+
('new_count', ctypes.c_longlong),
1191+
# FIXME: Skipped MediaList and MediaListView...
1192+
('filename', ctypes.c_char_p ),
1193+
('new_length', ctypes.c_longlong),
1194+
]
1195+
11521196
# Generated structs #
11531197
class TrackDescription(ctypes.Structure):
11541198
'''Description for video, audio tracks and subtitles. it contains
@@ -1188,11 +1232,13 @@ class Event(ctypes.Structure):
11881232
'''A libvlc event.
11891233
'''
11901234
pass
1191-
Event._fields_ = (
1192-
('type', ctypes.c_int),
1193-
('p_obj', ctypes.c_void_p),
1194-
('meta_type', Meta),
1195-
)
1235+
_fields_ = [
1236+
('type', EventType ),
1237+
('object', ctypes.c_void_p),
1238+
('u', EventUnion ),
1239+
]
1240+
1241+
11961242

11971243
class MediaStats(ctypes.Structure):
11981244
'''Libvlc media or media_player state.
@@ -4395,19 +4441,50 @@ def audio_set_volume(self, i_volume):
43954441
return libvlc_audio_set_volume(self, i_volume)
43964442

43974443

4398-
def audio_get_channel(self):
4399-
'''Get current audio channel.
4400-
@return: the audio channel See L{AudioOutputChannel}.
4444+
def audio_get_stereomode(self):
4445+
'''Get current audio stereo-mode.
4446+
@return: the audio stereo-mode, See L{AudioOutputStereomode}.
4447+
@version: LibVLC 4.0.0 or later.
44014448
'''
4402-
return libvlc_audio_get_channel(self)
4449+
return libvlc_audio_get_stereomode(self)
44034450

44044451

4405-
def audio_set_channel(self, channel):
4406-
'''Set current audio channel.
4407-
@param channel: the audio channel, See L{AudioOutputChannel}.
4452+
def audio_set_stereomode(self, mode):
4453+
'''Set current audio stereo-mode.
4454+
@param channel: the audio stereo-mode, See L{AudioOutputStereomode}.
44084455
@return: 0 on success, -1 on error.
4456+
@version: LibVLC 4.0.0 or later.
4457+
'''
4458+
return libvlc_audio_set_stereomode(self, mode)
4459+
4460+
4461+
def audio_get_mixmode(self):
4462+
'''Get current audio mix-mode.
4463+
@return: the audio mix-mode, See L{AudioOutputMixmode}.
4464+
@version: LibVLC 4.0.0 or later.
4465+
'''
4466+
return libvlc_audio_get_mixmode(self)
4467+
4468+
4469+
def audio_set_mixmode(self, mode):
4470+
'''Set current audio mix-mode.
4471+
By default (libvlc_AudioMixMode_Unset), the audio output will keep its
4472+
original channel configuration (play stereo as stereo, or 5.1 as 5.1). Yet,
4473+
the OS and Audio API might refuse a channel configuration and asks VLC to
4474+
adapt (Stereo played as 5.1 or vice-versa).
4475+
This function allows to force a channel configuration, it will only work if
4476+
the OS and Audio API accept this configuration (otherwise, it won't have any
4477+
effects). Here are some examples:
4478+
- Play multi-channels (5.1, 7.1...) as stereo (libvlc_AudioMixMode_Stereo)
4479+
- Play Stereo or 5.1 as 7.1 (libvlc_AudioMixMode_7_1)
4480+
- Play multi-channels as stereo with a binaural effect
4481+
(libvlc_AudioMixMode_Binaural). It might be selected automatically if the
4482+
OS and Audio API can detect if a headphone is plugged.
4483+
@param channel: the audio mix-mode, See L{AudioOutputMixmode}.
4484+
@return: 0 on success, -1 on error.
4485+
@version: LibVLC 4.0.0 or later.
44094486
'''
4410-
return libvlc_audio_set_channel(self, channel)
4487+
return libvlc_audio_set_mixmode(self, mode)
44114488

44124489

44134490
def audio_get_delay(self):
@@ -4908,6 +4985,18 @@ def libvlc_retain(p_instance):
49084985
None, Instance)
49094986
return f(p_instance)
49104987

4988+
def libvlc_abi_version():
4989+
'''Get the ABI version of the libvlc library.
4990+
This is different than the VLC version, which is the version of the whole
4991+
VLC package. The value is the same as LIBVLC_ABI_VERSION_INT used when
4992+
compiling.
4993+
@return: a value with the following mask in hexadecimal 0xFF000000: major VLC version, similar to VLC major version, 0x00FF0000: major ABI version, incremented incompatible changes are added, 0x0000FF00: minor ABI version, incremented when new functions are added 0x000000FF: micro ABI version, incremented with new release/builds @note This the same value as the .so version but cross platform.
4994+
'''
4995+
f = _Cfunctions.get('libvlc_abi_version', None) or \
4996+
_Cfunction('libvlc_abi_version', (), None,
4997+
ctypes.c_int)
4998+
return f()
4999+
49115000
def libvlc_add_intf(p_instance, name):
49125001
'''Try to start a user interface for the libvlc instance.
49135002
@param p_instance: the instance.
@@ -7648,26 +7737,63 @@ def libvlc_audio_set_volume(p_mi, i_volume):
76487737
ctypes.c_int, MediaPlayer, ctypes.c_int)
76497738
return f(p_mi, i_volume)
76507739

7651-
def libvlc_audio_get_channel(p_mi):
7652-
'''Get current audio channel.
7740+
def libvlc_audio_get_stereomode(p_mi):
7741+
'''Get current audio stereo-mode.
76537742
@param p_mi: media player.
7654-
@return: the audio channel See L{AudioOutputChannel}.
7743+
@return: the audio stereo-mode, See L{AudioOutputStereomode}.
7744+
@version: LibVLC 4.0.0 or later.
76557745
'''
7656-
f = _Cfunctions.get('libvlc_audio_get_channel', None) or \
7657-
_Cfunction('libvlc_audio_get_channel', ((1,),), None,
7658-
ctypes.c_int, MediaPlayer)
7746+
f = _Cfunctions.get('libvlc_audio_get_stereomode', None) or \
7747+
_Cfunction('libvlc_audio_get_stereomode', ((1,),), None,
7748+
AudioOutputStereomode, MediaPlayer)
76597749
return f(p_mi)
76607750

7661-
def libvlc_audio_set_channel(p_mi, channel):
7662-
'''Set current audio channel.
7751+
def libvlc_audio_set_stereomode(p_mi, mode):
7752+
'''Set current audio stereo-mode.
76637753
@param p_mi: media player.
7664-
@param channel: the audio channel, See L{AudioOutputChannel}.
7754+
@param channel: the audio stereo-mode, See L{AudioOutputStereomode}.
76657755
@return: 0 on success, -1 on error.
7756+
@version: LibVLC 4.0.0 or later.
76667757
'''
7667-
f = _Cfunctions.get('libvlc_audio_set_channel', None) or \
7668-
_Cfunction('libvlc_audio_set_channel', ((1,), (1,),), None,
7669-
ctypes.c_int, MediaPlayer, ctypes.c_int)
7670-
return f(p_mi, channel)
7758+
f = _Cfunctions.get('libvlc_audio_set_stereomode', None) or \
7759+
_Cfunction('libvlc_audio_set_stereomode', ((1,), (1,),), None,
7760+
ctypes.c_int, MediaPlayer, AudioOutputStereomode)
7761+
return f(p_mi, mode)
7762+
7763+
def libvlc_audio_get_mixmode(p_mi):
7764+
'''Get current audio mix-mode.
7765+
@param p_mi: media player.
7766+
@return: the audio mix-mode, See L{AudioOutputMixmode}.
7767+
@version: LibVLC 4.0.0 or later.
7768+
'''
7769+
f = _Cfunctions.get('libvlc_audio_get_mixmode', None) or \
7770+
_Cfunction('libvlc_audio_get_mixmode', ((1,),), None,
7771+
AudioOutputMixmode, MediaPlayer)
7772+
return f(p_mi)
7773+
7774+
def libvlc_audio_set_mixmode(p_mi, mode):
7775+
'''Set current audio mix-mode.
7776+
By default (libvlc_AudioMixMode_Unset), the audio output will keep its
7777+
original channel configuration (play stereo as stereo, or 5.1 as 5.1). Yet,
7778+
the OS and Audio API might refuse a channel configuration and asks VLC to
7779+
adapt (Stereo played as 5.1 or vice-versa).
7780+
This function allows to force a channel configuration, it will only work if
7781+
the OS and Audio API accept this configuration (otherwise, it won't have any
7782+
effects). Here are some examples:
7783+
- Play multi-channels (5.1, 7.1...) as stereo (libvlc_AudioMixMode_Stereo)
7784+
- Play Stereo or 5.1 as 7.1 (libvlc_AudioMixMode_7_1)
7785+
- Play multi-channels as stereo with a binaural effect
7786+
(libvlc_AudioMixMode_Binaural). It might be selected automatically if the
7787+
OS and Audio API can detect if a headphone is plugged.
7788+
@param p_mi: media player.
7789+
@param channel: the audio mix-mode, See L{AudioOutputMixmode}.
7790+
@return: 0 on success, -1 on error.
7791+
@version: LibVLC 4.0.0 or later.
7792+
'''
7793+
f = _Cfunctions.get('libvlc_audio_set_mixmode', None) or \
7794+
_Cfunction('libvlc_audio_set_mixmode', ((1,), (1,),), None,
7795+
ctypes.c_int, MediaPlayer, AudioOutputMixmode)
7796+
return f(p_mi, mode)
76717797

76727798
def libvlc_audio_get_delay(p_mi):
76737799
'''Get current audio delay.
@@ -8299,7 +8425,8 @@ def libvlc_renderer_discoverer_list_release(pp_services, i_count):
82998425
# libvlc_video_output_set_resize_cb
83008426
# libvlc_video_set_output_callbacks
83018427

8302-
# 54 function(s) not wrapped as methods:
8428+
# 55 function(s) not wrapped as methods:
8429+
# libvlc_abi_version
83038430
# libvlc_audio_equalizer_get_band_count
83048431
# libvlc_audio_equalizer_get_band_frequency
83058432
# libvlc_audio_equalizer_get_preset_count

0 commit comments

Comments
 (0)