Module vlc
[hide private]
[frames] | no frames]

Source Code for Module vlc

   1  #! /usr/bin/python 
   2  # -*- coding: utf-8 -*- 
   3   
   4  # Python ctypes bindings for VLC 
   5  # 
   6  # Copyright (C) 2009-2017 the VideoLAN team 
   7  # $Id: $ 
   8  # 
   9  # Authors: Olivier Aubert <contact at olivieraubert.net> 
  10  #          Jean Brouwers <MrJean1 at gmail.com> 
  11  #          Geoff Salmon <geoff.salmon at gmail.com> 
  12  # 
  13  # This library is free software; you can redistribute it and/or modify 
  14  # it under the terms of the GNU Lesser General Public License as 
  15  # published by the Free Software Foundation; either version 2.1 of the 
  16  # License, or (at your option) any later version. 
  17  # 
  18  # This library is distributed in the hope that it will be useful, but 
  19  # WITHOUT ANY WARRANTY; without even the implied warranty of 
  20  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
  21  # Lesser General Public License for more details. 
  22  # 
  23  # You should have received a copy of the GNU Lesser General Public 
  24  # License along with this library; if not, write to the Free Software 
  25  # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA 
  26   
  27  """This module provides bindings for the LibVLC public API, see 
  28  U{http://wiki.videolan.org/LibVLC}. 
  29   
  30  You can find the documentation and a README file with some examples 
  31  at U{https://www.olivieraubert.net/vlc/python-ctypes/}. 
  32   
  33  Basically, the most important class is L{Instance}, which is used 
  34  to create a libvlc instance.  From this instance, you then create 
  35  L{MediaPlayer} and L{MediaListPlayer} instances. 
  36   
  37  Alternatively, you may create instances of the L{MediaPlayer} and 
  38  L{MediaListPlayer} class directly and an instance of L{Instance} 
  39  will be implicitly created.  The latter can be obtained using the 
  40  C{get_instance} method of L{MediaPlayer} and L{MediaListPlayer}. 
  41  """ 
  42   
  43  import ctypes 
  44  from ctypes.util import find_library 
  45  import os 
  46  import sys 
  47  import functools 
  48   
  49  # Used by EventManager in override.py 
  50  from inspect import getargspec 
  51   
  52  import logging 
  53  logger = logging.getLogger(__name__) 
  54   
  55  __version__ = "3.0.11115" 
  56  __libvlc_version__ = "3.0.11" 
  57  __generator_version__ = "1.15" 
  58  build_date  = "Sat Jul 25 15:07:40 2020 3.0.11" 
  59   
  60  # The libvlc doc states that filenames are expected to be in UTF8, do 
  61  # not rely on sys.getfilesystemencoding() which will be confused, 
  62  # esp. on windows. 
  63  DEFAULT_ENCODING = 'utf-8' 
  64   
  65  if sys.version_info[0] > 2: 
  66      str = str 
  67      unicode = str 
  68      bytes = bytes 
  69      basestring = (str, bytes) 
  70      PYTHON3 = True 
