Merge lp:~trb143/openlp/no_vlc into lp:openlp

Proposed by Tim Bentley
Status: Superseded
Proposed branch: lp:~trb143/openlp/no_vlc
Merge into: lp:openlp
Diff against target: 8940 lines (+49/-8845)
4 files modified
openlp/core/ui/media/vendor/__init__.py (+0/-25)
openlp/core/ui/media/vendor/vlc.py (+0/-8775)
openlp/core/ui/media/vlcplayer.py (+47/-44)
scripts/check_dependencies.py (+2/-1)
To merge this branch: bzr merge lp:~trb143/openlp/no_vlc
Reviewer Review Type Date Requested Status
Raoul Snyman Needs Fixing
Review via email: mp+367067@code.launchpad.net

This proposal has been superseded by a proposal from 2019-05-08.

Commit message

This is for testing on different configurations.
media.vendor.vlc has been removed and python3-vlc installed in its place.

Works on Fedora

To post a comment you must log in.
Revision history for this message
Raoul Snyman (raoul-snyman) wrote :

Linux tests failed, please see https://ci.openlp.io/job/MP-02-Linux_Tests/148/ for more details

Revision history for this message
Raoul Snyman (raoul-snyman) wrote :

Linux tests failed, please see https://ci.openlp.io/job/MP-02-Linux_Tests/149/ for more details

Revision history for this message
Raoul Snyman (raoul-snyman) wrote :

There's just one test failing, now that I have installed python-vlc on the server, can you take a look please?

  https://ci.openlp.io/view/Merge%20Proposals/job/MP-02-Linux_Tests/149/console

review: Needs Fixing
lp:~trb143/openlp/no_vlc updated
2873. By Tim Bentley

remove unneeded test

2874. By Tim Bentley

remove commented out code

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== removed directory 'openlp/core/ui/media/vendor'
2=== removed file 'openlp/core/ui/media/vendor/__init__.py'
3--- openlp/core/ui/media/vendor/__init__.py 2019-04-13 13:00:22 +0000
4+++ openlp/core/ui/media/vendor/__init__.py 1970-01-01 00:00:00 +0000
5@@ -1,25 +0,0 @@
6-# -*- coding: utf-8 -*-
7-# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
8-
9-##########################################################################
10-# OpenLP - Open Source Lyrics Projection #
11-# ---------------------------------------------------------------------- #
12-# Copyright (c) 2008-2019 OpenLP Developers #
13-# ---------------------------------------------------------------------- #
14-# This program is free software: you can redistribute it and/or modify #
15-# it under the terms of the GNU General Public License as published by #
16-# the Free Software Foundation, either version 3 of the License, or #
17-# (at your option) any later version. #
18-# #
19-# This program is distributed in the hope that it will be useful, #
20-# but WITHOUT ANY WARRANTY; without even the implied warranty of #
21-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
22-# GNU General Public License for more details. #
23-# #
24-# You should have received a copy of the GNU General Public License #
25-# along with this program. If not, see <https://www.gnu.org/licenses/>. #
26-##########################################################################
27-"""
28-The :mod:`~openlp.core.ui.media.vendor` module contains any scripts or libraries
29-from 3rd party vendors which are required to make certain media modules work.
30-"""
31
32=== removed file 'openlp/core/ui/media/vendor/vlc.py'
33--- openlp/core/ui/media/vendor/vlc.py 2019-01-27 14:42:23 +0000
34+++ openlp/core/ui/media/vendor/vlc.py 1970-01-01 00:00:00 +0000
35@@ -1,8775 +0,0 @@
36-#! /usr/bin/python
37-# -*- coding: utf-8 -*-
38-
39-# Python ctypes bindings for VLC
40-#
41-# Copyright (C) 2009-2017 the VideoLAN team
42-# $Id: $
43-#
44-# Authors: Olivier Aubert <contact at olivieraubert.net>
45-# Jean Brouwers <MrJean1 at gmail.com>
46-# Geoff Salmon <geoff.salmon at gmail.com>
47-#
48-# This library is free software; you can redistribute it and/or modify
49-# it under the terms of the GNU Lesser General Public License as
50-# published by the Free Software Foundation; either version 2.1 of the
51-# License, or (at your option) any later version.
52-#
53-# This library is distributed in the hope that it will be useful, but
54-# WITHOUT ANY WARRANTY; without even the implied warranty of
55-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
56-# Lesser General Public License for more details.
57-#
58-# You should have received a copy of the GNU Lesser General Public
59-# License along with this library; if not, write to the Free Software
60-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA
61-
62-"""This module provides bindings for the LibVLC public API, see
63-U{http://wiki.videolan.org/LibVLC}.
64-
65-You can find the documentation and a README file with some examples
66-at U{http://www.olivieraubert.net/vlc/python-ctypes/}.
67-
68-Basically, the most important class is L{Instance}, which is used
69-to create a libvlc instance. From this instance, you then create
70-L{MediaPlayer} and L{MediaListPlayer} instances.
71-
72-Alternatively, you may create instances of the L{MediaPlayer} and
73-L{MediaListPlayer} class directly and an instance of L{Instance}
74-will be implicitly created. The latter can be obtained using the
75-C{get_instance} method of L{MediaPlayer} and L{MediaListPlayer}.
76-"""
77-
78-import ctypes
79-from ctypes.util import find_library
80-import os
81-import sys
82-import functools
83-
84-# Used by EventManager in override.py
85-from inspect import getargspec
86-
87-import logging
88-
89-logger = logging.getLogger(__name__)
90-
91-__version__ = "3.0.3104"
92-__libvlc_version__ = "3.0.3"
93-__generator_version__ = "1.4"
94-build_date = "Fri Jul 13 15:18:27 2018 3.0.3"
95-
96-# The libvlc doc states that filenames are expected to be in UTF8, do
97-# not rely on sys.getfilesystemencoding() which will be confused,
98-# esp. on windows.
99-DEFAULT_ENCODING = 'utf-8'
100-
101-if sys.version_info[0] > 2:
102- str = str
103- unicode = str
104- bytes = bytes
105- basestring = (str, bytes)
106- PYTHON3 = True
107-
108-
109- def str_to_bytes(s):
110- """Translate string or bytes to bytes.
111- """
112- if isinstance(s, str):
113- return bytes(s, DEFAULT_ENCODING)
114- else:
115- return s
116-
117-
118- def bytes_to_str(b):
119- """Translate bytes to string.
120- """
121- if isinstance(b, bytes):
122- return b.decode(DEFAULT_ENCODING)
123- else:
124- return b
125-else:
126- str = str
127- unicode = unicode
128- bytes = str
129- basestring = basestring
130- PYTHON3 = False
131-
132-
133- def str_to_bytes(s):
134- """Translate string or bytes to bytes.
135- """
136- if isinstance(s, unicode):
137- return s.encode(DEFAULT_ENCODING)
138- else:
139- return s
140-
141-
142- def bytes_to_str(b):
143- """Translate bytes to unicode string.
144- """
145- if isinstance(b, str):
146- return unicode(b, DEFAULT_ENCODING)
147- else:
148- return b
149-
150-# Internal guard to prevent internal classes to be directly
151-# instanciated.
152-_internal_guard = object()
153-
154-
155-def find_lib():
156- dll = None
157- plugin_path = os.environ.get('PYTHON_VLC_MODULE_PATH', None)
158- if 'PYTHON_VLC_LIB_PATH' in os.environ:
159- try:
160- dll = ctypes.CDLL(os.environ['PYTHON_VLC_LIB_PATH'])
161- except OSError:
162- logger.error("Cannot load lib specified by PYTHON_VLC_LIB_PATH env. variable")
163- sys.exit(1)
164- if plugin_path and not os.path.isdir(plugin_path):
165- logger.error("Invalid PYTHON_VLC_MODULE_PATH specified. Please fix.")
166- sys.exit(1)
167- if dll is not None:
168- return dll, plugin_path
169-
170- if sys.platform.startswith('linux'):
171- p = find_library('vlc')
172- try:
173- dll = ctypes.CDLL(p)
174- except OSError: # may fail
175- dll = ctypes.CDLL('libvlc.so.5')
176- elif sys.platform.startswith('win'):
177- libname = 'libvlc.dll'
178- p = find_library(libname)
179- if p is None:
180- try: # some registry settings
181- # leaner than win32api, win32con
182- if PYTHON3:
183- import winreg as w
184- else:
185- import _winreg as w
186- for r in w.HKEY_LOCAL_MACHINE, w.HKEY_CURRENT_USER:
187- try:
188- r = w.OpenKey(r, 'Software\\VideoLAN\\VLC')
189- plugin_path, _ = w.QueryValueEx(r, 'InstallDir')
190- w.CloseKey(r)
191- break
192- except w.error:
193- pass
194- except ImportError: # no PyWin32
195- pass
196- if plugin_path is None:
197- # try some standard locations.
198- programfiles = os.environ["ProgramFiles"]
199- homedir = os.environ["HOMEDRIVE"]
200- for p in ('{programfiles}\\VideoLan{libname}', '{homedir}:\\VideoLan{libname}',
201- '{programfiles}{libname}', '{homedir}:{libname}'):
202- p = p.format(homedir=homedir,
203- programfiles=programfiles,
204- libname='\\VLC\\' + libname)
205- if os.path.exists(p):
206- plugin_path = os.path.dirname(p)
207- break
208- if plugin_path is not None: # try loading
209- p = os.getcwd()
210- os.chdir(plugin_path)
211- # if chdir failed, this will raise an exception
212- dll = ctypes.CDLL(libname)
213- # restore cwd after dll has been loaded
214- os.chdir(p)
215- else: # may fail
216- dll = ctypes.CDLL(libname)
217- else:
218- plugin_path = os.path.dirname(p)
219- dll = ctypes.CDLL(p)
220-
221- elif sys.platform.startswith('darwin'):
222- # FIXME: should find a means to configure path
223- d = '/Applications/VLC.app/Contents/MacOS/'
224- c = d + 'lib/libvlccore.dylib'
225- p = d + 'lib/libvlc.dylib'
226- if os.path.exists(p) and os.path.exists(c):
227- # pre-load libvlccore VLC 2.2.8+
228- ctypes.CDLL(c)
229- dll = ctypes.CDLL(p)
230- for p in ('modules', 'plugins'):
231- p = d + p
232- if os.path.isdir(p):
233- plugin_path = p
234- break
235- else: # hope, some [DY]LD_LIBRARY_PATH is set...
236- # pre-load libvlccore VLC 2.2.8+
237- ctypes.CDLL('libvlccore.dylib')
238- dll = ctypes.CDLL('libvlc.dylib')
239-
240- else:
241- raise NotImplementedError('%s: %s not supported' % (sys.argv[0], sys.platform))
242-
243- return (dll, plugin_path)
244-
245-
246-# plugin_path used on win32 and MacOS in override.py
247-dll, plugin_path = find_lib()
248-
249-
250-class VLCException(Exception):
251- """Exception raised by libvlc methods.
252- """
253- pass
254-
255-
256-try:
257- _Ints = (int, long)
258-except NameError: # no long in Python 3+
259- _Ints = int
260-_Seqs = (list, tuple)
261-
262-
263-# Used for handling *event_manager() methods.
264-class memoize_parameterless(object):
265- """Decorator. Caches a parameterless method's return value each time it is called.
266-
267- If called later with the same arguments, the cached value is returned
268- (not reevaluated).
269- Adapted from https://wiki.python.org/moin/PythonDecoratorLibrary
270- """
271-
272- def __init__(self, func):
273- self.func = func
274- self._cache = {}
275-
276- def __call__(self, obj):
277- try:
278- return self._cache[obj]
279- except KeyError:
280- v = self._cache[obj] = self.func(obj)
281- return v
282-
283- def __repr__(self):
284- """Return the function's docstring.
285- """
286- return self.func.__doc__
287-
288- def __get__(self, obj, objtype):
289- """Support instance methods.
290- """
291- return functools.partial(self.__call__, obj)
292-
293-
294-# Default instance. It is used to instanciate classes directly in the
295-# OO-wrapper.
296-_default_instance = None
297-
298-
299-def get_default_instance():
300- """Return the default VLC.Instance.
301- """
302- global _default_instance
303- if _default_instance is None:
304- _default_instance = Instance()
305- return _default_instance
306-
307-
308-_Cfunctions = {} # from LibVLC __version__
309-_Globals = globals() # sys.modules[__name__].__dict__
310-
311-
312-def _Cfunction(name, flags, errcheck, *types):
313- """(INTERNAL) New ctypes function binding.
314- """
315- if hasattr(dll, name) and name in _Globals:
316- p = ctypes.CFUNCTYPE(*types)
317- f = p((name, dll), flags)
318- if errcheck is not None:
319- f.errcheck = errcheck
320- # replace the Python function
321- # in this module, but only when
322- # running as python -O or -OO
323- if __debug__:
324- _Cfunctions[name] = f
325- else:
326- _Globals[name] = f
327- return f
328- raise NameError('no function %r' % (name,))
329-
330-
331-def _Cobject(cls, ctype):
332- """(INTERNAL) New instance from ctypes.
333- """
334- o = object.__new__(cls)
335- o._as_parameter_ = ctype
336- return o
337-
338-
339-def _Constructor(cls, ptr=_internal_guard):
340- """(INTERNAL) New wrapper from ctypes.
341- """
342- if ptr == _internal_guard:
343- raise VLCException(
344- "(INTERNAL) ctypes class. You should get references for this class through methods of the LibVLC API.")
345- if ptr is None or ptr == 0:
346- return None
347- return _Cobject(cls, ctypes.c_void_p(ptr))
348-
349-
350-class _Cstruct(ctypes.Structure):
351- """(INTERNAL) Base class for ctypes structures.
352- """
353- _fields_ = [] # list of 2-tuples ('name', ctyptes.<type>)
354-
355- def __str__(self):
356- l = [' %s:\t%s' % (n, getattr(self, n)) for n, _ in self._fields_]
357- return '\n'.join([self.__class__.__name__] + l)
358-
359- def __repr__(self):
360- return '%s.%s' % (self.__class__.__module__, self)
361-
362-
363-class _Ctype(object):
364- """(INTERNAL) Base class for ctypes.
365- """
366-
367- @staticmethod
368- def from_param(this): # not self
369- """(INTERNAL) ctypes parameter conversion method.
370- """
371- if this is None:
372- return None
373- return this._as_parameter_
374-
375-
376-class ListPOINTER(object):
377- """Just like a POINTER but accept a list of ctype as an argument.
378- """
379-
380- def __init__(self, etype):
381- self.etype = etype
382-
383- def from_param(self, param):
384- if isinstance(param, _Seqs):
385- return (self.etype * len(param))(*param)
386- else:
387- return ctypes.POINTER(param)
388-
389-
390-# errcheck functions for some native functions.
391-def string_result(result, func, arguments):
392- """Errcheck function. Returns a string and frees the original pointer.
393-
394- It assumes the result is a char *.
395- """
396- if result:
397- # make a python string copy
398- s = bytes_to_str(ctypes.string_at(result))
399- # free original string ptr
400- libvlc_free(result)
401- return s
402- return None
403-
404-
405-def class_result(classname):
406- """Errcheck function. Returns a function that creates the specified class.
407- """
408-
409- def wrap_errcheck(result, func, arguments):
410- if result is None:
411- return None
412- return classname(result)
413-
414- return wrap_errcheck
415-
416-
417-# Wrapper for the opaque struct libvlc_log_t
418-class Log(ctypes.Structure):
419- pass
420-
421-
422-Log_ptr = ctypes.POINTER(Log)
423-
424-
425-# FILE* ctypes wrapper, copied from
426-# http://svn.python.org/projects/ctypes/trunk/ctypeslib/ctypeslib/contrib/pythonhdr.py
427-class FILE(ctypes.Structure):
428- pass
429-
430-
431-FILE_ptr = ctypes.POINTER(FILE)
432-
433-if PYTHON3:
434- PyFile_FromFd = ctypes.pythonapi.PyFile_FromFd
435- PyFile_FromFd.restype = ctypes.py_object
436- PyFile_FromFd.argtypes = [ctypes.c_int,
437- ctypes.c_char_p,
438- ctypes.c_char_p,
439- ctypes.c_int,
440- ctypes.c_char_p,
441- ctypes.c_char_p,
442- ctypes.c_char_p,
443- ctypes.c_int]
444-
445- PyFile_AsFd = ctypes.pythonapi.PyObject_AsFileDescriptor
446- PyFile_AsFd.restype = ctypes.c_int
447- PyFile_AsFd.argtypes = [ctypes.py_object]
448-else:
449- PyFile_FromFile = ctypes.pythonapi.PyFile_FromFile
450- PyFile_FromFile.restype = ctypes.py_object
451- PyFile_FromFile.argtypes = [FILE_ptr,
452- ctypes.c_char_p,
453- ctypes.c_char_p,
454- ctypes.CFUNCTYPE(ctypes.c_int, FILE_ptr)]
455-
456- PyFile_AsFile = ctypes.pythonapi.PyFile_AsFile
457- PyFile_AsFile.restype = FILE_ptr
458- PyFile_AsFile.argtypes = [ctypes.py_object]
459-
460-
461-# Generated enum types #
462-
463-class _Enum(ctypes.c_uint):
464- '''(INTERNAL) Base class
465- '''
466- _enum_names_ = {}
467-
468- def __str__(self):
469- n = self._enum_names_.get(self.value, '') or ('FIXME_(%r)' % (self.value,))
470- return '.'.join((self.__class__.__name__, n))
471-
472- def __hash__(self):
473- return self.value
474-
475- def __repr__(self):
476- return '.'.join((self.__class__.__module__, self.__str__()))
477-
478- def __eq__(self, other):
479- return ((isinstance(other, _Enum) and self.value == other.value)
480- or (isinstance(other, _Ints) and self.value == other))
481-
482- def __ne__(self, other):
483- return not self.__eq__(other)
484-
485-
486-class LogLevel(_Enum):
487- '''Logging messages level.
488-\note future libvlc versions may define new levels.
489- '''
490- _enum_names_ = {
491- 0: 'DEBUG',
492- 2: 'NOTICE',
493- 3: 'WARNING',
494- 4: 'ERROR',
495- }
496-
497-
498-LogLevel.DEBUG = LogLevel(0)
499-LogLevel.ERROR = LogLevel(4)
500-LogLevel.NOTICE = LogLevel(2)
501-LogLevel.WARNING = LogLevel(3)
502-
503-
504-class MediaDiscovererCategory(_Enum):
505- '''Category of a media discoverer
506-See libvlc_media_discoverer_list_get().
507- '''
508- _enum_names_ = {
509- 0: 'devices',
510- 1: 'lan',
511- 2: 'podcasts',
512- 3: 'localdirs',
513- }
514-
515-
516-MediaDiscovererCategory.devices = MediaDiscovererCategory(0)
517-MediaDiscovererCategory.lan = MediaDiscovererCategory(1)
518-MediaDiscovererCategory.localdirs = MediaDiscovererCategory(3)
519-MediaDiscovererCategory.podcasts = MediaDiscovererCategory(2)
520-
521-
522-class DialogQuestionType(_Enum):
523- '''@defgroup libvlc_dialog libvlc dialog
524-@ingroup libvlc
525-@{
526-@file
527-libvlc dialog external api.
528- '''
529- _enum_names_ = {
530- 0: 'NORMAL',
531- 1: 'WARNING',
532- 2: 'CRITICAL',
533- }
534-
535-
536-DialogQuestionType.CRITICAL = DialogQuestionType(2)
537-DialogQuestionType.NORMAL = DialogQuestionType(0)
538-DialogQuestionType.WARNING = DialogQuestionType(1)
539-
540-
541-class EventType(_Enum):
542- '''Event types.
543- '''
544- _enum_names_ = {
545- 0: 'MediaMetaChanged',
546- 1: 'MediaSubItemAdded',
547- 2: 'MediaDurationChanged',
548- 3: 'MediaParsedChanged',
549- 4: 'MediaFreed',
550- 5: 'MediaStateChanged',
551- 6: 'MediaSubItemTreeAdded',
552- 0x100: 'MediaPlayerMediaChanged',
553- 257: 'MediaPlayerNothingSpecial',
554- 258: 'MediaPlayerOpening',
555- 259: 'MediaPlayerBuffering',
556- 260: 'MediaPlayerPlaying',
557- 261: 'MediaPlayerPaused',
558- 262: 'MediaPlayerStopped',
559- 263: 'MediaPlayerForward',
560- 264: 'MediaPlayerBackward',
561- 265: 'MediaPlayerEndReached',
562- 266: 'MediaPlayerEncounteredError',
563- 267: 'MediaPlayerTimeChanged',
564- 268: 'MediaPlayerPositionChanged',
565- 269: 'MediaPlayerSeekableChanged',
566- 270: 'MediaPlayerPausableChanged',
567- 271: 'MediaPlayerTitleChanged',
568- 272: 'MediaPlayerSnapshotTaken',
569- 273: 'MediaPlayerLengthChanged',
570- 274: 'MediaPlayerVout',
571- 275: 'MediaPlayerScrambledChanged',
572- 276: 'MediaPlayerESAdded',
573- 277: 'MediaPlayerESDeleted',
574- 278: 'MediaPlayerESSelected',
575- 279: 'MediaPlayerCorked',
576- 280: 'MediaPlayerUncorked',
577- 281: 'MediaPlayerMuted',
578- 282: 'MediaPlayerUnmuted',
579- 283: 'MediaPlayerAudioVolume',
580- 284: 'MediaPlayerAudioDevice',
581- 285: 'MediaPlayerChapterChanged',
582- 0x200: 'MediaListItemAdded',
583- 513: 'MediaListWillAddItem',
584- 514: 'MediaListItemDeleted',
585- 515: 'MediaListWillDeleteItem',
586- 516: 'MediaListEndReached',
587- 0x300: 'MediaListViewItemAdded',
588- 769: 'MediaListViewWillAddItem',
589- 770: 'MediaListViewItemDeleted',
590- 771: 'MediaListViewWillDeleteItem',
591- 0x400: 'MediaListPlayerPlayed',
592- 1025: 'MediaListPlayerNextItemSet',
593- 1026: 'MediaListPlayerStopped',
594- 0x500: 'MediaDiscovererStarted',
595- 1281: 'MediaDiscovererEnded',
596- 1282: 'RendererDiscovererItemAdded',
597- 1283: 'RendererDiscovererItemDeleted',
598- 0x600: 'VlmMediaAdded',
599- 1537: 'VlmMediaRemoved',
600- 1538: 'VlmMediaChanged',
601- 1539: 'VlmMediaInstanceStarted',
602- 1540: 'VlmMediaInstanceStopped',
603- 1541: 'VlmMediaInstanceStatusInit',
604- 1542: 'VlmMediaInstanceStatusOpening',
605- 1543: 'VlmMediaInstanceStatusPlaying',
606- 1544: 'VlmMediaInstanceStatusPause',
607- 1545: 'VlmMediaInstanceStatusEnd',
608- 1546: 'VlmMediaInstanceStatusError',
609- }
610-
611-
612-EventType.MediaDiscovererEnded = EventType(1281)
613-EventType.MediaDiscovererStarted = EventType(0x500)
614-EventType.MediaDurationChanged = EventType(2)
615-EventType.MediaFreed = EventType(4)
616-EventType.MediaListEndReached = EventType(516)
617-EventType.MediaListItemAdded = EventType(0x200)
618-EventType.MediaListItemDeleted = EventType(514)
619-EventType.MediaListPlayerNextItemSet = EventType(1025)
620-EventType.MediaListPlayerPlayed = EventType(0x400)
621-EventType.MediaListPlayerStopped = EventType(1026)
622-EventType.MediaListViewItemAdded = EventType(0x300)
623-EventType.MediaListViewItemDeleted = EventType(770)
624-EventType.MediaListViewWillAddItem = EventType(769)
625-EventType.MediaListViewWillDeleteItem = EventType(771)
626-EventType.MediaListWillAddItem = EventType(513)
627-EventType.MediaListWillDeleteItem = EventType(515)
628-EventType.MediaMetaChanged = EventType(0)
629-EventType.MediaParsedChanged = EventType(3)
630-EventType.MediaPlayerAudioDevice = EventType(284)
631-EventType.MediaPlayerAudioVolume = EventType(283)
632-EventType.MediaPlayerBackward = EventType(264)
633-EventType.MediaPlayerBuffering = EventType(259)
634-EventType.MediaPlayerChapterChanged = EventType(285)
635-EventType.MediaPlayerCorked = EventType(279)
636-EventType.MediaPlayerESAdded = EventType(276)
637-EventType.MediaPlayerESDeleted = EventType(277)
638-EventType.MediaPlayerESSelected = EventType(278)
639-EventType.MediaPlayerEncounteredError = EventType(266)
640-EventType.MediaPlayerEndReached = EventType(265)
641-EventType.MediaPlayerForward = EventType(263)
642-EventType.MediaPlayerLengthChanged = EventType(273)
643-EventType.MediaPlayerMediaChanged = EventType(0x100)
644-EventType.MediaPlayerMuted = EventType(281)
645-EventType.MediaPlayerNothingSpecial = EventType(257)
646-EventType.MediaPlayerOpening = EventType(258)
647-EventType.MediaPlayerPausableChanged = EventType(270)
648-EventType.MediaPlayerPaused = EventType(261)
649-EventType.MediaPlayerPlaying = EventType(260)
650-EventType.MediaPlayerPositionChanged = EventType(268)
651-EventType.MediaPlayerScrambledChanged = EventType(275)
652-EventType.MediaPlayerSeekableChanged = EventType(269)
653-EventType.MediaPlayerSnapshotTaken = EventType(272)
654-EventType.MediaPlayerStopped = EventType(262)
655-EventType.MediaPlayerTimeChanged = EventType(267)
656-EventType.MediaPlayerTitleChanged = EventType(271)
657-EventType.MediaPlayerUncorked = EventType(280)
658-EventType.MediaPlayerUnmuted = EventType(282)
659-EventType.MediaPlayerVout = EventType(274)
660-EventType.MediaStateChanged = EventType(5)
661-EventType.MediaSubItemAdded = EventType(1)
662-EventType.MediaSubItemTreeAdded = EventType(6)
663-EventType.RendererDiscovererItemAdded = EventType(1282)
664-EventType.RendererDiscovererItemDeleted = EventType(1283)
665-EventType.VlmMediaAdded = EventType(0x600)
666-EventType.VlmMediaChanged = EventType(1538)
667-EventType.VlmMediaInstanceStarted = EventType(1539)
668-EventType.VlmMediaInstanceStatusEnd = EventType(1545)
669-EventType.VlmMediaInstanceStatusError = EventType(1546)
670-EventType.VlmMediaInstanceStatusInit = EventType(1541)
671-EventType.VlmMediaInstanceStatusOpening = EventType(1542)
672-EventType.VlmMediaInstanceStatusPause = EventType(1544)
673-EventType.VlmMediaInstanceStatusPlaying = EventType(1543)
674-EventType.VlmMediaInstanceStopped = EventType(1540)
675-EventType.VlmMediaRemoved = EventType(1537)
676-
677-
678-class Meta(_Enum):
679- '''Meta data types.
680- '''
681- _enum_names_ = {
682- 0: 'Title',
683- 1: 'Artist',
684- 2: 'Genre',
685- 3: 'Copyright',
686- 4: 'Album',
687- 5: 'TrackNumber',
688- 6: 'Description',
689- 7: 'Rating',
690- 8: 'Date',
691- 9: 'Setting',
692- 10: 'URL',
693- 11: 'Language',
694- 12: 'NowPlaying',
695- 13: 'Publisher',
696- 14: 'EncodedBy',
697- 15: 'ArtworkURL',
698- 16: 'TrackID',
699- 17: 'TrackTotal',
700- 18: 'Director',
701- 19: 'Season',
702- 20: 'Episode',
703- 21: 'ShowName',
704- 22: 'Actors',
705- 23: 'AlbumArtist',
706- 24: 'DiscNumber',
707- 25: 'DiscTotal',
708- }
709-
710-
711-Meta.Actors = Meta(22)
712-Meta.Album = Meta(4)
713-Meta.AlbumArtist = Meta(23)
714-Meta.Artist = Meta(1)
715-Meta.ArtworkURL = Meta(15)
716-Meta.Copyright = Meta(3)
717-Meta.Date = Meta(8)
718-Meta.Description = Meta(6)
719-Meta.Director = Meta(18)
720-Meta.DiscNumber = Meta(24)
721-Meta.DiscTotal = Meta(25)
722-Meta.EncodedBy = Meta(14)
723-Meta.Episode = Meta(20)
724-Meta.Genre = Meta(2)
725-Meta.Language = Meta(11)
726-Meta.NowPlaying = Meta(12)
727-Meta.Publisher = Meta(13)
728-Meta.Rating = Meta(7)
729-Meta.Season = Meta(19)
730-Meta.Setting = Meta(9)
731-Meta.ShowName = Meta(21)
732-Meta.Title = Meta(0)
733-Meta.TrackID = Meta(16)
734-Meta.TrackNumber = Meta(5)
735-Meta.TrackTotal = Meta(17)
736-Meta.URL = Meta(10)
737-
738-
739-class State(_Enum):
740- '''Note the order of libvlc_state_t enum must match exactly the order of
741-See mediacontrol_playerstatus, See input_state_e enums,
742-and videolan.libvlc.state (at bindings/cil/src/media.cs).
743-expected states by web plugins are:
744-idle/close=0, opening=1, playing=3, paused=4,
745-stopping=5, ended=6, error=7.
746- '''
747- _enum_names_ = {
748- 0: 'NothingSpecial',
749- 1: 'Opening',
750- 2: 'Buffering',
751- 3: 'Playing',
752- 4: 'Paused',
753- 5: 'Stopped',
754- 6: 'Ended',
755- 7: 'Error',
756- }
757-
758-
759-State.Buffering = State(2)
760-State.Ended = State(6)
761-State.Error = State(7)
762-State.NothingSpecial = State(0)
763-State.Opening = State(1)
764-State.Paused = State(4)
765-State.Playing = State(3)
766-State.Stopped = State(5)
767-
768-
769-class TrackType(_Enum):
770- '''N/A
771- '''
772- _enum_names_ = {
773- -1: 'unknown',
774- 0: 'audio',
775- 1: 'video',
776- 2: 'text',
777- }
778-
779-
780-TrackType.audio = TrackType(0)
781-TrackType.text = TrackType(2)
782-TrackType.unknown = TrackType(-1)
783-TrackType.video = TrackType(1)
784-
785-
786-class VideoOrient(_Enum):
787- '''N/A
788- '''
789- _enum_names_ = {
790- 0: 'left',
791- 1: 'right',
792- 2: 'left',
793- 3: 'right',
794- 4: 'top',
795- 5: 'bottom',
796- 6: 'top',
797- 7: 'bottom',
798- }
799-
800-
801-VideoOrient.bottom = VideoOrient(5)
802-VideoOrient.bottom = VideoOrient(7)
803-VideoOrient.left = VideoOrient(0)
804-VideoOrient.left = VideoOrient(2)
805-VideoOrient.right = VideoOrient(1)
806-VideoOrient.right = VideoOrient(3)
807-VideoOrient.top = VideoOrient(4)
808-VideoOrient.top = VideoOrient(6)
809-
810-
811-class VideoProjection(_Enum):
812- '''N/A
813- '''
814- _enum_names_ = {
815- 0: 'rectangular',
816- 1: 'equirectangular',
817- 0x100: 'standard',
818- }
819-
820-
821-VideoProjection.equirectangular = VideoProjection(1)
822-VideoProjection.rectangular = VideoProjection(0)
823-VideoProjection.standard = VideoProjection(0x100)
824-
825-
826-class MediaType(_Enum):
827- '''Media type
828-See libvlc_media_get_type.
829- '''
830- _enum_names_ = {
831- 0: 'unknown',
832- 1: 'file',
833- 2: 'directory',
834- 3: 'disc',
835- 4: 'stream',
836- 5: 'playlist',
837- }
838-
839-
840-MediaType.directory = MediaType(2)
841-MediaType.disc = MediaType(3)
842-MediaType.file = MediaType(1)
843-MediaType.playlist = MediaType(5)
844-MediaType.stream = MediaType(4)
845-MediaType.unknown = MediaType(0)
846-
847-
848-class MediaParseFlag(_Enum):
849- '''Parse flags used by libvlc_media_parse_with_options()
850-See libvlc_media_parse_with_options.
851- '''
852- _enum_names_ = {
853- 0x0: 'local',
854- 0x1: 'network',
855- 0x2: 'local',
856- 0x4: 'network',
857- 0x8: 'interact',
858- }
859-
860-
861-MediaParseFlag.interact = MediaParseFlag(0x8)
862-MediaParseFlag.local = MediaParseFlag(0x0)
863-MediaParseFlag.local = MediaParseFlag(0x2)
864-MediaParseFlag.network = MediaParseFlag(0x1)
865-MediaParseFlag.network = MediaParseFlag(0x4)
866-
867-
868-class MediaParsedStatus(_Enum):
869- '''Parse status used sent by libvlc_media_parse_with_options() or returned by
870-libvlc_media_get_parsed_status()
871-See libvlc_media_parse_with_options
872-See libvlc_media_get_parsed_status.
873- '''
874- _enum_names_ = {
875- 1: 'skipped',
876- 2: 'failed',
877- 3: 'timeout',
878- 4: 'done',
879- }
880-
881-
882-MediaParsedStatus.done = MediaParsedStatus(4)
883-MediaParsedStatus.failed = MediaParsedStatus(2)
884-MediaParsedStatus.skipped = MediaParsedStatus(1)
885-MediaParsedStatus.timeout = MediaParsedStatus(3)
886-
887-
888-class MediaSlaveType(_Enum):
889- '''Type of a media slave: subtitle or audio.
890- '''
891- _enum_names_ = {
892- 0: 'subtitle',
893- 1: 'audio',
894- }
895-
896-
897-MediaSlaveType.audio = MediaSlaveType(1)
898-MediaSlaveType.subtitle = MediaSlaveType(0)
899-
900-
901-class VideoMarqueeOption(_Enum):
902- '''Marq options definition.
903- '''
904- _enum_names_ = {
905- 0: 'Enable',
906- 1: 'Text',
907- 2: 'Color',
908- 3: 'Opacity',
909- 4: 'Position',
910- 5: 'Refresh',
911- 6: 'Size',
912- 7: 'Timeout',
913- 8: 'marquee_X',
914- 9: 'marquee_Y',
915- }
916-
917-
918-VideoMarqueeOption.Color = VideoMarqueeOption(2)
919-VideoMarqueeOption.Enable = VideoMarqueeOption(0)
920-VideoMarqueeOption.Opacity = VideoMarqueeOption(3)
921-VideoMarqueeOption.Position = VideoMarqueeOption(4)
922-VideoMarqueeOption.Refresh = VideoMarqueeOption(5)
923-VideoMarqueeOption.Size = VideoMarqueeOption(6)
924-VideoMarqueeOption.Text = VideoMarqueeOption(1)
925-VideoMarqueeOption.Timeout = VideoMarqueeOption(7)
926-VideoMarqueeOption.marquee_X = VideoMarqueeOption(8)
927-VideoMarqueeOption.marquee_Y = VideoMarqueeOption(9)
928-
929-
930-class NavigateMode(_Enum):
931- '''Navigation mode.
932- '''
933- _enum_names_ = {
934- 0: 'activate',
935- 1: 'up',
936- 2: 'down',
937- 3: 'left',
938- 4: 'right',
939- 5: 'popup',
940- }
941-
942-
943-NavigateMode.activate = NavigateMode(0)
944-NavigateMode.down = NavigateMode(2)
945-NavigateMode.left = NavigateMode(3)
946-NavigateMode.popup = NavigateMode(5)
947-NavigateMode.right = NavigateMode(4)
948-NavigateMode.up = NavigateMode(1)
949-
950-
951-class Position(_Enum):
952- '''Enumeration of values used to set position (e.g. of video title).
953- '''
954- _enum_names_ = {
955- -1: 'disable',
956- 0: 'center',
957- 1: 'left',
958- 2: 'right',
959- 3: 'top',
960- 4: 'left',
961- 5: 'right',
962- 6: 'bottom',
963- 7: 'left',
964- 8: 'right',
965- }
966-
967-
968-Position.bottom = Position(6)
969-Position.center = Position(0)
970-Position.disable = Position(-1)
971-Position.left = Position(1)
972-Position.left = Position(4)
973-Position.left = Position(7)
974-Position.right = Position(2)
975-Position.right = Position(5)
976-Position.right = Position(8)
977-Position.top = Position(3)
978-
979-
980-class TeletextKey(_Enum):
981- '''Enumeration of teletext keys than can be passed via
982-libvlc_video_set_teletext().
983- '''
984- _enum_names_ = {
985- 7471104: 'red',
986- 6750208: 'green',
987- 7929856: 'yellow',
988- 6422528: 'blue',
989- 6881280: 'index',
990- }
991-
992-
993-TeletextKey.blue = TeletextKey(6422528)
994-TeletextKey.green = TeletextKey(6750208)
995-TeletextKey.index = TeletextKey(6881280)
996-TeletextKey.red = TeletextKey(7471104)
997-TeletextKey.yellow = TeletextKey(7929856)
998-
999-
1000-class VideoLogoOption(_Enum):
1001- '''Option values for libvlc_video_{get,set}_logo_{int,string}.
1002- '''
1003- _enum_names_ = {
1004- 0: 'enable',
1005- 1: 'file',
1006- 2: 'logo_x',
1007- 3: 'logo_y',
1008- 4: 'delay',
1009- 5: 'repeat',
1010- 6: 'opacity',
1011- 7: 'position',
1012- }
1013-
1014-
1015-VideoLogoOption.delay = VideoLogoOption(4)
1016-VideoLogoOption.enable = VideoLogoOption(0)
1017-VideoLogoOption.file = VideoLogoOption(1)
1018-VideoLogoOption.logo_x = VideoLogoOption(2)
1019-VideoLogoOption.logo_y = VideoLogoOption(3)
1020-VideoLogoOption.opacity = VideoLogoOption(6)
1021-VideoLogoOption.position = VideoLogoOption(7)
1022-VideoLogoOption.repeat = VideoLogoOption(5)
1023-
1024-
1025-class VideoAdjustOption(_Enum):
1026- '''Option values for libvlc_video_{get,set}_adjust_{int,float,bool}.
1027- '''
1028- _enum_names_ = {
1029- 0: 'Enable',
1030- 1: 'Contrast',
1031- 2: 'Brightness',
1032- 3: 'Hue',
1033- 4: 'Saturation',
1034- 5: 'Gamma',
1035- }
1036-
1037-
1038-VideoAdjustOption.Brightness = VideoAdjustOption(2)
1039-VideoAdjustOption.Contrast = VideoAdjustOption(1)
1040-VideoAdjustOption.Enable = VideoAdjustOption(0)
1041-VideoAdjustOption.Gamma = VideoAdjustOption(5)
1042-VideoAdjustOption.Hue = VideoAdjustOption(3)
1043-VideoAdjustOption.Saturation = VideoAdjustOption(4)
1044-
1045-
1046-class AudioOutputDeviceTypes(_Enum):
1047- '''Audio device types.
1048- '''
1049- _enum_names_ = {
1050- -1: 'Error',
1051- 1: 'Mono',
1052- 2: 'Stereo',
1053- 4: '_2F2R',
1054- 5: '_3F2R',
1055- 6: '_5_1',
1056- 7: '_6_1',
1057- 8: '_7_1',
1058- 10: 'SPDIF',
1059- }
1060-
1061-
1062-AudioOutputDeviceTypes.Error = AudioOutputDeviceTypes(-1)
1063-AudioOutputDeviceTypes.Mono = AudioOutputDeviceTypes(1)
1064-AudioOutputDeviceTypes.SPDIF = AudioOutputDeviceTypes(10)
1065-AudioOutputDeviceTypes.Stereo = AudioOutputDeviceTypes(2)
1066-AudioOutputDeviceTypes._2F2R = AudioOutputDeviceTypes(4)
1067-AudioOutputDeviceTypes._3F2R = AudioOutputDeviceTypes(5)
1068-AudioOutputDeviceTypes._5_1 = AudioOutputDeviceTypes(6)
1069-AudioOutputDeviceTypes._6_1 = AudioOutputDeviceTypes(7)
1070-AudioOutputDeviceTypes._7_1 = AudioOutputDeviceTypes(8)
1071-
1072-
1073-class AudioOutputChannel(_Enum):
1074- '''Audio channels.
1075- '''
1076- _enum_names_ = {
1077- -1: 'Error',
1078- 1: 'Stereo',
1079- 2: 'RStereo',
1080- 3: 'Left',
1081- 4: 'Right',
1082- 5: 'Dolbys',
1083- }
1084-
1085-
1086-AudioOutputChannel.Dolbys = AudioOutputChannel(5)
1087-AudioOutputChannel.Error = AudioOutputChannel(-1)
1088-AudioOutputChannel.Left = AudioOutputChannel(3)
1089-AudioOutputChannel.RStereo = AudioOutputChannel(2)
1090-AudioOutputChannel.Right = AudioOutputChannel(4)
1091-AudioOutputChannel.Stereo = AudioOutputChannel(1)
1092-
1093-
1094-class MediaPlayerRole(_Enum):
1095- '''Media player roles.
1096-\version libvlc 3.0.0 and later.
1097-see \ref libvlc_media_player_set_role().
1098- '''
1099- _enum_names_ = {
1100- 0: '_None',
1101- 1: 'Music',
1102- 2: 'Video',
1103- 3: 'Communication',
1104- 4: 'Game',
1105- 5: 'Notification',
1106- 6: 'Animation',
1107- 7: 'Production',
1108- 8: 'Accessibility',
1109- 9: 'Test',
1110- }
1111-
1112-
1113-MediaPlayerRole.Accessibility = MediaPlayerRole(8)
1114-MediaPlayerRole.Animation = MediaPlayerRole(6)
1115-MediaPlayerRole.Communication = MediaPlayerRole(3)
1116-MediaPlayerRole.Game = MediaPlayerRole(4)
1117-MediaPlayerRole.Music = MediaPlayerRole(1)
1118-MediaPlayerRole.Notification = MediaPlayerRole(5)
1119-MediaPlayerRole.Production = MediaPlayerRole(7)
1120-MediaPlayerRole.Test = MediaPlayerRole(9)
1121-MediaPlayerRole.Video = MediaPlayerRole(2)
1122-MediaPlayerRole._None = MediaPlayerRole(0)
1123-
1124-
1125-class PlaybackMode(_Enum):
1126- '''Defines playback modes for playlist.
1127- '''
1128- _enum_names_ = {
1129- 0: 'default',
1130- 1: 'loop',
1131- 2: 'repeat',
1132- }
1133-
1134-
1135-PlaybackMode.default = PlaybackMode(0)
1136-PlaybackMode.loop = PlaybackMode(1)
1137-PlaybackMode.repeat = PlaybackMode(2)
1138-
1139-
1140-class Callback(ctypes.c_void_p):
1141- """Callback function notification.
1142- @param p_event: the event triggering the callback.
1143- """
1144- pass
1145-
1146-
1147-class LogCb(ctypes.c_void_p):
1148- """Callback prototype for LibVLC log message handler.
1149- @param data: data pointer as given to L{libvlc_log_set}().
1150- @param level: message level (@ref L{LogLevel}).
1151- @param ctx: message context (meta-information about the message).
1152- @param fmt: printf() format string (as defined by ISO C11).
1153- @param args: variable argument list for the format @note Log message handlers B{must} be thread-safe. @warning The message context pointer, the format string parameters and the variable arguments are only valid until the callback returns.
1154- """
1155- pass
1156-
1157-
1158-class MediaOpenCb(ctypes.c_void_p):
1159- """Callback prototype to open a custom bitstream input media.
1160- The same media item can be opened multiple times. Each time, this callback
1161- is invoked. It should allocate and initialize any instance-specific
1162- resources, then store them in *datap. The instance resources can be freed
1163- in the @ref libvlc_media_close_cb callback.
1164- @param opaque: private pointer as passed to L{libvlc_media_new_callbacks}().
1165- @return: datap storage space for a private data pointer, sizep byte length of the bitstream or UINT64_MAX if unknown.
1166- """
1167- pass
1168-
1169-
1170-class MediaReadCb(ctypes.c_void_p):
1171- """Callback prototype to read data from a custom bitstream input media.
1172- @param opaque: private pointer as set by the @ref libvlc_media_open_cb callback.
1173- @param buf: start address of the buffer to read data into.
1174- @param len: bytes length of the buffer.
1175- @return: strictly positive number of bytes read, 0 on end-of-stream, or -1 on non-recoverable error @note If no data is immediately available, then the callback should sleep. @warning The application is responsible for avoiding deadlock situations. In particular, the callback should return an error if playback is stopped; if it does not return, then L{libvlc_media_player_stop}() will never return.
1176- """
1177- pass
1178-
1179-
1180-class MediaSeekCb(ctypes.c_void_p):
1181- """Callback prototype to seek a custom bitstream input media.
1182- @param opaque: private pointer as set by the @ref libvlc_media_open_cb callback.
1183- @param offset: absolute byte offset to seek to.
1184- @return: 0 on success, -1 on error.
1185- """
1186- pass
1187-
1188-
1189-class MediaCloseCb(ctypes.c_void_p):
1190- """Callback prototype to close a custom bitstream input media.
1191- @param opaque: private pointer as set by the @ref libvlc_media_open_cb callback.
1192- """
1193- pass
1194-
1195-
1196-class VideoLockCb(ctypes.c_void_p):
1197- """Callback prototype to allocate and lock a picture buffer.
1198- Whenever a new video frame needs to be decoded, the lock callback is
1199- invoked. Depending on the video chroma, one or three pixel planes of
1200- adequate dimensions must be returned via the second parameter. Those
1201- planes must be aligned on 32-bytes boundaries.
1202- @param opaque: private pointer as passed to L{libvlc_video_set_callbacks}() [IN].
1203- @param planes: start address of the pixel planes (LibVLC allocates the array of void pointers, this callback must initialize the array) [OUT].
1204- @return: a private pointer for the display and unlock callbacks to identify the picture buffers.
1205- """
1206- pass
1207-
1208-
1209-class VideoUnlockCb(ctypes.c_void_p):
1210- """Callback prototype to unlock a picture buffer.
1211- When the video frame decoding is complete, the unlock callback is invoked.
1212- This callback might not be needed at all. It is only an indication that the
1213- application can now read the pixel values if it needs to.
1214- @note: A picture buffer is unlocked after the picture is decoded,
1215- but before the picture is displayed.
1216- @param opaque: private pointer as passed to L{libvlc_video_set_callbacks}() [IN].
1217- @param picture: private pointer returned from the @ref libvlc_video_lock_cb callback [IN].
1218- @param planes: pixel planes as defined by the @ref libvlc_video_lock_cb callback (this parameter is only for convenience) [IN].
1219- """
1220- pass
1221-
1222-
1223-class VideoDisplayCb(ctypes.c_void_p):
1224- """Callback prototype to display a picture.
1225- When the video frame needs to be shown, as determined by the media playback
1226- clock, the display callback is invoked.
1227- @param opaque: private pointer as passed to L{libvlc_video_set_callbacks}() [IN].
1228- @param picture: private pointer returned from the @ref libvlc_video_lock_cb callback [IN].
1229- """
1230- pass
1231-
1232-
1233-class VideoFormatCb(ctypes.c_void_p):
1234- """Callback prototype to configure picture buffers format.
1235- This callback gets the format of the video as output by the video decoder
1236- and the chain of video filters (if any). It can opt to change any parameter
1237- as it needs. In that case, LibVLC will attempt to convert the video format
1238- (rescaling and chroma conversion) but these operations can be CPU intensive.
1239- @param opaque: pointer to the private pointer passed to L{libvlc_video_set_callbacks}() [IN/OUT].
1240- @param chroma: pointer to the 4 bytes video format identifier [IN/OUT].
1241- @param width: pointer to the pixel width [IN/OUT].
1242- @param height: pointer to the pixel height [IN/OUT].
1243- @param pitches: table of scanline pitches in bytes for each pixel plane (the table is allocated by LibVLC) [OUT].
1244- @return: lines table of scanlines count for each plane.
1245- """
1246- pass
1247-
1248-
1249-class VideoCleanupCb(ctypes.c_void_p):
1250- """Callback prototype to configure picture buffers format.
1251- @param opaque: private pointer as passed to L{libvlc_video_set_callbacks}() (and possibly modified by @ref libvlc_video_format_cb) [IN].
1252- """
1253- pass
1254-
1255-
1256-class AudioPlayCb(ctypes.c_void_p):
1257- """Callback prototype for audio playback.
1258- The LibVLC media player decodes and post-processes the audio signal
1259- asynchronously (in an internal thread). Whenever audio samples are ready
1260- to be queued to the output, this callback is invoked.
1261- The number of samples provided per invocation may depend on the file format,
1262- the audio coding algorithm, the decoder plug-in, the post-processing
1263- filters and timing. Application must not assume a certain number of samples.
1264- The exact format of audio samples is determined by L{libvlc_audio_set_format}()
1265- or L{libvlc_audio_set_format_callbacks}() as is the channels layout.
1266- Note that the number of samples is per channel. For instance, if the audio
1267- track sampling rate is 48000 Hz, then 1200 samples represent 25 milliseconds
1268- of audio signal - regardless of the number of audio channels.
1269- @param data: data pointer as passed to L{libvlc_audio_set_callbacks}() [IN].
1270- @param samples: pointer to a table of audio samples to play back [IN].
1271- @param count: number of audio samples to play back.
1272- @param pts: expected play time stamp (see libvlc_delay()).
1273- """
1274- pass
1275-
1276-
1277-class AudioPauseCb(ctypes.c_void_p):
1278- """Callback prototype for audio pause.
1279- LibVLC invokes this callback to pause audio playback.
1280- @note: The pause callback is never called if the audio is already paused.
1281- @param data: data pointer as passed to L{libvlc_audio_set_callbacks}() [IN].
1282- @param pts: time stamp of the pause request (should be elapsed already).
1283- """
1284- pass
1285-
1286-
1287-class AudioResumeCb(ctypes.c_void_p):
1288- """Callback prototype for audio resumption.
1289- LibVLC invokes this callback to resume audio playback after it was
1290- previously paused.
1291- @note: The resume callback is never called if the audio is not paused.
1292- @param data: data pointer as passed to L{libvlc_audio_set_callbacks}() [IN].
1293- @param pts: time stamp of the resumption request (should be elapsed already).
1294- """
1295- pass
1296-
1297-
1298-class AudioFlushCb(ctypes.c_void_p):
1299- """Callback prototype for audio buffer flush.
1300- LibVLC invokes this callback if it needs to discard all pending buffers and
1301- stop playback as soon as possible. This typically occurs when the media is
1302- stopped.
1303- @param data: data pointer as passed to L{libvlc_audio_set_callbacks}() [IN].
1304- """
1305- pass
1306-
1307-
1308-class AudioDrainCb(ctypes.c_void_p):
1309- """Callback prototype for audio buffer drain.
1310- LibVLC may invoke this callback when the decoded audio track is ending.
1311- There will be no further decoded samples for the track, but playback should
1312- nevertheless continue until all already pending buffers are rendered.
1313- @param data: data pointer as passed to L{libvlc_audio_set_callbacks}() [IN].
1314- """
1315- pass
1316-
1317-
1318-class AudioSetVolumeCb(ctypes.c_void_p):
1319- """Callback prototype for audio volume change.
1320- @param data: data pointer as passed to L{libvlc_audio_set_callbacks}() [IN].
1321- @param volume: software volume (1. = nominal, 0. = mute).
1322- @param mute: muted flag.
1323- """
1324- pass
1325-
1326-
1327-class AudioSetupCb(ctypes.c_void_p):
1328- """Callback prototype to setup the audio playback.
1329- This is called when the media player needs to create a new audio output.
1330- @param opaque: pointer to the data pointer passed to L{libvlc_audio_set_callbacks}() [IN/OUT].
1331- @param format: 4 bytes sample format [IN/OUT].
1332- @param rate: sample rate [IN/OUT].
1333- @param channels: channels count [IN/OUT].
1334- @return: 0 on success, anything else to skip audio playback.
1335- """
1336- pass
1337-
1338-
1339-class AudioCleanupCb(ctypes.c_void_p):
1340- """Callback prototype for audio playback cleanup.
1341- This is called when the media player no longer needs an audio output.
1342- @param opaque: data pointer as passed to L{libvlc_audio_set_callbacks}() [IN].
1343- """
1344- pass
1345-
1346-
1347-class CallbackDecorators(object):
1348- "Class holding various method decorators for callback functions."
1349- Callback = ctypes.CFUNCTYPE(ctypes.c_void_p, ctypes.c_void_p, ctypes.c_void_p)
1350- Callback.__doc__ = '''Callback function notification.
1351- @param p_event: the event triggering the callback.
1352- '''
1353- LogCb = ctypes.CFUNCTYPE(ctypes.c_void_p, ctypes.c_void_p, ctypes.c_int, Log_ptr, ctypes.c_char_p, ctypes.c_void_p)
1354- LogCb.__doc__ = '''Callback prototype for LibVLC log message handler.
1355- @param data: data pointer as given to L{libvlc_log_set}().
1356- @param level: message level (@ref L{LogLevel}).
1357- @param ctx: message context (meta-information about the message).
1358- @param fmt: printf() format string (as defined by ISO C11).
1359- @param args: variable argument list for the format @note Log message handlers B{must} be thread-safe. @warning The message context pointer, the format string parameters and the variable arguments are only valid until the callback returns.
1360- '''
1361- MediaOpenCb = ctypes.CFUNCTYPE(ctypes.POINTER(ctypes.c_int), ctypes.c_void_p, ctypes.POINTER(ctypes.c_void_p),
1362- ctypes.POINTER(ctypes.c_uint64))
1363- MediaOpenCb.__doc__ = '''Callback prototype to open a custom bitstream input media.
1364- The same media item can be opened multiple times. Each time, this callback
1365- is invoked. It should allocate and initialize any instance-specific
1366- resources, then store them in *datap. The instance resources can be freed
1367- in the @ref libvlc_media_close_cb callback.
1368- @param opaque: private pointer as passed to L{libvlc_media_new_callbacks}().
1369- @return: datap storage space for a private data pointer, sizep byte length of the bitstream or UINT64_MAX if unknown.
1370- '''
1371- MediaReadCb = ctypes.CFUNCTYPE(ctypes.POINTER(ctypes.c_ssize_t), ctypes.c_void_p, ctypes.c_char_p, ctypes.c_size_t)
1372- MediaReadCb.__doc__ = '''Callback prototype to read data from a custom bitstream input media.
1373- @param opaque: private pointer as set by the @ref libvlc_media_open_cb callback.
1374- @param buf: start address of the buffer to read data into.
1375- @param len: bytes length of the buffer.
1376- @return: strictly positive number of bytes read, 0 on end-of-stream, or -1 on non-recoverable error @note If no data is immediately available, then the callback should sleep. @warning The application is responsible for avoiding deadlock situations. In particular, the callback should return an error if playback is stopped; if it does not return, then L{libvlc_media_player_stop}() will never return.
1377- '''
1378- MediaSeekCb = ctypes.CFUNCTYPE(ctypes.POINTER(ctypes.c_int), ctypes.c_void_p, ctypes.c_uint64)
1379- MediaSeekCb.__doc__ = '''Callback prototype to seek a custom bitstream input media.
1380- @param opaque: private pointer as set by the @ref libvlc_media_open_cb callback.
1381- @param offset: absolute byte offset to seek to.
1382- @return: 0 on success, -1 on error.
1383- '''
1384- MediaCloseCb = ctypes.CFUNCTYPE(ctypes.c_void_p, ctypes.c_void_p)
1385- MediaCloseCb.__doc__ = '''Callback prototype to close a custom bitstream input media.
1386- @param opaque: private pointer as set by the @ref libvlc_media_open_cb callback.
1387- '''
1388- VideoLockCb = ctypes.CFUNCTYPE(ctypes.c_void_p, ctypes.c_void_p, ctypes.POINTER(ctypes.c_void_p))
1389- VideoLockCb.__doc__ = '''Callback prototype to allocate and lock a picture buffer.
1390- Whenever a new video frame needs to be decoded, the lock callback is
1391- invoked. Depending on the video chroma, one or three pixel planes of
1392- adequate dimensions must be returned via the second parameter. Those
1393- planes must be aligned on 32-bytes boundaries.
1394- @param opaque: private pointer as passed to L{libvlc_video_set_callbacks}() [IN].
1395- @param planes: start address of the pixel planes (LibVLC allocates the array of void pointers, this callback must initialize the array) [OUT].
1396- @return: a private pointer for the display and unlock callbacks to identify the picture buffers.
1397- '''
1398- VideoUnlockCb = ctypes.CFUNCTYPE(ctypes.c_void_p, ctypes.c_void_p, ctypes.c_void_p, ctypes.POINTER(ctypes.c_void_p))
1399- VideoUnlockCb.__doc__ = '''Callback prototype to unlock a picture buffer.
1400- When the video frame decoding is complete, the unlock callback is invoked.
1401- This callback might not be needed at all. It is only an indication that the
1402- application can now read the pixel values if it needs to.
1403- @note: A picture buffer is unlocked after the picture is decoded,
1404- but before the picture is displayed.
1405- @param opaque: private pointer as passed to L{libvlc_video_set_callbacks}() [IN].
1406- @param picture: private pointer returned from the @ref libvlc_video_lock_cb callback [IN].
1407- @param planes: pixel planes as defined by the @ref libvlc_video_lock_cb callback (this parameter is only for convenience) [IN].
1408- '''
1409- VideoDisplayCb = ctypes.CFUNCTYPE(ctypes.c_void_p, ctypes.c_void_p, ctypes.c_void_p)
1410- VideoDisplayCb.__doc__ = '''Callback prototype to display a picture.
1411- When the video frame needs to be shown, as determined by the media playback
1412- clock, the display callback is invoked.
1413- @param opaque: private pointer as passed to L{libvlc_video_set_callbacks}() [IN].
1414- @param picture: private pointer returned from the @ref libvlc_video_lock_cb callback [IN].
1415- '''
1416- VideoFormatCb = ctypes.CFUNCTYPE(ctypes.POINTER(ctypes.c_uint), ctypes.POINTER(ctypes.c_void_p), ctypes.c_char_p,
1417- ctypes.POINTER(ctypes.c_uint), ctypes.POINTER(ctypes.c_uint),
1418- ctypes.POINTER(ctypes.c_uint), ctypes.POINTER(ctypes.c_uint))
1419- VideoFormatCb.__doc__ = '''Callback prototype to configure picture buffers format.
1420- This callback gets the format of the video as output by the video decoder
1421- and the chain of video filters (if any). It can opt to change any parameter
1422- as it needs. In that case, LibVLC will attempt to convert the video format
1423- (rescaling and chroma conversion) but these operations can be CPU intensive.
1424- @param opaque: pointer to the private pointer passed to L{libvlc_video_set_callbacks}() [IN/OUT].
1425- @param chroma: pointer to the 4 bytes video format identifier [IN/OUT].
1426- @param width: pointer to the pixel width [IN/OUT].
1427- @param height: pointer to the pixel height [IN/OUT].
1428- @param pitches: table of scanline pitches in bytes for each pixel plane (the table is allocated by LibVLC) [OUT].
1429- @return: lines table of scanlines count for each plane.
1430- '''
1431- VideoCleanupCb = ctypes.CFUNCTYPE(ctypes.c_void_p, ctypes.c_void_p)
1432- VideoCleanupCb.__doc__ = '''Callback prototype to configure picture buffers format.
1433- @param opaque: private pointer as passed to L{libvlc_video_set_callbacks}() (and possibly modified by @ref libvlc_video_format_cb) [IN].
1434- '''
1435- AudioPlayCb = ctypes.CFUNCTYPE(ctypes.c_void_p, ctypes.c_void_p, ctypes.c_void_p, ctypes.c_uint, ctypes.c_int64)
1436- AudioPlayCb.__doc__ = '''Callback prototype for audio playback.
1437- The LibVLC media player decodes and post-processes the audio signal
1438- asynchronously (in an internal thread). Whenever audio samples are ready
1439- to be queued to the output, this callback is invoked.
1440- The number of samples provided per invocation may depend on the file format,
1441- the audio coding algorithm, the decoder plug-in, the post-processing
1442- filters and timing. Application must not assume a certain number of samples.
1443- The exact format of audio samples is determined by L{libvlc_audio_set_format}()
1444- or L{libvlc_audio_set_format_callbacks}() as is the channels layout.
1445- Note that the number of samples is per channel. For instance, if the audio
1446- track sampling rate is 48000 Hz, then 1200 samples represent 25 milliseconds
1447- of audio signal - regardless of the number of audio channels.
1448- @param data: data pointer as passed to L{libvlc_audio_set_callbacks}() [IN].
1449- @param samples: pointer to a table of audio samples to play back [IN].
1450- @param count: number of audio samples to play back.
1451- @param pts: expected play time stamp (see libvlc_delay()).
1452- '''
1453- AudioPauseCb = ctypes.CFUNCTYPE(ctypes.c_void_p, ctypes.c_void_p, ctypes.c_int64)
1454- AudioPauseCb.__doc__ = '''Callback prototype for audio pause.
1455- LibVLC invokes this callback to pause audio playback.
1456- @note: The pause callback is never called if the audio is already paused.
1457- @param data: data pointer as passed to L{libvlc_audio_set_callbacks}() [IN].
1458- @param pts: time stamp of the pause request (should be elapsed already).
1459- '''
1460- AudioResumeCb = ctypes.CFUNCTYPE(ctypes.c_void_p, ctypes.c_void_p, ctypes.c_int64)
1461- AudioResumeCb.__doc__ = '''Callback prototype for audio resumption.
1462- LibVLC invokes this callback to resume audio playback after it was
1463- previously paused.
1464- @note: The resume callback is never called if the audio is not paused.
1465- @param data: data pointer as passed to L{libvlc_audio_set_callbacks}() [IN].
1466- @param pts: time stamp of the resumption request (should be elapsed already).
1467- '''
1468- AudioFlushCb = ctypes.CFUNCTYPE(ctypes.c_void_p, ctypes.c_void_p, ctypes.c_int64)
1469- AudioFlushCb.__doc__ = '''Callback prototype for audio buffer flush.
1470- LibVLC invokes this callback if it needs to discard all pending buffers and
1471- stop playback as soon as possible. This typically occurs when the media is
1472- stopped.
1473- @param data: data pointer as passed to L{libvlc_audio_set_callbacks}() [IN].
1474- '''
1475- AudioDrainCb = ctypes.CFUNCTYPE(ctypes.c_void_p, ctypes.c_void_p)
1476- AudioDrainCb.__doc__ = '''Callback prototype for audio buffer drain.
1477- LibVLC may invoke this callback when the decoded audio track is ending.
1478- There will be no further decoded samples for the track, but playback should
1479- nevertheless continue until all already pending buffers are rendered.
1480- @param data: data pointer as passed to L{libvlc_audio_set_callbacks}() [IN].
1481- '''
1482- AudioSetVolumeCb = ctypes.CFUNCTYPE(ctypes.c_void_p, ctypes.c_void_p, ctypes.c_float, ctypes.c_bool)
1483- AudioSetVolumeCb.__doc__ = '''Callback prototype for audio volume change.
1484- @param data: data pointer as passed to L{libvlc_audio_set_callbacks}() [IN].
1485- @param volume: software volume (1. = nominal, 0. = mute).
1486- @param mute: muted flag.
1487- '''
1488- AudioSetupCb = ctypes.CFUNCTYPE(ctypes.POINTER(ctypes.c_int), ctypes.POINTER(ctypes.c_void_p), ctypes.c_char_p,
1489- ctypes.POINTER(ctypes.c_uint), ctypes.POINTER(ctypes.c_uint))
1490- AudioSetupCb.__doc__ = '''Callback prototype to setup the audio playback.
1491- This is called when the media player needs to create a new audio output.
1492- @param opaque: pointer to the data pointer passed to L{libvlc_audio_set_callbacks}() [IN/OUT].
1493- @param format: 4 bytes sample format [IN/OUT].
1494- @param rate: sample rate [IN/OUT].
1495- @param channels: channels count [IN/OUT].
1496- @return: 0 on success, anything else to skip audio playback.
1497- '''
1498- AudioCleanupCb = ctypes.CFUNCTYPE(ctypes.c_void_p, ctypes.c_void_p)
1499- AudioCleanupCb.__doc__ = '''Callback prototype for audio playback cleanup.
1500- This is called when the media player no longer needs an audio output.
1501- @param opaque: data pointer as passed to L{libvlc_audio_set_callbacks}() [IN].
1502- '''
1503-
1504-
1505-cb = CallbackDecorators
1506-
1507-
1508-# End of generated enum types #
1509-
1510-# From libvlc_structures.h
1511-
1512-class AudioOutput(_Cstruct):
1513-
1514- def __str__(self):
1515- return '%s(%s:%s)' % (self.__class__.__name__, self.name, self.description)
1516-
1517-
1518-AudioOutput._fields_ = [ # recursive struct
1519- ('name', ctypes.c_char_p),
1520- ('description', ctypes.c_char_p),
1521- ('next', ctypes.POINTER(AudioOutput)),
1522-]
1523-
1524-
1525-class LogMessage(_Cstruct):
1526- _fields_ = [
1527- ('size', ctypes.c_uint),
1528- ('severity', ctypes.c_int),
1529- ('type', ctypes.c_char_p),
1530- ('name', ctypes.c_char_p),
1531- ('header', ctypes.c_char_p),
1532- ('message', ctypes.c_char_p),
1533- ]
1534-
1535- def __init__(self):
1536- super(LogMessage, self).__init__()
1537- self.size = ctypes.sizeof(self)
1538-
1539- def __str__(self):
1540- return '%s(%d:%s): %s' % (self.__class__.__name__, self.severity, self.type, self.message)
1541-
1542-
1543-class MediaEvent(_Cstruct):
1544- _fields_ = [
1545- ('media_name', ctypes.c_char_p),
1546- ('instance_name', ctypes.c_char_p),
1547- ]
1548-
1549-
1550-class MediaStats(_Cstruct):
1551- _fields_ = [
1552- ('read_bytes', ctypes.c_int),
1553- ('input_bitrate', ctypes.c_float),
1554- ('demux_read_bytes', ctypes.c_int),
1555- ('demux_bitrate', ctypes.c_float),
1556- ('demux_corrupted', ctypes.c_int),
1557- ('demux_discontinuity', ctypes.c_int),
1558- ('decoded_video', ctypes.c_int),
1559- ('decoded_audio', ctypes.c_int),
1560- ('displayed_pictures', ctypes.c_int),
1561- ('lost_pictures', ctypes.c_int),
1562- ('played_abuffers', ctypes.c_int),
1563- ('lost_abuffers', ctypes.c_int),
1564- ('sent_packets', ctypes.c_int),
1565- ('sent_bytes', ctypes.c_int),
1566- ('send_bitrate', ctypes.c_float),
1567- ]
1568-
1569-
1570-class MediaTrackInfo(_Cstruct):
1571- _fields_ = [
1572- ('codec', ctypes.c_uint32),
1573- ('id', ctypes.c_int),
1574- ('type', TrackType),
1575- ('profile', ctypes.c_int),
1576- ('level', ctypes.c_int),
1577- ('channels_or_height', ctypes.c_uint),
1578- ('rate_or_width', ctypes.c_uint),
1579- ]
1580-
1581-
1582-class AudioTrack(_Cstruct):
1583- _fields_ = [
1584- ('channels', ctypes.c_uint),
1585- ('rate', ctypes.c_uint),
1586- ]
1587-
1588-
1589-class VideoTrack(_Cstruct):
1590- _fields_ = [
1591- ('height', ctypes.c_uint),
1592- ('width', ctypes.c_uint),
1593- ('sar_num', ctypes.c_uint),
1594- ('sar_den', ctypes.c_uint),
1595- ('frame_rate_num', ctypes.c_uint),
1596- ('frame_rate_den', ctypes.c_uint),
1597- ]
1598-
1599-
1600-class SubtitleTrack(_Cstruct):
1601- _fields_ = [
1602- ('encoding', ctypes.c_char_p),
1603- ]
1604-
1605-
1606-class MediaTrackTracks(ctypes.Union):
1607- _fields_ = [
1608- ('audio', ctypes.POINTER(AudioTrack)),
1609- ('video', ctypes.POINTER(VideoTrack)),
1610- ('subtitle', ctypes.POINTER(SubtitleTrack)),
1611- ]
1612-
1613-
1614-class MediaTrack(_Cstruct):
1615- _anonymous_ = ("u",)
1616- _fields_ = [
1617- ('codec', ctypes.c_uint32),
1618- ('original_fourcc', ctypes.c_uint32),
1619- ('id', ctypes.c_int),
1620- ('type', TrackType),
1621- ('profile', ctypes.c_int),
1622- ('level', ctypes.c_int),
1623-
1624- ('u', MediaTrackTracks),
1625- ('bitrate', ctypes.c_uint),
1626- ('language', ctypes.c_char_p),
1627- ('description', ctypes.c_char_p),
1628- ]
1629-
1630-
1631-class PlaylistItem(_Cstruct):
1632- _fields_ = [
1633- ('id', ctypes.c_int),
1634- ('uri', ctypes.c_char_p),
1635- ('name', ctypes.c_char_p),
1636- ]
1637-
1638- def __str__(self):
1639- return '%s #%d %s (uri %s)' % (self.__class__.__name__, self.id, self.name, self.uri)
1640-
1641-
1642-class Position(object):
1643- """Enum-like, immutable window position constants.
1644-
1645- See e.g. VideoMarqueeOption.Position.
1646- """
1647- Center = 0
1648- Left = 1
1649- CenterLeft = 1
1650- Right = 2
1651- CenterRight = 2
1652- Top = 4
1653- TopCenter = 4
1654- TopLeft = 5
1655- TopRight = 6
1656- Bottom = 8
1657- BottomCenter = 8
1658- BottomLeft = 9
1659- BottomRight = 10
1660-
1661- def __init__(self, *unused):
1662- raise TypeError('constants only')
1663-
1664- def __setattr__(self, *unused): # PYCHOK expected
1665- raise TypeError('immutable constants')
1666-
1667-
1668-class Rectangle(_Cstruct):
1669- _fields_ = [
1670- ('top', ctypes.c_int),
1671- ('left', ctypes.c_int),
1672- ('bottom', ctypes.c_int),
1673- ('right', ctypes.c_int),
1674- ]
1675-
1676-
1677-class TrackDescription(_Cstruct):
1678-
1679- def __str__(self):
1680- return '%s(%d:%s)' % (self.__class__.__name__, self.id, self.name)
1681-
1682-
1683-TrackDescription._fields_ = [ # recursive struct
1684- ('id', ctypes.c_int),
1685- ('name', ctypes.c_char_p),
1686- ('next', ctypes.POINTER(TrackDescription)),
1687-]
1688-
1689-
1690-def track_description_list(head):
1691- """Convert a TrackDescription linked list to a Python list (and release the former).
1692- """
1693- r = []
1694- if head:
1695- item = head
1696- while item:
1697- item = item.contents
1698- r.append((item.id, item.name))
1699- item = item.next
1700- try:
1701- libvlc_track_description_release(head)
1702- except NameError:
1703- libvlc_track_description_list_release(head)
1704-
1705- return r
1706-
1707-
1708-class EventUnion(ctypes.Union):
1709- _fields_ = [
1710- ('meta_type', ctypes.c_uint),
1711- ('new_child', ctypes.c_uint),
1712- ('new_duration', ctypes.c_longlong),
1713- ('new_status', ctypes.c_int),
1714- ('media', ctypes.c_void_p),
1715- ('new_state', ctypes.c_uint),
1716- # FIXME: Media instance
1717- ('new_cache', ctypes.c_float),
1718- ('new_position', ctypes.c_float),
1719- ('new_time', ctypes.c_longlong),
1720- ('new_title', ctypes.c_int),
1721- ('new_seekable', ctypes.c_longlong),
1722- ('new_pausable', ctypes.c_longlong),
1723- ('new_scrambled', ctypes.c_longlong),
1724- ('new_count', ctypes.c_longlong),
1725- # FIXME: Skipped MediaList and MediaListView...
1726- ('filename', ctypes.c_char_p),
1727- ('new_length', ctypes.c_longlong),
1728- ('media_event', MediaEvent),
1729- ]
1730-
1731-
1732-class Event(_Cstruct):
1733- _fields_ = [
1734- ('type', EventType),
1735- ('object', ctypes.c_void_p),
1736- ('u', EventUnion),
1737- ]
1738-
1739-
1740-class ModuleDescription(_Cstruct):
1741-
1742- def __str__(self):
1743- return '%s %s (%s)' % (self.__class__.__name__, self.shortname, self.name)
1744-
1745-
1746-ModuleDescription._fields_ = [ # recursive struct
1747- ('name', ctypes.c_char_p),
1748- ('shortname', ctypes.c_char_p),
1749- ('longname', ctypes.c_char_p),
1750- ('help', ctypes.c_char_p),
1751- ('next', ctypes.POINTER(ModuleDescription)),
1752-]
1753-
1754-
1755-def module_description_list(head):
1756- """Convert a ModuleDescription linked list to a Python list (and release the former).
1757- """
1758- r = []
1759- if head:
1760- item = head
1761- while item:
1762- item = item.contents
1763- r.append((item.name, item.shortname, item.longname, item.help))
1764- item = item.next
1765- libvlc_module_description_list_release(head)
1766- return r
1767-
1768-
1769-class AudioOutputDevice(_Cstruct):
1770-
1771- def __str__(self):
1772- return '%s(%d:%s)' % (self.__class__.__name__, self.id, self.name)
1773-
1774-
1775-AudioOutputDevice._fields_ = [ # recursive struct
1776- ('next', ctypes.POINTER(AudioOutputDevice)),
1777- ('device', ctypes.c_char_p),
1778- ('description', ctypes.c_char_p),
1779-]
1780-
1781-
1782-class TitleDescription(_Cstruct):
1783- _fields_ = [
1784- ('duration', ctypes.c_longlong),
1785- ('name', ctypes.c_char_p),
1786- ('menu', ctypes.c_bool),
1787- ]
1788-
1789-
1790-class ChapterDescription(_Cstruct):
1791- _fields_ = [
1792- ('time_offset', ctypes.c_longlong),
1793- ('duration', ctypes.c_longlong),
1794- ('name', ctypes.c_char_p),
1795- ]
1796-
1797-
1798-class VideoViewpoint(_Cstruct):
1799- _fields_ = [
1800- ('yaw', ctypes.c_float),
1801- ('pitch', ctypes.c_float),
1802- ('roll', ctypes.c_float),
1803- ('field_of_view', ctypes.c_float),
1804- ]
1805-
1806-
1807-class MediaDiscovererDescription(_Cstruct):
1808- _fields_ = [
1809- ('name', ctypes.c_char_p),
1810- ('longname', ctypes.c_char_p),
1811- ('cat', MediaDiscovererCategory),
1812- ]
1813-
1814- def __str__(self):
1815- return '%s %s (%d) - %s' % (self.__class__.__name__, self.name, self.cat, self.longname)
1816-
1817-
1818-# This struct depends on the MediaSlaveType enum that is defined only
1819-# in > 2.2
1820-if 'MediaSlaveType' in locals():
1821- class MediaSlave(_Cstruct):
1822- _fields_ = [
1823- ('psz_uri', ctypes.c_char_p),
1824- ('i_type', MediaSlaveType),
1825- ('i_priority', ctypes.c_uint)
1826- ]
1827-
1828-
1829-class RDDescription(_Cstruct):
1830- _fields_ = [
1831- ('name', ctypes.c_char_p),
1832- ('longname', ctypes.c_char_p)
1833- ]
1834-
1835-
1836-# End of header.py #
1837-class EventManager(_Ctype):
1838- '''Create an event manager with callback handler.
1839-
1840- This class interposes the registration and handling of
1841- event notifications in order to (a) remove the need for
1842- decorating each callback functions with the decorator
1843- '@callbackmethod', (b) allow any number of positional
1844- and/or keyword arguments to the callback (in addition
1845- to the Event instance) and (c) to preserve the Python
1846- objects such that the callback and argument objects
1847- remain alive (i.e. are not garbage collected) until
1848- B{after} the notification has been unregistered.
1849-
1850- @note: Only a single notification can be registered
1851- for each event type in an EventManager instance.
1852-
1853- '''
1854-
1855- _callback_handler = None
1856- _callbacks = {}
1857-
1858- def __new__(cls, ptr=_internal_guard):
1859- if ptr == _internal_guard:
1860- raise VLCException(
1861- "(INTERNAL) ctypes class.\nYou should get a reference to EventManager through the MediaPlayer.event_manager() method.")
1862- return _Constructor(cls, ptr)
1863-
1864- def event_attach(self, eventtype, callback, *args, **kwds):
1865- """Register an event notification.
1866-
1867- @param eventtype: the desired event type to be notified about.
1868- @param callback: the function to call when the event occurs.
1869- @param args: optional positional arguments for the callback.
1870- @param kwds: optional keyword arguments for the callback.
1871- @return: 0 on success, ENOMEM on error.
1872-
1873- @note: The callback function must have at least one argument,
1874- an Event instance. Any other, optional positional and keyword
1875- arguments are in B{addition} to the first one.
1876- """
1877- if not isinstance(eventtype, EventType):
1878- raise VLCException("%s required: %r" % ('EventType', eventtype))
1879- if not hasattr(callback, '__call__'): # callable()
1880- raise VLCException("%s required: %r" % ('callable', callback))
1881- # check that the callback expects arguments
1882- if not any(getargspec(callback)[:2]): # list(...)
1883- raise VLCException("%s required: %r" % ('argument', callback))
1884-
1885- if self._callback_handler is None:
1886- _called_from_ctypes = ctypes.CFUNCTYPE(None, ctypes.POINTER(Event), ctypes.c_void_p)
1887-
1888- @_called_from_ctypes
1889- def _callback_handler(event, k):
1890- """(INTERNAL) handle callback call from ctypes.
1891-
1892- @note: We cannot simply make this an EventManager
1893- method since ctypes does not prepend self as the
1894- first parameter, hence this closure.
1895- """
1896- try: # retrieve Python callback and arguments
1897- call, args, kwds = self._callbacks[k]
1898- # deref event.contents to simplify callback code
1899- call(event.contents, *args, **kwds)
1900- except KeyError: # detached?
1901- pass
1902-
1903- self._callback_handler = _callback_handler
1904- self._callbacks = {}
1905-
1906- k = eventtype.value
1907- r = libvlc_event_attach(self, k, self._callback_handler, k)
1908- if not r:
1909- self._callbacks[k] = (callback, args, kwds)
1910- return r
1911-
1912- def event_detach(self, eventtype):
1913- """Unregister an event notification.
1914-
1915- @param eventtype: the event type notification to be removed.
1916- """
1917- if not isinstance(eventtype, EventType):
1918- raise VLCException("%s required: %r" % ('EventType', eventtype))
1919-
1920- k = eventtype.value
1921- if k in self._callbacks:
1922- del self._callbacks[k] # remove, regardless of libvlc return value
1923- libvlc_event_detach(self, k, self._callback_handler, k)
1924-
1925-
1926-class Instance(_Ctype):
1927- '''Create a new Instance instance.
1928-
1929- It may take as parameter either:
1930- - a string
1931- - a list of strings as first parameters
1932- - the parameters given as the constructor parameters (must be strings)
1933-
1934- '''
1935-
1936- def __new__(cls, *args):
1937- if len(args) == 1:
1938- # Only 1 arg. It is either a C pointer, or an arg string,
1939- # or a tuple.
1940- i = args[0]
1941- if isinstance(i, _Ints):
1942- return _Constructor(cls, i)
1943- elif isinstance(i, basestring):
1944- args = i.strip().split()
1945- elif isinstance(i, _Seqs):
1946- args = list(i)
1947- else:
1948- raise VLCException('Instance %r' % (args,))
1949- else:
1950- args = list(args)
1951-
1952- if not args: # no parameters passed
1953- args = ['vlc']
1954- elif args[0] != 'vlc':
1955- args.insert(0, 'vlc')
1956-
1957- if plugin_path is not None:
1958- # set plugin_path if detected, win32 and MacOS,
1959- # if the user did not specify it itself.
1960- os.environ.setdefault('VLC_PLUGIN_PATH', plugin_path)
1961-
1962- if PYTHON3:
1963- args = [str_to_bytes(a) for a in args]
1964- return libvlc_new(len(args), args)
1965-
1966- def media_player_new(self, uri=None):
1967- """Create a new MediaPlayer instance.
1968-
1969- @param uri: an optional URI to play in the player.
1970- """
1971- p = libvlc_media_player_new(self)
1972- if uri:
1973- p.set_media(self.media_new(uri))
1974- p._instance = self
1975- return p
1976-
1977- def media_list_player_new(self):
1978- """Create a new MediaListPlayer instance.
1979- """
1980- p = libvlc_media_list_player_new(self)
1981- p._instance = self
1982- return p
1983-
1984- def media_new(self, mrl, *options):
1985- """Create a new Media instance.
1986-
1987- If mrl contains a colon (:) preceded by more than 1 letter, it
1988- will be treated as a URL. Else, it will be considered as a
1989- local path. If you need more control, directly use
1990- media_new_location/media_new_path methods.
1991-
1992- Options can be specified as supplementary string parameters,
1993- but note that many options cannot be set at the media level,
1994- and rather at the Instance level. For instance, the marquee
1995- filter must be specified when creating the vlc.Instance or
1996- vlc.MediaPlayer.
1997-
1998- Alternatively, options can be added to the media using the
1999- Media.add_options method (with the same limitation).
2000-
2001- @param options: optional media option=value strings
2002- """
2003- if ':' in mrl and mrl.index(':') > 1:
2004- # Assume it is a URL
2005- m = libvlc_media_new_location(self, str_to_bytes(mrl))
2006- else:
2007- # Else it should be a local path.
2008- m = libvlc_media_new_path(self, str_to_bytes(os.path.normpath(mrl)))
2009- for o in options:
2010- libvlc_media_add_option(m, str_to_bytes(o))
2011- m._instance = self
2012- return m
2013-
2014- def media_list_new(self, mrls=None):
2015- """Create a new MediaList instance.
2016- @param mrls: optional list of MRL strings
2017- """
2018- l = libvlc_media_list_new(self)
2019- # We should take the lock, but since we did not leak the
2020- # reference, nobody else can access it.
2021- if mrls:
2022- for m in mrls:
2023- l.add_media(m)
2024- l._instance = self
2025- return l
2026-
2027- def audio_output_enumerate_devices(self):
2028- """Enumerate the defined audio output devices.
2029-
2030- @return: list of dicts {name:, description:, devices:}
2031- """
2032- r = []
2033- head = libvlc_audio_output_list_get(self)
2034- if head:
2035- i = head
2036- while i:
2037- i = i.contents
2038- d = [{'id': libvlc_audio_output_device_id(self, i.name, d),
2039- 'longname': libvlc_audio_output_device_longname(self, i.name, d)}
2040- for d in range(libvlc_audio_output_device_count(self, i.name))]
2041- r.append({'name': i.name, 'description': i.description, 'devices': d})
2042- i = i.next
2043- libvlc_audio_output_list_release(head)
2044- return r
2045-
2046- def audio_filter_list_get(self):
2047- """Returns a list of available audio filters.
2048-
2049- """
2050- return module_description_list(libvlc_audio_filter_list_get(self))
2051-
2052- def video_filter_list_get(self):
2053- """Returns a list of available video filters.
2054-
2055- """
2056- return module_description_list(libvlc_video_filter_list_get(self))
2057-
2058- def release(self):
2059- '''Decrement the reference count of a libvlc instance, and destroy it
2060- if it reaches zero.
2061- '''
2062- return libvlc_release(self)
2063-
2064- def retain(self):
2065- '''Increments the reference count of a libvlc instance.
2066- The initial reference count is 1 after L{new}() returns.
2067- '''
2068- return libvlc_retain(self)
2069-
2070- def add_intf(self, name):
2071- '''Try to start a user interface for the libvlc instance.
2072- @param name: interface name, or None for default.
2073- @return: 0 on success, -1 on error.
2074- '''
2075- return libvlc_add_intf(self, str_to_bytes(name))
2076-
2077- def set_user_agent(self, name, http):
2078- '''Sets the application name. LibVLC passes this as the user agent string
2079- when a protocol requires it.
2080- @param name: human-readable application name, e.g. "FooBar player 1.2.3".
2081- @param http: HTTP User Agent, e.g. "FooBar/1.2.3 Python/2.6.0".
2082- @version: LibVLC 1.1.1 or later.
2083- '''
2084- return libvlc_set_user_agent(self, str_to_bytes(name), str_to_bytes(http))
2085-
2086- def set_app_id(self, id, version, icon):
2087- '''Sets some meta-information about the application.
2088- See also L{set_user_agent}().
2089- @param id: Java-style application identifier, e.g. "com.acme.foobar".
2090- @param version: application version numbers, e.g. "1.2.3".
2091- @param icon: application icon name, e.g. "foobar".
2092- @version: LibVLC 2.1.0 or later.
2093- '''
2094- return libvlc_set_app_id(self, str_to_bytes(id), str_to_bytes(version), str_to_bytes(icon))
2095-
2096- def log_unset(self):
2097- '''Unsets the logging callback.
2098- This function deregisters the logging callback for a LibVLC instance.
2099- This is rarely needed as the callback is implicitly unset when the instance
2100- is destroyed.
2101- @note: This function will wait for any pending callbacks invocation to
2102- complete (causing a deadlock if called from within the callback).
2103- @version: LibVLC 2.1.0 or later.
2104- '''
2105- return libvlc_log_unset(self)
2106-
2107- def log_set(self, cb, data):
2108- '''Sets the logging callback for a LibVLC instance.
2109- This function is thread-safe: it will wait for any pending callbacks
2110- invocation to complete.
2111- @param data: opaque data pointer for the callback function @note Some log messages (especially debug) are emitted by LibVLC while is being initialized. These messages cannot be captured with this interface. @warning A deadlock may occur if this function is called from the callback.
2112- @param p_instance: libvlc instance.
2113- @version: LibVLC 2.1.0 or later.
2114- '''
2115- return libvlc_log_set(self, cb, data)
2116-
2117- def log_set_file(self, stream):
2118- '''Sets up logging to a file.
2119- @param stream: FILE pointer opened for writing (the FILE pointer must remain valid until L{log_unset}()).
2120- @version: LibVLC 2.1.0 or later.
2121- '''
2122- return libvlc_log_set_file(self, stream)
2123-
2124- def media_discoverer_new(self, psz_name):
2125- '''Create a media discoverer object by name.
2126- After this object is created, you should attach to media_list events in
2127- order to be notified of new items discovered.
2128- You need to call L{media_discoverer_start}() in order to start the
2129- discovery.
2130- See L{media_discoverer_media_list}
2131- See L{media_discoverer_event_manager}
2132- See L{media_discoverer_start}.
2133- @param psz_name: service name; use L{media_discoverer_list_get}() to get a list of the discoverer names available in this libVLC instance.
2134- @return: media discover object or None in case of error.
2135- @version: LibVLC 3.0.0 or later.
2136- '''
2137- return libvlc_media_discoverer_new(self, str_to_bytes(psz_name))
2138-
2139- def media_discoverer_list_get(self, i_cat, ppp_services):
2140- '''Get media discoverer services by category.
2141- @param i_cat: category of services to fetch.
2142- @param ppp_services: address to store an allocated array of media discoverer services (must be freed with L{media_discoverer_list_release}() by the caller) [OUT].
2143- @return: the number of media discoverer services (0 on error).
2144- @version: LibVLC 3.0.0 and later.
2145- '''
2146- return libvlc_media_discoverer_list_get(self, i_cat, ppp_services)
2147-
2148- def media_library_new(self):
2149- '''Create an new Media Library object.
2150- @return: a new object or None on error.
2151- '''
2152- return libvlc_media_library_new(self)
2153-
2154- def vlm_release(self):
2155- '''Release the vlm instance related to the given L{Instance}.
2156- '''
2157- return libvlc_vlm_release(self)
2158-
2159- def vlm_add_broadcast(self, psz_name, psz_input, psz_output, i_options, ppsz_options, b_enabled, b_loop):
2160- '''Add a broadcast, with one input.
2161- @param psz_name: the name of the new broadcast.
2162- @param psz_input: the input MRL.
2163- @param psz_output: the output MRL (the parameter to the "sout" variable).
2164- @param i_options: number of additional options.
2165- @param ppsz_options: additional options.
2166- @param b_enabled: boolean for enabling the new broadcast.
2167- @param b_loop: Should this broadcast be played in loop ?
2168- @return: 0 on success, -1 on error.
2169- '''
2170- return libvlc_vlm_add_broadcast(self, str_to_bytes(psz_name), str_to_bytes(psz_input), str_to_bytes(psz_output),
2171- i_options, ppsz_options, b_enabled, b_loop)
2172-
2173- def vlm_add_vod(self, psz_name, psz_input, i_options, ppsz_options, b_enabled, psz_mux):
2174- '''Add a vod, with one input.
2175- @param psz_name: the name of the new vod media.
2176- @param psz_input: the input MRL.
2177- @param i_options: number of additional options.
2178- @param ppsz_options: additional options.
2179- @param b_enabled: boolean for enabling the new vod.
2180- @param psz_mux: the muxer of the vod media.
2181- @return: 0 on success, -1 on error.
2182- '''
2183- return libvlc_vlm_add_vod(self, str_to_bytes(psz_name), str_to_bytes(psz_input), i_options, ppsz_options,
2184- b_enabled, str_to_bytes(psz_mux))
2185-
2186- def vlm_del_media(self, psz_name):
2187- '''Delete a media (VOD or broadcast).
2188- @param psz_name: the media to delete.
2189- @return: 0 on success, -1 on error.
2190- '''
2191- return libvlc_vlm_del_media(self, str_to_bytes(psz_name))
2192-
2193- def vlm_set_enabled(self, psz_name, b_enabled):
2194- '''Enable or disable a media (VOD or broadcast).
2195- @param psz_name: the media to work on.
2196- @param b_enabled: the new status.
2197- @return: 0 on success, -1 on error.
2198- '''
2199- return libvlc_vlm_set_enabled(self, str_to_bytes(psz_name), b_enabled)
2200-
2201- def vlm_set_output(self, psz_name, psz_output):
2202- '''Set the output for a media.
2203- @param psz_name: the media to work on.
2204- @param psz_output: the output MRL (the parameter to the "sout" variable).
2205- @return: 0 on success, -1 on error.
2206- '''
2207- return libvlc_vlm_set_output(self, str_to_bytes(psz_name), str_to_bytes(psz_output))
2208-
2209- def vlm_set_input(self, psz_name, psz_input):
2210- '''Set a media's input MRL. This will delete all existing inputs and
2211- add the specified one.
2212- @param psz_name: the media to work on.
2213- @param psz_input: the input MRL.
2214- @return: 0 on success, -1 on error.
2215- '''
2216- return libvlc_vlm_set_input(self, str_to_bytes(psz_name), str_to_bytes(psz_input))
2217-
2218- def vlm_add_input(self, psz_name, psz_input):
2219- '''Add a media's input MRL. This will add the specified one.
2220- @param psz_name: the media to work on.
2221- @param psz_input: the input MRL.
2222- @return: 0 on success, -1 on error.
2223- '''
2224- return libvlc_vlm_add_input(self, str_to_bytes(psz_name), str_to_bytes(psz_input))
2225-
2226- def vlm_set_loop(self, psz_name, b_loop):
2227- '''Set a media's loop status.
2228- @param psz_name: the media to work on.
2229- @param b_loop: the new status.
2230- @return: 0 on success, -1 on error.
2231- '''
2232- return libvlc_vlm_set_loop(self, str_to_bytes(psz_name), b_loop)
2233-
2234- def vlm_set_mux(self, psz_name, psz_mux):
2235- '''Set a media's vod muxer.
2236- @param psz_name: the media to work on.
2237- @param psz_mux: the new muxer.
2238- @return: 0 on success, -1 on error.
2239- '''
2240- return libvlc_vlm_set_mux(self, str_to_bytes(psz_name), str_to_bytes(psz_mux))
2241-
2242- def vlm_change_media(self, psz_name, psz_input, psz_output, i_options, ppsz_options, b_enabled, b_loop):
2243- '''Edit the parameters of a media. This will delete all existing inputs and
2244- add the specified one.
2245- @param psz_name: the name of the new broadcast.
2246- @param psz_input: the input MRL.
2247- @param psz_output: the output MRL (the parameter to the "sout" variable).
2248- @param i_options: number of additional options.
2249- @param ppsz_options: additional options.
2250- @param b_enabled: boolean for enabling the new broadcast.
2251- @param b_loop: Should this broadcast be played in loop ?
2252- @return: 0 on success, -1 on error.
2253- '''
2254- return libvlc_vlm_change_media(self, str_to_bytes(psz_name), str_to_bytes(psz_input), str_to_bytes(psz_output),
2255- i_options, ppsz_options, b_enabled, b_loop)
2256-
2257- def vlm_play_media(self, psz_name):
2258- '''Play the named broadcast.
2259- @param psz_name: the name of the broadcast.
2260- @return: 0 on success, -1 on error.
2261- '''
2262- return libvlc_vlm_play_media(self, str_to_bytes(psz_name))
2263-
2264- def vlm_stop_media(self, psz_name):
2265- '''Stop the named broadcast.
2266- @param psz_name: the name of the broadcast.
2267- @return: 0 on success, -1 on error.
2268- '''
2269- return libvlc_vlm_stop_media(self, str_to_bytes(psz_name))
2270-
2271- def vlm_pause_media(self, psz_name):
2272- '''Pause the named broadcast.
2273- @param psz_name: the name of the broadcast.
2274- @return: 0 on success, -1 on error.
2275- '''
2276- return libvlc_vlm_pause_media(self, str_to_bytes(psz_name))
2277-
2278- def vlm_seek_media(self, psz_name, f_percentage):
2279- '''Seek in the named broadcast.
2280- @param psz_name: the name of the broadcast.
2281- @param f_percentage: the percentage to seek to.
2282- @return: 0 on success, -1 on error.
2283- '''
2284- return libvlc_vlm_seek_media(self, str_to_bytes(psz_name), f_percentage)
2285-
2286- def vlm_show_media(self, psz_name):
2287- '''Return information about the named media as a JSON
2288- string representation.
2289- This function is mainly intended for debugging use,
2290- if you want programmatic access to the state of
2291- a vlm_media_instance_t, please use the corresponding
2292- libvlc_vlm_get_media_instance_xxx -functions.
2293- Currently there are no such functions available for
2294- vlm_media_t though.
2295- @param psz_name: the name of the media, if the name is an empty string, all media is described.
2296- @return: string with information about named media, or None on error.
2297- '''
2298- return libvlc_vlm_show_media(self, str_to_bytes(psz_name))
2299-
2300- def vlm_get_media_instance_position(self, psz_name, i_instance):
2301- '''Get vlm_media instance position by name or instance id.
2302- @param psz_name: name of vlm media instance.
2303- @param i_instance: instance id.
2304- @return: position as float or -1. on error.
2305- '''
2306- return libvlc_vlm_get_media_instance_position(self, str_to_bytes(psz_name), i_instance)
2307-
2308- def vlm_get_media_instance_time(self, psz_name, i_instance):
2309- '''Get vlm_media instance time by name or instance id.
2310- @param psz_name: name of vlm media instance.
2311- @param i_instance: instance id.
2312- @return: time as integer or -1 on error.
2313- '''
2314- return libvlc_vlm_get_media_instance_time(self, str_to_bytes(psz_name), i_instance)
2315-
2316- def vlm_get_media_instance_length(self, psz_name, i_instance):
2317- '''Get vlm_media instance length by name or instance id.
2318- @param psz_name: name of vlm media instance.
2319- @param i_instance: instance id.
2320- @return: length of media item or -1 on error.
2321- '''
2322- return libvlc_vlm_get_media_instance_length(self, str_to_bytes(psz_name), i_instance)
2323-
2324- def vlm_get_media_instance_rate(self, psz_name, i_instance):
2325- '''Get vlm_media instance playback rate by name or instance id.
2326- @param psz_name: name of vlm media instance.
2327- @param i_instance: instance id.
2328- @return: playback rate or -1 on error.
2329- '''
2330- return libvlc_vlm_get_media_instance_rate(self, str_to_bytes(psz_name), i_instance)
2331-
2332- def vlm_get_media_instance_title(self, psz_name, i_instance):
2333- '''Get vlm_media instance title number by name or instance id.
2334- @param psz_name: name of vlm media instance.
2335- @param i_instance: instance id.
2336- @return: title as number or -1 on error.
2337- @bug: will always return 0.
2338- '''
2339- return libvlc_vlm_get_media_instance_title(self, str_to_bytes(psz_name), i_instance)
2340-
2341- def vlm_get_media_instance_chapter(self, psz_name, i_instance):
2342- '''Get vlm_media instance chapter number by name or instance id.
2343- @param psz_name: name of vlm media instance.
2344- @param i_instance: instance id.
2345- @return: chapter as number or -1 on error.
2346- @bug: will always return 0.
2347- '''
2348- return libvlc_vlm_get_media_instance_chapter(self, str_to_bytes(psz_name), i_instance)
2349-
2350- def vlm_get_media_instance_seekable(self, psz_name, i_instance):
2351- '''Is libvlc instance seekable ?
2352- @param psz_name: name of vlm media instance.
2353- @param i_instance: instance id.
2354- @return: 1 if seekable, 0 if not, -1 if media does not exist.
2355- @bug: will always return 0.
2356- '''
2357- return libvlc_vlm_get_media_instance_seekable(self, str_to_bytes(psz_name), i_instance)
2358-
2359- @memoize_parameterless
2360- def vlm_get_event_manager(self):
2361- '''Get libvlc_event_manager from a vlm media.
2362- The p_event_manager is immutable, so you don't have to hold the lock.
2363- @return: libvlc_event_manager.
2364- '''
2365- return libvlc_vlm_get_event_manager(self)
2366-
2367- def media_new_location(self, psz_mrl):
2368- '''Create a media with a certain given media resource location,
2369- for instance a valid URL.
2370- @note: To refer to a local file with this function,
2371- the file://... URI syntax B{must} be used (see IETF RFC3986).
2372- We recommend using L{media_new_path}() instead when dealing with
2373- local files.
2374- See L{media_release}.
2375- @param psz_mrl: the media location.
2376- @return: the newly created media or None on error.
2377- '''
2378- return libvlc_media_new_location(self, str_to_bytes(psz_mrl))
2379-
2380- def media_new_path(self, path):
2381- '''Create a media for a certain file path.
2382- See L{media_release}.
2383- @param path: local filesystem path.
2384- @return: the newly created media or None on error.
2385- '''
2386- return libvlc_media_new_path(self, str_to_bytes(path))
2387-
2388- def media_new_fd(self, fd):
2389- '''Create a media for an already open file descriptor.
2390- The file descriptor shall be open for reading (or reading and writing).
2391- Regular file descriptors, pipe read descriptors and character device
2392- descriptors (including TTYs) are supported on all platforms.
2393- Block device descriptors are supported where available.
2394- Directory descriptors are supported on systems that provide fdopendir().
2395- Sockets are supported on all platforms where they are file descriptors,
2396- i.e. all except Windows.
2397- @note: This library will B{not} automatically close the file descriptor
2398- under any circumstance. Nevertheless, a file descriptor can usually only be
2399- rendered once in a media player. To render it a second time, the file
2400- descriptor should probably be rewound to the beginning with lseek().
2401- See L{media_release}.
2402- @param fd: open file descriptor.
2403- @return: the newly created media or None on error.
2404- @version: LibVLC 1.1.5 and later.
2405- '''
2406- return libvlc_media_new_fd(self, fd)
2407-
2408- def media_new_callbacks(self, open_cb, read_cb, seek_cb, close_cb, opaque):
2409- '''Create a media with custom callbacks to read the data from.
2410- @param open_cb: callback to open the custom bitstream input media.
2411- @param read_cb: callback to read data (must not be None).
2412- @param seek_cb: callback to seek, or None if seeking is not supported.
2413- @param close_cb: callback to close the media, or None if unnecessary.
2414- @param opaque: data pointer for the open callback.
2415- @return: the newly created media or None on error @note If open_cb is None, the opaque pointer will be passed to read_cb, seek_cb and close_cb, and the stream size will be treated as unknown. @note The callbacks may be called asynchronously (from another thread). A single stream instance need not be reentrant. However the open_cb needs to be reentrant if the media is used by multiple player instances. @warning The callbacks may be used until all or any player instances that were supplied the media item are stopped. See L{media_release}.
2416- @version: LibVLC 3.0.0 and later.
2417- '''
2418- return libvlc_media_new_callbacks(self, open_cb, read_cb, seek_cb, close_cb, opaque)
2419-
2420- def media_new_as_node(self, psz_name):
2421- '''Create a media as an empty node with a given name.
2422- See L{media_release}.
2423- @param psz_name: the name of the node.
2424- @return: the new empty media or None on error.
2425- '''
2426- return libvlc_media_new_as_node(self, str_to_bytes(psz_name))
2427-
2428- def renderer_discoverer_new(self, psz_name):
2429- '''Create a renderer discoverer object by name
2430- After this object is created, you should attach to events in order to be
2431- notified of the discoverer events.
2432- You need to call L{renderer_discoverer_start}() in order to start the
2433- discovery.
2434- See L{renderer_discoverer_event_manager}()
2435- See L{renderer_discoverer_start}().
2436- @param psz_name: service name; use L{renderer_discoverer_list_get}() to get a list of the discoverer names available in this libVLC instance.
2437- @return: media discover object or None in case of error.
2438- @version: LibVLC 3.0.0 or later.
2439- '''
2440- return libvlc_renderer_discoverer_new(self, str_to_bytes(psz_name))
2441-
2442- def renderer_discoverer_list_get(self, ppp_services):
2443- '''Get media discoverer services
2444- See libvlc_renderer_list_release().
2445- @param ppp_services: address to store an allocated array of renderer discoverer services (must be freed with libvlc_renderer_list_release() by the caller) [OUT].
2446- @return: the number of media discoverer services (0 on error).
2447- @version: LibVLC 3.0.0 and later.
2448- '''
2449- return libvlc_renderer_discoverer_list_get(self, ppp_services)
2450-
2451- def audio_output_device_count(self, psz_audio_output):
2452- '''Backward compatibility stub. Do not use in new code.
2453- \deprecated Use L{audio_output_device_list_get}() instead.
2454- @return: always 0.
2455- '''
2456- return libvlc_audio_output_device_count(self, str_to_bytes(psz_audio_output))
2457-
2458- def audio_output_device_longname(self, psz_output, i_device):
2459- '''Backward compatibility stub. Do not use in new code.
2460- \deprecated Use L{audio_output_device_list_get}() instead.
2461- @return: always None.
2462- '''
2463- return libvlc_audio_output_device_longname(self, str_to_bytes(psz_output), i_device)
2464-
2465- def audio_output_device_id(self, psz_audio_output, i_device):
2466- '''Backward compatibility stub. Do not use in new code.
2467- \deprecated Use L{audio_output_device_list_get}() instead.
2468- @return: always None.
2469- '''
2470- return libvlc_audio_output_device_id(self, str_to_bytes(psz_audio_output), i_device)
2471-
2472- def media_discoverer_new_from_name(self, psz_name):
2473- '''\deprecated Use L{media_discoverer_new}() and L{media_discoverer_start}().
2474- '''
2475- return libvlc_media_discoverer_new_from_name(self, str_to_bytes(psz_name))
2476-
2477- def wait(self):
2478- '''Waits until an interface causes the instance to exit.
2479- You should start at least one interface first, using L{add_intf}().
2480- '''
2481- return libvlc_wait(self)
2482-
2483- def get_log_verbosity(self):
2484- '''Always returns minus one.
2485- This function is only provided for backward compatibility.
2486- @return: always -1.
2487- '''
2488- return libvlc_get_log_verbosity(self)
2489-
2490- def set_log_verbosity(self, level):
2491- '''This function does nothing.
2492- It is only provided for backward compatibility.
2493- @param level: ignored.
2494- '''
2495- return libvlc_set_log_verbosity(self, level)
2496-
2497- def log_open(self):
2498- '''This function does nothing useful.
2499- It is only provided for backward compatibility.
2500- @return: an unique pointer or None on error.
2501- '''
2502- return libvlc_log_open(self)
2503-
2504- def playlist_play(self, i_id, i_options, ppsz_options):
2505- '''Start playing (if there is any item in the playlist).
2506- Additionnal playlist item options can be specified for addition to the
2507- item before it is played.
2508- @param i_id: the item to play. If this is a negative number, the next item will be selected. Otherwise, the item with the given ID will be played.
2509- @param i_options: the number of options to add to the item.
2510- @param ppsz_options: the options to add to the item.
2511- '''
2512- return libvlc_playlist_play(self, i_id, i_options, ppsz_options)
2513-
2514- def audio_output_list_get(self):
2515- '''Gets the list of available audio output modules.
2516- @return: list of available audio outputs. It must be freed with In case of error, None is returned.
2517- '''
2518- return libvlc_audio_output_list_get(self)
2519-
2520- def audio_output_device_list_get(self, aout):
2521- '''Gets a list of audio output devices for a given audio output module,
2522- See L{audio_output_device_set}().
2523- @note: Not all audio outputs support this. In particular, an empty (None)
2524- list of devices does B{not} imply that the specified audio output does
2525- not work.
2526- @note: The list might not be exhaustive.
2527- @warning: Some audio output devices in the list might not actually work in
2528- some circumstances. By default, it is recommended to not specify any
2529- explicit audio device.
2530- @param aout: audio output name (as returned by L{audio_output_list_get}()).
2531- @return: A None-terminated linked list of potential audio output devices. It must be freed with L{audio_output_device_list_release}().
2532- @version: LibVLC 2.1.0 or later.
2533- '''
2534- return libvlc_audio_output_device_list_get(self, str_to_bytes(aout))
2535-
2536-
2537-class LogIterator(_Ctype):
2538- '''Create a new VLC log iterator.
2539-
2540- '''
2541-
2542- def __new__(cls, ptr=_internal_guard):
2543- '''(INTERNAL) ctypes wrapper constructor.
2544- '''
2545- return _Constructor(cls, ptr)
2546-
2547- def __iter__(self):
2548- return self
2549-
2550- def next(self):
2551- if self.has_next():
2552- b = LogMessage()
2553- i = libvlc_log_iterator_next(self, b)
2554- return i.contents
2555- raise StopIteration
2556-
2557- def __next__(self):
2558- return self.next()
2559-
2560- def free(self):
2561- '''Frees memory allocated by L{log_get_iterator}().
2562- '''
2563- return libvlc_log_iterator_free(self)
2564-
2565- def has_next(self):
2566- '''Always returns zero.
2567- This function is only provided for backward compatibility.
2568- @return: always zero.
2569- '''
2570- return libvlc_log_iterator_has_next(self)
2571-
2572-
2573-class Media(_Ctype):
2574- '''Create a new Media instance.
2575-
2576- Usage: Media(MRL, *options)
2577-
2578- See vlc.Instance.media_new documentation for details.
2579-
2580- '''
2581-
2582- def __new__(cls, *args):
2583- if args:
2584- i = args[0]
2585- if isinstance(i, _Ints):
2586- return _Constructor(cls, i)
2587- if isinstance(i, Instance):
2588- return i.media_new(*args[1:])
2589-
2590- o = get_default_instance().media_new(*args)
2591- return o
2592-
2593- def get_instance(self):
2594- return getattr(self, '_instance', None)
2595-
2596- def add_options(self, *options):
2597- """Add a list of options to the media.
2598-
2599- Options must be written without the double-dash. Warning: most
2600- audio and video options, such as text renderer, have no
2601- effects on an individual media. These options must be set at
2602- the vlc.Instance or vlc.MediaPlayer instanciation.
2603-
2604- @param options: optional media option=value strings
2605- """
2606- for o in options:
2607- self.add_option(o)
2608-
2609- def tracks_get(self):
2610- """Get media descriptor's elementary streams description
2611- Note, you need to call L{parse}() or play the media at least once
2612- before calling this function.
2613- Not doing this will result in an empty array.
2614- The result must be freed with L{tracks_release}.
2615- @version: LibVLC 2.1.0 and later.
2616- """
2617- mediaTrack_pp = ctypes.POINTER(MediaTrack)()
2618- n = libvlc_media_tracks_get(self, ctypes.byref(mediaTrack_pp))
2619- info = ctypes.cast(mediaTrack_pp, ctypes.POINTER(ctypes.POINTER(MediaTrack) * n))
2620- try:
2621- contents = info.contents
2622- except ValueError:
2623- # Media not parsed, no info.
2624- return None
2625- tracks = (contents[i].contents for i in range(len(contents)))
2626- # libvlc_media_tracks_release(mediaTrack_pp, n)
2627- return tracks
2628-
2629- def add_option(self, psz_options):
2630- '''Add an option to the media.
2631- This option will be used to determine how the media_player will
2632- read the media. This allows to use VLC's advanced
2633- reading/streaming options on a per-media basis.
2634- @note: The options are listed in 'vlc --long-help' from the command line,
2635- e.g. "-sout-all". Keep in mind that available options and their semantics
2636- vary across LibVLC versions and builds.
2637- @warning: Not all options affects L{Media} objects:
2638- Specifically, due to architectural issues most audio and video options,
2639- such as text renderer options, have no effects on an individual media.
2640- These options must be set through L{new}() instead.
2641- @param psz_options: the options (as a string).
2642- '''
2643- return libvlc_media_add_option(self, str_to_bytes(psz_options))
2644-
2645- def add_option_flag(self, psz_options, i_flags):
2646- '''Add an option to the media with configurable flags.
2647- This option will be used to determine how the media_player will
2648- read the media. This allows to use VLC's advanced
2649- reading/streaming options on a per-media basis.
2650- The options are detailed in vlc --long-help, for instance
2651- "--sout-all". Note that all options are not usable on medias:
2652- specifically, due to architectural issues, video-related options
2653- such as text renderer options cannot be set on a single media. They
2654- must be set on the whole libvlc instance instead.
2655- @param psz_options: the options (as a string).
2656- @param i_flags: the flags for this option.
2657- '''
2658- return libvlc_media_add_option_flag(self, str_to_bytes(psz_options), i_flags)
2659-
2660- def retain(self):
2661- '''Retain a reference to a media descriptor object (L{Media}). Use
2662- L{release}() to decrement the reference count of a
2663- media descriptor object.
2664- '''
2665- return libvlc_media_retain(self)
2666-
2667- def release(self):
2668- '''Decrement the reference count of a media descriptor object. If the
2669- reference count is 0, then L{release}() will release the
2670- media descriptor object. It will send out an libvlc_MediaFreed event
2671- to all listeners. If the media descriptor object has been released it
2672- should not be used again.
2673- '''
2674- return libvlc_media_release(self)
2675-
2676- def get_mrl(self):
2677- '''Get the media resource locator (mrl) from a media descriptor object.
2678- @return: string with mrl of media descriptor object.
2679- '''
2680- return libvlc_media_get_mrl(self)
2681-
2682- def duplicate(self):
2683- '''Duplicate a media descriptor object.
2684- '''
2685- return libvlc_media_duplicate(self)
2686-
2687- def get_meta(self, e_meta):
2688- '''Read the meta of the media.
2689- If the media has not yet been parsed this will return None.
2690- See L{parse}
2691- See L{parse_with_options}
2692- See libvlc_MediaMetaChanged.
2693- @param e_meta: the meta to read.
2694- @return: the media's meta.
2695- '''
2696- return libvlc_media_get_meta(self, e_meta)
2697-
2698- def set_meta(self, e_meta, psz_value):
2699- '''Set the meta of the media (this function will not save the meta, call
2700- L{save_meta} in order to save the meta).
2701- @param e_meta: the meta to write.
2702- @param psz_value: the media's meta.
2703- '''
2704- return libvlc_media_set_meta(self, e_meta, str_to_bytes(psz_value))
2705-
2706- def save_meta(self):
2707- '''Save the meta previously set.
2708- @return: true if the write operation was successful.
2709- '''
2710- return libvlc_media_save_meta(self)
2711-
2712- def get_state(self):
2713- '''Get current state of media descriptor object. Possible media states are
2714- libvlc_NothingSpecial=0, libvlc_Opening, libvlc_Playing, libvlc_Paused,
2715- libvlc_Stopped, libvlc_Ended, libvlc_Error.
2716- See L{State}.
2717- @return: state of media descriptor object.
2718- '''
2719- return libvlc_media_get_state(self)
2720-
2721- def get_stats(self, p_stats):
2722- '''Get the current statistics about the media.
2723- @param p_stats:: structure that contain the statistics about the media (this structure must be allocated by the caller).
2724- @return: true if the statistics are available, false otherwise \libvlc_return_bool.
2725- '''
2726- return libvlc_media_get_stats(self, p_stats)
2727-
2728- def subitems(self):
2729- '''Get subitems of media descriptor object. This will increment
2730- the reference count of supplied media descriptor object. Use
2731- L{list_release}() to decrement the reference counting.
2732- @return: list of media descriptor subitems or None.
2733- '''
2734- return libvlc_media_subitems(self)
2735-
2736- @memoize_parameterless
2737- def event_manager(self):
2738- '''Get event manager from media descriptor object.
2739- NOTE: this function doesn't increment reference counting.
2740- @return: event manager object.
2741- '''
2742- return libvlc_media_event_manager(self)
2743-
2744- def get_duration(self):
2745- '''Get duration (in ms) of media descriptor object item.
2746- @return: duration of media item or -1 on error.
2747- '''
2748- return libvlc_media_get_duration(self)
2749-
2750- def parse_with_options(self, parse_flag, timeout):
2751- '''Parse the media asynchronously with options.
2752- This fetches (local or network) art, meta data and/or tracks information.
2753- This method is the extended version of L{parse_with_options}().
2754- To track when this is over you can listen to libvlc_MediaParsedChanged
2755- event. However if this functions returns an error, you will not receive any
2756- events.
2757- It uses a flag to specify parse options (see L{MediaParseFlag}). All
2758- these flags can be combined. By default, media is parsed if it's a local
2759- file.
2760- @note: Parsing can be aborted with L{parse_stop}().
2761- See libvlc_MediaParsedChanged
2762- See L{get_meta}
2763- See L{tracks_get}
2764- See L{get_parsed_status}
2765- See L{MediaParseFlag}.
2766- @param parse_flag: parse options:
2767- @param timeout: maximum time allowed to preparse the media. If -1, the default "preparse-timeout" option will be used as a timeout. If 0, it will wait indefinitely. If > 0, the timeout will be used (in milliseconds).
2768- @return: -1 in case of error, 0 otherwise.
2769- @version: LibVLC 3.0.0 or later.
2770- '''
2771- return libvlc_media_parse_with_options(self, parse_flag, timeout)
2772-
2773- def parse_stop(self):
2774- '''Stop the parsing of the media
2775- When the media parsing is stopped, the libvlc_MediaParsedChanged event will
2776- be sent with the libvlc_media_parsed_status_timeout status.
2777- See L{parse_with_options}.
2778- @version: LibVLC 3.0.0 or later.
2779- '''
2780- return libvlc_media_parse_stop(self)
2781-
2782- def get_parsed_status(self):
2783- '''Get Parsed status for media descriptor object.
2784- See libvlc_MediaParsedChanged
2785- See L{MediaParsedStatus}.
2786- @return: a value of the L{MediaParsedStatus} enum.
2787- @version: LibVLC 3.0.0 or later.
2788- '''
2789- return libvlc_media_get_parsed_status(self)
2790-
2791- def set_user_data(self, p_new_user_data):
2792- '''Sets media descriptor's user_data. user_data is specialized data
2793- accessed by the host application, VLC.framework uses it as a pointer to
2794- an native object that references a L{Media} pointer.
2795- @param p_new_user_data: pointer to user data.
2796- '''
2797- return libvlc_media_set_user_data(self, p_new_user_data)
2798-
2799- def get_user_data(self):
2800- '''Get media descriptor's user_data. user_data is specialized data
2801- accessed by the host application, VLC.framework uses it as a pointer to
2802- an native object that references a L{Media} pointer.
2803- '''
2804- return libvlc_media_get_user_data(self)
2805-
2806- def get_type(self):
2807- '''Get the media type of the media descriptor object.
2808- @return: media type.
2809- @version: LibVLC 3.0.0 and later. See L{MediaType}.
2810- '''
2811- return libvlc_media_get_type(self)
2812-
2813- def slaves_add(self, i_type, i_priority, psz_uri):
2814- '''Add a slave to the current media.
2815- A slave is an external input source that may contains an additional subtitle
2816- track (like a .srt) or an additional audio track (like a .ac3).
2817- @note: This function must be called before the media is parsed (via
2818- L{parse_with_options}()) or before the media is played (via
2819- L{player_play}()).
2820- @param i_type: subtitle or audio.
2821- @param i_priority: from 0 (low priority) to 4 (high priority).
2822- @param psz_uri: Uri of the slave (should contain a valid scheme).
2823- @return: 0 on success, -1 on error.
2824- @version: LibVLC 3.0.0 and later.
2825- '''
2826- return libvlc_media_slaves_add(self, i_type, i_priority, str_to_bytes(psz_uri))
2827-
2828- def slaves_clear(self):
2829- '''Clear all slaves previously added by L{slaves_add}() or
2830- internally.
2831- @version: LibVLC 3.0.0 and later.
2832- '''
2833- return libvlc_media_slaves_clear(self)
2834-
2835- def slaves_get(self, ppp_slaves):
2836- '''Get a media descriptor's slave list
2837- The list will contain slaves parsed by VLC or previously added by
2838- L{slaves_add}(). The typical use case of this function is to save
2839- a list of slave in a database for a later use.
2840- @param ppp_slaves: address to store an allocated array of slaves (must be freed with L{slaves_release}()) [OUT].
2841- @return: the number of slaves (zero on error).
2842- @version: LibVLC 3.0.0 and later. See L{slaves_add}.
2843- '''
2844- return libvlc_media_slaves_get(self, ppp_slaves)
2845-
2846- def parse(self):
2847- '''Parse a media.
2848- This fetches (local) art, meta data and tracks information.
2849- The method is synchronous.
2850- \deprecated This function could block indefinitely.
2851- Use L{parse_with_options}() instead
2852- See L{parse_with_options}
2853- See L{get_meta}
2854- See L{get_tracks_info}.
2855- '''
2856- return libvlc_media_parse(self)
2857-
2858- def parse_async(self):
2859- '''Parse a media.
2860- This fetches (local) art, meta data and tracks information.
2861- The method is the asynchronous of L{parse}().
2862- To track when this is over you can listen to libvlc_MediaParsedChanged
2863- event. However if the media was already parsed you will not receive this
2864- event.
2865- \deprecated You can't be sure to receive the libvlc_MediaParsedChanged
2866- event (you can wait indefinitely for this event).
2867- Use L{parse_with_options}() instead
2868- See L{parse}
2869- See libvlc_MediaParsedChanged
2870- See L{get_meta}
2871- See L{get_tracks_info}.
2872- '''
2873- return libvlc_media_parse_async(self)
2874-
2875- def is_parsed(self):
2876- '''Return true is the media descriptor object is parsed
2877- \deprecated This can return true in case of failure.
2878- Use L{get_parsed_status}() instead
2879- See libvlc_MediaParsedChanged.
2880- @return: true if media object has been parsed otherwise it returns false \libvlc_return_bool.
2881- '''
2882- return libvlc_media_is_parsed(self)
2883-
2884- def get_tracks_info(self):
2885- '''Get media descriptor's elementary streams description
2886- Note, you need to call L{parse}() or play the media at least once
2887- before calling this function.
2888- Not doing this will result in an empty array.
2889- \deprecated Use L{tracks_get}() instead.
2890- @param tracks: address to store an allocated array of Elementary Streams descriptions (must be freed by the caller) [OUT].
2891- @return: the number of Elementary Streams.
2892- '''
2893- return libvlc_media_get_tracks_info(self)
2894-
2895- def player_new_from_media(self):
2896- '''Create a Media Player object from a Media.
2897- @return: a new media player object, or None on error.
2898- '''
2899- return libvlc_media_player_new_from_media(self)
2900-
2901-
2902-class MediaDiscoverer(_Ctype):
2903- '''N/A
2904- '''
2905-
2906- def __new__(cls, ptr=_internal_guard):
2907- '''(INTERNAL) ctypes wrapper constructor.
2908- '''
2909- return _Constructor(cls, ptr)
2910-
2911- def start(self):
2912- '''Start media discovery.
2913- To stop it, call L{stop}() or
2914- L{list_release}() directly.
2915- See L{stop}.
2916- @return: -1 in case of error, 0 otherwise.
2917- @version: LibVLC 3.0.0 or later.
2918- '''
2919- return libvlc_media_discoverer_start(self)
2920-
2921- def stop(self):
2922- '''Stop media discovery.
2923- See L{start}.
2924- @version: LibVLC 3.0.0 or later.
2925- '''
2926- return libvlc_media_discoverer_stop(self)
2927-
2928- def release(self):
2929- '''Release media discover object. If the reference count reaches 0, then
2930- the object will be released.
2931- '''
2932- return libvlc_media_discoverer_release(self)
2933-
2934- def media_list(self):
2935- '''Get media service discover media list.
2936- @return: list of media items.
2937- '''
2938- return libvlc_media_discoverer_media_list(self)
2939-
2940- def is_running(self):
2941- '''Query if media service discover object is running.
2942- @return: true if running, false if not \libvlc_return_bool.
2943- '''
2944- return libvlc_media_discoverer_is_running(self)
2945-
2946- def localized_name(self):
2947- '''Get media service discover object its localized name.
2948- \deprecated Useless, use L{list_get}() to get the
2949- longname of the service discovery.
2950- @return: localized name or None if the media_discoverer is not started.
2951- '''
2952- return libvlc_media_discoverer_localized_name(self)
2953-
2954- @memoize_parameterless
2955- def event_manager(self):
2956- '''Get event manager from media service discover object.
2957- \deprecated Useless, media_discoverer events are only triggered when calling
2958- L{start}() and L{stop}().
2959- @return: event manager object.
2960- '''
2961- return libvlc_media_discoverer_event_manager(self)
2962-
2963-
2964-class MediaLibrary(_Ctype):
2965- '''N/A
2966- '''
2967-
2968- def __new__(cls, ptr=_internal_guard):
2969- '''(INTERNAL) ctypes wrapper constructor.
2970- '''
2971- return _Constructor(cls, ptr)
2972-
2973- def release(self):
2974- '''Release media library object. This functions decrements the
2975- reference count of the media library object. If it reaches 0,
2976- then the object will be released.
2977- '''
2978- return libvlc_media_library_release(self)
2979-
2980- def retain(self):
2981- '''Retain a reference to a media library object. This function will
2982- increment the reference counting for this object. Use
2983- L{release}() to decrement the reference count.
2984- '''
2985- return libvlc_media_library_retain(self)
2986-
2987- def load(self):
2988- '''Load media library.
2989- @return: 0 on success, -1 on error.
2990- '''
2991- return libvlc_media_library_load(self)
2992-
2993- def media_list(self):
2994- '''Get media library subitems.
2995- @return: media list subitems.
2996- '''
2997- return libvlc_media_library_media_list(self)
2998-
2999-
3000-class MediaList(_Ctype):
3001- '''Create a new MediaList instance.
3002-
3003- Usage: MediaList(list_of_MRLs)
3004-
3005- See vlc.Instance.media_list_new documentation for details.
3006-
3007- '''
3008-
3009- def __new__(cls, *args):
3010- if args:
3011- i = args[0]
3012- if isinstance(i, _Ints):
3013- return _Constructor(cls, i)
3014- if isinstance(i, Instance):
3015- return i.media_list_new(*args[1:])
3016-
3017- o = get_default_instance().media_list_new(*args)
3018- return o
3019-
3020- def get_instance(self):
3021- return getattr(self, '_instance', None)
3022-
3023- def add_media(self, mrl):
3024- """Add media instance to media list.
3025-
3026- The L{lock} should be held upon entering this function.
3027- @param mrl: a media instance or a MRL.
3028- @return: 0 on success, -1 if the media list is read-only.
3029- """
3030- if isinstance(mrl, basestring):
3031- mrl = (self.get_instance() or get_default_instance()).media_new(mrl)
3032- return libvlc_media_list_add_media(self, mrl)
3033-
3034- def release(self):
3035- '''Release media list created with L{new}().
3036- '''
3037- return libvlc_media_list_release(self)
3038-
3039- def retain(self):
3040- '''Retain reference to a media list.
3041- '''
3042- return libvlc_media_list_retain(self)
3043-
3044- def set_media(self, p_md):
3045- '''Associate media instance with this media list instance.
3046- If another media instance was present it will be released.
3047- The L{lock} should NOT be held upon entering this function.
3048- @param p_md: media instance to add.
3049- '''
3050- return libvlc_media_list_set_media(self, p_md)
3051-
3052- def media(self):
3053- '''Get media instance from this media list instance. This action will increase
3054- the refcount on the media instance.
3055- The L{lock} should NOT be held upon entering this function.
3056- @return: media instance.
3057- '''
3058- return libvlc_media_list_media(self)
3059-
3060- def insert_media(self, p_md, i_pos):
3061- '''Insert media instance in media list on a position
3062- The L{lock} should be held upon entering this function.
3063- @param p_md: a media instance.
3064- @param i_pos: position in array where to insert.
3065- @return: 0 on success, -1 if the media list is read-only.
3066- '''
3067- return libvlc_media_list_insert_media(self, p_md, i_pos)
3068-
3069- def remove_index(self, i_pos):
3070- '''Remove media instance from media list on a position
3071- The L{lock} should be held upon entering this function.
3072- @param i_pos: position in array where to insert.
3073- @return: 0 on success, -1 if the list is read-only or the item was not found.
3074- '''
3075- return libvlc_media_list_remove_index(self, i_pos)
3076-
3077- def count(self):
3078- '''Get count on media list items
3079- The L{lock} should be held upon entering this function.
3080- @return: number of items in media list.
3081- '''
3082- return libvlc_media_list_count(self)
3083-
3084- def __len__(self):
3085- return libvlc_media_list_count(self)
3086-
3087- def item_at_index(self, i_pos):
3088- '''List media instance in media list at a position
3089- The L{lock} should be held upon entering this function.
3090- @param i_pos: position in array where to insert.
3091- @return: media instance at position i_pos, or None if not found. In case of success, L{media_retain}() is called to increase the refcount on the media.
3092- '''
3093- return libvlc_media_list_item_at_index(self, i_pos)
3094-
3095- def __getitem__(self, i):
3096- return libvlc_media_list_item_at_index(self, i)
3097-
3098- def __iter__(self):
3099- for i in range(len(self)):
3100- yield self[i]
3101-
3102- def index_of_item(self, p_md):
3103- '''Find index position of List media instance in media list.
3104- Warning: the function will return the first matched position.
3105- The L{lock} should be held upon entering this function.
3106- @param p_md: media instance.
3107- @return: position of media instance or -1 if media not found.
3108- '''
3109- return libvlc_media_list_index_of_item(self, p_md)
3110-
3111- def is_readonly(self):
3112- '''This indicates if this media list is read-only from a user point of view.
3113- @return: 1 on readonly, 0 on readwrite \libvlc_return_bool.
3114- '''
3115- return libvlc_media_list_is_readonly(self)
3116-
3117- def lock(self):
3118- '''Get lock on media list items.
3119- '''
3120- return libvlc_media_list_lock(self)
3121-
3122- def unlock(self):
3123- '''Release lock on media list items
3124- The L{lock} should be held upon entering this function.
3125- '''
3126- return libvlc_media_list_unlock(self)
3127-
3128- @memoize_parameterless
3129- def event_manager(self):
3130- '''Get libvlc_event_manager from this media list instance.
3131- The p_event_manager is immutable, so you don't have to hold the lock.
3132- @return: libvlc_event_manager.
3133- '''
3134- return libvlc_media_list_event_manager(self)
3135-
3136-
3137-class MediaListPlayer(_Ctype):
3138- '''Create a new MediaListPlayer instance.
3139-
3140- It may take as parameter either:
3141- - a vlc.Instance
3142- - nothing
3143-
3144- '''
3145-
3146- def __new__(cls, arg=None):
3147- if arg is None:
3148- i = get_default_instance()
3149- elif isinstance(arg, Instance):
3150- i = arg
3151- elif isinstance(arg, _Ints):
3152- return _Constructor(cls, arg)
3153- else:
3154- raise TypeError('MediaListPlayer %r' % (arg,))
3155-
3156- return i.media_list_player_new()
3157-
3158- def get_instance(self):
3159- """Return the associated Instance.
3160- """
3161- return self._instance # PYCHOK expected
3162-
3163- def release(self):
3164- '''Release a media_list_player after use
3165- Decrement the reference count of a media player object. If the
3166- reference count is 0, then L{release}() will
3167- release the media player object. If the media player object
3168- has been released, then it should not be used again.
3169- '''
3170- return libvlc_media_list_player_release(self)
3171-
3172- def retain(self):
3173- '''Retain a reference to a media player list object. Use
3174- L{release}() to decrement reference count.
3175- '''
3176- return libvlc_media_list_player_retain(self)
3177-
3178- @memoize_parameterless
3179- def event_manager(self):
3180- '''Return the event manager of this media_list_player.
3181- @return: the event manager.
3182- '''
3183- return libvlc_media_list_player_event_manager(self)
3184-
3185- def set_media_player(self, p_mi):
3186- '''Replace media player in media_list_player with this instance.
3187- @param p_mi: media player instance.
3188- '''
3189- return libvlc_media_list_player_set_media_player(self, p_mi)
3190-
3191- def get_media_player(self):
3192- '''Get media player of the media_list_player instance.
3193- @return: media player instance @note the caller is responsible for releasing the returned instance.
3194- '''
3195- return libvlc_media_list_player_get_media_player(self)
3196-
3197- def set_media_list(self, p_mlist):
3198- '''Set the media list associated with the player.
3199- @param p_mlist: list of media.
3200- '''
3201- return libvlc_media_list_player_set_media_list(self, p_mlist)
3202-
3203- def play(self):
3204- '''Play media list.
3205- '''
3206- return libvlc_media_list_player_play(self)
3207-
3208- def pause(self):
3209- '''Toggle pause (or resume) media list.
3210- '''
3211- return libvlc_media_list_player_pause(self)
3212-
3213- def set_pause(self, do_pause):
3214- '''Pause or resume media list.
3215- @param do_pause: play/resume if zero, pause if non-zero.
3216- @version: LibVLC 3.0.0 or later.
3217- '''
3218- return libvlc_media_list_player_set_pause(self, do_pause)
3219-
3220- def is_playing(self):
3221- '''Is media list playing?
3222- @return: true for playing and false for not playing \libvlc_return_bool.
3223- '''
3224- return libvlc_media_list_player_is_playing(self)
3225-
3226- def get_state(self):
3227- '''Get current libvlc_state of media list player.
3228- @return: L{State} for media list player.
3229- '''
3230- return libvlc_media_list_player_get_state(self)
3231-
3232- def play_item_at_index(self, i_index):
3233- '''Play media list item at position index.
3234- @param i_index: index in media list to play.
3235- @return: 0 upon success -1 if the item wasn't found.
3236- '''
3237- return libvlc_media_list_player_play_item_at_index(self, i_index)
3238-
3239- def __getitem__(self, i):
3240- return libvlc_media_list_player_play_item_at_index(self, i)
3241-
3242- def __iter__(self):
3243- for i in range(len(self)):
3244- yield self[i]
3245-
3246- def play_item(self, p_md):
3247- '''Play the given media item.
3248- @param p_md: the media instance.
3249- @return: 0 upon success, -1 if the media is not part of the media list.
3250- '''
3251- return libvlc_media_list_player_play_item(self, p_md)
3252-
3253- def stop(self):
3254- '''Stop playing media list.
3255- '''
3256- return libvlc_media_list_player_stop(self)
3257-
3258- def next(self):
3259- '''Play next item from media list.
3260- @return: 0 upon success -1 if there is no next item.
3261- '''
3262- return libvlc_media_list_player_next(self)
3263-
3264- def previous(self):
3265- '''Play previous item from media list.
3266- @return: 0 upon success -1 if there is no previous item.
3267- '''
3268- return libvlc_media_list_player_previous(self)
3269-
3270- def set_playback_mode(self, e_mode):
3271- '''Sets the playback mode for the playlist.
3272- @param e_mode: playback mode specification.
3273- '''
3274- return libvlc_media_list_player_set_playback_mode(self, e_mode)
3275-
3276-
3277-class MediaPlayer(_Ctype):
3278- '''Create a new MediaPlayer instance.
3279-
3280- It may take as parameter either:
3281- - a string (media URI), options... In this case, a vlc.Instance will be created.
3282- - a vlc.Instance, a string (media URI), options...
3283-
3284- '''
3285-
3286- def __new__(cls, *args):
3287- if len(args) == 1 and isinstance(args[0], _Ints):
3288- return _Constructor(cls, args[0])
3289-
3290- if args and isinstance(args[0], Instance):
3291- instance = args[0]
3292- args = args[1:]
3293- else:
3294- instance = get_default_instance()
3295-
3296- o = instance.media_player_new()
3297- if args:
3298- o.set_media(instance.media_new(*args))
3299- return o
3300-
3301- def get_instance(self):
3302- """Return the associated Instance.
3303- """
3304- return self._instance # PYCHOK expected
3305-
3306- def set_mrl(self, mrl, *options):
3307- """Set the MRL to play.
3308-
3309- Warning: most audio and video options, such as text renderer,
3310- have no effects on an individual media. These options must be
3311- set at the vlc.Instance or vlc.MediaPlayer instanciation.
3312-
3313- @param mrl: The MRL
3314- @param options: optional media option=value strings
3315- @return: the Media object
3316- """
3317- m = self.get_instance().media_new(mrl, *options)
3318- self.set_media(m)
3319- return m
3320-
3321- def video_get_spu_description(self):
3322- """Get the description of available video subtitles.
3323- """
3324- return track_description_list(libvlc_video_get_spu_description(self))
3325-
3326- def video_get_title_description(self):
3327- """Get the description of available titles.
3328- """
3329- return track_description_list(libvlc_video_get_title_description(self))
3330-
3331- def video_get_chapter_description(self, title):
3332- """Get the description of available chapters for specific title.
3333-
3334- @param title: selected title (int)
3335- """
3336- return track_description_list(libvlc_video_get_chapter_description(self, title))
3337-
3338- def video_get_track_description(self):
3339- """Get the description of available video tracks.
3340- """
3341- return track_description_list(libvlc_video_get_track_description(self))
3342-
3343- def audio_get_track_description(self):
3344- """Get the description of available audio tracks.
3345- """
3346- return track_description_list(libvlc_audio_get_track_description(self))
3347-
3348- def get_full_title_descriptions(self):
3349- '''Get the full description of available titles.
3350- @return: the titles list
3351- @version: LibVLC 3.0.0 and later.
3352- '''
3353- titleDescription_pp = ctypes.POINTER(TitleDescription)()
3354- n = libvlc_media_player_get_full_title_descriptions(self, ctypes.byref(titleDescription_pp))
3355- info = ctypes.cast(titleDescription_pp, ctypes.POINTER(ctypes.POINTER(TitleDescription) * n))
3356- try:
3357- contents = info.contents
3358- except ValueError:
3359- # Media not parsed, no info.
3360- return None
3361- descr = (contents[i].contents for i in range(len(contents)))
3362- return descr
3363-
3364- def get_full_chapter_descriptions(self, i_chapters_of_title):
3365- '''Get the full description of available chapters.
3366- @param i_chapters_of_title: index of the title to query for chapters (uses current title if set to -1).
3367- @return: the chapters list
3368- @version: LibVLC 3.0.0 and later.
3369- '''
3370- chapterDescription_pp = ctypes.POINTER(ChapterDescription)()
3371- n = libvlc_media_player_get_full_chapter_descriptions(self, ctypes.byref(chapterDescription_pp))
3372- info = ctypes.cast(chapterDescription_pp, ctypes.POINTER(ctypes.POINTER(ChapterDescription) * n))
3373- try:
3374- contents = info.contents
3375- except ValueError:
3376- # Media not parsed, no info.
3377- return None
3378- descr = (contents[i].contents for i in range(len(contents)))
3379- return descr
3380-
3381- def video_get_size(self, num=0):
3382- """Get the video size in pixels as 2-tuple (width, height).
3383-
3384- @param num: video number (default 0).
3385- """
3386- r = libvlc_video_get_size(self, num)
3387- if isinstance(r, tuple) and len(r) == 2:
3388- return r
3389- else:
3390- raise VLCException('invalid video number (%s)' % (num,))
3391-
3392- def set_hwnd(self, drawable):
3393- """Set a Win32/Win64 API window handle (HWND).
3394-
3395- Specify where the media player should render its video
3396- output. If LibVLC was built without Win32/Win64 API output
3397- support, then this has no effects.
3398-
3399- @param drawable: windows handle of the drawable.
3400- """
3401- if not isinstance(drawable, ctypes.c_void_p):
3402- drawable = ctypes.c_void_p(int(drawable))
3403- libvlc_media_player_set_hwnd(self, drawable)
3404-
3405- def video_get_width(self, num=0):
3406- """Get the width of a video in pixels.
3407-
3408- @param num: video number (default 0).
3409- """
3410- return self.video_get_size(num)[0]
3411-
3412- def video_get_height(self, num=0):
3413- """Get the height of a video in pixels.
3414-
3415- @param num: video number (default 0).
3416- """
3417- return self.video_get_size(num)[1]
3418-
3419- def video_get_cursor(self, num=0):
3420- """Get the mouse pointer coordinates over a video as 2-tuple (x, y).
3421-
3422- Coordinates are expressed in terms of the decoded video resolution,
3423- B{not} in terms of pixels on the screen/viewport. To get the
3424- latter, you must query your windowing system directly.
3425-
3426- Either coordinate may be negative or larger than the corresponding
3427- size of the video, if the cursor is outside the rendering area.
3428-
3429- @warning: The coordinates may be out-of-date if the pointer is not
3430- located on the video rendering area. LibVLC does not track the
3431- mouse pointer if the latter is outside the video widget.
3432-
3433- @note: LibVLC does not support multiple mouse pointers (but does
3434- support multiple input devices sharing the same pointer).
3435-
3436- @param num: video number (default 0).
3437- """
3438- r = libvlc_video_get_cursor(self, num)
3439- if isinstance(r, tuple) and len(r) == 2:
3440- return r
3441- raise VLCException('invalid video number (%s)' % (num,))
3442-
3443- def get_fps(self):
3444- '''Get movie fps rate
3445- This function is provided for backward compatibility. It cannot deal with
3446- multiple video tracks. In LibVLC versions prior to 3.0, it would also fail
3447- if the file format did not convey the frame rate explicitly.
3448- \deprecated Consider using L{media_tracks_get}() instead.
3449- @return: frames per second (fps) for this playing movie, or 0 if unspecified.
3450- '''
3451- return libvlc_media_player_get_fps(self)
3452-
3453- def set_agl(self, drawable):
3454- '''\deprecated Use L{set_nsobject}() instead.
3455- '''
3456- return libvlc_media_player_set_agl(self, drawable)
3457-
3458- def get_agl(self):
3459- '''\deprecated Use L{get_nsobject}() instead.
3460- '''
3461- return libvlc_media_player_get_agl(self)
3462-
3463- def video_set_subtitle_file(self, psz_subtitle):
3464- '''Set new video subtitle file.
3465- \deprecated Use L{add_slave}() instead.
3466- @param psz_subtitle: new video subtitle file.
3467- @return: the success status (boolean).
3468- '''
3469- return libvlc_video_set_subtitle_file(self, str_to_bytes(psz_subtitle))
3470-
3471- def toggle_teletext(self):
3472- '''Toggle teletext transparent status on video output.
3473- \deprecated use L{video_set_teletext}() instead.
3474- '''
3475- return libvlc_toggle_teletext(self)
3476-
3477- def release(self):
3478- '''Release a media_player after use
3479- Decrement the reference count of a media player object. If the
3480- reference count is 0, then L{release}() will
3481- release the media player object. If the media player object
3482- has been released, then it should not be used again.
3483- '''
3484- return libvlc_media_player_release(self)
3485-
3486- def retain(self):
3487- '''Retain a reference to a media player object. Use
3488- L{release}() to decrement reference count.
3489- '''
3490- return libvlc_media_player_retain(self)
3491-
3492- def set_media(self, p_md):
3493- '''Set the media that will be used by the media_player. If any,
3494- previous md will be released.
3495- @param p_md: the Media. Afterwards the p_md can be safely destroyed.
3496- '''
3497- return libvlc_media_player_set_media(self, p_md)
3498-
3499- def get_media(self):
3500- '''Get the media used by the media_player.
3501- @return: the media associated with p_mi, or None if no media is associated.
3502- '''
3503- return libvlc_media_player_get_media(self)
3504-
3505- @memoize_parameterless
3506- def event_manager(self):
3507- '''Get the Event Manager from which the media player send event.
3508- @return: the event manager associated with p_mi.
3509- '''
3510- return libvlc_media_player_event_manager(self)
3511-
3512- def is_playing(self):
3513- '''is_playing.
3514- @return: 1 if the media player is playing, 0 otherwise \libvlc_return_bool.
3515- '''
3516- return libvlc_media_player_is_playing(self)
3517-
3518- def play(self):
3519- '''Play.
3520- @return: 0 if playback started (and was already started), or -1 on error.
3521- '''
3522- return libvlc_media_player_play(self)
3523-
3524- def set_pause(self, do_pause):
3525- '''Pause or resume (no effect if there is no media).
3526- @param do_pause: play/resume if zero, pause if non-zero.
3527- @version: LibVLC 1.1.1 or later.
3528- '''
3529- return libvlc_media_player_set_pause(self, do_pause)
3530-
3531- def pause(self):
3532- '''Toggle pause (no effect if there is no media).
3533- '''
3534- return libvlc_media_player_pause(self)
3535-
3536- def stop(self):
3537- '''Stop (no effect if there is no media).
3538- '''
3539- return libvlc_media_player_stop(self)
3540-
3541- def set_renderer(self, p_item):
3542- '''Set a renderer to the media player
3543- @note: must be called before the first call of L{play}() to
3544- take effect.
3545- See L{renderer_discoverer_new}.
3546- @param p_item: an item discovered by L{renderer_discoverer_start}().
3547- @return: 0 on success, -1 on error.
3548- @version: LibVLC 3.0.0 or later.
3549- '''
3550- return libvlc_media_player_set_renderer(self, p_item)
3551-
3552- def video_set_callbacks(self, lock, unlock, display, opaque):
3553- '''Set callbacks and private data to render decoded video to a custom area
3554- in memory.
3555- Use L{video_set_format}() or L{video_set_format_callbacks}()
3556- to configure the decoded format.
3557- @warning: Rendering video into custom memory buffers is considerably less
3558- efficient than rendering in a custom window as normal.
3559- For optimal perfomances, VLC media player renders into a custom window, and
3560- does not use this function and associated callbacks. It is B{highly
3561- recommended} that other LibVLC-based application do likewise.
3562- To embed video in a window, use libvlc_media_player_set_xid() or equivalent
3563- depending on the operating system.
3564- If window embedding does not fit the application use case, then a custom
3565- LibVLC video output display plugin is required to maintain optimal video
3566- rendering performances.
3567- The following limitations affect performance:
3568- - Hardware video decoding acceleration will either be disabled completely,
3569- or require (relatively slow) copy from video/DSP memory to main memory.
3570- - Sub-pictures (subtitles, on-screen display, etc.) must be blent into the
3571- main picture by the CPU instead of the GPU.
3572- - Depending on the video format, pixel format conversion, picture scaling,
3573- cropping and/or picture re-orientation, must be performed by the CPU
3574- instead of the GPU.
3575- - Memory copying is required between LibVLC reference picture buffers and
3576- application buffers (between lock and unlock callbacks).
3577- @param lock: callback to lock video memory (must not be None).
3578- @param unlock: callback to unlock video memory (or None if not needed).
3579- @param display: callback to display video (or None if not needed).
3580- @param opaque: private pointer for the three callbacks (as first parameter).
3581- @version: LibVLC 1.1.1 or later.
3582- '''
3583- return libvlc_video_set_callbacks(self, lock, unlock, display, opaque)
3584-
3585- def video_set_format(self, chroma, width, height, pitch):
3586- '''Set decoded video chroma and dimensions.
3587- This only works in combination with L{video_set_callbacks}(),
3588- and is mutually exclusive with L{video_set_format_callbacks}().
3589- @param chroma: a four-characters string identifying the chroma (e.g. "RV32" or "YUYV").
3590- @param width: pixel width.
3591- @param height: pixel height.
3592- @param pitch: line pitch (in bytes).
3593- @version: LibVLC 1.1.1 or later.
3594- @bug: All pixel planes are expected to have the same pitch. To use the YCbCr color space with chrominance subsampling, consider using L{video_set_format_callbacks}() instead.
3595- '''
3596- return libvlc_video_set_format(self, str_to_bytes(chroma), width, height, pitch)
3597-
3598- def video_set_format_callbacks(self, setup, cleanup):
3599- '''Set decoded video chroma and dimensions. This only works in combination with
3600- L{video_set_callbacks}().
3601- @param setup: callback to select the video format (cannot be None).
3602- @param cleanup: callback to release any allocated resources (or None).
3603- @version: LibVLC 2.0.0 or later.
3604- '''
3605- return libvlc_video_set_format_callbacks(self, setup, cleanup)
3606-
3607- def set_nsobject(self, drawable):
3608- '''Set the NSView handler where the media player should render its video output.
3609- Use the vout called "macosx".
3610- The drawable is an NSObject that follow the VLCOpenGLVideoViewEmbedding
3611- protocol:
3612- @code.m
3613- \@protocol VLCOpenGLVideoViewEmbedding <NSObject>
3614- - (void)addVoutSubview:(NSView *)view;
3615- - (void)removeVoutSubview:(NSView *)view;
3616- \@end
3617- @endcode
3618- Or it can be an NSView object.
3619- If you want to use it along with Qt see the QMacCocoaViewContainer. Then
3620- the following code should work:
3621- @code.mm
3622-
3623- NSView *video = [[NSView alloc] init];
3624- QMacCocoaViewContainer *container = new QMacCocoaViewContainer(video, parent);
3625- L{set_nsobject}(mp, video);
3626- [video release];
3627-
3628- @endcode
3629- You can find a live example in VLCVideoView in VLCKit.framework.
3630- @param drawable: the drawable that is either an NSView or an object following the VLCOpenGLVideoViewEmbedding protocol.
3631- '''
3632- return libvlc_media_player_set_nsobject(self, drawable)
3633-
3634- def get_nsobject(self):
3635- '''Get the NSView handler previously set with L{set_nsobject}().
3636- @return: the NSView handler or 0 if none where set.
3637- '''
3638- return libvlc_media_player_get_nsobject(self)
3639-
3640- def set_xwindow(self, drawable):
3641- '''Set an X Window System drawable where the media player should render its
3642- video output. The call takes effect when the playback starts. If it is
3643- already started, it might need to be stopped before changes apply.
3644- If LibVLC was built without X11 output support, then this function has no
3645- effects.
3646- By default, LibVLC will capture input events on the video rendering area.
3647- Use L{video_set_mouse_input}() and L{video_set_key_input}() to
3648- disable that and deliver events to the parent window / to the application
3649- instead. By design, the X11 protocol delivers input events to only one
3650- recipient.
3651- @warning
3652- The application must call the XInitThreads() function from Xlib before
3653- L{new}(), and before any call to XOpenDisplay() directly or via any
3654- other library. Failure to call XInitThreads() will seriously impede LibVLC
3655- performance. Calling XOpenDisplay() before XInitThreads() will eventually
3656- crash the process. That is a limitation of Xlib.
3657- @param drawable: X11 window ID @note The specified identifier must correspond to an existing Input/Output class X11 window. Pixmaps are B{not} currently supported. The default X11 server is assumed, i.e. that specified in the DISPLAY environment variable. @warning LibVLC can deal with invalid X11 handle errors, however some display drivers (EGL, GLX, VA and/or VDPAU) can unfortunately not. Thus the window handle must remain valid until playback is stopped, otherwise the process may abort or crash.
3658- @bug No more than one window handle per media player instance can be specified. If the media has multiple simultaneously active video tracks, extra tracks will be rendered into external windows beyond the control of the application.
3659- '''
3660- return libvlc_media_player_set_xwindow(self, drawable)
3661-
3662- def get_xwindow(self):
3663- '''Get the X Window System window identifier previously set with
3664- L{set_xwindow}(). Note that this will return the identifier
3665- even if VLC is not currently using it (for instance if it is playing an
3666- audio-only input).
3667- @return: an X window ID, or 0 if none where set.
3668- '''
3669- return libvlc_media_player_get_xwindow(self)
3670-
3671- def get_hwnd(self):
3672- '''Get the Windows API window handle (HWND) previously set with
3673- L{set_hwnd}(). The handle will be returned even if LibVLC
3674- is not currently outputting any video to it.
3675- @return: a window handle or None if there are none.
3676- '''
3677- return libvlc_media_player_get_hwnd(self)
3678-
3679- def set_android_context(self, p_awindow_handler):
3680- '''Set the android context.
3681- @param p_awindow_handler: org.videolan.libvlc.AWindow jobject owned by the org.videolan.libvlc.MediaPlayer class from the libvlc-android project.
3682- @version: LibVLC 3.0.0 and later.
3683- '''
3684- return libvlc_media_player_set_android_context(self, p_awindow_handler)
3685-
3686- def set_evas_object(self, p_evas_object):
3687- '''Set the EFL Evas Object.
3688- @param p_evas_object: a valid EFL Evas Object (Evas_Object).
3689- @return: -1 if an error was detected, 0 otherwise.
3690- @version: LibVLC 3.0.0 and later.
3691- '''
3692- return libvlc_media_player_set_evas_object(self, p_evas_object)
3693-
3694- def audio_set_callbacks(self, play, pause, resume, flush, drain, opaque):
3695- '''Sets callbacks and private data for decoded audio.
3696- Use L{audio_set_format}() or L{audio_set_format_callbacks}()
3697- to configure the decoded audio format.
3698- @note: The audio callbacks override any other audio output mechanism.
3699- If the callbacks are set, LibVLC will B{not} output audio in any way.
3700- @param play: callback to play audio samples (must not be None).
3701- @param pause: callback to pause playback (or None to ignore).
3702- @param resume: callback to resume playback (or None to ignore).
3703- @param flush: callback to flush audio buffers (or None to ignore).
3704- @param drain: callback to drain audio buffers (or None to ignore).
3705- @param opaque: private pointer for the audio callbacks (as first parameter).
3706- @version: LibVLC 2.0.0 or later.
3707- '''
3708- return libvlc_audio_set_callbacks(self, play, pause, resume, flush, drain, opaque)
3709-
3710- def audio_set_volume_callback(self, set_volume):
3711- '''Set callbacks and private data for decoded audio. This only works in
3712- combination with L{audio_set_callbacks}().
3713- Use L{audio_set_format}() or L{audio_set_format_callbacks}()
3714- to configure the decoded audio format.
3715- @param set_volume: callback to apply audio volume, or None to apply volume in software.
3716- @version: LibVLC 2.0.0 or later.
3717- '''
3718- return libvlc_audio_set_volume_callback(self, set_volume)
3719-
3720- def audio_set_format_callbacks(self, setup, cleanup):
3721- '''Sets decoded audio format via callbacks.
3722- This only works in combination with L{audio_set_callbacks}().
3723- @param setup: callback to select the audio format (cannot be None).
3724- @param cleanup: callback to release any allocated resources (or None).
3725- @version: LibVLC 2.0.0 or later.
3726- '''
3727- return libvlc_audio_set_format_callbacks(self, setup, cleanup)
3728-
3729- def audio_set_format(self, format, rate, channels):
3730- '''Sets a fixed decoded audio format.
3731- This only works in combination with L{audio_set_callbacks}(),
3732- and is mutually exclusive with L{audio_set_format_callbacks}().
3733- @param format: a four-characters string identifying the sample format (e.g. "S16N" or "FL32").
3734- @param rate: sample rate (expressed in Hz).
3735- @param channels: channels count.
3736- @version: LibVLC 2.0.0 or later.
3737- '''
3738- return libvlc_audio_set_format(self, str_to_bytes(format), rate, channels)
3739-
3740- def get_length(self):
3741- '''Get the current movie length (in ms).
3742- @return: the movie length (in ms), or -1 if there is no media.
3743- '''
3744- return libvlc_media_player_get_length(self)
3745-
3746- def get_time(self):
3747- '''Get the current movie time (in ms).
3748- @return: the movie time (in ms), or -1 if there is no media.
3749- '''
3750- return libvlc_media_player_get_time(self)
3751-
3752- def set_time(self, i_time):
3753- '''Set the movie time (in ms). This has no effect if no media is being played.
3754- Not all formats and protocols support this.
3755- @param i_time: the movie time (in ms).
3756- '''
3757- return libvlc_media_player_set_time(self, i_time)
3758-
3759- def get_position(self):
3760- '''Get movie position as percentage between 0.0 and 1.0.
3761- @return: movie position, or -1. in case of error.
3762- '''
3763- return libvlc_media_player_get_position(self)
3764-
3765- def set_position(self, f_pos):
3766- '''Set movie position as percentage between 0.0 and 1.0.
3767- This has no effect if playback is not enabled.
3768- This might not work depending on the underlying input format and protocol.
3769- @param f_pos: the position.
3770- '''
3771- return libvlc_media_player_set_position(self, f_pos)
3772-
3773- def set_chapter(self, i_chapter):
3774- '''Set movie chapter (if applicable).
3775- @param i_chapter: chapter number to play.
3776- '''
3777- return libvlc_media_player_set_chapter(self, i_chapter)
3778-
3779- def get_chapter(self):
3780- '''Get movie chapter.
3781- @return: chapter number currently playing, or -1 if there is no media.
3782- '''
3783- return libvlc_media_player_get_chapter(self)
3784-
3785- def get_chapter_count(self):
3786- '''Get movie chapter count.
3787- @return: number of chapters in movie, or -1.
3788- '''
3789- return libvlc_media_player_get_chapter_count(self)
3790-
3791- def will_play(self):
3792- '''Is the player able to play.
3793- @return: boolean \libvlc_return_bool.
3794- '''
3795- return libvlc_media_player_will_play(self)
3796-
3797- def get_chapter_count_for_title(self, i_title):
3798- '''Get title chapter count.
3799- @param i_title: title.
3800- @return: number of chapters in title, or -1.
3801- '''
3802- return libvlc_media_player_get_chapter_count_for_title(self, i_title)
3803-
3804- def set_title(self, i_title):
3805- '''Set movie title.
3806- @param i_title: title number to play.
3807- '''
3808- return libvlc_media_player_set_title(self, i_title)
3809-
3810- def get_title(self):
3811- '''Get movie title.
3812- @return: title number currently playing, or -1.
3813- '''
3814- return libvlc_media_player_get_title(self)
3815-
3816- def get_title_count(self):
3817- '''Get movie title count.
3818- @return: title number count, or -1.
3819- '''
3820- return libvlc_media_player_get_title_count(self)
3821-
3822- def previous_chapter(self):
3823- '''Set previous chapter (if applicable).
3824- '''
3825- return libvlc_media_player_previous_chapter(self)
3826-
3827- def next_chapter(self):
3828- '''Set next chapter (if applicable).
3829- '''
3830- return libvlc_media_player_next_chapter(self)
3831-
3832- def get_rate(self):
3833- '''Get the requested movie play rate.
3834- @warning: Depending on the underlying media, the requested rate may be
3835- different from the real playback rate.
3836- @return: movie play rate.
3837- '''
3838- return libvlc_media_player_get_rate(self)
3839-
3840- def set_rate(self, rate):
3841- '''Set movie play rate.
3842- @param rate: movie play rate to set.
3843- @return: -1 if an error was detected, 0 otherwise (but even then, it might not actually work depending on the underlying media protocol).
3844- '''
3845- return libvlc_media_player_set_rate(self, rate)
3846-
3847- def get_state(self):
3848- '''Get current movie state.
3849- @return: the current state of the media player (playing, paused, ...) See L{State}.
3850- '''
3851- return libvlc_media_player_get_state(self)
3852-
3853- def has_vout(self):
3854- '''How many video outputs does this media player have?
3855- @return: the number of video outputs.
3856- '''
3857- return libvlc_media_player_has_vout(self)
3858-
3859- def is_seekable(self):
3860- '''Is this media player seekable?
3861- @return: true if the media player can seek \libvlc_return_bool.
3862- '''
3863- return libvlc_media_player_is_seekable(self)
3864-
3865- def can_pause(self):
3866- '''Can this media player be paused?
3867- @return: true if the media player can pause \libvlc_return_bool.
3868- '''
3869- return libvlc_media_player_can_pause(self)
3870-
3871- def program_scrambled(self):
3872- '''Check if the current program is scrambled.
3873- @return: true if the current program is scrambled \libvlc_return_bool.
3874- @version: LibVLC 2.2.0 or later.
3875- '''
3876- return libvlc_media_player_program_scrambled(self)
3877-
3878- def next_frame(self):
3879- '''Display the next frame (if supported).
3880- '''
3881- return libvlc_media_player_next_frame(self)
3882-
3883- def navigate(self, navigate):
3884- '''Navigate through DVD Menu.
3885- @param navigate: the Navigation mode.
3886- @version: libVLC 2.0.0 or later.
3887- '''
3888- return libvlc_media_player_navigate(self, navigate)
3889-
3890- def set_video_title_display(self, position, timeout):
3891- '''Set if, and how, the video title will be shown when media is played.
3892- @param position: position at which to display the title, or libvlc_position_disable to prevent the title from being displayed.
3893- @param timeout: title display timeout in milliseconds (ignored if libvlc_position_disable).
3894- @version: libVLC 2.1.0 or later.
3895- '''
3896- return libvlc_media_player_set_video_title_display(self, position, timeout)
3897-
3898- def add_slave(self, i_type, psz_uri, b_select):
3899- '''Add a slave to the current media player.
3900- @note: If the player is playing, the slave will be added directly. This call
3901- will also update the slave list of the attached L{Media}.
3902- @param i_type: subtitle or audio.
3903- @param psz_uri: Uri of the slave (should contain a valid scheme).
3904- @param b_select: True if this slave should be selected when it's loaded.
3905- @return: 0 on success, -1 on error.
3906- @version: LibVLC 3.0.0 and later. See L{media_slaves_add}.
3907- '''
3908- return libvlc_media_player_add_slave(self, i_type, str_to_bytes(psz_uri), b_select)
3909-
3910- def toggle_fullscreen(self):
3911- '''Toggle fullscreen status on non-embedded video outputs.
3912- @warning: The same limitations applies to this function
3913- as to L{set_fullscreen}().
3914- '''
3915- return libvlc_toggle_fullscreen(self)
3916-
3917- def set_fullscreen(self, b_fullscreen):
3918- '''Enable or disable fullscreen.
3919- @warning: With most window managers, only a top-level windows can be in
3920- full-screen mode. Hence, this function will not operate properly if
3921- L{set_xwindow}() was used to embed the video in a
3922- non-top-level window. In that case, the embedding window must be reparented
3923- to the root window B{before} fullscreen mode is enabled. You will want
3924- to reparent it back to its normal parent when disabling fullscreen.
3925- @param b_fullscreen: boolean for fullscreen status.
3926- '''
3927- return libvlc_set_fullscreen(self, b_fullscreen)
3928-
3929- def get_fullscreen(self):
3930- '''Get current fullscreen status.
3931- @return: the fullscreen status (boolean) \libvlc_return_bool.
3932- '''
3933- return libvlc_get_fullscreen(self)
3934-
3935- def video_set_key_input(self, on):
3936- '''Enable or disable key press events handling, according to the LibVLC hotkeys
3937- configuration. By default and for historical reasons, keyboard events are
3938- handled by the LibVLC video widget.
3939- @note: On X11, there can be only one subscriber for key press and mouse
3940- click events per window. If your application has subscribed to those events
3941- for the X window ID of the video widget, then LibVLC will not be able to
3942- handle key presses and mouse clicks in any case.
3943- @warning: This function is only implemented for X11 and Win32 at the moment.
3944- @param on: true to handle key press events, false to ignore them.
3945- '''
3946- return libvlc_video_set_key_input(self, on)
3947-
3948- def video_set_mouse_input(self, on):
3949- '''Enable or disable mouse click events handling. By default, those events are
3950- handled. This is needed for DVD menus to work, as well as a few video
3951- filters such as "puzzle".
3952- See L{video_set_key_input}().
3953- @warning: This function is only implemented for X11 and Win32 at the moment.
3954- @param on: true to handle mouse click events, false to ignore them.
3955- '''
3956- return libvlc_video_set_mouse_input(self, on)
3957-
3958- def video_get_scale(self):
3959- '''Get the current video scaling factor.
3960- See also L{video_set_scale}().
3961- @return: the currently configured zoom factor, or 0. if the video is set to fit to the output window/drawable automatically.
3962- '''
3963- return libvlc_video_get_scale(self)
3964-
3965- def video_set_scale(self, f_factor):
3966- '''Set the video scaling factor. That is the ratio of the number of pixels on
3967- screen to the number of pixels in the original decoded video in each
3968- dimension. Zero is a special value; it will adjust the video to the output
3969- window/drawable (in windowed mode) or the entire screen.
3970- Note that not all video outputs support scaling.
3971- @param f_factor: the scaling factor, or zero.
3972- '''
3973- return libvlc_video_set_scale(self, f_factor)
3974-
3975- def video_get_aspect_ratio(self):
3976- '''Get current video aspect ratio.
3977- @return: the video aspect ratio or None if unspecified (the result must be released with free() or L{free}()).
3978- '''
3979- return libvlc_video_get_aspect_ratio(self)
3980-
3981- def video_set_aspect_ratio(self, psz_aspect):
3982- '''Set new video aspect ratio.
3983- @param psz_aspect: new video aspect-ratio or None to reset to default @note Invalid aspect ratios are ignored.
3984- '''
3985- return libvlc_video_set_aspect_ratio(self, str_to_bytes(psz_aspect))
3986-
3987- def video_update_viewpoint(self, p_viewpoint, b_absolute):
3988- '''Update the video viewpoint information.
3989- @note: It is safe to call this function before the media player is started.
3990- @param p_viewpoint: video viewpoint allocated via L{video_new_viewpoint}().
3991- @param b_absolute: if true replace the old viewpoint with the new one. If false, increase/decrease it.
3992- @return: -1 in case of error, 0 otherwise @note the values are set asynchronously, it will be used by the next frame displayed.
3993- @version: LibVLC 3.0.0 and later.
3994- '''
3995- return libvlc_video_update_viewpoint(self, p_viewpoint, b_absolute)
3996-
3997- def video_get_spu(self):
3998- '''Get current video subtitle.
3999- @return: the video subtitle selected, or -1 if none.
4000- '''
4001- return libvlc_video_get_spu(self)
4002-
4003- def video_get_spu_count(self):
4004- '''Get the number of available video subtitles.
4005- @return: the number of available video subtitles.
4006- '''
4007- return libvlc_video_get_spu_count(self)
4008-
4009- def video_set_spu(self, i_spu):
4010- '''Set new video subtitle.
4011- @param i_spu: video subtitle track to select (i_id from track description).
4012- @return: 0 on success, -1 if out of range.
4013- '''
4014- return libvlc_video_set_spu(self, i_spu)
4015-
4016- def video_get_spu_delay(self):
4017- '''Get the current subtitle delay. Positive values means subtitles are being
4018- displayed later, negative values earlier.
4019- @return: time (in microseconds) the display of subtitles is being delayed.
4020- @version: LibVLC 2.0.0 or later.
4021- '''
4022- return libvlc_video_get_spu_delay(self)
4023-
4024- def video_set_spu_delay(self, i_delay):
4025- '''Set the subtitle delay. This affects the timing of when the subtitle will
4026- be displayed. Positive values result in subtitles being displayed later,
4027- while negative values will result in subtitles being displayed earlier.
4028- The subtitle delay will be reset to zero each time the media changes.
4029- @param i_delay: time (in microseconds) the display of subtitles should be delayed.
4030- @return: 0 on success, -1 on error.
4031- @version: LibVLC 2.0.0 or later.
4032- '''
4033- return libvlc_video_set_spu_delay(self, i_delay)
4034-
4035- def video_get_crop_geometry(self):
4036- '''Get current crop filter geometry.
4037- @return: the crop filter geometry or None if unset.
4038- '''
4039- return libvlc_video_get_crop_geometry(self)
4040-
4041- def video_set_crop_geometry(self, psz_geometry):
4042- '''Set new crop filter geometry.
4043- @param psz_geometry: new crop filter geometry (None to unset).
4044- '''
4045- return libvlc_video_set_crop_geometry(self, str_to_bytes(psz_geometry))
4046-
4047- def video_get_teletext(self):
4048- '''Get current teletext page requested or 0 if it's disabled.
4049- Teletext is disabled by default, call L{video_set_teletext}() to enable
4050- it.
4051- @return: the current teletext page requested.
4052- '''
4053- return libvlc_video_get_teletext(self)
4054-
4055- def video_set_teletext(self, i_page):
4056- '''Set new teletext page to retrieve.
4057- This function can also be used to send a teletext key.
4058- @param i_page: teletex page number requested. This value can be 0 to disable teletext, a number in the range ]0;1000[ to show the requested page, or a \ref L{TeletextKey}. 100 is the default teletext page.
4059- '''
4060- return libvlc_video_set_teletext(self, i_page)
4061-
4062- def video_get_track_count(self):
4063- '''Get number of available video tracks.
4064- @return: the number of available video tracks (int).
4065- '''
4066- return libvlc_video_get_track_count(self)
4067-
4068- def video_get_track(self):
4069- '''Get current video track.
4070- @return: the video track ID (int) or -1 if no active input.
4071- '''
4072- return libvlc_video_get_track(self)
4073-
4074- def video_set_track(self, i_track):
4075- '''Set video track.
4076- @param i_track: the track ID (i_id field from track description).
4077- @return: 0 on success, -1 if out of range.
4078- '''
4079- return libvlc_video_set_track(self, i_track)
4080-
4081- def video_take_snapshot(self, num, psz_filepath, i_width, i_height):
4082- '''Take a snapshot of the current video window.
4083- If i_width AND i_height is 0, original size is used.
4084- If i_width XOR i_height is 0, original aspect-ratio is preserved.
4085- @param num: number of video output (typically 0 for the first/only one).
4086- @param psz_filepath: the path of a file or a folder to save the screenshot into.
4087- @param i_width: the snapshot's width.
4088- @param i_height: the snapshot's height.
4089- @return: 0 on success, -1 if the video was not found.
4090- '''
4091- return libvlc_video_take_snapshot(self, num, str_to_bytes(psz_filepath), i_width, i_height)
4092-
4093- def video_set_deinterlace(self, psz_mode):
4094- '''Enable or disable deinterlace filter.
4095- @param psz_mode: type of deinterlace filter, None to disable.
4096- '''
4097- return libvlc_video_set_deinterlace(self, str_to_bytes(psz_mode))
4098-
4099- def video_get_marquee_int(self, option):
4100- '''Get an integer marquee option value.
4101- @param option: marq option to get See libvlc_video_marquee_int_option_t.
4102- '''
4103- return libvlc_video_get_marquee_int(self, option)
4104-
4105- def video_get_marquee_string(self, option):
4106- '''Get a string marquee option value.
4107- @param option: marq option to get See libvlc_video_marquee_string_option_t.
4108- '''
4109- return libvlc_video_get_marquee_string(self, option)
4110-
4111- def video_set_marquee_int(self, option, i_val):
4112- '''Enable, disable or set an integer marquee option
4113- Setting libvlc_marquee_Enable has the side effect of enabling (arg !0)
4114- or disabling (arg 0) the marq filter.
4115- @param option: marq option to set See libvlc_video_marquee_int_option_t.
4116- @param i_val: marq option value.
4117- '''
4118- return libvlc_video_set_marquee_int(self, option, i_val)
4119-
4120- def video_set_marquee_string(self, option, psz_text):
4121- '''Set a marquee string option.
4122- @param option: marq option to set See libvlc_video_marquee_string_option_t.
4123- @param psz_text: marq option value.
4124- '''
4125- return libvlc_video_set_marquee_string(self, option, str_to_bytes(psz_text))
4126-
4127- def video_get_logo_int(self, option):
4128- '''Get integer logo option.
4129- @param option: logo option to get, values of L{VideoLogoOption}.
4130- '''
4131- return libvlc_video_get_logo_int(self, option)
4132-
4133- def video_set_logo_int(self, option, value):
4134- '''Set logo option as integer. Options that take a different type value
4135- are ignored.
4136- Passing libvlc_logo_enable as option value has the side effect of
4137- starting (arg !0) or stopping (arg 0) the logo filter.
4138- @param option: logo option to set, values of L{VideoLogoOption}.
4139- @param value: logo option value.
4140- '''
4141- return libvlc_video_set_logo_int(self, option, value)
4142-
4143- def video_set_logo_string(self, option, psz_value):
4144- '''Set logo option as string. Options that take a different type value
4145- are ignored.
4146- @param option: logo option to set, values of L{VideoLogoOption}.
4147- @param psz_value: logo option value.
4148- '''
4149- return libvlc_video_set_logo_string(self, option, str_to_bytes(psz_value))
4150-
4151- def video_get_adjust_int(self, option):
4152- '''Get integer adjust option.
4153- @param option: adjust option to get, values of L{VideoAdjustOption}.
4154- @version: LibVLC 1.1.1 and later.
4155- '''
4156- return libvlc_video_get_adjust_int(self, option)
4157-
4158- def video_set_adjust_int(self, option, value):
4159- '''Set adjust option as integer. Options that take a different type value
4160- are ignored.
4161- Passing libvlc_adjust_enable as option value has the side effect of
4162- starting (arg !0) or stopping (arg 0) the adjust filter.
4163- @param option: adust option to set, values of L{VideoAdjustOption}.
4164- @param value: adjust option value.
4165- @version: LibVLC 1.1.1 and later.
4166- '''
4167- return libvlc_video_set_adjust_int(self, option, value)
4168-
4169- def video_get_adjust_float(self, option):
4170- '''Get float adjust option.
4171- @param option: adjust option to get, values of L{VideoAdjustOption}.
4172- @version: LibVLC 1.1.1 and later.
4173- '''
4174- return libvlc_video_get_adjust_float(self, option)
4175-
4176- def video_set_adjust_float(self, option, value):
4177- '''Set adjust option as float. Options that take a different type value
4178- are ignored.
4179- @param option: adust option to set, values of L{VideoAdjustOption}.
4180- @param value: adjust option value.
4181- @version: LibVLC 1.1.1 and later.
4182- '''
4183- return libvlc_video_set_adjust_float(self, option, value)
4184-
4185- def audio_output_set(self, psz_name):
4186- '''Selects an audio output module.
4187- @note: Any change will take be effect only after playback is stopped and
4188- restarted. Audio output cannot be changed while playing.
4189- @param psz_name: name of audio output, use psz_name of See L{AudioOutput}.
4190- @return: 0 if function succeeded, -1 on error.
4191- '''
4192- return libvlc_audio_output_set(self, str_to_bytes(psz_name))
4193-
4194- def audio_output_device_enum(self):
4195- '''Gets a list of potential audio output devices,
4196- See L{audio_output_device_set}().
4197- @note: Not all audio outputs support enumerating devices.
4198- The audio output may be functional even if the list is empty (None).
4199- @note: The list may not be exhaustive.
4200- @warning: Some audio output devices in the list might not actually work in
4201- some circumstances. By default, it is recommended to not specify any
4202- explicit audio device.
4203- @return: A None-terminated linked list of potential audio output devices. It must be freed with L{audio_output_device_list_release}().
4204- @version: LibVLC 2.2.0 or later.
4205- '''
4206- return libvlc_audio_output_device_enum(self)
4207-
4208- def audio_output_device_set(self, module, device_id):
4209- '''Configures an explicit audio output device.
4210- If the module paramater is None, audio output will be moved to the device
4211- specified by the device identifier string immediately. This is the
4212- recommended usage.
4213- A list of adequate potential device strings can be obtained with
4214- L{audio_output_device_enum}().
4215- However passing None is supported in LibVLC version 2.2.0 and later only;
4216- in earlier versions, this function would have no effects when the module
4217- parameter was None.
4218- If the module parameter is not None, the device parameter of the
4219- corresponding audio output, if it exists, will be set to the specified
4220- string. Note that some audio output modules do not have such a parameter
4221- (notably MMDevice and PulseAudio).
4222- A list of adequate potential device strings can be obtained with
4223- L{audio_output_device_list_get}().
4224- @note: This function does not select the specified audio output plugin.
4225- L{audio_output_set}() is used for that purpose.
4226- @warning: The syntax for the device parameter depends on the audio output.
4227- Some audio output modules require further parameters (e.g. a channels map
4228- in the case of ALSA).
4229- @param module: If None, current audio output module. if non-None, name of audio output module.
4230- @param device_id: device identifier string.
4231- @return: Nothing. Errors are ignored (this is a design bug).
4232- '''
4233- return libvlc_audio_output_device_set(self, str_to_bytes(module), str_to_bytes(device_id))
4234-
4235- def audio_output_device_get(self):
4236- '''Get the current audio output device identifier.
4237- This complements L{audio_output_device_set}().
4238- @warning: The initial value for the current audio output device identifier
4239- may not be set or may be some unknown value. A LibVLC application should
4240- compare this value against the known device identifiers (e.g. those that
4241- were previously retrieved by a call to L{audio_output_device_enum} or
4242- L{audio_output_device_list_get}) to find the current audio output device.
4243- It is possible that the selected audio output device changes (an external
4244- change) without a call to L{audio_output_device_set}. That may make this
4245- method unsuitable to use if a LibVLC application is attempting to track
4246- dynamic audio device changes as they happen.
4247- @return: the current audio output device identifier None if no device is selected or in case of error (the result must be released with free() or L{free}()).
4248- @version: LibVLC 3.0.0 or later.
4249- '''
4250- return libvlc_audio_output_device_get(self)
4251-
4252- def audio_toggle_mute(self):
4253- '''Toggle mute status.
4254- '''
4255- return libvlc_audio_toggle_mute(self)
4256-
4257- def audio_get_mute(self):
4258- '''Get current mute status.
4259- @return: the mute status (boolean) if defined, -1 if undefined/unapplicable.
4260- '''
4261- return libvlc_audio_get_mute(self)
4262-
4263- def audio_set_mute(self, status):
4264- '''Set mute status.
4265- @param status: If status is true then mute, otherwise unmute @warning This function does not always work. If there are no active audio playback stream, the mute status might not be available. If digital pass-through (S/PDIF, HDMI...) is in use, muting may be unapplicable. Also some audio output plugins do not support muting at all. @note To force silent playback, disable all audio tracks. This is more efficient and reliable than mute.
4266- '''
4267- return libvlc_audio_set_mute(self, status)
4268-
4269- def audio_get_volume(self):
4270- '''Get current software audio volume.
4271- @return: the software volume in percents (0 = mute, 100 = nominal / 0dB).
4272- '''
4273- return libvlc_audio_get_volume(self)
4274-
4275- def audio_set_volume(self, i_volume):
4276- '''Set current software audio volume.
4277- @param i_volume: the volume in percents (0 = mute, 100 = 0dB).
4278- @return: 0 if the volume was set, -1 if it was out of range.
4279- '''
4280- return libvlc_audio_set_volume(self, i_volume)
4281-
4282- def audio_get_track_count(self):
4283- '''Get number of available audio tracks.
4284- @return: the number of available audio tracks (int), or -1 if unavailable.
4285- '''
4286- return libvlc_audio_get_track_count(self)
4287-
4288- def audio_get_track(self):
4289- '''Get current audio track.
4290- @return: the audio track ID or -1 if no active input.
4291- '''
4292- return libvlc_audio_get_track(self)
4293-
4294- def audio_set_track(self, i_track):
4295- '''Set current audio track.
4296- @param i_track: the track ID (i_id field from track description).
4297- @return: 0 on success, -1 on error.
4298- '''
4299- return libvlc_audio_set_track(self, i_track)
4300-
4301- def audio_get_channel(self):
4302- '''Get current audio channel.
4303- @return: the audio channel See L{AudioOutputChannel}.
4304- '''
4305- return libvlc_audio_get_channel(self)
4306-
4307- def audio_set_channel(self, channel):
4308- '''Set current audio channel.
4309- @param channel: the audio channel, See L{AudioOutputChannel}.
4310- @return: 0 on success, -1 on error.
4311- '''
4312- return libvlc_audio_set_channel(self, channel)
4313-
4314- def audio_get_delay(self):
4315- '''Get current audio delay.
4316- @return: the audio delay (microseconds).
4317- @version: LibVLC 1.1.1 or later.
4318- '''
4319- return libvlc_audio_get_delay(self)
4320-
4321- def audio_set_delay(self, i_delay):
4322- '''Set current audio delay. The audio delay will be reset to zero each time the media changes.
4323- @param i_delay: the audio delay (microseconds).
4324- @return: 0 on success, -1 on error.
4325- @version: LibVLC 1.1.1 or later.
4326- '''
4327- return libvlc_audio_set_delay(self, i_delay)
4328-
4329- def set_equalizer(self, p_equalizer):
4330- '''Apply new equalizer settings to a media player.
4331- The equalizer is first created by invoking L{audio_equalizer_new}() or
4332- L{audio_equalizer_new_from_preset}().
4333- It is possible to apply new equalizer settings to a media player whether the media
4334- player is currently playing media or not.
4335- Invoking this method will immediately apply the new equalizer settings to the audio
4336- output of the currently playing media if there is any.
4337- If there is no currently playing media, the new equalizer settings will be applied
4338- later if and when new media is played.
4339- Equalizer settings will automatically be applied to subsequently played media.
4340- To disable the equalizer for a media player invoke this method passing None for the
4341- p_equalizer parameter.
4342- The media player does not keep a reference to the supplied equalizer so it is safe
4343- for an application to release the equalizer reference any time after this method
4344- returns.
4345- @param p_equalizer: opaque equalizer handle, or None to disable the equalizer for this media player.
4346- @return: zero on success, -1 on error.
4347- @version: LibVLC 2.2.0 or later.
4348- '''
4349- return libvlc_media_player_set_equalizer(self, p_equalizer)
4350-
4351- def get_role(self):
4352- '''Gets the media role.
4353- @return: the media player role (\ref libvlc_media_player_role_t).
4354- @version: LibVLC 3.0.0 and later.
4355- '''
4356- return libvlc_media_player_get_role(self)
4357-
4358- def set_role(self, role):
4359- '''Sets the media role.
4360- @param role: the media player role (\ref libvlc_media_player_role_t).
4361- @return: 0 on success, -1 on error.
4362- '''
4363- return libvlc_media_player_set_role(self, role)
4364-
4365-
4366-# LibVLC __version__ functions #
4367-
4368-def libvlc_clearerr():
4369- '''Clears the LibVLC error status for the current thread. This is optional.
4370- By default, the error status is automatically overridden when a new error
4371- occurs, and destroyed when the thread exits.
4372- '''
4373- f = _Cfunctions.get('libvlc_clearerr', None) or \
4374- _Cfunction('libvlc_clearerr', (), None,
4375- None)
4376- return f()
4377-
4378-
4379-def libvlc_vprinterr(fmt, ap):
4380- '''Sets the LibVLC error status and message for the current thread.
4381- Any previous error is overridden.
4382- @param fmt: the format string.
4383- @param ap: the arguments.
4384- @return: a nul terminated string in any case.
4385- '''
4386- f = _Cfunctions.get('libvlc_vprinterr', None) or \
4387- _Cfunction('libvlc_vprinterr', ((1,), (1,),), None,
4388- ctypes.c_char_p, ctypes.c_char_p, ctypes.c_void_p)
4389- return f(fmt, ap)
4390-
4391-
4392-def libvlc_new(argc, argv):
4393- '''Create and initialize a libvlc instance.
4394- This functions accept a list of "command line" arguments similar to the
4395- main(). These arguments affect the LibVLC instance default configuration.
4396- @note
4397- LibVLC may create threads. Therefore, any thread-unsafe process
4398- initialization must be performed before calling L{libvlc_new}(). In particular
4399- and where applicable:
4400- - setlocale() and textdomain(),
4401- - setenv(), unsetenv() and putenv(),
4402- - with the X11 display system, XInitThreads()
4403- (see also L{libvlc_media_player_set_xwindow}()) and
4404- - on Microsoft Windows, SetErrorMode().
4405- - sigprocmask() shall never be invoked; pthread_sigmask() can be used.
4406- On POSIX systems, the SIGCHLD signal B{must not} be ignored, i.e. the
4407- signal handler must set to SIG_DFL or a function pointer, not SIG_IGN.
4408- Also while LibVLC is active, the wait() function shall not be called, and
4409- any call to waitpid() shall use a strictly positive value for the first
4410- parameter (i.e. the PID). Failure to follow those rules may lead to a
4411- deadlock or a busy loop.
4412- Also on POSIX systems, it is recommended that the SIGPIPE signal be blocked,
4413- even if it is not, in principles, necessary, e.g.:
4414- @code
4415- @endcode
4416- On Microsoft Windows Vista/2008, the process error mode
4417- SEM_FAILCRITICALERRORS flag B{must} be set before using LibVLC.
4418- On later versions, that is optional and unnecessary.
4419- Also on Microsoft Windows (Vista and any later version), setting the default
4420- DLL directories to SYSTEM32 exclusively is strongly recommended for
4421- security reasons:
4422- @code
4423- @endcode.
4424- @param argc: the number of arguments (should be 0).
4425- @param argv: list of arguments (should be None).
4426- @return: the libvlc instance or None in case of error.
4427- @version Arguments are meant to be passed from the command line to LibVLC, just like VLC media player does. The list of valid arguments depends on the LibVLC version, the operating system and platform, and set of available LibVLC plugins. Invalid or unsupported arguments will cause the function to fail (i.e. return None). Also, some arguments may alter the behaviour or otherwise interfere with other LibVLC functions. @warning There is absolutely no warranty or promise of forward, backward and cross-platform compatibility with regards to L{libvlc_new}() arguments. We recommend that you do not use them, other than when debugging.
4428- '''
4429- f = _Cfunctions.get('libvlc_new', None) or \
4430- _Cfunction('libvlc_new', ((1,), (1,),), class_result(Instance),
4431- ctypes.c_void_p, ctypes.c_int, ListPOINTER(ctypes.c_char_p))
4432- return f(argc, argv)
4433-
4434-
4435-def libvlc_release(p_instance):
4436- '''Decrement the reference count of a libvlc instance, and destroy it
4437- if it reaches zero.
4438- @param p_instance: the instance to destroy.
4439- '''
4440- f = _Cfunctions.get('libvlc_release', None) or \
4441- _Cfunction('libvlc_release', ((1,),), None,
4442- None, Instance)
4443- return f(p_instance)
4444-
4445-
4446-def libvlc_retain(p_instance):
4447- '''Increments the reference count of a libvlc instance.
4448- The initial reference count is 1 after L{libvlc_new}() returns.
4449- @param p_instance: the instance to reference.
4450- '''
4451- f = _Cfunctions.get('libvlc_retain', None) or \
4452- _Cfunction('libvlc_retain', ((1,),), None,
4453- None, Instance)
4454- return f(p_instance)
4455-
4456-
4457-def libvlc_add_intf(p_instance, name):
4458- '''Try to start a user interface for the libvlc instance.
4459- @param p_instance: the instance.
4460- @param name: interface name, or None for default.
4461- @return: 0 on success, -1 on error.
4462- '''
4463- f = _Cfunctions.get('libvlc_add_intf', None) or \
4464- _Cfunction('libvlc_add_intf', ((1,), (1,),), None,
4465- ctypes.c_int, Instance, ctypes.c_char_p)
4466- return f(p_instance, name)
4467-
4468-
4469-def libvlc_set_user_agent(p_instance, name, http):
4470- '''Sets the application name. LibVLC passes this as the user agent string
4471- when a protocol requires it.
4472- @param p_instance: LibVLC instance.
4473- @param name: human-readable application name, e.g. "FooBar player 1.2.3".
4474- @param http: HTTP User Agent, e.g. "FooBar/1.2.3 Python/2.6.0".
4475- @version: LibVLC 1.1.1 or later.
4476- '''
4477- f = _Cfunctions.get('libvlc_set_user_agent', None) or \
4478- _Cfunction('libvlc_set_user_agent', ((1,), (1,), (1,),), None,
4479- None, Instance, ctypes.c_char_p, ctypes.c_char_p)
4480- return f(p_instance, name, http)
4481-
4482-
4483-def libvlc_set_app_id(p_instance, id, version, icon):
4484- '''Sets some meta-information about the application.
4485- See also L{libvlc_set_user_agent}().
4486- @param p_instance: LibVLC instance.
4487- @param id: Java-style application identifier, e.g. "com.acme.foobar".
4488- @param version: application version numbers, e.g. "1.2.3".
4489- @param icon: application icon name, e.g. "foobar".
4490- @version: LibVLC 2.1.0 or later.
4491- '''
4492- f = _Cfunctions.get('libvlc_set_app_id', None) or \
4493- _Cfunction('libvlc_set_app_id', ((1,), (1,), (1,), (1,),), None,
4494- None, Instance, ctypes.c_char_p, ctypes.c_char_p, ctypes.c_char_p)
4495- return f(p_instance, id, version, icon)
4496-
4497-
4498-def libvlc_get_version():
4499- '''Retrieve libvlc version.
4500- Example: "1.1.0-git The Luggage".
4501- @return: a string containing the libvlc version.
4502- '''
4503- f = _Cfunctions.get('libvlc_get_version', None) or \
4504- _Cfunction('libvlc_get_version', (), None,
4505- ctypes.c_char_p)
4506- return f()
4507-
4508-
4509-def libvlc_get_compiler():
4510- '''Retrieve libvlc compiler version.
4511- Example: "gcc version 4.2.3 (Ubuntu 4.2.3-2ubuntu6)".
4512- @return: a string containing the libvlc compiler version.
4513- '''
4514- f = _Cfunctions.get('libvlc_get_compiler', None) or \
4515- _Cfunction('libvlc_get_compiler', (), None,
4516- ctypes.c_char_p)
4517- return f()
4518-
4519-
4520-def libvlc_get_changeset():
4521- '''Retrieve libvlc changeset.
4522- Example: "aa9bce0bc4".
4523- @return: a string containing the libvlc changeset.
4524- '''
4525- f = _Cfunctions.get('libvlc_get_changeset', None) or \
4526- _Cfunction('libvlc_get_changeset', (), None,
4527- ctypes.c_char_p)
4528- return f()
4529-
4530-
4531-def libvlc_free(ptr):
4532- '''Frees an heap allocation returned by a LibVLC function.
4533- If you know you're using the same underlying C run-time as the LibVLC
4534- implementation, then you can call ANSI C free() directly instead.
4535- @param ptr: the pointer.
4536- '''
4537- f = _Cfunctions.get('libvlc_free', None) or \
4538- _Cfunction('libvlc_free', ((1,),), None,
4539- None, ctypes.c_void_p)
4540- return f(ptr)
4541-
4542-
4543-def libvlc_event_attach(p_event_manager, i_event_type, f_callback, user_data):
4544- '''Register for an event notification.
4545- @param p_event_manager: the event manager to which you want to attach to. Generally it is obtained by vlc_my_object_event_manager() where my_object is the object you want to listen to.
4546- @param i_event_type: the desired event to which we want to listen.
4547- @param f_callback: the function to call when i_event_type occurs.
4548- @param user_data: user provided data to carry with the event.
4549- @return: 0 on success, ENOMEM on error.
4550- '''
4551- f = _Cfunctions.get('libvlc_event_attach', None) or \
4552- _Cfunction('libvlc_event_attach', ((1,), (1,), (1,), (1,),), None,
4553- ctypes.c_int, EventManager, ctypes.c_uint, Callback, ctypes.c_void_p)
4554- return f(p_event_manager, i_event_type, f_callback, user_data)
4555-
4556-
4557-def libvlc_event_detach(p_event_manager, i_event_type, f_callback, p_user_data):
4558- '''Unregister an event notification.
4559- @param p_event_manager: the event manager.
4560- @param i_event_type: the desired event to which we want to unregister.
4561- @param f_callback: the function to call when i_event_type occurs.
4562- @param p_user_data: user provided data to carry with the event.
4563- '''
4564- f = _Cfunctions.get('libvlc_event_detach', None) or \
4565- _Cfunction('libvlc_event_detach', ((1,), (1,), (1,), (1,),), None,
4566- None, EventManager, ctypes.c_uint, Callback, ctypes.c_void_p)
4567- return f(p_event_manager, i_event_type, f_callback, p_user_data)
4568-
4569-
4570-def libvlc_event_type_name(event_type):
4571- '''Get an event's type name.
4572- @param event_type: the desired event.
4573- '''
4574- f = _Cfunctions.get('libvlc_event_type_name', None) or \
4575- _Cfunction('libvlc_event_type_name', ((1,),), None,
4576- ctypes.c_char_p, ctypes.c_uint)
4577- return f(event_type)
4578-
4579-
4580-def libvlc_log_get_context(ctx):
4581- '''Gets log message debug infos.
4582- This function retrieves self-debug information about a log message:
4583- - the name of the VLC module emitting the message,
4584- - the name of the source code module (i.e. file) and
4585- - the line number within the source code module.
4586- The returned module name and file name will be None if unknown.
4587- The returned line number will similarly be zero if unknown.
4588- @param ctx: message context (as passed to the @ref libvlc_log_cb callback).
4589- @return: module module name storage (or None), file source code file name storage (or None), line source code file line number storage (or None).
4590- @version: LibVLC 2.1.0 or later.
4591- '''
4592- f = _Cfunctions.get('libvlc_log_get_context', None) or \
4593- _Cfunction('libvlc_log_get_context', ((1,), (2,), (2,), (2,),), None,
4594- None, Log_ptr, ListPOINTER(ctypes.c_char_p), ListPOINTER(ctypes.c_char_p),
4595- ctypes.POINTER(ctypes.c_uint))
4596- return f(ctx)
4597-
4598-
4599-def libvlc_log_get_object(ctx, id):
4600- '''Gets log message info.
4601- This function retrieves meta-information about a log message:
4602- - the type name of the VLC object emitting the message,
4603- - the object header if any, and
4604- - a temporaly-unique object identifier.
4605- This information is mainly meant for B{manual} troubleshooting.
4606- The returned type name may be "generic" if unknown, but it cannot be None.
4607- The returned header will be None if unset; in current versions, the header
4608- is used to distinguish for VLM inputs.
4609- The returned object ID will be zero if the message is not associated with
4610- any VLC object.
4611- @param ctx: message context (as passed to the @ref libvlc_log_cb callback).
4612- @return: name object name storage (or None), header object header (or None), line source code file line number storage (or None).
4613- @version: LibVLC 2.1.0 or later.
4614- '''
4615- f = _Cfunctions.get('libvlc_log_get_object', None) or \
4616- _Cfunction('libvlc_log_get_object', ((1,), (2,), (2,), (1,),), None,
4617- None, Log_ptr, ListPOINTER(ctypes.c_char_p), ListPOINTER(ctypes.c_char_p),
4618- ctypes.POINTER(ctypes.c_uint))
4619- return f(ctx, id)
4620-
4621-
4622-def libvlc_log_unset(p_instance):
4623- '''Unsets the logging callback.
4624- This function deregisters the logging callback for a LibVLC instance.
4625- This is rarely needed as the callback is implicitly unset when the instance
4626- is destroyed.
4627- @note: This function will wait for any pending callbacks invocation to
4628- complete (causing a deadlock if called from within the callback).
4629- @param p_instance: libvlc instance.
4630- @version: LibVLC 2.1.0 or later.
4631- '''
4632- f = _Cfunctions.get('libvlc_log_unset', None) or \
4633- _Cfunction('libvlc_log_unset', ((1,),), None,
4634- None, Instance)
4635- return f(p_instance)
4636-
4637-
4638-def libvlc_log_set(p_instance, cb, data):
4639- '''Sets the logging callback for a LibVLC instance.
4640- This function is thread-safe: it will wait for any pending callbacks
4641- invocation to complete.
4642- @param cb: callback function pointer.
4643- @param data: opaque data pointer for the callback function @note Some log messages (especially debug) are emitted by LibVLC while is being initialized. These messages cannot be captured with this interface. @warning A deadlock may occur if this function is called from the callback.
4644- @param p_instance: libvlc instance.
4645- @version: LibVLC 2.1.0 or later.
4646- '''
4647- f = _Cfunctions.get('libvlc_log_set', None) or \
4648- _Cfunction('libvlc_log_set', ((1,), (1,), (1,),), None,
4649- None, Instance, LogCb, ctypes.c_void_p)
4650- return f(p_instance, cb, data)
4651-
4652-
4653-def libvlc_log_set_file(p_instance, stream):
4654- '''Sets up logging to a file.
4655- @param p_instance: libvlc instance.
4656- @param stream: FILE pointer opened for writing (the FILE pointer must remain valid until L{libvlc_log_unset}()).
4657- @version: LibVLC 2.1.0 or later.
4658- '''
4659- f = _Cfunctions.get('libvlc_log_set_file', None) or \
4660- _Cfunction('libvlc_log_set_file', ((1,), (1,),), None,
4661- None, Instance, FILE_ptr)
4662- return f(p_instance, stream)
4663-
4664-
4665-def libvlc_module_description_list_release(p_list):
4666- '''Release a list of module descriptions.
4667- @param p_list: the list to be released.
4668- '''
4669- f = _Cfunctions.get('libvlc_module_description_list_release', None) or \
4670- _Cfunction('libvlc_module_description_list_release', ((1,),), None,
4671- None, ctypes.POINTER(ModuleDescription))
4672- return f(p_list)
4673-
4674-
4675-def libvlc_audio_filter_list_get(p_instance):
4676- '''Returns a list of audio filters that are available.
4677- @param p_instance: libvlc instance.
4678- @return: a list of module descriptions. It should be freed with L{libvlc_module_description_list_release}(). In case of an error, None is returned. See L{ModuleDescription} See L{libvlc_module_description_list_release}.
4679- '''
4680- f = _Cfunctions.get('libvlc_audio_filter_list_get', None) or \
4681- _Cfunction('libvlc_audio_filter_list_get', ((1,),), None,
4682- ctypes.POINTER(ModuleDescription), Instance)
4683- return f(p_instance)
4684-
4685-
4686-def libvlc_video_filter_list_get(p_instance):
4687- '''Returns a list of video filters that are available.
4688- @param p_instance: libvlc instance.
4689- @return: a list of module descriptions. It should be freed with L{libvlc_module_description_list_release}(). In case of an error, None is returned. See L{ModuleDescription} See L{libvlc_module_description_list_release}.
4690- '''
4691- f = _Cfunctions.get('libvlc_video_filter_list_get', None) or \
4692- _Cfunction('libvlc_video_filter_list_get', ((1,),), None,
4693- ctypes.POINTER(ModuleDescription), Instance)
4694- return f(p_instance)
4695-
4696-
4697-def libvlc_clock():
4698- '''Return the current time as defined by LibVLC. The unit is the microsecond.
4699- Time increases monotonically (regardless of time zone changes and RTC
4700- adjustements).
4701- The origin is arbitrary but consistent across the whole system
4702- (e.g. the system uptim, the time since the system was booted).
4703- @note: On systems that support it, the POSIX monotonic clock is used.
4704- '''
4705- f = _Cfunctions.get('libvlc_clock', None) or \
4706- _Cfunction('libvlc_clock', (), None,
4707- ctypes.c_int64)
4708- return f()
4709-
4710-
4711-def libvlc_media_discoverer_new(p_inst, psz_name):
4712- '''Create a media discoverer object by name.
4713- After this object is created, you should attach to media_list events in
4714- order to be notified of new items discovered.
4715- You need to call L{libvlc_media_discoverer_start}() in order to start the
4716- discovery.
4717- See L{libvlc_media_discoverer_media_list}
4718- See L{libvlc_media_discoverer_event_manager}
4719- See L{libvlc_media_discoverer_start}.
4720- @param p_inst: libvlc instance.
4721- @param psz_name: service name; use L{libvlc_media_discoverer_list_get}() to get a list of the discoverer names available in this libVLC instance.
4722- @return: media discover object or None in case of error.
4723- @version: LibVLC 3.0.0 or later.
4724- '''
4725- f = _Cfunctions.get('libvlc_media_discoverer_new', None) or \
4726- _Cfunction('libvlc_media_discoverer_new', ((1,), (1,),), class_result(MediaDiscoverer),
4727- ctypes.c_void_p, Instance, ctypes.c_char_p)
4728- return f(p_inst, psz_name)
4729-
4730-
4731-def libvlc_media_discoverer_start(p_mdis):
4732- '''Start media discovery.
4733- To stop it, call L{libvlc_media_discoverer_stop}() or
4734- L{libvlc_media_discoverer_list_release}() directly.
4735- See L{libvlc_media_discoverer_stop}.
4736- @param p_mdis: media discover object.
4737- @return: -1 in case of error, 0 otherwise.
4738- @version: LibVLC 3.0.0 or later.
4739- '''
4740- f = _Cfunctions.get('libvlc_media_discoverer_start', None) or \
4741- _Cfunction('libvlc_media_discoverer_start', ((1,),), None,
4742- ctypes.c_int, MediaDiscoverer)
4743- return f(p_mdis)
4744-
4745-
4746-def libvlc_media_discoverer_stop(p_mdis):
4747- '''Stop media discovery.
4748- See L{libvlc_media_discoverer_start}.
4749- @param p_mdis: media discover object.
4750- @version: LibVLC 3.0.0 or later.
4751- '''
4752- f = _Cfunctions.get('libvlc_media_discoverer_stop', None) or \
4753- _Cfunction('libvlc_media_discoverer_stop', ((1,),), None,
4754- None, MediaDiscoverer)
4755- return f(p_mdis)
4756-
4757-
4758-def libvlc_media_discoverer_release(p_mdis):
4759- '''Release media discover object. If the reference count reaches 0, then
4760- the object will be released.
4761- @param p_mdis: media service discover object.
4762- '''
4763- f = _Cfunctions.get('libvlc_media_discoverer_release', None) or \
4764- _Cfunction('libvlc_media_discoverer_release', ((1,),), None,
4765- None, MediaDiscoverer)
4766- return f(p_mdis)
4767-
4768-
4769-def libvlc_media_discoverer_media_list(p_mdis):
4770- '''Get media service discover media list.
4771- @param p_mdis: media service discover object.
4772- @return: list of media items.
4773- '''
4774- f = _Cfunctions.get('libvlc_media_discoverer_media_list', None) or \
4775- _Cfunction('libvlc_media_discoverer_media_list', ((1,),), class_result(MediaList),
4776- ctypes.c_void_p, MediaDiscoverer)
4777- return f(p_mdis)
4778-
4779-
4780-def libvlc_media_discoverer_is_running(p_mdis):
4781- '''Query if media service discover object is running.
4782- @param p_mdis: media service discover object.
4783- @return: true if running, false if not \libvlc_return_bool.
4784- '''
4785- f = _Cfunctions.get('libvlc_media_discoverer_is_running', None) or \
4786- _Cfunction('libvlc_media_discoverer_is_running', ((1,),), None,
4787- ctypes.c_int, MediaDiscoverer)
4788- return f(p_mdis)
4789-
4790-
4791-def libvlc_media_discoverer_list_get(p_inst, i_cat, ppp_services):
4792- '''Get media discoverer services by category.
4793- @param p_inst: libvlc instance.
4794- @param i_cat: category of services to fetch.
4795- @param ppp_services: address to store an allocated array of media discoverer services (must be freed with L{libvlc_media_discoverer_list_release}() by the caller) [OUT].
4796- @return: the number of media discoverer services (0 on error).
4797- @version: LibVLC 3.0.0 and later.
4798- '''
4799- f = _Cfunctions.get('libvlc_media_discoverer_list_get', None) or \
4800- _Cfunction('libvlc_media_discoverer_list_get', ((1,), (1,), (1,),), None,
4801- ctypes.c_size_t, Instance, MediaDiscovererCategory,
4802- ctypes.POINTER(ctypes.POINTER(MediaDiscovererDescription)))
4803- return f(p_inst, i_cat, ppp_services)
4804-
4805-
4806-def libvlc_media_discoverer_list_release(pp_services, i_count):
4807- '''Release an array of media discoverer services.
4808- @param pp_services: array to release.
4809- @param i_count: number of elements in the array.
4810- @version: LibVLC 3.0.0 and later. See L{libvlc_media_discoverer_list_get}().
4811- '''
4812- f = _Cfunctions.get('libvlc_media_discoverer_list_release', None) or \
4813- _Cfunction('libvlc_media_discoverer_list_release', ((1,), (1,),), None,
4814- None, ctypes.POINTER(MediaDiscovererDescription), ctypes.c_size_t)
4815- return f(pp_services, i_count)
4816-
4817-
4818-def libvlc_dialog_set_context(p_id, p_context):
4819- '''Associate an opaque pointer with the dialog id.
4820- @version: LibVLC 3.0.0 and later.
4821- '''
4822- f = _Cfunctions.get('libvlc_dialog_set_context', None) or \
4823- _Cfunction('libvlc_dialog_set_context', ((1,), (1,),), None,
4824- None, ctypes.c_void_p, ctypes.c_void_p)
4825- return f(p_id, p_context)
4826-
4827-
4828-def libvlc_dialog_get_context(p_id):
4829- '''Return the opaque pointer associated with the dialog id.
4830- @version: LibVLC 3.0.0 and later.
4831- '''
4832- f = _Cfunctions.get('libvlc_dialog_get_context', None) or \
4833- _Cfunction('libvlc_dialog_get_context', ((1,),), None,
4834- ctypes.c_void_p, ctypes.c_void_p)
4835- return f(p_id)
4836-
4837-
4838-def libvlc_dialog_post_login(p_id, psz_username, psz_password, b_store):
4839- '''Post a login answer
4840- After this call, p_id won't be valid anymore
4841- See libvlc_dialog_cbs.pf_display_login.
4842- @param p_id: id of the dialog.
4843- @param psz_username: valid and non empty string.
4844- @param psz_password: valid string (can be empty).
4845- @param b_store: if true, store the credentials.
4846- @return: 0 on success, or -1 on error.
4847- @version: LibVLC 3.0.0 and later.
4848- '''
4849- f = _Cfunctions.get('libvlc_dialog_post_login', None) or \
4850- _Cfunction('libvlc_dialog_post_login', ((1,), (1,), (1,), (1,),), None,
4851- ctypes.c_int, ctypes.c_void_p, ctypes.c_char_p, ctypes.c_char_p, ctypes.c_bool)
4852- return f(p_id, psz_username, psz_password, b_store)
4853-
4854-
4855-def libvlc_dialog_post_action(p_id, i_action):
4856- '''Post a question answer
4857- After this call, p_id won't be valid anymore
4858- See libvlc_dialog_cbs.pf_display_question.
4859- @param p_id: id of the dialog.
4860- @param i_action: 1 for action1, 2 for action2.
4861- @return: 0 on success, or -1 on error.
4862- @version: LibVLC 3.0.0 and later.
4863- '''
4864- f = _Cfunctions.get('libvlc_dialog_post_action', None) or \
4865- _Cfunction('libvlc_dialog_post_action', ((1,), (1,),), None,
4866- ctypes.c_int, ctypes.c_void_p, ctypes.c_int)
4867- return f(p_id, i_action)
4868-
4869-
4870-def libvlc_dialog_dismiss(p_id):
4871- '''Dismiss a dialog
4872- After this call, p_id won't be valid anymore
4873- See libvlc_dialog_cbs.pf_cancel.
4874- @param p_id: id of the dialog.
4875- @return: 0 on success, or -1 on error.
4876- @version: LibVLC 3.0.0 and later.
4877- '''
4878- f = _Cfunctions.get('libvlc_dialog_dismiss', None) or \
4879- _Cfunction('libvlc_dialog_dismiss', ((1,),), None,
4880- ctypes.c_int, ctypes.c_void_p)
4881- return f(p_id)
4882-
4883-
4884-def libvlc_media_library_new(p_instance):
4885- '''Create an new Media Library object.
4886- @param p_instance: the libvlc instance.
4887- @return: a new object or None on error.
4888- '''
4889- f = _Cfunctions.get('libvlc_media_library_new', None) or \
4890- _Cfunction('libvlc_media_library_new', ((1,),), class_result(MediaLibrary),
4891- ctypes.c_void_p, Instance)
4892- return f(p_instance)
4893-
4894-
4895-def libvlc_media_library_release(p_mlib):
4896- '''Release media library object. This functions decrements the
4897- reference count of the media library object. If it reaches 0,
4898- then the object will be released.
4899- @param p_mlib: media library object.
4900- '''
4901- f = _Cfunctions.get('libvlc_media_library_release', None) or \
4902- _Cfunction('libvlc_media_library_release', ((1,),), None,
4903- None, MediaLibrary)
4904- return f(p_mlib)
4905-
4906-
4907-def libvlc_media_library_retain(p_mlib):
4908- '''Retain a reference to a media library object. This function will
4909- increment the reference counting for this object. Use
4910- L{libvlc_media_library_release}() to decrement the reference count.
4911- @param p_mlib: media library object.
4912- '''
4913- f = _Cfunctions.get('libvlc_media_library_retain', None) or \
4914- _Cfunction('libvlc_media_library_retain', ((1,),), None,
4915- None, MediaLibrary)
4916- return f(p_mlib)
4917-
4918-
4919-def libvlc_media_library_load(p_mlib):
4920- '''Load media library.
4921- @param p_mlib: media library object.
4922- @return: 0 on success, -1 on error.
4923- '''
4924- f = _Cfunctions.get('libvlc_media_library_load', None) or \
4925- _Cfunction('libvlc_media_library_load', ((1,),), None,
4926- ctypes.c_int, MediaLibrary)
4927- return f(p_mlib)
4928-
4929-
4930-def libvlc_media_library_media_list(p_mlib):
4931- '''Get media library subitems.
4932- @param p_mlib: media library object.
4933- @return: media list subitems.
4934- '''
4935- f = _Cfunctions.get('libvlc_media_library_media_list', None) or \
4936- _Cfunction('libvlc_media_library_media_list', ((1,),), class_result(MediaList),
4937- ctypes.c_void_p, MediaLibrary)
4938- return f(p_mlib)
4939-
4940-
4941-def libvlc_vlm_release(p_instance):
4942- '''Release the vlm instance related to the given L{Instance}.
4943- @param p_instance: the instance.
4944- '''
4945- f = _Cfunctions.get('libvlc_vlm_release', None) or \
4946- _Cfunction('libvlc_vlm_release', ((1,),), None,
4947- None, Instance)
4948- return f(p_instance)
4949-
4950-
4951-def libvlc_vlm_add_broadcast(p_instance, psz_name, psz_input, psz_output, i_options, ppsz_options, b_enabled, b_loop):
4952- '''Add a broadcast, with one input.
4953- @param p_instance: the instance.
4954- @param psz_name: the name of the new broadcast.
4955- @param psz_input: the input MRL.
4956- @param psz_output: the output MRL (the parameter to the "sout" variable).
4957- @param i_options: number of additional options.
4958- @param ppsz_options: additional options.
4959- @param b_enabled: boolean for enabling the new broadcast.
4960- @param b_loop: Should this broadcast be played in loop ?
4961- @return: 0 on success, -1 on error.
4962- '''
4963- f = _Cfunctions.get('libvlc_vlm_add_broadcast', None) or \
4964- _Cfunction('libvlc_vlm_add_broadcast', ((1,), (1,), (1,), (1,), (1,), (1,), (1,), (1,),), None,
4965- ctypes.c_int, Instance, ctypes.c_char_p, ctypes.c_char_p, ctypes.c_char_p, ctypes.c_int,
4966- ListPOINTER(ctypes.c_char_p), ctypes.c_int, ctypes.c_int)
4967- return f(p_instance, psz_name, psz_input, psz_output, i_options, ppsz_options, b_enabled, b_loop)
4968-
4969-
4970-def libvlc_vlm_add_vod(p_instance, psz_name, psz_input, i_options, ppsz_options, b_enabled, psz_mux):
4971- '''Add a vod, with one input.
4972- @param p_instance: the instance.
4973- @param psz_name: the name of the new vod media.
4974- @param psz_input: the input MRL.
4975- @param i_options: number of additional options.
4976- @param ppsz_options: additional options.
4977- @param b_enabled: boolean for enabling the new vod.
4978- @param psz_mux: the muxer of the vod media.
4979- @return: 0 on success, -1 on error.
4980- '''
4981- f = _Cfunctions.get('libvlc_vlm_add_vod', None) or \
4982- _Cfunction('libvlc_vlm_add_vod', ((1,), (1,), (1,), (1,), (1,), (1,), (1,),), None,
4983- ctypes.c_int, Instance, ctypes.c_char_p, ctypes.c_char_p, ctypes.c_int, ListPOINTER(ctypes.c_char_p),
4984- ctypes.c_int, ctypes.c_char_p)
4985- return f(p_instance, psz_name, psz_input, i_options, ppsz_options, b_enabled, psz_mux)
4986-
4987-
4988-def libvlc_vlm_del_media(p_instance, psz_name):
4989- '''Delete a media (VOD or broadcast).
4990- @param p_instance: the instance.
4991- @param psz_name: the media to delete.
4992- @return: 0 on success, -1 on error.
4993- '''
4994- f = _Cfunctions.get('libvlc_vlm_del_media', None) or \
4995- _Cfunction('libvlc_vlm_del_media', ((1,), (1,),), None,
4996- ctypes.c_int, Instance, ctypes.c_char_p)
4997- return f(p_instance, psz_name)
4998-
4999-
5000-def libvlc_vlm_set_enabled(p_instance, psz_name, b_enabled):
The diff has been truncated for viewing.