[vlc-commits] python: fix unserializing of title/chapter descriptions
Olivier Aubert
git at videolan.org
Wed Jul 11 00:27:49 CEST 2018
vlc/python | branch: master | Olivier Aubert <contact at olivieraubert.net> | Mon May 14 17:58:34 2018 +0200| [0eeb9ca92ae1aeacfbe61f34201442dc98171ed3] | committer: Olivier Aubert
python: fix unserializing of title/chapter descriptions
> http://git.videolan.org/gitweb.cgi/vlc/python.git/?a=commit;h=0eeb9ca92ae1aeacfbe61f34201442dc98171ed3
---
generator/templates/override.py | 20 ++++++++++++++++----
1 file changed, 16 insertions(+), 4 deletions(-)
diff --git a/generator/templates/override.py b/generator/templates/override.py
index e58bef5..3de106b 100644
--- a/generator/templates/override.py
+++ b/generator/templates/override.py
@@ -291,8 +291,14 @@ class MediaPlayer: #PYCHOK expected (comment is lost)
'''
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.
@@ -302,8 +308,14 @@ class MediaPlayer: #PYCHOK expected (comment is lost)
'''
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).
More information about the vlc-commits
mailing list