Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
videolan
vlc
Commits
d3b60bf0
Commit
d3b60bf0
authored
Sep 03, 2009
by
Olivier Aubert
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
python-ctypes: fix Logger bindings.
parent
5f760829
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
43 additions
and
5 deletions
+43
-5
bindings/python-ctypes/generate.py
bindings/python-ctypes/generate.py
+8
-2
bindings/python-ctypes/header.py
bindings/python-ctypes/header.py
+3
-0
bindings/python-ctypes/override.py
bindings/python-ctypes/override.py
+6
-3
bindings/python-ctypes/test.py
bindings/python-ctypes/test.py
+26
-0
No files found.
bindings/python-ctypes/generate.py
View file @
d3b60bf0
...
...
@@ -329,7 +329,7 @@ class PythonGenerator(object):
'libvlc_media_t*'
:
'Media'
,
'libvlc_log_t*'
:
'Log'
,
'libvlc_log_iterator_t*'
:
'LogIterator'
,
'libvlc_log_message_t*'
:
'
LogMessage
'
,
'libvlc_log_message_t*'
:
'
ctypes.POINTER(LogMessage)
'
,
'libvlc_event_type_t'
:
'ctypes.c_uint'
,
'libvlc_event_manager_t*'
:
'EventManager'
,
'libvlc_media_discoverer_t*'
:
'MediaDiscoverer'
,
...
...
@@ -658,9 +658,15 @@ class PythonGenerator(object):
# Check for standard methods
if name == '
count
':
# There is a count method. Generate a __len__ one.
self.output(""" def __len__(self):
if params and params[-1][0] == '
libvlc_exception_t
*
':
self.output(""" def __len__(self):
e=VLCException()
return %s(self, e)
""" % method)
else:
# No exception
self.output(""" def __len__(self):
return %s(self)
""" % method)
elif name.endswith('
item_at_index
'):
# Indexable (and thus iterable)"
...
...
bindings/python-ctypes/header.py
View file @
d3b60bf0
...
...
@@ -149,6 +149,9 @@ class LogMessage(ctypes.Structure):
(
'message'
,
ctypes
.
c_char_p
),
]
def
__init__
(
self
):
self
.
size
=
ctypes
.
sizeof
(
self
)
def
__str__
(
self
):
return
"vlc.LogMessage(%d:%s): %s"
%
(
self
.
severity
,
self
.
type
,
self
.
message
)
...
...
bindings/python-ctypes/override.py
View file @
d3b60bf0
...
...
@@ -210,11 +210,14 @@ class LogIterator:
def
next
(
self
):
if
not
self
.
has_next
():
raise
StopIteration
buf
fer
=
LogMessage
()
buf
=
LogMessage
()
e
=
VLCException
()
ret
=
libvlc_log_iterator_next
(
self
,
buf
fer
,
e
)
return
ret
ret
=
libvlc_log_iterator_next
(
self
,
buf
,
e
)
return
ret
.
contents
class
Log
:
def
__iter__
(
self
):
return
self
.
get_iterator
()
def
dump
(
self
):
return
[
str
(
m
)
for
m
in
self
]
bindings/python-ctypes/test.py
View file @
d3b60bf0
...
...
@@ -107,5 +107,31 @@ class TestVLCAPI(unittest.TestCase):
p
=
i
.
media_player_new
(
mrl
)
self
.
assertEqual
(
p
.
get_state
(),
vlc
.
State
.
Ended
)
def
test_libvlc_logger
(
self
):
i
=
vlc
.
Instance
()
l
=
i
.
log_open
()
l
.
clear
()
self
.
assertEqual
(
l
.
count
(),
0
)
l
.
close
()
def
test_libvlc_logger_clear
(
self
):
i
=
vlc
.
Instance
()
l
=
i
.
log_open
()
l
.
clear
()
self
.
assertEqual
(
l
.
count
(),
0
)
l
.
close
()
def
test_libvlc_logger
(
self
):
i
=
vlc
.
Instance
()
i
.
set_log_verbosity
(
3
)
l
=
i
.
log_open
()
# This should generate a log message
i
.
add_intf
(
'dummy'
)
self
.
assertNotEqual
(
l
.
count
(),
0
)
for
m
in
l
:
# Ensure that messages can be read.
self
.
assertNotEqual
(
len
(
m
.
message
),
0
)
l
.
close
()
if
__name__
==
'__main__'
:
unittest
.
main
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment