[vlc-commits] python: fix struct definitions
Olivier Aubert
git at videolan.org
Wed Jul 11 00:27:53 CEST 2018
vlc/python | branch: master | Olivier Aubert <contact at olivieraubert.net> | Mon May 14 19:15:21 2018 +0200| [991d601007f772dda6cc4dbbf7e658353ea647e4] | committer: Olivier Aubert
python: fix struct definitions
Closes #50
> http://git.videolan.org/gitweb.cgi/vlc/python.git/?a=commit;h=991d601007f772dda6cc4dbbf7e658353ea647e4
---
generated/3.0/vlc.py | 32 ++++++++++++++++++++++----------
generated/dev/vlc.py | 32 ++++++++++++++++++++++----------
generator/templates/header.py | 10 +++++-----
tests/test.py | 7 ++++---
4 files changed, 53 insertions(+), 28 deletions(-)
diff --git a/generated/3.0/vlc.py b/generated/3.0/vlc.py
index 0253312..f909443 100644
--- a/generated/3.0/vlc.py
+++ b/generated/3.0/vlc.py
@@ -55,7 +55,7 @@ logger = logging.getLogger(__name__)
__version__ = "3.0.2102"
__libvlc_version__ = "3.0.2"
__generator_version__ = "1.2"
-build_date = "Fri May 11 18:17:40 2018 3.0.2"
+build_date = "Mon May 14 17:58:40 2018 3.0.2"
# The libvlc doc states that filenames are expected to be in UTF8, do
# not rely on sys.getfilesystemencoding() which will be confused,
@@ -1567,21 +1567,21 @@ AudioOutputDevice._fields_ = [ # recursive struct
]
class TitleDescription(_Cstruct):
- _fields = [
+ _fields_ = [
('duration', ctypes.c_longlong),
('name', ctypes.c_char_p),
('menu', ctypes.c_bool),
]
class ChapterDescription(_Cstruct):
- _fields = [
+ _fields_ = [
('time_offset', ctypes.c_longlong),
('duration', ctypes.c_longlong),
('name', ctypes.c_char_p),
]
class VideoViewpoint(_Cstruct):
- _fields = [
+ _fields_ = [
('yaw', ctypes.c_float),
('pitch', ctypes.c_float),
('roll', ctypes.c_float),
@@ -1592,14 +1592,14 @@ class VideoViewpoint(_Cstruct):
# in > 2.2
if 'MediaSlaveType' in locals():
class MediaSlave(_Cstruct):
- _fields = [
+ _fields_ = [
('psz_uri', ctypes.c_char_p),
('i_type', MediaSlaveType),
('i_priority', ctypes.c_uint)
]
class RDDescription(_Cstruct):
- _fields = [
+ _fields_ = [
('name', ctypes.c_char_p),
('longname', ctypes.c_char_p)
]
@@ -3231,8 +3231,14 @@ class MediaPlayer(_Ctype):
'''
titleDescription_pp = ctypes.POINTER(TitleDescription)()
n = libvlc_media_player_get_full_title_descriptions(self, ctypes.byref(titleDescription_pp))
- info = ctypes.cast(ctypes.titleDescription_pp, ctypes.POINTER(ctypes.POINTER(TitleDescription) * n))
- return info
+ info = ctypes.cast(titleDescription_pp, ctypes.POINTER(ctypes.POINTER(TitleDescription) * n))
+ try:
+ contents = info.contents
+ except ValueError:
+ # Media not parsed, no info.
+ return None
+ descr = ( contents[i].contents for i in range(len(contents)) )
+ return descr
def get_full_chapter_descriptions(self, i_chapters_of_title):
'''Get the full description of available chapters.
@@ -3242,8 +3248,14 @@ class MediaPlayer(_Ctype):
'''
chapterDescription_pp = ctypes.POINTER(ChapterDescription)()
n = libvlc_media_player_get_full_chapter_descriptions(self, ctypes.byref(chapterDescription_pp))
- info = ctypes.cast(ctypes.chapterDescription_pp, ctypes.POINTER(ctypes.POINTER(ChapterDescription) * n))
- return info
+ info = ctypes.cast(chapterDescription_pp, ctypes.POINTER(ctypes.POINTER(ChapterDescription) * n))
+ try:
+ contents = info.contents
+ except ValueError:
+ # Media not parsed, no info.
+ return None
+ descr = ( contents[i].contents for i in range(len(contents)) )
+ return descr
def video_get_size(self, num=0):
"""Get the video size in pixels as 2-tuple (width, height).
diff --git a/generated/dev/vlc.py b/generated/dev/vlc.py
index 4f2b306..450f4e3 100644
--- a/generated/dev/vlc.py
+++ b/generated/dev/vlc.py
@@ -55,7 +55,7 @@ logger = logging.getLogger(__name__)
__version__ = "4.0.0-dev-2548-g1a5afc2114102"
__libvlc_version__ = "4.0.0-dev-2548-g1a5afc2114"
__generator_version__ = "1.2"
-build_date = "Fri May 11 18:17:40 2018 4.0.0-dev-2548-g1a5afc2114"
+build_date = "Mon May 14 17:58:40 2018 4.0.0-dev-2548-g1a5afc2114"
# The libvlc doc states that filenames are expected to be in UTF8, do
# not rely on sys.getfilesystemencoding() which will be confused,
@@ -1588,21 +1588,21 @@ AudioOutputDevice._fields_ = [ # recursive struct
]
class TitleDescription(_Cstruct):
- _fields = [
+ _fields_ = [
('duration', ctypes.c_longlong),
('name', ctypes.c_char_p),
('menu', ctypes.c_bool),
]
class ChapterDescription(_Cstruct):
- _fields = [
+ _fields_ = [
('time_offset', ctypes.c_longlong),
('duration', ctypes.c_longlong),
('name', ctypes.c_char_p),
]
class VideoViewpoint(_Cstruct):
- _fields = [
+ _fields_ = [
('yaw', ctypes.c_float),
('pitch', ctypes.c_float),
('roll', ctypes.c_float),
@@ -1613,14 +1613,14 @@ class VideoViewpoint(_Cstruct):
# in > 2.2
if 'MediaSlaveType' in locals():
class MediaSlave(_Cstruct):
- _fields = [
+ _fields_ = [
('psz_uri', ctypes.c_char_p),
('i_type', MediaSlaveType),
('i_priority', ctypes.c_uint)
]
class RDDescription(_Cstruct):
- _fields = [
+ _fields_ = [
('name', ctypes.c_char_p),
('longname', ctypes.c_char_p)
]
@@ -3252,8 +3252,14 @@ class MediaPlayer(_Ctype):
'''
titleDescription_pp = ctypes.POINTER(TitleDescription)()
n = libvlc_media_player_get_full_title_descriptions(self, ctypes.byref(titleDescription_pp))
- info = ctypes.cast(ctypes.titleDescription_pp, ctypes.POINTER(ctypes.POINTER(TitleDescription) * n))
- return info
+ info = ctypes.cast(titleDescription_pp, ctypes.POINTER(ctypes.POINTER(TitleDescription) * n))
+ try:
+ contents = info.contents
+ except ValueError:
+ # Media not parsed, no info.
+ return None
+ descr = ( contents[i].contents for i in range(len(contents)) )
+ return descr
def get_full_chapter_descriptions(self, i_chapters_of_title):
'''Get the full description of available chapters.
@@ -3263,8 +3269,14 @@ class MediaPlayer(_Ctype):
'''
chapterDescription_pp = ctypes.POINTER(ChapterDescription)()
n = libvlc_media_player_get_full_chapter_descriptions(self, ctypes.byref(chapterDescription_pp))
- info = ctypes.cast(ctypes.chapterDescription_pp, ctypes.POINTER(ctypes.POINTER(ChapterDescription) * n))
- return info
+ info = ctypes.cast(chapterDescription_pp, ctypes.POINTER(ctypes.POINTER(ChapterDescription) * n))
+ try:
+ contents = info.contents
+ except ValueError:
+ # Media not parsed, no info.
+ return None
+ descr = ( contents[i].contents for i in range(len(contents)) )
+ return descr
def video_get_size(self, num=0):
"""Get the video size in pixels as 2-tuple (width, height).
diff --git a/generator/templates/header.py b/generator/templates/header.py
index 0c2aacd..5256d7f 100755
--- a/generator/templates/header.py
+++ b/generator/templates/header.py
@@ -635,21 +635,21 @@ AudioOutputDevice._fields_ = [ # recursive struct
]
class TitleDescription(_Cstruct):
- _fields = [
+ _fields_ = [
('duration', ctypes.c_longlong),
('name', ctypes.c_char_p),
('menu', ctypes.c_bool),
]
class ChapterDescription(_Cstruct):
- _fields = [
+ _fields_ = [
('time_offset', ctypes.c_longlong),
('duration', ctypes.c_longlong),
('name', ctypes.c_char_p),
]
class VideoViewpoint(_Cstruct):
- _fields = [
+ _fields_ = [
('yaw', ctypes.c_float),
('pitch', ctypes.c_float),
('roll', ctypes.c_float),
@@ -660,14 +660,14 @@ class VideoViewpoint(_Cstruct):
# in > 2.2
if 'MediaSlaveType' in locals():
class MediaSlave(_Cstruct):
- _fields = [
+ _fields_ = [
('psz_uri', ctypes.c_char_p),
('i_type', MediaSlaveType),
('i_priority', ctypes.c_uint)
]
class RDDescription(_Cstruct):
- _fields = [
+ _fields_ = [
('name', ctypes.c_char_p),
('longname', ctypes.c_char_p)
]
diff --git a/tests/test.py b/tests/test.py
index 932205b..d958114 100755
--- a/tests/test.py
+++ b/tests/test.py
@@ -116,9 +116,10 @@ class TestVLCAPI(unittest.TestCase):
url_encoded_mrl = urllib.quote(mrl.encode('utf-8'))
self.assertEqual(m.get_mrl(), 'file://' + url_encoded_mrl)
- def test_new_libvlc_viewpoint(self):
- view = vlc.libvlc_video_new_viewpoint()
- self.assertEqual(str(view.contents), 'VideoViewpoint')
+ def test_libvlc_video_new_viewpoint(self):
+ vp = vlc.libvlc_video_new_viewpoint()
+ vp.contents.yaw = 2
+ self.assertEqual(vp.contents.yaw, 2)
def no_test_callback(self):
More information about the vlc-commits
mailing list