71 - def str_to_bytes(s):
72 """Translate string or bytes to bytes. 73 """ 74 if isinstance(s, str): 75 return bytes(s, DEFAULT_ENCODING) 76 else: 77 return s
78
79 - def bytes_to_str(b):
80 """Translate bytes to string. 81 """ 82 if isinstance(b, bytes): 83 return b.decode(DEFAULT_ENCODING) 84 else: 85 return b
86 else: 87 str = str 88 unicode = unicode 89 bytes = str 90 basestring = basestring 91 PYTHON3 = False
92 - def str_to_bytes(s):
93 """Translate string or bytes to bytes. 94 """ 95 if isinstance(s, unicode): 96 return s.encode(DEFAULT_ENCODING) 97 else: 98 return s
99
100 - def bytes_to_str(b):
101 """Translate bytes to unicode string. 102 """ 103 if isinstance(b, str): 104 return unicode(b, DEFAULT_ENCODING) 105 else: 106 return b
107 108 # Internal guard to prevent internal classes to be directly 109 # instanciated. 110 _internal_guard = object()
111 112 -def find_lib():
113 dll = None 114 plugin_path = os.environ.get('PYTHON_VLC_MODULE_PATH', None) 115 if 'PYTHON_VLC_LIB_PATH' in os.environ: 116 try: 117 dll = ctypes.CDLL(os.environ['PYTHON_VLC_LIB_PATH']) 118 except OSError: 119 logger.error("Cannot load lib specified by PYTHON_VLC_LIB_PATH env. variable") 120 sys.exit(1) 121 if plugin_path and not os.path.isdir(plugin_path): 122 logger.error("Invalid PYTHON_VLC_MODULE_PATH specified. Please fix.") 123 sys.exit(1) 124 if dll is not None: 125 return dll, plugin_path 126 127 if sys.platform.startswith('win'): 128 libname = 'libvlc.dll' 129 p = find_library(libname) 130 if p is None: 131 try: # some registry settings 132 # leaner than win32api, win32con 133 if PYTHON3: 134 import winreg as w 135 else: 136 import _winreg as w 137 for r in w.HKEY_LOCAL_MACHINE, w.HKEY_CURRENT_USER: 138 try: 139 r = w.OpenKey(r, 'Software\\VideoLAN\\VLC') 140 plugin_path, _ = w.QueryValueEx(r, 'InstallDir') 141 w.CloseKey(r) 142 break 143 except w.error: 144 pass 145 except ImportError: # no PyWin32 146 pass 147 if plugin_path is None: 148 # try some standard locations. 149 programfiles = os.environ["ProgramFiles"] 150 homedir = os.environ["HOMEDRIVE"] 151 for p in ('{programfiles}\\VideoLan{libname}', '{homedir}:\\VideoLan{libname}', 152 '{programfiles}{libname}', '{homedir}:{libname}'): 153 p = p.format(homedir = homedir, 154 programfiles = programfiles, 155 libname = '\\VLC\\' + libname) 156 if os.path.exists(p): 157 plugin_path = os.path.dirname(p) 158 break 159 if plugin_path is not None: # try loading 160 # PyInstaller Windows fix 161 if 'PyInstallerCDLL' in ctypes.CDLL.__name__: 162 ctypes.windll.kernel32.SetDllDirectoryW(None) 163 p = os.getcwd() 164 os.chdir(plugin_path) 165 # if chdir failed, this will raise an exception 166 dll = ctypes.CDLL('.\\' + libname) 167 # restore cwd after dll has been loaded 168 os.chdir(p) 169 else: # may fail 170 dll = ctypes.CDLL('.\\' + libname) 171 else: 172 plugin_path = os.path.dirname(p) 173 dll = ctypes.CDLL(p) 174 175 elif sys.platform.startswith('darwin'): 176 # FIXME: should find a means to configure path 177 d = '/Applications/VLC.app/Contents/MacOS/' 178 c = d + 'lib/libvlccore.dylib' 179 p = d + 'lib/libvlc.dylib' 180 if os.path.exists(p) and os.path.exists(c): 181 # pre-load libvlccore VLC 2.2.8+ 182 ctypes.CDLL(c) 183 dll = ctypes.CDLL(p) 184 for p in ('modules', 'plugins'): 185 p = d + p 186 if os.path.isdir(p): 187 plugin_path = p 188 break 189 else: # hope, some [DY]LD_LIBRARY_PATH is set... 190 # pre-load libvlccore VLC 2.2.8+ 191 ctypes.CDLL('libvlccore.dylib') 192 dll = ctypes.CDLL('libvlc.dylib') 193 194 else: 195 # All other OSes (linux, freebsd...) 196 p = find_library('vlc') 197 try: 198 dll = ctypes.CDLL(p) 199 except OSError: # may fail 200 dll = None 201 if dll is None: 202 try: 203 dll = ctypes.CDLL('libvlc.so.5') 204 except: 205 raise NotImplementedError('Cannot find libvlc lib') 206 207 return (dll, plugin_path)
208 209 # plugin_path used on win32 and MacOS in override.py 210 dll, plugin_path = find_lib()
211 212 -class VLCException(Exception):
213 """Exception raised by libvlc methods. 214 """ 215 pass
216 217 try: 218 _Ints = (int, long) 219 except NameError: # no long in Python 3+ 220 _Ints = int 221 _Seqs = (list, tuple)
222 223 # Used for handling *event_manager() methods. 224 -class memoize_parameterless(object):
225 """Decorator. Caches a parameterless method's return value each time it is called. 226 227 If called later with the same arguments, the cached value is returned 228 (not reevaluated). 229 Adapted from https://wiki.python.org/moin/PythonDecoratorLibrary 230 """
231 - def __init__(self, func):
232 self.func = func 233 self._cache = {}
234
235 - def __call__(self, obj):
236 try: 237 return self._cache[obj] 238 except KeyError: 239 v = self._cache[obj] = self.func(obj) 240 return v
241
242 - def __repr__(self):
243 """Return the function's docstring. 244 """ 245 return self.func.__doc__
246
247 - def __get__(self, obj, objtype):
248 """Support instance methods. 249 """ 250 return functools.partial(self.__call__, obj)
251 252 # Default instance. It is used to instanciate classes directly in the 253 # OO-wrapper. 254 _default_instance = None
255 256 -def get_default_instance():
257 """Return the default VLC.Instance. 258 """ 259 global _default_instance 260 if _default_instance is None: 261 _default_instance = Instance() 262 return _default_instance
263
264 -def try_fspath(path):
265 """Try calling os.fspath 266 os.fspath is only available from py3.6 267 """ 268 try: 269 return os.fspath(path) 270 except (AttributeError, TypeError): 271 return path
272 273 _Cfunctions = {} # from LibVLC __version__ 274 _Globals = globals() # sys.modules[__name__].__dict__
275 276 -def _Cfunction(name, flags, errcheck, *types):
277 """(INTERNAL) New ctypes function binding. 278 """ 279 if hasattr(dll, name) and name in _Globals: 280 p = ctypes.CFUNCTYPE(*types) 281 f = p((name, dll), flags) 282 if errcheck is not None: 283 f.errcheck = errcheck 284 # replace the Python function 285 # in this module, but only when 286 # running as python -O or -OO 287 if __debug__: 288 _Cfunctions[name] = f 289 else: 290 _Globals[name] = f 291 return f 292 raise NameError('no function %r' % (name,))
293
294 -def _Cobject(cls, ctype):
295 """(INTERNAL) New instance from ctypes. 296 """ 297 o = object.__new__(cls) 298 o._as_parameter_ = ctype 299 return o
300
301 -def _Constructor(cls, ptr=_internal_guard):
302 """(INTERNAL) New wrapper from ctypes. 303 """ 304 if ptr == _internal_guard: 305 raise VLCException("(INTERNAL) ctypes class. You should get references for this class through methods of the LibVLC API.") 306 if ptr is None or ptr == 0: 307 return None 308 return _Cobject(cls, ctypes.c_void_p(ptr))
309
310 -class _Cstruct(ctypes.Structure):
311 """(INTERNAL) Base class for ctypes structures. 312 """ 313 _fields_ = [] # list of 2-tuples ('name', ctypes.<type>) 314
315 - def __str__(self):
316 l = [' %s:\t%s' % (n, getattr(self, n)) for n, _ in self._fields_] 317 return '\n'.join([self.__class__.__name__] + l)
318
319 - def __repr__(self):
320 return '%s.%s' % (self.__class__.__module__, self)
321
322 -class _Ctype(object):
323 """(INTERNAL) Base class for ctypes. 324 """ 325 @staticmethod
326 - def from_param(this): # not self
327 """(INTERNAL) ctypes parameter conversion method. 328 """ 329 if this is None: 330 return None 331 return this._as_parameter_
332
333 -class ListPOINTER(object):
334 """Just like a POINTER but accept a list of etype elements as an argument. 335 """
336 - def __init__(self, etype):
337 self.etype = etype
338
339 - def from_param(self, param):
340 if isinstance(param, _Seqs): 341 return (self.etype * len(param))(*param) 342 else: 343 return ctypes.POINTER(param)
344
345 # errcheck functions for some native functions. 346 -def string_result(result, func, arguments):
347 """Errcheck function. Returns a string and frees the original pointer. 348 349 It assumes the result is a char *. 350 """ 351 if result: 352 # make a python string copy 353 s = bytes_to_str(ctypes.string_at(result)) 354 # free original string ptr 355 libvlc_free(result) 356 return s 357 return None
358
359 -def class_result(classname):
360 """Errcheck function. Returns a function that creates the specified class. 361 """ 362 def wrap_errcheck(result, func, arguments): 363 if result is None: 364 return None 365 return classname(result)
366 return wrap_errcheck 367
368 # Wrapper for the opaque struct libvlc_log_t 369 -class Log(ctypes.Structure):
370 pass
371 Log_ptr = ctypes.POINTER(Log)
372 373 # FILE* ctypes wrapper, copied from 374 # http://svn.python.org/projects/ctypes/trunk/ctypeslib/ctypeslib/contrib/pythonhdr.py 375 -class FILE(ctypes.Structure):
376 pass
377 FILE_ptr = ctypes.POINTER(FILE) 378 379 if PYTHON3: 380 PyFile_FromFd = ctypes.pythonapi.PyFile_FromFd 381 PyFile_FromFd.restype = ctypes.py_object 382 PyFile_FromFd.argtypes = [ctypes.c_int, 383 ctypes.c_char_p, 384 ctypes.c_char_p, 385 ctypes.c_int, 386 ctypes.c_char_p, 387 ctypes.c_char_p, 388 ctypes.c_char_p, 389 ctypes.c_int ] 390 391 PyFile_AsFd = ctypes.pythonapi.PyObject_AsFileDescriptor 392 PyFile_AsFd.restype = ctypes.c_int 393 PyFile_AsFd.argtypes = [ctypes.py_object] 394 else: 395 PyFile_FromFile = ctypes.pythonapi.PyFile_FromFile 396 PyFile_FromFile.restype = ctypes.py_object 397 PyFile_FromFile.argtypes = [FILE_ptr, 398 ctypes.c_char_p, 399 ctypes.c_char_p, 400 ctypes.CFUNCTYPE(ctypes.c_int, FILE_ptr)] 401 402 PyFile_AsFile = ctypes.pythonapi.PyFile_AsFile 403 PyFile_AsFile.restype = FILE_ptr 404 PyFile_AsFile.argtypes = [ctypes.py_object]
405 406 # Generated enum types # 407 408 -class _Enum(ctypes.c_uint):
409 '''(INTERNAL) Base class 410 ''' 411 _enum_names_ = {} 412
413 - def __str__(self):
414 n = self._enum_names_.get(self.value, '') or ('FIXME_(%r)' % (self.value,)) 415 return '.'.join((self.__class__.__name__, n))
416
417 - def __hash__(self):
418 return self.value
419
420 - def __repr__(self):
421 return '.'.join((self.__class__.__module__, self.__str__()))
422
423 - def __eq__(self, other):
424 return ( (isinstance(other, _Enum) and self.value == other.value) 425 or (isinstance(other, _Ints) and self.value == other) )
426
427 - def __ne__(self, other):
428 return not self.__eq__(other)
429
430 -class LogLevel(_Enum):
431 '''Logging messages level. 432 \note future libvlc versions may define new levels. 433 ''' 434 _enum_names_ = { 435 0: 'DEBUG', 436 2: 'NOTICE', 437 3: 'WARNING', 438 4: 'ERROR', 439 }
440 LogLevel.DEBUG = LogLevel(0) 441 LogLevel.ERROR = LogLevel(4) 442 LogLevel.NOTICE = LogLevel(2) 443 LogLevel.WARNING = LogLevel(3)
444 445 -class MediaDiscovererCategory(_Enum):
446 '''Category of a media discoverer 447 See libvlc_media_discoverer_list_get(). 448 ''' 449 _enum_names_ = { 450 0: 'devices', 451 1: 'lan', 452 2: 'podcasts', 453 3: 'localdirs', 454 }
455 MediaDiscovererCategory.devices = MediaDiscovererCategory(0) 456 MediaDiscovererCategory.lan = MediaDiscovererCategory(1) 457 MediaDiscovererCategory.localdirs = MediaDiscovererCategory(3) 458 MediaDiscovererCategory.podcasts = MediaDiscovererCategory(2)
459 460 -class DialogQuestionType(_Enum):
461 '''@defgroup libvlc_dialog libvlc dialog 462 @ingroup libvlc 463 @{ 464 @file 465 libvlc dialog external api. 466 ''' 467 _enum_names_ = { 468 0: 'DIALOG_QUESTION_NORMAL', 469 1: 'DIALOG_QUESTION_WARNING', 470 2: 'DIALOG_QUESTION_CRITICAL', 471 }
472 DialogQuestionType.DIALOG_QUESTION_CRITICAL = DialogQuestionType(2) 473 DialogQuestionType.DIALOG_QUESTION_NORMAL = DialogQuestionType(0) 474 DialogQuestionType.DIALOG_QUESTION_WARNING = DialogQuestionType(1)
475 476 -class EventType(_Enum):
477 '''Event types. 478 ''' 479 _enum_names_ = { 480 0: 'MediaMetaChanged', 481 1: 'MediaSubItemAdded', 482 2: 'MediaDurationChanged', 483 3: 'MediaParsedChanged', 484 4: 'MediaFreed', 485 5: 'MediaStateChanged', 486 6: 'MediaSubItemTreeAdded', 487 0x100: 'MediaPlayerMediaChanged', 488 257: 'MediaPlayerNothingSpecial', 489 258: 'MediaPlayerOpening', 490 259: 'MediaPlayerBuffering', 491 260: 'MediaPlayerPlaying', 492 261: 'MediaPlayerPaused', 493 262: 'MediaPlayerStopped', 494 263: 'MediaPlayerForward', 495 264: 'MediaPlayerBackward', 496 265: 'MediaPlayerEndReached', 497 266: 'MediaPlayerEncounteredError', 498 267: 'MediaPlayerTimeChanged', 499 268: 'MediaPlayerPositionChanged', 500 269: 'MediaPlayerSeekableChanged', 501 270: 'MediaPlayerPausableChanged', 502 271: 'MediaPlayerTitleChanged', 503 272: 'MediaPlayerSnapshotTaken', 504 273: 'MediaPlayerLengthChanged', 505 274: 'MediaPlayerVout', 506 275: 'MediaPlayerScrambledChanged', 507 276: 'MediaPlayerESAdded', 508 277: 'MediaPlayerESDeleted', 509 278: 'MediaPlayerESSelected', 510 279: 'MediaPlayerCorked', 511 280: 'MediaPlayerUncorked', 512 281: 'MediaPlayerMuted', 513 282: 'MediaPlayerUnmuted', 514 283: 'MediaPlayerAudioVolume', 515 284: 'MediaPlayerAudioDevice', 516 285: 'MediaPlayerChapterChanged', 517 0x200: 'MediaListItemAdded', 518 513: 'MediaListWillAddItem', 519 514: 'MediaListItemDeleted', 520 515: 'MediaListWillDeleteItem', 521 516: 'MediaListEndReached', 522 0x300: 'MediaListViewItemAdded', 523 769: 'MediaListViewWillAddItem', 524 770: 'MediaListViewItemDeleted', 525 771: 'MediaListViewWillDeleteItem', 526 0x400: 'MediaListPlayerPlayed', 527 1025: 'MediaListPlayerNextItemSet', 528 1026: 'MediaListPlayerStopped', 529 0x500: 'MediaDiscovererStarted', 530 1281: 'MediaDiscovererEnded', 531 1282: 'RendererDiscovererItemAdded', 532 1283: 'RendererDiscovererItemDeleted', 533 0x600: 'VlmMediaAdded', 534 1537: 'VlmMediaRemoved', 535 1538: 'VlmMediaChanged', 536 1539: 'VlmMediaInstanceStarted', 537 1540: 'VlmMediaInstanceStopped', 538 1541: 'VlmMediaInstanceStatusInit', 539 1542: 'VlmMediaInstanceStatusOpening', 540 1543: 'VlmMediaInstanceStatusPlaying', 541 1544: 'VlmMediaInstanceStatusPause', 542 1545: 'VlmMediaInstanceStatusEnd', 543 1546: 'VlmMediaInstanceStatusError', 544 }
545 EventType.MediaDiscovererEnded = EventType(1281) 546 EventType.MediaDiscovererStarted = EventType(0x500) 547 EventType.MediaDurationChanged = EventType(2) 548 EventType.MediaFreed = EventType(4) 549 EventType.MediaListEndReached = EventType(516) 550 EventType.MediaListItemAdded = EventType(0x200) 551 EventType.MediaListItemDeleted = EventType(514) 552 EventType.MediaListPlayerNextItemSet = EventType(1025) 553 EventType.MediaListPlayerPlayed = EventType(0x400) 554 EventType.MediaListPlayerStopped = EventType(1026) 555 EventType.MediaListViewItemAdded = EventType(0x300) 556 EventType.MediaListViewItemDeleted = EventType(770) 557 EventType.MediaListViewWillAddItem = EventType(769) 558 EventType.MediaListViewWillDeleteItem = EventType(771) 559 EventType.MediaListWillAddItem = EventType(513) 560 EventType.MediaListWillDeleteItem = EventType(515) 561 EventType.MediaMetaChanged = EventType(0) 562 EventType.MediaParsedChanged = EventType(3) 563 EventType.MediaPlayerAudioDevice = EventType(284) 564 EventType.MediaPlayerAudioVolume = EventType(283) 565 EventType.MediaPlayerBackward = EventType(264) 566 EventType.MediaPlayerBuffering = EventType(259) 567 EventType.MediaPlayerChapterChanged = EventType(285) 568 EventType.MediaPlayerCorked = EventType(279) 569 EventType.MediaPlayerESAdded = EventType(276) 570 EventType.MediaPlayerESDeleted = EventType(277) 571 EventType.MediaPlayerESSelected = EventType(278) 572 EventType.MediaPlayerEncounteredError = EventType(266) 573 EventType.MediaPlayerEndReached = EventType(265) 574 EventType.MediaPlayerForward = EventType(263) 575 EventType.MediaPlayerLengthChanged = EventType(273) 576 EventType.MediaPlayerMediaChanged = EventType(0x100) 577 EventType.MediaPlayerMuted = EventType(281) 578 EventType.MediaPlayerNothingSpecial = EventType(257) 579 EventType.MediaPlayerOpening = EventType(258) 580 EventType.MediaPlayerPausableChanged = EventType(270) 581 EventType.MediaPlayerPaused = EventType(261) 582 EventType.MediaPlayerPlaying = EventType(260) 583 EventType.MediaPlayerPositionChanged = EventType(268) 584 EventType.MediaPlayerScrambledChanged = EventType(275) 585 EventType.MediaPlayerSeekableChanged = EventType(269) 586 EventType.MediaPlayerSnapshotTaken = EventType(272) 587 EventType.MediaPlayerStopped = EventType(262) 588 EventType.MediaPlayerTimeChanged = EventType(267) 589 EventType.MediaPlayerTitleChanged = EventType(271) 590 EventType.MediaPlayerUncorked = EventType(280) 591 EventType.MediaPlayerUnmuted = EventType(282) 592 EventType.MediaPlayerVout = EventType(274) 593 EventType.MediaStateChanged = EventType(5) 594 EventType.MediaSubItemAdded = EventType(1) 595 EventType.MediaSubItemTreeAdded = EventType(6) 596 EventType.RendererDiscovererItemAdded = EventType(1282) 597 EventType.RendererDiscovererItemDeleted = EventType(1283) 598 EventType.VlmMediaAdded = EventType(0x600) 599 EventType.VlmMediaChanged = EventType(1538) 600 EventType.VlmMediaInstanceStarted = EventType(1539) 601 EventType.VlmMediaInstanceStatusEnd = EventType(1545) 602 EventType.VlmMediaInstanceStatusError = EventType(1546) 603 EventType.VlmMediaInstanceStatusInit = EventType(1541) 604 EventType.VlmMediaInstanceStatusOpening = EventType(1542) 605 EventType.VlmMediaInstanceStatusPause = EventType(1544) 606 EventType.VlmMediaInstanceStatusPlaying = EventType(1543) 607 EventType.VlmMediaInstanceStopped = EventType(1540) 608 EventType.VlmMediaRemoved = EventType(1537)
609 610 -class Meta(_Enum):
611 '''Meta data types. 612 ''' 613 _enum_names_ = { 614 0: 'Title', 615 1: 'Artist', 616 2: 'Genre', 617 3: 'Copyright', 618 4: 'Album', 619 5: 'TrackNumber', 620 6: 'Description', 621 7: 'Rating', 622 8: 'Date', 623 9: 'Setting', 624 10: 'URL', 625 11: 'Language', 626 12: 'NowPlaying', 627 13: 'Publisher', 628 14: 'EncodedBy', 629 15: 'ArtworkURL', 630 16: 'TrackID', 631 17: 'TrackTotal', 632 18: 'Director', 633 19: 'Season', 634 20: 'Episode', 635 21: 'ShowName', 636 22: 'Actors', 637 23: 'AlbumArtist', 638 24: 'DiscNumber', 639 25: 'DiscTotal', 640 }
641 Meta.Actors = Meta(22) 642 Meta.Album = Meta(4) 643 Meta.AlbumArtist = Meta(23) 644 Meta.Artist = Meta(1) 645 Meta.ArtworkURL = Meta(15) 646 Meta.Copyright = Meta(3) 647 Meta.Date = Meta(8) 648 Meta.Description = Meta(6) 649 Meta.Director = Meta(18) 650 Meta.DiscNumber = Meta(24) 651 Meta.DiscTotal = Meta(25) 652 Meta.EncodedBy = Meta(14) 653 Meta.Episode = Meta(20) 654 Meta.Genre = Meta(2) 655 Meta.Language = Meta(11) 656 Meta.NowPlaying = Meta(12) 657 Meta.Publisher = Meta(13) 658 Meta.Rating = Meta(7) 659 Meta.Season = Meta(19) 660 Meta.Setting = Meta(9) 661 Meta.ShowName = Meta(21) 662 Meta.Title = Meta(0) 663 Meta.TrackID = Meta(16) 664 Meta.TrackNumber = Meta(5) 665 Meta.TrackTotal = Meta(17) 666 Meta.URL = Meta(10)
667 668 -class State(_Enum):
669 '''Note the order of libvlc_state_t enum must match exactly the order of 670 See mediacontrol_playerstatus, See input_state_e enums, 671 and videolan.libvlc.state (at bindings/cil/src/media.cs). 672 expected states by web plugins are: 673 idle/close=0, opening=1, playing=3, paused=4, 674 stopping=5, ended=6, error=7. 675 ''' 676 _enum_names_ = { 677 0: 'NothingSpecial', 678 1: 'Opening', 679 2: 'Buffering', 680 3: 'Playing', 681 4: 'Paused', 682 5: 'Stopped', 683 6: 'Ended', 684 7: 'Error', 685 }
686 State.Buffering = State(2) 687 State.Ended = State(6) 688 State.Error = State(7) 689 State.NothingSpecial = State(0) 690 State.Opening = State(1) 691 State.Paused = State(4) 692 State.Playing = State(3) 693 State.Stopped = State(5)
694 695 -class TrackType(_Enum):
696 '''N/A 697 ''' 698 _enum_names_ = { 699 -1: 'unknown', 700 0: 'audio', 701 1: 'video', 702 2: 'ext', 703 }
704 TrackType.audio = TrackType(0) 705 TrackType.ext = TrackType(2) 706 TrackType.unknown = TrackType(-1) 707 TrackType.video = TrackType(1)
708 709 -class VideoOrient(_Enum):
710 '''N/A 711 ''' 712 _enum_names_ = { 713 0: 'top_left', 714 1: 'top_right', 715 2: 'bottom_left', 716 3: 'bottom_right', 717 4: 'left_top', 718 5: 'left_bottom', 719 6: 'right_top', 720 7: 'right_bottom', 721 }
722 VideoOrient.bottom_left = VideoOrient(2) 723 VideoOrient.bottom_right = VideoOrient(3) 724 VideoOrient.left_bottom = VideoOrient(5) 725 VideoOrient.left_top = VideoOrient(4) 726 VideoOrient.right_bottom = VideoOrient(7) 727 VideoOrient.right_top = VideoOrient(6) 728 VideoOrient.top_left = VideoOrient(0) 729 VideoOrient.top_right = VideoOrient(1)
730 731 -class VideoProjection(_Enum):
732 '''N/A 733 ''' 734 _enum_names_ = { 735 0: 'rectangular', 736 1: 'equirectangular', 737 0x100: 'cubemap_layout_standard', 738 }
739 VideoProjection.cubemap_layout_standard = VideoProjection(0x100) 740 VideoProjection.equirectangular = VideoProjection(1) 741 VideoProjection.rectangular = VideoProjection(0)
742 743 -class MediaType(_Enum):
744 '''Media type 745 See libvlc_media_get_type. 746 ''' 747 _enum_names_ = { 748 0: 'unknown', 749 1: 'file', 750 2: 'directory', 751 3: 'disc', 752 4: 'stream', 753 5: 'playlist', 754 }
755 MediaType.directory = MediaType(2) 756 MediaType.disc = MediaType(3) 757 MediaType.file = MediaType(1) 758 MediaType.playlist = MediaType(5) 759 MediaType.stream = MediaType(4) 760 MediaType.unknown = MediaType(0)
761 762 -class MediaParseFlag(_Enum):
763 '''Parse flags used by libvlc_media_parse_with_options() 764 See libvlc_media_parse_with_options. 765 ''' 766 _enum_names_ = { 767 0x0: 'local', 768 0x1: 'network', 769 0x2: 'fetch_local', 770 0x4: 'fetch_network', 771 0x8: 'do_interact', 772 }
773 MediaParseFlag.do_interact = MediaParseFlag(0x8) 774 MediaParseFlag.fetch_local = MediaParseFlag(0x2) 775 MediaParseFlag.fetch_network = MediaParseFlag(0x4) 776 MediaParseFlag.local = MediaParseFlag(0x0) 777 MediaParseFlag.network = MediaParseFlag(0x1)
778 779 -class MediaParsedStatus(_Enum):
780 '''Parse status used sent by libvlc_media_parse_with_options() or returned by 781 libvlc_media_get_parsed_status() 782 See libvlc_media_parse_with_options 783 See libvlc_media_get_parsed_status. 784 ''' 785 _enum_names_ = { 786 1: 'skipped', 787 2: 'failed', 788 3: 'timeout', 789 4: 'done', 790 }
791 MediaParsedStatus.done = MediaParsedStatus(4) 792 MediaParsedStatus.failed = MediaParsedStatus(2) 793 MediaParsedStatus.skipped = MediaParsedStatus(1) 794 MediaParsedStatus.timeout = MediaParsedStatus(3)
795 796 -class MediaSlaveType(_Enum):
797 '''Type of a media slave: subtitle or audio. 798 ''' 799 _enum_names_ = { 800 0: 'subtitle', 801 1: 'audio', 802 }
803 MediaSlaveType.audio = MediaSlaveType(1) 804 MediaSlaveType.subtitle = MediaSlaveType(0)
805 806 -class VideoMarqueeOption(_Enum):
807 '''Marq options definition. 808 ''' 809 _enum_names_ = { 810 0: 'Enable', 811 1: 'Text', 812 2: 'Color', 813 3: 'Opacity', 814 4: 'Position', 815 5: 'Refresh', 816 6: 'Size', 817 7: 'Timeout', 818 8: 'X', 819 9: 'Y', 820 }
821 VideoMarqueeOption.Color = VideoMarqueeOption(2) 822 VideoMarqueeOption.Enable = VideoMarqueeOption(0) 823 VideoMarqueeOption.Opacity = VideoMarqueeOption(3) 824 VideoMarqueeOption.Position = VideoMarqueeOption(4) 825 VideoMarqueeOption.Refresh = VideoMarqueeOption(5) 826 VideoMarqueeOption.Size = VideoMarqueeOption(6) 827 VideoMarqueeOption.Text = VideoMarqueeOption(1) 828 VideoMarqueeOption.Timeout = VideoMarqueeOption(7) 829 VideoMarqueeOption.X = VideoMarqueeOption(8) 830 VideoMarqueeOption.Y = VideoMarqueeOption(9) 843 NavigateMode.activate = NavigateMode(0) 844 NavigateMode.down = NavigateMode(2) 845 NavigateMode.left = NavigateMode(3) 846 NavigateMode.popup = NavigateMode(5) 847 NavigateMode.right = NavigateMode(4) 848 NavigateMode.up = NavigateMode(1)
849 850 -class Position(_Enum):
851 '''Enumeration of values used to set position (e.g. of video title). 852 ''' 853 _enum_names_ = { 854 -1: 'disable', 855 0: 'center', 856 1: 'left', 857 2: 'right', 858 3: 'top', 859 4: 'top_left', 860 5: 'top_right', 861 6: 'bottom', 862 7: 'bottom_left', 863 8: 'bottom_right', 864 }
865 Position.bottom = Position(6) 866 Position.bottom_left = Position(7) 867 Position.bottom_right = Position(8) 868 Position.center = Position(0) 869 Position.disable = Position(-1) 870 Position.left = Position(1) 871 Position.right = Position(2) 872 Position.top = Position(3) 873 Position.top_left = Position(4) 874 Position.top_right = Position(5)
875 876 -class TeletextKey(_Enum):
877 '''Enumeration of teletext keys than can be passed via 878 libvlc_video_set_teletext(). 879 ''' 880 _enum_names_ = { 881 7471104: 'red', 882 6750208: 'green', 883 7929856: 'yellow', 884 6422528: 'blue', 885 6881280: 'index', 886 }
887 TeletextKey.blue = TeletextKey(6422528) 888 TeletextKey.green = TeletextKey(6750208) 889 TeletextKey.index = TeletextKey(6881280) 890 TeletextKey.red = TeletextKey(7471104) 891 TeletextKey.yellow = TeletextKey(7929856)
892 893 -class VideoLogoOption(_Enum):
894 '''Option values for libvlc_video_{get,set}_logo_{int,string}. 895 ''' 896 _enum_names_ = { 897 0: 'logo_enable', 898 1: 'logo_file', 899 2: 'logo_x', 900 3: 'logo_y', 901 4: 'logo_delay', 902 5: 'logo_repeat', 903 6: 'logo_opacity', 904 7: 'logo_position', 905 }
906 VideoLogoOption.logo_delay = VideoLogoOption(4) 907 VideoLogoOption.logo_enable = VideoLogoOption(0) 908 VideoLogoOption.logo_file = VideoLogoOption(1) 909 VideoLogoOption.logo_opacity = VideoLogoOption(6) 910 VideoLogoOption.logo_position = VideoLogoOption(7) 911 VideoLogoOption.logo_repeat = VideoLogoOption(5) 912 VideoLogoOption.logo_x = VideoLogoOption(2) 913 VideoLogoOption.logo_y = VideoLogoOption(3)
914 915 -class VideoAdjustOption(_Enum):
916 '''Option values for libvlc_video_{get,set}_adjust_{int,float,bool}. 917 ''' 918 _enum_names_ = { 919 0: 'Enable', 920 1: 'Contrast', 921 2: 'Brightness', 922 3: 'Hue', 923 4: 'Saturation', 924 5: 'Gamma', 925 }
926 VideoAdjustOption.Brightness = VideoAdjustOption(2) 927 VideoAdjustOption.Contrast = VideoAdjustOption(1) 928 VideoAdjustOption.Enable = VideoAdjustOption(0) 929 VideoAdjustOption.Gamma = VideoAdjustOption(5) 930 VideoAdjustOption.Hue = VideoAdjustOption(3) 931 VideoAdjustOption.Saturation = VideoAdjustOption(4)
932 933 -class AudioOutputDeviceTypes(_Enum):
934 '''Audio device types. 935 ''' 936 _enum_names_ = { 937 -1: 'Error', 938 1: 'Mono', 939 2: 'Stereo', 940 4: '_2F2R', 941 5: '_3F2R', 942 6: '_5_1', 943 7: '_6_1', 944 8: '_7_1', 945 10: 'SPDIF', 946 }
947 AudioOutputDeviceTypes.Error = AudioOutputDeviceTypes(-1) 948 AudioOutputDeviceTypes.Mono = AudioOutputDeviceTypes(1) 949 AudioOutputDeviceTypes.SPDIF = AudioOutputDeviceTypes(10) 950 AudioOutputDeviceTypes.Stereo = AudioOutputDeviceTypes(2) 951 AudioOutputDeviceTypes._2F2R = AudioOutputDeviceTypes(4) 952 AudioOutputDeviceTypes._3F2R = AudioOutputDeviceTypes(5) 953 AudioOutputDeviceTypes._5_1 = AudioOutputDeviceTypes(6) 954 AudioOutputDeviceTypes._6_1 = AudioOutputDeviceTypes(7) 955 AudioOutputDeviceTypes._7_1 = AudioOutputDeviceTypes(8)
956 957 -class AudioOutputChannel(_Enum):
958 '''Audio channels. 959 ''' 960 _enum_names_ = { 961 -1: 'Error', 962 1: 'Stereo', 963 2: 'RStereo', 964 3: 'Left', 965 4: 'Right', 966 5: 'Dolbys', 967 }
968 AudioOutputChannel.Dolbys = AudioOutputChannel(5) 969 AudioOutputChannel.Error = AudioOutputChannel(-1) 970 AudioOutputChannel.Left = AudioOutputChannel(3) 971 AudioOutputChannel.RStereo = AudioOutputChannel(2) 972 AudioOutputChannel.Right = AudioOutputChannel(4) 973 AudioOutputChannel.Stereo = AudioOutputChannel(1)
974 975 -class MediaPlayerRole(_Enum):
976 '''Media player roles. 977 \version libvlc 3.0.0 and later. 978 see \ref libvlc_media_player_set_role(). 979 ''' 980 _enum_names_ = { 981 0: '_None', 982 1: 'Music', 983 2: 'Video', 984 3: 'Communication', 985 4: 'Game', 986 5: 'Notification', 987 6: 'Animation', 988 7: 'Production', 989 8: 'Accessibility', 990 9: 'Test', 991 }
992 MediaPlayerRole.Accessibility = MediaPlayerRole(8) 993 MediaPlayerRole.Animation = MediaPlayerRole(6) 994 MediaPlayerRole.Communication = MediaPlayerRole(3) 995 MediaPlayerRole.Game = MediaPlayerRole(4) 996 MediaPlayerRole.Music = MediaPlayerRole(1) 997 MediaPlayerRole.Notification = MediaPlayerRole(5) 998 MediaPlayerRole.Production = MediaPlayerRole(7) 999 MediaPlayerRole.Test = MediaPlayerRole(9) 1000 MediaPlayerRole.Video = MediaPlayerRole(2) 1001 MediaPlayerRole._None = MediaPlayerRole(0)
1002 1003 -class PlaybackMode(_Enum):
1004 '''Defines playback modes for playlist. 1005 ''' 1006 _enum_names_ = { 1007 0: 'default', 1008 1: 'loop', 1009 2: 'repeat', 1010 }
1011 PlaybackMode.default = PlaybackMode(0) 1012 PlaybackMode.loop = PlaybackMode(1) 1013 PlaybackMode.repeat = PlaybackMode(2)
1014 1015 # End of generated enum types # 1016 1017 # From libvlc_structures.h 1018 1019 -class AudioOutput(_Cstruct):
1020
1021 - def __str__(self):
1022 return '%s(%s:%s)' % (self.__class__.__name__, self.name, self.description)
1023 1024 AudioOutput._fields_ = [ # recursive struct 1025 ('name', ctypes.c_char_p), 1026 ('description', ctypes.c_char_p), 1027 ('next', ctypes.POINTER(AudioOutput)), 1028 ]
1029 1030 -class LogMessage(_Cstruct):
1031 _fields_ = [ 1032 ('size', ctypes.c_uint ), 1033 ('severity', ctypes.c_int ), 1034 ('type', ctypes.c_char_p), 1035 ('name', ctypes.c_char_p), 1036 ('header', ctypes.c_char_p), 1037 ('message', ctypes.c_char_p), 1038 ] 1039
1040 - def __init__(self):
1041 super(LogMessage, self).__init__() 1042 self.size = ctypes.sizeof(self)
1043
1044 - def __str__(self):
1045 return '%s(%d:%s): %s' % (self.__class__.__name__, self.severity, self.type, self.message)
1046
1047 -class MediaEvent(_Cstruct):
1048 _fields_ = [ 1049 ('media_name', ctypes.c_char_p), 1050 ('instance_name', ctypes.c_char_p), 1051 ]
1052
1053 -class MediaStats(_Cstruct):
1054 _fields_ = [ 1055 ('read_bytes', ctypes.c_int ), 1056 ('input_bitrate', ctypes.c_float), 1057 ('demux_read_bytes', ctypes.c_int ), 1058 ('demux_bitrate', ctypes.c_float), 1059 ('demux_corrupted', ctypes.c_int ), 1060 ('demux_discontinuity', ctypes.c_int ), 1061 ('decoded_video', ctypes.c_int ), 1062 ('decoded_audio', ctypes.c_int ), 1063 ('displayed_pictures', ctypes.c_int ), 1064 ('lost_pictures', ctypes.c_int ), 1065 ('played_abuffers', ctypes.c_int ), 1066 ('lost_abuffers', ctypes.c_int ), 1067 ('sent_packets', ctypes.c_int ), 1068 ('sent_bytes', ctypes.c_int ), 1069 ('send_bitrate', ctypes.c_float), 1070 ]
1071
1072 -class MediaTrackInfo(_Cstruct):
1073 _fields_ = [ 1074 ('codec', ctypes.c_uint32), 1075 ('id', ctypes.c_int ), 1076 ('type', TrackType ), 1077 ('profile', ctypes.c_int ), 1078 ('level', ctypes.c_int ), 1079 ('channels_or_height', ctypes.c_uint ), 1080 ('rate_or_width', ctypes.c_uint ), 1081 ]
1082
1083 -class AudioTrack(_Cstruct):
1084 _fields_ = [ 1085 ('channels', ctypes.c_uint), 1086 ('rate', ctypes.c_uint), 1087 ]
1088
1089 -class VideoTrack(_Cstruct):
1090 _fields_ = [ 1091 ('height', ctypes.c_uint), 1092 ('width', ctypes.c_uint), 1093 ('sar_num', ctypes.c_uint), 1094 ('sar_den', ctypes.c_uint), 1095 ('frame_rate_num', ctypes.c_uint), 1096 ('frame_rate_den', ctypes.c_uint), 1097 ]
1098
1099 -class SubtitleTrack(_Cstruct):
1100 _fields_ = [ 1101 ('encoding', ctypes.c_char_p), 1102 ]
1103
1104 -class MediaTrackTracks(ctypes.Union):
1105 _fields_ = [ 1106 ('audio', ctypes.POINTER(AudioTrack)), 1107 ('video', ctypes.POINTER(VideoTrack)), 1108 ('subtitle', ctypes.POINTER(SubtitleTrack)), 1109 ]
1110
1111 -class MediaTrack(_Cstruct):
1112 _anonymous_ = ("u",) 1113 _fields_ = [ 1114 ('codec', ctypes.c_uint32), 1115 ('original_fourcc', ctypes.c_uint32), 1116 ('id', ctypes.c_int ), 1117 ('type', TrackType ), 1118 ('profile', ctypes.c_int ), 1119 ('level', ctypes.c_int ), 1120 1121 ('u', MediaTrackTracks), 1122 ('bitrate', ctypes.c_uint), 1123 ('language', ctypes.c_char_p), 1124 ('description', ctypes.c_char_p), 1125 ]
1126
1127 -class PlaylistItem(_Cstruct):
1128 _fields_ = [ 1129 ('id', ctypes.c_int ), 1130 ('uri', ctypes.c_char_p), 1131 ('name', ctypes.c_char_p), 1132 ] 1133
1134 - def __str__(self):
1135 return '%s #%d %s (uri %s)' % (self.__class__.__name__, self.id, self.name, self.uri)
1136
1137 -class Rectangle(_Cstruct):
1138 _fields_ = [ 1139 ('top', ctypes.c_int), 1140 ('left', ctypes.c_int), 1141 ('bottom', ctypes.c_int), 1142 ('right', ctypes.c_int), 1143 ]
1144
1145 -class TrackDescription(_Cstruct):
1146
1147 - def __str__(self):
1148 return '%s(%d:%s)' % (self.__class__.__name__, self.id, self.name)
1149 1150 TrackDescription._fields_ = [ # recursive struct 1151 ('id', ctypes.c_int ), 1152 ('name', ctypes.c_char_p), 1153 ('next', ctypes.POINTER(TrackDescription)), 1154 ]
1155 1156 -def track_description_list(head):
1157 """Convert a TrackDescription linked list to a Python list (and release the former). 1158 """ 1159 r = [] 1160 if head: 1161 item = head 1162 while item: 1163 item = item.contents 1164 r.append((item.id, item.name)) 1165 item = item.next 1166 try: 1167 libvlc_track_description_release(head) 1168 except NameError: 1169 libvlc_track_description_list_release(head) 1170 1171 return r
1172
1173 -class EventUnion(ctypes.Union):
1174 _fields_ = [ 1175 ('meta_type', ctypes.c_uint ), 1176 ('new_child', ctypes.c_uint ), 1177 ('new_duration', ctypes.c_longlong), 1178 ('new_status', ctypes.c_int ), 1179 ('media', ctypes.c_void_p ), 1180 ('new_state', ctypes.c_uint ), 1181 # FIXME: Media instance 1182 ('new_cache', ctypes.c_float ), 1183 ('new_position', ctypes.c_float ), 1184 ('new_time', ctypes.c_longlong), 1185 ('new_title', ctypes.c_int ), 1186 ('new_seekable', ctypes.c_longlong), 1187 ('new_pausable', ctypes.c_longlong), 1188 ('new_scrambled', ctypes.c_longlong), 1189 ('new_count', ctypes.c_longlong), 1190 # FIXME: Skipped MediaList and MediaListView... 1191 ('filename', ctypes.c_char_p ), 1192 ('new_length', ctypes.c_longlong), 1193 ('media_event', MediaEvent ), 1194 ]
1195
1196 -class Event(_Cstruct):
1197 _fields_ = [ 1198 ('type', EventType ), 1199 ('object', ctypes.c_void_p), 1200 ('u', EventUnion ), 1201 ]
1202
1203 -class ModuleDescription(_Cstruct):
1204
1205 - def __str__(self):
1206 return '%s %s (%s)' % (self.__class__.__name__, self.shortname, self.name)
1207 1208 ModuleDescription._fields_ = [ # recursive struct 1209 ('name', ctypes.c_char_p), 1210 ('shortname', ctypes.c_char_p), 1211 ('longname', ctypes.c_char_p), 1212 ('help', ctypes.c_char_p), 1213 ('next', ctypes.POINTER(ModuleDescription)), 1214 ]
1215 1216 -def module_description_list(head):
1217 """Convert a ModuleDescription linked list to a Python list (and release the former). 1218 """ 1219 r = [] 1220 if head: 1221 item = head 1222 while item: 1223 item = item.contents 1224 r.append((item.name, item.shortname, item.longname, item.help)) 1225 item = item.next 1226 libvlc_module_description_list_release(head) 1227 return r
1228
1229 -class AudioOutputDevice(_Cstruct):
1230
1231 - def __str__(self):
1232 return '%s(%d:%s)' % (self.__class__.__name__, self.id, self.name)
1233 1234 AudioOutputDevice._fields_ = [ # recursive struct 1235 ('next', ctypes.POINTER(AudioOutputDevice)), 1236 ('device', ctypes.c_char_p ), 1237 ('description', ctypes.c_char_p), 1238 ]
1239 1240 -class TitleDescription(_Cstruct):
1241 _fields_ = [ 1242 ('duration', ctypes.c_longlong), 1243 ('name', ctypes.c_char_p), 1244 ('menu', ctypes.c_bool), 1245 ]
1246
1247 -class ChapterDescription(_Cstruct):
1248 _fields_ = [ 1249 ('time_offset', ctypes.c_longlong), 1250 ('duration', ctypes.c_longlong), 1251 ('name', ctypes.c_char_p), 1252 ]
1253
1254 -class VideoViewpoint(_Cstruct):
1255 _fields_ = [ 1256 ('yaw', ctypes.c_float), 1257 ('pitch', ctypes.c_float), 1258 ('roll', ctypes.c_float), 1259 ('field_of_view', ctypes.c_float), 1260 ]
1261
1262 -class MediaDiscovererDescription(_Cstruct):
1263 _fields_ = [ 1264 ('name', ctypes.c_char_p), 1265 ('longname', ctypes.c_char_p), 1266 ('cat', MediaDiscovererCategory), 1267 ] 1268
1269 - def __str__(self):
1270 return '%s %s (%d) - %s' % (self.__class__.__name__, self.name, self.cat, self.longname)
1271 1272 # This struct depends on the MediaSlaveType enum that is defined only 1273 # in > 2.2 1274 if 'MediaSlaveType' in locals():
1275 - class MediaSlave(_Cstruct):
1276 _fields_ = [ 1277 ('psz_uri', ctypes.c_char_p), 1278 ('i_type', MediaSlaveType), 1279 ('i_priority', ctypes.c_uint) 1280 ]
1281
1282 -class RDDescription(_Cstruct):
1283 _fields_ = [ 1284 ('name', ctypes.c_char_p), 1285 ('longname', ctypes.c_char_p) 1286 ]
1287
1288 1289 -class MediaThumbnailRequest:
1290 - def __new__(cls, *args):
1291 if len(args) == 1 and isinstance(args[0], _Ints): 1292 return _Constructor(cls, args[0])
1293
1294 -class Direct3dDeviceSetup(_Cstruct):
1295 _fields_ = [ 1296 ('device_context', ctypes.c_void_p), 1297 ]
1298
1299 -class Direct3dDeviceCfg(_Cstruct):
1300 _fields_ = [ 1301 ('hardware_decoding', ctypes.c_bool), 1302 ]
1303
1304 -class Direct3dCfg(_Cstruct):
1305 _fields_ = [ 1306 ('width', ctypes.c_uint), 1307 ('height', ctypes.c_uint), 1308 ('bitdepth', ctypes.c_uint), 1309 ('full_range', ctypes.c_bool), 1310 # FIXME: should be references to enums 1311 ('colorspace', ctypes.c_uint), 1312 ('primaries', ctypes.c_uint), 1313 ('transfer', ctypes.c_uint), 1314 ]
1315
1316 -class VideoOutputCfg(_Cstruct):
1317 _fields_ = [ 1318 ('surface_format', ctypes.c_int), 1319 ('full_range', ctypes.c_bool), 1320 # FIXME: should be references to enums 1321 ('colorspace', ctypes.c_uint), 1322 ('primaries', ctypes.c_uint), 1323 ('transfer', ctypes.c_uint), 1324 ]
1325
1326 -class Direct3dHdr10Metadata(_Cstruct):
1327 _fields_ = [ 1328 ('RedPrimary ', ctypes.c_uint16 * 2), 1329 ('GreenPrimary', ctypes.c_uint16 * 2), 1330 ('BluePrimary', ctypes.c_uint16 * 2), 1331 ('WhitePoint', ctypes.c_uint16 * 2), 1332 ('MaxMasteringLuminance', ctypes.c_uint), 1333 ('MinMasteringLuminance', ctypes.c_uint), 1334 ('MaxContentLightLevel', ctypes.c_uint16), 1335 ('MaxFrameAverageLightLevel', ctypes.c_uint16), 1336 ]
1337
1338 -class VideoSetupDeviceCfg(_Cstruct):
1339 _fields_ = [ 1340 ('hardware_decoding', ctypes.c_bool), 1341 ]
1342
1343 -class VideoSetupDeviceInfo(_Cstruct):
1344 # FIXME: this is normally a union for D3D11/D3D9. We only define 1345 # the mapping for d3d11 here 1346 _fields_ = [ 1347 ('device_context', ctypes.c_void_p), 1348 ]
1349
1350 -class VideoRenderCfg(_Cstruct):
1351 _fields_ = [ 1352 ('width', ctypes.c_uint), 1353 ('height', ctypes.c_uint), 1354 ('bitdepth', ctypes.c_uint), 1355 ('full_range', ctypes.c_bool), 1356 # FIXME: should be references to enums 1357 ('colorspace', ctypes.c_uint), 1358 ('primaries', ctypes.c_uint), 1359 ('transfer', ctypes.c_uint), 1360 ('device', ctypes.c_void_p), 1361 ]
1362
1363 # Generated callback definitions # 1364 -class Callback(ctypes.c_void_p):
1365 """Callback function notification. 1366 @param p_event: the event triggering the callback. 1367 """ 1368 pass
1369 -class LogCb(ctypes.c_void_p):
1370 """Callback prototype for LibVLC log message handler. 1371 @param data: data pointer as given to L{libvlc_log_set}(). 1372 @param level: message level (@ref L{LogLevel}). 1373 @param ctx: message context (meta-information about the message). 1374 @param fmt: printf() format string (as defined by ISO C11). 1375 @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. 1376 """ 1377 pass
1378 -class MediaOpenCb(ctypes.c_void_p):
1379 """Callback prototype to open a custom bitstream input media. 1380 The same media item can be opened multiple times. Each time, this callback 1381 is invoked. It should allocate and initialize any instance-specific 1382 resources, then store them in *datap. The instance resources can be freed 1383 in the @ref libvlc_media_close_cb callback. 1384 @param opaque: private pointer as passed to L{libvlc_media_new_callbacks}(). 1385 @return: datap storage space for a private data pointer, sizep byte length of the bitstream or UINT64_MAX if unknown. 1386 """ 1387 pass
1388 -class MediaReadCb(ctypes.c_void_p):
1389 """Callback prototype to read data from a custom bitstream input media. 1390 @param opaque: private pointer as set by the @ref libvlc_media_open_cb callback. 1391 @param buf: start address of the buffer to read data into. 1392 @param len: bytes length of the buffer. 1393 @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. 1394 """ 1395 pass
1396 -class MediaSeekCb(ctypes.c_void_p):
1397 """Callback prototype to seek a custom bitstream input media. 1398 @param opaque: private pointer as set by the @ref libvlc_media_open_cb callback. 1399 @param offset: absolute byte offset to seek to. 1400 @return: 0 on success, -1 on error. 1401 """ 1402 pass
1403 -class MediaCloseCb(ctypes.c_void_p):
1404 """Callback prototype to close a custom bitstream input media. 1405 @param opaque: private pointer as set by the @ref libvlc_media_open_cb callback. 1406 """ 1407 pass
1408 -class VideoLockCb(ctypes.c_void_p):
1409 """Callback prototype to allocate and lock a picture buffer. 1410 Whenever a new video frame needs to be decoded, the lock callback is 1411 invoked. Depending on the video chroma, one or three pixel planes of 1412 adequate dimensions must be returned via the second parameter. Those 1413 planes must be aligned on 32-bytes boundaries. 1414 @param opaque: private pointer as passed to L{libvlc_video_set_callbacks}() [IN]. 1415 @param planes: start address of the pixel planes (LibVLC allocates the array of void pointers, this callback must initialize the array) [OUT]. 1416 @return: a private pointer for the display and unlock callbacks to identify the picture buffers. 1417 """ 1418 pass
1419 -class VideoUnlockCb(ctypes.c_void_p):
1420 """Callback prototype to unlock a picture buffer. 1421 When the video frame decoding is complete, the unlock callback is invoked. 1422 This callback might not be needed at all. It is only an indication that the 1423 application can now read the pixel values if it needs to. 1424 @note: A picture buffer is unlocked after the picture is decoded, 1425 but before the picture is displayed. 1426 @param opaque: private pointer as passed to L{libvlc_video_set_callbacks}() [IN]. 1427 @param picture: private pointer returned from the @ref libvlc_video_lock_cb callback [IN]. 1428 @param planes: pixel planes as defined by the @ref libvlc_video_lock_cb callback (this parameter is only for convenience) [IN]. 1429 """ 1430 pass
1431 -class VideoDisplayCb(ctypes.c_void_p):
1432 """Callback prototype to display a picture. 1433 When the video frame needs to be shown, as determined by the media playback 1434 clock, the display callback is invoked. 1435 @param opaque: private pointer as passed to L{libvlc_video_set_callbacks}() [IN]. 1436 @param picture: private pointer returned from the @ref libvlc_video_lock_cb callback [IN]. 1437 """ 1438 pass
1439 -class VideoFormatCb(ctypes.c_void_p):
1440 """Callback prototype to configure picture buffers format. 1441 This callback gets the format of the video as output by the video decoder 1442 and the chain of video filters (if any). It can opt to change any parameter 1443 as it needs. In that case, LibVLC will attempt to convert the video format 1444 (rescaling and chroma conversion) but these operations can be CPU intensive. 1445 @param opaque: pointer to the private pointer passed to L{libvlc_video_set_callbacks}() [IN/OUT]. 1446 @param chroma: pointer to the 4 bytes video format identifier [IN/OUT]. 1447 @param width: pointer to the pixel width [IN/OUT]. 1448 @param height: pointer to the pixel height [IN/OUT]. 1449 @param pitches: table of scanline pitches in bytes for each pixel plane (the table is allocated by LibVLC) [OUT]. 1450 @return: lines table of scanlines count for each plane. 1451 """ 1452 pass
1453 -class VideoCleanupCb(ctypes.c_void_p):
1454 """Callback prototype to configure picture buffers format. 1455 @param opaque: private pointer as passed to L{libvlc_video_set_callbacks}() (and possibly modified by @ref libvlc_video_format_cb) [IN]. 1456 """ 1457 pass
1458 -class AudioPlayCb(ctypes.c_void_p):
1459 """Callback prototype for audio playback. 1460 The LibVLC media player decodes and post-processes the audio signal 1461 asynchronously (in an internal thread). Whenever audio samples are ready 1462 to be queued to the output, this callback is invoked. 1463 The number of samples provided per invocation may depend on the file format, 1464 the audio coding algorithm, the decoder plug-in, the post-processing 1465 filters and timing. Application must not assume a certain number of samples. 1466 The exact format of audio samples is determined by L{libvlc_audio_set_format}() 1467 or L{libvlc_audio_set_format_callbacks}() as is the channels layout. 1468 Note that the number of samples is per channel. For instance, if the audio 1469 track sampling rate is 48000 Hz, then 1200 samples represent 25 milliseconds 1470 of audio signal - regardless of the number of audio channels. 1471 @param data: data pointer as passed to L{libvlc_audio_set_callbacks}() [IN]. 1472 @param samples: pointer to a table of audio samples to play back [IN]. 1473 @param count: number of audio samples to play back. 1474 @param pts: expected play time stamp (see libvlc_delay()). 1475 """ 1476 pass
1477 -class AudioPauseCb(ctypes.c_void_p):
1478 """Callback prototype for audio pause. 1479 LibVLC invokes this callback to pause audio playback. 1480 @note: The pause callback is never called if the audio is already paused. 1481 @param data: data pointer as passed to L{libvlc_audio_set_callbacks}() [IN]. 1482 @param pts: time stamp of the pause request (should be elapsed already). 1483 """ 1484 pass
1485 -class AudioResumeCb(ctypes.c_void_p):
1486 """Callback prototype for audio resumption. 1487 LibVLC invokes this callback to resume audio playback after it was 1488 previously paused. 1489 @note: The resume callback is never called if the audio is not paused. 1490 @param data: data pointer as passed to L{libvlc_audio_set_callbacks}() [IN]. 1491 @param pts: time stamp of the resumption request (should be elapsed already). 1492 """ 1493 pass
1494 -class AudioFlushCb(ctypes.c_void_p):
1495 """Callback prototype for audio buffer flush. 1496 LibVLC invokes this callback if it needs to discard all pending buffers and 1497 stop playback as soon as possible. This typically occurs when the media is 1498 stopped. 1499 @param data: data pointer as passed to L{libvlc_audio_set_callbacks}() [IN]. 1500 """ 1501 pass
1502 -class AudioDrainCb(ctypes.c_void_p):
1503 """Callback prototype for audio buffer drain. 1504 LibVLC may invoke this callback when the decoded audio track is ending. 1505 There will be no further decoded samples for the track, but playback should 1506 nevertheless continue until all already pending buffers are rendered. 1507 @param data: data pointer as passed to L{libvlc_audio_set_callbacks}() [IN]. 1508 """ 1509 pass
1510 -class AudioSetVolumeCb(ctypes.c_void_p):
1511 """Callback prototype for audio volume change. 1512 @param data: data pointer as passed to L{libvlc_audio_set_callbacks}() [IN]. 1513 @param volume: software volume (1. = nominal, 0. = mute). 1514 @param mute: muted flag. 1515 """ 1516 pass
1517 -class AudioSetupCb(ctypes.c_void_p):
1518 """Callback prototype to setup the audio playback. 1519 This is called when the media player needs to create a new audio output. 1520 @param opaque: pointer to the data pointer passed to L{libvlc_audio_set_callbacks}() [IN/OUT]. 1521 @param format: 4 bytes sample format [IN/OUT]. 1522 @param rate: sample rate [IN/OUT]. 1523 @param channels: channels count [IN/OUT]. 1524 @return: 0 on success, anything else to skip audio playback. 1525 """ 1526 pass
1527 -class AudioCleanupCb(ctypes.c_void_p):
1528 """Callback prototype for audio playback cleanup. 1529 This is called when the media player no longer needs an audio output. 1530 @param opaque: data pointer as passed to L{libvlc_audio_set_callbacks}() [IN]. 1531 """ 1532 pass
1533 -class CallbackDecorators(object):
1534 "Class holding various method decorators for callback functions." 1535 Callback = ctypes.CFUNCTYPE(None, ctypes.c_void_p, ctypes.c_void_p) 1536 Callback.__doc__ = '''Callback function notification. 1537 @param p_event: the event triggering the callback. 1538 ''' 1539 LogCb = ctypes.CFUNCTYPE(None, ctypes.c_void_p, ctypes.c_int, Log_ptr, ctypes.c_char_p, ctypes.c_void_p) 1540 LogCb.__doc__ = '''Callback prototype for LibVLC log message handler. 1541 @param data: data pointer as given to L{libvlc_log_set}(). 1542 @param level: message level (@ref L{LogLevel}). 1543 @param ctx: message context (meta-information about the message). 1544 @param fmt: printf() format string (as defined by ISO C11). 1545 @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. 1546 ''' 1547 MediaOpenCb = ctypes.CFUNCTYPE(ctypes.c_int, ctypes.c_void_p, ctypes.POINTER(ctypes.c_void_p), ctypes.POINTER(ctypes.c_uint64)) 1548 MediaOpenCb.__doc__ = '''Callback prototype to open a custom bitstream input media. 1549 The same media item can be opened multiple times. Each time, this callback 1550 is invoked. It should allocate and initialize any instance-specific 1551 resources, then store them in *datap. The instance resources can be freed 1552 in the @ref libvlc_media_close_cb callback. 1553 @param opaque: private pointer as passed to L{libvlc_media_new_callbacks}(). 1554 @return: datap storage space for a private data pointer, sizep byte length of the bitstream or UINT64_MAX if unknown. 1555 ''' 1556 MediaReadCb = ctypes.CFUNCTYPE(ctypes.c_ssize_t, ctypes.c_void_p, ctypes.POINTER(ctypes.c_char), ctypes.c_size_t) 1557 MediaReadCb.__doc__ = '''Callback prototype to read data from a custom bitstream input media. 1558 @param opaque: private pointer as set by the @ref libvlc_media_open_cb callback. 1559 @param buf: start address of the buffer to read data into. 1560 @param len: bytes length of the buffer. 1561 @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. 1562 ''' 1563 MediaSeekCb = ctypes.CFUNCTYPE(ctypes.c_int, ctypes.c_void_p, ctypes.c_uint64) 1564 MediaSeekCb.__doc__ = '''Callback prototype to seek a custom bitstream input media. 1565 @param opaque: private pointer as set by the @ref libvlc_media_open_cb callback. 1566 @param offset: absolute byte offset to seek to. 1567 @return: 0 on success, -1 on error. 1568 ''' 1569 MediaCloseCb = ctypes.CFUNCTYPE(None, ctypes.c_void_p) 1570 MediaCloseCb.__doc__ = '''Callback prototype to close a custom bitstream input media. 1571 @param opaque: private pointer as set by the @ref libvlc_media_open_cb callback. 1572 ''' 1573 VideoLockCb = ctypes.CFUNCTYPE(ctypes.c_void_p, ctypes.c_void_p, ctypes.POINTER(ctypes.c_void_p)) 1574 VideoLockCb.__doc__ = '''Callback prototype to allocate and lock a picture buffer. 1575 Whenever a new video frame needs to be decoded, the lock callback is 1576 invoked. Depending on the video chroma, one or three pixel planes of 1577 adequate dimensions must be returned via the second parameter. Those 1578 planes must be aligned on 32-bytes boundaries. 1579 @param opaque: private pointer as passed to L{libvlc_video_set_callbacks}() [IN]. 1580 @param planes: start address of the pixel planes (LibVLC allocates the array of void pointers, this callback must initialize the array) [OUT]. 1581 @return: a private pointer for the display and unlock callbacks to identify the picture buffers. 1582 ''' 1583 VideoUnlockCb = ctypes.CFUNCTYPE(None, ctypes.c_void_p, ctypes.c_void_p, ctypes.POINTER(ctypes.c_void_p)) 1584 VideoUnlockCb.__doc__ = '''Callback prototype to unlock a picture buffer. 1585 When the video frame decoding is complete, the unlock callback is invoked. 1586 This callback might not be needed at all. It is only an indication that the 1587 application can now read the pixel values if it needs to. 1588 @note: A picture buffer is unlocked after the picture is decoded, 1589 but before the picture is displayed. 1590 @param opaque: private pointer as passed to L{libvlc_video_set_callbacks}() [IN]. 1591 @param picture: private pointer returned from the @ref libvlc_video_lock_cb callback [IN]. 1592 @param planes: pixel planes as defined by the @ref libvlc_video_lock_cb callback (this parameter is only for convenience) [IN]. 1593 ''' 1594 VideoDisplayCb = ctypes.CFUNCTYPE(None, ctypes.c_void_p, ctypes.c_void_p) 1595 VideoDisplayCb.__doc__ = '''Callback prototype to display a picture. 1596 When the video frame needs to be shown, as determined by the media playback 1597 clock, the display callback is invoked. 1598 @param opaque: private pointer as passed to L{libvlc_video_set_callbacks}() [IN]. 1599 @param picture: private pointer returned from the @ref libvlc_video_lock_cb callback [IN]. 1600 ''' 1601 VideoFormatCb = ctypes.CFUNCTYPE(ctypes.c_uint, ctypes.POINTER(ctypes.c_void_p), ctypes.c_char_p, ctypes.POINTER(ctypes.c_uint), ctypes.POINTER(ctypes.c_uint), ctypes.POINTER(ctypes.c_uint), ctypes.POINTER(ctypes.c_uint)) 1602 VideoFormatCb.__doc__ = '''Callback prototype to configure picture buffers format. 1603 This callback gets the format of the video as output by the video decoder 1604 and the chain of video filters (if any). It can opt to change any parameter 1605 as it needs. In that case, LibVLC will attempt to convert the video format 1606 (rescaling and chroma conversion) but these operations can be CPU intensive. 1607 @param opaque: pointer to the private pointer passed to L{libvlc_video_set_callbacks}() [IN/OUT]. 1608 @param chroma: pointer to the 4 bytes video format identifier [IN/OUT]. 1609 @param width: pointer to the pixel width [IN/OUT]. 1610 @param height: pointer to the pixel height [IN/OUT]. 1611 @param pitches: table of scanline pitches in bytes for each pixel plane (the table is allocated by LibVLC) [OUT]. 1612 @return: lines table of scanlines count for each plane. 1613 ''' 1614 VideoCleanupCb = ctypes.CFUNCTYPE(None, ctypes.c_void_p) 1615 VideoCleanupCb.__doc__ = '''Callback prototype to configure picture buffers format. 1616 @param opaque: private pointer as passed to L{libvlc_video_set_callbacks}() (and possibly modified by @ref libvlc_video_format_cb) [IN]. 1617 ''' 1618 AudioPlayCb = ctypes.CFUNCTYPE(None, ctypes.c_void_p, ctypes.c_void_p, ctypes.c_uint, ctypes.c_int64) 1619 AudioPlayCb.__doc__ = '''Callback prototype for audio playback. 1620 The LibVLC media player decodes and post-processes the audio signal 1621 asynchronously (in an internal thread). Whenever audio samples are ready 1622 to be queued to the output, this callback is invoked. 1623 The number of samples provided per invocation may depend on the file format, 1624 the audio coding algorithm, the decoder plug-in, the post-processing 1625 filters and timing. Application must not assume a certain number of samples. 1626 The exact format of audio samples is determined by L{libvlc_audio_set_format}() 1627 or L{libvlc_audio_set_format_callbacks}() as is the channels layout. 1628 Note that the number of samples is per channel. For instance, if the audio 1629 track sampling rate is 48000 Hz, then 1200 samples represent 25 milliseconds 1630 of audio signal - regardless of the number of audio channels. 1631 @param data: data pointer as passed to L{libvlc_audio_set_callbacks}() [IN]. 1632 @param samples: pointer to a table of audio samples to play back [IN]. 1633 @param count: number of audio samples to play back. 1634 @param pts: expected play time stamp (see libvlc_delay()). 1635 ''' 1636 AudioPauseCb = ctypes.CFUNCTYPE(None, ctypes.c_void_p, ctypes.c_int64) 1637 AudioPauseCb.__doc__ = '''Callback prototype for audio pause. 1638 LibVLC invokes this callback to pause audio playback. 1639 @note: The pause callback is never called if the audio is already paused. 1640 @param data: data pointer as passed to L{libvlc_audio_set_callbacks}() [IN]. 1641 @param pts: time stamp of the pause request (should be elapsed already). 1642 ''' 1643 AudioResumeCb = ctypes.CFUNCTYPE(None, ctypes.c_void_p, ctypes.c_int64) 1644 AudioResumeCb.__doc__ = '''Callback prototype for audio resumption. 1645 LibVLC invokes this callback to resume audio playback after it was 1646 previously paused. 1647 @note: The resume callback is never called if the audio is not paused. 1648 @param data: data pointer as passed to L{libvlc_audio_set_callbacks}() [IN]. 1649 @param pts: time stamp of the resumption request (should be elapsed already). 1650 ''' 1651 AudioFlushCb = ctypes.CFUNCTYPE(None, ctypes.c_void_p, ctypes.c_int64) 1652 AudioFlushCb.__doc__ = '''Callback prototype for audio buffer flush. 1653 LibVLC invokes this callback if it needs to discard all pending buffers and 1654 stop playback as soon as possible. This typically occurs when the media is 1655 stopped. 1656 @param data: data pointer as passed to L{libvlc_audio_set_callbacks}() [IN]. 1657 ''' 1658 AudioDrainCb = ctypes.CFUNCTYPE(None, ctypes.c_void_p) 1659 AudioDrainCb.__doc__ = '''Callback prototype for audio buffer drain. 1660 LibVLC may invoke this callback when the decoded audio track is ending. 1661 There will be no further decoded samples for the track, but playback should 1662 nevertheless continue until all already pending buffers are rendered. 1663 @param data: data pointer as passed to L{libvlc_audio_set_callbacks}() [IN]. 1664 ''' 1665 AudioSetVolumeCb = ctypes.CFUNCTYPE(None, ctypes.c_void_p, ctypes.c_float, ctypes.c_bool) 1666 AudioSetVolumeCb.__doc__ = '''Callback prototype for audio volume change. 1667 @param data: data pointer as passed to L{libvlc_audio_set_callbacks}() [IN]. 1668 @param volume: software volume (1. = nominal, 0. = mute). 1669 @param mute: muted flag. 1670 ''' 1671 AudioSetupCb = ctypes.CFUNCTYPE(ctypes.c_int, ctypes.POINTER(ctypes.c_void_p), ctypes.c_char_p, ctypes.POINTER(ctypes.c_uint), ctypes.POINTER(ctypes.c_uint)) 1672 AudioSetupCb.__doc__ = '''Callback prototype to setup the audio playback. 1673 This is called when the media player needs to create a new audio output. 1674 @param opaque: pointer to the data pointer passed to L{libvlc_audio_set_callbacks}() [IN/OUT]. 1675 @param format: 4 bytes sample format [IN/OUT]. 1676 @param rate: sample rate [IN/OUT]. 1677 @param channels: channels count [IN/OUT]. 1678 @return: 0 on success, anything else to skip audio playback. 1679 ''' 1680 AudioCleanupCb = ctypes.CFUNCTYPE(None, ctypes.c_void_p) 1681 AudioCleanupCb.__doc__ = '''Callback prototype for audio playback cleanup. 1682 This is called when the media player no longer needs an audio output. 1683 @param opaque: data pointer as passed to L{libvlc_audio_set_callbacks}() [IN]. 1684 '''
1685 cb = CallbackDecorators
1686 # End of generated enum types # 1687 1688 # End of header.py # 1689 -class AudioEqualizer(_Ctype):
1690 '''Create a new default equalizer, with all frequency values zeroed. 1691 1692 The new equalizer can subsequently be applied to a media player by invoking 1693 L{MediaPlayer.set_equalizer}. 1694 The returned handle should be freed via libvlc_audio_equalizer_release() when 1695 it is no longer needed. 1696 ''' 1697
1698 - def __new__(cls, *args):
1699 if len(args) == 1 and isinstance(args[0], _Ints): 1700 return _Constructor(cls, args[0]) 1701 return libvlc_audio_equalizer_new()
1702 1703
1704 - def release(self):
1705 '''Release a previously created equalizer instance. 1706 The equalizer was previously created by using L{new}() or 1707 L{new_from_preset}(). 1708 It is safe to invoke this method with a None p_equalizer parameter for no effect. 1709 @version: LibVLC 2.2.0 or later. 1710 ''' 1711 return libvlc_audio_equalizer_release(self)
1712 1713
1714 - def set_preamp(self, f_preamp):
1715 '''Set a new pre-amplification value for an equalizer. 1716 The new equalizer settings are subsequently applied to a media player by invoking 1717 L{media_player_set_equalizer}(). 1718 The supplied amplification value will be clamped to the -20.0 to +20.0 range. 1719 @param f_preamp: preamp value (-20.0 to 20.0 Hz). 1720 @return: zero on success, -1 on error. 1721 @version: LibVLC 2.2.0 or later. 1722 ''' 1723 return libvlc_audio_equalizer_set_preamp(self, f_preamp)
1724 1725
1726 - def get_preamp(self):
1727 '''Get the current pre-amplification value from an equalizer. 1728 @return: preamp value (Hz). 1729 @version: LibVLC 2.2.0 or later. 1730 ''' 1731 return libvlc_audio_equalizer_get_preamp(self)
1732 1733
1734 - def set_amp_at_index(self, f_amp, u_band):
1735 '''Set a new amplification value for a particular equalizer frequency band. 1736 The new equalizer settings are subsequently applied to a media player by invoking 1737 L{media_player_set_equalizer}(). 1738 The supplied amplification value will be clamped to the -20.0 to +20.0 range. 1739 @param f_amp: amplification value (-20.0 to 20.0 Hz). 1740 @param u_band: index, counting from zero, of the frequency band to set. 1741 @return: zero on success, -1 on error. 1742 @version: LibVLC 2.2.0 or later. 1743 ''' 1744 return libvlc_audio_equalizer_set_amp_at_index(self, f_amp, u_band)
1745 1746
1747 - def get_amp_at_index(self, u_band):
1748 '''Get the amplification value for a particular equalizer frequency band. 1749 @param u_band: index, counting from zero, of the frequency band to get. 1750 @return: amplification value (Hz); NaN if there is no such frequency band. 1751 @version: LibVLC 2.2.0 or later. 1752 ''' 1753 return libvlc_audio_equalizer_get_amp_at_index(self, u_band)
1754
1755 -class EventManager(_Ctype):
1756 '''Create an event manager with callback handler. 1757 1758 This class interposes the registration and handling of 1759 event notifications in order to (a) remove the need for 1760 decorating each callback functions with the decorator 1761 '@callbackmethod', (b) allow any number of positional 1762 and/or keyword arguments to the callback (in addition 1763 to the Event instance) and (c) to preserve the Python 1764 objects such that the callback and argument objects 1765 remain alive (i.e. are not garbage collected) until 1766 B{after} the notification has been unregistered. 1767 1768 @note: Only a single notification can be registered 1769 for each event type in an EventManager instance. 1770 1771 ''' 1772 1773 _callback_handler = None 1774 _callbacks = {} 1775
1776 - def __new__(cls, ptr=_internal_guard):
1777 if ptr == _internal_guard: 1778 raise VLCException("(INTERNAL) ctypes class.\nYou should get a reference to EventManager through the MediaPlayer.event_manager() method.") 1779 return _Constructor(cls, ptr)
1780
1781 - def event_attach(self, eventtype, callback, *args, **kwds):
1782 """Register an event notification. 1783 1784 @param eventtype: the desired event type to be notified about. 1785 @param callback: the function to call when the event occurs. 1786 @param args: optional positional arguments for the callback. 1787 @param kwds: optional keyword arguments for the callback. 1788 @return: 0 on success, ENOMEM on error. 1789 1790 @note: The callback function must have at least one argument, 1791 an Event instance. Any other, optional positional and keyword 1792 arguments are in B{addition} to the first one. Warning: libvlc 1793 is not reentrant, i.e. you cannot call libvlc functions from 1794 an event handler. They must be called from the main 1795 application thread. 1796 """ 1797 if not isinstance(eventtype, EventType): 1798 raise VLCException("%s required: %r" % ('EventType', eventtype)) 1799 if not hasattr(callback, '__call__'): # callable() 1800 raise VLCException("%s required: %r" % ('callable', callback)) 1801 # check that the callback expects arguments 1802 if not any(getargspec(callback)[:2]): # list(...) 1803 raise VLCException("%s required: %r" % ('argument', callback)) 1804 1805 if self._callback_handler is None: 1806 _called_from_ctypes = ctypes.CFUNCTYPE(None, ctypes.POINTER(Event), ctypes.c_void_p) 1807 @_called_from_ctypes 1808 def _callback_handler(event, k): 1809 """(INTERNAL) handle callback call from ctypes. 1810 1811 @note: We cannot simply make this an EventManager 1812 method since ctypes does not prepend self as the 1813 first parameter, hence this closure. 1814 """ 1815 try: # retrieve Python callback and arguments 1816 call, args, kwds = self._callbacks[k] 1817 except KeyError: # detached? 1818 pass 1819 else: 1820 # deref event.contents to simplify callback code 1821 call(event.contents, *args, **kwds)
1822 self._callback_handler = _callback_handler 1823 self._callbacks = {} 1824 1825 k = eventtype.value 1826 r = libvlc_event_attach(self, k, self._callback_handler, k) 1827 if not r: 1828 self._callbacks[k] = (callback, args, kwds) 1829 return r
1830
1831 - def event_detach(self, eventtype):
1832 """Unregister an event notification. 1833 1834 @param eventtype: the event type notification to be removed. 1835 """ 1836 if not isinstance(eventtype, EventType): 1837 raise VLCException("%s required: %r" % ('EventType', eventtype)) 1838 1839 k = eventtype.value 1840 if k in self._callbacks: 1841 del self._callbacks[k] # remove, regardless of libvlc return value 1842 libvlc_event_detach(self, k, self._callback_handler, k)
1843
1844 1845 -class Instance(_Ctype):
1846 '''Create a new Instance instance. 1847 1848 It may take as parameter either: 1849 - a string 1850 - a list of strings as first parameters 1851 - the parameters given as the constructor parameters (must be strings) 1852 1853 ''' 1854
1855 - def __new__(cls, *args):
1856 if len(args) == 1: 1857 # Only 1 arg. It is either a C pointer, or an arg string, 1858 # or a tuple. 1859 i = args[0] 1860 if isinstance(i, _Ints): 1861 return _Constructor(cls, i) 1862 elif isinstance(i, basestring): 1863 args = i.strip().split() 1864 elif isinstance(i, _Seqs): 1865 args = list(i) 1866 else: 1867 raise VLCException('Instance %r' % (args,)) 1868 else: 1869 args = list(args) 1870 1871 if not args: # no parameters passed 1872 args = ['vlc'] 1873 elif args[0] != 'vlc': 1874 args.insert(0, 'vlc') 1875 1876 if plugin_path is not None: 1877 # set plugin_path if detected, win32 and MacOS, 1878 # if the user did not specify it itself. 1879 os.environ.setdefault('VLC_PLUGIN_PATH', plugin_path) 1880 1881 if PYTHON3: 1882 args = [ str_to_bytes(a) for a in args ] 1883 return libvlc_new(len(args), args)
1884
1885 - def media_player_new(self, uri=None):
1886 """Create a new MediaPlayer instance. 1887 1888 @param uri: an optional URI to play in the player as a str, bytes or PathLike object. 1889 """ 1890 p = libvlc_media_player_new(self) 1891 if uri: 1892 p.set_media(self.media_new(uri)) 1893 p._instance = self 1894 return p
1895
1896 - def media_list_player_new(self):
1897 """Create a new MediaListPlayer instance. 1898 """ 1899 p = libvlc_media_list_player_new(self) 1900 p._instance = self 1901 return p
1902
1903 - def media_new(self, mrl, *options):
1904 """Create a new Media instance. 1905 1906 If mrl contains a colon (:) preceded by more than 1 letter, it 1907 will be treated as a URL. Else, it will be considered as a 1908 local path. If you need more control, directly use 1909 media_new_location/media_new_path methods. 1910 1911 Options can be specified as supplementary string parameters, 1912 but note that many options cannot be set at the media level, 1913 and rather at the Instance level. For instance, the marquee 1914 filter must be specified when creating the vlc.Instance or 1915 vlc.MediaPlayer. 1916 1917 Alternatively, options can be added to the media using the 1918 Media.add_options method (with the same limitation). 1919 1920 @param mrl: A str, bytes or PathLike object 1921 @param options: optional media option=value strings 1922 """ 1923 mrl = try_fspath(mrl) 1924 if ':' in mrl and mrl.index(':') > 1: 1925 # Assume it is a URL 1926 m = libvlc_media_new_location(self, str_to_bytes(mrl)) 1927 else: 1928 # Else it should be a local path. 1929 m = libvlc_media_new_path(self, str_to_bytes(os.path.normpath(mrl))) 1930 for o in options: 1931 libvlc_media_add_option(m, str_to_bytes(o)) 1932 m._instance = self 1933 return m
1934
1935 - def media_new_path(self, path):
1936 """Create a media for a certain file path. 1937 See L{media_release}. 1938 @param path: A str, byte, or PathLike object representing a local filesystem path. 1939 @return: the newly created media or None on error. 1940 """ 1941 path = try_fspath(path) 1942 return libvlc_media_new_path(self, str_to_bytes(path))
1943
1944 - def media_list_new(self, mrls=None):
1945 """Create a new MediaList instance. 1946 @param mrls: optional list of MRL strings, bytes, or PathLike objects. 1947 """ 1948 l = libvlc_media_list_new(self) 1949 # We should take the lock, but since we did not leak the 1950 # reference, nobody else can access it. 1951 if mrls: 1952 for m in mrls: 1953 l.add_media(m) 1954 l._instance = self 1955 return l
1956
1958 """Enumerate the defined audio output devices. 1959 1960 @return: list of dicts {name:, description:, devices:} 1961 """ 1962 r = [] 1963 head = libvlc_audio_output_list_get(self) 1964 if head: 1965 i = head 1966 while i: 1967 i = i.contents 1968 r.append({'name': i.name, 'description': i.description}) 1969 i = i.next 1970 libvlc_audio_output_list_release(head) 1971 return r
1972
1973 - def audio_filter_list_get(self):
1974 """Returns a list of available audio filters. 1975 1976 """ 1977 return module_description_list(libvlc_audio_filter_list_get(self))
1978
1979 - def video_filter_list_get(self):
1980 """Returns a list of available video filters. 1981 1982 """ 1983 return module_description_list(libvlc_video_filter_list_get(self))
1984 1985 1986
1987 - def release(self):
1988 '''Decrement the reference count of a libvlc instance, and destroy it 1989 if it reaches zero. 1990 ''' 1991 return libvlc_release(self)
1992 1993
1994 - def retain(self):
1995 '''Increments the reference count of a libvlc instance. 1996 The initial reference count is 1 after L{new}() returns. 1997 ''' 1998 return libvlc_retain(self)
1999 2000
2001 - def add_intf(self, name):
2002 '''Try to start a user interface for the libvlc instance. 2003 @param name: interface name, or None for default. 2004 @return: 0 on success, -1 on error. 2005 ''' 2006 return libvlc_add_intf(self, str_to_bytes(name))
2007 2008
2009 - def set_user_agent(self, name, http):
2010 '''Sets the application name. LibVLC passes this as the user agent string 2011 when a protocol requires it. 2012 @param name: human-readable application name, e.g. "FooBar player 1.2.3". 2013 @param http: HTTP User Agent, e.g. "FooBar/1.2.3 Python/2.6.0". 2014 @version: LibVLC 1.1.1 or later. 2015 ''' 2016 return libvlc_set_user_agent(self, str_to_bytes(name), str_to_bytes(http))
2017 2018
2019 - def set_app_id(self, id, version, icon):
2020 '''Sets some meta-information about the application. 2021 See also L{set_user_agent}(). 2022 @param id: Java-style application identifier, e.g. "com.acme.foobar". 2023 @param version: application version numbers, e.g. "1.2.3". 2024 @param icon: application icon name, e.g. "foobar". 2025 @version: LibVLC 2.1.0 or later. 2026 ''' 2027 return libvlc_set_app_id(self, str_to_bytes(id), str_to_bytes(version), str_to_bytes(icon))
2028 2029
2030 - def log_unset(self):
2031 '''Unsets the logging callback. 2032 This function deregisters the logging callback for a LibVLC instance. 2033 This is rarely needed as the callback is implicitly unset when the instance 2034 is destroyed. 2035 @note: This function will wait for any pending callbacks invocation to 2036 complete (causing a deadlock if called from within the callback). 2037 @version: LibVLC 2.1.0 or later. 2038 ''' 2039 return libvlc_log_unset(self)
2040 2041
2042 - def log_set(self, cb, data):
2043 '''Sets the logging callback for a LibVLC instance. 2044 This function is thread-safe: it will wait for any pending callbacks 2045 invocation to complete. 2046 @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. 2047 @param p_instance: libvlc instance. 2048 @version: LibVLC 2.1.0 or later. 2049 ''' 2050 return libvlc_log_set(self, cb, data)
2051 2052
2053 - def log_set_file(self, stream):
2054 '''Sets up logging to a file. 2055 @param stream: FILE pointer opened for writing (the FILE pointer must remain valid until L{log_unset}()). 2056 @version: LibVLC 2.1.0 or later. 2057 ''' 2058 return libvlc_log_set_file(self, stream)
2059 2060
2061 - def media_discoverer_new(self, psz_name):
2062 '''Create a media discoverer object by name. 2063 After this object is created, you should attach to media_list events in 2064 order to be notified of new items discovered. 2065 You need to call L{media_discoverer_start}() in order to start the 2066 discovery. 2067 See L{media_discoverer_media_list} 2068 See L{media_discoverer_event_manager} 2069 See L{media_discoverer_start}. 2070 @param psz_name: service name; use L{media_discoverer_list_get}() to get a list of the discoverer names available in this libVLC instance. 2071 @return: media discover object or None in case of error. 2072 @version: LibVLC 3.0.0 or later. 2073 ''' 2074 return libvlc_media_discoverer_new(self, str_to_bytes(psz_name))
2075 2076
2077 - def media_discoverer_list_get(self, i_cat, ppp_services):
2078 '''Get media discoverer services by category. 2079 @param i_cat: category of services to fetch. 2080 @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]. 2081 @return: the number of media discoverer services (0 on error). 2082 @version: LibVLC 3.0.0 and later. 2083 ''' 2084 return libvlc_media_discoverer_list_get(self, i_cat, ppp_services)
2085 2086
2087 - def media_library_new(self):
2088 '''Create an new Media Library object. 2089 @return: a new object or None on error. 2090 ''' 2091 return libvlc_media_library_new(self)
2092 2093
2094 - def vlm_release(self):
2095 '''Release the vlm instance related to the given L{Instance}. 2096 ''' 2097 return libvlc_vlm_release(self)
2098 2099
2100 - def vlm_add_broadcast(self, psz_name, psz_input, psz_output, i_options, ppsz_options, b_enabled, b_loop):
2101 '''Add a broadcast, with one input. 2102 @param psz_name: the name of the new broadcast. 2103 @param psz_input: the input MRL. 2104 @param psz_output: the output MRL (the parameter to the "sout" variable). 2105 @param i_options: number of additional options. 2106 @param ppsz_options: additional options. 2107 @param b_enabled: boolean for enabling the new broadcast. 2108 @param b_loop: Should this broadcast be played in loop ? 2109 @return: 0 on success, -1 on error. 2110 ''' 2111 return libvlc_vlm_add_broadcast(self, str_to_bytes(psz_name), str_to_bytes(psz_input), str_to_bytes(psz_output), i_options, ppsz_options, b_enabled, b_loop)
2112 2113
2114 - def vlm_add_vod(self, psz_name, psz_input, i_options, ppsz_options, b_enabled, psz_mux):
2115 '''Add a vod, with one input. 2116 @param psz_name: the name of the new vod media. 2117 @param psz_input: the input MRL. 2118 @param i_options: number of additional options. 2119 @param ppsz_options: additional options. 2120 @param b_enabled: boolean for enabling the new vod. 2121 @param psz_mux: the muxer of the vod media. 2122 @return: 0 on success, -1 on error. 2123 ''' 2124 return libvlc_vlm_add_vod(self, str_to_bytes(psz_name), str_to_bytes(psz_input), i_options, ppsz_options, b_enabled, str_to_bytes(psz_mux))
2125 2126
2127 - def vlm_del_media(self, psz_name):
2128 '''Delete a media (VOD or broadcast). 2129 @param psz_name: the media to delete. 2130 @return: 0 on success, -1 on error. 2131 ''' 2132 return libvlc_vlm_del_media(self, str_to_bytes(psz_name))
2133 2134
2135 - def vlm_set_enabled(self, psz_name, b_enabled):
2136 '''Enable or disable a media (VOD or broadcast). 2137 @param psz_name: the media to work on. 2138 @param b_enabled: the new status. 2139 @return: 0 on success, -1 on error. 2140 ''' 2141 return libvlc_vlm_set_enabled(self, str_to_bytes(psz_name), b_enabled)
2142 2143
2144 - def vlm_set_output(self, psz_name, psz_output):
2145 '''Set the output for a media. 2146 @param psz_name: the media to work on. 2147 @param psz_output: the output MRL (the parameter to the "sout" variable). 2148 @return: 0 on success, -1 on error. 2149 ''' 2150 return libvlc_vlm_set_output(self, str_to_bytes(psz_name), str_to_bytes(psz_output))
2151 2152
2153 - def vlm_set_input(self, psz_name, psz_input):
2154 '''Set a media's input MRL. This will delete all existing inputs and 2155 add the specified one. 2156 @param psz_name: the media to work on. 2157 @param psz_input: the input MRL. 2158 @return: 0 on success, -1 on error. 2159 ''' 2160 return libvlc_vlm_set_input(self, str_to_bytes(psz_name), str_to_bytes(psz_input))
2161 2162
2163 - def vlm_add_input(self, psz_name, psz_input):
2164 '''Add a media's input MRL. This will add the specified one. 2165 @param psz_name: the media to work on. 2166 @param psz_input: the input MRL. 2167 @return: 0 on success, -1 on error. 2168 ''' 2169 return libvlc_vlm_add_input(self, str_to_bytes(psz_name), str_to_bytes(psz_input))
2170 2171
2172 - def vlm_set_loop(self, psz_name, b_loop):
2173 '''Set a media's loop status. 2174 @param psz_name: the media to work on. 2175 @param b_loop: the new status. 2176 @return: 0 on success, -1 on error. 2177 ''' 2178 return libvlc_vlm_set_loop(self, str_to_bytes(psz_name), b_loop)
2179 2180
2181 - def vlm_set_mux(self, psz_name, psz_mux):
2182 '''Set a media's vod muxer. 2183 @param psz_name: the media to work on. 2184 @param psz_mux: the new muxer. 2185 @return: 0 on success, -1 on error. 2186 ''' 2187 return libvlc_vlm_set_mux(self, str_to_bytes(psz_name), str_to_bytes(psz_mux))
2188 2189
2190 - def vlm_change_media(self, psz_name, psz_input, psz_output, i_options, ppsz_options, b_enabled, b_loop):
2191 '''Edit the parameters of a media. This will delete all existing inputs and 2192 add the specified one. 2193 @param psz_name: the name of the new broadcast. 2194 @param psz_input: the input MRL. 2195 @param psz_output: the output MRL (the parameter to the "sout" variable). 2196 @param i_options: number of additional options. 2197 @param ppsz_options: additional options. 2198 @param b_enabled: boolean for enabling the new broadcast. 2199 @param b_loop: Should this broadcast be played in loop ? 2200 @return: 0 on success, -1 on error. 2201 ''' 2202 return libvlc_vlm_change_media(self, str_to_bytes(psz_name), str_to_bytes(psz_input), str_to_bytes(psz_output), i_options, ppsz_options, b_enabled, b_loop)
2203 2204
2205 - def vlm_play_media(self, psz_name):
2206 '''Play the named broadcast. 2207 @param psz_name: the name of the broadcast. 2208 @return: 0 on success, -1 on error. 2209 ''' 2210 return libvlc_vlm_play_media(self, str_to_bytes(psz_name))
2211 2212
2213 - def vlm_stop_media(self, psz_name):
2214 '''Stop the named broadcast. 2215 @param psz_name: the name of the broadcast. 2216 @return: 0 on success, -1 on error. 2217 ''' 2218 return libvlc_vlm_stop_media(self, str_to_bytes(psz_name))
2219 2220
2221 - def vlm_pause_media(self, psz_name):
2222 '''Pause the named broadcast. 2223 @param psz_name: the name of the broadcast. 2224 @return: 0 on success, -1 on error. 2225 ''' 2226 return libvlc_vlm_pause_media(self, str_to_bytes(psz_name))
2227 2228
2229 - def vlm_seek_media(self, psz_name, f_percentage):
2230 '''Seek in the named broadcast. 2231 @param psz_name: the name of the broadcast. 2232 @param f_percentage: the percentage to seek to. 2233 @return: 0 on success, -1 on error. 2234 ''' 2235 return libvlc_vlm_seek_media(self, str_to_bytes(psz_name), f_percentage)
2236 2237
2238 - def vlm_show_media(self, psz_name):
2239 '''Return information about the named media as a JSON 2240 string representation. 2241 This function is mainly intended for debugging use, 2242 if you want programmatic access to the state of 2243 a vlm_media_instance_t, please use the corresponding 2244 libvlc_vlm_get_media_instance_xxx -functions. 2245 Currently there are no such functions available for 2246 vlm_media_t though. 2247 @param psz_name: the name of the media, if the name is an empty string, all media is described. 2248 @return: string with information about named media, or None on error. 2249 ''' 2250 return libvlc_vlm_show_media(self, str_to_bytes(psz_name))
2251 2252
2253 - def vlm_get_media_instance_position(self, psz_name, i_instance):
2254 '''Get vlm_media instance position by name or instance id. 2255 @param psz_name: name of vlm media instance. 2256 @param i_instance: instance id. 2257 @return: position as float or -1. on error. 2258 ''' 2259 return libvlc_vlm_get_media_instance_position(self, str_to_bytes(psz_name), i_instance)
2260 2261
2262 - def vlm_get_media_instance_time(self, psz_name, i_instance):
2263 '''Get vlm_media instance time by name or instance id. 2264 @param psz_name: name of vlm media instance. 2265 @param i_instance: instance id. 2266 @return: time as integer or -1 on error. 2267 ''' 2268 return libvlc_vlm_get_media_instance_time(self, str_to_bytes(psz_name), i_instance)
2269 2270
2271 - def vlm_get_media_instance_length(self, psz_name, i_instance):
2272 '''Get vlm_media instance length by name or instance id. 2273 @param psz_name: name of vlm media instance. 2274 @param i_instance: instance id. 2275 @return: length of media item or -1 on error. 2276 ''' 2277 return libvlc_vlm_get_media_instance_length(self, str_to_bytes(psz_name), i_instance)
2278 2279
2280 - def vlm_get_media_instance_rate(self, psz_name, i_instance):
2281 '''Get vlm_media instance playback rate by name or instance id. 2282 @param psz_name: name of vlm media instance. 2283 @param i_instance: instance id. 2284 @return: playback rate or -1 on error. 2285 ''' 2286 return libvlc_vlm_get_media_instance_rate(self, str_to_bytes(psz_name), i_instance)
2287 2288
2289 - def vlm_get_media_instance_title(self, psz_name, i_instance):
2290 '''Get vlm_media instance title number by name or instance id. 2291 @param psz_name: name of vlm media instance. 2292 @param i_instance: instance id. 2293 @return: title as number or -1 on error. 2294 @bug: will always return 0. 2295 ''' 2296 return libvlc_vlm_get_media_instance_title(self, str_to_bytes(psz_name), i_instance)
2297 2298
2299 - def vlm_get_media_instance_chapter(self, psz_name, i_instance):
2300 '''Get vlm_media instance chapter number by name or instance id. 2301 @param psz_name: name of vlm media instance. 2302 @param i_instance: instance id. 2303 @return: chapter as number or -1 on error. 2304 @bug: will always return 0. 2305 ''' 2306 return libvlc_vlm_get_media_instance_chapter(self, str_to_bytes(psz_name), i_instance)
2307 2308
2309 - def vlm_get_media_instance_seekable(self, psz_name, i_instance):
2310 '''Is libvlc instance seekable ? 2311 @param psz_name: name of vlm media instance. 2312 @param i_instance: instance id. 2313 @return: 1 if seekable, 0 if not, -1 if media does not exist. 2314 @bug: will always return 0. 2315 ''' 2316 return libvlc_vlm_get_media_instance_seekable(self, str_to_bytes(psz_name), i_instance)
2317 2318 @memoize_parameterless
2319 - def vlm_get_event_manager(self):
2320 '''Get libvlc_event_manager from a vlm media. 2321 The p_event_manager is immutable, so you don't have to hold the lock. 2322 @return: libvlc_event_manager. 2323 ''' 2324 return libvlc_vlm_get_event_manager(self)
2325 2326
2327 - def media_new_location(self, psz_mrl):
2328 '''Create a media with a certain given media resource location, 2329 for instance a valid URL. 2330 @note: To refer to a local file with this function, 2331 the file://... URI syntax B{must} be used (see IETF RFC3986). 2332 We recommend using L{media_new_path}() instead when dealing with 2333 local files. 2334 See L{media_release}. 2335 @param psz_mrl: the media location. 2336 @return: the newly created media or None on error. 2337 ''' 2338 return libvlc_media_new_location(self, str_to_bytes(psz_mrl))
2339 2340
2341 - def media_new_fd(self, fd):
2342 '''Create a media for an already open file descriptor. 2343 The file descriptor shall be open for reading (or reading and writing). 2344 Regular file descriptors, pipe read descriptors and character device 2345 descriptors (including TTYs) are supported on all platforms. 2346 Block device descriptors are supported where available. 2347 Directory descriptors are supported on systems that provide fdopendir(). 2348 Sockets are supported on all platforms where they are file descriptors, 2349 i.e. all except Windows. 2350 @note: This library will B{not} automatically close the file descriptor 2351 under any circumstance. Nevertheless, a file descriptor can usually only be 2352 rendered once in a media player. To render it a second time, the file 2353 descriptor should probably be rewound to the beginning with lseek(). 2354 See L{media_release}. 2355 @param fd: open file descriptor. 2356 @return: the newly created media or None on error. 2357 @version: LibVLC 1.1.5 and later. 2358 ''' 2359 return libvlc_media_new_fd(self, fd)
2360 2361
2362 - def media_new_callbacks(self, open_cb, read_cb, seek_cb, close_cb, opaque):
2363 '''Create a media with custom callbacks to read the data from. 2364 @param open_cb: callback to open the custom bitstream input media. 2365 @param read_cb: callback to read data (must not be None). 2366 @param seek_cb: callback to seek, or None if seeking is not supported. 2367 @param close_cb: callback to close the media, or None if unnecessary. 2368 @param opaque: data pointer for the open callback. 2369 @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}. 2370 @version: LibVLC 3.0.0 and later. 2371 ''' 2372 return libvlc_media_new_callbacks(self, open_cb, read_cb, seek_cb, close_cb, opaque)
2373 2374
2375 - def media_new_as_node(self, psz_name):
2376 '''Create a media as an empty node with a given name. 2377 See L{media_release}. 2378 @param psz_name: the name of the node. 2379 @return: the new empty media or None on error. 2380 ''' 2381 return libvlc_media_new_as_node(self, str_to_bytes(psz_name))
2382 2383
2384 - def renderer_discoverer_new(self, psz_name):
2385 '''Create a renderer discoverer object by name 2386 After this object is created, you should attach to events in order to be 2387 notified of the discoverer events. 2388 You need to call L{renderer_discoverer_start}() in order to start the 2389 discovery. 2390 See L{renderer_discoverer_event_manager}() 2391 See L{renderer_discoverer_start}(). 2392 @param psz_name: service name; use L{renderer_discoverer_list_get}() to get a list of the discoverer names available in this libVLC instance. 2393 @return: media discover object or None in case of error. 2394 @version: LibVLC 3.0.0 or later. 2395 ''' 2396 return libvlc_renderer_discoverer_new(self, str_to_bytes(psz_name))
2397 2398
2399 - def renderer_discoverer_list_get(self, ppp_services):
2400 '''Get media discoverer services 2401 See libvlc_renderer_list_release(). 2402 @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]. 2403 @return: the number of media discoverer services (0 on error). 2404 @version: LibVLC 3.0.0 and later. 2405 ''' 2406 return libvlc_renderer_discoverer_list_get(self, ppp_services)
2407 2408
2409 - def audio_output_device_count(self, psz_audio_output):
2410 '''Backward compatibility stub. Do not use in new code. 2411 \deprecated Use L{audio_output_device_list_get}() instead. 2412 @return: always 0. 2413 ''' 2414 return libvlc_audio_output_device_count(self, str_to_bytes(psz_audio_output))
2415 2416
2417 - def audio_output_device_longname(self, psz_output, i_device):
2418 '''Backward compatibility stub. Do not use in new code. 2419 \deprecated Use L{audio_output_device_list_get}() instead. 2420 @return: always None. 2421 ''' 2422 return libvlc_audio_output_device_longname(self, str_to_bytes(psz_output), i_device)
2423 2424
2425 - def audio_output_device_id(self, psz_audio_output, i_device):
2426 '''Backward compatibility stub. Do not use in new code. 2427 \deprecated Use L{audio_output_device_list_get}() instead. 2428 @return: always None. 2429 ''' 2430 return libvlc_audio_output_device_id(self, str_to_bytes(psz_audio_output), i_device)
2431 2432
2433 - def media_discoverer_new_from_name(self, psz_name):
2434 '''\deprecated Use L{media_discoverer_new}() and L{media_discoverer_start}(). 2435 ''' 2436 return libvlc_media_discoverer_new_from_name(self, str_to_bytes(psz_name))
2437 2438
2439 - def wait(self):
2440 '''Waits until an interface causes the instance to exit. 2441 You should start at least one interface first, using L{add_intf}(). 2442 ''' 2443 return libvlc_wait(self)
2444 2445
2446 - def get_log_verbosity(self):
2447 '''Always returns minus one. 2448 This function is only provided for backward compatibility. 2449 @return: always -1. 2450 ''' 2451 return libvlc_get_log_verbosity(self)
2452 2453
2454 - def set_log_verbosity(self, level):
2455 '''This function does nothing. 2456 It is only provided for backward compatibility. 2457 @param level: ignored. 2458 ''' 2459 return libvlc_set_log_verbosity(self, level)
2460 2461
2462 - def log_open(self):
2463 '''This function does nothing useful. 2464 It is only provided for backward compatibility. 2465 @return: an unique pointer or None on error. 2466 ''' 2467 return libvlc_log_open(self)
2468 2469
2470 - def playlist_play(self, i_id, i_options, ppsz_options):
2471 '''Start playing (if there is any item in the playlist). 2472 Additionnal playlist item options can be specified for addition to the 2473 item before it is played. 2474 @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. 2475 @param i_options: the number of options to add to the item. 2476 @param ppsz_options: the options to add to the item. 2477 ''' 2478 return libvlc_playlist_play(self, i_id, i_options, ppsz_options)
2479 2480
2481 - def audio_output_list_get(self):
2482 '''Gets the list of available audio output modules. 2483 @return: list of available audio outputs. It must be freed with In case of error, None is returned. 2484 ''' 2485 return libvlc_audio_output_list_get(self)
2486 2487
2488 - def audio_output_device_list_get(self, aout):
2489 '''Gets a list of audio output devices for a given audio output module, 2490 See L{audio_output_device_set}(). 2491 @note: Not all audio outputs support this. In particular, an empty (None) 2492 list of devices does B{not} imply that the specified audio output does 2493 not work. 2494 @note: The list might not be exhaustive. 2495 @warning: Some audio output devices in the list might not actually work in 2496 some circumstances. By default, it is recommended to not specify any 2497 explicit audio device. 2498 @param aout: audio output name (as returned by L{audio_output_list_get}()). 2499 @return: A None-terminated linked list of potential audio output devices. It must be freed with L{audio_output_device_list_release}(). 2500 @version: LibVLC 2.1.0 or later. 2501 ''' 2502 return libvlc_audio_output_device_list_get(self, str_to_bytes(aout))
2503
2504 -class LogIterator(_Ctype):
2505 '''Create a new VLC log iterator. 2506 2507 ''' 2508
2509 - def __new__(cls, ptr=_internal_guard):
2510 '''(INTERNAL) ctypes wrapper constructor. 2511 ''' 2512 return _Constructor(cls, ptr)
2513
2514 - def __iter__(self):
2515 return self
2516
2517 - def next(self):
2518 if self.has_next(): 2519 b = LogMessage() 2520 i = libvlc_log_iterator_next(self, b) 2521 return i.contents 2522 raise StopIteration
2523
2524 - def __next__(self):
2525 return self.next()
2526 2527 2528
2529 - def free(self):
2530 '''Frees memory allocated by L{log_get_iterator}(). 2531 ''' 2532 return libvlc_log_iterator_free(self)
2533 2534
2535 - def has_next(self):
2536 '''Always returns zero. 2537 This function is only provided for backward compatibility. 2538 @return: always zero. 2539 ''' 2540 return libvlc_log_iterator_has_next(self)
2541
2542 -class Media(_Ctype):
2543 '''Create a new Media instance. 2544 2545 Usage: Media(MRL, *options) 2546 2547 See vlc.Instance.media_new documentation for details. 2548 2549 ''' 2550
2551 - def __new__(cls, *args):
2552 if args: 2553 i = args[0] 2554 if isinstance(i, _Ints): 2555 return _Constructor(cls, i) 2556 if isinstance(i, Instance): 2557 return i.media_new(*args[1:]) 2558 2559 o = get_default_instance().media_new(*args) 2560 return o
2561
2562 - def get_instance(self):
2563 return getattr(self, '_instance', None)
2564
2565 - def add_options(self, *options):
2566 """Add a list of options to the media. 2567 2568 Options must be written without the double-dash. Warning: most 2569 audio and video options, such as text renderer, have no 2570 effects on an individual media. These options must be set at 2571 the vlc.Instance or vlc.MediaPlayer instanciation. 2572 2573 @param options: optional media option=value strings 2574 """ 2575 for o in options: 2576 self.add_option(o)
2577
2578 - def tracks_get(self):
2579 """Get media descriptor's elementary streams description 2580 Note, you need to call L{parse}() or play the media at least once 2581 before calling this function. 2582 Not doing this will result in an empty array. 2583 The result must be freed with L{tracks_release}. 2584 @version: LibVLC 2.1.0 and later. 2585 """ 2586 mediaTrack_pp = ctypes.POINTER(MediaTrack)() 2587 n = libvlc_media_tracks_get(self, ctypes.byref(mediaTrack_pp)) 2588 info = ctypes.cast(mediaTrack_pp, ctypes.POINTER(ctypes.POINTER(MediaTrack) * n)) 2589 try: 2590 contents = info.contents 2591 except ValueError: 2592 # Media not parsed, no info. 2593 return None 2594 tracks = ( contents[i].contents for i in range(len(contents)) ) 2595 # libvlc_media_tracks_release(mediaTrack_pp, n) 2596 return tracks
2597 2598 2599
2600 - def add_option(self, psz_options):
2601 '''Add an option to the media. 2602 This option will be used to determine how the media_player will 2603 read the media. This allows to use VLC's advanced 2604 reading/streaming options on a per-media basis. 2605 @note: The options are listed in 'vlc --long-help' from the command line, 2606 e.g. "-sout-all". Keep in mind that available options and their semantics 2607 vary across LibVLC versions and builds. 2608 @warning: Not all options affects L{Media} objects: 2609 Specifically, due to architectural issues most audio and video options, 2610 such as text renderer options, have no effects on an individual media. 2611 These options must be set through L{new}() instead. 2612 @param psz_options: the options (as a string). 2613 ''' 2614 return libvlc_media_add_option(self, str_to_bytes(psz_options))
2615 2616
2617 - def add_option_flag(self, psz_options, i_flags):
2618 '''Add an option to the media with configurable flags. 2619 This option will be used to determine how the media_player will 2620 read the media. This allows to use VLC's advanced 2621 reading/streaming options on a per-media basis. 2622 The options are detailed in vlc --long-help, for instance 2623 "--sout-all". Note that all options are not usable on medias: 2624 specifically, due to architectural issues, video-related options 2625 such as text renderer options cannot be set on a single media. They 2626 must be set on the whole libvlc instance instead. 2627 @param psz_options: the options (as a string). 2628 @param i_flags: the flags for this option. 2629 ''' 2630 return libvlc_media_add_option_flag(self, str_to_bytes(psz_options), i_flags)
2631 2632
2633 - def retain(self):
2634 '''Retain a reference to a media descriptor object (L{Media}). Use 2635 L{release}() to decrement the reference count of a 2636 media descriptor object. 2637 ''' 2638 return libvlc_media_retain(self)
2639 2640
2641 - def release(self):
2642 '''Decrement the reference count of a media descriptor object. If the 2643 reference count is 0, then L{release}() will release the 2644 media descriptor object. It will send out an libvlc_MediaFreed event 2645 to all listeners. If the media descriptor object has been released it 2646 should not be used again. 2647 ''' 2648 return libvlc_media_release(self)
2649 2650
2651 - def get_mrl(self):
2652 '''Get the media resource locator (mrl) from a media descriptor object. 2653 @return: string with mrl of media descriptor object. 2654 ''' 2655 return libvlc_media_get_mrl(self)
2656 2657
2658 - def duplicate(self):
2659 '''Duplicate a media descriptor object. 2660 ''' 2661 return libvlc_media_duplicate(self)
2662 2663
2664 - def get_meta(self, e_meta):
2665 '''Read the meta of the media. 2666 If the media has not yet been parsed this will return None. 2667 See L{parse} 2668 See L{parse_with_options} 2669 See libvlc_MediaMetaChanged. 2670 @param e_meta: the meta to read. 2671 @return: the media's meta. 2672 ''' 2673 return libvlc_media_get_meta(self, e_meta)
2674 2675
2676 - def set_meta(self, e_meta, psz_value):
2677 '''Set the meta of the media (this function will not save the meta, call 2678 L{save_meta} in order to save the meta). 2679 @param e_meta: the meta to write. 2680 @param psz_value: the media's meta. 2681 ''' 2682 return libvlc_media_set_meta(self, e_meta, str_to_bytes(psz_value))
2683 2684
2685 - def save_meta(self):
2686 '''Save the meta previously set. 2687 @return: true if the write operation was successful. 2688 ''' 2689 return libvlc_media_save_meta(self)
2690 2691
2692 - def get_state(self):
2693 '''Get current state of media descriptor object. Possible media states are 2694 libvlc_NothingSpecial=0, libvlc_Opening, libvlc_Playing, libvlc_Paused, 2695 libvlc_Stopped, libvlc_Ended, libvlc_Error. 2696 See L{State}. 2697 @return: state of media descriptor object. 2698 ''' 2699 return libvlc_media_get_state(self)
2700 2701
2702 - def get_stats(self, p_stats):
2703 '''Get the current statistics about the media. 2704 @param p_stats:: structure that contain the statistics about the media (this structure must be allocated by the caller). 2705 @return: true if the statistics are available, false otherwise \libvlc_return_bool. 2706 ''' 2707 return libvlc_media_get_stats(self, p_stats)
2708 2709
2710 - def subitems(self):
2711 '''Get subitems of media descriptor object. This will increment 2712 the reference count of supplied media descriptor object. Use 2713 L{list_release}() to decrement the reference counting. 2714 @return: list of media descriptor subitems or None. 2715 ''' 2716 return libvlc_media_subitems(self)
2717 2718 @memoize_parameterless
2719 - def event_manager(self):
2720 '''Get event manager from media descriptor object. 2721 NOTE: this function doesn't increment reference counting. 2722 @return: event manager object. 2723 ''' 2724 return libvlc_media_event_manager(self)
2725 2726
2727 - def get_duration(self):
2728 '''Get duration (in ms) of media descriptor object item. 2729 @return: duration of media item or -1 on error. 2730 ''' 2731 return libvlc_media_get_duration(self)
2732 2733
2734 - def parse_with_options(self, parse_flag, timeout):
2735 '''Parse the media asynchronously with options. 2736 This fetches (local or network) art, meta data and/or tracks information. 2737 This method is the extended version of L{parse_with_options}(). 2738 To track when this is over you can listen to libvlc_MediaParsedChanged 2739 event. However if this functions returns an error, you will not receive any 2740 events. 2741 It uses a flag to specify parse options (see L{MediaParseFlag}). All 2742 these flags can be combined. By default, media is parsed if it's a local 2743 file. 2744 @note: Parsing can be aborted with L{parse_stop}(). 2745 See libvlc_MediaParsedChanged 2746 See L{get_meta} 2747 See L{tracks_get} 2748 See L{get_parsed_status} 2749 See L{MediaParseFlag}. 2750 @param parse_flag: parse options: 2751 @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). 2752 @return: -1 in case of error, 0 otherwise. 2753 @version: LibVLC 3.0.0 or later. 2754 ''' 2755 return libvlc_media_parse_with_options(self, parse_flag, timeout)
2756 2757
2758 - def parse_stop(self):
2759 '''Stop the parsing of the media 2760 When the media parsing is stopped, the libvlc_MediaParsedChanged event will 2761 be sent with the libvlc_media_parsed_status_timeout status. 2762 See L{parse_with_options}. 2763 @version: LibVLC 3.0.0 or later. 2764 ''' 2765 return libvlc_media_parse_stop(self)
2766 2767
2768 - def get_parsed_status(self):
2769 '''Get Parsed status for media descriptor object. 2770 See libvlc_MediaParsedChanged 2771 See L{MediaParsedStatus}. 2772 @return: a value of the L{MediaParsedStatus} enum. 2773 @version: LibVLC 3.0.0 or later. 2774 ''' 2775 return libvlc_media_get_parsed_status(self)
2776 2777
2778 - def set_user_data(self, p_new_user_data):
2779 '''Sets media descriptor's user_data. user_data is specialized data 2780 accessed by the host application, VLC.framework uses it as a pointer to 2781 an native object that references a L{Media} pointer. 2782 @param p_new_user_data: pointer to user data. 2783 ''' 2784 return libvlc_media_set_user_data(self, p_new_user_data)
2785 2786
2787 - def get_user_data(self):
2788 '''Get media descriptor's user_data. user_data is specialized data 2789 accessed by the host application, VLC.framework uses it as a pointer to 2790 an native object that references a L{Media} pointer. 2791 ''' 2792 return libvlc_media_get_user_data(self)
2793 2794
2795 - def get_type(self):
2796 '''Get the media type of the media descriptor object. 2797 @return: media type. 2798 @version: LibVLC 3.0.0 and later. See L{MediaType}. 2799 ''' 2800 return libvlc_media_get_type(self)
2801 2802
2803 - def slaves_add(self, i_type, i_priority, psz_uri):
2804 '''Add a slave to the current media. 2805 A slave is an external input source that may contains an additional subtitle 2806 track (like a .srt) or an additional audio track (like a .ac3). 2807 @note: This function must be called before the media is parsed (via 2808 L{parse_with_options}()) or before the media is played (via 2809 L{player_play}()). 2810 @param i_type: subtitle or audio. 2811 @param i_priority: from 0 (low priority) to 4 (high priority). 2812 @param psz_uri: Uri of the slave (should contain a valid scheme). 2813 @return: 0 on success, -1 on error. 2814 @version: LibVLC 3.0.0 and later. 2815 ''' 2816 return libvlc_media_slaves_add(self, i_type, i_priority, str_to_bytes(psz_uri))
2817 2818
2819 - def slaves_clear(self):
2820 '''Clear all slaves previously added by L{slaves_add}() or 2821 internally. 2822 @version: LibVLC 3.0.0 and later. 2823 ''' 2824 return libvlc_media_slaves_clear(self)
2825 2826
2827 - def slaves_get(self, ppp_slaves):
2828 '''Get a media descriptor's slave list 2829 The list will contain slaves parsed by VLC or previously added by 2830 L{slaves_add}(). The typical use case of this function is to save 2831 a list of slave in a database for a later use. 2832 @param ppp_slaves: address to store an allocated array of slaves (must be freed with L{slaves_release}()) [OUT]. 2833 @return: the number of slaves (zero on error). 2834 @version: LibVLC 3.0.0 and later. See L{slaves_add}. 2835 ''' 2836 return libvlc_media_slaves_get(self, ppp_slaves)
2837 2838
2839 - def parse(self):
2840 '''Parse a media. 2841 This fetches (local) art, meta data and tracks information. 2842 The method is synchronous. 2843 \deprecated This function could block indefinitely. 2844 Use L{parse_with_options}() instead 2845 See L{parse_with_options} 2846 See L{get_meta} 2847 See L{get_tracks_info}. 2848 ''' 2849 return libvlc_media_parse(self)
2850 2851
2852 - def parse_async(self):
2853 '''Parse a media. 2854 This fetches (local) art, meta data and tracks information. 2855 The method is the asynchronous of L{parse}(). 2856 To track when this is over you can listen to libvlc_MediaParsedChanged 2857 event. However if the media was already parsed you will not receive this 2858 event. 2859 \deprecated You can't be sure to receive the libvlc_MediaParsedChanged 2860 event (you can wait indefinitely for this event). 2861 Use L{parse_with_options}() instead 2862 See L{parse} 2863 See libvlc_MediaParsedChanged 2864 See L{get_meta} 2865 See L{get_tracks_info}. 2866 ''' 2867 return libvlc_media_parse_async(self)
2868 2869
2870 - def is_parsed(self):
2871 '''Return true is the media descriptor object is parsed 2872 \deprecated This can return true in case of failure. 2873 Use L{get_parsed_status}() instead 2874 See libvlc_MediaParsedChanged. 2875 @return: true if media object has been parsed otherwise it returns false \libvlc_return_bool. 2876 ''' 2877 return libvlc_media_is_parsed(self)
2878 2879
2880 - def get_tracks_info(self):
2881 '''Get media descriptor's elementary streams description 2882 Note, you need to call L{parse}() or play the media at least once 2883 before calling this function. 2884 Not doing this will result in an empty array. 2885 \deprecated Use L{tracks_get}() instead. 2886 @param tracks: address to store an allocated array of Elementary Streams descriptions (must be freed by the caller) [OUT]. 2887 @return: the number of Elementary Streams. 2888 ''' 2889 return libvlc_media_get_tracks_info(self)
2890 2891
2892 - def player_new_from_media(self):
2893 '''Create a Media Player object from a Media. 2894 @return: a new media player object, or None on error. 2895 ''' 2896 return libvlc_media_player_new_from_media(self)
2897
2898 -class MediaDiscoverer(_Ctype):
2899 '''N/A 2900 ''' 2901
2902 - def __new__(cls, ptr=_internal_guard):
2903 '''(INTERNAL) ctypes wrapper constructor. 2904 ''' 2905 return _Constructor(cls, ptr)
2906
2907 - def start(self):
2908 '''Start media discovery. 2909 To stop it, call L{stop}() or 2910 L{list_release}() directly. 2911 See L{stop}. 2912 @return: -1 in case of error, 0 otherwise. 2913 @version: LibVLC 3.0.0 or later. 2914 ''' 2915 return libvlc_media_discoverer_start(self)
2916 2917
2918 - def stop(self):
2919 '''Stop media discovery. 2920 See L{start}. 2921 @version: LibVLC 3.0.0 or later. 2922 ''' 2923 return libvlc_media_discoverer_stop(self)
2924 2925
2926 - def release(self):
2927 '''Release media discover object. If the reference count reaches 0, then 2928 the object will be released. 2929 ''' 2930 return libvlc_media_discoverer_release(self)
2931 2932
2933 - def media_list(self):
2934 '''Get media service discover media list. 2935 @return: list of media items. 2936 ''' 2937 return libvlc_media_discoverer_media_list(self)
2938 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
2947 - def localized_name(self):
2948 '''Get media service discover object its localized name. 2949 \deprecated Useless, use L{list_get}() to get the 2950 longname of the service discovery. 2951 @return: localized name or None if the media_discoverer is not started. 2952 ''' 2953 return libvlc_media_discoverer_localized_name(self)
2954 2955 @memoize_parameterless
2956 - def event_manager(self):
2957 '''Get event manager from media service discover object. 2958 \deprecated Useless, media_discoverer events are only triggered when calling 2959 L{start}() and L{stop}(). 2960 @return: event manager object. 2961 ''' 2962 return libvlc_media_discoverer_event_manager(self)
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
2981 - def retain(self):
2982 '''Retain a reference to a media library object. This function will 2983 increment the reference counting for this object. Use 2984 L{release}() to decrement the reference count. 2985 ''' 2986 return libvlc_media_library_retain(self)
2987 2988
2989 - def load(self):
2990 '''Load media library. 2991 @return: 0 on success, -1 on error. 2992 ''' 2993 return libvlc_media_library_load(self)
2994 2995
2996 - def media_list(self):
2997 '''Get media library subitems. 2998 @return: media list subitems. 2999 ''' 3000 return libvlc_media_library_media_list(self)
3001
3002 -class MediaList(_Ctype):
3003 '''Create a new MediaList instance. 3004 3005 Usage: MediaList(list_of_MRLs) 3006 3007 See vlc.Instance.media_list_new documentation for details. 3008 3009 ''' 3010
3011 - def __new__(cls, *args):
3012 if args: 3013 i = args[0] 3014 if isinstance(i, _Ints): 3015 return _Constructor(cls, i) 3016 if isinstance(i, Instance): 3017 return i.media_list_new(*args[1:]) 3018 3019 o = get_default_instance().media_list_new(*args) 3020 return o
3021
3022 - def get_instance(self):
3023 return getattr(self, '_instance', None)
3024
3025 - def add_media(self, mrl):
3026 """Add media instance to media list. 3027 3028 The L{lock} should be held upon entering this function. 3029 @param mrl: a media instance or a MRL. 3030 @return: 0 on success, -1 if the media list is read-only. 3031 """ 3032 mrl = try_fspath(mrl) 3033 if isinstance(mrl, basestring): 3034 mrl = (self.get_instance() or get_default_instance()).media_new(mrl) 3035 return libvlc_media_list_add_media(self, mrl)
3036 3037 3038
3039 - def release(self):
3040 '''Release media list created with L{new}(). 3041 ''' 3042 return libvlc_media_list_release(self)
3043 3044
3045 - def retain(self):
3046 '''Retain reference to a media list. 3047 ''' 3048 return libvlc_media_list_retain(self)
3049 3050
3051 - def set_media(self, p_md):
3052 '''Associate media instance with this media list instance. 3053 If another media instance was present it will be released. 3054 The L{lock} should NOT be held upon entering this function. 3055 @param p_md: media instance to add. 3056 ''' 3057 return libvlc_media_list_set_media(self, p_md)
3058 3059
3060 - def media(self):
3061 '''Get media instance from this media list instance. This action will increase 3062 the refcount on the media instance. 3063 The L{lock} should NOT be held upon entering this function. 3064 @return: media instance. 3065 ''' 3066 return libvlc_media_list_media(self)
3067 3068
3069 - def insert_media(self, p_md, i_pos):
3070 '''Insert media instance in media list on a position 3071 The L{lock} should be held upon entering this function. 3072 @param p_md: a media instance. 3073 @param i_pos: position in array where to insert. 3074 @return: 0 on success, -1 if the media list is read-only. 3075 ''' 3076 return libvlc_media_list_insert_media(self, p_md, i_pos)
3077 3078
3079 - def remove_index(self, i_pos):
3080 '''Remove media instance from media list on a position 3081 The L{lock} should be held upon entering this function. 3082 @param i_pos: position in array where to insert. 3083 @return: 0 on success, -1 if the list is read-only or the item was not found. 3084 ''' 3085 return libvlc_media_list_remove_index(self, i_pos)
3086 3087
3088 -