~openlp-core/openlp/trunk

« back to all changes in this revision

Viewing changes to openlp/core/ui/media/vendor/vlc.py

  • Committer: Tim Bentley
  • Date: 2019-05-10 17:09:17 UTC
  • mfrom: (2857.3.17 no_vlc)
  • Revision ID: tim.bentley@gmail.com-20190510170917-1ca28ad068r0wpq2
media.vendor.vlc has been removed and python3-vlc installed in its place.

Show diffs side-by-side

added added

removed removed

Lines of Context:
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{http://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
 
 
54
 
logger = logging.getLogger(__name__)
55
 
 
56
 
__version__ = "3.0.3104"
57
 
__libvlc_version__ = "3.0.3"
58
 
__generator_version__ = "1.4"
59
 
build_date = "Fri Jul 13 15:18:27 2018 3.0.3"
60
 
 
61
 
# The libvlc doc states that filenames are expected to be in UTF8, do
62
 
# not rely on sys.getfilesystemencoding() which will be confused,
63
 
# esp. on windows.
64
 
DEFAULT_ENCODING = 'utf-8'
65
 
 
66
 
if sys.version_info[0] > 2:
67
 
    str = str
68
 
    unicode = str
69
 
    bytes = bytes
70
 
    basestring = (str, bytes)
71
 
    PYTHON3 = True
72
 
 
73
 
 
74
 
    def str_to_bytes(s):
75
 
        """Translate string or bytes to bytes.
76
 
        """
77
 
        if isinstance(s, str):
78
 
            return bytes(s, DEFAULT_ENCODING)
79
 
        else:
80
 
            return s
81
 
 
82
 
 
83
 
    def bytes_to_str(b):
84
 
        """Translate bytes to string.
85
 
        """
86
 
        if isinstance(b, bytes):
87
 
            return b.decode(DEFAULT_ENCODING)
88
 
        else:
89
 
            return b
90
 
else:
91
 
    str = str
92
 
    unicode = unicode
93
 
    bytes = str
94
 
    basestring = basestring
95
 
    PYTHON3 = False
96
 
 
97
 
 
98
 
    def str_to_bytes(s):
99
 
        """Translate string or bytes to bytes.
100
 
        """
101
 
        if isinstance(s, unicode):
102
 
            return s.encode(DEFAULT_ENCODING)
103
 
        else:
104
 
            return s
105
 
 
106
 
 
107
 
    def bytes_to_str(b):
108
 
        """Translate bytes to unicode string.
109
 
        """
110
 
        if isinstance(b, str):
111
 
            return unicode(b, DEFAULT_ENCODING)
112
 
        else:
113
 
            return b
114
 
 
115
 
# Internal guard to prevent internal classes to be directly
116
 
# instanciated.
117
 
_internal_guard = object()
118
 
 
119
 
 
120
 
def find_lib():
121
 
    dll = None
122
 
    plugin_path = os.environ.get('PYTHON_VLC_MODULE_PATH', None)
123
 
    if 'PYTHON_VLC_LIB_PATH' in os.environ:
124
 
        try:
125
 
            dll = ctypes.CDLL(os.environ['PYTHON_VLC_LIB_PATH'])
126
 
        except OSError:
127
 
            logger.error("Cannot load lib specified by PYTHON_VLC_LIB_PATH env. variable")
128
 
            sys.exit(1)
129
 
    if plugin_path and not os.path.isdir(plugin_path):
130
 
        logger.error("Invalid PYTHON_VLC_MODULE_PATH specified. Please fix.")
131
 
        sys.exit(1)
132
 
    if dll is not None:
133
 
        return dll, plugin_path
134
 
 
135
 
    if sys.platform.startswith('linux'):
136
 
        p = find_library('vlc')
137
 
        try:
138
 
            dll = ctypes.CDLL(p)
139
 
        except OSError:  # may fail
140
 
            dll = ctypes.CDLL('libvlc.so.5')
141
 
    elif sys.platform.startswith('win'):
142
 
        libname = 'libvlc.dll'
143
 
        p = find_library(libname)
144
 
        if p is None:
145
 
            try:  # some registry settings
146
 
                # leaner than win32api, win32con
147
 
                if PYTHON3:
148
 
                    import winreg as w
149
 
                else:
150
 
                    import _winreg as w
151
 
                for r in w.HKEY_LOCAL_MACHINE, w.HKEY_CURRENT_USER:
152
 
                    try:
153
 
                        r = w.OpenKey(r, 'Software\\VideoLAN\\VLC')
154
 
                        plugin_path, _ = w.QueryValueEx(r, 'InstallDir')
155
 
                        w.CloseKey(r)
156
 
                        break
157
 
                    except w.error:
158
 
                        pass
159
 
            except ImportError:  # no PyWin32
160
 
                pass
161
 
            if plugin_path is None:
162
 
                # try some standard locations.
163
 
                programfiles = os.environ["ProgramFiles"]
164
 
                homedir = os.environ["HOMEDRIVE"]
165
 
                for p in ('{programfiles}\\VideoLan{libname}', '{homedir}:\\VideoLan{libname}',
166
 
                          '{programfiles}{libname}', '{homedir}:{libname}'):
167
 
                    p = p.format(homedir=homedir,
168
 
                                 programfiles=programfiles,
169
 
                                 libname='\\VLC\\' + libname)
170
 
                    if os.path.exists(p):
171
 
                        plugin_path = os.path.dirname(p)
172
 
                        break
173
 
            if plugin_path is not None:  # try loading
174
 
                p = os.getcwd()
175
 
                os.chdir(plugin_path)
176
 
                # if chdir failed, this will raise an exception
177
 
                dll = ctypes.CDLL(libname)
178
 
                # restore cwd after dll has been loaded
179
 
                os.chdir(p)
180
 
            else:  # may fail
181
 
                dll = ctypes.CDLL(libname)
182
 
        else:
183
 
            plugin_path = os.path.dirname(p)
184
 
            dll = ctypes.CDLL(p)
185
 
 
186
 
    elif sys.platform.startswith('darwin'):
187
 
        # FIXME: should find a means to configure path
188
 
        d = '/Applications/VLC.app/Contents/MacOS/'
189
 
        c = d + 'lib/libvlccore.dylib'
190
 
        p = d + 'lib/libvlc.dylib'
191
 
        if os.path.exists(p) and os.path.exists(c):
192
 
            # pre-load libvlccore VLC 2.2.8+
193
 
            ctypes.CDLL(c)
194
 
            dll = ctypes.CDLL(p)
195
 
            for p in ('modules', 'plugins'):
196
 
                p = d + p
197
 
                if os.path.isdir(p):
198
 
                    plugin_path = p
199
 
                    break
200
 
        else:  # hope, some [DY]LD_LIBRARY_PATH is set...
201
 
            # pre-load libvlccore VLC 2.2.8+
202
 
            ctypes.CDLL('libvlccore.dylib')
203
 
            dll = ctypes.CDLL('libvlc.dylib')
204
 
 
205
 
    else:
206
 
        raise NotImplementedError('%s: %s not supported' % (sys.argv[0], sys.platform))
207
 
 
208
 
    return (dll, plugin_path)
209
 
 
210
 
 
211
 
# plugin_path used on win32 and MacOS in override.py
212
 
dll, plugin_path = find_lib()
213
 
 
214
 
 
215
 
class VLCException(Exception):
216
 
    """Exception raised by libvlc methods.
217
 
    """
218
 
    pass
219
 
 
220
 
 
221
 
try:
222
 
    _Ints = (int, long)
223
 
except NameError:  # no long in Python 3+
224
 
    _Ints = int
225
 
_Seqs = (list, tuple)
226
 
 
227
 
 
228
 
# Used for handling *event_manager() methods.
229
 
class memoize_parameterless(object):
230
 
    """Decorator. Caches a parameterless method's return value each time it is called.
231
 
 
232
 
    If called later with the same arguments, the cached value is returned
233
 
    (not reevaluated).
234
 
    Adapted from https://wiki.python.org/moin/PythonDecoratorLibrary
235
 
    """
236
 
 
237
 
    def __init__(self, func):
238
 
        self.func = func
239
 
        self._cache = {}
240
 
 
241
 
    def __call__(self, obj):
242
 
        try:
243
 
            return self._cache[obj]
244
 
        except KeyError:
245
 
            v = self._cache[obj] = self.func(obj)
246
 
            return v
247
 
 
248
 
    def __repr__(self):
249
 
        """Return the function's docstring.
250
 
        """
251
 
        return self.func.__doc__
252
 
 
253
 
    def __get__(self, obj, objtype):
254
 
        """Support instance methods.
255
 
        """
256
 
        return functools.partial(self.__call__, obj)
257
 
 
258
 
 
259
 
# Default instance. It is used to instanciate classes directly in the
260
 
# OO-wrapper.
261
 
_default_instance = None
262
 
 
263
 
 
264
 
def get_default_instance():
265
 
    """Return the default VLC.Instance.
266
 
    """
267
 
    global _default_instance
268
 
    if _default_instance is None:
269
 
        _default_instance = Instance()
270
 
    return _default_instance
271
 
 
272
 
 
273
 
_Cfunctions = {}  # from LibVLC __version__
274
 
_Globals = globals()  # sys.modules[__name__].__dict__
275
 
 
276
 
 
277
 
def _Cfunction(name, flags, errcheck, *types):
278
 
    """(INTERNAL) New ctypes function binding.
279
 
    """
280
 
    if hasattr(dll, name) and name in _Globals:
281
 
        p = ctypes.CFUNCTYPE(*types)
282
 
        f = p((name, dll), flags)
283
 
        if errcheck is not None:
284
 
            f.errcheck = errcheck
285
 
        # replace the Python function
286
 
        # in this module, but only when
287
 
        # running as python -O or -OO
288
 
        if __debug__:
289
 
            _Cfunctions[name] = f
290
 
        else:
291
 
            _Globals[name] = f
292
 
        return f
293
 
    raise NameError('no function %r' % (name,))
294
 
 
295
 
 
296
 
def _Cobject(cls, ctype):
297
 
    """(INTERNAL) New instance from ctypes.
298
 
    """
299
 
    o = object.__new__(cls)
300
 
    o._as_parameter_ = ctype
301
 
    return o
302
 
 
303
 
 
304
 
def _Constructor(cls, ptr=_internal_guard):
305
 
    """(INTERNAL) New wrapper from ctypes.
306
 
    """
307
 
    if ptr == _internal_guard:
308
 
        raise VLCException(
309
 
            "(INTERNAL) ctypes class. You should get references for this class through methods of the LibVLC API.")
310
 
    if ptr is None or ptr == 0:
311
 
        return None
312
 
    return _Cobject(cls, ctypes.c_void_p(ptr))
313
 
 
314
 
 
315
 
class _Cstruct(ctypes.Structure):
316
 
    """(INTERNAL) Base class for ctypes structures.
317
 
    """
318
 
    _fields_ = []  # list of 2-tuples ('name', ctyptes.<type>)
319
 
 
320
 
    def __str__(self):
321
 
        l = [' %s:\t%s' % (n, getattr(self, n)) for n, _ in self._fields_]
322
 
        return '\n'.join([self.__class__.__name__] + l)
323
 
 
324
 
    def __repr__(self):
325
 
        return '%s.%s' % (self.__class__.__module__, self)
326
 
 
327
 
 
328
 
class _Ctype(object):
329
 
    """(INTERNAL) Base class for ctypes.
330
 
    """
331
 
 
332
 
    @staticmethod
333
 
    def from_param(this):  # not self
334
 
        """(INTERNAL) ctypes parameter conversion method.
335
 
        """
336
 
        if this is None:
337
 
            return None
338
 
        return this._as_parameter_
339
 
 
340
 
 
341
 
class ListPOINTER(object):
342
 
    """Just like a POINTER but accept a list of ctype as an argument.
343
 
    """
344
 
 
345
 
    def __init__(self, etype):
346
 
        self.etype = etype
347
 
 
348
 
    def from_param(self, param):
349
 
        if isinstance(param, _Seqs):
350
 
            return (self.etype * len(param))(*param)
351
 
        else:
352
 
            return ctypes.POINTER(param)
353
 
 
354
 
 
355
 
# errcheck functions for some native functions.
356
 
def string_result(result, func, arguments):
357
 
    """Errcheck function. Returns a string and frees the original pointer.
358
 
 
359
 
    It assumes the result is a char *.
360
 
    """
361
 
    if result:
362
 
        # make a python string copy
363
 
        s = bytes_to_str(ctypes.string_at(result))
364
 
        # free original string ptr
365
 
        libvlc_free(result)
366
 
        return s
367
 
    return None
368
 
 
369
 
 
370
 
def class_result(classname):
371
 
    """Errcheck function. Returns a function that creates the specified class.
372
 
    """
373
 
 
374
 
    def wrap_errcheck(result, func, arguments):
375
 
        if result is None:
376
 
            return None
377
 
        return classname(result)
378
 
 
379
 
    return wrap_errcheck
380
 
 
381
 
 
382
 
# Wrapper for the opaque struct libvlc_log_t
383
 
class Log(ctypes.Structure):
384
 
    pass
385
 
 
386
 
 
387
 
Log_ptr = ctypes.POINTER(Log)
388
 
 
389
 
 
390
 
# FILE* ctypes wrapper, copied from
391
 
# http://svn.python.org/projects/ctypes/trunk/ctypeslib/ctypeslib/contrib/pythonhdr.py
392
 
class FILE(ctypes.Structure):
393
 
    pass
394
 
 
395
 
 
396
 
FILE_ptr = ctypes.POINTER(FILE)
397
 
 
398
 
if PYTHON3:
399
 
    PyFile_FromFd = ctypes.pythonapi.PyFile_FromFd
400
 
    PyFile_FromFd.restype = ctypes.py_object
401
 
    PyFile_FromFd.argtypes = [ctypes.c_int,
402
 
                              ctypes.c_char_p,
403
 
                              ctypes.c_char_p,
404
 
                              ctypes.c_int,
405
 
                              ctypes.c_char_p,
406
 
                              ctypes.c_char_p,
407
 
                              ctypes.c_char_p,
408
 
                              ctypes.c_int]
409
 
 
410
 
    PyFile_AsFd = ctypes.pythonapi.PyObject_AsFileDescriptor
411
 
    PyFile_AsFd.restype = ctypes.c_int
412
 
    PyFile_AsFd.argtypes = [ctypes.py_object]
413
 
else:
414
 
    PyFile_FromFile = ctypes.pythonapi.PyFile_FromFile
415
 
    PyFile_FromFile.restype = ctypes.py_object
416
 
    PyFile_FromFile.argtypes = [FILE_ptr,
417
 
                                ctypes.c_char_p,
418
 
                                ctypes.c_char_p,
419
 
                                ctypes.CFUNCTYPE(ctypes.c_int, FILE_ptr)]
420
 
 
421
 
    PyFile_AsFile = ctypes.pythonapi.PyFile_AsFile
422
 
    PyFile_AsFile.restype = FILE_ptr
423
 
    PyFile_AsFile.argtypes = [ctypes.py_object]
424
 
 
425
 
 
426
 
# Generated enum types #
427
 
 
428
 
class _Enum(ctypes.c_uint):
429
 
    '''(INTERNAL) Base class
430
 
    '''
431
 
    _enum_names_ = {}
432
 
 
433
 
    def __str__(self):
434
 
        n = self._enum_names_.get(self.value, '') or ('FIXME_(%r)' % (self.value,))
435
 
        return '.'.join((self.__class__.__name__, n))
436
 
 
437
 
    def __hash__(self):
438
 
        return self.value
439
 
 
440
 
    def __repr__(self):
441
 
        return '.'.join((self.__class__.__module__, self.__str__()))
442
 
 
443
 
    def __eq__(self, other):
444
 
        return ((isinstance(other, _Enum) and self.value == other.value)
445
 
                or (isinstance(other, _Ints) and self.value == other))
446
 
 
447
 
    def __ne__(self, other):
448
 
        return not self.__eq__(other)
449
 
 
450
 
 
451
 
class LogLevel(_Enum):
452
 
    '''Logging messages level.
453
 
\note future libvlc versions may define new levels.
454
 
    '''
455
 
    _enum_names_ = {
456
 
        0: 'DEBUG',
457
 
        2: 'NOTICE',
458
 
        3: 'WARNING',
459
 
        4: 'ERROR',
460
 
    }
461
 
 
462
 
 
463
 
LogLevel.DEBUG = LogLevel(0)
464
 
LogLevel.ERROR = LogLevel(4)
465
 
LogLevel.NOTICE = LogLevel(2)
466
 
LogLevel.WARNING = LogLevel(3)
467
 
 
468
 
 
469
 
class MediaDiscovererCategory(_Enum):
470
 
    '''Category of a media discoverer
471
 
See libvlc_media_discoverer_list_get().
472
 
    '''
473
 
    _enum_names_ = {
474
 
        0: 'devices',
475
 
        1: 'lan',
476
 
        2: 'podcasts',
477
 
        3: 'localdirs',
478
 
    }
479
 
 
480
 
 
481
 
MediaDiscovererCategory.devices = MediaDiscovererCategory(0)
482
 
MediaDiscovererCategory.lan = MediaDiscovererCategory(1)
483
 
MediaDiscovererCategory.localdirs = MediaDiscovererCategory(3)
484
 
MediaDiscovererCategory.podcasts = MediaDiscovererCategory(2)
485
 
 
486
 
 
487
 
class DialogQuestionType(_Enum):
488
 
    '''@defgroup libvlc_dialog libvlc dialog
489
 
@ingroup libvlc
490
 
@{
491
 
@file
492
 
libvlc dialog external api.
493
 
    '''
494
 
    _enum_names_ = {
495
 
        0: 'NORMAL',
496
 
        1: 'WARNING',
497
 
        2: 'CRITICAL',
498
 
    }
499
 
 
500
 
 
501
 
DialogQuestionType.CRITICAL = DialogQuestionType(2)
502
 
DialogQuestionType.NORMAL = DialogQuestionType(0)
503
 
DialogQuestionType.WARNING = DialogQuestionType(1)
504
 
 
505
 
 
506
 
class EventType(_Enum):
507
 
    '''Event types.
508
 
    '''
509
 
    _enum_names_ = {
510
 
        0: 'MediaMetaChanged',
511
 
        1: 'MediaSubItemAdded',
512
 
        2: 'MediaDurationChanged',
513
 
        3: 'MediaParsedChanged',
514
 
        4: 'MediaFreed',
515
 
        5: 'MediaStateChanged',
516
 
        6: 'MediaSubItemTreeAdded',
517
 
        0x100: 'MediaPlayerMediaChanged',
518
 
        257: 'MediaPlayerNothingSpecial',
519
 
        258: 'MediaPlayerOpening',
520
 
        259: 'MediaPlayerBuffering',
521
 
        260: 'MediaPlayerPlaying',
522
 
        261: 'MediaPlayerPaused',
523
 
        262: 'MediaPlayerStopped',
524
 
        263: 'MediaPlayerForward',
525
 
        264: 'MediaPlayerBackward',
526
 
        265: 'MediaPlayerEndReached',
527
 
        266: 'MediaPlayerEncounteredError',
528
 
        267: 'MediaPlayerTimeChanged',
529
 
        268: 'MediaPlayerPositionChanged',
530
 
        269: 'MediaPlayerSeekableChanged',
531
 
        270: 'MediaPlayerPausableChanged',
532
 
        271: 'MediaPlayerTitleChanged',
533
 
        272: 'MediaPlayerSnapshotTaken',
534
 
        273: 'MediaPlayerLengthChanged',
535
 
        274: 'MediaPlayerVout',
536
 
        275: 'MediaPlayerScrambledChanged',
537
 
        276: 'MediaPlayerESAdded',
538
 
        277: 'MediaPlayerESDeleted',
539
 
        278: 'MediaPlayerESSelected',
540
 
        279: 'MediaPlayerCorked',
541
 
        280: 'MediaPlayerUncorked',
542
 
        281: 'MediaPlayerMuted',
543
 
        282: 'MediaPlayerUnmuted',
544
 
        283: 'MediaPlayerAudioVolume',
545
 
        284: 'MediaPlayerAudioDevice',
546
 
        285: 'MediaPlayerChapterChanged',
547
 
        0x200: 'MediaListItemAdded',
548
 
        513: 'MediaListWillAddItem',
549
 
        514: 'MediaListItemDeleted',
550
 
        515: 'MediaListWillDeleteItem',
551
 
        516: 'MediaListEndReached',
552
 
        0x300: 'MediaListViewItemAdded',
553
 
        769: 'MediaListViewWillAddItem',
554
 
        770: 'MediaListViewItemDeleted',
555
 
        771: 'MediaListViewWillDeleteItem',
556
 
        0x400: 'MediaListPlayerPlayed',
557
 
        1025: 'MediaListPlayerNextItemSet',
558
 
        1026: 'MediaListPlayerStopped',
559
 
        0x500: 'MediaDiscovererStarted',
560
 
        1281: 'MediaDiscovererEnded',
561
 
        1282: 'RendererDiscovererItemAdded',
562
 
        1283: 'RendererDiscovererItemDeleted',
563
 
        0x600: 'VlmMediaAdded',
564
 
        1537: 'VlmMediaRemoved',
565
 
        1538: 'VlmMediaChanged',
566
 
        1539: 'VlmMediaInstanceStarted',
567
 
        1540: 'VlmMediaInstanceStopped',
568
 
        1541: 'VlmMediaInstanceStatusInit',
569
 
        1542: 'VlmMediaInstanceStatusOpening',
570
 
        1543: 'VlmMediaInstanceStatusPlaying',
571
 
        1544: 'VlmMediaInstanceStatusPause',
572
 
        1545: 'VlmMediaInstanceStatusEnd',
573
 
        1546: 'VlmMediaInstanceStatusError',
574
 
    }
575
 
 
576
 
 
577
 
EventType.MediaDiscovererEnded = EventType(1281)
578
 
EventType.MediaDiscovererStarted = EventType(0x500)
579
 
EventType.MediaDurationChanged = EventType(2)
580
 
EventType.MediaFreed = EventType(4)
581
 
EventType.MediaListEndReached = EventType(516)
582
 
EventType.MediaListItemAdded = EventType(0x200)
583
 
EventType.MediaListItemDeleted = EventType(514)
584
 
EventType.MediaListPlayerNextItemSet = EventType(1025)
585
 
EventType.MediaListPlayerPlayed = EventType(0x400)
586
 
EventType.MediaListPlayerStopped = EventType(1026)
587
 
EventType.MediaListViewItemAdded = EventType(0x300)
588
 
EventType.MediaListViewItemDeleted = EventType(770)
589
 
EventType.MediaListViewWillAddItem = EventType(769)
590
 
EventType.MediaListViewWillDeleteItem = EventType(771)
591
 
EventType.MediaListWillAddItem = EventType(513)
592
 
EventType.MediaListWillDeleteItem = EventType(515)
593
 
EventType.MediaMetaChanged = EventType(0)
594
 
EventType.MediaParsedChanged = EventType(3)
595
 
EventType.MediaPlayerAudioDevice = EventType(284)
596
 
EventType.MediaPlayerAudioVolume = EventType(283)
597
 
EventType.MediaPlayerBackward = EventType(264)
598
 
EventType.MediaPlayerBuffering = EventType(259)
599
 
EventType.MediaPlayerChapterChanged = EventType(285)
600
 
EventType.MediaPlayerCorked = EventType(279)
601
 
EventType.MediaPlayerESAdded = EventType(276)
602
 
EventType.MediaPlayerESDeleted = EventType(277)
603
 
EventType.MediaPlayerESSelected = EventType(278)
604
 
EventType.MediaPlayerEncounteredError = EventType(266)
605
 
EventType.MediaPlayerEndReached = EventType(265)
606
 
EventType.MediaPlayerForward = EventType(263)
607
 
EventType.MediaPlayerLengthChanged = EventType(273)
608
 
EventType.MediaPlayerMediaChanged = EventType(0x100)
609
 
EventType.MediaPlayerMuted = EventType(281)
610
 
EventType.MediaPlayerNothingSpecial = EventType(257)
611
 
EventType.MediaPlayerOpening = EventType(258)
612
 
EventType.MediaPlayerPausableChanged = EventType(270)
613
 
EventType.MediaPlayerPaused = EventType(261)
614
 
EventType.MediaPlayerPlaying = EventType(260)
615
 
EventType.MediaPlayerPositionChanged = EventType(268)
616
 
EventType.MediaPlayerScrambledChanged = EventType(275)
617
 
EventType.MediaPlayerSeekableChanged = EventType(269)
618
 
EventType.MediaPlayerSnapshotTaken = EventType(272)
619
 
EventType.MediaPlayerStopped = EventType(262)
620
 
EventType.MediaPlayerTimeChanged = EventType(267)
621
 
EventType.MediaPlayerTitleChanged = EventType(271)
622
 
EventType.MediaPlayerUncorked = EventType(280)
623
 
EventType.MediaPlayerUnmuted = EventType(282)
624
 
EventType.MediaPlayerVout = EventType(274)
625
 
EventType.MediaStateChanged = EventType(5)
626
 
EventType.MediaSubItemAdded = EventType(1)
627
 
EventType.MediaSubItemTreeAdded = EventType(6)
628
 
EventType.RendererDiscovererItemAdded = EventType(1282)
629
 
EventType.RendererDiscovererItemDeleted = EventType(1283)
630
 
EventType.VlmMediaAdded = EventType(0x600)
631
 
EventType.VlmMediaChanged = EventType(1538)
632
 
EventType.VlmMediaInstanceStarted = EventType(1539)
633
 
EventType.VlmMediaInstanceStatusEnd = EventType(1545)
634
 
EventType.VlmMediaInstanceStatusError = EventType(1546)
635
 
EventType.VlmMediaInstanceStatusInit = EventType(1541)
636
 
EventType.VlmMediaInstanceStatusOpening = EventType(1542)
637
 
EventType.VlmMediaInstanceStatusPause = EventType(1544)
638
 
EventType.VlmMediaInstanceStatusPlaying = EventType(1543)
639
 
EventType.VlmMediaInstanceStopped = EventType(1540)
640
 
EventType.VlmMediaRemoved = EventType(1537)
641
 
 
642
 
 
643
 
class Meta(_Enum):
644
 
    '''Meta data types.
645
 
    '''
646
 
    _enum_names_ = {
647
 
        0: 'Title',
648
 
        1: 'Artist',
649
 
        2: 'Genre',
650
 
        3: 'Copyright',
651
 
        4: 'Album',
652
 
        5: 'TrackNumber',
653
 
        6: 'Description',
654
 
        7: 'Rating',
655
 
        8: 'Date',
656
 
        9: 'Setting',
657
 
        10: 'URL',
658
 
        11: 'Language',
659
 
        12: 'NowPlaying',
660
 
        13: 'Publisher',
661
 
        14: 'EncodedBy',
662
 
        15: 'ArtworkURL',
663
 
        16: 'TrackID',
664
 
        17: 'TrackTotal',
665
 
        18: 'Director',
666
 
        19: 'Season',
667
 
        20: 'Episode',
668
 
        21: 'ShowName',
669
 
        22: 'Actors',
670
 
        23: 'AlbumArtist',
671
 
        24: 'DiscNumber',
672
 
        25: 'DiscTotal',
673
 
    }
674
 
 
675
 
 
676
 
Meta.Actors = Meta(22)
677
 
Meta.Album = Meta(4)
678
 
Meta.AlbumArtist = Meta(23)
679
 
Meta.Artist = Meta(1)
680
 
Meta.ArtworkURL = Meta(15)
681
 
Meta.Copyright = Meta(3)
682
 
Meta.Date = Meta(8)
683
 
Meta.Description = Meta(6)
684
 
Meta.Director = Meta(18)
685
 
Meta.DiscNumber = Meta(24)
686
 
Meta.DiscTotal = Meta(25)
687
 
Meta.EncodedBy = Meta(14)
688
 
Meta.Episode = Meta(20)
689
 
Meta.Genre = Meta(2)
690
 
Meta.Language = Meta(11)
691
 
Meta.NowPlaying = Meta(12)
692
 
Meta.Publisher = Meta(13)
693
 
Meta.Rating = Meta(7)
694
 
Meta.Season = Meta(19)
695
 
Meta.Setting = Meta(9)
696
 
Meta.ShowName = Meta(21)
697
 
Meta.Title = Meta(0)
698
 
Meta.TrackID = Meta(16)
699
 
Meta.TrackNumber = Meta(5)
700
 
Meta.TrackTotal = Meta(17)
701
 
Meta.URL = Meta(10)
702
 
 
703
 
 
704
 
class State(_Enum):
705
 
    '''Note the order of libvlc_state_t enum must match exactly the order of
706
 
See mediacontrol_playerstatus, See input_state_e enums,
707
 
and videolan.libvlc.state (at bindings/cil/src/media.cs).
708
 
expected states by web plugins are:
709
 
idle/close=0, opening=1, playing=3, paused=4,
710
 
stopping=5, ended=6, error=7.
711
 
    '''
712
 
    _enum_names_ = {
713
 
        0: 'NothingSpecial',
714
 
        1: 'Opening',
715
 
        2: 'Buffering',
716
 
        3: 'Playing',
717
 
        4: 'Paused',
718
 
        5: 'Stopped',
719
 
        6: 'Ended',
720
 
        7: 'Error',
721
 
    }
722
 
 
723
 
 
724
 
State.Buffering = State(2)
725
 
State.Ended = State(6)
726
 
State.Error = State(7)
727
 
State.NothingSpecial = State(0)
728
 
State.Opening = State(1)
729
 
State.Paused = State(4)
730
 
State.Playing = State(3)
731
 
State.Stopped = State(5)
732
 
 
733
 
 
734
 
class TrackType(_Enum):
735
 
    '''N/A
736
 
    '''
737
 
    _enum_names_ = {
738
 
        -1: 'unknown',
739
 
        0: 'audio',
740
 
        1: 'video',
741
 
        2: 'text',
742
 
    }
743
 
 
744
 
 
745
 
TrackType.audio = TrackType(0)
746
 
TrackType.text = TrackType(2)
747
 
TrackType.unknown = TrackType(-1)
748
 
TrackType.video = TrackType(1)
749
 
 
750
 
 
751
 
class VideoOrient(_Enum):
752
 
    '''N/A
753
 
    '''
754
 
    _enum_names_ = {
755
 
        0: 'left',
756
 
        1: 'right',
757
 
        2: 'left',
758
 
        3: 'right',
759
 
        4: 'top',
760
 
        5: 'bottom',
761
 
        6: 'top',
762
 
        7: 'bottom',
763
 
    }
764
 
 
765
 
 
766
 
VideoOrient.bottom = VideoOrient(5)
767
 
VideoOrient.bottom = VideoOrient(7)
768
 
VideoOrient.left = VideoOrient(0)
769
 
VideoOrient.left = VideoOrient(2)
770
 
VideoOrient.right = VideoOrient(1)
771
 
VideoOrient.right = VideoOrient(3)
772
 
VideoOrient.top = VideoOrient(4)
773
 
VideoOrient.top = VideoOrient(6)
774
 
 
775
 
 
776
 
class VideoProjection(_Enum):
777
 
    '''N/A
778
 
    '''
779
 
    _enum_names_ = {
780
 
        0: 'rectangular',
781
 
        1: 'equirectangular',
782
 
        0x100: 'standard',
783
 
    }
784
 
 
785
 
 
786
 
VideoProjection.equirectangular = VideoProjection(1)
787
 
VideoProjection.rectangular = VideoProjection(0)
788
 
VideoProjection.standard = VideoProjection(0x100)
789
 
 
790
 
 
791
 
class MediaType(_Enum):
792
 
    '''Media type
793
 
See libvlc_media_get_type.
794
 
    '''
795
 
    _enum_names_ = {
796
 
        0: 'unknown',
797
 
        1: 'file',
798
 
        2: 'directory',
799
 
        3: 'disc',
800
 
        4: 'stream',
801
 
        5: 'playlist',
802
 
    }
803
 
 
804
 
 
805
 
MediaType.directory = MediaType(2)
806
 
MediaType.disc = MediaType(3)
807
 
MediaType.file = MediaType(1)
808
 
MediaType.playlist = MediaType(5)
809
 
MediaType.stream = MediaType(4)
810
 
MediaType.unknown = MediaType(0)
811
 
 
812
 
 
813
 
class MediaParseFlag(_Enum):
814
 
    '''Parse flags used by libvlc_media_parse_with_options()
815
 
See libvlc_media_parse_with_options.
816
 
    '''
817
 
    _enum_names_ = {
818
 
        0x0: 'local',
819
 
        0x1: 'network',
820
 
        0x2: 'local',
821
 
        0x4: 'network',
822
 
        0x8: 'interact',
823
 
    }
824
 
 
825
 
 
826
 
MediaParseFlag.interact = MediaParseFlag(0x8)
827
 
MediaParseFlag.local = MediaParseFlag(0x0)
828
 
MediaParseFlag.local = MediaParseFlag(0x2)
829
 
MediaParseFlag.network = MediaParseFlag(0x1)
830
 
MediaParseFlag.network = MediaParseFlag(0x4)
831
 
 
832
 
 
833
 
class MediaParsedStatus(_Enum):
834
 
    '''Parse status used sent by libvlc_media_parse_with_options() or returned by
835
 
libvlc_media_get_parsed_status()
836
 
See libvlc_media_parse_with_options
837
 
See libvlc_media_get_parsed_status.
838
 
    '''
839
 
    _enum_names_ = {
840
 
        1: 'skipped',
841
 
        2: 'failed',
842
 
        3: 'timeout',
843
 
        4: 'done',
844
 
    }
845
 
 
846
 
 
847
 
MediaParsedStatus.done = MediaParsedStatus(4)
848
 
MediaParsedStatus.failed = MediaParsedStatus(2)
849
 
MediaParsedStatus.skipped = MediaParsedStatus(1)
850
 
MediaParsedStatus.timeout = MediaParsedStatus(3)
851
 
 
852
 
 
853
 
class MediaSlaveType(_Enum):
854
 
    '''Type of a media slave: subtitle or audio.
855
 
    '''
856
 
    _enum_names_ = {
857
 
        0: 'subtitle',
858
 
        1: 'audio',
859
 
    }
860
 
 
861
 
 
862
 
MediaSlaveType.audio = MediaSlaveType(1)
863
 
MediaSlaveType.subtitle = MediaSlaveType(0)
864
 
 
865
 
 
866
 
class VideoMarqueeOption(_Enum):
867
 
    '''Marq options definition.
868
 
    '''
869
 
    _enum_names_ = {
870
 
        0: 'Enable',
871
 
        1: 'Text',
872
 
        2: 'Color',
873
 
        3: 'Opacity',
874
 
        4: 'Position',
875
 
        5: 'Refresh',
876
 
        6: 'Size',
877
 
        7: 'Timeout',
878
 
        8: 'marquee_X',
879
 
        9: 'marquee_Y',
880
 
    }
881
 
 
882
 
 
883
 
VideoMarqueeOption.Color = VideoMarqueeOption(2)
884
 
VideoMarqueeOption.Enable = VideoMarqueeOption(0)
885
 
VideoMarqueeOption.Opacity = VideoMarqueeOption(3)
886
 
VideoMarqueeOption.Position = VideoMarqueeOption(4)
887
 
VideoMarqueeOption.Refresh = VideoMarqueeOption(5)
888
 
VideoMarqueeOption.Size = VideoMarqueeOption(6)
889
 
VideoMarqueeOption.Text = VideoMarqueeOption(1)
890
 
VideoMarqueeOption.Timeout = VideoMarqueeOption(7)
891
 
VideoMarqueeOption.marquee_X = VideoMarqueeOption(8)
892
 
VideoMarqueeOption.marquee_Y = VideoMarqueeOption(9)
893
 
 
894
 
 
895
 
class NavigateMode(_Enum):
896
 
    '''Navigation mode.
897
 
    '''
898
 
    _enum_names_ = {
899
 
        0: 'activate',
900
 
        1: 'up',
901
 
        2: 'down',
902
 
        3: 'left',
903
 
        4: 'right',
904
 
        5: 'popup',
905
 
    }
906
 
 
907
 
 
908
 
NavigateMode.activate = NavigateMode(0)
909
 
NavigateMode.down = NavigateMode(2)
910
 
NavigateMode.left = NavigateMode(3)
911
 
NavigateMode.popup = NavigateMode(5)
912
 
NavigateMode.right = NavigateMode(4)
913
 
NavigateMode.up = NavigateMode(1)
914
 
 
915
 
 
916
 
class Position(_Enum):
917
 
    '''Enumeration of values used to set position (e.g. of video title).
918
 
    '''
919
 
    _enum_names_ = {
920
 
        -1: 'disable',
921
 
        0: 'center',
922
 
        1: 'left',
923
 
        2: 'right',
924
 
        3: 'top',
925
 
        4: 'left',
926
 
        5: 'right',
927
 
        6: 'bottom',
928
 
        7: 'left',
929
 
        8: 'right',
930
 
    }
931
 
 
932
 
 
933
 
Position.bottom = Position(6)
934
 
Position.center = Position(0)
935
 
Position.disable = Position(-1)
936
 
Position.left = Position(1)
937
 
Position.left = Position(4)
938
 
Position.left = Position(7)
939
 
Position.right = Position(2)
940
 
Position.right = Position(5)
941
 
Position.right = Position(8)
942
 
Position.top = Position(3)
943
 
 
944
 
 
945
 
class TeletextKey(_Enum):
946
 
    '''Enumeration of teletext keys than can be passed via
947
 
libvlc_video_set_teletext().
948
 
    '''
949
 
    _enum_names_ = {
950
 
        7471104: 'red',
951
 
        6750208: 'green',
952
 
        7929856: 'yellow',
953
 
        6422528: 'blue',
954
 
        6881280: 'index',
955
 
    }
956
 
 
957
 
 
958
 
TeletextKey.blue = TeletextKey(6422528)
959
 
TeletextKey.green = TeletextKey(6750208)
960
 
TeletextKey.index = TeletextKey(6881280)
961
 
TeletextKey.red = TeletextKey(7471104)
962
 
TeletextKey.yellow = TeletextKey(7929856)
963
 
 
964
 
 
965
 
class VideoLogoOption(_Enum):
966
 
    '''Option values for libvlc_video_{get,set}_logo_{int,string}.
967
 
    '''
968
 
    _enum_names_ = {
969
 
        0: 'enable',
970
 
        1: 'file',
971
 
        2: 'logo_x',
972
 
        3: 'logo_y',
973
 
        4: 'delay',
974
 
        5: 'repeat',
975
 
        6: 'opacity',
976
 
        7: 'position',
977
 
    }
978
 
 
979
 
 
980
 
VideoLogoOption.delay = VideoLogoOption(4)
981
 
VideoLogoOption.enable = VideoLogoOption(0)
982
 
VideoLogoOption.file = VideoLogoOption(1)
983
 
VideoLogoOption.logo_x = VideoLogoOption(2)
984
 
VideoLogoOption.logo_y = VideoLogoOption(3)
985
 
VideoLogoOption.opacity = VideoLogoOption(6)
986
 
VideoLogoOption.position = VideoLogoOption(7)
987
 
VideoLogoOption.repeat = VideoLogoOption(5)
988
 
 
989
 
 
990
 
class VideoAdjustOption(_Enum):
991
 
    '''Option values for libvlc_video_{get,set}_adjust_{int,float,bool}.
992
 
    '''
993
 
    _enum_names_ = {
994
 
        0: 'Enable',
995
 
        1: 'Contrast',
996
 
        2: 'Brightness',
997
 
        3: 'Hue',
998
 
        4: 'Saturation',
999
 
        5: 'Gamma',
1000
 
    }
1001
 
 
1002
 
 
1003
 
VideoAdjustOption.Brightness = VideoAdjustOption(2)
1004
 
VideoAdjustOption.Contrast = VideoAdjustOption(1)
1005
 
VideoAdjustOption.Enable = VideoAdjustOption(0)
1006
 
VideoAdjustOption.Gamma = VideoAdjustOption(5)
1007
 
VideoAdjustOption.Hue = VideoAdjustOption(3)
1008
 
VideoAdjustOption.Saturation = VideoAdjustOption(4)
1009
 
 
1010
 
 
1011
 
class AudioOutputDeviceTypes(_Enum):
1012
 
    '''Audio device types.
1013
 
    '''
1014
 
    _enum_names_ = {
1015
 
        -1: 'Error',
1016
 
        1: 'Mono',
1017
 
        2: 'Stereo',
1018
 
        4: '_2F2R',
1019
 
        5: '_3F2R',
1020
 
        6: '_5_1',
1021
 
        7: '_6_1',
1022
 
        8: '_7_1',
1023
 
        10: 'SPDIF',
1024
 
    }
1025
 
 
1026
 
 
1027
 
AudioOutputDeviceTypes.Error = AudioOutputDeviceTypes(-1)
1028
 
AudioOutputDeviceTypes.Mono = AudioOutputDeviceTypes(1)
1029
 
AudioOutputDeviceTypes.SPDIF = AudioOutputDeviceTypes(10)
1030
 
AudioOutputDeviceTypes.Stereo = AudioOutputDeviceTypes(2)
1031
 
AudioOutputDeviceTypes._2F2R = AudioOutputDeviceTypes(4)
1032
 
AudioOutputDeviceTypes._3F2R = AudioOutputDeviceTypes(5)
1033
 
AudioOutputDeviceTypes._5_1 = AudioOutputDeviceTypes(6)
1034
 
AudioOutputDeviceTypes._6_1 = AudioOutputDeviceTypes(7)
1035
 
AudioOutputDeviceTypes._7_1 = AudioOutputDeviceTypes(8)
1036
 
 
1037
 
 
1038
 
class AudioOutputChannel(_Enum):
1039
 
    '''Audio channels.
1040
 
    '''
1041
 
    _enum_names_ = {
1042
 
        -1: 'Error',
1043
 
        1: 'Stereo',
1044
 
        2: 'RStereo',
1045
 
        3: 'Left',
1046
 
        4: 'Right',
1047
 
        5: 'Dolbys',
1048
 
    }
1049
 
 
1050
 
 
1051
 
AudioOutputChannel.Dolbys = AudioOutputChannel(5)
1052
 
AudioOutputChannel.Error = AudioOutputChannel(-1)
1053
 
AudioOutputChannel.Left = AudioOutputChannel(3)
1054
 
AudioOutputChannel.RStereo = AudioOutputChannel(2)
1055
 
AudioOutputChannel.Right = AudioOutputChannel(4)
1056
 
AudioOutputChannel.Stereo = AudioOutputChannel(1)
1057
 
 
1058
 
 
1059
 
class MediaPlayerRole(_Enum):
1060
 
    '''Media player roles.
1061
 
\version libvlc 3.0.0 and later.
1062
 
see \ref libvlc_media_player_set_role().
1063
 
    '''
1064
 
    _enum_names_ = {
1065
 
        0: '_None',
1066
 
        1: 'Music',
1067
 
        2: 'Video',
1068
 
        3: 'Communication',
1069
 
        4: 'Game',
1070
 
        5: 'Notification',
1071
 
        6: 'Animation',
1072
 
        7: 'Production',
1073
 
        8: 'Accessibility',
1074
 
        9: 'Test',
1075
 
    }
1076
 
 
1077
 
 
1078
 
MediaPlayerRole.Accessibility = MediaPlayerRole(8)
1079
 
MediaPlayerRole.Animation = MediaPlayerRole(6)
1080
 
MediaPlayerRole.Communication = MediaPlayerRole(3)
1081
 
MediaPlayerRole.Game = MediaPlayerRole(4)
1082
 
MediaPlayerRole.Music = MediaPlayerRole(1)
1083
 
MediaPlayerRole.Notification = MediaPlayerRole(5)
1084
 
MediaPlayerRole.Production = MediaPlayerRole(7)
1085
 
MediaPlayerRole.Test = MediaPlayerRole(9)
1086
 
MediaPlayerRole.Video = MediaPlayerRole(2)
1087
 
MediaPlayerRole._None = MediaPlayerRole(0)
1088
 
 
1089
 
 
1090
 
class PlaybackMode(_Enum):
1091
 
    '''Defines playback modes for playlist.
1092
 
    '''
1093
 
    _enum_names_ = {
1094
 
        0: 'default',
1095
 
        1: 'loop',
1096
 
        2: 'repeat',
1097
 
    }
1098
 
 
1099
 
 
1100
 
PlaybackMode.default = PlaybackMode(0)
1101
 
PlaybackMode.loop = PlaybackMode(1)
1102
 
PlaybackMode.repeat = PlaybackMode(2)
1103
 
 
1104
 
 
1105
 
class Callback(ctypes.c_void_p):
1106
 
    """Callback function notification.
1107
 
    @param p_event: the event triggering the callback.
1108
 
    """
1109
 
    pass
1110
 
 
1111
 
 
1112
 
class LogCb(ctypes.c_void_p):
1113
 
    """Callback prototype for LibVLC log message handler.
1114
 
    @param data: data pointer as given to L{libvlc_log_set}().
1115
 
    @param level: message level (@ref L{LogLevel}).
1116
 
    @param ctx: message context (meta-information about the message).
1117
 
    @param fmt: printf() format string (as defined by ISO C11).
1118
 
    @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.
1119
 
    """
1120
 
    pass
1121
 
 
1122
 
 
1123
 
class MediaOpenCb(ctypes.c_void_p):
1124
 
    """Callback prototype to open a custom bitstream input media.
1125
 
    The same media item can be opened multiple times. Each time, this callback
1126
 
    is invoked. It should allocate and initialize any instance-specific
1127
 
    resources, then store them in *datap. The instance resources can be freed
1128
 
    in the @ref libvlc_media_close_cb callback.
1129
 
    @param opaque: private pointer as passed to L{libvlc_media_new_callbacks}().
1130
 
    @return: datap storage space for a private data pointer, sizep byte length of the bitstream or UINT64_MAX if unknown.
1131
 
    """
1132
 
    pass
1133
 
 
1134
 
 
1135
 
class MediaReadCb(ctypes.c_void_p):
1136
 
    """Callback prototype to read data from a custom bitstream input media.
1137
 
    @param opaque: private pointer as set by the @ref libvlc_media_open_cb callback.
1138
 
    @param buf: start address of the buffer to read data into.
1139
 
    @param len: bytes length of the buffer.
1140
 
    @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.
1141
 
    """
1142
 
    pass
1143
 
 
1144
 
 
1145
 
class MediaSeekCb(ctypes.c_void_p):
1146
 
    """Callback prototype to seek a custom bitstream input media.
1147
 
    @param opaque: private pointer as set by the @ref libvlc_media_open_cb callback.
1148
 
    @param offset: absolute byte offset to seek to.
1149
 
    @return: 0 on success, -1 on error.
1150
 
    """
1151
 
    pass
1152
 
 
1153
 
 
1154
 
class MediaCloseCb(ctypes.c_void_p):
1155
 
    """Callback prototype to close a custom bitstream input media.
1156
 
    @param opaque: private pointer as set by the @ref libvlc_media_open_cb callback.
1157
 
    """
1158
 
    pass
1159
 
 
1160
 
 
1161
 
class VideoLockCb(ctypes.c_void_p):
1162
 
    """Callback prototype to allocate and lock a picture buffer.
1163
 
    Whenever a new video frame needs to be decoded, the lock callback is
1164
 
    invoked. Depending on the video chroma, one or three pixel planes of
1165
 
    adequate dimensions must be returned via the second parameter. Those
1166
 
    planes must be aligned on 32-bytes boundaries.
1167
 
    @param opaque: private pointer as passed to L{libvlc_video_set_callbacks}() [IN].
1168
 
    @param planes: start address of the pixel planes (LibVLC allocates the array of void pointers, this callback must initialize the array) [OUT].
1169
 
    @return: a private pointer for the display and unlock callbacks to identify the picture buffers.
1170
 
    """
1171
 
    pass
1172
 
 
1173
 
 
1174
 
class VideoUnlockCb(ctypes.c_void_p):
1175
 
    """Callback prototype to unlock a picture buffer.
1176
 
    When the video frame decoding is complete, the unlock callback is invoked.
1177
 
    This callback might not be needed at all. It is only an indication that the
1178
 
    application can now read the pixel values if it needs to.
1179
 
    @note: A picture buffer is unlocked after the picture is decoded,
1180
 
    but before the picture is displayed.
1181
 
    @param opaque: private pointer as passed to L{libvlc_video_set_callbacks}() [IN].
1182
 
    @param picture: private pointer returned from the @ref libvlc_video_lock_cb callback [IN].
1183
 
    @param planes: pixel planes as defined by the @ref libvlc_video_lock_cb callback (this parameter is only for convenience) [IN].
1184
 
    """
1185
 
    pass
1186
 
 
1187
 
 
1188
 
class VideoDisplayCb(ctypes.c_void_p):
1189
 
    """Callback prototype to display a picture.
1190
 
    When the video frame needs to be shown, as determined by the media playback
1191
 
    clock, the display callback is invoked.
1192
 
    @param opaque: private pointer as passed to L{libvlc_video_set_callbacks}() [IN].
1193
 
    @param picture: private pointer returned from the @ref libvlc_video_lock_cb callback [IN].
1194
 
    """
1195
 
    pass
1196
 
 
1197
 
 
1198
 
class VideoFormatCb(ctypes.c_void_p):
1199
 
    """Callback prototype to configure picture buffers format.
1200
 
    This callback gets the format of the video as output by the video decoder
1201
 
    and the chain of video filters (if any). It can opt to change any parameter
1202
 
    as it needs. In that case, LibVLC will attempt to convert the video format
1203
 
    (rescaling and chroma conversion) but these operations can be CPU intensive.
1204
 
    @param opaque: pointer to the private pointer passed to L{libvlc_video_set_callbacks}() [IN/OUT].
1205
 
    @param chroma: pointer to the 4 bytes video format identifier [IN/OUT].
1206
 
    @param width: pointer to the pixel width [IN/OUT].
1207
 
    @param height: pointer to the pixel height [IN/OUT].
1208
 
    @param pitches: table of scanline pitches in bytes for each pixel plane (the table is allocated by LibVLC) [OUT].
1209
 
    @return: lines table of scanlines count for each plane.
1210
 
    """
1211
 
    pass
1212
 
 
1213
 
 
1214
 
class VideoCleanupCb(ctypes.c_void_p):
1215
 
    """Callback prototype to configure picture buffers format.
1216
 
    @param opaque: private pointer as passed to L{libvlc_video_set_callbacks}() (and possibly modified by @ref libvlc_video_format_cb) [IN].
1217
 
    """
1218
 
    pass
1219
 
 
1220
 
 
1221
 
class AudioPlayCb(ctypes.c_void_p):
1222
 
    """Callback prototype for audio playback.
1223
 
    The LibVLC media player decodes and post-processes the audio signal
1224
 
    asynchronously (in an internal thread). Whenever audio samples are ready
1225
 
    to be queued to the output, this callback is invoked.
1226
 
    The number of samples provided per invocation may depend on the file format,
1227
 
    the audio coding algorithm, the decoder plug-in, the post-processing
1228
 
    filters and timing. Application must not assume a certain number of samples.
1229
 
    The exact format of audio samples is determined by L{libvlc_audio_set_format}()
1230
 
    or L{libvlc_audio_set_format_callbacks}() as is the channels layout.
1231
 
    Note that the number of samples is per channel. For instance, if the audio
1232
 
    track sampling rate is 48000 Hz, then 1200 samples represent 25 milliseconds
1233
 
    of audio signal - regardless of the number of audio channels.
1234
 
    @param data: data pointer as passed to L{libvlc_audio_set_callbacks}() [IN].
1235
 
    @param samples: pointer to a table of audio samples to play back [IN].
1236
 
    @param count: number of audio samples to play back.
1237
 
    @param pts: expected play time stamp (see libvlc_delay()).
1238
 
    """
1239
 
    pass
1240
 
 
1241
 
 
1242
 
class AudioPauseCb(ctypes.c_void_p):
1243
 
    """Callback prototype for audio pause.
1244
 
    LibVLC invokes this callback to pause audio playback.
1245
 
    @note: The pause callback is never called if the audio is already paused.
1246
 
    @param data: data pointer as passed to L{libvlc_audio_set_callbacks}() [IN].
1247
 
    @param pts: time stamp of the pause request (should be elapsed already).
1248
 
    """
1249
 
    pass
1250
 
 
1251
 
 
1252
 
class AudioResumeCb(ctypes.c_void_p):
1253
 
    """Callback prototype for audio resumption.
1254
 
    LibVLC invokes this callback to resume audio playback after it was
1255
 
    previously paused.
1256
 
    @note: The resume callback is never called if the audio is not paused.
1257
 
    @param data: data pointer as passed to L{libvlc_audio_set_callbacks}() [IN].
1258
 
    @param pts: time stamp of the resumption request (should be elapsed already).
1259
 
    """
1260
 
    pass
1261
 
 
1262
 
 
1263
 
class AudioFlushCb(ctypes.c_void_p):
1264
 
    """Callback prototype for audio buffer flush.
1265
 
    LibVLC invokes this callback if it needs to discard all pending buffers and
1266
 
    stop playback as soon as possible. This typically occurs when the media is
1267
 
    stopped.
1268
 
    @param data: data pointer as passed to L{libvlc_audio_set_callbacks}() [IN].
1269
 
    """
1270
 
    pass
1271
 
 
1272
 
 
1273
 
class AudioDrainCb(ctypes.c_void_p):
1274
 
    """Callback prototype for audio buffer drain.
1275
 
    LibVLC may invoke this callback when the decoded audio track is ending.
1276
 
    There will be no further decoded samples for the track, but playback should
1277
 
    nevertheless continue until all already pending buffers are rendered.
1278
 
    @param data: data pointer as passed to L{libvlc_audio_set_callbacks}() [IN].
1279
 
    """
1280
 
    pass
1281
 
 
1282
 
 
1283
 
class AudioSetVolumeCb(ctypes.c_void_p):
1284
 
    """Callback prototype for audio volume change.
1285
 
    @param data: data pointer as passed to L{libvlc_audio_set_callbacks}() [IN].
1286
 
    @param volume: software volume (1. = nominal, 0. = mute).
1287
 
    @param mute: muted flag.
1288
 
    """
1289
 
    pass
1290
 
 
1291
 
 
1292
 
class AudioSetupCb(ctypes.c_void_p):
1293
 
    """Callback prototype to setup the audio playback.
1294
 
    This is called when the media player needs to create a new audio output.
1295
 
    @param opaque: pointer to the data pointer passed to L{libvlc_audio_set_callbacks}() [IN/OUT].
1296
 
    @param format: 4 bytes sample format [IN/OUT].
1297
 
    @param rate: sample rate [IN/OUT].
1298
 
    @param channels: channels count [IN/OUT].
1299
 
    @return: 0 on success, anything else to skip audio playback.
1300
 
    """
1301
 
    pass
1302
 
 
1303
 
 
1304
 
class AudioCleanupCb(ctypes.c_void_p):
1305
 
    """Callback prototype for audio playback cleanup.
1306
 
    This is called when the media player no longer needs an audio output.
1307
 
    @param opaque: data pointer as passed to L{libvlc_audio_set_callbacks}() [IN].
1308
 
    """
1309
 
    pass
1310
 
 
1311
 
 
1312
 
class CallbackDecorators(object):
1313
 
    "Class holding various method decorators for callback functions."
1314
 
    Callback = ctypes.CFUNCTYPE(ctypes.c_void_p, ctypes.c_void_p, ctypes.c_void_p)
1315
 
    Callback.__doc__ = '''Callback function notification.
1316
 
        @param p_event: the event triggering the callback.
1317
 
    '''
1318
 
    LogCb = ctypes.CFUNCTYPE(ctypes.c_void_p, ctypes.c_void_p, ctypes.c_int, Log_ptr, ctypes.c_char_p, ctypes.c_void_p)
1319
 
    LogCb.__doc__ = '''Callback prototype for LibVLC log message handler.
1320
 
        @param data: data pointer as given to L{libvlc_log_set}().
1321
 
        @param level: message level (@ref L{LogLevel}).
1322
 
        @param ctx: message context (meta-information about the message).
1323
 
        @param fmt: printf() format string (as defined by ISO C11).
1324
 
        @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.
1325
 
    '''
1326
 
    MediaOpenCb = ctypes.CFUNCTYPE(ctypes.POINTER(ctypes.c_int), ctypes.c_void_p, ctypes.POINTER(ctypes.c_void_p),
1327
 
                                   ctypes.POINTER(ctypes.c_uint64))
1328
 
    MediaOpenCb.__doc__ = '''Callback prototype to open a custom bitstream input media.
1329
 
        The same media item can be opened multiple times. Each time, this callback
1330
 
        is invoked. It should allocate and initialize any instance-specific
1331
 
        resources, then store them in *datap. The instance resources can be freed
1332
 
        in the @ref libvlc_media_close_cb callback.
1333
 
        @param opaque: private pointer as passed to L{libvlc_media_new_callbacks}().
1334
 
        @return: datap storage space for a private data pointer, sizep byte length of the bitstream or UINT64_MAX if unknown.
1335
 
    '''
1336
 
    MediaReadCb = ctypes.CFUNCTYPE(ctypes.POINTER(ctypes.c_ssize_t), ctypes.c_void_p, ctypes.c_char_p, ctypes.c_size_t)
1337
 
    MediaReadCb.__doc__ = '''Callback prototype to read data from a custom bitstream input media.
1338
 
        @param opaque: private pointer as set by the @ref libvlc_media_open_cb callback.
1339
 
        @param buf: start address of the buffer to read data into.
1340
 
        @param len: bytes length of the buffer.
1341
 
        @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.
1342
 
    '''
1343
 
    MediaSeekCb = ctypes.CFUNCTYPE(ctypes.POINTER(ctypes.c_int), ctypes.c_void_p, ctypes.c_uint64)
1344
 
    MediaSeekCb.__doc__ = '''Callback prototype to seek a custom bitstream input media.
1345
 
        @param opaque: private pointer as set by the @ref libvlc_media_open_cb callback.
1346
 
        @param offset: absolute byte offset to seek to.
1347
 
        @return: 0 on success, -1 on error.
1348
 
    '''
1349
 
    MediaCloseCb = ctypes.CFUNCTYPE(ctypes.c_void_p, ctypes.c_void_p)
1350
 
    MediaCloseCb.__doc__ = '''Callback prototype to close a custom bitstream input media.
1351
 
        @param opaque: private pointer as set by the @ref libvlc_media_open_cb callback.
1352
 
    '''
1353
 
    VideoLockCb = ctypes.CFUNCTYPE(ctypes.c_void_p, ctypes.c_void_p, ctypes.POINTER(ctypes.c_void_p))
1354
 
    VideoLockCb.__doc__ = '''Callback prototype to allocate and lock a picture buffer.
1355
 
        Whenever a new video frame needs to be decoded, the lock callback is
1356
 
        invoked. Depending on the video chroma, one or three pixel planes of
1357
 
        adequate dimensions must be returned via the second parameter. Those
1358
 
        planes must be aligned on 32-bytes boundaries.
1359
 
        @param opaque: private pointer as passed to L{libvlc_video_set_callbacks}() [IN].
1360
 
        @param planes: start address of the pixel planes (LibVLC allocates the array of void pointers, this callback must initialize the array) [OUT].
1361
 
        @return: a private pointer for the display and unlock callbacks to identify the picture buffers.
1362
 
    '''
1363
 
    VideoUnlockCb = ctypes.CFUNCTYPE(ctypes.c_void_p, ctypes.c_void_p, ctypes.c_void_p, ctypes.POINTER(ctypes.c_void_p))
1364
 
    VideoUnlockCb.__doc__ = '''Callback prototype to unlock a picture buffer.
1365
 
        When the video frame decoding is complete, the unlock callback is invoked.
1366
 
        This callback might not be needed at all. It is only an indication that the
1367
 
        application can now read the pixel values if it needs to.
1368
 
        @note: A picture buffer is unlocked after the picture is decoded,
1369
 
        but before the picture is displayed.
1370
 
        @param opaque: private pointer as passed to L{libvlc_video_set_callbacks}() [IN].
1371
 
        @param picture: private pointer returned from the @ref libvlc_video_lock_cb callback [IN].
1372
 
        @param planes: pixel planes as defined by the @ref libvlc_video_lock_cb callback (this parameter is only for convenience) [IN].
1373
 
    '''
1374
 
    VideoDisplayCb = ctypes.CFUNCTYPE(ctypes.c_void_p, ctypes.c_void_p, ctypes.c_void_p)
1375
 
    VideoDisplayCb.__doc__ = '''Callback prototype to display a picture.
1376
 
        When the video frame needs to be shown, as determined by the media playback
1377
 
        clock, the display callback is invoked.
1378
 
        @param opaque: private pointer as passed to L{libvlc_video_set_callbacks}() [IN].
1379
 
        @param picture: private pointer returned from the @ref libvlc_video_lock_cb callback [IN].
1380
 
    '''
1381
 
    VideoFormatCb = ctypes.CFUNCTYPE(ctypes.POINTER(ctypes.c_uint), ctypes.POINTER(ctypes.c_void_p), ctypes.c_char_p,
1382
 
                                     ctypes.POINTER(ctypes.c_uint), ctypes.POINTER(ctypes.c_uint),
1383
 
                                     ctypes.POINTER(ctypes.c_uint), ctypes.POINTER(ctypes.c_uint))
1384
 
    VideoFormatCb.__doc__ = '''Callback prototype to configure picture buffers format.
1385
 
        This callback gets the format of the video as output by the video decoder
1386
 
        and the chain of video filters (if any). It can opt to change any parameter
1387
 
        as it needs. In that case, LibVLC will attempt to convert the video format
1388
 
        (rescaling and chroma conversion) but these operations can be CPU intensive.
1389
 
        @param opaque: pointer to the private pointer passed to L{libvlc_video_set_callbacks}() [IN/OUT].
1390
 
        @param chroma: pointer to the 4 bytes video format identifier [IN/OUT].
1391
 
        @param width: pointer to the pixel width [IN/OUT].
1392
 
        @param height: pointer to the pixel height [IN/OUT].
1393
 
        @param pitches: table of scanline pitches in bytes for each pixel plane (the table is allocated by LibVLC) [OUT].
1394
 
        @return: lines table of scanlines count for each plane.
1395
 
    '''
1396
 
    VideoCleanupCb = ctypes.CFUNCTYPE(ctypes.c_void_p, ctypes.c_void_p)
1397
 
    VideoCleanupCb.__doc__ = '''Callback prototype to configure picture buffers format.
1398
 
        @param opaque: private pointer as passed to L{libvlc_video_set_callbacks}() (and possibly modified by @ref libvlc_video_format_cb) [IN].
1399
 
    '''
1400
 
    AudioPlayCb = ctypes.CFUNCTYPE(ctypes.c_void_p, ctypes.c_void_p, ctypes.c_void_p, ctypes.c_uint, ctypes.c_int64)
1401
 
    AudioPlayCb.__doc__ = '''Callback prototype for audio playback.
1402
 
        The LibVLC media player decodes and post-processes the audio signal
1403
 
        asynchronously (in an internal thread). Whenever audio samples are ready
1404
 
        to be queued to the output, this callback is invoked.
1405
 
        The number of samples provided per invocation may depend on the file format,
1406
 
        the audio coding algorithm, the decoder plug-in, the post-processing
1407
 
        filters and timing. Application must not assume a certain number of samples.
1408
 
        The exact format of audio samples is determined by L{libvlc_audio_set_format}()
1409
 
        or L{libvlc_audio_set_format_callbacks}() as is the channels layout.
1410
 
        Note that the number of samples is per channel. For instance, if the audio
1411
 
        track sampling rate is 48000 Hz, then 1200 samples represent 25 milliseconds
1412
 
        of audio signal - regardless of the number of audio channels.
1413
 
        @param data: data pointer as passed to L{libvlc_audio_set_callbacks}() [IN].
1414
 
        @param samples: pointer to a table of audio samples to play back [IN].
1415
 
        @param count: number of audio samples to play back.
1416
 
        @param pts: expected play time stamp (see libvlc_delay()).
1417
 
    '''
1418
 
    AudioPauseCb = ctypes.CFUNCTYPE(ctypes.c_void_p, ctypes.c_void_p, ctypes.c_int64)
1419
 
    AudioPauseCb.__doc__ = '''Callback prototype for audio pause.
1420
 
        LibVLC invokes this callback to pause audio playback.
1421
 
        @note: The pause callback is never called if the audio is already paused.
1422
 
        @param data: data pointer as passed to L{libvlc_audio_set_callbacks}() [IN].
1423
 
        @param pts: time stamp of the pause request (should be elapsed already).
1424
 
    '''
1425
 
    AudioResumeCb = ctypes.CFUNCTYPE(ctypes.c_void_p, ctypes.c_void_p, ctypes.c_int64)
1426
 
    AudioResumeCb.__doc__ = '''Callback prototype for audio resumption.
1427
 
        LibVLC invokes this callback to resume audio playback after it was
1428
 
        previously paused.
1429
 
        @note: The resume callback is never called if the audio is not paused.
1430
 
        @param data: data pointer as passed to L{libvlc_audio_set_callbacks}() [IN].
1431
 
        @param pts: time stamp of the resumption request (should be elapsed already).
1432
 
    '''
1433
 
    AudioFlushCb = ctypes.CFUNCTYPE(ctypes.c_void_p, ctypes.c_void_p, ctypes.c_int64)
1434
 
    AudioFlushCb.__doc__ = '''Callback prototype for audio buffer flush.
1435
 
        LibVLC invokes this callback if it needs to discard all pending buffers and
1436
 
        stop playback as soon as possible. This typically occurs when the media is
1437
 
        stopped.
1438
 
        @param data: data pointer as passed to L{libvlc_audio_set_callbacks}() [IN].
1439
 
    '''
1440
 
    AudioDrainCb = ctypes.CFUNCTYPE(ctypes.c_void_p, ctypes.c_void_p)
1441
 
    AudioDrainCb.__doc__ = '''Callback prototype for audio buffer drain.
1442
 
        LibVLC may invoke this callback when the decoded audio track is ending.
1443
 
        There will be no further decoded samples for the track, but playback should
1444
 
        nevertheless continue until all already pending buffers are rendered.
1445
 
        @param data: data pointer as passed to L{libvlc_audio_set_callbacks}() [IN].
1446
 
    '''
1447
 
    AudioSetVolumeCb = ctypes.CFUNCTYPE(ctypes.c_void_p, ctypes.c_void_p, ctypes.c_float, ctypes.c_bool)
1448
 
    AudioSetVolumeCb.__doc__ = '''Callback prototype for audio volume change.
1449
 
        @param data: data pointer as passed to L{libvlc_audio_set_callbacks}() [IN].
1450
 
        @param volume: software volume (1. = nominal, 0. = mute).
1451
 
        @param mute: muted flag.
1452
 
    '''
1453
 
    AudioSetupCb = ctypes.CFUNCTYPE(ctypes.POINTER(ctypes.c_int), ctypes.POINTER(ctypes.c_void_p), ctypes.c_char_p,
1454
 
                                    ctypes.POINTER(ctypes.c_uint), ctypes.POINTER(ctypes.c_uint))
1455
 
    AudioSetupCb.__doc__ = '''Callback prototype to setup the audio playback.
1456
 
        This is called when the media player needs to create a new audio output.
1457
 
        @param opaque: pointer to the data pointer passed to L{libvlc_audio_set_callbacks}() [IN/OUT].
1458
 
        @param format: 4 bytes sample format [IN/OUT].
1459
 
        @param rate: sample rate [IN/OUT].
1460
 
        @param channels: channels count [IN/OUT].
1461
 
        @return: 0 on success, anything else to skip audio playback.
1462
 
    '''
1463
 
    AudioCleanupCb = ctypes.CFUNCTYPE(ctypes.c_void_p, ctypes.c_void_p)
1464
 
    AudioCleanupCb.__doc__ = '''Callback prototype for audio playback cleanup.
1465
 
        This is called when the media player no longer needs an audio output.
1466
 
        @param opaque: data pointer as passed to L{libvlc_audio_set_callbacks}() [IN].
1467
 
    '''
1468
 
 
1469
 
 
1470
 
cb = CallbackDecorators
1471
 
 
1472
 
 
1473
 
# End of generated enum types #
1474
 
 
1475
 
# From libvlc_structures.h
1476
 
 
1477
 
class AudioOutput(_Cstruct):
1478
 
 
1479
 
    def __str__(self):
1480
 
        return '%s(%s:%s)' % (self.__class__.__name__, self.name, self.description)
1481
 
 
1482
 
 
1483
 
AudioOutput._fields_ = [  # recursive struct
1484
 
    ('name', ctypes.c_char_p),
1485
 
    ('description', ctypes.c_char_p),
1486
 
    ('next', ctypes.POINTER(AudioOutput)),
1487
 
]
1488
 
 
1489
 
 
1490
 
class LogMessage(_Cstruct):
1491
 
    _fields_ = [
1492
 
        ('size', ctypes.c_uint),
1493
 
        ('severity', ctypes.c_int),
1494
 
        ('type', ctypes.c_char_p),
1495
 
        ('name', ctypes.c_char_p),
1496
 
        ('header', ctypes.c_char_p),
1497
 
        ('message', ctypes.c_char_p),
1498
 
    ]
1499
 
 
1500
 
    def __init__(self):
1501
 
        super(LogMessage, self).__init__()
1502
 
        self.size = ctypes.sizeof(self)
1503
 
 
1504
 
    def __str__(self):
1505
 
        return '%s(%d:%s): %s' % (self.__class__.__name__, self.severity, self.type, self.message)
1506
 
 
1507
 
 
1508
 
class MediaEvent(_Cstruct):
1509
 
    _fields_ = [
1510
 
        ('media_name', ctypes.c_char_p),
1511
 
        ('instance_name', ctypes.c_char_p),
1512
 
    ]
1513
 
 
1514
 
 
1515
 
class MediaStats(_Cstruct):
1516
 
    _fields_ = [
1517
 
        ('read_bytes', ctypes.c_int),
1518
 
        ('input_bitrate', ctypes.c_float),
1519
 
        ('demux_read_bytes', ctypes.c_int),
1520
 
        ('demux_bitrate', ctypes.c_float),
1521
 
        ('demux_corrupted', ctypes.c_int),
1522
 
        ('demux_discontinuity', ctypes.c_int),
1523
 
        ('decoded_video', ctypes.c_int),
1524
 
        ('decoded_audio', ctypes.c_int),
1525
 
        ('displayed_pictures', ctypes.c_int),
1526
 
        ('lost_pictures', ctypes.c_int),
1527
 
        ('played_abuffers', ctypes.c_int),
1528
 
        ('lost_abuffers', ctypes.c_int),
1529
 
        ('sent_packets', ctypes.c_int),
1530
 
        ('sent_bytes', ctypes.c_int),
1531
 
        ('send_bitrate', ctypes.c_float),
1532
 
    ]
1533
 
 
1534
 
 
1535
 
class MediaTrackInfo(_Cstruct):
1536
 
    _fields_ = [
1537
 
        ('codec', ctypes.c_uint32),
1538
 
        ('id', ctypes.c_int),
1539
 
        ('type', TrackType),
1540
 
        ('profile', ctypes.c_int),
1541
 
        ('level', ctypes.c_int),
1542
 
        ('channels_or_height', ctypes.c_uint),
1543
 
        ('rate_or_width', ctypes.c_uint),
1544
 
    ]
1545
 
 
1546
 
 
1547
 
class AudioTrack(_Cstruct):
1548
 
    _fields_ = [
1549
 
        ('channels', ctypes.c_uint),
1550
 
        ('rate', ctypes.c_uint),
1551
 
    ]
1552
 
 
1553
 
 
1554
 
class VideoTrack(_Cstruct):
1555
 
    _fields_ = [
1556
 
        ('height', ctypes.c_uint),
1557
 
        ('width', ctypes.c_uint),
1558
 
        ('sar_num', ctypes.c_uint),
1559
 
        ('sar_den', ctypes.c_uint),
1560
 
        ('frame_rate_num', ctypes.c_uint),
1561
 
        ('frame_rate_den', ctypes.c_uint),
1562
 
    ]
1563
 
 
1564
 
 
1565
 
class SubtitleTrack(_Cstruct):
1566
 
    _fields_ = [
1567
 
        ('encoding', ctypes.c_char_p),
1568
 
    ]
1569
 
 
1570
 
 
1571
 
class MediaTrackTracks(ctypes.Union):
1572
 
    _fields_ = [
1573
 
        ('audio', ctypes.POINTER(AudioTrack)),
1574
 
        ('video', ctypes.POINTER(VideoTrack)),
1575
 
        ('subtitle', ctypes.POINTER(SubtitleTrack)),
1576
 
    ]
1577
 
 
1578
 
 
1579
 
class MediaTrack(_Cstruct):
1580
 
    _anonymous_ = ("u",)
1581
 
    _fields_ = [
1582
 
        ('codec', ctypes.c_uint32),
1583
 
        ('original_fourcc', ctypes.c_uint32),
1584
 
        ('id', ctypes.c_int),
1585
 
        ('type', TrackType),
1586
 
        ('profile', ctypes.c_int),
1587
 
        ('level', ctypes.c_int),
1588
 
 
1589
 
        ('u', MediaTrackTracks),
1590
 
        ('bitrate', ctypes.c_uint),
1591
 
        ('language', ctypes.c_char_p),
1592
 
        ('description', ctypes.c_char_p),
1593
 
    ]
1594
 
 
1595
 
 
1596
 
class PlaylistItem(_Cstruct):
1597
 
    _fields_ = [
1598
 
        ('id', ctypes.c_int),
1599
 
        ('uri', ctypes.c_char_p),
1600
 
        ('name', ctypes.c_char_p),
1601
 
    ]
1602
 
 
1603
 
    def __str__(self):
1604
 
        return '%s #%d %s (uri %s)' % (self.__class__.__name__, self.id, self.name, self.uri)
1605
 
 
1606
 
 
1607
 
class Position(object):
1608
 
    """Enum-like, immutable window position constants.
1609
 
 
1610
 
       See e.g. VideoMarqueeOption.Position.
1611
 
    """
1612
 
    Center = 0
1613
 
    Left = 1
1614
 
    CenterLeft = 1
1615
 
    Right = 2
1616
 
    CenterRight = 2
1617
 
    Top = 4
1618
 
    TopCenter = 4
1619
 
    TopLeft = 5
1620
 
    TopRight = 6
1621
 
    Bottom = 8
1622
 
    BottomCenter = 8
1623
 
    BottomLeft = 9
1624
 
    BottomRight = 10
1625
 
 
1626
 
    def __init__(self, *unused):
1627
 
        raise TypeError('constants only')
1628
 
 
1629
 
    def __setattr__(self, *unused):  # PYCHOK expected
1630
 
        raise TypeError('immutable constants')
1631
 
 
1632
 
 
1633
 
class Rectangle(_Cstruct):
1634
 
    _fields_ = [
1635
 
        ('top', ctypes.c_int),
1636
 
        ('left', ctypes.c_int),
1637
 
        ('bottom', ctypes.c_int),
1638
 
        ('right', ctypes.c_int),
1639
 
    ]
1640
 
 
1641
 
 
1642
 
class TrackDescription(_Cstruct):
1643
 
 
1644
 
    def __str__(self):
1645
 
        return '%s(%d:%s)' % (self.__class__.__name__, self.id, self.name)
1646
 
 
1647
 
 
1648
 
TrackDescription._fields_ = [  # recursive struct
1649
 
    ('id', ctypes.c_int),
1650
 
    ('name', ctypes.c_char_p),
1651
 
    ('next', ctypes.POINTER(TrackDescription)),
1652
 
]
1653
 
 
1654
 
 
1655
 
def track_description_list(head):
1656
 
    """Convert a TrackDescription linked list to a Python list (and release the former).
1657
 
    """
1658
 
    r = []
1659
 
    if head:
1660
 
        item = head
1661
 
        while item:
1662
 
            item = item.contents
1663
 
            r.append((item.id, item.name))
1664
 
            item = item.next
1665
 
        try:
1666
 
            libvlc_track_description_release(head)
1667
 
        except NameError:
1668
 
            libvlc_track_description_list_release(head)
1669
 
 
1670
 
    return r
1671
 
 
1672
 
 
1673
 
class EventUnion(ctypes.Union):
1674
 
    _fields_ = [
1675
 
        ('meta_type', ctypes.c_uint),
1676
 
        ('new_child', ctypes.c_uint),
1677
 
        ('new_duration', ctypes.c_longlong),
1678
 
        ('new_status', ctypes.c_int),
1679
 
        ('media', ctypes.c_void_p),
1680
 
        ('new_state', ctypes.c_uint),
1681
 
        # FIXME: Media instance
1682
 
        ('new_cache', ctypes.c_float),
1683
 
        ('new_position', ctypes.c_float),
1684
 
        ('new_time', ctypes.c_longlong),
1685
 
        ('new_title', ctypes.c_int),
1686
 
        ('new_seekable', ctypes.c_longlong),
1687
 
        ('new_pausable', ctypes.c_longlong),
1688
 
        ('new_scrambled', ctypes.c_longlong),
1689
 
        ('new_count', ctypes.c_longlong),
1690
 
        # FIXME: Skipped MediaList and MediaListView...
1691
 
        ('filename', ctypes.c_char_p),
1692
 
        ('new_length', ctypes.c_longlong),
1693
 
        ('media_event', MediaEvent),
1694
 
    ]
1695
 
 
1696
 
 
1697
 
class Event(_Cstruct):
1698
 
    _fields_ = [
1699
 
        ('type', EventType),
1700
 
        ('object', ctypes.c_void_p),
1701
 
        ('u', EventUnion),
1702
 
    ]
1703
 
 
1704
 
 
1705
 
class ModuleDescription(_Cstruct):
1706
 
 
1707
 
    def __str__(self):
1708
 
        return '%s %s (%s)' % (self.__class__.__name__, self.shortname, self.name)
1709
 
 
1710
 
 
1711
 
ModuleDescription._fields_ = [  # recursive struct
1712
 
    ('name', ctypes.c_char_p),
1713
 
    ('shortname', ctypes.c_char_p),
1714
 
    ('longname', ctypes.c_char_p),
1715
 
    ('help', ctypes.c_char_p),
1716
 
    ('next', ctypes.POINTER(ModuleDescription)),
1717
 
]
1718
 
 
1719
 
 
1720
 
def module_description_list(head):
1721
 
    """Convert a ModuleDescription linked list to a Python list (and release the former).
1722
 
    """
1723
 
    r = []
1724
 
    if head:
1725
 
        item = head
1726
 
        while item:
1727
 
            item = item.contents
1728
 
            r.append((item.name, item.shortname, item.longname, item.help))
1729
 
            item = item.next
1730
 
        libvlc_module_description_list_release(head)
1731
 
    return r
1732
 
 
1733
 
 
1734
 
class AudioOutputDevice(_Cstruct):
1735
 
 
1736
 
    def __str__(self):
1737
 
        return '%s(%d:%s)' % (self.__class__.__name__, self.id, self.name)
1738
 
 
1739
 
 
1740
 
AudioOutputDevice._fields_ = [  # recursive struct
1741
 
    ('next', ctypes.POINTER(AudioOutputDevice)),
1742
 
    ('device', ctypes.c_char_p),
1743
 
    ('description', ctypes.c_char_p),
1744
 
]
1745
 
 
1746
 
 
1747
 
class TitleDescription(_Cstruct):
1748
 
    _fields_ = [
1749
 
        ('duration', ctypes.c_longlong),
1750
 
        ('name', ctypes.c_char_p),
1751
 
        ('menu', ctypes.c_bool),
1752
 
    ]
1753
 
 
1754
 
 
1755
 
class ChapterDescription(_Cstruct):
1756
 
    _fields_ = [
1757
 
        ('time_offset', ctypes.c_longlong),
1758
 
        ('duration', ctypes.c_longlong),
1759
 
        ('name', ctypes.c_char_p),
1760
 
    ]
1761
 
 
1762
 
 
1763
 
class VideoViewpoint(_Cstruct):
1764
 
    _fields_ = [
1765
 
        ('yaw', ctypes.c_float),
1766
 
        ('pitch', ctypes.c_float),
1767
 
        ('roll', ctypes.c_float),
1768
 
        ('field_of_view', ctypes.c_float),
1769
 
    ]
1770
 
 
1771
 
 
1772
 
class MediaDiscovererDescription(_Cstruct):
1773
 
    _fields_ = [
1774
 
        ('name', ctypes.c_char_p),
1775
 
        ('longname', ctypes.c_char_p),
1776
 
        ('cat', MediaDiscovererCategory),
1777
 
    ]
1778
 
 
1779
 
    def __str__(self):
1780
 
        return '%s %s (%d) - %s' % (self.__class__.__name__, self.name, self.cat, self.longname)
1781
 
 
1782
 
 
1783
 
# This struct depends on the MediaSlaveType enum that is defined only
1784
 
# in > 2.2
1785
 
if 'MediaSlaveType' in locals():
1786
 
    class MediaSlave(_Cstruct):
1787
 
        _fields_ = [
1788
 
            ('psz_uri', ctypes.c_char_p),
1789
 
            ('i_type', MediaSlaveType),
1790
 
            ('i_priority', ctypes.c_uint)
1791
 
        ]
1792
 
 
1793
 
 
1794
 
class RDDescription(_Cstruct):
1795
 
    _fields_ = [
1796
 
        ('name', ctypes.c_char_p),
1797
 
        ('longname', ctypes.c_char_p)
1798
 
    ]
1799
 
 
1800
 
 
1801
 
# End of header.py #
1802
 
class EventManager(_Ctype):
1803
 
    '''Create an event manager with callback handler.
1804
 
 
1805
 
    This class interposes the registration and handling of
1806
 
    event notifications in order to (a) remove the need for
1807
 
    decorating each callback functions with the decorator
1808
 
    '@callbackmethod', (b) allow any number of positional
1809
 
    and/or keyword arguments to the callback (in addition
1810
 
    to the Event instance) and (c) to preserve the Python
1811
 
    objects such that the callback and argument objects
1812
 
    remain alive (i.e. are not garbage collected) until
1813
 
    B{after} the notification has been unregistered.
1814
 
 
1815
 
    @note: Only a single notification can be registered
1816
 
    for each event type in an EventManager instance.
1817
 
 
1818
 
    '''
1819
 
 
1820
 
    _callback_handler = None
1821
 
    _callbacks = {}
1822
 
 
1823
 
    def __new__(cls, ptr=_internal_guard):
1824
 
        if ptr == _internal_guard:
1825
 
            raise VLCException(
1826
 
                "(INTERNAL) ctypes class.\nYou should get a reference to EventManager through the MediaPlayer.event_manager() method.")
1827
 
        return _Constructor(cls, ptr)
1828
 
 
1829
 
    def event_attach(self, eventtype, callback, *args, **kwds):
1830
 
        """Register an event notification.
1831
 
 
1832
 
        @param eventtype: the desired event type to be notified about.
1833
 
        @param callback: the function to call when the event occurs.
1834
 
        @param args: optional positional arguments for the callback.
1835
 
        @param kwds: optional keyword arguments for the callback.
1836
 
        @return: 0 on success, ENOMEM on error.
1837
 
 
1838
 
        @note: The callback function must have at least one argument,
1839
 
        an Event instance.  Any other, optional positional and keyword
1840
 
        arguments are in B{addition} to the first one.
1841
 
        """
1842
 
        if not isinstance(eventtype, EventType):
1843
 
            raise VLCException("%s required: %r" % ('EventType', eventtype))
1844
 
        if not hasattr(callback, '__call__'):  # callable()
1845
 
            raise VLCException("%s required: %r" % ('callable', callback))
1846
 
        # check that the callback expects arguments
1847
 
        if not any(getargspec(callback)[:2]):  # list(...)
1848
 
            raise VLCException("%s required: %r" % ('argument', callback))
1849
 
 
1850
 
        if self._callback_handler is None:
1851
 
            _called_from_ctypes = ctypes.CFUNCTYPE(None, ctypes.POINTER(Event), ctypes.c_void_p)
1852
 
 
1853
 
            @_called_from_ctypes
1854
 
            def _callback_handler(event, k):
1855
 
                """(INTERNAL) handle callback call from ctypes.
1856
 
 
1857
 
                @note: We cannot simply make this an EventManager
1858
 
                method since ctypes does not prepend self as the
1859
 
                first parameter, hence this closure.
1860
 
                """
1861
 
                try:  # retrieve Python callback and arguments
1862
 
                    call, args, kwds = self._callbacks[k]
1863
 
                    # deref event.contents to simplify callback code
1864
 
                    call(event.contents, *args, **kwds)
1865
 
                except KeyError:  # detached?
1866
 
                    pass
1867
 
 
1868
 
            self._callback_handler = _callback_handler
1869
 
            self._callbacks = {}
1870
 
 
1871
 
        k = eventtype.value
1872
 
        r = libvlc_event_attach(self, k, self._callback_handler, k)
1873
 
        if not r:
1874
 
            self._callbacks[k] = (callback, args, kwds)
1875
 
        return r
1876
 
 
1877
 
    def event_detach(self, eventtype):
1878
 
        """Unregister an event notification.
1879
 
 
1880
 
        @param eventtype: the event type notification to be removed.
1881
 
        """
1882
 
        if not isinstance(eventtype, EventType):
1883
 
            raise VLCException("%s required: %r" % ('EventType', eventtype))
1884
 
 
1885
 
        k = eventtype.value
1886
 
        if k in self._callbacks:
1887
 
            del self._callbacks[k]  # remove, regardless of libvlc return value
1888
 
            libvlc_event_detach(self, k, self._callback_handler, k)
1889
 
 
1890
 
 
1891
 
class Instance(_Ctype):
1892
 
    '''Create a new Instance instance.
1893
 
 
1894
 
    It may take as parameter either:
1895
 
      - a string
1896
 
      - a list of strings as first parameters
1897
 
      - the parameters given as the constructor parameters (must be strings)
1898
 
 
1899
 
    '''
1900
 
 
1901
 
    def __new__(cls, *args):
1902
 
        if len(args) == 1:
1903
 
            # Only 1 arg. It is either a C pointer, or an arg string,
1904
 
            # or a tuple.
1905
 
            i = args[0]
1906
 
            if isinstance(i, _Ints):
1907
 
                return _Constructor(cls, i)
1908
 
            elif isinstance(i, basestring):
1909
 
                args = i.strip().split()
1910
 
            elif isinstance(i, _Seqs):
1911
 
                args = list(i)
1912
 
            else:
1913
 
                raise VLCException('Instance %r' % (args,))
1914
 
        else:
1915
 
            args = list(args)
1916
 
 
1917
 
        if not args:  # no parameters passed
1918
 
            args = ['vlc']
1919
 
        elif args[0] != 'vlc':
1920
 
            args.insert(0, 'vlc')
1921
 
 
1922
 
        if plugin_path is not None:
1923
 
            # set plugin_path if detected, win32 and MacOS,
1924
 
            # if the user did not specify it itself.
1925
 
            os.environ.setdefault('VLC_PLUGIN_PATH', plugin_path)
1926
 
 
1927
 
        if PYTHON3:
1928
 
            args = [str_to_bytes(a) for a in args]
1929
 
        return libvlc_new(len(args), args)
1930
 
 
1931
 
    def media_player_new(self, uri=None):
1932
 
        """Create a new MediaPlayer instance.
1933
 
 
1934
 
        @param uri: an optional URI to play in the player.
1935
 
        """
1936
 
        p = libvlc_media_player_new(self)
1937
 
        if uri:
1938
 
            p.set_media(self.media_new(uri))
1939
 
        p._instance = self
1940
 
        return p
1941
 
 
1942
 
    def media_list_player_new(self):
1943
 
        """Create a new MediaListPlayer instance.
1944
 
        """
1945
 
        p = libvlc_media_list_player_new(self)
1946
 
        p._instance = self
1947
 
        return p
1948
 
 
1949
 
    def media_new(self, mrl, *options):
1950
 
        """Create a new Media instance.
1951
 
 
1952
 
        If mrl contains a colon (:) preceded by more than 1 letter, it
1953
 
        will be treated as a URL. Else, it will be considered as a
1954
 
        local path. If you need more control, directly use
1955
 
        media_new_location/media_new_path methods.
1956
 
 
1957
 
        Options can be specified as supplementary string parameters,
1958
 
        but note that many options cannot be set at the media level,
1959
 
        and rather at the Instance level. For instance, the marquee
1960
 
        filter must be specified when creating the vlc.Instance or
1961
 
        vlc.MediaPlayer.
1962
 
 
1963
 
        Alternatively, options can be added to the media using the
1964
 
        Media.add_options method (with the same limitation).
1965
 
 
1966
 
        @param options: optional media option=value strings
1967
 
        """
1968
 
        if ':' in mrl and mrl.index(':') > 1:
1969
 
            # Assume it is a URL
1970
 
            m = libvlc_media_new_location(self, str_to_bytes(mrl))
1971
 
        else:
1972
 
            # Else it should be a local path.
1973
 
            m = libvlc_media_new_path(self, str_to_bytes(os.path.normpath(mrl)))
1974
 
        for o in options:
1975
 
            libvlc_media_add_option(m, str_to_bytes(o))
1976
 
        m._instance = self
1977
 
        return m
1978
 
 
1979
 
    def media_list_new(self, mrls=None):
1980
 
        """Create a new MediaList instance.
1981
 
        @param mrls: optional list of MRL strings
1982
 
        """
1983
 
        l = libvlc_media_list_new(self)
1984
 
        # We should take the lock, but since we did not leak the
1985
 
        # reference, nobody else can access it.
1986
 
        if mrls:
1987
 
            for m in mrls:
1988
 
                l.add_media(m)
1989
 
        l._instance = self
1990
 
        return l
1991
 
 
1992
 
    def audio_output_enumerate_devices(self):
1993
 
        """Enumerate the defined audio output devices.
1994
 
 
1995
 
        @return: list of dicts {name:, description:, devices:}
1996
 
        """
1997
 
        r = []
1998
 
        head = libvlc_audio_output_list_get(self)
1999
 
        if head:
2000
 
            i = head
2001
 
            while i:
2002
 
                i = i.contents
2003
 
                d = [{'id': libvlc_audio_output_device_id(self, i.name, d),
2004
 
                      'longname': libvlc_audio_output_device_longname(self, i.name, d)}
2005
 
                     for d in range(libvlc_audio_output_device_count(self, i.name))]
2006
 
                r.append({'name': i.name, 'description': i.description, 'devices': d})
2007
 
                i = i.next
2008
 
            libvlc_audio_output_list_release(head)
2009
 
        return r
2010
 
 
2011
 
    def audio_filter_list_get(self):
2012
 
        """Returns a list of available audio filters.
2013
 
 
2014
 
        """
2015
 
        return module_description_list(libvlc_audio_filter_list_get(self))
2016
 
 
2017
 
    def video_filter_list_get(self):
2018
 
        """Returns a list of available video filters.
2019
 
 
2020
 
        """
2021
 
        return module_description_list(libvlc_video_filter_list_get(self))
2022
 
 
2023
 
    def release(self):
2024
 
        '''Decrement the reference count of a libvlc instance, and destroy it
2025
 
        if it reaches zero.
2026
 
        '''
2027
 
        return libvlc_release(self)
2028
 
 
2029
 
    def retain(self):
2030
 
        '''Increments the reference count of a libvlc instance.
2031
 
        The initial reference count is 1 after L{new}() returns.
2032
 
        '''
2033
 
        return libvlc_retain(self)
2034
 
 
2035
 
    def add_intf(self, name):
2036
 
        '''Try to start a user interface for the libvlc instance.
2037
 
        @param name: interface name, or None for default.
2038
 
        @return: 0 on success, -1 on error.
2039
 
        '''
2040
 
        return libvlc_add_intf(self, str_to_bytes(name))
2041
 
 
2042
 
    def set_user_agent(self, name, http):
2043
 
        '''Sets the application name. LibVLC passes this as the user agent string
2044
 
        when a protocol requires it.
2045
 
        @param name: human-readable application name, e.g. "FooBar player 1.2.3".
2046
 
        @param http: HTTP User Agent, e.g. "FooBar/1.2.3 Python/2.6.0".
2047
 
        @version: LibVLC 1.1.1 or later.
2048
 
        '''
2049
 
        return libvlc_set_user_agent(self, str_to_bytes(name), str_to_bytes(http))
2050
 
 
2051
 
    def set_app_id(self, id, version, icon):
2052
 
        '''Sets some meta-information about the application.
2053
 
        See also L{set_user_agent}().
2054
 
        @param id: Java-style application identifier, e.g. "com.acme.foobar".
2055
 
        @param version: application version numbers, e.g. "1.2.3".
2056
 
        @param icon: application icon name, e.g. "foobar".
2057
 
        @version: LibVLC 2.1.0 or later.
2058
 
        '''
2059
 
        return libvlc_set_app_id(self, str_to_bytes(id), str_to_bytes(version), str_to_bytes(icon))
2060
 
 
2061
 
    def log_unset(self):
2062
 
        '''Unsets the logging callback.
2063
 
        This function deregisters the logging callback for a LibVLC instance.
2064
 
        This is rarely needed as the callback is implicitly unset when the instance
2065
 
        is destroyed.
2066
 
        @note: This function will wait for any pending callbacks invocation to
2067
 
        complete (causing a deadlock if called from within the callback).
2068
 
        @version: LibVLC 2.1.0 or later.
2069
 
        '''
2070
 
        return libvlc_log_unset(self)
2071
 
 
2072
 
    def log_set(self, cb, data):
2073
 
        '''Sets the logging callback for a LibVLC instance.
2074
 
        This function is thread-safe: it will wait for any pending callbacks
2075
 
        invocation to complete.
2076
 
        @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.
2077
 
        @param p_instance: libvlc instance.
2078
 
        @version: LibVLC 2.1.0 or later.
2079
 
        '''
2080
 
        return libvlc_log_set(self, cb, data)
2081
 
 
2082
 
    def log_set_file(self, stream):
2083
 
        '''Sets up logging to a file.
2084
 
        @param stream: FILE pointer opened for writing (the FILE pointer must remain valid until L{log_unset}()).
2085
 
        @version: LibVLC 2.1.0 or later.
2086
 
        '''
2087
 
        return libvlc_log_set_file(self, stream)
2088
 
 
2089
 
    def media_discoverer_new(self, psz_name):
2090
 
        '''Create a media discoverer object by name.
2091
 
        After this object is created, you should attach to media_list events in
2092
 
        order to be notified of new items discovered.
2093
 
        You need to call L{media_discoverer_start}() in order to start the
2094
 
        discovery.
2095
 
        See L{media_discoverer_media_list}
2096
 
        See L{media_discoverer_event_manager}
2097
 
        See L{media_discoverer_start}.
2098
 
        @param psz_name: service name; use L{media_discoverer_list_get}() to get a list of the discoverer names available in this libVLC instance.
2099
 
        @return: media discover object or None in case of error.
2100
 
        @version: LibVLC 3.0.0 or later.
2101
 
        '''
2102
 
        return libvlc_media_discoverer_new(self, str_to_bytes(psz_name))
2103
 
 
2104
 
    def media_discoverer_list_get(self, i_cat, ppp_services):
2105
 
        '''Get media discoverer services by category.
2106
 
        @param i_cat: category of services to fetch.
2107
 
        @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].
2108
 
        @return: the number of media discoverer services (0 on error).
2109
 
        @version: LibVLC 3.0.0 and later.
2110
 
        '''
2111
 
        return libvlc_media_discoverer_list_get(self, i_cat, ppp_services)
2112
 
 
2113
 
    def media_library_new(self):
2114
 
        '''Create an new Media Library object.
2115
 
        @return: a new object or None on error.
2116
 
        '''
2117
 
        return libvlc_media_library_new(self)
2118
 
 
2119
 
    def vlm_release(self):
2120
 
        '''Release the vlm instance related to the given L{Instance}.
2121
 
        '''
2122
 
        return libvlc_vlm_release(self)
2123
 
 
2124
 
    def vlm_add_broadcast(self, psz_name, psz_input, psz_output, i_options, ppsz_options, b_enabled, b_loop):
2125
 
        '''Add a broadcast, with one input.
2126
 
        @param psz_name: the name of the new broadcast.
2127
 
        @param psz_input: the input MRL.
2128
 
        @param psz_output: the output MRL (the parameter to the "sout" variable).
2129
 
        @param i_options: number of additional options.
2130
 
        @param ppsz_options: additional options.
2131
 
        @param b_enabled: boolean for enabling the new broadcast.
2132
 
        @param b_loop: Should this broadcast be played in loop ?
2133
 
        @return: 0 on success, -1 on error.
2134
 
        '''
2135
 
        return libvlc_vlm_add_broadcast(self, str_to_bytes(psz_name), str_to_bytes(psz_input), str_to_bytes(psz_output),
2136
 
                                        i_options, ppsz_options, b_enabled, b_loop)
2137
 
 
2138
 
    def vlm_add_vod(self, psz_name, psz_input, i_options, ppsz_options, b_enabled, psz_mux):
2139
 
        '''Add a vod, with one input.
2140
 
        @param psz_name: the name of the new vod media.
2141
 
        @param psz_input: the input MRL.
2142
 
        @param i_options: number of additional options.
2143
 
        @param ppsz_options: additional options.
2144
 
        @param b_enabled: boolean for enabling the new vod.
2145
 
        @param psz_mux: the muxer of the vod media.
2146
 
        @return: 0 on success, -1 on error.
2147
 
        '''
2148
 
        return libvlc_vlm_add_vod(self, str_to_bytes(psz_name), str_to_bytes(psz_input), i_options, ppsz_options,
2149
 
                                  b_enabled, str_to_bytes(psz_mux))
2150
 
 
2151
 
    def vlm_del_media(self, psz_name):
2152
 
        '''Delete a media (VOD or broadcast).
2153
 
        @param psz_name: the media to delete.
2154
 
        @return: 0 on success, -1 on error.
2155
 
        '''
2156
 
        return libvlc_vlm_del_media(self, str_to_bytes(psz_name))
2157
 
 
2158
 
    def vlm_set_enabled(self, psz_name, b_enabled):
2159
 
        '''Enable or disable a media (VOD or broadcast).
2160
 
        @param psz_name: the media to work on.
2161
 
        @param b_enabled: the new status.
2162
 
        @return: 0 on success, -1 on error.
2163
 
        '''
2164
 
        return libvlc_vlm_set_enabled(self, str_to_bytes(psz_name), b_enabled)
2165
 
 
2166
 
    def vlm_set_output(self, psz_name, psz_output):
2167
 
        '''Set the output for a media.
2168
 
        @param psz_name: the media to work on.
2169
 
        @param psz_output: the output MRL (the parameter to the "sout" variable).
2170
 
        @return: 0 on success, -1 on error.
2171
 
        '''
2172
 
        return libvlc_vlm_set_output(self, str_to_bytes(psz_name), str_to_bytes(psz_output))
2173
 
 
2174
 
    def vlm_set_input(self, psz_name, psz_input):
2175
 
        '''Set a media's input MRL. This will delete all existing inputs and
2176
 
        add the specified one.
2177
 
        @param psz_name: the media to work on.
2178
 
        @param psz_input: the input MRL.
2179
 
        @return: 0 on success, -1 on error.
2180
 
        '''
2181
 
        return libvlc_vlm_set_input(self, str_to_bytes(psz_name), str_to_bytes(psz_input))
2182
 
 
2183
 
    def vlm_add_input(self, psz_name, psz_input):
2184
 
        '''Add a media's input MRL. This will add the specified one.
2185
 
        @param psz_name: the media to work on.
2186
 
        @param psz_input: the input MRL.
2187
 
        @return: 0 on success, -1 on error.
2188
 
        '''
2189
 
        return libvlc_vlm_add_input(self, str_to_bytes(psz_name), str_to_bytes(psz_input))
2190
 
 
2191
 
    def vlm_set_loop(self, psz_name, b_loop):
2192
 
        '''Set a media's loop status.
2193
 
        @param psz_name: the media to work on.
2194
 
        @param b_loop: the new status.
2195
 
        @return: 0 on success, -1 on error.
2196
 
        '''
2197
 
        return libvlc_vlm_set_loop(self, str_to_bytes(psz_name), b_loop)
2198
 
 
2199
 
    def vlm_set_mux(self, psz_name, psz_mux):
2200
 
        '''Set a media's vod muxer.
2201
 
        @param psz_name: the media to work on.
2202
 
        @param psz_mux: the new muxer.
2203
 
        @return: 0 on success, -1 on error.
2204
 
        '''
2205
 
        return libvlc_vlm_set_mux(self, str_to_bytes(psz_name), str_to_bytes(psz_mux))
2206
 
 
2207
 
    def vlm_change_media(self, psz_name, psz_input, psz_output, i_options, ppsz_options, b_enabled, b_loop):
2208
 
        '''Edit the parameters of a media. This will delete all existing inputs and
2209
 
        add the specified one.
2210
 
        @param psz_name: the name of the new broadcast.
2211
 
        @param psz_input: the input MRL.
2212
 
        @param psz_output: the output MRL (the parameter to the "sout" variable).
2213
 
        @param i_options: number of additional options.
2214
 
        @param ppsz_options: additional options.
2215
 
        @param b_enabled: boolean for enabling the new broadcast.
2216
 
        @param b_loop: Should this broadcast be played in loop ?
2217
 
        @return: 0 on success, -1 on error.
2218
 
        '''
2219
 
        return libvlc_vlm_change_media(self, str_to_bytes(psz_name), str_to_bytes(psz_input), str_to_bytes(psz_output),
2220
 
                                       i_options, ppsz_options, b_enabled, b_loop)
2221
 
 
2222
 
    def vlm_play_media(self, psz_name):
2223
 
        '''Play the named broadcast.
2224
 
        @param psz_name: the name of the broadcast.
2225
 
        @return: 0 on success, -1 on error.
2226
 
        '''
2227
 
        return libvlc_vlm_play_media(self, str_to_bytes(psz_name))
2228
 
 
2229
 
    def vlm_stop_media(self, psz_name):
2230
 
        '''Stop the named broadcast.
2231
 
        @param psz_name: the name of the broadcast.
2232
 
        @return: 0 on success, -1 on error.
2233
 
        '''
2234
 
        return libvlc_vlm_stop_media(self, str_to_bytes(psz_name))
2235
 
 
2236
 
    def vlm_pause_media(self, psz_name):
2237
 
        '''Pause the named broadcast.
2238
 
        @param psz_name: the name of the broadcast.
2239
 
        @return: 0 on success, -1 on error.
2240
 
        '''
2241
 
        return libvlc_vlm_pause_media(self, str_to_bytes(psz_name))
2242
 
 
2243
 
    def vlm_seek_media(self, psz_name, f_percentage):
2244
 
        '''Seek in the named broadcast.
2245
 
        @param psz_name: the name of the broadcast.
2246
 
        @param f_percentage: the percentage to seek to.
2247
 
        @return: 0 on success, -1 on error.
2248
 
        '''
2249
 
        return libvlc_vlm_seek_media(self, str_to_bytes(psz_name), f_percentage)
2250
 
 
2251
 
    def vlm_show_media(self, psz_name):
2252
 
        '''Return information about the named media as a JSON
2253
 
        string representation.
2254
 
        This function is mainly intended for debugging use,
2255
 
        if you want programmatic access to the state of
2256
 
        a vlm_media_instance_t, please use the corresponding
2257
 
        libvlc_vlm_get_media_instance_xxx -functions.
2258
 
        Currently there are no such functions available for
2259
 
        vlm_media_t though.
2260
 
        @param psz_name: the name of the media, if the name is an empty string, all media is described.
2261
 
        @return: string with information about named media, or None on error.
2262
 
        '''
2263
 
        return libvlc_vlm_show_media(self, str_to_bytes(psz_name))
2264
 
 
2265
 
    def vlm_get_media_instance_position(self, psz_name, i_instance):
2266
 
        '''Get vlm_media instance position by name or instance id.
2267
 
        @param psz_name: name of vlm media instance.
2268
 
        @param i_instance: instance id.
2269
 
        @return: position as float or -1. on error.
2270
 
        '''
2271
 
        return libvlc_vlm_get_media_instance_position(self, str_to_bytes(psz_name), i_instance)
2272
 
 
2273
 
    def vlm_get_media_instance_time(self, psz_name, i_instance):
2274
 
        '''Get vlm_media instance time by name or instance id.
2275
 
        @param psz_name: name of vlm media instance.
2276
 
        @param i_instance: instance id.
2277
 
        @return: time as integer or -1 on error.
2278
 
        '''
2279
 
        return libvlc_vlm_get_media_instance_time(self, str_to_bytes(psz_name), i_instance)
2280
 
 
2281
 
    def vlm_get_media_instance_length(self, psz_name, i_instance):
2282
 
        '''Get vlm_media instance length by name or instance id.
2283
 
        @param psz_name: name of vlm media instance.
2284
 
        @param i_instance: instance id.
2285
 
        @return: length of media item or -1 on error.
2286
 
        '''
2287
 
        return libvlc_vlm_get_media_instance_length(self, str_to_bytes(psz_name), i_instance)
2288
 
 
2289
 
    def vlm_get_media_instance_rate(self, psz_name, i_instance):
2290
 
        '''Get vlm_media instance playback rate by name or instance id.
2291
 
        @param psz_name: name of vlm media instance.
2292
 
        @param i_instance: instance id.
2293
 
        @return: playback rate or -1 on error.
2294
 
        '''
2295
 
        return libvlc_vlm_get_media_instance_rate(self, str_to_bytes(psz_name), i_instance)
2296
 
 
2297
 
    def vlm_get_media_instance_title(self, psz_name, i_instance):
2298
 
        '''Get vlm_media instance title number by name or instance id.
2299
 
        @param psz_name: name of vlm media instance.
2300
 
        @param i_instance: instance id.
2301
 
        @return: title as number or -1 on error.
2302
 
        @bug: will always return 0.
2303
 
        '''
2304
 
        return libvlc_vlm_get_media_instance_title(self, str_to_bytes(psz_name), i_instance)
2305
 
 
2306
 
    def vlm_get_media_instance_chapter(self, psz_name, i_instance):
2307
 
        '''Get vlm_media instance chapter number by name or instance id.
2308
 
        @param psz_name: name of vlm media instance.
2309
 
        @param i_instance: instance id.
2310
 
        @return: chapter as number or -1 on error.
2311
 
        @bug: will always return 0.
2312
 
        '''
2313
 
        return libvlc_vlm_get_media_instance_chapter(self, str_to_bytes(psz_name), i_instance)
2314
 
 
2315
 
    def vlm_get_media_instance_seekable(self, psz_name, i_instance):
2316
 
        '''Is libvlc instance seekable ?
2317
 
        @param psz_name: name of vlm media instance.
2318
 
        @param i_instance: instance id.
2319
 
        @return: 1 if seekable, 0 if not, -1 if media does not exist.
2320
 
        @bug: will always return 0.
2321
 
        '''
2322
 
        return libvlc_vlm_get_media_instance_seekable(self, str_to_bytes(psz_name), i_instance)
2323
 
 
2324
 
    @memoize_parameterless
2325
 
    def vlm_get_event_manager(self):
2326
 
        '''Get libvlc_event_manager from a vlm media.
2327
 
        The p_event_manager is immutable, so you don't have to hold the lock.
2328
 
        @return: libvlc_event_manager.
2329
 
        '''
2330
 
        return libvlc_vlm_get_event_manager(self)
2331
 
 
2332
 
    def media_new_location(self, psz_mrl):
2333
 
        '''Create a media with a certain given media resource location,
2334
 
        for instance a valid URL.
2335
 
        @note: To refer to a local file with this function,
2336
 
        the file://... URI syntax B{must} be used (see IETF RFC3986).
2337
 
        We recommend using L{media_new_path}() instead when dealing with
2338
 
        local files.
2339
 
        See L{media_release}.
2340
 
        @param psz_mrl: the media location.
2341
 
        @return: the newly created media or None on error.
2342
 
        '''
2343
 
        return libvlc_media_new_location(self, str_to_bytes(psz_mrl))
2344
 
 
2345
 
    def media_new_path(self, path):
2346
 
        '''Create a media for a certain file path.
2347
 
        See L{media_release}.
2348
 
        @param path: local filesystem path.
2349
 
        @return: the newly created media or None on error.
2350
 
        '''
2351
 
        return libvlc_media_new_path(self, str_to_bytes(path))
2352
 
 
2353
 
    def media_new_fd(self, fd):
2354
 
        '''Create a media for an already open file descriptor.
2355
 
        The file descriptor shall be open for reading (or reading and writing).
2356
 
        Regular file descriptors, pipe read descriptors and character device
2357
 
        descriptors (including TTYs) are supported on all platforms.
2358
 
        Block device descriptors are supported where available.
2359
 
        Directory descriptors are supported on systems that provide fdopendir().
2360
 
        Sockets are supported on all platforms where they are file descriptors,
2361
 
        i.e. all except Windows.
2362
 
        @note: This library will B{not} automatically close the file descriptor
2363
 
        under any circumstance. Nevertheless, a file descriptor can usually only be
2364
 
        rendered once in a media player. To render it a second time, the file
2365
 
        descriptor should probably be rewound to the beginning with lseek().
2366
 
        See L{media_release}.
2367
 
        @param fd: open file descriptor.
2368
 
        @return: the newly created media or None on error.
2369
 
        @version: LibVLC 1.1.5 and later.
2370
 
        '''
2371
 
        return libvlc_media_new_fd(self, fd)
2372
 
 
2373
 
    def media_new_callbacks(self, open_cb, read_cb, seek_cb, close_cb, opaque):
2374
 
        '''Create a media with custom callbacks to read the data from.
2375
 
        @param open_cb: callback to open the custom bitstream input media.
2376
 
        @param read_cb: callback to read data (must not be None).
2377
 
        @param seek_cb: callback to seek, or None if seeking is not supported.
2378
 
        @param close_cb: callback to close the media, or None if unnecessary.
2379
 
        @param opaque: data pointer for the open callback.
2380
 
        @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}.
2381
 
        @version: LibVLC 3.0.0 and later.
2382
 
        '''
2383
 
        return libvlc_media_new_callbacks(self, open_cb, read_cb, seek_cb, close_cb, opaque)
2384
 
 
2385
 
    def media_new_as_node(self, psz_name):
2386
 
        '''Create a media as an empty node with a given name.
2387
 
        See L{media_release}.
2388
 
        @param psz_name: the name of the node.
2389
 
        @return: the new empty media or None on error.
2390
 
        '''
2391
 
        return libvlc_media_new_as_node(self, str_to_bytes(psz_name))
2392
 
 
2393
 
    def renderer_discoverer_new(self, psz_name):
2394
 
        '''Create a renderer discoverer object by name
2395
 
        After this object is created, you should attach to events in order to be
2396
 
        notified of the discoverer events.
2397
 
        You need to call L{renderer_discoverer_start}() in order to start the
2398
 
        discovery.
2399
 
        See L{renderer_discoverer_event_manager}()
2400
 
        See L{renderer_discoverer_start}().
2401
 
        @param psz_name: service name; use L{renderer_discoverer_list_get}() to get a list of the discoverer names available in this libVLC instance.
2402
 
        @return: media discover object or None in case of error.
2403
 
        @version: LibVLC 3.0.0 or later.
2404
 
        '''
2405
 
        return libvlc_renderer_discoverer_new(self, str_to_bytes(psz_name))
2406
 
 
2407
 
    def renderer_discoverer_list_get(self, ppp_services):
2408
 
        '''Get media discoverer services
2409
 
        See libvlc_renderer_list_release().
2410
 
        @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].
2411
 
        @return: the number of media discoverer services (0 on error).
2412
 
        @version: LibVLC 3.0.0 and later.
2413
 
        '''
2414
 
        return libvlc_renderer_discoverer_list_get(self, ppp_services)
2415
 
 
2416
 
    def audio_output_device_count(self, psz_audio_output):
2417
 
        '''Backward compatibility stub. Do not use in new code.
2418
 
        \deprecated Use L{audio_output_device_list_get}() instead.
2419
 
        @return: always 0.
2420
 
        '''
2421
 
        return libvlc_audio_output_device_count(self, str_to_bytes(psz_audio_output))
2422
 
 
2423
 
    def audio_output_device_longname(self, psz_output, i_device):
2424
 
        '''Backward compatibility stub. Do not use in new code.
2425
 
        \deprecated Use L{audio_output_device_list_get}() instead.
2426
 
        @return: always None.
2427
 
        '''
2428
 
        return libvlc_audio_output_device_longname(self, str_to_bytes(psz_output), i_device)
2429
 
 
2430
 
    def audio_output_device_id(self, psz_audio_output, i_device):
2431
 
        '''Backward compatibility stub. Do not use in new code.
2432
 
        \deprecated Use L{audio_output_device_list_get}() instead.
2433
 
        @return: always None.
2434
 
        '''
2435
 
        return libvlc_audio_output_device_id(self, str_to_bytes(psz_audio_output), i_device)
2436
 
 
2437
 
    def media_discoverer_new_from_name(self, psz_name):
2438
 
        '''\deprecated Use L{media_discoverer_new}() and L{media_discoverer_start}().
2439
 
        '''
2440
 
        return libvlc_media_discoverer_new_from_name(self, str_to_bytes(psz_name))
2441
 
 
2442
 
    def wait(self):
2443
 
        '''Waits until an interface causes the instance to exit.
2444
 
        You should start at least one interface first, using L{add_intf}().
2445
 
        '''
2446
 
        return libvlc_wait(self)
2447
 
 
2448
 
    def get_log_verbosity(self):
2449
 
        '''Always returns minus one.
2450
 
        This function is only provided for backward compatibility.
2451
 
        @return: always -1.
2452
 
        '''
2453
 
        return libvlc_get_log_verbosity(self)
2454
 
 
2455
 
    def set_log_verbosity(self, level):
2456
 
        '''This function does nothing.
2457
 
        It is only provided for backward compatibility.
2458
 
        @param level: ignored.
2459
 
        '''
2460
 
        return libvlc_set_log_verbosity(self, level)
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
 
    def playlist_play(self, i_id, i_options, ppsz_options):
2470
 
        '''Start playing (if there is any item in the playlist).
2471
 
        Additionnal playlist item options can be specified for addition to the
2472
 
        item before it is played.
2473
 
        @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.
2474
 
        @param i_options: the number of options to add to the item.
2475
 
        @param ppsz_options: the options to add to the item.
2476
 
        '''
2477
 
        return libvlc_playlist_play(self, i_id, i_options, ppsz_options)
2478
 
 
2479
 
    def audio_output_list_get(self):
2480
 
        '''Gets the list of available audio output modules.
2481
 
        @return: list of available audio outputs. It must be freed with In case of error, None is returned.
2482
 
        '''
2483
 
        return libvlc_audio_output_list_get(self)
2484
 
 
2485
 
    def audio_output_device_list_get(self, aout):
2486
 
        '''Gets a list of audio output devices for a given audio output module,
2487
 
        See L{audio_output_device_set}().
2488
 
        @note: Not all audio outputs support this. In particular, an empty (None)
2489
 
        list of devices does B{not} imply that the specified audio output does
2490
 
        not work.
2491
 
        @note: The list might not be exhaustive.
2492
 
        @warning: Some audio output devices in the list might not actually work in
2493
 
        some circumstances. By default, it is recommended to not specify any
2494
 
        explicit audio device.
2495
 
        @param aout: audio output name (as returned by L{audio_output_list_get}()).
2496
 
        @return: A None-terminated linked list of potential audio output devices. It must be freed with L{audio_output_device_list_release}().
2497
 
        @version: LibVLC 2.1.0 or later.
2498
 
        '''
2499
 
        return libvlc_audio_output_device_list_get(self, str_to_bytes(aout))
2500
 
 
2501
 
 
2502
 
class LogIterator(_Ctype):
2503
 
    '''Create a new VLC log iterator.
2504
 
 
2505
 
    '''
2506
 
 
2507
 
    def __new__(cls, ptr=_internal_guard):
2508
 
        '''(INTERNAL) ctypes wrapper constructor.
2509
 
        '''
2510
 
        return _Constructor(cls, ptr)
2511
 
 
2512
 
    def __iter__(self):
2513
 
        return self
2514
 
 
2515
 
    def next(self):
2516
 
        if self.has_next():
2517
 
            b = LogMessage()
2518
 
            i = libvlc_log_iterator_next(self, b)
2519
 
            return i.contents
2520
 
        raise StopIteration
2521
 
 
2522
 
    def __next__(self):
2523
 
        return self.next()
2524
 
 
2525
 
    def free(self):
2526
 
        '''Frees memory allocated by L{log_get_iterator}().
2527
 
        '''
2528
 
        return libvlc_log_iterator_free(self)
2529
 
 
2530
 
    def has_next(self):
2531
 
        '''Always returns zero.
2532
 
        This function is only provided for backward compatibility.
2533
 
        @return: always zero.
2534
 
        '''
2535
 
        return libvlc_log_iterator_has_next(self)
2536
 
 
2537
 
 
2538
 
class Media(_Ctype):
2539
 
    '''Create a new Media instance.
2540
 
 
2541
 
    Usage: Media(MRL, *options)
2542
 
 
2543
 
    See vlc.Instance.media_new documentation for details.
2544
 
 
2545
 
    '''
2546
 
 
2547
 
    def __new__(cls, *args):
2548
 
        if args:
2549
 
            i = args[0]
2550
 
            if isinstance(i, _Ints):
2551
 
                return _Constructor(cls, i)
2552
 
            if isinstance(i, Instance):
2553
 
                return i.media_new(*args[1:])
2554
 
 
2555
 
        o = get_default_instance().media_new(*args)
2556
 
        return o
2557
 
 
2558
 
    def get_instance(self):
2559
 
        return getattr(self, '_instance', None)
2560
 
 
2561
 
    def add_options(self, *options):
2562
 
        """Add a list of options to the media.
2563
 
 
2564
 
        Options must be written without the double-dash. Warning: most
2565
 
        audio and video options, such as text renderer, have no
2566
 
        effects on an individual media. These options must be set at
2567
 
        the vlc.Instance or vlc.MediaPlayer instanciation.
2568
 
 
2569
 
        @param options: optional media option=value strings
2570
 
        """
2571
 
        for o in options:
2572
 
            self.add_option(o)
2573
 
 
2574
 
    def tracks_get(self):
2575
 
        """Get media descriptor's elementary streams description
2576
 
        Note, you need to call L{parse}() or play the media at least once
2577
 
        before calling this function.
2578
 
        Not doing this will result in an empty array.
2579
 
        The result must be freed with L{tracks_release}.
2580
 
        @version: LibVLC 2.1.0 and later.
2581
 
        """
2582
 
        mediaTrack_pp = ctypes.POINTER(MediaTrack)()
2583
 
        n = libvlc_media_tracks_get(self, ctypes.byref(mediaTrack_pp))
2584
 
        info = ctypes.cast(mediaTrack_pp, ctypes.POINTER(ctypes.POINTER(MediaTrack) * n))
2585
 
        try:
2586
 
            contents = info.contents
2587
 
        except ValueError:
2588
 
            # Media not parsed, no info.
2589
 
            return None
2590
 
        tracks = (contents[i].contents for i in range(len(contents)))
2591
 
        # libvlc_media_tracks_release(mediaTrack_pp, n)
2592
 
        return tracks
2593
 
 
2594
 
    def add_option(self, psz_options):
2595
 
        '''Add an option to the media.
2596
 
        This option will be used to determine how the media_player will
2597
 
        read the media. This allows to use VLC's advanced
2598
 
        reading/streaming options on a per-media basis.
2599
 
        @note: The options are listed in 'vlc --long-help' from the command line,
2600
 
        e.g. "-sout-all". Keep in mind that available options and their semantics
2601
 
        vary across LibVLC versions and builds.
2602
 
        @warning: Not all options affects L{Media} objects:
2603
 
        Specifically, due to architectural issues most audio and video options,
2604
 
        such as text renderer options, have no effects on an individual media.
2605
 
        These options must be set through L{new}() instead.
2606
 
        @param psz_options: the options (as a string).
2607
 
        '''
2608
 
        return libvlc_media_add_option(self, str_to_bytes(psz_options))
2609
 
 
2610
 
    def add_option_flag(self, psz_options, i_flags):
2611
 
        '''Add an option to the media with configurable flags.
2612
 
        This option will be used to determine how the media_player will
2613
 
        read the media. This allows to use VLC's advanced
2614
 
        reading/streaming options on a per-media basis.
2615
 
        The options are detailed in vlc --long-help, for instance
2616
 
        "--sout-all". Note that all options are not usable on medias:
2617
 
        specifically, due to architectural issues, video-related options
2618
 
        such as text renderer options cannot be set on a single media. They
2619
 
        must be set on the whole libvlc instance instead.
2620
 
        @param psz_options: the options (as a string).
2621
 
        @param i_flags: the flags for this option.
2622
 
        '''
2623
 
        return libvlc_media_add_option_flag(self, str_to_bytes(psz_options), i_flags)
2624
 
 
2625
 
    def retain(self):
2626
 
        '''Retain a reference to a media descriptor object (L{Media}). Use
2627
 
        L{release}() to decrement the reference count of a
2628
 
        media descriptor object.
2629
 
        '''
2630
 
        return libvlc_media_retain(self)
2631
 
 
2632
 
    def release(self):
2633
 
        '''Decrement the reference count of a media descriptor object. If the
2634
 
        reference count is 0, then L{release}() will release the
2635
 
        media descriptor object. It will send out an libvlc_MediaFreed event
2636
 
        to all listeners. If the media descriptor object has been released it
2637
 
        should not be used again.
2638
 
        '''
2639
 
        return libvlc_media_release(self)
2640
 
 
2641
 
    def get_mrl(self):
2642
 
        '''Get the media resource locator (mrl) from a media descriptor object.
2643
 
        @return: string with mrl of media descriptor object.
2644
 
        '''
2645
 
        return libvlc_media_get_mrl(self)
2646
 
 
2647
 
    def duplicate(self):
2648
 
        '''Duplicate a media descriptor object.
2649
 
        '''
2650
 
        return libvlc_media_duplicate(self)
2651
 
 
2652
 
    def get_meta(self, e_meta):
2653
 
        '''Read the meta of the media.
2654
 
        If the media has not yet been parsed this will return None.
2655
 
        See L{parse}
2656
 
        See L{parse_with_options}
2657
 
        See libvlc_MediaMetaChanged.
2658
 
        @param e_meta: the meta to read.
2659
 
        @return: the media's meta.
2660
 
        '''
2661
 
        return libvlc_media_get_meta(self, e_meta)
2662
 
 
2663
 
    def set_meta(self, e_meta, psz_value):
2664
 
        '''Set the meta of the media (this function will not save the meta, call
2665
 
        L{save_meta} in order to save the meta).
2666
 
        @param e_meta: the meta to write.
2667
 
        @param psz_value: the media's meta.
2668
 
        '''
2669
 
        return libvlc_media_set_meta(self, e_meta, str_to_bytes(psz_value))
2670
 
 
2671
 
    def save_meta(self):
2672
 
        '''Save the meta previously set.
2673
 
        @return: true if the write operation was successful.
2674
 
        '''
2675
 
        return libvlc_media_save_meta(self)
2676
 
 
2677
 
    def get_state(self):
2678
 
        '''Get current state of media descriptor object. Possible media states are
2679
 
        libvlc_NothingSpecial=0, libvlc_Opening, libvlc_Playing, libvlc_Paused,
2680
 
        libvlc_Stopped, libvlc_Ended, libvlc_Error.
2681
 
        See L{State}.
2682
 
        @return: state of media descriptor object.
2683
 
        '''
2684
 
        return libvlc_media_get_state(self)
2685
 
 
2686
 
    def get_stats(self, p_stats):
2687
 
        '''Get the current statistics about the media.
2688
 
        @param p_stats:: structure that contain the statistics about the media (this structure must be allocated by the caller).
2689
 
        @return: true if the statistics are available, false otherwise \libvlc_return_bool.
2690
 
        '''
2691
 
        return libvlc_media_get_stats(self, p_stats)
2692
 
 
2693
 
    def subitems(self):
2694
 
        '''Get subitems of media descriptor object. This will increment
2695
 
        the reference count of supplied media descriptor object. Use
2696
 
        L{list_release}() to decrement the reference counting.
2697
 
        @return: list of media descriptor subitems or None.
2698
 
        '''
2699
 
        return libvlc_media_subitems(self)
2700
 
 
2701
 
    @memoize_parameterless
2702
 
    def event_manager(self):
2703
 
        '''Get event manager from media descriptor object.
2704
 
        NOTE: this function doesn't increment reference counting.
2705
 
        @return: event manager object.
2706
 
        '''
2707
 
        return libvlc_media_event_manager(self)
2708
 
 
2709
 
    def get_duration(self):
2710
 
        '''Get duration (in ms) of media descriptor object item.
2711
 
        @return: duration of media item or -1 on error.
2712
 
        '''
2713
 
        return libvlc_media_get_duration(self)
2714
 
 
2715
 
    def parse_with_options(self, parse_flag, timeout):
2716
 
        '''Parse the media asynchronously with options.
2717
 
        This fetches (local or network) art, meta data and/or tracks information.
2718
 
        This method is the extended version of L{parse_with_options}().
2719
 
        To track when this is over you can listen to libvlc_MediaParsedChanged
2720
 
        event. However if this functions returns an error, you will not receive any
2721
 
        events.
2722
 
        It uses a flag to specify parse options (see L{MediaParseFlag}). All
2723
 
        these flags can be combined. By default, media is parsed if it's a local
2724
 
        file.
2725
 
        @note: Parsing can be aborted with L{parse_stop}().
2726
 
        See libvlc_MediaParsedChanged
2727
 
        See L{get_meta}
2728
 
        See L{tracks_get}
2729
 
        See L{get_parsed_status}
2730
 
        See L{MediaParseFlag}.
2731
 
        @param parse_flag: parse options:
2732
 
        @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).
2733
 
        @return: -1 in case of error, 0 otherwise.
2734
 
        @version: LibVLC 3.0.0 or later.
2735
 
        '''
2736
 
        return libvlc_media_parse_with_options(self, parse_flag, timeout)
2737
 
 
2738
 
    def parse_stop(self):
2739
 
        '''Stop the parsing of the media
2740
 
        When the media parsing is stopped, the libvlc_MediaParsedChanged event will
2741
 
        be sent with the libvlc_media_parsed_status_timeout status.
2742
 
        See L{parse_with_options}.
2743
 
        @version: LibVLC 3.0.0 or later.
2744
 
        '''
2745
 
        return libvlc_media_parse_stop(self)
2746
 
 
2747
 
    def get_parsed_status(self):
2748
 
        '''Get Parsed status for media descriptor object.
2749
 
        See libvlc_MediaParsedChanged
2750
 
        See L{MediaParsedStatus}.
2751
 
        @return: a value of the L{MediaParsedStatus} enum.
2752
 
        @version: LibVLC 3.0.0 or later.
2753
 
        '''
2754
 
        return libvlc_media_get_parsed_status(self)
2755
 
 
2756
 
    def set_user_data(self, p_new_user_data):
2757
 
        '''Sets media descriptor's user_data. user_data is specialized data
2758
 
        accessed by the host application, VLC.framework uses it as a pointer to
2759
 
        an native object that references a L{Media} pointer.
2760
 
        @param p_new_user_data: pointer to user data.
2761
 
        '''
2762
 
        return libvlc_media_set_user_data(self, p_new_user_data)
2763
 
 
2764
 
    def get_user_data(self):
2765
 
        '''Get media descriptor's user_data. user_data is specialized data
2766
 
        accessed by the host application, VLC.framework uses it as a pointer to
2767
 
        an native object that references a L{Media} pointer.
2768
 
        '''
2769
 
        return libvlc_media_get_user_data(self)
2770
 
 
2771
 
    def get_type(self):
2772
 
        '''Get the media type of the media descriptor object.
2773
 
        @return: media type.
2774
 
        @version: LibVLC 3.0.0 and later. See L{MediaType}.
2775
 
        '''
2776
 
        return libvlc_media_get_type(self)
2777
 
 
2778
 
    def slaves_add(self, i_type, i_priority, psz_uri):
2779
 
        '''Add a slave to the current media.
2780
 
        A slave is an external input source that may contains an additional subtitle
2781
 
        track (like a .srt) or an additional audio track (like a .ac3).
2782
 
        @note: This function must be called before the media is parsed (via
2783
 
        L{parse_with_options}()) or before the media is played (via
2784
 
        L{player_play}()).
2785
 
        @param i_type: subtitle or audio.
2786
 
        @param i_priority: from 0 (low priority) to 4 (high priority).
2787
 
        @param psz_uri: Uri of the slave (should contain a valid scheme).
2788
 
        @return: 0 on success, -1 on error.
2789
 
        @version: LibVLC 3.0.0 and later.
2790
 
        '''
2791
 
        return libvlc_media_slaves_add(self, i_type, i_priority, str_to_bytes(psz_uri))
2792
 
 
2793
 
    def slaves_clear(self):
2794
 
        '''Clear all slaves previously added by L{slaves_add}() or
2795
 
        internally.
2796
 
        @version: LibVLC 3.0.0 and later.
2797
 
        '''
2798
 
        return libvlc_media_slaves_clear(self)
2799
 
 
2800
 
    def slaves_get(self, ppp_slaves):
2801
 
        '''Get a media descriptor's slave list
2802
 
        The list will contain slaves parsed by VLC or previously added by
2803
 
        L{slaves_add}(). The typical use case of this function is to save
2804
 
        a list of slave in a database for a later use.
2805
 
        @param ppp_slaves: address to store an allocated array of slaves (must be freed with L{slaves_release}()) [OUT].
2806
 
        @return: the number of slaves (zero on error).
2807
 
        @version: LibVLC 3.0.0 and later. See L{slaves_add}.
2808
 
        '''
2809
 
        return libvlc_media_slaves_get(self, ppp_slaves)
2810
 
 
2811
 
    def parse(self):
2812
 
        '''Parse a media.
2813
 
        This fetches (local) art, meta data and tracks information.
2814
 
        The method is synchronous.
2815
 
        \deprecated This function could block indefinitely.
2816
 
                    Use L{parse_with_options}() instead
2817
 
        See L{parse_with_options}
2818
 
        See L{get_meta}
2819
 
        See L{get_tracks_info}.
2820
 
        '''
2821
 
        return libvlc_media_parse(self)
2822
 
 
2823
 
    def parse_async(self):
2824
 
        '''Parse a media.
2825
 
        This fetches (local) art, meta data and tracks information.
2826
 
        The method is the asynchronous of L{parse}().
2827
 
        To track when this is over you can listen to libvlc_MediaParsedChanged
2828
 
        event. However if the media was already parsed you will not receive this
2829
 
        event.
2830
 
        \deprecated You can't be sure to receive the libvlc_MediaParsedChanged
2831
 
                    event (you can wait indefinitely for this event).
2832
 
                    Use L{parse_with_options}() instead
2833
 
        See L{parse}
2834
 
        See libvlc_MediaParsedChanged
2835
 
        See L{get_meta}
2836
 
        See L{get_tracks_info}.
2837
 
        '''
2838
 
        return libvlc_media_parse_async(self)
2839
 
 
2840
 
    def is_parsed(self):
2841
 
        '''Return true is the media descriptor object is parsed
2842
 
        \deprecated This can return true in case of failure.
2843
 
                    Use L{get_parsed_status}() instead
2844
 
        See libvlc_MediaParsedChanged.
2845
 
        @return: true if media object has been parsed otherwise it returns false \libvlc_return_bool.
2846
 
        '''
2847
 
        return libvlc_media_is_parsed(self)
2848
 
 
2849
 
    def get_tracks_info(self):
2850
 
        '''Get media descriptor's elementary streams description
2851
 
        Note, you need to call L{parse}() or play the media at least once
2852
 
        before calling this function.
2853
 
        Not doing this will result in an empty array.
2854
 
        \deprecated Use L{tracks_get}() instead.
2855
 
        @param tracks: address to store an allocated array of Elementary Streams descriptions (must be freed by the caller) [OUT].
2856
 
        @return: the number of Elementary Streams.
2857
 
        '''
2858
 
        return libvlc_media_get_tracks_info(self)
2859
 
 
2860
 
    def player_new_from_media(self):
2861
 
        '''Create a Media Player object from a Media.
2862
 
        @return: a new media player object, or None on error.
2863
 
        '''
2864
 
        return libvlc_media_player_new_from_media(self)
2865
 
 
2866
 
 
2867
 
class MediaDiscoverer(_Ctype):
2868
 
    '''N/A
2869
 
    '''
2870
 
 
2871
 
    def __new__(cls, ptr=_internal_guard):
2872
 
        '''(INTERNAL) ctypes wrapper constructor.
2873
 
        '''
2874
 
        return _Constructor(cls, ptr)
2875
 
 
2876
 
    def start(self):
2877
 
        '''Start media discovery.
2878
 
        To stop it, call L{stop}() or
2879
 
        L{list_release}() directly.
2880
 
        See L{stop}.
2881
 
        @return: -1 in case of error, 0 otherwise.
2882
 
        @version: LibVLC 3.0.0 or later.
2883
 
        '''
2884
 
        return libvlc_media_discoverer_start(self)
2885
 
 
2886
 
    def stop(self):
2887
 
        '''Stop media discovery.
2888
 
        See L{start}.
2889
 
        @version: LibVLC 3.0.0 or later.
2890
 
        '''
2891
 
        return libvlc_media_discoverer_stop(self)
2892
 
 
2893
 
    def release(self):
2894
 
        '''Release media discover object. If the reference count reaches 0, then
2895
 
        the object will be released.
2896
 
        '''
2897
 
        return libvlc_media_discoverer_release(self)
2898
 
 
2899
 
    def media_list(self):
2900
 
        '''Get media service discover media list.
2901
 
        @return: list of media items.
2902
 
        '''
2903
 
        return libvlc_media_discoverer_media_list(self)
2904
 
 
2905
 
    def is_running(self):
2906
 
        '''Query if media service discover object is running.
2907
 
        @return: true if running, false if not \libvlc_return_bool.
2908
 
        '''
2909
 
        return libvlc_media_discoverer_is_running(self)
2910
 
 
2911
 
    def localized_name(self):
2912
 
        '''Get media service discover object its localized name.
2913
 
        \deprecated Useless, use L{list_get}() to get the
2914
 
        longname of the service discovery.
2915
 
        @return: localized name or None if the media_discoverer is not started.
2916
 
        '''
2917
 
        return libvlc_media_discoverer_localized_name(self)
2918
 
 
2919
 
    @memoize_parameterless
2920
 
    def event_manager(self):
2921
 
        '''Get event manager from media service discover object.
2922
 
        \deprecated Useless, media_discoverer events are only triggered when calling
2923
 
        L{start}() and L{stop}().
2924
 
        @return: event manager object.
2925
 
        '''
2926
 
        return libvlc_media_discoverer_event_manager(self)
2927
 
 
2928
 
 
2929
 
class MediaLibrary(_Ctype):
2930
 
    '''N/A
2931
 
    '''
2932
 
 
2933
 
    def __new__(cls, ptr=_internal_guard):
2934
 
        '''(INTERNAL) ctypes wrapper constructor.
2935
 
        '''
2936
 
        return _Constructor(cls, ptr)
2937
 
 
2938
 
    def release(self):
2939
 
        '''Release media library object. This functions decrements the
2940
 
        reference count of the media library object. If it reaches 0,
2941
 
        then the object will be released.
2942
 
        '''
2943
 
        return libvlc_media_library_release(self)
2944
 
 
2945
 
    def retain(self):
2946
 
        '''Retain a reference to a media library object. This function will
2947
 
        increment the reference counting for this object. Use
2948
 
        L{release}() to decrement the reference count.
2949
 
        '''
2950
 
        return libvlc_media_library_retain(self)
2951
 
 
2952
 
    def load(self):
2953
 
        '''Load media library.
2954
 
        @return: 0 on success, -1 on error.
2955
 
        '''
2956
 
        return libvlc_media_library_load(self)
2957
 
 
2958
 
    def media_list(self):
2959
 
        '''Get media library subitems.
2960
 
        @return: media list subitems.
2961
 
        '''
2962
 
        return libvlc_media_library_media_list(self)
2963
 
 
2964
 
 
2965
 
class MediaList(_Ctype):
2966
 
    '''Create a new MediaList instance.
2967
 
 
2968
 
    Usage: MediaList(list_of_MRLs)
2969
 
 
2970
 
    See vlc.Instance.media_list_new documentation for details.
2971
 
 
2972
 
    '''
2973
 
 
2974
 
    def __new__(cls, *args):
2975
 
        if args:
2976
 
            i = args[0]
2977
 
            if isinstance(i, _Ints):
2978
 
                return _Constructor(cls, i)
2979
 
            if isinstance(i, Instance):
2980
 
                return i.media_list_new(*args[1:])
2981
 
 
2982
 
        o = get_default_instance().media_list_new(*args)
2983
 
        return o
2984
 
 
2985
 
    def get_instance(self):
2986
 
        return getattr(self, '_instance', None)
2987
 
 
2988
 
    def add_media(self, mrl):
2989
 
        """Add media instance to media list.
2990
 
 
2991
 
        The L{lock} should be held upon entering this function.
2992
 
        @param mrl: a media instance or a MRL.
2993
 
        @return: 0 on success, -1 if the media list is read-only.
2994
 
        """
2995
 
        if isinstance(mrl, basestring):
2996
 
            mrl = (self.get_instance() or get_default_instance()).media_new(mrl)
2997
 
        return libvlc_media_list_add_media(self, mrl)
2998
 
 
2999
 
    def release(self):
3000
 
        '''Release media list created with L{new}().
3001
 
        '''
3002
 
        return libvlc_media_list_release(self)
3003
 
 
3004
 
    def retain(self):
3005
 
        '''Retain reference to a media list.
3006
 
        '''
3007
 
        return libvlc_media_list_retain(self)
3008
 
 
3009
 
    def set_media(self, p_md):
3010
 
        '''Associate media instance with this media list instance.
3011
 
        If another media instance was present it will be released.
3012
 
        The L{lock} should NOT be held upon entering this function.
3013
 
        @param p_md: media instance to add.
3014
 
        '''
3015
 
        return libvlc_media_list_set_media(self, p_md)
3016
 
 
3017
 
    def media(self):
3018
 
        '''Get media instance from this media list instance. This action will increase
3019
 
        the refcount on the media instance.
3020
 
        The L{lock} should NOT be held upon entering this function.
3021
 
        @return: media instance.
3022
 
        '''
3023
 
        return libvlc_media_list_media(self)
3024
 
 
3025
 
    def insert_media(self, p_md, i_pos):
3026
 
        '''Insert media instance in media list on a position
3027
 
        The L{lock} should be held upon entering this function.
3028
 
        @param p_md: a media instance.
3029
 
        @param i_pos: position in array where to insert.
3030
 
        @return: 0 on success, -1 if the media list is read-only.
3031
 
        '''
3032
 
        return libvlc_media_list_insert_media(self, p_md, i_pos)
3033
 
 
3034
 
    def remove_index(self, i_pos):
3035
 
        '''Remove media instance from media list on a position
3036
 
        The L{lock} should be held upon entering this function.
3037
 
        @param i_pos: position in array where to insert.
3038
 
        @return: 0 on success, -1 if the list is read-only or the item was not found.
3039
 
        '''
3040
 
        return libvlc_media_list_remove_index(self, i_pos)
3041
 
 
3042
 
    def count(self):
3043
 
        '''Get count on media list items
3044
 
        The L{lock} should be held upon entering this function.
3045
 
        @return: number of items in media list.
3046
 
        '''
3047
 
        return libvlc_media_list_count(self)
3048
 
 
3049
 
    def __len__(self):
3050
 
        return libvlc_media_list_count(self)
3051
 
 
3052
 
    def item_at_index(self, i_pos):
3053
 
        '''List media instance in media list at a position
3054
 
        The L{lock} should be held upon entering this function.
3055
 
        @param i_pos: position in array where to insert.
3056
 
        @return: media instance at position i_pos, or None if not found. In case of success, L{media_retain}() is called to increase the refcount on the media.
3057
 
        '''
3058
 
        return libvlc_media_list_item_at_index(self, i_pos)
3059
 
 
3060
 
    def __getitem__(self, i):
3061
 
        return libvlc_media_list_item_at_index(self, i)
3062
 
 
3063
 
    def __iter__(self):
3064
 
        for i in range(len(self)):
3065
 
            yield self[i]
3066
 
 
3067
 
    def index_of_item(self, p_md):
3068
 
        '''Find index position of List media instance in media list.
3069
 
        Warning: the function will return the first matched position.
3070
 
        The L{lock} should be held upon entering this function.
3071
 
        @param p_md: media instance.
3072
 
        @return: position of media instance or -1 if media not found.
3073
 
        '''
3074
 
        return libvlc_media_list_index_of_item(self, p_md)
3075
 
 
3076
 
    def is_readonly(self):
3077
 
        '''This indicates if this media list is read-only from a user point of view.
3078
 
        @return: 1 on readonly, 0 on readwrite \libvlc_return_bool.
3079
 
        '''
3080
 
        return libvlc_media_list_is_readonly(self)
3081
 
 
3082
 
    def lock(self):
3083
 
        '''Get lock on media list items.
3084
 
        '''
3085
 
        return libvlc_media_list_lock(self)
3086
 
 
3087
 
    def unlock(self):
3088
 
        '''Release lock on media list items
3089
 
        The L{lock} should be held upon entering this function.
3090
 
        '''
3091
 
        return libvlc_media_list_unlock(self)
3092
 
 
3093
 
    @memoize_parameterless
3094
 
    def event_manager(self):
3095
 
        '''Get libvlc_event_manager from this media list instance.
3096
 
        The p_event_manager is immutable, so you don't have to hold the lock.
3097
 
        @return: libvlc_event_manager.
3098
 
        '''
3099
 
        return libvlc_media_list_event_manager(self)
3100
 
 
3101
 
 
3102
 
class MediaListPlayer(_Ctype):
3103
 
    '''Create a new MediaListPlayer instance.
3104
 
 
3105
 
    It may take as parameter either:
3106
 
      - a vlc.Instance
3107
 
      - nothing
3108
 
 
3109
 
    '''
3110
 
 
3111
 
    def __new__(cls, arg=None):
3112
 
        if arg is None:
3113
 
            i = get_default_instance()
3114
 
        elif isinstance(arg, Instance):
3115
 
            i = arg
3116
 
        elif isinstance(arg, _Ints):
3117
 
            return _Constructor(cls, arg)
3118
 
        else:
3119
 
            raise TypeError('MediaListPlayer %r' % (arg,))
3120
 
 
3121
 
        return i.media_list_player_new()
3122
 
 
3123
 
    def get_instance(self):
3124
 
        """Return the associated Instance.
3125
 
        """
3126
 
        return self._instance  # PYCHOK expected
3127
 
 
3128
 
    def release(self):
3129
 
        '''Release a media_list_player after use
3130
 
        Decrement the reference count of a media player object. If the
3131
 
        reference count is 0, then L{release}() will
3132
 
        release the media player object. If the media player object
3133
 
        has been released, then it should not be used again.
3134
 
        '''
3135
 
        return libvlc_media_list_player_release(self)
3136
 
 
3137
 
    def retain(self):
3138
 
        '''Retain a reference to a media player list object. Use
3139
 
        L{release}() to decrement reference count.
3140
 
        '''
3141
 
        return libvlc_media_list_player_retain(self)
3142
 
 
3143
 
    @memoize_parameterless
3144
 
    def event_manager(self):
3145
 
        '''Return the event manager of this media_list_player.
3146
 
        @return: the event manager.
3147
 
        '''
3148
 
        return libvlc_media_list_player_event_manager(self)
3149
 
 
3150
 
    def set_media_player(self, p_mi):
3151
 
        '''Replace media player in media_list_player with this instance.
3152
 
        @param p_mi: media player instance.
3153
 
        '''
3154
 
        return libvlc_media_list_player_set_media_player(self, p_mi)
3155
 
 
3156
 
    def get_media_player(self):
3157
 
        '''Get media player of the media_list_player instance.
3158
 
        @return: media player instance @note the caller is responsible for releasing the returned instance.
3159
 
        '''
3160
 
        return libvlc_media_list_player_get_media_player(self)
3161
 
 
3162
 
    def set_media_list(self, p_mlist):
3163
 
        '''Set the media list associated with the player.
3164
 
        @param p_mlist: list of media.
3165
 
        '''
3166
 
        return libvlc_media_list_player_set_media_list(self, p_mlist)
3167
 
 
3168
 
    def play(self):
3169
 
        '''Play media list.
3170
 
        '''
3171
 
        return libvlc_media_list_player_play(self)
3172
 
 
3173
 
    def pause(self):
3174
 
        '''Toggle pause (or resume) media list.
3175
 
        '''
3176
 
        return libvlc_media_list_player_pause(self)
3177
 
 
3178
 
    def set_pause(self, do_pause):
3179
 
        '''Pause or resume media list.
3180
 
        @param do_pause: play/resume if zero, pause if non-zero.
3181
 
        @version: LibVLC 3.0.0 or later.
3182
 
        '''
3183
 
        return libvlc_media_list_player_set_pause(self, do_pause)
3184
 
 
3185
 
    def is_playing(self):
3186
 
        '''Is media list playing?
3187
 
        @return: true for playing and false for not playing \libvlc_return_bool.
3188
 
        '''
3189
 
        return libvlc_media_list_player_is_playing(self)
3190
 
 
3191
 
    def get_state(self):
3192
 
        '''Get current libvlc_state of media list player.
3193
 
        @return: L{State} for media list player.
3194
 
        '''
3195
 
        return libvlc_media_list_player_get_state(self)
3196
 
 
3197
 
    def play_item_at_index(self, i_index):
3198
 
        '''Play media list item at position index.
3199
 
        @param i_index: index in media list to play.
3200
 
        @return: 0 upon success -1 if the item wasn't found.
3201
 
        '''
3202
 
        return libvlc_media_list_player_play_item_at_index(self, i_index)
3203
 
 
3204
 
    def __getitem__(self, i):
3205
 
        return libvlc_media_list_player_play_item_at_index(self, i)
3206
 
 
3207
 
    def __iter__(self):
3208
 
        for i in range(len(self)):
3209
 
            yield self[i]
3210
 
 
3211
 
    def play_item(self, p_md):
3212
 
        '''Play the given media item.
3213
 
        @param p_md: the media instance.
3214
 
        @return: 0 upon success, -1 if the media is not part of the media list.
3215
 
        '''
3216
 
        return libvlc_media_list_player_play_item(self, p_md)
3217
 
 
3218
 
    def stop(self):
3219
 
        '''Stop playing media list.
3220
 
        '''
3221
 
        return libvlc_media_list_player_stop(self)
3222
 
 
3223
 
    def next(self):
3224
 
        '''Play next item from media list.
3225
 
        @return: 0 upon success -1 if there is no next item.
3226
 
        '''
3227
 
        return libvlc_media_list_player_next(self)
3228
 
 
3229
 
    def previous(self):
3230
 
        '''Play previous item from media list.
3231
 
        @return: 0 upon success -1 if there is no previous item.
3232
 
        '''
3233
 
        return libvlc_media_list_player_previous(self)
3234
 
 
3235
 
    def set_playback_mode(self, e_mode):
3236
 
        '''Sets the playback mode for the playlist.
3237
 
        @param e_mode: playback mode specification.
3238
 
        '''
3239
 
        return libvlc_media_list_player_set_playback_mode(self, e_mode)
3240
 
 
3241
 
 
3242
 
class MediaPlayer(_Ctype):
3243
 
    '''Create a new MediaPlayer instance.
3244
 
 
3245
 
    It may take as parameter either:
3246
 
      - a string (media URI), options... In this case, a vlc.Instance will be created.
3247
 
      - a vlc.Instance, a string (media URI), options...
3248
 
 
3249
 
    '''
3250
 
 
3251
 
    def __new__(cls, *args):
3252
 
        if len(args) == 1 and isinstance(args[0], _Ints):
3253
 
            return _Constructor(cls, args[0])
3254
 
 
3255
 
        if args and isinstance(args[0], Instance):
3256
 
            instance = args[0]
3257
 
            args = args[1:]
3258
 
        else:
3259
 
            instance = get_default_instance()
3260
 
 
3261
 
        o = instance.media_player_new()
3262
 
        if args:
3263
 
            o.set_media(instance.media_new(*args))
3264
 
        return o
3265
 
 
3266
 
    def get_instance(self):
3267
 
        """Return the associated Instance.
3268
 
        """
3269
 
        return self._instance  # PYCHOK expected
3270
 
 
3271
 
    def set_mrl(self, mrl, *options):
3272
 
        """Set the MRL to play.
3273
 
 
3274
 
        Warning: most audio and video options, such as text renderer,
3275
 
        have no effects on an individual media. These options must be
3276
 
        set at the vlc.Instance or vlc.MediaPlayer instanciation.
3277
 
 
3278
 
        @param mrl: The MRL
3279
 
        @param options: optional media option=value strings
3280
 
        @return: the Media object
3281
 
        """
3282
 
        m = self.get_instance().media_new(mrl, *options)
3283
 
        self.set_media(m)
3284
 
        return m
3285
 
 
3286
 
    def video_get_spu_description(self):
3287
 
        """Get the description of available video subtitles.
3288
 
        """
3289
 
        return track_description_list(libvlc_video_get_spu_description(self))
3290
 
 
3291
 
    def video_get_title_description(self):
3292
 
        """Get the description of available titles.
3293
 
        """
3294
 
        return track_description_list(libvlc_video_get_title_description(self))
3295
 
 
3296
 
    def video_get_chapter_description(self, title):
3297
 
        """Get the description of available chapters for specific title.
3298
 
 
3299
 
        @param title: selected title (int)
3300
 
        """
3301
 
        return track_description_list(libvlc_video_get_chapter_description(self, title))
3302
 
 
3303
 
    def video_get_track_description(self):
3304
 
        """Get the description of available video tracks.
3305
 
        """
3306
 
        return track_description_list(libvlc_video_get_track_description(self))
3307
 
 
3308
 
    def audio_get_track_description(self):
3309
 
        """Get the description of available audio tracks.
3310
 
        """
3311
 
        return track_description_list(libvlc_audio_get_track_description(self))
3312
 
 
3313
 
    def get_full_title_descriptions(self):
3314
 
        '''Get the full description of available titles.
3315
 
        @return: the titles list
3316
 
        @version: LibVLC 3.0.0 and later.
3317
 
        '''
3318
 
        titleDescription_pp = ctypes.POINTER(TitleDescription)()
3319
 
        n = libvlc_media_player_get_full_title_descriptions(self, ctypes.byref(titleDescription_pp))
3320
 
        info = ctypes.cast(titleDescription_pp, ctypes.POINTER(ctypes.POINTER(TitleDescription) * n))
3321
 
        try:
3322
 
            contents = info.contents
3323
 
        except ValueError:
3324
 
            # Media not parsed, no info.
3325
 
            return None
3326
 
        descr = (contents[i].contents for i in range(len(contents)))
3327
 
        return descr
3328
 
 
3329
 
    def get_full_chapter_descriptions(self, i_chapters_of_title):
3330
 
        '''Get the full description of available chapters.
3331
 
        @param i_chapters_of_title: index of the title to query for chapters (uses current title if set to -1).
3332
 
        @return: the chapters list
3333
 
        @version: LibVLC 3.0.0 and later.
3334
 
        '''
3335
 
        chapterDescription_pp = ctypes.POINTER(ChapterDescription)()
3336
 
        n = libvlc_media_player_get_full_chapter_descriptions(self, ctypes.byref(chapterDescription_pp))
3337
 
        info = ctypes.cast(chapterDescription_pp, ctypes.POINTER(ctypes.POINTER(ChapterDescription) * n))
3338
 
        try:
3339
 
            contents = info.contents
3340
 
        except ValueError:
3341
 
            # Media not parsed, no info.
3342
 
            return None
3343
 
        descr = (contents[i].contents for i in range(len(contents)))
3344
 
        return descr
3345
 
 
3346
 
    def video_get_size(self, num=0):
3347
 
        """Get the video size in pixels as 2-tuple (width, height).
3348
 
 
3349
 
        @param num: video number (default 0).
3350
 
        """
3351
 
        r = libvlc_video_get_size(self, num)
3352
 
        if isinstance(r, tuple) and len(r) == 2:
3353
 
            return r
3354
 
        else:
3355
 
            raise VLCException('invalid video number (%s)' % (num,))
3356
 
 
3357
 
    def set_hwnd(self, drawable):
3358
 
        """Set a Win32/Win64 API window handle (HWND).
3359
 
 
3360
 
        Specify where the media player should render its video
3361
 
        output. If LibVLC was built without Win32/Win64 API output
3362
 
        support, then this has no effects.
3363
 
 
3364
 
        @param drawable: windows handle of the drawable.
3365
 
        """
3366
 
        if not isinstance(drawable, ctypes.c_void_p):
3367
 
            drawable = ctypes.c_void_p(int(drawable))
3368
 
        libvlc_media_player_set_hwnd(self, drawable)
3369
 
 
3370
 
    def video_get_width(self, num=0):
3371
 
        """Get the width of a video in pixels.
3372
 
 
3373
 
        @param num: video number (default 0).
3374
 
        """
3375
 
        return self.video_get_size(num)[0]
3376
 
 
3377
 
    def video_get_height(self, num=0):
3378
 
        """Get the height of a video in pixels.
3379
 
 
3380
 
        @param num: video number (default 0).
3381
 
        """
3382
 
        return self.video_get_size(num)[1]
3383
 
 
3384
 
    def video_get_cursor(self, num=0):
3385
 
        """Get the mouse pointer coordinates over a video as 2-tuple (x, y).
3386
 
 
3387
 
        Coordinates are expressed in terms of the decoded video resolution,
3388
 
        B{not} in terms of pixels on the screen/viewport.  To get the
3389
 
        latter, you must query your windowing system directly.
3390
 
 
3391
 
        Either coordinate may be negative or larger than the corresponding
3392
 
        size of the video, if the cursor is outside the rendering area.
3393
 
 
3394
 
        @warning: The coordinates may be out-of-date if the pointer is not
3395
 
        located on the video rendering area.  LibVLC does not track the
3396
 
        mouse pointer if the latter is outside the video widget.
3397
 
 
3398
 
        @note: LibVLC does not support multiple mouse pointers (but does
3399
 
        support multiple input devices sharing the same pointer).
3400
 
 
3401
 
        @param num: video number (default 0).
3402
 
        """
3403
 
        r = libvlc_video_get_cursor(self, num)
3404
 
        if isinstance(r, tuple) and len(r) == 2:
3405
 
            return r
3406
 
        raise VLCException('invalid video number (%s)' % (num,))
3407
 
 
3408
 
    def get_fps(self):
3409
 
        '''Get movie fps rate
3410
 
        This function is provided for backward compatibility. It cannot deal with
3411
 
        multiple video tracks. In LibVLC versions prior to 3.0, it would also fail
3412
 
        if the file format did not convey the frame rate explicitly.
3413
 
        \deprecated Consider using L{media_tracks_get}() instead.
3414
 
        @return: frames per second (fps) for this playing movie, or 0 if unspecified.
3415
 
        '''
3416
 
        return libvlc_media_player_get_fps(self)
3417
 
 
3418
 
    def set_agl(self, drawable):
3419
 
        '''\deprecated Use L{set_nsobject}() instead.
3420
 
        '''
3421
 
        return libvlc_media_player_set_agl(self, drawable)
3422
 
 
3423
 
    def get_agl(self):
3424
 
        '''\deprecated Use L{get_nsobject}() instead.
3425
 
        '''
3426
 
        return libvlc_media_player_get_agl(self)
3427
 
 
3428
 
    def video_set_subtitle_file(self, psz_subtitle):
3429
 
        '''Set new video subtitle file.
3430
 
        \deprecated Use L{add_slave}() instead.
3431
 
        @param psz_subtitle: new video subtitle file.
3432
 
        @return: the success status (boolean).
3433
 
        '''
3434
 
        return libvlc_video_set_subtitle_file(self, str_to_bytes(psz_subtitle))
3435
 
 
3436
 
    def toggle_teletext(self):
3437
 
        '''Toggle teletext transparent status on video output.
3438
 
        \deprecated use L{video_set_teletext}() instead.
3439
 
        '''
3440
 
        return libvlc_toggle_teletext(self)
3441
 
 
3442
 
    def release(self):
3443
 
        '''Release a media_player after use
3444
 
        Decrement the reference count of a media player object. If the
3445
 
        reference count is 0, then L{release}() will
3446
 
        release the media player object. If the media player object
3447
 
        has been released, then it should not be used again.
3448
 
        '''
3449
 
        return libvlc_media_player_release(self)
3450
 
 
3451
 
    def retain(self):
3452
 
        '''Retain a reference to a media player object. Use
3453
 
        L{release}() to decrement reference count.
3454
 
        '''
3455
 
        return libvlc_media_player_retain(self)
3456
 
 
3457
 
    def set_media(self, p_md):
3458
 
        '''Set the media that will be used by the media_player. If any,
3459
 
        previous md will be released.
3460
 
        @param p_md: the Media. Afterwards the p_md can be safely destroyed.
3461
 
        '''
3462
 
        return libvlc_media_player_set_media(self, p_md)
3463
 
 
3464
 
    def get_media(self):
3465
 
        '''Get the media used by the media_player.
3466
 
        @return: the media associated with p_mi, or None if no media is associated.
3467
 
        '''
3468
 
        return libvlc_media_player_get_media(self)
3469
 
 
3470
 
    @memoize_parameterless
3471
 
    def event_manager(self):
3472
 
        '''Get the Event Manager from which the media player send event.
3473
 
        @return: the event manager associated with p_mi.
3474
 
        '''
3475
 
        return libvlc_media_player_event_manager(self)
3476
 
 
3477
 
    def is_playing(self):
3478
 
        '''is_playing.
3479
 
        @return: 1 if the media player is playing, 0 otherwise \libvlc_return_bool.
3480
 
        '''
3481
 
        return libvlc_media_player_is_playing(self)
3482
 
 
3483
 
    def play(self):
3484
 
        '''Play.
3485
 
        @return: 0 if playback started (and was already started), or -1 on error.
3486
 
        '''
3487
 
        return libvlc_media_player_play(self)
3488
 
 
3489
 
    def set_pause(self, do_pause):
3490
 
        '''Pause or resume (no effect if there is no media).
3491
 
        @param do_pause: play/resume if zero, pause if non-zero.
3492
 
        @version: LibVLC 1.1.1 or later.
3493
 
        '''
3494
 
        return libvlc_media_player_set_pause(self, do_pause)
3495
 
 
3496
 
    def pause(self):
3497
 
        '''Toggle pause (no effect if there is no media).
3498
 
        '''
3499
 
        return libvlc_media_player_pause(self)
3500
 
 
3501
 
    def stop(self):
3502
 
        '''Stop (no effect if there is no media).
3503
 
        '''
3504
 
        return libvlc_media_player_stop(self)
3505
 
 
3506
 
    def set_renderer(self, p_item):
3507
 
        '''Set a renderer to the media player
3508
 
        @note: must be called before the first call of L{play}() to
3509
 
        take effect.
3510
 
        See L{renderer_discoverer_new}.
3511
 
        @param p_item: an item discovered by L{renderer_discoverer_start}().
3512
 
        @return: 0 on success, -1 on error.
3513
 
        @version: LibVLC 3.0.0 or later.
3514
 
        '''
3515
 
        return libvlc_media_player_set_renderer(self, p_item)
3516
 
 
3517
 
    def video_set_callbacks(self, lock, unlock, display, opaque):
3518
 
        '''Set callbacks and private data to render decoded video to a custom area
3519
 
        in memory.
3520
 
        Use L{video_set_format}() or L{video_set_format_callbacks}()
3521
 
        to configure the decoded format.
3522
 
        @warning: Rendering video into custom memory buffers is considerably less
3523
 
        efficient than rendering in a custom window as normal.
3524
 
        For optimal perfomances, VLC media player renders into a custom window, and
3525
 
        does not use this function and associated callbacks. It is B{highly
3526
 
        recommended} that other LibVLC-based application do likewise.
3527
 
        To embed video in a window, use libvlc_media_player_set_xid() or equivalent
3528
 
        depending on the operating system.
3529
 
        If window embedding does not fit the application use case, then a custom
3530
 
        LibVLC video output display plugin is required to maintain optimal video
3531
 
        rendering performances.
3532
 
        The following limitations affect performance:
3533
 
        - Hardware video decoding acceleration will either be disabled completely,
3534
 
          or require (relatively slow) copy from video/DSP memory to main memory.
3535
 
        - Sub-pictures (subtitles, on-screen display, etc.) must be blent into the
3536
 
          main picture by the CPU instead of the GPU.
3537
 
        - Depending on the video format, pixel format conversion, picture scaling,
3538
 
          cropping and/or picture re-orientation, must be performed by the CPU
3539
 
          instead of the GPU.
3540
 
        - Memory copying is required between LibVLC reference picture buffers and
3541
 
          application buffers (between lock and unlock callbacks).
3542
 
        @param lock: callback to lock video memory (must not be None).
3543
 
        @param unlock: callback to unlock video memory (or None if not needed).
3544
 
        @param display: callback to display video (or None if not needed).
3545
 
        @param opaque: private pointer for the three callbacks (as first parameter).
3546
 
        @version: LibVLC 1.1.1 or later.
3547
 
        '''
3548
 
        return libvlc_video_set_callbacks(self, lock, unlock, display, opaque)
3549
 
 
3550
 
    def video_set_format(self, chroma, width, height, pitch):
3551
 
        '''Set decoded video chroma and dimensions.
3552
 
        This only works in combination with L{video_set_callbacks}(),
3553
 
        and is mutually exclusive with L{video_set_format_callbacks}().
3554
 
        @param chroma: a four-characters string identifying the chroma (e.g. "RV32" or "YUYV").
3555
 
        @param width: pixel width.
3556
 
        @param height: pixel height.
3557
 
        @param pitch: line pitch (in bytes).
3558
 
        @version: LibVLC 1.1.1 or later.
3559
 
        @bug: All pixel planes are expected to have the same pitch. To use the YCbCr color space with chrominance subsampling, consider using L{video_set_format_callbacks}() instead.
3560
 
        '''
3561
 
        return libvlc_video_set_format(self, str_to_bytes(chroma), width, height, pitch)
3562
 
 
3563
 
    def video_set_format_callbacks(self, setup, cleanup):
3564
 
        '''Set decoded video chroma and dimensions. This only works in combination with
3565
 
        L{video_set_callbacks}().
3566
 
        @param setup: callback to select the video format (cannot be None).
3567
 
        @param cleanup: callback to release any allocated resources (or None).
3568
 
        @version: LibVLC 2.0.0 or later.
3569
 
        '''
3570
 
        return libvlc_video_set_format_callbacks(self, setup, cleanup)
3571
 
 
3572
 
    def set_nsobject(self, drawable):
3573
 
        '''Set the NSView handler where the media player should render its video output.
3574
 
        Use the vout called "macosx".
3575
 
        The drawable is an NSObject that follow the VLCOpenGLVideoViewEmbedding
3576
 
        protocol:
3577
 
        @code.m
3578
 
        \@protocol VLCOpenGLVideoViewEmbedding <NSObject>
3579
 
        - (void)addVoutSubview:(NSView *)view;
3580
 
        - (void)removeVoutSubview:(NSView *)view;
3581
 
        \@end
3582
 
        @endcode
3583
 
        Or it can be an NSView object.
3584
 
        If you want to use it along with Qt see the QMacCocoaViewContainer. Then
3585
 
        the following code should work:
3586
 
        @code.mm
3587
 
 
3588
 
            NSView *video = [[NSView alloc] init];
3589
 
            QMacCocoaViewContainer *container = new QMacCocoaViewContainer(video, parent);
3590
 
            L{set_nsobject}(mp, video);
3591
 
            [video release];
3592
 
 
3593
 
        @endcode
3594
 
        You can find a live example in VLCVideoView in VLCKit.framework.
3595
 
        @param drawable: the drawable that is either an NSView or an object following the VLCOpenGLVideoViewEmbedding protocol.
3596
 
        '''
3597
 
        return libvlc_media_player_set_nsobject(self, drawable)
3598
 
 
3599
 
    def get_nsobject(self):
3600
 
        '''Get the NSView handler previously set with L{set_nsobject}().
3601
 
        @return: the NSView handler or 0 if none where set.
3602
 
        '''
3603
 
        return libvlc_media_player_get_nsobject(self)
3604
 
 
3605
 
    def set_xwindow(self, drawable):
3606
 
        '''Set an X Window System drawable where the media player should render its
3607
 
        video output. The call takes effect when the playback starts. If it is
3608
 
        already started, it might need to be stopped before changes apply.
3609
 
        If LibVLC was built without X11 output support, then this function has no
3610
 
        effects.
3611
 
        By default, LibVLC will capture input events on the video rendering area.
3612
 
        Use L{video_set_mouse_input}() and L{video_set_key_input}() to
3613
 
        disable that and deliver events to the parent window / to the application
3614
 
        instead. By design, the X11 protocol delivers input events to only one
3615
 
        recipient.
3616
 
        @warning
3617
 
        The application must call the XInitThreads() function from Xlib before
3618
 
        L{new}(), and before any call to XOpenDisplay() directly or via any
3619
 
        other library. Failure to call XInitThreads() will seriously impede LibVLC
3620
 
        performance. Calling XOpenDisplay() before XInitThreads() will eventually
3621
 
        crash the process. That is a limitation of Xlib.
3622
 
        @param drawable: X11 window ID @note The specified identifier must correspond to an existing Input/Output class X11 window. Pixmaps are B{not} currently supported. The default X11 server is assumed, i.e. that specified in the DISPLAY environment variable. @warning LibVLC can deal with invalid X11 handle errors, however some display drivers (EGL, GLX, VA and/or VDPAU) can unfortunately not. Thus the window handle must remain valid until playback is stopped, otherwise the process may abort or crash.
3623
 
        @bug No more than one window handle per media player instance can be specified. If the media has multiple simultaneously active video tracks, extra tracks will be rendered into external windows beyond the control of the application.
3624
 
        '''
3625
 
        return libvlc_media_player_set_xwindow(self, drawable)
3626
 
 
3627
 
    def get_xwindow(self):
3628
 
        '''Get the X Window System window identifier previously set with
3629
 
        L{set_xwindow}(). Note that this will return the identifier
3630
 
        even if VLC is not currently using it (for instance if it is playing an
3631
 
        audio-only input).
3632
 
        @return: an X window ID, or 0 if none where set.
3633
 
        '''
3634
 
        return libvlc_media_player_get_xwindow(self)
3635
 
 
3636
 
    def get_hwnd(self):
3637
 
        '''Get the Windows API window handle (HWND) previously set with
3638
 
        L{set_hwnd}(). The handle will be returned even if LibVLC
3639
 
        is not currently outputting any video to it.
3640
 
        @return: a window handle or None if there are none.
3641
 
        '''
3642
 
        return libvlc_media_player_get_hwnd(self)
3643
 
 
3644
 
    def set_android_context(self, p_awindow_handler):
3645
 
        '''Set the android context.
3646
 
        @param p_awindow_handler: org.videolan.libvlc.AWindow jobject owned by the org.videolan.libvlc.MediaPlayer class from the libvlc-android project.
3647
 
        @version: LibVLC 3.0.0 and later.
3648
 
        '''
3649
 
        return libvlc_media_player_set_android_context(self, p_awindow_handler)
3650
 
 
3651
 
    def set_evas_object(self, p_evas_object):
3652
 
        '''Set the EFL Evas Object.
3653
 
        @param p_evas_object: a valid EFL Evas Object (Evas_Object).
3654
 
        @return: -1 if an error was detected, 0 otherwise.
3655
 
        @version: LibVLC 3.0.0 and later.
3656
 
        '''
3657
 
        return libvlc_media_player_set_evas_object(self, p_evas_object)
3658
 
 
3659
 
    def audio_set_callbacks(self, play, pause, resume, flush, drain, opaque):
3660
 
        '''Sets callbacks and private data for decoded audio.
3661
 
        Use L{audio_set_format}() or L{audio_set_format_callbacks}()
3662
 
        to configure the decoded audio format.
3663
 
        @note: The audio callbacks override any other audio output mechanism.
3664
 
        If the callbacks are set, LibVLC will B{not} output audio in any way.
3665
 
        @param play: callback to play audio samples (must not be None).
3666
 
        @param pause: callback to pause playback (or None to ignore).
3667
 
        @param resume: callback to resume playback (or None to ignore).
3668
 
        @param flush: callback to flush audio buffers (or None to ignore).
3669
 
        @param drain: callback to drain audio buffers (or None to ignore).
3670
 
        @param opaque: private pointer for the audio callbacks (as first parameter).
3671
 
        @version: LibVLC 2.0.0 or later.
3672
 
        '''
3673
 
        return libvlc_audio_set_callbacks(self, play, pause, resume, flush, drain, opaque)
3674
 
 
3675
 
    def audio_set_volume_callback(self, set_volume):
3676
 
        '''Set callbacks and private data for decoded audio. This only works in
3677
 
        combination with L{audio_set_callbacks}().
3678
 
        Use L{audio_set_format}() or L{audio_set_format_callbacks}()
3679
 
        to configure the decoded audio format.
3680
 
        @param set_volume: callback to apply audio volume, or None to apply volume in software.
3681
 
        @version: LibVLC 2.0.0 or later.
3682
 
        '''
3683
 
        return libvlc_audio_set_volume_callback(self, set_volume)
3684
 
 
3685
 
    def audio_set_format_callbacks(self, setup, cleanup):
3686
 
        '''Sets decoded audio format via callbacks.
3687
 
        This only works in combination with L{audio_set_callbacks}().
3688
 
        @param setup: callback to select the audio format (cannot be None).
3689
 
        @param cleanup: callback to release any allocated resources (or None).
3690
 
        @version: LibVLC 2.0.0 or later.
3691
 
        '''
3692
 
        return libvlc_audio_set_format_callbacks(self, setup, cleanup)
3693
 
 
3694
 
    def audio_set_format(self, format, rate, channels):
3695
 
        '''Sets a fixed decoded audio format.
3696
 
        This only works in combination with L{audio_set_callbacks}(),
3697
 
        and is mutually exclusive with L{audio_set_format_callbacks}().
3698
 
        @param format: a four-characters string identifying the sample format (e.g. "S16N" or "FL32").
3699
 
        @param rate: sample rate (expressed in Hz).
3700
 
        @param channels: channels count.
3701
 
        @version: LibVLC 2.0.0 or later.
3702
 
        '''
3703
 
        return libvlc_audio_set_format(self, str_to_bytes(format), rate, channels)
3704
 
 
3705
 
    def get_length(self):
3706
 
        '''Get the current movie length (in ms).
3707
 
        @return: the movie length (in ms), or -1 if there is no media.
3708
 
        '''
3709
 
        return libvlc_media_player_get_length(self)
3710
 
 
3711
 
    def get_time(self):
3712
 
        '''Get the current movie time (in ms).
3713
 
        @return: the movie time (in ms), or -1 if there is no media.
3714
 
        '''
3715
 
        return libvlc_media_player_get_time(self)
3716
 
 
3717
 
    def set_time(self, i_time):
3718
 
        '''Set the movie time (in ms). This has no effect if no media is being played.
3719
 
        Not all formats and protocols support this.
3720
 
        @param i_time: the movie time (in ms).
3721
 
        '''
3722
 
        return libvlc_media_player_set_time(self, i_time)
3723
 
 
3724
 
    def get_position(self):
3725
 
        '''Get movie position as percentage between 0.0 and 1.0.
3726
 
        @return: movie position, or -1. in case of error.
3727
 
        '''
3728
 
        return libvlc_media_player_get_position(self)
3729
 
 
3730
 
    def set_position(self, f_pos):
3731
 
        '''Set movie position as percentage between 0.0 and 1.0.
3732
 
        This has no effect if playback is not enabled.
3733
 
        This might not work depending on the underlying input format and protocol.
3734
 
        @param f_pos: the position.
3735
 
        '''
3736
 
        return libvlc_media_player_set_position(self, f_pos)
3737
 
 
3738
 
    def set_chapter(self, i_chapter):
3739
 
        '''Set movie chapter (if applicable).
3740
 
        @param i_chapter: chapter number to play.
3741
 
        '''
3742
 
        return libvlc_media_player_set_chapter(self, i_chapter)
3743
 
 
3744
 
    def get_chapter(self):
3745
 
        '''Get movie chapter.
3746
 
        @return: chapter number currently playing, or -1 if there is no media.
3747
 
        '''
3748
 
        return libvlc_media_player_get_chapter(self)
3749
 
 
3750
 
    def get_chapter_count(self):
3751
 
        '''Get movie chapter count.
3752
 
        @return: number of chapters in movie, or -1.
3753
 
        '''
3754
 
        return libvlc_media_player_get_chapter_count(self)
3755
 
 
3756
 
    def will_play(self):
3757
 
        '''Is the player able to play.
3758
 
        @return: boolean \libvlc_return_bool.
3759
 
        '''
3760
 
        return libvlc_media_player_will_play(self)
3761
 
 
3762
 
    def get_chapter_count_for_title(self, i_title):
3763
 
        '''Get title chapter count.
3764
 
        @param i_title: title.
3765
 
        @return: number of chapters in title, or -1.
3766
 
        '''
3767
 
        return libvlc_media_player_get_chapter_count_for_title(self, i_title)
3768
 
 
3769
 
    def set_title(self, i_title):
3770
 
        '''Set movie title.
3771
 
        @param i_title: title number to play.
3772
 
        '''
3773
 
        return libvlc_media_player_set_title(self, i_title)
3774
 
 
3775
 
    def get_title(self):
3776
 
        '''Get movie title.
3777
 
        @return: title number currently playing, or -1.
3778
 
        '''
3779
 
        return libvlc_media_player_get_title(self)
3780
 
 
3781
 
    def get_title_count(self):
3782
 
        '''Get movie title count.
3783
 
        @return: title number count, or -1.
3784
 
        '''
3785
 
        return libvlc_media_player_get_title_count(self)
3786
 
 
3787
 
    def previous_chapter(self):
3788
 
        '''Set previous chapter (if applicable).
3789
 
        '''
3790
 
        return libvlc_media_player_previous_chapter(self)
3791
 
 
3792
 
    def next_chapter(self):
3793
 
        '''Set next chapter (if applicable).
3794
 
        '''
3795
 
        return libvlc_media_player_next_chapter(self)
3796
 
 
3797
 
    def get_rate(self):
3798
 
        '''Get the requested movie play rate.
3799
 
        @warning: Depending on the underlying media, the requested rate may be
3800
 
        different from the real playback rate.
3801
 
        @return: movie play rate.
3802
 
        '''
3803
 
        return libvlc_media_player_get_rate(self)
3804
 
 
3805
 
    def set_rate(self, rate):
3806
 
        '''Set movie play rate.
3807
 
        @param rate: movie play rate to set.
3808
 
        @return: -1 if an error was detected, 0 otherwise (but even then, it might not actually work depending on the underlying media protocol).
3809
 
        '''
3810
 
        return libvlc_media_player_set_rate(self, rate)
3811
 
 
3812
 
    def get_state(self):
3813
 
        '''Get current movie state.
3814
 
        @return: the current state of the media player (playing, paused, ...) See L{State}.
3815
 
        '''
3816
 
        return libvlc_media_player_get_state(self)
3817
 
 
3818
 
    def has_vout(self):
3819
 
        '''How many video outputs does this media player have?
3820
 
        @return: the number of video outputs.
3821
 
        '''
3822
 
        return libvlc_media_player_has_vout(self)
3823
 
 
3824
 
    def is_seekable(self):
3825
 
        '''Is this media player seekable?
3826
 
        @return: true if the media player can seek \libvlc_return_bool.
3827
 
        '''
3828
 
        return libvlc_media_player_is_seekable(self)
3829
 
 
3830
 
    def can_pause(self):
3831
 
        '''Can this media player be paused?
3832
 
        @return: true if the media player can pause \libvlc_return_bool.
3833
 
        '''
3834
 
        return libvlc_media_player_can_pause(self)
3835
 
 
3836
 
    def program_scrambled(self):
3837
 
        '''Check if the current program is scrambled.
3838
 
        @return: true if the current program is scrambled \libvlc_return_bool.
3839
 
        @version: LibVLC 2.2.0 or later.
3840
 
        '''
3841
 
        return libvlc_media_player_program_scrambled(self)
3842
 
 
3843
 
    def next_frame(self):
3844
 
        '''Display the next frame (if supported).
3845
 
        '''
3846
 
        return libvlc_media_player_next_frame(self)
3847
 
 
3848
 
    def navigate(self, navigate):
3849
 
        '''Navigate through DVD Menu.
3850
 
        @param navigate: the Navigation mode.
3851
 
        @version: libVLC 2.0.0 or later.
3852
 
        '''
3853
 
        return libvlc_media_player_navigate(self, navigate)
3854
 
 
3855
 
    def set_video_title_display(self, position, timeout):
3856
 
        '''Set if, and how, the video title will be shown when media is played.
3857
 
        @param position: position at which to display the title, or libvlc_position_disable to prevent the title from being displayed.
3858
 
        @param timeout: title display timeout in milliseconds (ignored if libvlc_position_disable).
3859
 
        @version: libVLC 2.1.0 or later.
3860
 
        '''
3861
 
        return libvlc_media_player_set_video_title_display(self, position, timeout)
3862
 
 
3863
 
    def add_slave(self, i_type, psz_uri, b_select):
3864
 
        '''Add a slave to the current media player.
3865
 
        @note: If the player is playing, the slave will be added directly. This call
3866
 
        will also update the slave list of the attached L{Media}.
3867
 
        @param i_type: subtitle or audio.
3868
 
        @param psz_uri: Uri of the slave (should contain a valid scheme).
3869
 
        @param b_select: True if this slave should be selected when it's loaded.
3870
 
        @return: 0 on success, -1 on error.
3871
 
        @version: LibVLC 3.0.0 and later. See L{media_slaves_add}.
3872
 
        '''
3873
 
        return libvlc_media_player_add_slave(self, i_type, str_to_bytes(psz_uri), b_select)
3874
 
 
3875
 
    def toggle_fullscreen(self):
3876
 
        '''Toggle fullscreen status on non-embedded video outputs.
3877
 
        @warning: The same limitations applies to this function
3878
 
        as to L{set_fullscreen}().
3879
 
        '''
3880
 
        return libvlc_toggle_fullscreen(self)
3881
 
 
3882
 
    def set_fullscreen(self, b_fullscreen):
3883
 
        '''Enable or disable fullscreen.
3884
 
        @warning: With most window managers, only a top-level windows can be in
3885
 
        full-screen mode. Hence, this function will not operate properly if
3886
 
        L{set_xwindow}() was used to embed the video in a
3887
 
        non-top-level window. In that case, the embedding window must be reparented
3888
 
        to the root window B{before} fullscreen mode is enabled. You will want
3889
 
        to reparent it back to its normal parent when disabling fullscreen.
3890
 
        @param b_fullscreen: boolean for fullscreen status.
3891
 
        '''
3892
 
        return libvlc_set_fullscreen(self, b_fullscreen)
3893
 
 
3894
 
    def get_fullscreen(self):
3895
 
        '''Get current fullscreen status.
3896
 
        @return: the fullscreen status (boolean) \libvlc_return_bool.
3897
 
        '''
3898
 
        return libvlc_get_fullscreen(self)
3899
 
 
3900
 
    def video_set_key_input(self, on):
3901
 
        '''Enable or disable key press events handling, according to the LibVLC hotkeys
3902
 
        configuration. By default and for historical reasons, keyboard events are
3903
 
        handled by the LibVLC video widget.
3904
 
        @note: On X11, there can be only one subscriber for key press and mouse
3905
 
        click events per window. If your application has subscribed to those events
3906
 
        for the X window ID of the video widget, then LibVLC will not be able to
3907
 
        handle key presses and mouse clicks in any case.
3908
 
        @warning: This function is only implemented for X11 and Win32 at the moment.
3909
 
        @param on: true to handle key press events, false to ignore them.
3910
 
        '''
3911
 
        return libvlc_video_set_key_input(self, on)
3912
 
 
3913
 
    def video_set_mouse_input(self, on):
3914
 
        '''Enable or disable mouse click events handling. By default, those events are
3915
 
        handled. This is needed for DVD menus to work, as well as a few video
3916
 
        filters such as "puzzle".
3917
 
        See L{video_set_key_input}().
3918
 
        @warning: This function is only implemented for X11 and Win32 at the moment.
3919
 
        @param on: true to handle mouse click events, false to ignore them.
3920
 
        '''
3921
 
        return libvlc_video_set_mouse_input(self, on)
3922
 
 
3923
 
    def video_get_scale(self):
3924
 
        '''Get the current video scaling factor.
3925
 
        See also L{video_set_scale}().
3926
 
        @return: the currently configured zoom factor, or 0. if the video is set to fit to the output window/drawable automatically.
3927
 
        '''
3928
 
        return libvlc_video_get_scale(self)
3929
 
 
3930
 
    def video_set_scale(self, f_factor):
3931
 
        '''Set the video scaling factor. That is the ratio of the number of pixels on
3932
 
        screen to the number of pixels in the original decoded video in each
3933
 
        dimension. Zero is a special value; it will adjust the video to the output
3934
 
        window/drawable (in windowed mode) or the entire screen.
3935
 
        Note that not all video outputs support scaling.
3936
 
        @param f_factor: the scaling factor, or zero.
3937
 
        '''
3938
 
        return libvlc_video_set_scale(self, f_factor)
3939
 
 
3940
 
    def video_get_aspect_ratio(self):
3941
 
        '''Get current video aspect ratio.
3942
 
        @return: the video aspect ratio or None if unspecified (the result must be released with free() or L{free}()).
3943
 
        '''
3944
 
        return libvlc_video_get_aspect_ratio(self)
3945
 
 
3946
 
    def video_set_aspect_ratio(self, psz_aspect):
3947
 
        '''Set new video aspect ratio.
3948
 
        @param psz_aspect: new video aspect-ratio or None to reset to default @note Invalid aspect ratios are ignored.
3949
 
        '''
3950
 
        return libvlc_video_set_aspect_ratio(self, str_to_bytes(psz_aspect))
3951
 
 
3952
 
    def video_update_viewpoint(self, p_viewpoint, b_absolute):
3953
 
        '''Update the video viewpoint information.
3954
 
        @note: It is safe to call this function before the media player is started.
3955
 
        @param p_viewpoint: video viewpoint allocated via L{video_new_viewpoint}().
3956
 
        @param b_absolute: if true replace the old viewpoint with the new one. If false, increase/decrease it.
3957
 
        @return: -1 in case of error, 0 otherwise @note the values are set asynchronously, it will be used by the next frame displayed.
3958
 
        @version: LibVLC 3.0.0 and later.
3959
 
        '''
3960
 
        return libvlc_video_update_viewpoint(self, p_viewpoint, b_absolute)
3961
 
 
3962
 
    def video_get_spu(self):
3963
 
        '''Get current video subtitle.
3964
 
        @return: the video subtitle selected, or -1 if none.
3965
 
        '''
3966
 
        return libvlc_video_get_spu(self)
3967
 
 
3968
 
    def video_get_spu_count(self):
3969
 
        '''Get the number of available video subtitles.
3970
 
        @return: the number of available video subtitles.
3971
 
        '''
3972
 
        return libvlc_video_get_spu_count(self)
3973
 
 
3974
 
    def video_set_spu(self, i_spu):
3975
 
        '''Set new video subtitle.
3976
 
        @param i_spu: video subtitle track to select (i_id from track description).
3977
 
        @return: 0 on success, -1 if out of range.
3978
 
        '''
3979
 
        return libvlc_video_set_spu(self, i_spu)
3980
 
 
3981
 
    def video_get_spu_delay(self):
3982
 
        '''Get the current subtitle delay. Positive values means subtitles are being
3983
 
        displayed later, negative values earlier.
3984
 
        @return: time (in microseconds) the display of subtitles is being delayed.
3985
 
        @version: LibVLC 2.0.0 or later.
3986
 
        '''
3987
 
        return libvlc_video_get_spu_delay(self)
3988
 
 
3989
 
    def video_set_spu_delay(self, i_delay):
3990
 
        '''Set the subtitle delay. This affects the timing of when the subtitle will
3991
 
        be displayed. Positive values result in subtitles being displayed later,
3992
 
        while negative values will result in subtitles being displayed earlier.
3993
 
        The subtitle delay will be reset to zero each time the media changes.
3994
 
        @param i_delay: time (in microseconds) the display of subtitles should be delayed.
3995
 
        @return: 0 on success, -1 on error.
3996
 
        @version: LibVLC 2.0.0 or later.
3997
 
        '''
3998
 
        return libvlc_video_set_spu_delay(self, i_delay)
3999
 
 
4000
 
    def video_get_crop_geometry(self):
4001
 
        '''Get current crop filter geometry.
4002
 
        @return: the crop filter geometry or None if unset.
4003
 
        '''
4004
 
        return libvlc_video_get_crop_geometry(self)
4005
 
 
4006
 
    def video_set_crop_geometry(self, psz_geometry):
4007
 
        '''Set new crop filter geometry.
4008
 
        @param psz_geometry: new crop filter geometry (None to unset).
4009
 
        '''
4010
 
        return libvlc_video_set_crop_geometry(self, str_to_bytes(psz_geometry))
4011
 
 
4012
 
    def video_get_teletext(self):
4013
 
        '''Get current teletext page requested or 0 if it's disabled.
4014
 
        Teletext is disabled by default, call L{video_set_teletext}() to enable
4015
 
        it.
4016
 
        @return: the current teletext page requested.
4017
 
        '''
4018
 
        return libvlc_video_get_teletext(self)
4019
 
 
4020
 
    def video_set_teletext(self, i_page):
4021
 
        '''Set new teletext page to retrieve.
4022
 
        This function can also be used to send a teletext key.
4023
 
        @param i_page: teletex page number requested. This value can be 0 to disable teletext, a number in the range ]0;1000[ to show the requested page, or a \ref L{TeletextKey}. 100 is the default teletext page.
4024
 
        '''
4025
 
        return libvlc_video_set_teletext(self, i_page)
4026
 
 
4027
 
    def video_get_track_count(self):
4028
 
        '''Get number of available video tracks.
4029
 
        @return: the number of available video tracks (int).
4030
 
        '''
4031
 
        return libvlc_video_get_track_count(self)
4032
 
 
4033
 
    def video_get_track(self):
4034
 
        '''Get current video track.
4035
 
        @return: the video track ID (int) or -1 if no active input.
4036
 
        '''
4037
 
        return libvlc_video_get_track(self)
4038
 
 
4039
 
    def video_set_track(self, i_track):
4040
 
        '''Set video track.
4041
 
        @param i_track: the track ID (i_id field from track description).
4042
 
        @return: 0 on success, -1 if out of range.
4043
 
        '''
4044
 
        return libvlc_video_set_track(self, i_track)
4045
 
 
4046
 
    def video_take_snapshot(self, num, psz_filepath, i_width, i_height):
4047
 
        '''Take a snapshot of the current video window.
4048
 
        If i_width AND i_height is 0, original size is used.
4049
 
        If i_width XOR i_height is 0, original aspect-ratio is preserved.
4050
 
        @param num: number of video output (typically 0 for the first/only one).
4051
 
        @param psz_filepath: the path of a file or a folder to save the screenshot into.
4052
 
        @param i_width: the snapshot's width.
4053
 
        @param i_height: the snapshot's height.
4054
 
        @return: 0 on success, -1 if the video was not found.
4055
 
        '''
4056
 
        return libvlc_video_take_snapshot(self, num, str_to_bytes(psz_filepath), i_width, i_height)
4057
 
 
4058
 
    def video_set_deinterlace(self, psz_mode):
4059
 
        '''Enable or disable deinterlace filter.
4060
 
        @param psz_mode: type of deinterlace filter, None to disable.
4061
 
        '''
4062
 
        return libvlc_video_set_deinterlace(self, str_to_bytes(psz_mode))
4063
 
 
4064
 
    def video_get_marquee_int(self, option):
4065
 
        '''Get an integer marquee option value.
4066
 
        @param option: marq option to get See libvlc_video_marquee_int_option_t.
4067
 
        '''
4068
 
        return libvlc_video_get_marquee_int(self, option)
4069
 
 
4070
 
    def video_get_marquee_string(self, option):
4071
 
        '''Get a string marquee option value.
4072
 
        @param option: marq option to get See libvlc_video_marquee_string_option_t.
4073
 
        '''
4074
 
        return libvlc_video_get_marquee_string(self, option)
4075
 
 
4076
 
    def video_set_marquee_int(self, option, i_val):
4077
 
        '''Enable, disable or set an integer marquee option
4078
 
        Setting libvlc_marquee_Enable has the side effect of enabling (arg !0)
4079
 
        or disabling (arg 0) the marq filter.
4080
 
        @param option: marq option to set See libvlc_video_marquee_int_option_t.
4081
 
        @param i_val: marq option value.
4082
 
        '''
4083
 
        return libvlc_video_set_marquee_int(self, option, i_val)
4084
 
 
4085
 
    def video_set_marquee_string(self, option, psz_text):
4086
 
        '''Set a marquee string option.
4087
 
        @param option: marq option to set See libvlc_video_marquee_string_option_t.
4088
 
        @param psz_text: marq option value.
4089
 
        '''
4090
 
        return libvlc_video_set_marquee_string(self, option, str_to_bytes(psz_text))
4091
 
 
4092
 
    def video_get_logo_int(self, option):
4093
 
        '''Get integer logo option.
4094
 
        @param option: logo option to get, values of L{VideoLogoOption}.
4095
 
        '''
4096
 
        return libvlc_video_get_logo_int(self, option)
4097
 
 
4098
 
    def video_set_logo_int(self, option, value):
4099
 
        '''Set logo option as integer. Options that take a different type value
4100
 
        are ignored.
4101
 
        Passing libvlc_logo_enable as option value has the side effect of
4102
 
        starting (arg !0) or stopping (arg 0) the logo filter.
4103
 
        @param option: logo option to set, values of L{VideoLogoOption}.
4104
 
        @param value: logo option value.
4105
 
        '''
4106
 
        return libvlc_video_set_logo_int(self, option, value)
4107
 
 
4108
 
    def video_set_logo_string(self, option, psz_value):
4109
 
        '''Set logo option as string. Options that take a different type value
4110
 
        are ignored.
4111
 
        @param option: logo option to set, values of L{VideoLogoOption}.
4112
 
        @param psz_value: logo option value.
4113
 
        '''
4114
 
        return libvlc_video_set_logo_string(self, option, str_to_bytes(psz_value))
4115
 
 
4116
 
    def video_get_adjust_int(self, option):
4117
 
        '''Get integer adjust option.
4118
 
        @param option: adjust option to get, values of L{VideoAdjustOption}.
4119
 
        @version: LibVLC 1.1.1 and later.
4120
 
        '''
4121
 
        return libvlc_video_get_adjust_int(self, option)
4122
 
 
4123
 
    def video_set_adjust_int(self, option, value):
4124
 
        '''Set adjust option as integer. Options that take a different type value
4125
 
        are ignored.
4126
 
        Passing libvlc_adjust_enable as option value has the side effect of
4127
 
        starting (arg !0) or stopping (arg 0) the adjust filter.
4128
 
        @param option: adust option to set, values of L{VideoAdjustOption}.
4129
 
        @param value: adjust option value.
4130
 
        @version: LibVLC 1.1.1 and later.
4131
 
        '''
4132
 
        return libvlc_video_set_adjust_int(self, option, value)
4133
 
 
4134
 
    def video_get_adjust_float(self, option):
4135
 
        '''Get float adjust option.
4136
 
        @param option: adjust option to get, values of L{VideoAdjustOption}.
4137
 
        @version: LibVLC 1.1.1 and later.
4138
 
        '''
4139
 
        return libvlc_video_get_adjust_float(self, option)
4140
 
 
4141
 
    def video_set_adjust_float(self, option, value):
4142
 
        '''Set adjust option as float. Options that take a different type value
4143
 
        are ignored.
4144
 
        @param option: adust option to set, values of L{VideoAdjustOption}.
4145
 
        @param value: adjust option value.
4146
 
        @version: LibVLC 1.1.1 and later.
4147
 
        '''
4148
 
        return libvlc_video_set_adjust_float(self, option, value)
4149
 
 
4150
 
    def audio_output_set(self, psz_name):
4151
 
        '''Selects an audio output module.
4152
 
        @note: Any change will take be effect only after playback is stopped and
4153
 
        restarted. Audio output cannot be changed while playing.
4154
 
        @param psz_name: name of audio output, use psz_name of See L{AudioOutput}.
4155
 
        @return: 0 if function succeeded, -1 on error.
4156
 
        '''
4157
 
        return libvlc_audio_output_set(self, str_to_bytes(psz_name))
4158
 
 
4159
 
    def audio_output_device_enum(self):
4160
 
        '''Gets a list of potential audio output devices,
4161
 
        See L{audio_output_device_set}().
4162
 
        @note: Not all audio outputs support enumerating devices.
4163
 
        The audio output may be functional even if the list is empty (None).
4164
 
        @note: The list may not be exhaustive.
4165
 
        @warning: Some audio output devices in the list might not actually work in
4166
 
        some circumstances. By default, it is recommended to not specify any
4167
 
        explicit audio device.
4168
 
        @return: A None-terminated linked list of potential audio output devices. It must be freed with L{audio_output_device_list_release}().
4169
 
        @version: LibVLC 2.2.0 or later.
4170
 
        '''
4171
 
        return libvlc_audio_output_device_enum(self)
4172
 
 
4173
 
    def audio_output_device_set(self, module, device_id):
4174
 
        '''Configures an explicit audio output device.
4175
 
        If the module paramater is None, audio output will be moved to the device
4176
 
        specified by the device identifier string immediately. This is the
4177
 
        recommended usage.
4178
 
        A list of adequate potential device strings can be obtained with
4179
 
        L{audio_output_device_enum}().
4180
 
        However passing None is supported in LibVLC version 2.2.0 and later only;
4181
 
        in earlier versions, this function would have no effects when the module
4182
 
        parameter was None.
4183
 
        If the module parameter is not None, the device parameter of the
4184
 
        corresponding audio output, if it exists, will be set to the specified
4185
 
        string. Note that some audio output modules do not have such a parameter
4186
 
        (notably MMDevice and PulseAudio).
4187
 
        A list of adequate potential device strings can be obtained with
4188
 
        L{audio_output_device_list_get}().
4189
 
        @note: This function does not select the specified audio output plugin.
4190
 
        L{audio_output_set}() is used for that purpose.
4191
 
        @warning: The syntax for the device parameter depends on the audio output.
4192
 
        Some audio output modules require further parameters (e.g. a channels map
4193
 
        in the case of ALSA).
4194
 
        @param module: If None, current audio output module. if non-None, name of audio output module.
4195
 
        @param device_id: device identifier string.
4196
 
        @return: Nothing. Errors are ignored (this is a design bug).
4197
 
        '''
4198
 
        return libvlc_audio_output_device_set(self, str_to_bytes(module), str_to_bytes(device_id))
4199
 
 
4200
 
    def audio_output_device_get(self):
4201
 
        '''Get the current audio output device identifier.
4202
 
        This complements L{audio_output_device_set}().
4203
 
        @warning: The initial value for the current audio output device identifier
4204
 
        may not be set or may be some unknown value. A LibVLC application should
4205
 
        compare this value against the known device identifiers (e.g. those that
4206
 
        were previously retrieved by a call to L{audio_output_device_enum} or
4207
 
        L{audio_output_device_list_get}) to find the current audio output device.
4208
 
        It is possible that the selected audio output device changes (an external
4209
 
        change) without a call to L{audio_output_device_set}. That may make this
4210
 
        method unsuitable to use if a LibVLC application is attempting to track
4211
 
        dynamic audio device changes as they happen.
4212
 
        @return: the current audio output device identifier None if no device is selected or in case of error (the result must be released with free() or L{free}()).
4213
 
        @version: LibVLC 3.0.0 or later.
4214
 
        '''
4215
 
        return libvlc_audio_output_device_get(self)
4216
 
 
4217
 
    def audio_toggle_mute(self):
4218
 
        '''Toggle mute status.
4219
 
        '''
4220
 
        return libvlc_audio_toggle_mute(self)
4221
 
 
4222
 
    def audio_get_mute(self):
4223
 
        '''Get current mute status.
4224
 
        @return: the mute status (boolean) if defined, -1 if undefined/unapplicable.
4225
 
        '''
4226
 
        return libvlc_audio_get_mute(self)
4227
 
 
4228
 
    def audio_set_mute(self, status):
4229
 
        '''Set mute status.
4230
 
        @param status: If status is true then mute, otherwise unmute @warning This function does not always work. If there are no active audio playback stream, the mute status might not be available. If digital pass-through (S/PDIF, HDMI...) is in use, muting may be unapplicable. Also some audio output plugins do not support muting at all. @note To force silent playback, disable all audio tracks. This is more efficient and reliable than mute.
4231
 
        '''
4232
 
        return libvlc_audio_set_mute(self, status)
4233
 
 
4234
 
    def audio_get_volume(self):
4235
 
        '''Get current software audio volume.
4236
 
        @return: the software volume in percents (0 = mute, 100 = nominal / 0dB).
4237
 
        '''
4238
 
        return libvlc_audio_get_volume(self)
4239
 
 
4240
 
    def audio_set_volume(self, i_volume):
4241
 
        '''Set current software audio volume.
4242
 
        @param i_volume: the volume in percents (0 = mute, 100 = 0dB).
4243
 
        @return: 0 if the volume was set, -1 if it was out of range.
4244
 
        '''
4245
 
        return libvlc_audio_set_volume(self, i_volume)
4246
 
 
4247
 
    def audio_get_track_count(self):
4248
 
        '''Get number of available audio tracks.
4249
 
        @return: the number of available audio tracks (int), or -1 if unavailable.
4250
 
        '''
4251
 
        return libvlc_audio_get_track_count(self)
4252
 
 
4253
 
    def audio_get_track(self):
4254
 
        '''Get current audio track.
4255
 
        @return: the audio track ID or -1 if no active input.
4256
 
        '''
4257
 
        return libvlc_audio_get_track(self)
4258
 
 
4259
 
    def audio_set_track(self, i_track):
4260
 
        '''Set current audio track.
4261
 
        @param i_track: the track ID (i_id field from track description).
4262
 
        @return: 0 on success, -1 on error.
4263
 
        '''
4264
 
        return libvlc_audio_set_track(self, i_track)
4265
 
 
4266
 
    def audio_get_channel(self):
4267
 
        '''Get current audio channel.
4268
 
        @return: the audio channel See L{AudioOutputChannel}.
4269
 
        '''
4270
 
        return libvlc_audio_get_channel(self)
4271
 
 
4272
 
    def audio_set_channel(self, channel):
4273
 
        '''Set current audio channel.
4274
 
        @param channel: the audio channel, See L{AudioOutputChannel}.
4275
 
        @return: 0 on success, -1 on error.
4276
 
        '''
4277
 
        return libvlc_audio_set_channel(self, channel)
4278
 
 
4279
 
    def audio_get_delay(self):
4280
 
        '''Get current audio delay.
4281
 
        @return: the audio delay (microseconds).
4282
 
        @version: LibVLC 1.1.1 or later.
4283
 
        '''
4284
 
        return libvlc_audio_get_delay(self)
4285
 
 
4286
 
    def audio_set_delay(self, i_delay):
4287
 
        '''Set current audio delay. The audio delay will be reset to zero each time the media changes.
4288
 
        @param i_delay: the audio delay (microseconds).
4289
 
        @return: 0 on success, -1 on error.
4290
 
        @version: LibVLC 1.1.1 or later.
4291
 
        '''
4292
 
        return libvlc_audio_set_delay(self, i_delay)
4293
 
 
4294
 
    def set_equalizer(self, p_equalizer):
4295
 
        '''Apply new equalizer settings to a media player.
4296
 
        The equalizer is first created by invoking L{audio_equalizer_new}() or
4297
 
        L{audio_equalizer_new_from_preset}().
4298
 
        It is possible to apply new equalizer settings to a media player whether the media
4299
 
        player is currently playing media or not.
4300
 
        Invoking this method will immediately apply the new equalizer settings to the audio
4301
 
        output of the currently playing media if there is any.
4302
 
        If there is no currently playing media, the new equalizer settings will be applied
4303
 
        later if and when new media is played.
4304
 
        Equalizer settings will automatically be applied to subsequently played media.
4305
 
        To disable the equalizer for a media player invoke this method passing None for the
4306
 
        p_equalizer parameter.
4307
 
        The media player does not keep a reference to the supplied equalizer so it is safe
4308
 
        for an application to release the equalizer reference any time after this method
4309
 
        returns.
4310
 
        @param p_equalizer: opaque equalizer handle, or None to disable the equalizer for this media player.
4311
 
        @return: zero on success, -1 on error.
4312
 
        @version: LibVLC 2.2.0 or later.
4313
 
        '''
4314
 
        return libvlc_media_player_set_equalizer(self, p_equalizer)
4315
 
 
4316
 
    def get_role(self):
4317
 
        '''Gets the media role.
4318
 
        @return: the media player role (\ref libvlc_media_player_role_t).
4319
 
        @version: LibVLC 3.0.0 and later.
4320
 
        '''
4321
 
        return libvlc_media_player_get_role(self)
4322
 
 
4323
 
    def set_role(self, role):
4324
 
        '''Sets the media role.
4325
 
        @param role: the media player role (\ref libvlc_media_player_role_t).
4326
 
        @return: 0 on success, -1 on error.
4327
 
        '''
4328
 
        return libvlc_media_player_set_role(self, role)
4329
 
 
4330
 
 
4331
 
# LibVLC __version__ functions #
4332
 
 
4333
 
def libvlc_clearerr():
4334
 
    '''Clears the LibVLC error status for the current thread. This is optional.
4335
 
    By default, the error status is automatically overridden when a new error
4336
 
    occurs, and destroyed when the thread exits.
4337
 
    '''
4338
 
    f = _Cfunctions.get('libvlc_clearerr', None) or \
4339
 
        _Cfunction('libvlc_clearerr', (), None,
4340
 
                   None)
4341
 
    return f()
4342
 
 
4343
 
 
4344
 
def libvlc_vprinterr(fmt, ap):
4345
 
    '''Sets the LibVLC error status and message for the current thread.
4346
 
    Any previous error is overridden.
4347
 
    @param fmt: the format string.
4348
 
    @param ap: the arguments.
4349
 
    @return: a nul terminated string in any case.
4350
 
    '''
4351
 
    f = _Cfunctions.get('libvlc_vprinterr', None) or \
4352
 
        _Cfunction('libvlc_vprinterr', ((1,), (1,),), None,
4353
 
                   ctypes.c_char_p, ctypes.c_char_p, ctypes.c_void_p)
4354
 
    return f(fmt, ap)
4355
 
 
4356
 
 
4357
 
def libvlc_new(argc, argv):
4358
 
    '''Create and initialize a libvlc instance.
4359
 
    This functions accept a list of "command line" arguments similar to the
4360
 
    main(). These arguments affect the LibVLC instance default configuration.
4361
 
    @note
4362
 
    LibVLC may create threads. Therefore, any thread-unsafe process
4363
 
    initialization must be performed before calling L{libvlc_new}(). In particular
4364
 
    and where applicable:
4365
 
    - setlocale() and textdomain(),
4366
 
    - setenv(), unsetenv() and putenv(),
4367
 
    - with the X11 display system, XInitThreads()
4368
 
      (see also L{libvlc_media_player_set_xwindow}()) and
4369
 
    - on Microsoft Windows, SetErrorMode().
4370
 
    - sigprocmask() shall never be invoked; pthread_sigmask() can be used.
4371
 
    On POSIX systems, the SIGCHLD signal B{must not} be ignored, i.e. the
4372
 
    signal handler must set to SIG_DFL or a function pointer, not SIG_IGN.
4373
 
    Also while LibVLC is active, the wait() function shall not be called, and
4374
 
    any call to waitpid() shall use a strictly positive value for the first
4375
 
    parameter (i.e. the PID). Failure to follow those rules may lead to a
4376
 
    deadlock or a busy loop.
4377
 
    Also on POSIX systems, it is recommended that the SIGPIPE signal be blocked,
4378
 
    even if it is not, in principles, necessary, e.g.:
4379
 
    @code
4380
 
    @endcode
4381
 
    On Microsoft Windows Vista/2008, the process error mode
4382
 
    SEM_FAILCRITICALERRORS flag B{must} be set before using LibVLC.
4383
 
    On later versions, that is optional and unnecessary.
4384
 
    Also on Microsoft Windows (Vista and any later version), setting the default
4385
 
    DLL directories to SYSTEM32 exclusively is strongly recommended for
4386
 
    security reasons:
4387
 
    @code
4388
 
    @endcode.
4389
 
    @param argc: the number of arguments (should be 0).
4390
 
    @param argv: list of arguments (should be None).
4391
 
    @return: the libvlc instance or None in case of error.
4392
 
    @version Arguments are meant to be passed from the command line to LibVLC, just like VLC media player does. The list of valid arguments depends on the LibVLC version, the operating system and platform, and set of available LibVLC plugins. Invalid or unsupported arguments will cause the function to fail (i.e. return None). Also, some arguments may alter the behaviour or otherwise interfere with other LibVLC functions. @warning There is absolutely no warranty or promise of forward, backward and cross-platform compatibility with regards to L{libvlc_new}() arguments. We recommend that you do not use them, other than when debugging.
4393
 
    '''
4394
 
    f = _Cfunctions.get('libvlc_new', None) or \
4395
 
        _Cfunction('libvlc_new', ((1,), (1,),), class_result(Instance),
4396
 
                   ctypes.c_void_p, ctypes.c_int, ListPOINTER(ctypes.c_char_p))
4397
 
    return f(argc, argv)
4398
 
 
4399
 
 
4400
 
def libvlc_release(p_instance):
4401
 
    '''Decrement the reference count of a libvlc instance, and destroy it
4402
 
    if it reaches zero.
4403
 
    @param p_instance: the instance to destroy.
4404
 
    '''
4405
 
    f = _Cfunctions.get('libvlc_release', None) or \
4406
 
        _Cfunction('libvlc_release', ((1,),), None,
4407
 
                   None, Instance)
4408
 
    return f(p_instance)
4409
 
 
4410
 
 
4411
 
def libvlc_retain(p_instance):
4412
 
    '''Increments the reference count of a libvlc instance.
4413
 
    The initial reference count is 1 after L{libvlc_new}() returns.
4414
 
    @param p_instance: the instance to reference.
4415
 
    '''
4416
 
    f = _Cfunctions.get('libvlc_retain', None) or \
4417
 
        _Cfunction('libvlc_retain', ((1,),), None,
4418
 
                   None, Instance)
4419
 
    return f(p_instance)
4420
 
 
4421
 
 
4422
 
def libvlc_add_intf(p_instance, name):
4423
 
    '''Try to start a user interface for the libvlc instance.
4424
 
    @param p_instance: the instance.
4425
 
    @param name: interface name, or None for default.
4426
 
    @return: 0 on success, -1 on error.
4427
 
    '''
4428
 
    f = _Cfunctions.get('libvlc_add_intf', None) or \
4429
 
        _Cfunction('libvlc_add_intf', ((1,), (1,),), None,
4430
 
                   ctypes.c_int, Instance, ctypes.c_char_p)
4431
 
    return f(p_instance, name)
4432
 
 
4433
 
 
4434
 
def libvlc_set_user_agent(p_instance, name, http):
4435
 
    '''Sets the application name. LibVLC passes this as the user agent string
4436
 
    when a protocol requires it.
4437
 
    @param p_instance: LibVLC instance.
4438
 
    @param name: human-readable application name, e.g. "FooBar player 1.2.3".
4439
 
    @param http: HTTP User Agent, e.g. "FooBar/1.2.3 Python/2.6.0".
4440
 
    @version: LibVLC 1.1.1 or later.
4441
 
    '''
4442
 
    f = _Cfunctions.get('libvlc_set_user_agent', None) or \
4443
 
        _Cfunction('libvlc_set_user_agent', ((1,), (1,), (1,),), None,
4444
 
                   None, Instance, ctypes.c_char_p, ctypes.c_char_p)
4445
 
    return f(p_instance, name, http)
4446
 
 
4447
 
 
4448
 
def libvlc_set_app_id(p_instance, id, version, icon):
4449
 
    '''Sets some meta-information about the application.
4450
 
    See also L{libvlc_set_user_agent}().
4451
 
    @param p_instance: LibVLC instance.
4452
 
    @param id: Java-style application identifier, e.g. "com.acme.foobar".
4453
 
    @param version: application version numbers, e.g. "1.2.3".
4454
 
    @param icon: application icon name, e.g. "foobar".
4455
 
    @version: LibVLC 2.1.0 or later.
4456
 
    '''
4457
 
    f = _Cfunctions.get('libvlc_set_app_id', None) or \
4458
 
        _Cfunction('libvlc_set_app_id', ((1,), (1,), (1,), (1,),), None,
4459
 
                   None, Instance, ctypes.c_char_p, ctypes.c_char_p, ctypes.c_char_p)
4460
 
    return f(p_instance, id, version, icon)
4461
 
 
4462
 
 
4463
 
def libvlc_get_version():
4464
 
    '''Retrieve libvlc version.
4465
 
    Example: "1.1.0-git The Luggage".
4466
 
    @return: a string containing the libvlc version.
4467
 
    '''
4468
 
    f = _Cfunctions.get('libvlc_get_version', None) or \
4469
 
        _Cfunction('libvlc_get_version', (), None,
4470
 
                   ctypes.c_char_p)
4471
 
    return f()
4472
 
 
4473
 
 
4474
 
def libvlc_get_compiler():
4475
 
    '''Retrieve libvlc compiler version.
4476
 
    Example: "gcc version 4.2.3 (Ubuntu 4.2.3-2ubuntu6)".
4477
 
    @return: a string containing the libvlc compiler version.
4478
 
    '''
4479
 
    f = _Cfunctions.get('libvlc_get_compiler', None) or \
4480
 
        _Cfunction('libvlc_get_compiler', (), None,
4481
 
                   ctypes.c_char_p)
4482
 
    return f()
4483
 
 
4484
 
 
4485
 
def libvlc_get_changeset():
4486
 
    '''Retrieve libvlc changeset.
4487
 
    Example: "aa9bce0bc4".
4488
 
    @return: a string containing the libvlc changeset.
4489
 
    '''
4490
 
    f = _Cfunctions.get('libvlc_get_changeset', None) or \
4491
 
        _Cfunction('libvlc_get_changeset', (), None,
4492
 
                   ctypes.c_char_p)
4493
 
    return f()
4494
 
 
4495
 
 
4496
 
def libvlc_free(ptr):
4497
 
    '''Frees an heap allocation returned by a LibVLC function.
4498
 
    If you know you're using the same underlying C run-time as the LibVLC
4499
 
    implementation, then you can call ANSI C free() directly instead.
4500
 
    @param ptr: the pointer.
4501
 
    '''
4502
 
    f = _Cfunctions.get('libvlc_free', None) or \
4503
 
        _Cfunction('libvlc_free', ((1,),), None,
4504
 
                   None, ctypes.c_void_p)
4505
 
    return f(ptr)
4506
 
 
4507
 
 
4508
 
def libvlc_event_attach(p_event_manager, i_event_type, f_callback, user_data):
4509
 
    '''Register for an event notification.
4510
 
    @param p_event_manager: the event manager to which you want to attach to. Generally it is obtained by vlc_my_object_event_manager() where my_object is the object you want to listen to.
4511
 
    @param i_event_type: the desired event to which we want to listen.
4512
 
    @param f_callback: the function to call when i_event_type occurs.
4513
 
    @param user_data: user provided data to carry with the event.
4514
 
    @return: 0 on success, ENOMEM on error.
4515
 
    '''
4516
 
    f = _Cfunctions.get('libvlc_event_attach', None) or \
4517
 
        _Cfunction('libvlc_event_attach', ((1,), (1,), (1,), (1,),), None,
4518
 
                   ctypes.c_int, EventManager, ctypes.c_uint, Callback, ctypes.c_void_p)
4519
 
    return f(p_event_manager, i_event_type, f_callback, user_data)
4520
 
 
4521
 
 
4522
 
def libvlc_event_detach(p_event_manager, i_event_type, f_callback, p_user_data):
4523
 
    '''Unregister an event notification.
4524
 
    @param p_event_manager: the event manager.
4525
 
    @param i_event_type: the desired event to which we want to unregister.
4526
 
    @param f_callback: the function to call when i_event_type occurs.
4527
 
    @param p_user_data: user provided data to carry with the event.
4528
 
    '''
4529
 
    f = _Cfunctions.get('libvlc_event_detach', None) or \
4530
 
        _Cfunction('libvlc_event_detach', ((1,), (1,), (1,), (1,),), None,
4531
 
                   None, EventManager, ctypes.c_uint, Callback, ctypes.c_void_p)
4532
 
    return f(p_event_manager, i_event_type, f_callback, p_user_data)
4533
 
 
4534
 
 
4535
 
def libvlc_event_type_name(event_type):
4536
 
    '''Get an event's type name.
4537
 
    @param event_type: the desired event.
4538
 
    '''
4539
 
    f = _Cfunctions.get('libvlc_event_type_name', None) or \
4540
 
        _Cfunction('libvlc_event_type_name', ((1,),), None,
4541
 
                   ctypes.c_char_p, ctypes.c_uint)
4542
 
    return f(event_type)
4543
 
 
4544
 
 
4545
 
def libvlc_log_get_context(ctx):
4546
 
    '''Gets log message debug infos.
4547
 
    This function retrieves self-debug information about a log message:
4548
 
    - the name of the VLC module emitting the message,
4549
 
    - the name of the source code module (i.e. file) and
4550
 
    - the line number within the source code module.
4551
 
    The returned module name and file name will be None if unknown.
4552
 
    The returned line number will similarly be zero if unknown.
4553
 
    @param ctx: message context (as passed to the @ref libvlc_log_cb callback).
4554
 
    @return: module module name storage (or None), file source code file name storage (or None), line source code file line number storage (or None).
4555
 
    @version: LibVLC 2.1.0 or later.
4556
 
    '''
4557
 
    f = _Cfunctions.get('libvlc_log_get_context', None) or \
4558
 
        _Cfunction('libvlc_log_get_context', ((1,), (2,), (2,), (2,),), None,
4559
 
                   None, Log_ptr, ListPOINTER(ctypes.c_char_p), ListPOINTER(ctypes.c_char_p),
4560
 
                   ctypes.POINTER(ctypes.c_uint))
4561
 
    return f(ctx)
4562
 
 
4563
 
 
4564
 
def libvlc_log_get_object(ctx, id):
4565
 
    '''Gets log message info.
4566
 
    This function retrieves meta-information about a log message:
4567
 
    - the type name of the VLC object emitting the message,
4568
 
    - the object header if any, and
4569
 
    - a temporaly-unique object identifier.
4570
 
    This information is mainly meant for B{manual} troubleshooting.
4571
 
    The returned type name may be "generic" if unknown, but it cannot be None.
4572
 
    The returned header will be None if unset; in current versions, the header
4573
 
    is used to distinguish for VLM inputs.
4574
 
    The returned object ID will be zero if the message is not associated with
4575
 
    any VLC object.
4576
 
    @param ctx: message context (as passed to the @ref libvlc_log_cb callback).
4577
 
    @return: name object name storage (or None), header object header (or None), line source code file line number storage (or None).
4578
 
    @version: LibVLC 2.1.0 or later.
4579
 
    '''
4580
 
    f = _Cfunctions.get('libvlc_log_get_object', None) or \
4581
 
        _Cfunction('libvlc_log_get_object', ((1,), (2,), (2,), (1,),), None,
4582
 
                   None, Log_ptr, ListPOINTER(ctypes.c_char_p), ListPOINTER(ctypes.c_char_p),
4583
 
                   ctypes.POINTER(ctypes.c_uint))
4584
 
    return f(ctx, id)
4585
 
 
4586
 
 
4587
 
def libvlc_log_unset(p_instance):
4588
 
    '''Unsets the logging callback.
4589
 
    This function deregisters the logging callback for a LibVLC instance.
4590
 
    This is rarely needed as the callback is implicitly unset when the instance
4591
 
    is destroyed.
4592
 
    @note: This function will wait for any pending callbacks invocation to
4593
 
    complete (causing a deadlock if called from within the callback).
4594
 
    @param p_instance: libvlc instance.
4595
 
    @version: LibVLC 2.1.0 or later.
4596
 
    '''
4597
 
    f = _Cfunctions.get('libvlc_log_unset', None) or \
4598
 
        _Cfunction('libvlc_log_unset', ((1,),), None,
4599
 
                   None, Instance)
4600
 
    return f(p_instance)
4601
 
 
4602
 
 
4603
 
def libvlc_log_set(p_instance, cb, data):
4604
 
    '''Sets the logging callback for a LibVLC instance.
4605
 
    This function is thread-safe: it will wait for any pending callbacks
4606
 
    invocation to complete.
4607
 
    @param cb: callback function pointer.
4608
 
    @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.
4609
 
    @param p_instance: libvlc instance.
4610
 
    @version: LibVLC 2.1.0 or later.
4611
 
    '''
4612
 
    f = _Cfunctions.get('libvlc_log_set', None) or \
4613
 
        _Cfunction('libvlc_log_set', ((1,), (1,), (1,),), None,
4614
 
                   None, Instance, LogCb, ctypes.c_void_p)
4615
 
    return f(p_instance, cb, data)
4616
 
 
4617
 
 
4618
 
def libvlc_log_set_file(p_instance, stream):
4619
 
    '''Sets up logging to a file.
4620
 
    @param p_instance: libvlc instance.
4621
 
    @param stream: FILE pointer opened for writing (the FILE pointer must remain valid until L{libvlc_log_unset}()).
4622
 
    @version: LibVLC 2.1.0 or later.
4623
 
    '''
4624
 
    f = _Cfunctions.get('libvlc_log_set_file', None) or \
4625
 
        _Cfunction('libvlc_log_set_file', ((1,), (1,),), None,
4626
 
                   None, Instance, FILE_ptr)
4627
 
    return f(p_instance, stream)
4628
 
 
4629
 
 
4630
 
def libvlc_module_description_list_release(p_list):
4631
 
    '''Release a list of module descriptions.
4632
 
    @param p_list: the list to be released.
4633
 
    '''
4634
 
    f = _Cfunctions.get('libvlc_module_description_list_release', None) or \
4635
 
        _Cfunction('libvlc_module_description_list_release', ((1,),), None,
4636
 
                   None, ctypes.POINTER(ModuleDescription))
4637
 
    return f(p_list)
4638
 
 
4639
 
 
4640
 
def libvlc_audio_filter_list_get(p_instance):
4641
 
    '''Returns a list of audio filters that are available.
4642
 
    @param p_instance: libvlc instance.
4643
 
    @return: a list of module descriptions. It should be freed with L{libvlc_module_description_list_release}(). In case of an error, None is returned. See L{ModuleDescription} See L{libvlc_module_description_list_release}.
4644
 
    '''
4645
 
    f = _Cfunctions.get('libvlc_audio_filter_list_get', None) or \
4646
 
        _Cfunction('libvlc_audio_filter_list_get', ((1,),), None,
4647
 
                   ctypes.POINTER(ModuleDescription), Instance)
4648
 
    return f(p_instance)
4649
 
 
4650
 
 
4651
 
def libvlc_video_filter_list_get(p_instance):
4652
 
    '''Returns a list of video filters that are available.
4653
 
    @param p_instance: libvlc instance.
4654
 
    @return: a list of module descriptions. It should be freed with L{libvlc_module_description_list_release}(). In case of an error, None is returned. See L{ModuleDescription} See L{libvlc_module_description_list_release}.
4655
 
    '''
4656
 
    f = _Cfunctions.get('libvlc_video_filter_list_get', None) or \
4657
 
        _Cfunction('libvlc_video_filter_list_get', ((1,),), None,
4658
 
                   ctypes.POINTER(ModuleDescription), Instance)
4659
 
    return f(p_instance)
4660
 
 
4661
 
 
4662
 
def libvlc_clock():
4663
 
    '''Return the current time as defined by LibVLC. The unit is the microsecond.
4664
 
    Time increases monotonically (regardless of time zone changes and RTC
4665
 
    adjustements).
4666
 
    The origin is arbitrary but consistent across the whole system
4667
 
    (e.g. the system uptim, the time since the system was booted).
4668
 
    @note: On systems that support it, the POSIX monotonic clock is used.
4669
 
    '''
4670
 
    f = _Cfunctions.get('libvlc_clock', None) or \
4671
 
        _Cfunction('libvlc_clock', (), None,
4672
 
                   ctypes.c_int64)
4673
 
    return f()
4674
 
 
4675
 
 
4676
 
def libvlc_media_discoverer_new(p_inst, psz_name):
4677
 
    '''Create a media discoverer object by name.
4678
 
    After this object is created, you should attach to media_list events in
4679
 
    order to be notified of new items discovered.
4680
 
    You need to call L{libvlc_media_discoverer_start}() in order to start the
4681
 
    discovery.
4682
 
    See L{libvlc_media_discoverer_media_list}
4683
 
    See L{libvlc_media_discoverer_event_manager}
4684
 
    See L{libvlc_media_discoverer_start}.
4685
 
    @param p_inst: libvlc instance.
4686
 
    @param psz_name: service name; use L{libvlc_media_discoverer_list_get}() to get a list of the discoverer names available in this libVLC instance.
4687
 
    @return: media discover object or None in case of error.
4688
 
    @version: LibVLC 3.0.0 or later.
4689
 
    '''
4690
 
    f = _Cfunctions.get('libvlc_media_discoverer_new', None) or \
4691
 
        _Cfunction('libvlc_media_discoverer_new', ((1,), (1,),), class_result(MediaDiscoverer),
4692
 
                   ctypes.c_void_p, Instance, ctypes.c_char_p)
4693
 
    return f(p_inst, psz_name)
4694
 
 
4695
 
 
4696
 
def libvlc_media_discoverer_start(p_mdis):
4697
 
    '''Start media discovery.
4698
 
    To stop it, call L{libvlc_media_discoverer_stop}() or
4699
 
    L{libvlc_media_discoverer_list_release}() directly.
4700
 
    See L{libvlc_media_discoverer_stop}.
4701
 
    @param p_mdis: media discover object.
4702
 
    @return: -1 in case of error, 0 otherwise.
4703
 
    @version: LibVLC 3.0.0 or later.
4704
 
    '''
4705
 
    f = _Cfunctions.get('libvlc_media_discoverer_start', None) or \
4706
 
        _Cfunction('libvlc_media_discoverer_start', ((1,),), None,
4707
 
                   ctypes.c_int, MediaDiscoverer)
4708
 
    return f(p_mdis)
4709
 
 
4710
 
 
4711
 
def libvlc_media_discoverer_stop(p_mdis):
4712
 
    '''Stop media discovery.
4713
 
    See L{libvlc_media_discoverer_start}.
4714
 
    @param p_mdis: media discover object.
4715
 
    @version: LibVLC 3.0.0 or later.
4716
 
    '''
4717
 
    f = _Cfunctions.get('libvlc_media_discoverer_stop', None) or \
4718
 
        _Cfunction('libvlc_media_discoverer_stop', ((1,),), None,
4719
 
                   None, MediaDiscoverer)
4720
 
    return f(p_mdis)
4721
 
 
4722
 
 
4723
 
def libvlc_media_discoverer_release(p_mdis):
4724
 
    '''Release media discover object. If the reference count reaches 0, then
4725
 
    the object will be released.
4726
 
    @param p_mdis: media service discover object.
4727
 
    '''
4728
 
    f = _Cfunctions.get('libvlc_media_discoverer_release', None) or \
4729
 
        _Cfunction('libvlc_media_discoverer_release', ((1,),), None,
4730
 
                   None, MediaDiscoverer)
4731
 
    return f(p_mdis)
4732
 
 
4733
 
 
4734
 
def libvlc_media_discoverer_media_list(p_mdis):
4735
 
    '''Get media service discover media list.
4736
 
    @param p_mdis: media service discover object.
4737
 
    @return: list of media items.
4738
 
    '''
4739
 
    f = _Cfunctions.get('libvlc_media_discoverer_media_list', None) or \
4740
 
        _Cfunction('libvlc_media_discoverer_media_list', ((1,),), class_result(MediaList),
4741
 
                   ctypes.c_void_p, MediaDiscoverer)
4742
 
    return f(p_mdis)
4743
 
 
4744
 
 
4745
 
def libvlc_media_discoverer_is_running(p_mdis):
4746
 
    '''Query if media service discover object is running.
4747
 
    @param p_mdis: media service discover object.
4748
 
    @return: true if running, false if not \libvlc_return_bool.
4749
 
    '''
4750
 
    f = _Cfunctions.get('libvlc_media_discoverer_is_running', None) or \
4751
 
        _Cfunction('libvlc_media_discoverer_is_running', ((1,),), None,
4752
 
                   ctypes.c_int, MediaDiscoverer)
4753
 
    return f(p_mdis)
4754
 
 
4755
 
 
4756
 
def libvlc_media_discoverer_list_get(p_inst, i_cat, ppp_services):
4757
 
    '''Get media discoverer services by category.
4758
 
    @param p_inst: libvlc instance.
4759
 
    @param i_cat: category of services to fetch.
4760
 
    @param ppp_services: address to store an allocated array of media discoverer services (must be freed with L{libvlc_media_discoverer_list_release}() by the caller) [OUT].
4761
 
    @return: the number of media discoverer services (0 on error).
4762
 
    @version: LibVLC 3.0.0 and later.
4763
 
    '''
4764
 
    f = _Cfunctions.get('libvlc_media_discoverer_list_get', None) or \
4765
 
        _Cfunction('libvlc_media_discoverer_list_get', ((1,), (1,), (1,),), None,
4766
 
                   ctypes.c_size_t, Instance, MediaDiscovererCategory,
4767
 
                   ctypes.POINTER(ctypes.POINTER(MediaDiscovererDescription)))
4768
 
    return f(p_inst, i_cat, ppp_services)
4769
 
 
4770
 
 
4771
 
def libvlc_media_discoverer_list_release(pp_services, i_count):
4772
 
    '''Release an array of media discoverer services.
4773
 
    @param pp_services: array to release.
4774
 
    @param i_count: number of elements in the array.
4775
 
    @version: LibVLC 3.0.0 and later. See L{libvlc_media_discoverer_list_get}().
4776
 
    '''
4777
 
    f = _Cfunctions.get('libvlc_media_discoverer_list_release', None) or \
4778
 
        _Cfunction('libvlc_media_discoverer_list_release', ((1,), (1,),), None,
4779
 
                   None, ctypes.POINTER(MediaDiscovererDescription), ctypes.c_size_t)
4780
 
    return f(pp_services, i_count)
4781
 
 
4782
 
 
4783
 
def libvlc_dialog_set_context(p_id, p_context):
4784
 
    '''Associate an opaque pointer with the dialog id.
4785
 
    @version: LibVLC 3.0.0 and later.
4786
 
    '''
4787
 
    f = _Cfunctions.get('libvlc_dialog_set_context', None) or \
4788
 
        _Cfunction('libvlc_dialog_set_context', ((1,), (1,),), None,
4789
 
                   None, ctypes.c_void_p, ctypes.c_void_p)
4790
 
    return f(p_id, p_context)
4791
 
 
4792
 
 
4793
 
def libvlc_dialog_get_context(p_id):
4794
 
    '''Return the opaque pointer associated with the dialog id.
4795
 
    @version: LibVLC 3.0.0 and later.
4796
 
    '''
4797
 
    f = _Cfunctions.get('libvlc_dialog_get_context', None) or \
4798
 
        _Cfunction('libvlc_dialog_get_context', ((1,),), None,
4799
 
                   ctypes.c_void_p, ctypes.c_void_p)
4800
 
    return f(p_id)
4801
 
 
4802
 
 
4803
 
def libvlc_dialog_post_login(p_id, psz_username, psz_password, b_store):
4804
 
    '''Post a login answer
4805
 
    After this call, p_id won't be valid anymore
4806
 
    See libvlc_dialog_cbs.pf_display_login.
4807
 
    @param p_id: id of the dialog.
4808
 
    @param psz_username: valid and non empty string.
4809
 
    @param psz_password: valid string (can be empty).
4810
 
    @param b_store: if true, store the credentials.
4811
 
    @return: 0 on success, or -1 on error.
4812
 
    @version: LibVLC 3.0.0 and later.
4813
 
    '''
4814
 
    f = _Cfunctions.get('libvlc_dialog_post_login', None) or \
4815
 
        _Cfunction('libvlc_dialog_post_login', ((1,), (1,), (1,), (1,),), None,
4816
 
                   ctypes.c_int, ctypes.c_void_p, ctypes.c_char_p, ctypes.c_char_p, ctypes.c_bool)
4817
 
    return f(p_id, psz_username, psz_password, b_store)
4818
 
 
4819
 
 
4820
 
def libvlc_dialog_post_action(p_id, i_action):
4821
 
    '''Post a question answer
4822
 
    After this call, p_id won't be valid anymore
4823
 
    See libvlc_dialog_cbs.pf_display_question.
4824
 
    @param p_id: id of the dialog.
4825
 
    @param i_action: 1 for action1, 2 for action2.
4826
 
    @return: 0 on success, or -1 on error.
4827
 
    @version: LibVLC 3.0.0 and later.
4828
 
    '''
4829
 
    f = _Cfunctions.get('libvlc_dialog_post_action', None) or \
4830
 
        _Cfunction('libvlc_dialog_post_action', ((1,), (1,),), None,
4831
 
                   ctypes.c_int, ctypes.c_void_p, ctypes.c_int)
4832
 
    return f(p_id, i_action)
4833
 
 
4834
 
 
4835
 
def libvlc_dialog_dismiss(p_id):
4836
 
    '''Dismiss a dialog
4837
 
    After this call, p_id won't be valid anymore
4838
 
    See libvlc_dialog_cbs.pf_cancel.
4839
 
    @param p_id: id of the dialog.
4840
 
    @return: 0 on success, or -1 on error.
4841
 
    @version: LibVLC 3.0.0 and later.
4842
 
    '''
4843
 
    f = _Cfunctions.get('libvlc_dialog_dismiss', None) or \
4844
 
        _Cfunction('libvlc_dialog_dismiss', ((1,),), None,
4845
 
                   ctypes.c_int, ctypes.c_void_p)
4846
 
    return f(p_id)
4847
 
 
4848
 
 
4849
 
def libvlc_media_library_new(p_instance):
4850
 
    '''Create an new Media Library object.
4851
 
    @param p_instance: the libvlc instance.
4852
 
    @return: a new object or None on error.
4853
 
    '''
4854
 
    f = _Cfunctions.get('libvlc_media_library_new', None) or \
4855
 
        _Cfunction('libvlc_media_library_new', ((1,),), class_result(MediaLibrary),
4856
 
                   ctypes.c_void_p, Instance)
4857
 
    return f(p_instance)
4858
 
 
4859
 
 
4860
 
def libvlc_media_library_release(p_mlib):
4861
 
    '''Release media library object. This functions decrements the
4862
 
    reference count of the media library object. If it reaches 0,
4863
 
    then the object will be released.
4864
 
    @param p_mlib: media library object.
4865
 
    '''
4866
 
    f = _Cfunctions.get('libvlc_media_library_release', None) or \
4867
 
        _Cfunction('libvlc_media_library_release', ((1,),), None,
4868
 
                   None, MediaLibrary)
4869
 
    return f(p_mlib)
4870
 
 
4871
 
 
4872
 
def libvlc_media_library_retain(p_mlib):
4873
 
    '''Retain a reference to a media library object. This function will
4874
 
    increment the reference counting for this object. Use
4875
 
    L{libvlc_media_library_release}() to decrement the reference count.
4876
 
    @param p_mlib: media library object.
4877
 
    '''
4878
 
    f = _Cfunctions.get('libvlc_media_library_retain', None) or \
4879
 
        _Cfunction('libvlc_media_library_retain', ((1,),), None,
4880
 
                   None, MediaLibrary)
4881
 
    return f(p_mlib)
4882
 
 
4883
 
 
4884
 
def libvlc_media_library_load(p_mlib):
4885
 
    '''Load media library.
4886
 
    @param p_mlib: media library object.
4887
 
    @return: 0 on success, -1 on error.
4888
 
    '''
4889
 
    f = _Cfunctions.get('libvlc_media_library_load', None) or \
4890
 
        _Cfunction('libvlc_media_library_load', ((1,),), None,
4891
 
                   ctypes.c_int, MediaLibrary)
4892
 
    return f(p_mlib)
4893
 
 
4894
 
 
4895
 
def libvlc_media_library_media_list(p_mlib):
4896
 
    '''Get media library subitems.
4897
 
    @param p_mlib: media library object.
4898
 
    @return: media list subitems.
4899
 
    '''
4900
 
    f = _Cfunctions.get('libvlc_media_library_media_list', None) or \
4901
 
        _Cfunction('libvlc_media_library_media_list', ((1,),), class_result(MediaList),
4902
 
                   ctypes.c_void_p, MediaLibrary)
4903
 
    return f(p_mlib)
4904
 
 
4905
 
 
4906
 
def libvlc_vlm_release(p_instance):
4907
 
    '''Release the vlm instance related to the given L{Instance}.
4908
 
    @param p_instance: the instance.
4909
 
    '''
4910
 
    f = _Cfunctions.get('libvlc_vlm_release', None) or \
4911
 
        _Cfunction('libvlc_vlm_release', ((1,),), None,
4912
 
                   None, Instance)
4913
 
    return f(p_instance)
4914
 
 
4915
 
 
4916
 
def libvlc_vlm_add_broadcast(p_instance, psz_name, psz_input, psz_output, i_options, ppsz_options, b_enabled, b_loop):
4917
 
    '''Add a broadcast, with one input.
4918
 
    @param p_instance: the instance.
4919
 
    @param psz_name: the name of the new broadcast.
4920
 
    @param psz_input: the input MRL.
4921
 
    @param psz_output: the output MRL (the parameter to the "sout" variable).
4922
 
    @param i_options: number of additional options.
4923
 
    @param ppsz_options: additional options.
4924
 
    @param b_enabled: boolean for enabling the new broadcast.
4925
 
    @param b_loop: Should this broadcast be played in loop ?
4926
 
    @return: 0 on success, -1 on error.
4927
 
    '''
4928
 
    f = _Cfunctions.get('libvlc_vlm_add_broadcast', None) or \
4929
 
        _Cfunction('libvlc_vlm_add_broadcast', ((1,), (1,), (1,), (1,), (1,), (1,), (1,), (1,),), None,
4930
 
                   ctypes.c_int, Instance, ctypes.c_char_p, ctypes.c_char_p, ctypes.c_char_p, ctypes.c_int,
4931
 
                   ListPOINTER(ctypes.c_char_p), ctypes.c_int, ctypes.c_int)
4932
 
    return f(p_instance, psz_name, psz_input, psz_output, i_options, ppsz_options, b_enabled, b_loop)
4933
 
 
4934
 
 
4935
 
def libvlc_vlm_add_vod(p_instance, psz_name, psz_input, i_options, ppsz_options, b_enabled, psz_mux):
4936
 
    '''Add a vod, with one input.
4937
 
    @param p_instance: the instance.
4938
 
    @param psz_name: the name of the new vod media.
4939
 
    @param psz_input: the input MRL.
4940
 
    @param i_options: number of additional options.
4941
 
    @param ppsz_options: additional options.
4942
 
    @param b_enabled: boolean for enabling the new vod.
4943
 
    @param psz_mux: the muxer of the vod media.
4944
 
    @return: 0 on success, -1 on error.
4945
 
    '''
4946
 
    f = _Cfunctions.get('libvlc_vlm_add_vod', None) or \
4947
 
        _Cfunction('libvlc_vlm_add_vod', ((1,), (1,), (1,), (1,), (1,), (1,), (1,),), None,
4948
 
                   ctypes.c_int, Instance, ctypes.c_char_p, ctypes.c_char_p, ctypes.c_int, ListPOINTER(ctypes.c_char_p),
4949
 
                   ctypes.c_int, ctypes.c_char_p)
4950
 
    return f(p_instance, psz_name, psz_input, i_options, ppsz_options, b_enabled, psz_mux)
4951
 
 
4952
 
 
4953
 
def libvlc_vlm_del_media(p_instance, psz_name):
4954
 
    '''Delete a media (VOD or broadcast).
4955
 
    @param p_instance: the instance.
4956
 
    @param psz_name: the media to delete.
4957
 
    @return: 0 on success, -1 on error.
4958
 
    '''
4959
 
    f = _Cfunctions.get('libvlc_vlm_del_media', None) or \
4960
 
        _Cfunction('libvlc_vlm_del_media', ((1,), (1,),), None,
4961
 
                   ctypes.c_int, Instance, ctypes.c_char_p)
4962
 
    return f(p_instance, psz_name)
4963
 
 
4964
 
 
4965
 
def libvlc_vlm_set_enabled(p_instance, psz_name, b_enabled):
4966
 
    '''Enable or disable a media (VOD or broadcast).
4967
 
    @param p_instance: the instance.
4968
 
    @param psz_name: the media to work on.
4969
 
    @param b_enabled: the new status.
4970
 
    @return: 0 on success, -1 on error.
4971
 
    '''
4972
 
    f = _Cfunctions.get('libvlc_vlm_set_enabled', None) or \
4973
 
        _Cfunction('libvlc_vlm_set_enabled', ((1,), (1,), (1,),), None,
4974
 
                   ctypes.c_int, Instance, ctypes.c_char_p, ctypes.c_int)
4975
 
    return f(p_instance, psz_name, b_enabled)
4976
 
 
4977
 
 
4978
 
def libvlc_vlm_set_output(p_instance, psz_name, psz_output):
4979
 
    '''Set the output for a media.
4980
 
    @param p_instance: the instance.
4981
 
    @param psz_name: the media to work on.
4982
 
    @param psz_output: the output MRL (the parameter to the "sout" variable).
4983
 
    @return: 0 on success, -1 on error.
4984
 
    '''
4985
 
    f = _Cfunctions.get('libvlc_vlm_set_output', None) or \
4986
 
        _Cfunction('libvlc_vlm_set_output', ((1,), (1,), (1,),), None,
4987
 
                   ctypes.c_int, Instance, ctypes.c_char_p, ctypes.c_char_p)
4988
 
    return f(p_instance, psz_name, psz_output)
4989
 
 
4990
 
 
4991
 
def libvlc_vlm_set_input(p_instance, psz_name, psz_input):
4992
 
    '''Set a media's input MRL. This will delete all existing inputs and
4993
 
    add the specified one.
4994
 
    @param p_instance: the instance.
4995
 
    @param psz_name: the media to work on.
4996
 
    @param psz_input: the input MRL.
4997
 
    @return: 0 on success, -1 on error.
4998
 
    '''
4999
 
    f = _Cfunctions.get('libvlc_vlm_set_input', None) or \
5000
 
        _Cfunction('libvlc_vlm_set_input', ((1,), (1,), (1,),), None,
5001
 
                   ctypes.c_int, Instance, ctypes.c_char_p, ctypes.c_char_p)
5002
 
    return f(p_instance, psz_name, psz_input)
5003
 
 
5004
 
 
5005
 
def libvlc_vlm_add_input(p_instance, psz_name, psz_input):
5006
 
    '''Add a media's input MRL. This will add the specified one.
5007
 
    @param p_instance: the instance.
5008
 
    @param psz_name: the media to work on.
5009
 
    @param psz_input: the input MRL.
5010
 
    @return: 0 on success, -1 on error.
5011
 
    '''
5012
 
    f = _Cfunctions.get('libvlc_vlm_add_input', None) or \
5013
 
        _Cfunction('libvlc_vlm_add_input', ((1,), (1,), (1,),), None,
5014
 
                   ctypes.c_int, Instance, ctypes.c_char_p, ctypes.c_char_p)
5015
 
    return f(p_instance, psz_name, psz_input)
5016
 
 
5017
 
 
5018
 
def libvlc_vlm_set_loop(p_instance, psz_name, b_loop):
5019
 
    '''Set a media's loop status.
5020
 
    @param p_instance: the instance.
5021
 
    @param psz_name: the media to work on.
5022
 
    @param b_loop: the new status.
5023
 
    @return: 0 on success, -1 on error.
5024
 
    '''
5025
 
    f = _Cfunctions.get('libvlc_vlm_set_loop', None) or \
5026
 
        _Cfunction('libvlc_vlm_set_loop', ((1,), (1,), (1,),), None,
5027
 
                   ctypes.c_int, Instance, ctypes.c_char_p, ctypes.c_int)
5028
 
    return f(p_instance, psz_name, b_loop)
5029
 
 
5030
 
 
5031
 
def libvlc_vlm_set_mux(p_instance, psz_name, psz_mux):
5032
 
    '''Set a media's vod muxer.
5033
 
    @param p_instance: the instance.
5034
 
    @param psz_name: the media to work on.
5035
 
    @param psz_mux: the new muxer.
5036
 
    @return: 0 on success, -1 on error.
5037
 
    '''
5038
 
    f = _Cfunctions.get('libvlc_vlm_set_mux', None) or \
5039
 
        _Cfunction('libvlc_vlm_set_mux', ((1,), (1,), (1,),), None,
5040
 
                   ctypes.c_int, Instance, ctypes.c_char_p, ctypes.c_char_p)
5041
 
    return f(p_instance, psz_name, psz_mux)
5042
 
 
5043
 
 
5044
 
def libvlc_vlm_change_media(p_instance, psz_name, psz_input, psz_output, i_options, ppsz_options, b_enabled, b_loop):
5045
 
    '''Edit the parameters of a media. This will delete all existing inputs and
5046
 
    add the specified one.
5047
 
    @param p_instance: the instance.
5048
 
    @param psz_name: the name of the new broadcast.
5049
 
    @param psz_input: the input MRL.
5050
 
    @param psz_output: the output MRL (the parameter to the "sout" variable).
5051
 
    @param i_options: number of additional options.
5052
 
    @param ppsz_options: additional options.
5053
 
    @param b_enabled: boolean for enabling the new broadcast.
5054
 
    @param b_loop: Should this broadcast be played in loop ?
5055
 
    @return: 0 on success, -1 on error.
5056
 
    '''
5057
 
    f = _Cfunctions.get('libvlc_vlm_change_media', None) or \
5058
 
        _Cfunction('libvlc_vlm_change_media', ((1,), (1,), (1,), (1,), (1,), (1,), (1,), (1,),), None,
5059
 
                   ctypes.c_int, Instance, ctypes.c_char_p, ctypes.c_char_p, ctypes.c_char_p, ctypes.c_int,
5060
 
                   ListPOINTER(ctypes.c_char_p), ctypes.c_int, ctypes.c_int)
5061
 
    return f(p_instance, psz_name, psz_input, psz_output, i_options, ppsz_options, b_enabled, b_loop)
5062
 
 
5063
 
 
5064
 
def libvlc_vlm_play_media(p_instance, psz_name):
5065
 
    '''Play the named broadcast.
5066
 
    @param p_instance: the instance.
5067
 
    @param psz_name: the name of the broadcast.
5068
 
    @return: 0 on success, -1 on error.
5069
 
    '''
5070
 
    f = _Cfunctions.get('libvlc_vlm_play_media', None) or \
5071
 
        _Cfunction('libvlc_vlm_play_media', ((1,), (1,),), None,
5072
 
                   ctypes.c_int, Instance, ctypes.c_char_p)
5073
 
    return f(p_instance, psz_name)
5074
 
 
5075
 
 
5076
 
def libvlc_vlm_stop_media(p_instance, psz_name):
5077
 
    '''Stop the named broadcast.
5078
 
    @param p_instance: the instance.
5079
 
    @param psz_name: the name of the broadcast.
5080
 
    @return: 0 on success, -1 on error.
5081
 
    '''
5082
 
    f = _Cfunctions.get('libvlc_vlm_stop_media', None) or \
5083
 
        _Cfunction('libvlc_vlm_stop_media', ((1,), (1,),), None,
5084
 
                   ctypes.c_int, Instance, ctypes.c_char_p)
5085
 
    return f(p_instance, psz_name)
5086
 
 
5087
 
 
5088
 
def libvlc_vlm_pause_media(p_instance, psz_name):
5089
 
    '''Pause the named broadcast.
5090
 
    @param p_instance: the instance.
5091
 
    @param psz_name: the name of the broadcast.
5092
 
    @return: 0 on success, -1 on error.
5093
 
    '''
5094
 
    f = _Cfunctions.get('libvlc_vlm_pause_media', None) or \
5095
 
        _Cfunction('libvlc_vlm_pause_media', ((1,), (1,),), None,
5096
 
                   ctypes.c_int, Instance, ctypes.c_char_p)
5097
 
    return f(p_instance, psz_name)
5098
 
 
5099
 
 
5100
 
def libvlc_vlm_seek_media(p_instance, psz_name, f_percentage):
5101
 
    '''Seek in the named broadcast.
5102
 
    @param p_instance: the instance.
5103
 
    @param psz_name: the name of the broadcast.
5104
 
    @param f_percentage: the percentage to seek to.
5105
 
    @return: 0 on success, -1 on error.
5106
 
    '''
5107
 
    f = _Cfunctions.get('libvlc_vlm_seek_media', None) or \
5108
 
        _Cfunction('libvlc_vlm_seek_media', ((1,), (1,), (1,),), None,
5109
 
                   ctypes.c_int, Instance, ctypes.c_char_p, ctypes.c_float)
5110
 
    return f(p_instance, psz_name, f_percentage)
5111
 
 
5112
 
 
5113
 
def libvlc_vlm_show_media(p_instance, psz_name):
5114
 
    '''Return information about the named media as a JSON
5115
 
    string representation.
5116
 
    This function is mainly intended for debugging use,
5117
 
    if you want programmatic access to the state of
5118
 
    a vlm_media_instance_t, please use the corresponding
5119
 
    libvlc_vlm_get_media_instance_xxx -functions.
5120
 
    Currently there are no such functions available for
5121
 
    vlm_media_t though.
5122
 
    @param p_instance: the instance.
5123
 
    @param psz_name: the name of the media, if the name is an empty string, all media is described.
5124
 
    @return: string with information about named media, or None on error.
5125
 
    '''
5126
 
    f = _Cfunctions.get('libvlc_vlm_show_media', None) or \
5127
 
        _Cfunction('libvlc_vlm_show_media', ((1,), (1,),), string_result,
5128
 
                   ctypes.c_void_p, Instance, ctypes.c_char_p)
5129
 
    return f(p_instance, psz_name)
5130
 
 
5131
 
 
5132
 
def libvlc_vlm_get_media_instance_position(p_instance, psz_name, i_instance):
5133
 
    '''Get vlm_media instance position by name or instance id.
5134
 
    @param p_instance: a libvlc instance.
5135
 
    @param psz_name: name of vlm media instance.
5136
 
    @param i_instance: instance id.
5137
 
    @return: position as float or -1. on error.
5138
 
    '''
5139
 
    f = _Cfunctions.get('libvlc_vlm_get_media_instance_position', None) or \
5140
 
        _Cfunction('libvlc_vlm_get_media_instance_position', ((1,), (1,), (1,),), None,
5141
 
                   ctypes.c_float, Instance, ctypes.c_char_p, ctypes.c_int)
5142
 
    return f(p_instance, psz_name, i_instance)
5143
 
 
5144
 
 
5145
 
def libvlc_vlm_get_media_instance_time(p_instance, psz_name, i_instance):
5146
 
    '''Get vlm_media instance time by name or instance id.
5147
 
    @param p_instance: a libvlc instance.
5148
 
    @param psz_name: name of vlm media instance.
5149
 
    @param i_instance: instance id.
5150
 
    @return: time as integer or -1 on error.
5151
 
    '''
5152
 
    f = _Cfunctions.get('libvlc_vlm_get_media_instance_time', None) or \
5153
 
        _Cfunction('libvlc_vlm_get_media_instance_time', ((1,), (1,), (1,),), None,
5154
 
                   ctypes.c_int, Instance, ctypes.c_char_p, ctypes.c_int)
5155
 
    return f(p_instance, psz_name, i_instance)
5156
 
 
5157
 
 
5158
 
def libvlc_vlm_get_media_instance_length(p_instance, psz_name, i_instance):
5159
 
    '''Get vlm_media instance length by name or instance id.
5160
 
    @param p_instance: a libvlc instance.
5161
 
    @param psz_name: name of vlm media instance.
5162
 
    @param i_instance: instance id.
5163
 
    @return: length of media item or -1 on error.
5164
 
    '''
5165
 
    f = _Cfunctions.get('libvlc_vlm_get_media_instance_length', None) or \
5166
 
        _Cfunction('libvlc_vlm_get_media_instance_length', ((1,), (1,), (1,),), None,
5167
 
                   ctypes.c_int, Instance, ctypes.c_char_p, ctypes.c_int)
5168
 
    return f(p_instance, psz_name, i_instance)
5169
 
 
5170
 
 
5171
 
def libvlc_vlm_get_media_instance_rate(p_instance, psz_name, i_instance):
5172
 
    '''Get vlm_media instance playback rate by name or instance id.
5173
 
    @param p_instance: a libvlc instance.
5174
 
    @param psz_name: name of vlm media instance.
5175
 
    @param i_instance: instance id.
5176
 
    @return: playback rate or -1 on error.
5177
 
    '''
5178
 
    f = _Cfunctions.get('libvlc_vlm_get_media_instance_rate', None) or \
5179
 
        _Cfunction('libvlc_vlm_get_media_instance_rate', ((1,), (1,), (1,),), None,
5180
 
                   ctypes.c_int, Instance, ctypes.c_char_p, ctypes.c_int)
5181
 
    return f(p_instance, psz_name, i_instance)
5182
 
 
5183
 
 
5184
 
def libvlc_vlm_get_media_instance_title(p_instance, psz_name, i_instance):
5185
 
    '''Get vlm_media instance title number by name or instance id.
5186
 
    @param p_instance: a libvlc instance.
5187
 
    @param psz_name: name of vlm media instance.
5188
 
    @param i_instance: instance id.
5189
 
    @return: title as number or -1 on error.
5190
 
    @bug: will always return 0.
5191
 
    '''
5192
 
    f = _Cfunctions.get('libvlc_vlm_get_media_instance_title', None) or \
5193
 
        _Cfunction('libvlc_vlm_get_media_instance_title', ((1,), (1,), (1,),), None,
5194
 
                   ctypes.c_int, Instance, ctypes.c_char_p, ctypes.c_int)
5195
 
    return f(p_instance, psz_name, i_instance)
5196
 
 
5197
 
 
5198
 
def libvlc_vlm_get_media_instance_chapter(p_instance, psz_name, i_instance):
5199
 
    '''Get vlm_media instance chapter number by name or instance id.
5200
 
    @param p_instance: a libvlc instance.
5201
 
    @param psz_name: name of vlm media instance.
5202
 
    @param i_instance: instance id.
5203
 
    @return: chapter as number or -1 on error.
5204
 
    @bug: will always return 0.
5205
 
    '''
5206
 
    f = _Cfunctions.get('libvlc_vlm_get_media_instance_chapter', None) or \
5207
 
        _Cfunction('libvlc_vlm_get_media_instance_chapter', ((1,), (1,), (1,),), None,
5208
 
                   ctypes.c_int, Instance, ctypes.c_char_p, ctypes.c_int)
5209
 
    return f(p_instance, psz_name, i_instance)
5210
 
 
5211
 
 
5212
 
def libvlc_vlm_get_media_instance_seekable(p_instance, psz_name, i_instance):
5213
 
    '''Is libvlc instance seekable ?
5214
 
    @param p_instance: a libvlc instance.
5215
 
    @param psz_name: name of vlm media instance.
5216
 
    @param i_instance: instance id.
5217
 
    @return: 1 if seekable, 0 if not, -1 if media does not exist.
5218
 
    @bug: will always return 0.
5219
 
    '''
5220
 
    f = _Cfunctions.get('libvlc_vlm_get_media_instance_seekable', None) or \
5221
 
        _Cfunction('libvlc_vlm_get_media_instance_seekable', ((1,), (1,), (1,),), None,
5222
 
                   ctypes.c_int, Instance, ctypes.c_char_p, ctypes.c_int)
5223
 
    return f(p_instance, psz_name, i_instance)
5224
 
 
5225
 
 
5226
 
def libvlc_vlm_get_event_manager(p_instance):
5227
 
    '''Get libvlc_event_manager from a vlm media.
5228
 
    The p_event_manager is immutable, so you don't have to hold the lock.
5229
 
    @param p_instance: a libvlc instance.
5230
 
    @return: libvlc_event_manager.
5231
 
    '''
5232
 
    f = _Cfunctions.get('libvlc_vlm_get_event_manager', None) or \
5233
 
        _Cfunction('libvlc_vlm_get_event_manager', ((1,),), class_result(EventManager),
5234
 
                   ctypes.c_void_p, Instance)
5235
 
    return f(p_instance)
5236
 
 
5237
 
 
5238
 
def libvlc_media_new_location(p_instance, psz_mrl):
5239
 
    '''Create a media with a certain given media resource location,
5240
 
    for instance a valid URL.
5241
 
    @note: To refer to a local file with this function,
5242
 
    the file://... URI syntax B{must} be used (see IETF RFC3986).
5243
 
    We recommend using L{libvlc_media_new_path}() instead when dealing with
5244
 
    local files.
5245
 
    See L{libvlc_media_release}.
5246
 
    @param p_instance: the instance.
5247
 
    @param psz_mrl: the media location.
5248
 
    @return: the newly created media or None on error.
5249
 
    '''
5250
 
    f = _Cfunctions.get('libvlc_media_new_location', None) or \
5251
 
        _Cfunction('libvlc_media_new_location', ((1,), (1,),), class_result(Media),
5252
 
                   ctypes.c_void_p, Instance, ctypes.c_char_p)
5253
 
    return f(p_instance, psz_mrl)
5254
 
 
5255
 
 
5256
 
def libvlc_media_new_path(p_instance, path):
5257
 
    '''Create a media for a certain file path.
5258
 
    See L{libvlc_media_release}.
5259
 
    @param p_instance: the instance.
5260
 
    @param path: local filesystem path.
5261
 
    @return: the newly created media or None on error.
5262
 
    '''
5263
 
    f = _Cfunctions.get('libvlc_media_new_path', None) or \
5264
 
        _Cfunction('libvlc_media_new_path', ((1,), (1,),), class_result(Media),
5265
 
                   ctypes.c_void_p, Instance, ctypes.c_char_p)
5266
 
    return f(p_instance, path)
5267
 
 
5268
 
 
5269
 
def libvlc_media_new_fd(p_instance, fd):
5270
 
    '''Create a media for an already open file descriptor.
5271
 
    The file descriptor shall be open for reading (or reading and writing).
5272
 
    Regular file descriptors, pipe read descriptors and character device
5273
 
    descriptors (including TTYs) are supported on all platforms.
5274
 
    Block device descriptors are supported where available.
5275
 
    Directory descriptors are supported on systems that provide fdopendir().
5276
 
    Sockets are supported on all platforms where they are file descriptors,
5277
 
    i.e. all except Windows.
5278
 
    @note: This library will B{not} automatically close the file descriptor
5279
 
    under any circumstance. Nevertheless, a file descriptor can usually only be
5280
 
    rendered once in a media player. To render it a second time, the file
5281
 
    descriptor should probably be rewound to the beginning with lseek().
5282
 
    See L{libvlc_media_release}.
5283
 
    @param p_instance: the instance.
5284
 
    @param fd: open file descriptor.
5285
 
    @return: the newly created media or None on error.
5286
 
    @version: LibVLC 1.1.5 and later.
5287
 
    '''
5288
 
    f = _Cfunctions.get('libvlc_media_new_fd', None) or \
5289
 
        _Cfunction('libvlc_media_new_fd', ((1,), (1,),), class_result(Media),
5290
 
                   ctypes.c_void_p, Instance, ctypes.c_int)
5291
 
    return f(p_instance, fd)
5292
 
 
5293
 
 
5294
 
def libvlc_media_new_callbacks(instance, open_cb, read_cb, seek_cb, close_cb, opaque):
5295
 
    '''Create a media with custom callbacks to read the data from.
5296
 
    @param instance: LibVLC instance.
5297
 
    @param open_cb: callback to open the custom bitstream input media.
5298
 
    @param read_cb: callback to read data (must not be None).
5299
 
    @param seek_cb: callback to seek, or None if seeking is not supported.
5300
 
    @param close_cb: callback to close the media, or None if unnecessary.
5301
 
    @param opaque: data pointer for the open callback.
5302
 
    @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{libvlc_media_release}.
5303
 
    @version: LibVLC 3.0.0 and later.
5304
 
    '''
5305
 
    f = _Cfunctions.get('libvlc_media_new_callbacks', None) or \
5306
 
        _Cfunction('libvlc_media_new_callbacks', ((1,), (1,), (1,), (1,), (1,), (1,),), class_result(Media),
5307
 
                   ctypes.c_void_p, Instance, MediaOpenCb, MediaReadCb, MediaSeekCb, MediaCloseCb, ctypes.c_void_p)
5308
 
    return f(instance, open_cb, read_cb, seek_cb, close_cb, opaque)
5309
 
 
5310
 
 
5311
 
def libvlc_media_new_as_node(p_instance, psz_name):
5312
 
    '''Create a media as an empty node with a given name.
5313
 
    See L{libvlc_media_release}.
5314
 
    @param p_instance: the instance.
5315
 
    @param psz_name: the name of the node.
5316
 
    @return: the new empty media or None on error.
5317
 
    '''
5318
 
    f = _Cfunctions.get('libvlc_media_new_as_node', None) or \
5319
 
        _Cfunction('libvlc_media_new_as_node', ((1,), (1,),), class_result(Media),
5320
 
                   ctypes.c_void_p, Instance, ctypes.c_char_p)
5321
 
    return f(p_instance, psz_name)
5322
 
 
5323
 
 
5324
 
def libvlc_media_add_option(p_md, psz_options):
5325
 
    '''Add an option to the media.
5326
 
    This option will be used to determine how the media_player will
5327
 
    read the media. This allows to use VLC's advanced
5328
 
    reading/streaming options on a per-media basis.
5329
 
    @note: The options are listed in 'vlc --long-help' from the command line,
5330
 
    e.g. "-sout-all". Keep in mind that available options and their semantics
5331
 
    vary across LibVLC versions and builds.
5332
 
    @warning: Not all options affects L{Media} objects:
5333
 
    Specifically, due to architectural issues most audio and video options,
5334
 
    such as text renderer options, have no effects on an individual media.
5335
 
    These options must be set through L{libvlc_new}() instead.
5336
 
    @param p_md: the media descriptor.
5337
 
    @param psz_options: the options (as a string).
5338
 
    '''
5339
 
    f = _Cfunctions.get('libvlc_media_add_option', None) or \
5340
 
        _Cfunction('libvlc_media_add_option', ((1,), (1,),), None,
5341
 
                   None, Media, ctypes.c_char_p)
5342
 
    return f(p_md, psz_options)
5343
 
 
5344
 
 
5345
 
def libvlc_media_add_option_flag(p_md, psz_options, i_flags):
5346
 
    '''Add an option to the media with configurable flags.
5347
 
    This option will be used to determine how the media_player will
5348
 
    read the media. This allows to use VLC's advanced
5349
 
    reading/streaming options on a per-media basis.
5350
 
    The options are detailed in vlc --long-help, for instance
5351
 
    "--sout-all". Note that all options are not usable on medias:
5352
 
    specifically, due to architectural issues, video-related options
5353
 
    such as text renderer options cannot be set on a single media. They
5354
 
    must be set on the whole libvlc instance instead.
5355
 
    @param p_md: the media descriptor.
5356
 
    @param psz_options: the options (as a string).
5357
 
    @param i_flags: the flags for this option.
5358
 
    '''
5359
 
    f = _Cfunctions.get('libvlc_media_add_option_flag', None) or \
5360
 
        _Cfunction('libvlc_media_add_option_flag', ((1,), (1,), (1,),), None,
5361
 
                   None, Media, ctypes.c_char_p, ctypes.c_uint)
5362
 
    return f(p_md, psz_options, i_flags)
5363
 
 
5364
 
 
5365
 
def libvlc_media_retain(p_md):
5366
 
    '''Retain a reference to a media descriptor object (L{Media}). Use
5367
 
    L{libvlc_media_release}() to decrement the reference count of a
5368
 
    media descriptor object.
5369
 
    @param p_md: the media descriptor.
5370
 
    '''
5371
 
    f = _Cfunctions.get('libvlc_media_retain', None) or \
5372
 
        _Cfunction('libvlc_media_retain', ((1,),), None,
5373
 
                   None, Media)
5374
 
    return f(p_md)
5375
 
 
5376
 
 
5377
 
def libvlc_media_release(p_md):
5378
 
    '''Decrement the reference count of a media descriptor object. If the
5379
 
    reference count is 0, then L{libvlc_media_release}() will release the
5380
 
    media descriptor object. It will send out an libvlc_MediaFreed event
5381
 
    to all listeners. If the media descriptor object has been released it
5382
 
    should not be used again.
5383
 
    @param p_md: the media descriptor.
5384
 
    '''
5385
 
    f = _Cfunctions.get('libvlc_media_release', None) or \
5386
 
        _Cfunction('libvlc_media_release', ((1,),), None,
5387
 
                   None, Media)
5388
 
    return f(p_md)
5389
 
 
5390
 
 
5391
 
def libvlc_media_get_mrl(p_md):
5392
 
    '''Get the media resource locator (mrl) from a media descriptor object.
5393
 
    @param p_md: a media descriptor object.
5394
 
    @return: string with mrl of media descriptor object.
5395
 
    '''
5396
 
    f = _Cfunctions.get('libvlc_media_get_mrl', None) or \
5397
 
        _Cfunction('libvlc_media_get_mrl', ((1,),), string_result,
5398
 
                   ctypes.c_void_p, Media)
5399
 
    return f(p_md)
5400
 
 
5401
 
 
5402
 
def libvlc_media_duplicate(p_md):
5403
 
    '''Duplicate a media descriptor object.
5404
 
    @param p_md: a media descriptor object.
5405
 
    '''
5406
 
    f = _Cfunctions.get('libvlc_media_duplicate', None) or \
5407
 
        _Cfunction('libvlc_media_duplicate', ((1,),), class_result(Media),
5408
 
                   ctypes.c_void_p, Media)
5409
 
    return f(p_md)
5410
 
 
5411
 
 
5412
 
def libvlc_media_get_meta(p_md, e_meta):
5413
 
    '''Read the meta of the media.
5414
 
    If the media has not yet been parsed this will return None.
5415
 
    See L{libvlc_media_parse}
5416
 
    See L{libvlc_media_parse_with_options}
5417
 
    See libvlc_MediaMetaChanged.
5418
 
    @param p_md: the media descriptor.
5419
 
    @param e_meta: the meta to read.
5420
 
    @return: the media's meta.
5421
 
    '''
5422
 
    f = _Cfunctions.get('libvlc_media_get_meta', None) or \
5423
 
        _Cfunction('libvlc_media_get_meta', ((1,), (1,),), string_result,
5424
 
                   ctypes.c_void_p, Media, Meta)
5425
 
    return f(p_md, e_meta)
5426
 
 
5427
 
 
5428
 
def libvlc_media_set_meta(p_md, e_meta, psz_value):
5429
 
    '''Set the meta of the media (this function will not save the meta, call
5430
 
    L{libvlc_media_save_meta} in order to save the meta).
5431
 
    @param p_md: the media descriptor.
5432
 
    @param e_meta: the meta to write.
5433
 
    @param psz_value: the media's meta.
5434
 
    '''
5435
 
    f = _Cfunctions.get('libvlc_media_set_meta', None) or \
5436
 
        _Cfunction('libvlc_media_set_meta', ((1,), (1,), (1,),), None,
5437
 
                   None, Media, Meta, ctypes.c_char_p)
5438
 
    return f(p_md, e_meta, psz_value)
5439
 
 
5440
 
 
5441
 
def libvlc_media_save_meta(p_md):
5442
 
    '''Save the meta previously set.
5443
 
    @param p_md: the media desriptor.
5444
 
    @return: true if the write operation was successful.
5445
 
    '''
5446
 
    f = _Cfunctions.get('libvlc_media_save_meta', None) or \
5447
 
        _Cfunction('libvlc_media_save_meta', ((1,),), None,
5448
 
                   ctypes.c_int, Media)
5449
 
    return f(p_md)
5450
 
 
5451
 
 
5452
 
def libvlc_media_get_state(p_md):
5453
 
    '''Get current state of media descriptor object. Possible media states are
5454
 
    libvlc_NothingSpecial=0, libvlc_Opening, libvlc_Playing, libvlc_Paused,
5455
 
    libvlc_Stopped, libvlc_Ended, libvlc_Error.
5456
 
    See L{State}.
5457
 
    @param p_md: a media descriptor object.
5458
 
    @return: state of media descriptor object.
5459
 
    '''
5460
 
    f = _Cfunctions.get('libvlc_media_get_state', None) or \
5461
 
        _Cfunction('libvlc_media_get_state', ((1,),), None,
5462
 
                   State, Media)
5463
 
    return f(p_md)
5464
 
 
5465
 
 
5466
 
def libvlc_media_get_stats(p_md, p_stats):
5467
 
    '''Get the current statistics about the media.
5468
 
    @param p_md:: media descriptor object.
5469
 
    @param p_stats:: structure that contain the statistics about the media (this structure must be allocated by the caller).
5470
 
    @return: true if the statistics are available, false otherwise \libvlc_return_bool.
5471
 
    '''
5472
 
    f = _Cfunctions.get('libvlc_media_get_stats', None) or \
5473
 
        _Cfunction('libvlc_media_get_stats', ((1,), (1,),), None,
5474
 
                   ctypes.c_int, Media, ctypes.POINTER(MediaStats))
5475
 
    return f(p_md, p_stats)
5476
 
 
5477
 
 
5478
 
def libvlc_media_subitems(p_md):
5479
 
    '''Get subitems of media descriptor object. This will increment
5480
 
    the reference count of supplied media descriptor object. Use
5481
 
    L{libvlc_media_list_release}() to decrement the reference counting.
5482
 
    @param p_md: media descriptor object.
5483
 
    @return: list of media descriptor subitems or None.
5484
 
    '''
5485
 
    f = _Cfunctions.get('libvlc_media_subitems', None) or \
5486
 
        _Cfunction('libvlc_media_subitems', ((1,),), class_result(MediaList),
5487
 
                   ctypes.c_void_p, Media)
5488
 
    return f(p_md)
5489
 
 
5490
 
 
5491
 
def libvlc_media_event_manager(p_md):
5492
 
    '''Get event manager from media descriptor object.
5493
 
    NOTE: this function doesn't increment reference counting.
5494
 
    @param p_md: a media descriptor object.
5495
 
    @return: event manager object.
5496
 
    '''
5497
 
    f = _Cfunctions.get('libvlc_media_event_manager', None) or \
5498
 
        _Cfunction('libvlc_media_event_manager', ((1,),), class_result(EventManager),
5499
 
                   ctypes.c_void_p, Media)
5500
 
    return f(p_md)
5501
 
 
5502
 
 
5503
 
def libvlc_media_get_duration(p_md):
5504
 
    '''Get duration (in ms) of media descriptor object item.
5505
 
    @param p_md: media descriptor object.
5506
 
    @return: duration of media item or -1 on error.
5507
 
    '''
5508
 
    f = _Cfunctions.get('libvlc_media_get_duration', None) or \
5509
 
        _Cfunction('libvlc_media_get_duration', ((1,),), None,
5510
 
                   ctypes.c_longlong, Media)
5511
 
    return f(p_md)
5512
 
 
5513
 
 
5514
 
def libvlc_media_parse_with_options(p_md, parse_flag, timeout):
5515
 
    '''Parse the media asynchronously with options.
5516
 
    This fetches (local or network) art, meta data and/or tracks information.
5517
 
    This method is the extended version of L{libvlc_media_parse_with_options}().
5518
 
    To track when this is over you can listen to libvlc_MediaParsedChanged
5519
 
    event. However if this functions returns an error, you will not receive any
5520
 
    events.
5521
 
    It uses a flag to specify parse options (see L{MediaParseFlag}). All
5522
 
    these flags can be combined. By default, media is parsed if it's a local
5523
 
    file.
5524
 
    @note: Parsing can be aborted with L{libvlc_media_parse_stop}().
5525
 
    See libvlc_MediaParsedChanged
5526
 
    See L{libvlc_media_get_meta}
5527
 
    See L{libvlc_media_tracks_get}
5528
 
    See L{libvlc_media_get_parsed_status}
5529
 
    See L{MediaParseFlag}.
5530
 
    @param p_md: media descriptor object.
5531
 
    @param parse_flag: parse options:
5532
 
    @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).
5533
 
    @return: -1 in case of error, 0 otherwise.
5534
 
    @version: LibVLC 3.0.0 or later.
5535
 
    '''
5536
 
    f = _Cfunctions.get('libvlc_media_parse_with_options', None) or \
5537
 
        _Cfunction('libvlc_media_parse_with_options', ((1,), (1,), (1,),), None,
5538
 
                   ctypes.c_int, Media, MediaParseFlag, ctypes.c_int)
5539
 
    return f(p_md, parse_flag, timeout)
5540
 
 
5541
 
 
5542
 
def libvlc_media_parse_stop(p_md):
5543
 
    '''Stop the parsing of the media
5544
 
    When the media parsing is stopped, the libvlc_MediaParsedChanged event will
5545
 
    be sent with the libvlc_media_parsed_status_timeout status.
5546
 
    See L{libvlc_media_parse_with_options}.
5547
 
    @param p_md: media descriptor object.
5548
 
    @version: LibVLC 3.0.0 or later.
5549
 
    '''
5550
 
    f = _Cfunctions.get('libvlc_media_parse_stop', None) or \
5551
 
        _Cfunction('libvlc_media_parse_stop', ((1,),), None,
5552
 
                   None, Media)
5553
 
    return f(p_md)
5554
 
 
5555
 
 
5556
 
def libvlc_media_get_parsed_status(p_md):
5557
 
    '''Get Parsed status for media descriptor object.
5558
 
    See libvlc_MediaParsedChanged
5559
 
    See L{MediaParsedStatus}.
5560
 
    @param p_md: media descriptor object.
5561
 
    @return: a value of the L{MediaParsedStatus} enum.
5562
 
    @version: LibVLC 3.0.0 or later.
5563
 
    '''
5564
 
    f = _Cfunctions.get('libvlc_media_get_parsed_status', None) or \
5565
 
        _Cfunction('libvlc_media_get_parsed_status', ((1,),), None,
5566
 
                   MediaParsedStatus, Media)
5567
 
    return f(p_md)
5568
 
 
5569
 
 
5570
 
def libvlc_media_set_user_data(p_md, p_new_user_data):
5571
 
    '''Sets media descriptor's user_data. user_data is specialized data
5572
 
    accessed by the host application, VLC.framework uses it as a pointer to
5573
 
    an native object that references a L{Media} pointer.
5574
 
    @param p_md: media descriptor object.
5575
 
    @param p_new_user_data: pointer to user data.
5576
 
    '''
5577
 
    f = _Cfunctions.get('libvlc_media_set_user_data', None) or \
5578
 
        _Cfunction('libvlc_media_set_user_data', ((1,), (1,),), None,
5579
 
                   None, Media, ctypes.c_void_p)
5580
 
    return f(p_md, p_new_user_data)
5581
 
 
5582
 
 
5583
 
def libvlc_media_get_user_data(p_md):
5584
 
    '''Get media descriptor's user_data. user_data is specialized data
5585
 
    accessed by the host application, VLC.framework uses it as a pointer to
5586
 
    an native object that references a L{Media} pointer.
5587
 
    @param p_md: media descriptor object.
5588
 
    '''
5589
 
    f = _Cfunctions.get('libvlc_media_get_user_data', None) or \
5590
 
        _Cfunction('libvlc_media_get_user_data', ((1,),), None,
5591
 
                   ctypes.c_void_p, Media)
5592
 
    return f(p_md)
5593
 
 
5594
 
 
5595
 
def libvlc_media_tracks_get(p_md, tracks):
5596
 
    '''Get media descriptor's elementary streams description
5597
 
    Note, you need to call L{libvlc_media_parse}() or play the media at least once
5598
 
    before calling this function.
5599
 
    Not doing this will result in an empty array.
5600
 
    @param p_md: media descriptor object.
5601
 
    @param tracks: address to store an allocated array of Elementary Streams descriptions (must be freed with L{libvlc_media_tracks_release}.
5602
 
    @return: the number of Elementary Streams (zero on error).
5603
 
    @version: LibVLC 2.1.0 and later.
5604
 
    '''
5605
 
    f = _Cfunctions.get('libvlc_media_tracks_get', None) or \
5606
 
        _Cfunction('libvlc_media_tracks_get', ((1,), (1,),), None,
5607
 
                   ctypes.c_uint, Media, ctypes.POINTER(ctypes.POINTER(MediaTrack)))
5608
 
    return f(p_md, tracks)
5609
 
 
5610
 
 
5611
 
def libvlc_media_get_codec_description(i_type, i_codec):
5612
 
    '''Get codec description from media elementary stream.
5613
 
    @param i_type: i_type from L{MediaTrack}.
5614
 
    @param i_codec: i_codec or i_original_fourcc from L{MediaTrack}.
5615
 
    @return: codec description.
5616
 
    @version: LibVLC 3.0.0 and later. See L{MediaTrack}.
5617
 
    '''
5618
 
    f = _Cfunctions.get('libvlc_media_get_codec_description', None) or \
5619
 
        _Cfunction('libvlc_media_get_codec_description', ((1,), (1,),), None,
5620
 
                   ctypes.c_char_p, TrackType, ctypes.c_uint32)
5621
 
    return f(i_type, i_codec)
5622
 
 
5623
 
 
5624
 
def libvlc_media_tracks_release(p_tracks, i_count):
5625
 
    '''Release media descriptor's elementary streams description array.
5626
 
    @param p_tracks: tracks info array to release.
5627
 
    @param i_count: number of elements in the array.
5628
 
    @version: LibVLC 2.1.0 and later.
5629
 
    '''
5630
 
    f = _Cfunctions.get('libvlc_media_tracks_release', None) or \
5631
 
        _Cfunction('libvlc_media_tracks_release', ((1,), (1,),), None,
5632
 
                   None, ctypes.POINTER(MediaTrack), ctypes.c_uint)
5633
 
    return f(p_tracks, i_count)
5634
 
 
5635
 
 
5636
 
def libvlc_media_get_type(p_md):
5637
 
    '''Get the media type of the media descriptor object.
5638
 
    @param p_md: media descriptor object.
5639
 
    @return: media type.
5640
 
    @version: LibVLC 3.0.0 and later. See L{MediaType}.
5641
 
    '''
5642
 
    f = _Cfunctions.get('libvlc_media_get_type', None) or \
5643
 
        _Cfunction('libvlc_media_get_type', ((1,),), None,
5644
 
                   MediaType, Media)
5645
 
    return f(p_md)
5646
 
 
5647
 
 
5648
 
def libvlc_media_slaves_add(p_md, i_type, i_priority, psz_uri):
5649
 
    '''Add a slave to the current media.
5650
 
    A slave is an external input source that may contains an additional subtitle
5651
 
    track (like a .srt) or an additional audio track (like a .ac3).
5652
 
    @note: This function must be called before the media is parsed (via
5653
 
    L{libvlc_media_parse_with_options}()) or before the media is played (via
5654
 
    L{libvlc_media_player_play}()).
5655
 
    @param p_md: media descriptor object.
5656
 
    @param i_type: subtitle or audio.
5657
 
    @param i_priority: from 0 (low priority) to 4 (high priority).
5658
 
    @param psz_uri: Uri of the slave (should contain a valid scheme).
5659
 
    @return: 0 on success, -1 on error.
5660
 
    @version: LibVLC 3.0.0 and later.
5661
 
    '''
5662
 
    f = _Cfunctions.get('libvlc_media_slaves_add', None) or \
5663
 
        _Cfunction('libvlc_media_slaves_add', ((1,), (1,), (1,), (1,),), None,
5664
 
                   ctypes.c_int, Media, MediaSlaveType, ctypes.c_int, ctypes.c_char_p)
5665
 
    return f(p_md, i_type, i_priority, psz_uri)
5666
 
 
5667
 
 
5668
 
def libvlc_media_slaves_clear(p_md):
5669
 
    '''Clear all slaves previously added by L{libvlc_media_slaves_add}() or
5670
 
    internally.
5671
 
    @param p_md: media descriptor object.
5672
 
    @version: LibVLC 3.0.0 and later.
5673
 
    '''
5674
 
    f = _Cfunctions.get('libvlc_media_slaves_clear', None) or \
5675
 
        _Cfunction('libvlc_media_slaves_clear', ((1,),), None,
5676
 
                   None, Media)
5677
 
    return f(p_md)
5678
 
 
5679
 
 
5680
 
def libvlc_media_slaves_get(p_md, ppp_slaves):
5681
 
    '''Get a media descriptor's slave list
5682
 
    The list will contain slaves parsed by VLC or previously added by
5683
 
    L{libvlc_media_slaves_add}(). The typical use case of this function is to save
5684
 
    a list of slave in a database for a later use.
5685
 
    @param p_md: media descriptor object.
5686
 
    @param ppp_slaves: address to store an allocated array of slaves (must be freed with L{libvlc_media_slaves_release}()) [OUT].
5687
 
    @return: the number of slaves (zero on error).
5688
 
    @version: LibVLC 3.0.0 and later. See L{libvlc_media_slaves_add}.
5689
 
    '''
5690
 
    f = _Cfunctions.get('libvlc_media_slaves_get', None) or \
5691
 
        _Cfunction('libvlc_media_slaves_get', ((1,), (1,),), None,
5692
 
                   ctypes.c_int, Media, ctypes.POINTER(ctypes.POINTER(MediaSlave)))
5693
 
    return f(p_md, ppp_slaves)
5694
 
 
5695
 
 
5696
 
def libvlc_media_slaves_release(pp_slaves, i_count):
5697
 
    '''Release a media descriptor's slave list.
5698
 
    @param pp_slaves: slave array to release.
5699
 
    @param i_count: number of elements in the array.
5700
 
    @version: LibVLC 3.0.0 and later.
5701
 
    '''
5702
 
    f = _Cfunctions.get('libvlc_media_slaves_release', None) or \
5703
 
        _Cfunction('libvlc_media_slaves_release', ((1,), (1,),), None,
5704
 
                   None, ctypes.POINTER(MediaSlave), ctypes.c_int)
5705
 
    return f(pp_slaves, i_count)
5706
 
 
5707
 
 
5708
 
def libvlc_renderer_item_hold(p_item):
5709
 
    '''Hold a renderer item, i.e. creates a new reference
5710
 
    This functions need to called from the libvlc_RendererDiscovererItemAdded
5711
 
    callback if the libvlc user wants to use this item after. (for display or
5712
 
    for passing it to the mediaplayer for example).
5713
 
    @return: the current item.
5714
 
    @version: LibVLC 3.0.0 or later.
5715
 
    '''
5716
 
    f = _Cfunctions.get('libvlc_renderer_item_hold', None) or \
5717
 
        _Cfunction('libvlc_renderer_item_hold', ((1,),), None,
5718
 
                   ctypes.c_void_p, ctypes.c_void_p)
5719
 
    return f(p_item)
5720
 
 
5721
 
 
5722
 
def libvlc_renderer_item_release(p_item):
5723
 
    '''Releases a renderer item, i.e. decrements its reference counter.
5724
 
    @version: LibVLC 3.0.0 or later.
5725
 
    '''
5726
 
    f = _Cfunctions.get('libvlc_renderer_item_release', None) or \
5727
 
        _Cfunction('libvlc_renderer_item_release', ((1,),), None,
5728
 
                   None, ctypes.c_void_p)
5729
 
    return f(p_item)
5730
 
 
5731
 
 
5732
 
def libvlc_renderer_item_name(p_item):
5733
 
    '''Get the human readable name of a renderer item.
5734
 
    @return: the name of the item (can't be None, must *not* be freed).
5735
 
    @version: LibVLC 3.0.0 or later.
5736
 
    '''
5737
 
    f = _Cfunctions.get('libvlc_renderer_item_name', None) or \
5738
 
        _Cfunction('libvlc_renderer_item_name', ((1,),), None,
5739
 
                   ctypes.c_char_p, ctypes.c_void_p)
5740
 
    return f(p_item)
5741
 
 
5742
 
 
5743
 
def libvlc_renderer_item_type(p_item):
5744
 
    '''Get the type (not translated) of a renderer item. For now, the type can only
5745
 
    be "chromecast" ("upnp", "airplay" may come later).
5746
 
    @return: the type of the item (can't be None, must *not* be freed).
5747
 
    @version: LibVLC 3.0.0 or later.
5748
 
    '''
5749
 
    f = _Cfunctions.get('libvlc_renderer_item_type', None) or \
5750
 
        _Cfunction('libvlc_renderer_item_type', ((1,),), None,
5751
 
                   ctypes.c_char_p, ctypes.c_void_p)
5752
 
    return f(p_item)
5753
 
 
5754
 
 
5755
 
def libvlc_renderer_item_icon_uri(p_item):
5756
 
    '''Get the icon uri of a renderer item.
5757
 
    @return: the uri of the item's icon (can be None, must *not* be freed).
5758
 
    @version: LibVLC 3.0.0 or later.
5759
 
    '''
5760
 
    f = _Cfunctions.get('libvlc_renderer_item_icon_uri', None) or \
5761
 
        _Cfunction('libvlc_renderer_item_icon_uri', ((1,),), None,
5762
 
                   ctypes.c_char_p, ctypes.c_void_p)
5763
 
    return f(p_item)
5764
 
 
5765
 
 
5766
 
def libvlc_renderer_item_flags(p_item):
5767
 
    '''Get the flags of a renderer item
5768
 
    See LIBVLC_RENDERER_CAN_AUDIO
5769
 
    See LIBVLC_RENDERER_CAN_VIDEO.
5770
 
    @return: bitwise flag: capabilities of the renderer, see.
5771
 
    @version: LibVLC 3.0.0 or later.
5772
 
    '''
5773
 
    f = _Cfunctions.get('libvlc_renderer_item_flags', None) or \
5774
 
        _Cfunction('libvlc_renderer_item_flags', ((1,),), None,
5775
 
                   ctypes.c_int, ctypes.c_void_p)
5776
 
    return f(p_item)
5777
 
 
5778
 
 
5779
 
def libvlc_renderer_discoverer_new(p_inst, psz_name):
5780
 
    '''Create a renderer discoverer object by name
5781
 
    After this object is created, you should attach to events in order to be
5782
 
    notified of the discoverer events.
5783
 
    You need to call L{libvlc_renderer_discoverer_start}() in order to start the
5784
 
    discovery.
5785
 
    See L{libvlc_renderer_discoverer_event_manager}()
5786
 
    See L{libvlc_renderer_discoverer_start}().
5787
 
    @param p_inst: libvlc instance.
5788
 
    @param psz_name: service name; use L{libvlc_renderer_discoverer_list_get}() to get a list of the discoverer names available in this libVLC instance.
5789
 
    @return: media discover object or None in case of error.
5790
 
    @version: LibVLC 3.0.0 or later.
5791
 
    '''
5792
 
    f = _Cfunctions.get('libvlc_renderer_discoverer_new', None) or \
5793
 
        _Cfunction('libvlc_renderer_discoverer_new', ((1,), (1,),), None,
5794
 
                   ctypes.c_void_p, Instance, ctypes.c_char_p)
5795
 
    return f(p_inst, psz_name)
5796
 
 
5797
 
 
5798
 
def libvlc_renderer_discoverer_release(p_rd):
5799
 
    '''Release a renderer discoverer object.
5800
 
    @param p_rd: renderer discoverer object.
5801
 
    @version: LibVLC 3.0.0 or later.
5802
 
    '''
5803
 
    f = _Cfunctions.get('libvlc_renderer_discoverer_release', None) or \
5804
 
        _Cfunction('libvlc_renderer_discoverer_release', ((1,),), None,
5805
 
                   None, ctypes.c_void_p)
5806
 
    return f(p_rd)
5807
 
 
5808
 
 
5809
 
def libvlc_renderer_discoverer_start(p_rd):
5810
 
    '''Start renderer discovery
5811
 
    To stop it, call L{libvlc_renderer_discoverer_stop}() or
5812
 
    L{libvlc_renderer_discoverer_release}() directly.
5813
 
    See L{libvlc_renderer_discoverer_stop}().
5814
 
    @param p_rd: renderer discoverer object.
5815
 
    @return: -1 in case of error, 0 otherwise.
5816
 
    @version: LibVLC 3.0.0 or later.
5817
 
    '''
5818
 
    f = _Cfunctions.get('libvlc_renderer_discoverer_start', None) or \
5819
 
        _Cfunction('libvlc_renderer_discoverer_start', ((1,),), None,
5820
 
                   ctypes.c_int, ctypes.c_void_p)
5821
 
    return f(p_rd)
5822
 
 
5823
 
 
5824
 
def libvlc_renderer_discoverer_stop(p_rd):
5825
 
    '''Stop renderer discovery.
5826
 
    See L{libvlc_renderer_discoverer_start}().
5827
 
    @param p_rd: renderer discoverer object.
5828
 
    @version: LibVLC 3.0.0 or later.
5829
 
    '''
5830
 
    f = _Cfunctions.get('libvlc_renderer_discoverer_stop', None) or \
5831
 
        _Cfunction('libvlc_renderer_discoverer_stop', ((1,),), None,
5832
 
                   None, ctypes.c_void_p)
5833
 
    return f(p_rd)
5834
 
 
5835
 
 
5836
 
def libvlc_renderer_discoverer_event_manager(p_rd):
5837
 
    '''Get the event manager of the renderer discoverer
5838
 
    The possible events to attach are @ref libvlc_RendererDiscovererItemAdded
5839
 
    and @ref libvlc_RendererDiscovererItemDeleted.
5840
 
    The @ref libvlc_renderer_item_t struct passed to event callbacks is owned by
5841
 
    VLC, users should take care of holding/releasing this struct for their
5842
 
    internal usage.
5843
 
    See libvlc_event_t.u.renderer_discoverer_item_added.item
5844
 
    See libvlc_event_t.u.renderer_discoverer_item_removed.item.
5845
 
    @return: a valid event manager (can't fail).
5846
 
    @version: LibVLC 3.0.0 or later.
5847
 
    '''
5848
 
    f = _Cfunctions.get('libvlc_renderer_discoverer_event_manager', None) or \
5849
 
        _Cfunction('libvlc_renderer_discoverer_event_manager', ((1,),), class_result(EventManager),
5850
 
                   ctypes.c_void_p, ctypes.c_void_p)
5851
 
    return f(p_rd)
5852
 
 
5853
 
 
5854
 
def libvlc_renderer_discoverer_list_get(p_inst, ppp_services):
5855
 
    '''Get media discoverer services
5856
 
    See libvlc_renderer_list_release().
5857
 
    @param p_inst: libvlc instance.
5858
 
    @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].
5859
 
    @return: the number of media discoverer services (0 on error).
5860
 
    @version: LibVLC 3.0.0 and later.
5861
 
    '''
5862
 
    f = _Cfunctions.get('libvlc_renderer_discoverer_list_get', None) or \
5863
 
        _Cfunction('libvlc_renderer_discoverer_list_get', ((1,), (1,),), None,
5864
 
                   ctypes.c_size_t, Instance, ctypes.POINTER(ctypes.POINTER(RDDescription)))
5865
 
    return f(p_inst, ppp_services)
5866
 
 
5867
 
 
5868
 
def libvlc_renderer_discoverer_list_release(pp_services, i_count):
5869
 
    '''Release an array of media discoverer services
5870
 
    See L{libvlc_renderer_discoverer_list_get}().
5871
 
    @param pp_services: array to release.
5872
 
    @param i_count: number of elements in the array.
5873
 
    @version: LibVLC 3.0.0 and later.
5874
 
    '''
5875
 
    f = _Cfunctions.get('libvlc_renderer_discoverer_list_release', None) or \
5876
 
        _Cfunction('libvlc_renderer_discoverer_list_release', ((1,), (1,),), None,
5877
 
                   None, ctypes.POINTER(RDDescription), ctypes.c_size_t)
5878
 
    return f(pp_services, i_count)
5879
 
 
5880
 
 
5881
 
def libvlc_media_list_new(p_instance):
5882
 
    '''Create an empty media list.
5883
 
    @param p_instance: libvlc instance.
5884
 
    @return: empty media list, or None on error.
5885
 
    '''
5886
 
    f = _Cfunctions.get('libvlc_media_list_new', None) or \
5887
 
        _Cfunction('libvlc_media_list_new', ((1,),), class_result(MediaList),
5888
 
                   ctypes.c_void_p, Instance)
5889
 
    return f(p_instance)
5890
 
 
5891
 
 
5892
 
def libvlc_media_list_release(p_ml):
5893
 
    '''Release media list created with L{libvlc_media_list_new}().
5894
 
    @param p_ml: a media list created with L{libvlc_media_list_new}().
5895
 
    '''
5896
 
    f = _Cfunctions.get('libvlc_media_list_release', None) or \
5897
 
        _Cfunction('libvlc_media_list_release', ((1,),), None,
5898
 
                   None, MediaList)
5899
 
    return f(p_ml)
5900
 
 
5901
 
 
5902
 
def libvlc_media_list_retain(p_ml):
5903
 
    '''Retain reference to a media list.
5904
 
    @param p_ml: a media list created with L{libvlc_media_list_new}().
5905
 
    '''
5906
 
    f = _Cfunctions.get('libvlc_media_list_retain', None) or \
5907
 
        _Cfunction('libvlc_media_list_retain', ((1,),), None,
5908
 
                   None, MediaList)
5909
 
    return f(p_ml)
5910
 
 
5911
 
 
5912
 
def libvlc_media_list_set_media(p_ml, p_md):
5913
 
    '''Associate media instance with this media list instance.
5914
 
    If another media instance was present it will be released.
5915
 
    The L{libvlc_media_list_lock} should NOT be held upon entering this function.
5916
 
    @param p_ml: a media list instance.
5917
 
    @param p_md: media instance to add.
5918
 
    '''
5919
 
    f = _Cfunctions.get('libvlc_media_list_set_media', None) or \
5920
 
        _Cfunction('libvlc_media_list_set_media', ((1,), (1,),), None,
5921
 
                   None, MediaList, Media)
5922
 
    return f(p_ml, p_md)
5923
 
 
5924
 
 
5925
 
def libvlc_media_list_media(p_ml):
5926
 
    '''Get media instance from this media list instance. This action will increase
5927
 
    the refcount on the media instance.
5928
 
    The L{libvlc_media_list_lock} should NOT be held upon entering this function.
5929
 
    @param p_ml: a media list instance.
5930
 
    @return: media instance.
5931
 
    '''
5932
 
    f = _Cfunctions.get('libvlc_media_list_media', None) or \
5933
 
        _Cfunction('libvlc_media_list_media', ((1,),), class_result(Media),
5934
 
                   ctypes.c_void_p, MediaList)
5935
 
    return f(p_ml)
5936
 
 
5937
 
 
5938
 
def libvlc_media_list_add_media(p_ml, p_md):
5939
 
    '''Add media instance to media list
5940
 
    The L{libvlc_media_list_lock} should be held upon entering this function.
5941
 
    @param p_ml: a media list instance.
5942
 
    @param p_md: a media instance.
5943
 
    @return: 0 on success, -1 if the media list is read-only.
5944
 
    '''
5945
 
    f = _Cfunctions.get('libvlc_media_list_add_media', None) or \
5946
 
        _Cfunction('libvlc_media_list_add_media', ((1,), (1,),), None,
5947
 
                   ctypes.c_int, MediaList, Media)
5948
 
    return f(p_ml, p_md)
5949
 
 
5950
 
 
5951
 
def libvlc_media_list_insert_media(p_ml, p_md, i_pos):
5952
 
    '''Insert media instance in media list on a position
5953
 
    The L{libvlc_media_list_lock} should be held upon entering this function.
5954
 
    @param p_ml: a media list instance.
5955
 
    @param p_md: a media instance.
5956
 
    @param i_pos: position in array where to insert.
5957
 
    @return: 0 on success, -1 if the media list is read-only.
5958
 
    '''
5959
 
    f = _Cfunctions.get('libvlc_media_list_insert_media', None) or \
5960
 
        _Cfunction('libvlc_media_list_insert_media', ((1,), (1,), (1,),), None,
5961
 
                   ctypes.c_int, MediaList, Media, ctypes.c_int)
5962
 
    return f(p_ml, p_md, i_pos)
5963
 
 
5964
 
 
5965
 
def libvlc_media_list_remove_index(p_ml, i_pos):
5966
 
    '''Remove media instance from media list on a position
5967
 
    The L{libvlc_media_list_lock} should be held upon entering this function.
5968
 
    @param p_ml: a media list instance.
5969
 
    @param i_pos: position in array where to insert.
5970
 
    @return: 0 on success, -1 if the list is read-only or the item was not found.
5971
 
    '''
5972
 
    f = _Cfunctions.get('libvlc_media_list_remove_index', None) or \
5973
 
        _Cfunction('libvlc_media_list_remove_index', ((1,), (1,),), None,
5974
 
                   ctypes.c_int, MediaList, ctypes.c_int)
5975
 
    return f(p_ml, i_pos)
5976
 
 
5977
 
 
5978
 
def libvlc_media_list_count(p_ml):
5979
 
    '''Get count on media list items
5980
 
    The L{libvlc_media_list_lock} should be held upon entering this function.
5981
 
    @param p_ml: a media list instance.
5982
 
    @return: number of items in media list.
5983
 
    '''
5984
 
    f = _Cfunctions.get('libvlc_media_list_count', None) or \
5985
 
        _Cfunction('libvlc_media_list_count', ((1,),), None,
5986
 
                   ctypes.c_int, MediaList)
5987
 
    return f(p_ml)
5988
 
 
5989
 
 
5990
 
def libvlc_media_list_item_at_index(p_ml, i_pos):
5991
 
    '''List media instance in media list at a position
5992
 
    The L{libvlc_media_list_lock} should be held upon entering this function.
5993
 
    @param p_ml: a media list instance.
5994
 
    @param i_pos: position in array where to insert.
5995
 
    @return: media instance at position i_pos, or None if not found. In case of success, L{libvlc_media_retain}() is called to increase the refcount on the media.
5996
 
    '''
5997
 
    f = _Cfunctions.get('libvlc_media_list_item_at_index', None) or \
5998
 
        _Cfunction('libvlc_media_list_item_at_index', ((1,), (1,),), class_result(Media),
5999
 
                   ctypes.c_void_p, MediaList, ctypes.c_int)
6000
 
    return f(p_ml, i_pos)
6001
 
 
6002
 
 
6003
 
def libvlc_media_list_index_of_item(p_ml, p_md):
6004
 
    '''Find index position of List media instance in media list.
6005
 
    Warning: the function will return the first matched position.
6006
 
    The L{libvlc_media_list_lock} should be held upon entering this function.
6007
 
    @param p_ml: a media list instance.
6008
 
    @param p_md: media instance.
6009
 
    @return: position of media instance or -1 if media not found.
6010
 
    '''
6011
 
    f = _Cfunctions.get('libvlc_media_list_index_of_item', None) or \
6012
 
        _Cfunction('libvlc_media_list_index_of_item', ((1,), (1,),), None,
6013
 
                   ctypes.c_int, MediaList, Media)
6014
 
    return f(p_ml, p_md)
6015
 
 
6016
 
 
6017
 
def libvlc_media_list_is_readonly(p_ml):
6018
 
    '''This indicates if this media list is read-only from a user point of view.
6019
 
    @param p_ml: media list instance.
6020
 
    @return: 1 on readonly, 0 on readwrite \libvlc_return_bool.
6021
 
    '''
6022
 
    f = _Cfunctions.get('libvlc_media_list_is_readonly', None) or \
6023
 
        _Cfunction('libvlc_media_list_is_readonly', ((1,),), None,
6024
 
                   ctypes.c_int, MediaList)
6025
 
    return f(p_ml)
6026
 
 
6027
 
 
6028
 
def libvlc_media_list_lock(p_ml):
6029
 
    '''Get lock on media list items.
6030
 
    @param p_ml: a media list instance.
6031
 
    '''
6032
 
    f = _Cfunctions.get('libvlc_media_list_lock', None) or \
6033
 
        _Cfunction('libvlc_media_list_lock', ((1,),), None,
6034
 
                   None, MediaList)
6035
 
    return f(p_ml)
6036
 
 
6037
 
 
6038
 
def libvlc_media_list_unlock(p_ml):
6039
 
    '''Release lock on media list items
6040
 
    The L{libvlc_media_list_lock} should be held upon entering this function.
6041
 
    @param p_ml: a media list instance.
6042
 
    '''
6043
 
    f = _Cfunctions.get('libvlc_media_list_unlock', None) or \
6044
 
        _Cfunction('libvlc_media_list_unlock', ((1,),), None,
6045
 
                   None, MediaList)
6046
 
    return f(p_ml)
6047
 
 
6048
 
 
6049
 
def libvlc_media_list_event_manager(p_ml):
6050
 
    '''Get libvlc_event_manager from this media list instance.
6051
 
    The p_event_manager is immutable, so you don't have to hold the lock.
6052
 
    @param p_ml: a media list instance.
6053
 
    @return: libvlc_event_manager.
6054
 
    '''
6055
 
    f = _Cfunctions.get('libvlc_media_list_event_manager', None) or \
6056
 
        _Cfunction('libvlc_media_list_event_manager', ((1,),), class_result(EventManager),
6057
 
                   ctypes.c_void_p, MediaList)
6058
 
    return f(p_ml)
6059
 
 
6060
 
 
6061
 
def libvlc_media_player_get_fps(p_mi):
6062
 
    '''Get movie fps rate
6063
 
    This function is provided for backward compatibility. It cannot deal with
6064
 
    multiple video tracks. In LibVLC versions prior to 3.0, it would also fail
6065
 
    if the file format did not convey the frame rate explicitly.
6066
 
    \deprecated Consider using L{libvlc_media_tracks_get}() instead.
6067
 
    @param p_mi: the Media Player.
6068
 
    @return: frames per second (fps) for this playing movie, or 0 if unspecified.
6069
 
    '''
6070
 
    f = _Cfunctions.get('libvlc_media_player_get_fps', None) or \
6071
 
        _Cfunction('libvlc_media_player_get_fps', ((1,),), None,
6072
 
                   ctypes.c_float, MediaPlayer)
6073
 
    return f(p_mi)
6074
 
 
6075
 
 
6076
 
def libvlc_media_player_set_agl(p_mi, drawable):
6077
 
    '''\deprecated Use L{libvlc_media_player_set_nsobject}() instead.
6078
 
    '''
6079
 
    f = _Cfunctions.get('libvlc_media_player_set_agl', None) or \
6080
 
        _Cfunction('libvlc_media_player_set_agl', ((1,), (1,),), None,
6081
 
                   None, MediaPlayer, ctypes.c_uint32)
6082
 
    return f(p_mi, drawable)
6083
 
 
6084
 
 
6085
 
def libvlc_media_player_get_agl(p_mi):
6086
 
    '''\deprecated Use L{libvlc_media_player_get_nsobject}() instead.
6087
 
    '''
6088
 
    f = _Cfunctions.get('libvlc_media_player_get_agl', None) or \
6089
 
        _Cfunction('libvlc_media_player_get_agl', ((1,),), None,
6090
 
                   ctypes.c_uint32, MediaPlayer)
6091
 
    return f(p_mi)
6092
 
 
6093
 
 
6094
 
def libvlc_track_description_release(p_track_description):
6095
 
    '''\deprecated Use L{libvlc_track_description_list_release}() instead.
6096
 
    '''
6097
 
    f = _Cfunctions.get('libvlc_track_description_release', None) or \
6098
 
        _Cfunction('libvlc_track_description_release', ((1,),), None,
6099
 
                   None, ctypes.POINTER(TrackDescription))
6100
 
    return f(p_track_description)
6101
 
 
6102
 
 
6103
 
def libvlc_video_get_height(p_mi):
6104
 
    '''Get current video height.
6105
 
    \deprecated Use L{libvlc_video_get_size}() instead.
6106
 
    @param p_mi: the media player.
6107
 
    @return: the video pixel height or 0 if not applicable.
6108
 
    '''
6109
 
    f = _Cfunctions.get('libvlc_video_get_height', None) or \
6110
 
        _Cfunction('libvlc_video_get_height', ((1,),), None,
6111
 
                   ctypes.c_int, MediaPlayer)
6112
 
    return f(p_mi)
6113
 
 
6114
 
 
6115
 
def libvlc_video_get_width(p_mi):
6116
 
    '''Get current video width.
6117
 
    \deprecated Use L{libvlc_video_get_size}() instead.
6118
 
    @param p_mi: the media player.
6119
 
    @return: the video pixel width or 0 if not applicable.
6120
 
    '''
6121
 
    f = _Cfunctions.get('libvlc_video_get_width', None) or \
6122
 
        _Cfunction('libvlc_video_get_width', ((1,),), None,
6123
 
                   ctypes.c_int, MediaPlayer)
6124
 
    return f(p_mi)
6125
 
 
6126
 
 
6127
 
def libvlc_video_get_title_description(p_mi):
6128
 
    '''Get the description of available titles.
6129
 
    @param p_mi: the media player.
6130
 
    @return: list containing description of available titles. It must be freed with L{libvlc_track_description_list_release}().
6131
 
    '''
6132
 
    f = _Cfunctions.get('libvlc_video_get_title_description', None) or \
6133
 
        _Cfunction('libvlc_video_get_title_description', ((1,),), None,
6134
 
                   ctypes.POINTER(TrackDescription), MediaPlayer)
6135
 
    return f(p_mi)
6136
 
 
6137
 
 
6138
 
def libvlc_video_get_chapter_description(p_mi, i_title):
6139
 
    '''Get the description of available chapters for specific title.
6140
 
    @param p_mi: the media player.
6141
 
    @param i_title: selected title.
6142
 
    @return: list containing description of available chapter for title i_title. It must be freed with L{libvlc_track_description_list_release}().
6143
 
    '''
6144
 
    f = _Cfunctions.get('libvlc_video_get_chapter_description', None) or \
6145
 
        _Cfunction('libvlc_video_get_chapter_description', ((1,), (1,),), None,
6146
 
                   ctypes.POINTER(TrackDescription), MediaPlayer, ctypes.c_int)
6147
 
    return f(p_mi, i_title)
6148
 
 
6149
 
 
6150
 
def libvlc_video_set_subtitle_file(p_mi, psz_subtitle):
6151
 
    '''Set new video subtitle file.
6152
 
    \deprecated Use L{libvlc_media_player_add_slave}() instead.
6153
 
    @param p_mi: the media player.
6154
 
    @param psz_subtitle: new video subtitle file.
6155
 
    @return: the success status (boolean).
6156
 
    '''
6157
 
    f = _Cfunctions.get('libvlc_video_set_subtitle_file', None) or \
6158
 
        _Cfunction('libvlc_video_set_subtitle_file', ((1,), (1,),), None,
6159
 
                   ctypes.c_int, MediaPlayer, ctypes.c_char_p)
6160
 
    return f(p_mi, psz_subtitle)
6161
 
 
6162
 
 
6163
 
def libvlc_toggle_teletext(p_mi):
6164
 
    '''Toggle teletext transparent status on video output.
6165
 
    \deprecated use L{libvlc_video_set_teletext}() instead.
6166
 
    @param p_mi: the media player.
6167
 
    '''
6168
 
    f = _Cfunctions.get('libvlc_toggle_teletext', None) or \
6169
 
        _Cfunction('libvlc_toggle_teletext', ((1,),), None,
6170
 
                   None, MediaPlayer)
6171
 
    return f(p_mi)
6172
 
 
6173
 
 
6174
 
def libvlc_audio_output_device_count(p_instance, psz_audio_output):
6175
 
    '''Backward compatibility stub. Do not use in new code.
6176
 
    \deprecated Use L{libvlc_audio_output_device_list_get}() instead.
6177
 
    @return: always 0.
6178
 
    '''
6179
 
    f = _Cfunctions.get('libvlc_audio_output_device_count', None) or \
6180
 
        _Cfunction('libvlc_audio_output_device_count', ((1,), (1,),), None,
6181
 
                   ctypes.c_int, Instance, ctypes.c_char_p)
6182
 
    return f(p_instance, psz_audio_output)
6183
 
 
6184
 
 
6185
 
def libvlc_audio_output_device_longname(p_instance, psz_output, i_device):
6186
 
    '''Backward compatibility stub. Do not use in new code.
6187
 
    \deprecated Use L{libvlc_audio_output_device_list_get}() instead.
6188
 
    @return: always None.
6189
 
    '''
6190
 
    f = _Cfunctions.get('libvlc_audio_output_device_longname', None) or \
6191
 
        _Cfunction('libvlc_audio_output_device_longname', ((1,), (1,), (1,),), string_result,
6192
 
                   ctypes.c_void_p, Instance, ctypes.c_char_p, ctypes.c_int)
6193
 
    return f(p_instance, psz_output, i_device)
6194
 
 
6195
 
 
6196
 
def libvlc_audio_output_device_id(p_instance, psz_audio_output, i_device):
6197
 
    '''Backward compatibility stub. Do not use in new code.
6198
 
    \deprecated Use L{libvlc_audio_output_device_list_get}() instead.
6199
 
    @return: always None.
6200
 
    '''
6201
 
    f = _Cfunctions.get('libvlc_audio_output_device_id', None) or \
6202
 
        _Cfunction('libvlc_audio_output_device_id', ((1,), (1,), (1,),), string_result,
6203
 
                   ctypes.c_void_p, Instance, ctypes.c_char_p, ctypes.c_int)
6204
 
    return f(p_instance, psz_audio_output, i_device)
6205
 
 
6206
 
 
6207
 
def libvlc_media_parse(p_md):
6208
 
    '''Parse a media.
6209
 
    This fetches (local) art, meta data and tracks information.
6210
 
    The method is synchronous.
6211
 
    \deprecated This function could block indefinitely.
6212
 
                Use L{libvlc_media_parse_with_options}() instead
6213
 
    See L{libvlc_media_parse_with_options}
6214
 
    See L{libvlc_media_get_meta}
6215
 
    See L{libvlc_media_get_tracks_info}.
6216
 
    @param p_md: media descriptor object.
6217
 
    '''
6218
 
    f = _Cfunctions.get('libvlc_media_parse', None) or \
6219
 
        _Cfunction('libvlc_media_parse', ((1,),), None,
6220
 
                   None, Media)
6221
 
    return f(p_md)
6222
 
 
6223
 
 
6224
 
def libvlc_media_parse_async(p_md):
6225
 
    '''Parse a media.
6226
 
    This fetches (local) art, meta data and tracks information.
6227
 
    The method is the asynchronous of L{libvlc_media_parse}().
6228
 
    To track when this is over you can listen to libvlc_MediaParsedChanged
6229
 
    event. However if the media was already parsed you will not receive this
6230
 
    event.
6231
 
    \deprecated You can't be sure to receive the libvlc_MediaParsedChanged
6232
 
                event (you can wait indefinitely for this event).
6233
 
                Use L{libvlc_media_parse_with_options}() instead
6234
 
    See L{libvlc_media_parse}
6235
 
    See libvlc_MediaParsedChanged
6236
 
    See L{libvlc_media_get_meta}
6237
 
    See L{libvlc_media_get_tracks_info}.
6238
 
    @param p_md: media descriptor object.
6239
 
    '''
6240
 
    f = _Cfunctions.get('libvlc_media_parse_async', None) or \
6241
 
        _Cfunction('libvlc_media_parse_async', ((1,),), None,
6242
 
                   None, Media)
6243
 
    return f(p_md)
6244
 
 
6245
 
 
6246
 
def libvlc_media_is_parsed(p_md):
6247
 
    '''Return true is the media descriptor object is parsed
6248
 
    \deprecated This can return true in case of failure.
6249
 
                Use L{libvlc_media_get_parsed_status}() instead
6250
 
    See libvlc_MediaParsedChanged.
6251
 
    @param p_md: media descriptor object.
6252
 
    @return: true if media object has been parsed otherwise it returns false \libvlc_return_bool.
6253
 
    '''
6254
 
    f = _Cfunctions.get('libvlc_media_is_parsed', None) or \
6255
 
        _Cfunction('libvlc_media_is_parsed', ((1,),), None,
6256
 
                   ctypes.c_int, Media)
6257
 
    return f(p_md)
6258
 
 
6259
 
 
6260
 
def libvlc_media_get_tracks_info(p_md):
6261
 
    '''Get media descriptor's elementary streams description
6262
 
    Note, you need to call L{libvlc_media_parse}() or play the media at least once
6263
 
    before calling this function.
6264
 
    Not doing this will result in an empty array.
6265
 
    \deprecated Use L{libvlc_media_tracks_get}() instead.
6266
 
    @param p_md: media descriptor object.
6267
 
    @param tracks: address to store an allocated array of Elementary Streams descriptions (must be freed by the caller) [OUT].
6268
 
    @return: the number of Elementary Streams.
6269
 
    '''
6270
 
    f = _Cfunctions.get('libvlc_media_get_tracks_info', None) or \
6271
 
        _Cfunction('libvlc_media_get_tracks_info', ((1,), (2,),), None,
6272
 
                   ctypes.c_int, Media, ctypes.POINTER(ctypes.c_void_p))
6273
 
    return f(p_md)
6274
 
 
6275
 
 
6276
 
def libvlc_media_discoverer_new_from_name(p_inst, psz_name):
6277
 
    '''\deprecated Use L{libvlc_media_discoverer_new}() and L{libvlc_media_discoverer_start}().
6278
 
    '''
6279
 
    f = _Cfunctions.get('libvlc_media_discoverer_new_from_name', None) or \
6280
 
        _Cfunction('libvlc_media_discoverer_new_from_name', ((1,), (1,),), class_result(MediaDiscoverer),
6281
 
                   ctypes.c_void_p, Instance, ctypes.c_char_p)
6282
 
    return f(p_inst, psz_name)
6283
 
 
6284
 
 
6285
 
def libvlc_media_discoverer_localized_name(p_mdis):
6286
 
    '''Get media service discover object its localized name.
6287
 
    \deprecated Useless, use L{libvlc_media_discoverer_list_get}() to get the
6288
 
    longname of the service discovery.
6289
 
    @param p_mdis: media discover object.
6290
 
    @return: localized name or None if the media_discoverer is not started.
6291
 
    '''
6292
 
    f = _Cfunctions.get('libvlc_media_discoverer_localized_name', None) or \
6293
 
        _Cfunction('libvlc_media_discoverer_localized_name', ((1,),), string_result,
6294
 
                   ctypes.c_void_p, MediaDiscoverer)
6295
 
    return f(p_mdis)
6296
 
 
6297
 
 
6298
 
def libvlc_media_discoverer_event_manager(p_mdis):
6299
 
    '''Get event manager from media service discover object.
6300
 
    \deprecated Useless, media_discoverer events are only triggered when calling
6301
 
    L{libvlc_media_discoverer_start}() and L{libvlc_media_discoverer_stop}().
6302
 
    @param p_mdis: media service discover object.
6303
 
    @return: event manager object.
6304
 
    '''
6305
 
    f = _Cfunctions.get('libvlc_media_discoverer_event_manager', None) or \
6306
 
        _Cfunction('libvlc_media_discoverer_event_manager', ((1,),), class_result(EventManager),
6307
 
                   ctypes.c_void_p, MediaDiscoverer)
6308
 
    return f(p_mdis)
6309
 
 
6310
 
 
6311
 
def libvlc_wait(p_instance):
6312
 
    '''Waits until an interface causes the instance to exit.
6313
 
    You should start at least one interface first, using L{libvlc_add_intf}().
6314
 
    @param p_instance: the instance @warning This function wastes one thread doing basically nothing. libvlc_set_exit_handler() should be used instead.
6315
 
    '''
6316
 
    f = _Cfunctions.get('libvlc_wait', None) or \
6317
 
        _Cfunction('libvlc_wait', ((1,),), None,
6318
 
                   None, Instance)
6319
 
    return f(p_instance)
6320
 
 
6321
 
 
6322
 
def libvlc_get_log_verbosity(p_instance):
6323
 
    '''Always returns minus one.
6324
 
    This function is only provided for backward compatibility.
6325
 
    @param p_instance: ignored.
6326
 
    @return: always -1.
6327
 
    '''
6328
 
    f = _Cfunctions.get('libvlc_get_log_verbosity', None) or \
6329
 
        _Cfunction('libvlc_get_log_verbosity', ((1,),), None,
6330
 
                   ctypes.c_uint, Instance)
6331
 
    return f(p_instance)
6332
 
 
6333
 
 
6334
 
def libvlc_set_log_verbosity(p_instance, level):
6335
 
    '''This function does nothing.
6336
 
    It is only provided for backward compatibility.
6337
 
    @param p_instance: ignored.
6338
 
    @param level: ignored.
6339
 
    '''
6340
 
    f = _Cfunctions.get('libvlc_set_log_verbosity', None) or \
6341
 
        _Cfunction('libvlc_set_log_verbosity', ((1,), (1,),), None,
6342
 
                   None, Instance, ctypes.c_uint)
6343
 
    return f(p_instance, level)
6344
 
 
6345
 
 
6346
 
def libvlc_log_open(p_instance):
6347
 
    '''This function does nothing useful.
6348
 
    It is only provided for backward compatibility.
6349
 
    @param p_instance: libvlc instance.
6350
 
    @return: an unique pointer or None on error.
6351
 
    '''
6352
 
    f = _Cfunctions.get('libvlc_log_open', None) or \
6353
 
        _Cfunction('libvlc_log_open', ((1,),), None,
6354
 
                   Log_ptr, Instance)
6355
 
    return f(p_instance)
6356
 
 
6357
 
 
6358
 
def libvlc_log_close(p_log):
6359
 
    '''Frees memory allocated by L{libvlc_log_open}().
6360
 
    @param p_log: libvlc log instance or None.
6361
 
    '''
6362
 
    f = _Cfunctions.get('libvlc_log_close', None) or \
6363
 
        _Cfunction('libvlc_log_close', ((1,),), None,
6364
 
                   None, Log_ptr)
6365
 
    return f(p_log)
6366
 
 
6367
 
 
6368
 
def libvlc_log_count(p_log):
6369
 
    '''Always returns zero.
6370
 
    This function is only provided for backward compatibility.
6371
 
    @param p_log: ignored.
6372
 
    @return: always zero.
6373
 
    '''
6374
 
    f = _Cfunctions.get('libvlc_log_count', None) or \
6375
 
        _Cfunction('libvlc_log_count', ((1,),), None,
6376
 
                   ctypes.c_uint, Log_ptr)
6377
 
    return f(p_log)
6378
 
 
6379
 
 
6380
 
def libvlc_log_clear(p_log):
6381
 
    '''This function does nothing.
6382
 
    It is only provided for backward compatibility.
6383
 
    @param p_log: ignored.
6384
 
    '''
6385
 
    f = _Cfunctions.get('libvlc_log_clear', None) or \
6386
 
        _Cfunction('libvlc_log_clear', ((1,),), None,
6387
 
                   None, Log_ptr)
6388
 
    return f(p_log)
6389
 
 
6390
 
 
6391
 
def libvlc_log_get_iterator(p_log):
6392
 
    '''This function does nothing useful.
6393
 
    It is only provided for backward compatibility.
6394
 
    @param p_log: ignored.
6395
 
    @return: an unique pointer or None on error or if the parameter was None.
6396
 
    '''
6397
 
    f = _Cfunctions.get('libvlc_log_get_iterator', None) or \
6398
 
        _Cfunction('libvlc_log_get_iterator', ((1,),), class_result(LogIterator),
6399
 
                   ctypes.c_void_p, Log_ptr)
6400
 
    return f(p_log)
6401
 
 
6402
 
 
6403
 
def libvlc_log_iterator_free(p_iter):
6404
 
    '''Frees memory allocated by L{libvlc_log_get_iterator}().
6405
 
    @param p_iter: libvlc log iterator or None.
6406
 
    '''
6407
 
    f = _Cfunctions.get('libvlc_log_iterator_free', None) or \
6408
 
        _Cfunction('libvlc_log_iterator_free', ((1,),), None,
6409
 
                   None, LogIterator)
6410
 
    return f(p_iter)
6411
 
 
6412
 
 
6413
 
def libvlc_log_iterator_has_next(p_iter):
6414
 
    '''Always returns zero.
6415
 
    This function is only provided for backward compatibility.
6416
 
    @param p_iter: ignored.
6417
 
    @return: always zero.
6418
 
    '''
6419
 
    f = _Cfunctions.get('libvlc_log_iterator_has_next', None) or \
6420
 
        _Cfunction('libvlc_log_iterator_has_next', ((1,),), None,
6421
 
                   ctypes.c_int, LogIterator)
6422
 
    return f(p_iter)
6423
 
 
6424
 
 
6425
 
def libvlc_log_iterator_next(p_iter, p_buf):
6426
 
    '''Always returns None.
6427
 
    This function is only provided for backward compatibility.
6428
 
    @param p_iter: libvlc log iterator or None.
6429
 
    @param p_buf: ignored.
6430
 
    @return: always None.
6431
 
    '''
6432
 
    f = _Cfunctions.get('libvlc_log_iterator_next', None) or \
6433
 
        _Cfunction('libvlc_log_iterator_next', ((1,), (1,),), None,
6434
 
                   ctypes.POINTER(LogMessage), LogIterator, ctypes.POINTER(LogMessage))
6435
 
    return f(p_iter, p_buf)
6436
 
 
6437
 
 
6438
 
def libvlc_playlist_play(p_instance, i_id, i_options, ppsz_options):
6439
 
    '''Start playing (if there is any item in the playlist).
6440
 
    Additionnal playlist item options can be specified for addition to the
6441
 
    item before it is played.
6442
 
    @param p_instance: the playlist instance.
6443
 
    @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.
6444
 
    @param i_options: the number of options to add to the item.
6445
 
    @param ppsz_options: the options to add to the item.
6446
 
    '''
6447
 
    f = _Cfunctions.get('libvlc_playlist_play', None) or \
6448
 
        _Cfunction('libvlc_playlist_play', ((1,), (1,), (1,), (1,),), None,
6449
 
                   None, Instance, ctypes.c_int, ctypes.c_int, ListPOINTER(ctypes.c_char_p))
6450
 
    return f(p_instance, i_id, i_options, ppsz_options)
6451
 
 
6452
 
 
6453
 
def libvlc_media_player_new(p_libvlc_instance):
6454
 
    '''Create an empty Media Player object.
6455
 
    @param p_libvlc_instance: the libvlc instance in which the Media Player should be created.
6456
 
    @return: a new media player object, or None on error.
6457
 
    '''
6458
 
    f = _Cfunctions.get('libvlc_media_player_new', None) or \
6459
 
        _Cfunction('libvlc_media_player_new', ((1,),), class_result(MediaPlayer),
6460
 
                   ctypes.c_void_p, Instance)
6461
 
    return f(p_libvlc_instance)
6462
 
 
6463
 
 
6464
 
def libvlc_media_player_new_from_media(p_md):
6465
 
    '''Create a Media Player object from a Media.
6466
 
    @param p_md: the media. Afterwards the p_md can be safely destroyed.
6467
 
    @return: a new media player object, or None on error.
6468
 
    '''
6469
 
    f = _Cfunctions.get('libvlc_media_player_new_from_media', None) or \
6470
 
        _Cfunction('libvlc_media_player_new_from_media', ((1,),), class_result(MediaPlayer),
6471
 
                   ctypes.c_void_p, Media)
6472
 
    return f(p_md)
6473
 
 
6474
 
 
6475
 
def libvlc_media_player_release(p_mi):
6476
 
    '''Release a media_player after use
6477
 
    Decrement the reference count of a media player object. If the
6478
 
    reference count is 0, then L{libvlc_media_player_release}() will
6479
 
    release the media player object. If the media player object
6480
 
    has been released, then it should not be used again.
6481
 
    @param p_mi: the Media Player to free.
6482
 
    '''
6483
 
    f = _Cfunctions.get('libvlc_media_player_release', None) or \
6484
 
        _Cfunction('libvlc_media_player_release', ((1,),), None,
6485
 
                   None, MediaPlayer)
6486
 
    return f(p_mi)
6487
 
 
6488
 
 
6489
 
def libvlc_media_player_retain(p_mi):
6490
 
    '''Retain a reference to a media player object. Use
6491
 
    L{libvlc_media_player_release}() to decrement reference count.
6492
 
    @param p_mi: media player object.
6493
 
    '''
6494
 
    f = _Cfunctions.get('libvlc_media_player_retain', None) or \
6495
 
        _Cfunction('libvlc_media_player_retain', ((1,),), None,
6496
 
                   None, MediaPlayer)
6497
 
    return f(p_mi)
6498
 
 
6499
 
 
6500
 
def libvlc_media_player_set_media(p_mi, p_md):
6501
 
    '''Set the media that will be used by the media_player. If any,
6502
 
    previous md will be released.
6503
 
    @param p_mi: the Media Player.
6504
 
    @param p_md: the Media. Afterwards the p_md can be safely destroyed.
6505
 
    '''
6506
 
    f = _Cfunctions.get('libvlc_media_player_set_media', None) or \
6507
 
        _Cfunction('libvlc_media_player_set_media', ((1,), (1,),), None,
6508
 
                   None, MediaPlayer, Media)
6509
 
    return f(p_mi, p_md)
6510
 
 
6511
 
 
6512
 
def libvlc_media_player_get_media(p_mi):
6513
 
    '''Get the media used by the media_player.
6514
 
    @param p_mi: the Media Player.
6515
 
    @return: the media associated with p_mi, or None if no media is associated.
6516
 
    '''
6517
 
    f = _Cfunctions.get('libvlc_media_player_get_media', None) or \
6518
 
        _Cfunction('libvlc_media_player_get_media', ((1,),), class_result(Media),
6519
 
                   ctypes.c_void_p, MediaPlayer)
6520
 
    return f(p_mi)
6521
 
 
6522
 
 
6523
 
def libvlc_media_player_event_manager(p_mi):
6524
 
    '''Get the Event Manager from which the media player send event.
6525
 
    @param p_mi: the Media Player.
6526
 
    @return: the event manager associated with p_mi.
6527
 
    '''
6528
 
    f = _Cfunctions.get('libvlc_media_player_event_manager', None) or \
6529
 
        _Cfunction('libvlc_media_player_event_manager', ((1,),), class_result(EventManager),
6530
 
                   ctypes.c_void_p, MediaPlayer)
6531
 
    return f(p_mi)
6532
 
 
6533
 
 
6534
 
def libvlc_media_player_is_playing(p_mi):
6535
 
    '''is_playing.
6536
 
    @param p_mi: the Media Player.
6537
 
    @return: 1 if the media player is playing, 0 otherwise \libvlc_return_bool.
6538
 
    '''
6539
 
    f = _Cfunctions.get('libvlc_media_player_is_playing', None) or \
6540
 
        _Cfunction('libvlc_media_player_is_playing', ((1,),), None,
6541
 
                   ctypes.c_int, MediaPlayer)
6542
 
    return f(p_mi)
6543
 
 
6544
 
 
6545
 
def libvlc_media_player_play(p_mi):
6546
 
    '''Play.
6547
 
    @param p_mi: the Media Player.
6548
 
    @return: 0 if playback started (and was already started), or -1 on error.
6549
 
    '''
6550
 
    f = _Cfunctions.get('libvlc_media_player_play', None) or \
6551
 
        _Cfunction('libvlc_media_player_play', ((1,),), None,
6552
 
                   ctypes.c_int, MediaPlayer)
6553
 
    return f(p_mi)
6554
 
 
6555
 
 
6556
 
def libvlc_media_player_set_pause(mp, do_pause):
6557
 
    '''Pause or resume (no effect if there is no media).
6558
 
    @param mp: the Media Player.
6559
 
    @param do_pause: play/resume if zero, pause if non-zero.
6560
 
    @version: LibVLC 1.1.1 or later.
6561
 
    '''
6562
 
    f = _Cfunctions.get('libvlc_media_player_set_pause', None) or \
6563
 
        _Cfunction('libvlc_media_player_set_pause', ((1,), (1,),), None,
6564
 
                   None, MediaPlayer, ctypes.c_int)
6565
 
    return f(mp, do_pause)
6566
 
 
6567
 
 
6568
 
def libvlc_media_player_pause(p_mi):
6569
 
    '''Toggle pause (no effect if there is no media).
6570
 
    @param p_mi: the Media Player.
6571
 
    '''
6572
 
    f = _Cfunctions.get('libvlc_media_player_pause', None) or \
6573
 
        _Cfunction('libvlc_media_player_pause', ((1,),), None,
6574
 
                   None, MediaPlayer)
6575
 
    return f(p_mi)
6576
 
 
6577
 
 
6578
 
def libvlc_media_player_stop(p_mi):
6579
 
    '''Stop (no effect if there is no media).
6580
 
    @param p_mi: the Media Player.
6581
 
    '''
6582
 
    f = _Cfunctions.get('libvlc_media_player_stop', None) or \
6583
 
        _Cfunction('libvlc_media_player_stop', ((1,),), None,
6584
 
                   None, MediaPlayer)
6585
 
    return f(p_mi)
6586
 
 
6587
 
 
6588
 
def libvlc_media_player_set_renderer(p_mi, p_item):
6589
 
    '''Set a renderer to the media player
6590
 
    @note: must be called before the first call of L{libvlc_media_player_play}() to
6591
 
    take effect.
6592
 
    See L{libvlc_renderer_discoverer_new}.
6593
 
    @param p_mi: the Media Player.
6594
 
    @param p_item: an item discovered by L{libvlc_renderer_discoverer_start}().
6595
 
    @return: 0 on success, -1 on error.
6596
 
    @version: LibVLC 3.0.0 or later.
6597
 
    '''
6598
 
    f = _Cfunctions.get('libvlc_media_player_set_renderer', None) or \
6599
 
        _Cfunction('libvlc_media_player_set_renderer', ((1,), (1,),), None,
6600
 
                   ctypes.c_int, MediaPlayer, ctypes.c_void_p)
6601
 
    return f(p_mi, p_item)
6602
 
 
6603
 
 
6604
 
def libvlc_video_set_callbacks(mp, lock, unlock, display, opaque):
6605
 
    '''Set callbacks and private data to render decoded video to a custom area
6606
 
    in memory.
6607
 
    Use L{libvlc_video_set_format}() or L{libvlc_video_set_format_callbacks}()
6608
 
    to configure the decoded format.
6609
 
    @warning: Rendering video into custom memory buffers is considerably less
6610
 
    efficient than rendering in a custom window as normal.
6611
 
    For optimal perfomances, VLC media player renders into a custom window, and
6612
 
    does not use this function and associated callbacks. It is B{highly
6613
 
    recommended} that other LibVLC-based application do likewise.
6614
 
    To embed video in a window, use libvlc_media_player_set_xid() or equivalent
6615
 
    depending on the operating system.
6616
 
    If window embedding does not fit the application use case, then a custom
6617
 
    LibVLC video output display plugin is required to maintain optimal video
6618
 
    rendering performances.
6619
 
    The following limitations affect performance:
6620
 
    - Hardware video decoding acceleration will either be disabled completely,
6621
 
      or require (relatively slow) copy from video/DSP memory to main memory.
6622
 
    - Sub-pictures (subtitles, on-screen display, etc.) must be blent into the
6623
 
      main picture by the CPU instead of the GPU.
6624
 
    - Depending on the video format, pixel format conversion, picture scaling,
6625
 
      cropping and/or picture re-orientation, must be performed by the CPU
6626
 
      instead of the GPU.
6627
 
    - Memory copying is required between LibVLC reference picture buffers and
6628
 
      application buffers (between lock and unlock callbacks).
6629
 
    @param mp: the media player.
6630
 
    @param lock: callback to lock video memory (must not be None).
6631
 
    @param unlock: callback to unlock video memory (or None if not needed).
6632
 
    @param display: callback to display video (or None if not needed).
6633
 
    @param opaque: private pointer for the three callbacks (as first parameter).
6634
 
    @version: LibVLC 1.1.1 or later.
6635
 
    '''
6636
 
    f = _Cfunctions.get('libvlc_video_set_callbacks', None) or \
6637
 
        _Cfunction('libvlc_video_set_callbacks', ((1,), (1,), (1,), (1,), (1,),), None,
6638
 
                   None, MediaPlayer, VideoLockCb, VideoUnlockCb, VideoDisplayCb, ctypes.c_void_p)
6639
 
    return f(mp, lock, unlock, display, opaque)
6640
 
 
6641
 
 
6642
 
def libvlc_video_set_format(mp, chroma, width, height, pitch):
6643
 
    '''Set decoded video chroma and dimensions.
6644
 
    This only works in combination with L{libvlc_video_set_callbacks}(),
6645
 
    and is mutually exclusive with L{libvlc_video_set_format_callbacks}().
6646
 
    @param mp: the media player.
6647
 
    @param chroma: a four-characters string identifying the chroma (e.g. "RV32" or "YUYV").
6648
 
    @param width: pixel width.
6649
 
    @param height: pixel height.
6650
 
    @param pitch: line pitch (in bytes).
6651
 
    @version: LibVLC 1.1.1 or later.
6652
 
    @bug: All pixel planes are expected to have the same pitch. To use the YCbCr color space with chrominance subsampling, consider using L{libvlc_video_set_format_callbacks}() instead.
6653
 
    '''
6654
 
    f = _Cfunctions.get('libvlc_video_set_format', None) or \
6655
 
        _Cfunction('libvlc_video_set_format', ((1,), (1,), (1,), (1,), (1,),), None,
6656
 
                   None, MediaPlayer, ctypes.c_char_p, ctypes.c_uint, ctypes.c_uint, ctypes.c_uint)
6657
 
    return f(mp, chroma, width, height, pitch)
6658
 
 
6659
 
 
6660
 
def libvlc_video_set_format_callbacks(mp, setup, cleanup):
6661
 
    '''Set decoded video chroma and dimensions. This only works in combination with
6662
 
    L{libvlc_video_set_callbacks}().
6663
 
    @param mp: the media player.
6664
 
    @param setup: callback to select the video format (cannot be None).
6665
 
    @param cleanup: callback to release any allocated resources (or None).
6666
 
    @version: LibVLC 2.0.0 or later.
6667
 
    '''
6668
 
    f = _Cfunctions.get('libvlc_video_set_format_callbacks', None) or \
6669
 
        _Cfunction('libvlc_video_set_format_callbacks', ((1,), (1,), (1,),), None,
6670
 
                   None, MediaPlayer, VideoFormatCb, VideoCleanupCb)
6671
 
    return f(mp, setup, cleanup)
6672
 
 
6673
 
 
6674
 
def libvlc_media_player_set_nsobject(p_mi, drawable):
6675
 
    '''Set the NSView handler where the media player should render its video output.
6676
 
    Use the vout called "macosx".
6677
 
    The drawable is an NSObject that follow the VLCOpenGLVideoViewEmbedding
6678
 
    protocol:
6679
 
    @code.m
6680
 
    \@protocol VLCOpenGLVideoViewEmbedding <NSObject>
6681
 
    - (void)addVoutSubview:(NSView *)view;
6682
 
    - (void)removeVoutSubview:(NSView *)view;
6683
 
    \@end
6684
 
    @endcode
6685
 
    Or it can be an NSView object.
6686
 
    If you want to use it along with Qt see the QMacCocoaViewContainer. Then
6687
 
    the following code should work:
6688
 
    @code.mm
6689
 
 
6690
 
        NSView *video = [[NSView alloc] init];
6691
 
        QMacCocoaViewContainer *container = new QMacCocoaViewContainer(video, parent);
6692
 
        L{libvlc_media_player_set_nsobject}(mp, video);
6693
 
        [video release];
6694
 
 
6695
 
    @endcode
6696
 
    You can find a live example in VLCVideoView in VLCKit.framework.
6697
 
    @param p_mi: the Media Player.
6698
 
    @param drawable: the drawable that is either an NSView or an object following the VLCOpenGLVideoViewEmbedding protocol.
6699
 
    '''
6700
 
    f = _Cfunctions.get('libvlc_media_player_set_nsobject', None) or \
6701
 
        _Cfunction('libvlc_media_player_set_nsobject', ((1,), (1,),), None,
6702
 
                   None, MediaPlayer, ctypes.c_void_p)
6703
 
    return f(p_mi, drawable)
6704
 
 
6705
 
 
6706
 
def libvlc_media_player_get_nsobject(p_mi):
6707
 
    '''Get the NSView handler previously set with L{libvlc_media_player_set_nsobject}().
6708
 
    @param p_mi: the Media Player.
6709
 
    @return: the NSView handler or 0 if none where set.
6710
 
    '''
6711
 
    f = _Cfunctions.get('libvlc_media_player_get_nsobject', None) or \
6712
 
        _Cfunction('libvlc_media_player_get_nsobject', ((1,),), None,
6713
 
                   ctypes.c_void_p, MediaPlayer)
6714
 
    return f(p_mi)
6715
 
 
6716
 
 
6717
 
def libvlc_media_player_set_xwindow(p_mi, drawable):
6718
 
    '''Set an X Window System drawable where the media player should render its
6719
 
    video output. The call takes effect when the playback starts. If it is
6720
 
    already started, it might need to be stopped before changes apply.
6721
 
    If LibVLC was built without X11 output support, then this function has no
6722
 
    effects.
6723
 
    By default, LibVLC will capture input events on the video rendering area.
6724
 
    Use L{libvlc_video_set_mouse_input}() and L{libvlc_video_set_key_input}() to
6725
 
    disable that and deliver events to the parent window / to the application
6726
 
    instead. By design, the X11 protocol delivers input events to only one
6727
 
    recipient.
6728
 
    @warning
6729
 
    The application must call the XInitThreads() function from Xlib before
6730
 
    L{libvlc_new}(), and before any call to XOpenDisplay() directly or via any
6731
 
    other library. Failure to call XInitThreads() will seriously impede LibVLC
6732
 
    performance. Calling XOpenDisplay() before XInitThreads() will eventually
6733
 
    crash the process. That is a limitation of Xlib.
6734
 
    @param p_mi: media player.
6735
 
    @param drawable: X11 window ID @note The specified identifier must correspond to an existing Input/Output class X11 window. Pixmaps are B{not} currently supported. The default X11 server is assumed, i.e. that specified in the DISPLAY environment variable. @warning LibVLC can deal with invalid X11 handle errors, however some display drivers (EGL, GLX, VA and/or VDPAU) can unfortunately not. Thus the window handle must remain valid until playback is stopped, otherwise the process may abort or crash.
6736
 
    @bug No more than one window handle per media player instance can be specified. If the media has multiple simultaneously active video tracks, extra tracks will be rendered into external windows beyond the control of the application.
6737
 
    '''
6738
 
    f = _Cfunctions.get('libvlc_media_player_set_xwindow', None) or \
6739
 
        _Cfunction('libvlc_media_player_set_xwindow', ((1,), (1,),), None,
6740
 
                   None, MediaPlayer, ctypes.c_uint32)
6741
 
    return f(p_mi, drawable)
6742
 
 
6743
 
 
6744
 
def libvlc_media_player_get_xwindow(p_mi):
6745
 
    '''Get the X Window System window identifier previously set with
6746
 
    L{libvlc_media_player_set_xwindow}(). Note that this will return the identifier
6747
 
    even if VLC is not currently using it (for instance if it is playing an
6748
 
    audio-only input).
6749
 
    @param p_mi: the Media Player.
6750
 
    @return: an X window ID, or 0 if none where set.
6751
 
    '''
6752
 
    f = _Cfunctions.get('libvlc_media_player_get_xwindow', None) or \
6753
 
        _Cfunction('libvlc_media_player_get_xwindow', ((1,),), None,
6754
 
                   ctypes.c_uint32, MediaPlayer)
6755
 
    return f(p_mi)
6756
 
 
6757
 
 
6758
 
def libvlc_media_player_set_hwnd(p_mi, drawable):
6759
 
    '''Set a Win32/Win64 API window handle (HWND) where the media player should
6760
 
    render its video output. If LibVLC was built without Win32/Win64 API output
6761
 
    support, then this has no effects.
6762
 
    @param p_mi: the Media Player.
6763
 
    @param drawable: windows handle of the drawable.
6764
 
    '''
6765
 
    f = _Cfunctions.get('libvlc_media_player_set_hwnd', None) or \
6766
 
        _Cfunction('libvlc_media_player_set_hwnd', ((1,), (1,),), None,
6767
 
                   None, MediaPlayer, ctypes.c_void_p)
6768
 
    return f(p_mi, drawable)
6769
 
 
6770
 
 
6771
 
def libvlc_media_player_get_hwnd(p_mi):
6772
 
    '''Get the Windows API window handle (HWND) previously set with
6773
 
    L{libvlc_media_player_set_hwnd}(). The handle will be returned even if LibVLC
6774
 
    is not currently outputting any video to it.
6775
 
    @param p_mi: the Media Player.
6776
 
    @return: a window handle or None if there are none.
6777
 
    '''
6778
 
    f = _Cfunctions.get('libvlc_media_player_get_hwnd', None) or \
6779
 
        _Cfunction('libvlc_media_player_get_hwnd', ((1,),), None,
6780
 
                   ctypes.c_void_p, MediaPlayer)
6781
 
    return f(p_mi)
6782
 
 
6783
 
 
6784
 
def libvlc_media_player_set_android_context(p_mi, p_awindow_handler):
6785
 
    '''Set the android context.
6786
 
    @param p_mi: the media player.
6787
 
    @param p_awindow_handler: org.videolan.libvlc.AWindow jobject owned by the org.videolan.libvlc.MediaPlayer class from the libvlc-android project.
6788
 
    @version: LibVLC 3.0.0 and later.
6789
 
    '''
6790
 
    f = _Cfunctions.get('libvlc_media_player_set_android_context', None) or \
6791
 
        _Cfunction('libvlc_media_player_set_android_context', ((1,), (1,),), None,
6792
 
                   None, MediaPlayer, ctypes.c_void_p)
6793
 
    return f(p_mi, p_awindow_handler)
6794
 
 
6795
 
 
6796
 
def libvlc_media_player_set_evas_object(p_mi, p_evas_object):
6797
 
    '''Set the EFL Evas Object.
6798
 
    @param p_mi: the media player.
6799
 
    @param p_evas_object: a valid EFL Evas Object (Evas_Object).
6800
 
    @return: -1 if an error was detected, 0 otherwise.
6801
 
    @version: LibVLC 3.0.0 and later.
6802
 
    '''
6803
 
    f = _Cfunctions.get('libvlc_media_player_set_evas_object', None) or \
6804
 
        _Cfunction('libvlc_media_player_set_evas_object', ((1,), (1,),), None,
6805
 
                   ctypes.c_int, MediaPlayer, ctypes.c_void_p)
6806
 
    return f(p_mi, p_evas_object)
6807
 
 
6808
 
 
6809
 
def libvlc_audio_set_callbacks(mp, play, pause, resume, flush, drain, opaque):
6810
 
    '''Sets callbacks and private data for decoded audio.
6811
 
    Use L{libvlc_audio_set_format}() or L{libvlc_audio_set_format_callbacks}()
6812
 
    to configure the decoded audio format.
6813
 
    @note: The audio callbacks override any other audio output mechanism.
6814
 
    If the callbacks are set, LibVLC will B{not} output audio in any way.
6815
 
    @param mp: the media player.
6816
 
    @param play: callback to play audio samples (must not be None).
6817
 
    @param pause: callback to pause playback (or None to ignore).
6818
 
    @param resume: callback to resume playback (or None to ignore).
6819
 
    @param flush: callback to flush audio buffers (or None to ignore).
6820
 
    @param drain: callback to drain audio buffers (or None to ignore).
6821
 
    @param opaque: private pointer for the audio callbacks (as first parameter).
6822
 
    @version: LibVLC 2.0.0 or later.
6823
 
    '''
6824
 
    f = _Cfunctions.get('libvlc_audio_set_callbacks', None) or \
6825
 
        _Cfunction('libvlc_audio_set_callbacks', ((1,), (1,), (1,), (1,), (1,), (1,), (1,),), None,
6826
 
                   None, MediaPlayer, AudioPlayCb, AudioPauseCb, AudioResumeCb, AudioFlushCb, AudioDrainCb,
6827
 
                   ctypes.c_void_p)
6828
 
    return f(mp, play, pause, resume, flush, drain, opaque)
6829
 
 
6830
 
 
6831
 
def libvlc_audio_set_volume_callback(mp, set_volume):
6832
 
    '''Set callbacks and private data for decoded audio. This only works in
6833
 
    combination with L{libvlc_audio_set_callbacks}().
6834
 
    Use L{libvlc_audio_set_format}() or L{libvlc_audio_set_format_callbacks}()
6835
 
    to configure the decoded audio format.
6836
 
    @param mp: the media player.
6837
 
    @param set_volume: callback to apply audio volume, or None to apply volume in software.
6838
 
    @version: LibVLC 2.0.0 or later.
6839
 
    '''
6840
 
    f = _Cfunctions.get('libvlc_audio_set_volume_callback', None) or \
6841
 
        _Cfunction('libvlc_audio_set_volume_callback', ((1,), (1,),), None,
6842
 
                   None, MediaPlayer, AudioSetVolumeCb)
6843
 
    return f(mp, set_volume)
6844
 
 
6845
 
 
6846
 
def libvlc_audio_set_format_callbacks(mp, setup, cleanup):
6847
 
    '''Sets decoded audio format via callbacks.
6848
 
    This only works in combination with L{libvlc_audio_set_callbacks}().
6849
 
    @param mp: the media player.
6850
 
    @param setup: callback to select the audio format (cannot be None).
6851
 
    @param cleanup: callback to release any allocated resources (or None).
6852
 
    @version: LibVLC 2.0.0 or later.
6853
 
    '''
6854
 
    f = _Cfunctions.get('libvlc_audio_set_format_callbacks', None) or \
6855
 
        _Cfunction('libvlc_audio_set_format_callbacks', ((1,), (1,), (1,),), None,
6856
 
                   None, MediaPlayer, AudioSetupCb, AudioCleanupCb)
6857
 
    return f(mp, setup, cleanup)
6858
 
 
6859
 
 
6860
 
def libvlc_audio_set_format(mp, format, rate, channels):
6861
 
    '''Sets a fixed decoded audio format.
6862
 
    This only works in combination with L{libvlc_audio_set_callbacks}(),
6863
 
    and is mutually exclusive with L{libvlc_audio_set_format_callbacks}().
6864
 
    @param mp: the media player.
6865
 
    @param format: a four-characters string identifying the sample format (e.g. "S16N" or "FL32").
6866
 
    @param rate: sample rate (expressed in Hz).
6867
 
    @param channels: channels count.
6868
 
    @version: LibVLC 2.0.0 or later.
6869
 
    '''
6870
 
    f = _Cfunctions.get('libvlc_audio_set_format', None) or \
6871
 
        _Cfunction('libvlc_audio_set_format', ((1,), (1,), (1,), (1,),), None,
6872
 
                   None, MediaPlayer, ctypes.c_char_p, ctypes.c_uint, ctypes.c_uint)
6873
 
    return f(mp, format, rate, channels)
6874
 
 
6875
 
 
6876
 
def libvlc_media_player_get_length(p_mi):
6877
 
    '''Get the current movie length (in ms).
6878
 
    @param p_mi: the Media Player.
6879
 
    @return: the movie length (in ms), or -1 if there is no media.
6880
 
    '''
6881
 
    f = _Cfunctions.get('libvlc_media_player_get_length', None) or \
6882
 
        _Cfunction('libvlc_media_player_get_length', ((1,),), None,
6883
 
                   ctypes.c_longlong, MediaPlayer)
6884
 
    return f(p_mi)
6885
 
 
6886
 
 
6887
 
def libvlc_media_player_get_time(p_mi):
6888
 
    '''Get the current movie time (in ms).
6889
 
    @param p_mi: the Media Player.
6890
 
    @return: the movie time (in ms), or -1 if there is no media.
6891
 
    '''
6892
 
    f = _Cfunctions.get('libvlc_media_player_get_time', None) or \
6893
 
        _Cfunction('libvlc_media_player_get_time', ((1,),), None,
6894
 
                   ctypes.c_longlong, MediaPlayer)
6895
 
    return f(p_mi)
6896
 
 
6897
 
 
6898
 
def libvlc_media_player_set_time(p_mi, i_time):
6899
 
    '''Set the movie time (in ms). This has no effect if no media is being played.
6900
 
    Not all formats and protocols support this.
6901
 
    @param p_mi: the Media Player.
6902
 
    @param i_time: the movie time (in ms).
6903
 
    '''
6904
 
    f = _Cfunctions.get('libvlc_media_player_set_time', None) or \
6905
 
        _Cfunction('libvlc_media_player_set_time', ((1,), (1,),), None,
6906
 
                   None, MediaPlayer, ctypes.c_longlong)
6907
 
    return f(p_mi, i_time)
6908
 
 
6909
 
 
6910
 
def libvlc_media_player_get_position(p_mi):
6911
 
    '''Get movie position as percentage between 0.0 and 1.0.
6912
 
    @param p_mi: the Media Player.
6913
 
    @return: movie position, or -1. in case of error.
6914
 
    '''
6915
 
    f = _Cfunctions.get('libvlc_media_player_get_position', None) or \
6916
 
        _Cfunction('libvlc_media_player_get_position', ((1,),), None,
6917
 
                   ctypes.c_float, MediaPlayer)
6918
 
    return f(p_mi)
6919
 
 
6920
 
 
6921
 
def libvlc_media_player_set_position(p_mi, f_pos):
6922
 
    '''Set movie position as percentage between 0.0 and 1.0.
6923
 
    This has no effect if playback is not enabled.
6924
 
    This might not work depending on the underlying input format and protocol.
6925
 
    @param p_mi: the Media Player.
6926
 
    @param f_pos: the position.
6927
 
    '''
6928
 
    f = _Cfunctions.get('libvlc_media_player_set_position', None) or \
6929
 
        _Cfunction('libvlc_media_player_set_position', ((1,), (1,),), None,
6930
 
                   None, MediaPlayer, ctypes.c_float)
6931
 
    return f(p_mi, f_pos)
6932
 
 
6933
 
 
6934
 
def libvlc_media_player_set_chapter(p_mi, i_chapter):
6935
 
    '''Set movie chapter (if applicable).
6936
 
    @param p_mi: the Media Player.
6937
 
    @param i_chapter: chapter number to play.
6938
 
    '''
6939
 
    f = _Cfunctions.get('libvlc_media_player_set_chapter', None) or \
6940
 
        _Cfunction('libvlc_media_player_set_chapter', ((1,), (1,),), None,
6941
 
                   None, MediaPlayer, ctypes.c_int)
6942
 
    return f(p_mi, i_chapter)
6943
 
 
6944
 
 
6945
 
def libvlc_media_player_get_chapter(p_mi):
6946
 
    '''Get movie chapter.
6947
 
    @param p_mi: the Media Player.
6948
 
    @return: chapter number currently playing, or -1 if there is no media.
6949
 
    '''
6950
 
    f = _Cfunctions.get('libvlc_media_player_get_chapter', None) or \
6951
 
        _Cfunction('libvlc_media_player_get_chapter', ((1,),), None,
6952
 
                   ctypes.c_int, MediaPlayer)
6953
 
    return f(p_mi)
6954
 
 
6955
 
 
6956
 
def libvlc_media_player_get_chapter_count(p_mi):
6957
 
    '''Get movie chapter count.
6958
 
    @param p_mi: the Media Player.
6959
 
    @return: number of chapters in movie, or -1.
6960
 
    '''
6961
 
    f = _Cfunctions.get('libvlc_media_player_get_chapter_count', None) or \
6962
 
        _Cfunction('libvlc_media_player_get_chapter_count', ((1,),), None,
6963
 
                   ctypes.c_int, MediaPlayer)
6964
 
    return f(p_mi)
6965
 
 
6966
 
 
6967
 
def libvlc_media_player_will_play(p_mi):
6968
 
    '''Is the player able to play.
6969
 
    @param p_mi: the Media Player.
6970
 
    @return: boolean \libvlc_return_bool.
6971
 
    '''
6972
 
    f = _Cfunctions.get('libvlc_media_player_will_play', None) or \
6973
 
        _Cfunction('libvlc_media_player_will_play', ((1,),), None,
6974
 
                   ctypes.c_int, MediaPlayer)
6975
 
    return f(p_mi)
6976
 
 
6977
 
 
6978
 
def libvlc_media_player_get_chapter_count_for_title(p_mi, i_title):
6979
 
    '''Get title chapter count.
6980
 
    @param p_mi: the Media Player.
6981
 
    @param i_title: title.
6982
 
    @return: number of chapters in title, or -1.
6983
 
    '''
6984
 
    f = _Cfunctions.get('libvlc_media_player_get_chapter_count_for_title', None) or \
6985
 
        _Cfunction('libvlc_media_player_get_chapter_count_for_title', ((1,), (1,),), None,
6986
 
                   ctypes.c_int, MediaPlayer, ctypes.c_int)
6987
 
    return f(p_mi, i_title)
6988
 
 
6989
 
 
6990
 
def libvlc_media_player_set_title(p_mi, i_title):
6991
 
    '''Set movie title.
6992
 
    @param p_mi: the Media Player.
6993
 
    @param i_title: title number to play.
6994
 
    '''
6995
 
    f = _Cfunctions.get('libvlc_media_player_set_title', None) or \
6996
 
        _Cfunction('libvlc_media_player_set_title', ((1,), (1,),), None,
6997
 
                   None, MediaPlayer, ctypes.c_int)
6998
 
    return f(p_mi, i_title)
6999
 
 
7000
 
 
7001
 
def libvlc_media_player_get_title(p_mi):
7002
 
    '''Get movie title.
7003
 
    @param p_mi: the Media Player.
7004
 
    @return: title number currently playing, or -1.
7005
 
    '''
7006
 
    f = _Cfunctions.get('libvlc_media_player_get_title', None) or \
7007
 
        _Cfunction('libvlc_media_player_get_title', ((1,),), None,
7008
 
                   ctypes.c_int, MediaPlayer)
7009
 
    return f(p_mi)
7010
 
 
7011
 
 
7012
 
def libvlc_media_player_get_title_count(p_mi):
7013
 
    '''Get movie title count.
7014
 
    @param p_mi: the Media Player.
7015
 
    @return: title number count, or -1.
7016
 
    '''
7017
 
    f = _Cfunctions.get('libvlc_media_player_get_title_count', None) or \
7018
 
        _Cfunction('libvlc_media_player_get_title_count', ((1,),), None,
7019
 
                   ctypes.c_int, MediaPlayer)
7020
 
    return f(p_mi)
7021
 
 
7022
 
 
7023
 
def libvlc_media_player_previous_chapter(p_mi):
7024
 
    '''Set previous chapter (if applicable).
7025
 
    @param p_mi: the Media Player.
7026
 
    '''
7027
 
    f = _Cfunctions.get('libvlc_media_player_previous_chapter', None) or \
7028
 
        _Cfunction('libvlc_media_player_previous_chapter', ((1,),), None,
7029
 
                   None, MediaPlayer)
7030
 
    return f(p_mi)
7031
 
 
7032
 
 
7033
 
def libvlc_media_player_next_chapter(p_mi):
7034
 
    '''Set next chapter (if applicable).
7035
 
    @param p_mi: the Media Player.
7036
 
    '''
7037
 
    f = _Cfunctions.get('libvlc_media_player_next_chapter', None) or \
7038
 
        _Cfunction('libvlc_media_player_next_chapter', ((1,),), None,
7039
 
                   None, MediaPlayer)
7040
 
    return f(p_mi)
7041
 
 
7042
 
 
7043
 
def libvlc_media_player_get_rate(p_mi):
7044
 
    '''Get the requested movie play rate.
7045
 
    @warning: Depending on the underlying media, the requested rate may be
7046
 
    different from the real playback rate.
7047
 
    @param p_mi: the Media Player.
7048
 
    @return: movie play rate.
7049
 
    '''
7050
 
    f = _Cfunctions.get('libvlc_media_player_get_rate', None) or \
7051
 
        _Cfunction('libvlc_media_player_get_rate', ((1,),), None,
7052
 
                   ctypes.c_float, MediaPlayer)
7053
 
    return f(p_mi)
7054
 
 
7055
 
 
7056
 
def libvlc_media_player_set_rate(p_mi, rate):
7057
 
    '''Set movie play rate.
7058
 
    @param p_mi: the Media Player.
7059
 
    @param rate: movie play rate to set.
7060
 
    @return: -1 if an error was detected, 0 otherwise (but even then, it might not actually work depending on the underlying media protocol).
7061
 
    '''
7062
 
    f = _Cfunctions.get('libvlc_media_player_set_rate', None) or \
7063
 
        _Cfunction('libvlc_media_player_set_rate', ((1,), (1,),), None,
7064
 
                   ctypes.c_int, MediaPlayer, ctypes.c_float)
7065
 
    return f(p_mi, rate)
7066
 
 
7067
 
 
7068
 
def libvlc_media_player_get_state(p_mi):
7069
 
    '''Get current movie state.
7070
 
    @param p_mi: the Media Player.
7071
 
    @return: the current state of the media player (playing, paused, ...) See L{State}.
7072
 
    '''
7073
 
    f = _Cfunctions.get('libvlc_media_player_get_state', None) or \
7074
 
        _Cfunction('libvlc_media_player_get_state', ((1,),), None,
7075
 
                   State, MediaPlayer)
7076
 
    return f(p_mi)
7077
 
 
7078
 
 
7079
 
def libvlc_media_player_has_vout(p_mi):
7080
 
    '''How many video outputs does this media player have?
7081
 
    @param p_mi: the media player.
7082
 
    @return: the number of video outputs.
7083
 
    '''
7084
 
    f = _Cfunctions.get('libvlc_media_player_has_vout', None) or \
7085
 
        _Cfunction('libvlc_media_player_has_vout', ((1,),), None,
7086
 
                   ctypes.c_uint, MediaPlayer)
7087
 
    return f(p_mi)
7088
 
 
7089
 
 
7090
 
def libvlc_media_player_is_seekable(p_mi):
7091
 
    '''Is this media player seekable?
7092
 
    @param p_mi: the media player.
7093
 
    @return: true if the media player can seek \libvlc_return_bool.
7094
 
    '''
7095
 
    f = _Cfunctions.get('libvlc_media_player_is_seekable', None) or \
7096
 
        _Cfunction('libvlc_media_player_is_seekable', ((1,),), None,
7097
 
                   ctypes.c_int, MediaPlayer)
7098
 
    return f(p_mi)
7099
 
 
7100
 
 
7101
 
def libvlc_media_player_can_pause(p_mi):
7102
 
    '''Can this media player be paused?
7103
 
    @param p_mi: the media player.
7104
 
    @return: true if the media player can pause \libvlc_return_bool.
7105
 
    '''
7106
 
    f = _Cfunctions.get('libvlc_media_player_can_pause', None) or \
7107
 
        _Cfunction('libvlc_media_player_can_pause', ((1,),), None,
7108
 
                   ctypes.c_int, MediaPlayer)
7109
 
    return f(p_mi)
7110
 
 
7111
 
 
7112
 
def libvlc_media_player_program_scrambled(p_mi):
7113
 
    '''Check if the current program is scrambled.
7114
 
    @param p_mi: the media player.
7115
 
    @return: true if the current program is scrambled \libvlc_return_bool.
7116
 
    @version: LibVLC 2.2.0 or later.
7117
 
    '''
7118
 
    f = _Cfunctions.get('libvlc_media_player_program_scrambled', None) or \
7119
 
        _Cfunction('libvlc_media_player_program_scrambled', ((1,),), None,
7120
 
                   ctypes.c_int, MediaPlayer)
7121
 
    return f(p_mi)
7122
 
 
7123
 
 
7124
 
def libvlc_media_player_next_frame(p_mi):
7125
 
    '''Display the next frame (if supported).
7126
 
    @param p_mi: the media player.
7127
 
    '''
7128
 
    f = _Cfunctions.get('libvlc_media_player_next_frame', None) or \
7129
 
        _Cfunction('libvlc_media_player_next_frame', ((1,),), None,
7130
 
                   None, MediaPlayer)
7131
 
    return f(p_mi)
7132
 
 
7133
 
 
7134
 
def libvlc_media_player_navigate(p_mi, navigate):
7135
 
    '''Navigate through DVD Menu.
7136
 
    @param p_mi: the Media Player.
7137
 
    @param navigate: the Navigation mode.
7138
 
    @version: libVLC 2.0.0 or later.
7139
 
    '''
7140
 
    f = _Cfunctions.get('libvlc_media_player_navigate', None) or \
7141
 
        _Cfunction('libvlc_media_player_navigate', ((1,), (1,),), None,
7142
 
                   None, MediaPlayer, ctypes.c_uint)
7143
 
    return f(p_mi, navigate)
7144
 
 
7145
 
 
7146
 
def libvlc_media_player_set_video_title_display(p_mi, position, timeout):
7147
 
    '''Set if, and how, the video title will be shown when media is played.
7148
 
    @param p_mi: the media player.
7149
 
    @param position: position at which to display the title, or libvlc_position_disable to prevent the title from being displayed.
7150
 
    @param timeout: title display timeout in milliseconds (ignored if libvlc_position_disable).
7151
 
    @version: libVLC 2.1.0 or later.
7152
 
    '''
7153
 
    f = _Cfunctions.get('libvlc_media_player_set_video_title_display', None) or \
7154
 
        _Cfunction('libvlc_media_player_set_video_title_display', ((1,), (1,), (1,),), None,
7155
 
                   None, MediaPlayer, Position, ctypes.c_int)
7156
 
    return f(p_mi, position, timeout)
7157
 
 
7158
 
 
7159
 
def libvlc_media_player_add_slave(p_mi, i_type, psz_uri, b_select):
7160
 
    '''Add a slave to the current media player.
7161
 
    @note: If the player is playing, the slave will be added directly. This call
7162
 
    will also update the slave list of the attached L{Media}.
7163
 
    @param p_mi: the media player.
7164
 
    @param i_type: subtitle or audio.
7165
 
    @param psz_uri: Uri of the slave (should contain a valid scheme).
7166
 
    @param b_select: True if this slave should be selected when it's loaded.
7167
 
    @return: 0 on success, -1 on error.
7168
 
    @version: LibVLC 3.0.0 and later. See L{libvlc_media_slaves_add}.
7169
 
    '''
7170
 
    f = _Cfunctions.get('libvlc_media_player_add_slave', None) or \
7171
 
        _Cfunction('libvlc_media_player_add_slave', ((1,), (1,), (1,), (1,),), None,
7172
 
                   ctypes.c_int, MediaPlayer, MediaSlaveType, ctypes.c_char_p, ctypes.c_bool)
7173
 
    return f(p_mi, i_type, psz_uri, b_select)
7174
 
 
7175
 
 
7176
 
def libvlc_track_description_list_release(p_track_description):
7177
 
    '''Release (free) L{TrackDescription}.
7178
 
    @param p_track_description: the structure to release.
7179
 
    '''
7180
 
    f = _Cfunctions.get('libvlc_track_description_list_release', None) or \
7181
 
        _Cfunction('libvlc_track_description_list_release', ((1,),), None,
7182
 
                   None, ctypes.POINTER(TrackDescription))
7183
 
    return f(p_track_description)
7184
 
 
7185
 
 
7186
 
def libvlc_toggle_fullscreen(p_mi):
7187
 
    '''Toggle fullscreen status on non-embedded video outputs.
7188
 
    @warning: The same limitations applies to this function
7189
 
    as to L{libvlc_set_fullscreen}().
7190
 
    @param p_mi: the media player.
7191
 
    '''
7192
 
    f = _Cfunctions.get('libvlc_toggle_fullscreen', None) or \
7193
 
        _Cfunction('libvlc_toggle_fullscreen', ((1,),), None,
7194
 
                   None, MediaPlayer)
7195
 
    return f(p_mi)
7196
 
 
7197
 
 
7198
 
def libvlc_set_fullscreen(p_mi, b_fullscreen):
7199
 
    '''Enable or disable fullscreen.
7200
 
    @warning: With most window managers, only a top-level windows can be in
7201
 
    full-screen mode. Hence, this function will not operate properly if
7202
 
    L{libvlc_media_player_set_xwindow}() was used to embed the video in a
7203
 
    non-top-level window. In that case, the embedding window must be reparented
7204
 
    to the root window B{before} fullscreen mode is enabled. You will want
7205
 
    to reparent it back to its normal parent when disabling fullscreen.
7206
 
    @param p_mi: the media player.
7207
 
    @param b_fullscreen: boolean for fullscreen status.
7208
 
    '''
7209
 
    f = _Cfunctions.get('libvlc_set_fullscreen', None) or \
7210
 
        _Cfunction('libvlc_set_fullscreen', ((1,), (1,),), None,
7211
 
                   None, MediaPlayer, ctypes.c_int)
7212
 
    return f(p_mi, b_fullscreen)
7213
 
 
7214
 
 
7215
 
def libvlc_get_fullscreen(p_mi):
7216
 
    '''Get current fullscreen status.
7217
 
    @param p_mi: the media player.
7218
 
    @return: the fullscreen status (boolean) \libvlc_return_bool.
7219
 
    '''
7220
 
    f = _Cfunctions.get('libvlc_get_fullscreen', None) or \
7221
 
        _Cfunction('libvlc_get_fullscreen', ((1,),), None,
7222
 
                   ctypes.c_int, MediaPlayer)
7223
 
    return f(p_mi)
7224
 
 
7225
 
 
7226
 
def libvlc_video_set_key_input(p_mi, on):
7227
 
    '''Enable or disable key press events handling, according to the LibVLC hotkeys
7228
 
    configuration. By default and for historical reasons, keyboard events are
7229
 
    handled by the LibVLC video widget.
7230
 
    @note: On X11, there can be only one subscriber for key press and mouse
7231
 
    click events per window. If your application has subscribed to those events
7232
 
    for the X window ID of the video widget, then LibVLC will not be able to
7233
 
    handle key presses and mouse clicks in any case.
7234
 
    @warning: This function is only implemented for X11 and Win32 at the moment.
7235
 
    @param p_mi: the media player.
7236
 
    @param on: true to handle key press events, false to ignore them.
7237
 
    '''
7238
 
    f = _Cfunctions.get('libvlc_video_set_key_input', None) or \
7239
 
        _Cfunction('libvlc_video_set_key_input', ((1,), (1,),), None,
7240
 
                   None, MediaPlayer, ctypes.c_uint)
7241
 
    return f(p_mi, on)
7242
 
 
7243
 
 
7244
 
def libvlc_video_set_mouse_input(p_mi, on):
7245
 
    '''Enable or disable mouse click events handling. By default, those events are
7246
 
    handled. This is needed for DVD menus to work, as well as a few video
7247
 
    filters such as "puzzle".
7248
 
    See L{libvlc_video_set_key_input}().
7249
 
    @warning: This function is only implemented for X11 and Win32 at the moment.
7250
 
    @param p_mi: the media player.
7251
 
    @param on: true to handle mouse click events, false to ignore them.
7252
 
    '''
7253
 
    f = _Cfunctions.get('libvlc_video_set_mouse_input', None) or \
7254
 
        _Cfunction('libvlc_video_set_mouse_input', ((1,), (1,),), None,
7255
 
                   None, MediaPlayer, ctypes.c_uint)
7256
 
    return f(p_mi, on)
7257
 
 
7258
 
 
7259
 
def libvlc_video_get_size(p_mi, num):
7260
 
    '''Get the pixel dimensions of a video.
7261
 
    @param p_mi: media player.
7262
 
    @param num: number of the video (starting from, and most commonly 0).
7263
 
    @return: px pixel width, py pixel height.
7264
 
    '''
7265
 
    f = _Cfunctions.get('libvlc_video_get_size', None) or \
7266
 
        _Cfunction('libvlc_video_get_size', ((1,), (1,), (2,), (2,),), None,
7267
 
                   ctypes.c_int, MediaPlayer, ctypes.c_uint, ctypes.POINTER(ctypes.c_uint),
7268
 
                   ctypes.POINTER(ctypes.c_uint))
7269
 
    return f(p_mi, num)
7270
 
 
7271
 
 
7272
 
def libvlc_video_get_cursor(p_mi, num):
7273
 
    '''Get the mouse pointer coordinates over a video.
7274
 
    Coordinates are expressed in terms of the decoded video resolution,
7275
 
    B{not} in terms of pixels on the screen/viewport (to get the latter,
7276
 
    you can query your windowing system directly).
7277
 
    Either of the coordinates may be negative or larger than the corresponding
7278
 
    dimension of the video, if the cursor is outside the rendering area.
7279
 
    @warning: The coordinates may be out-of-date if the pointer is not located
7280
 
    on the video rendering area. LibVLC does not track the pointer if it is
7281
 
    outside of the video widget.
7282
 
    @note: LibVLC does not support multiple pointers (it does of course support
7283
 
    multiple input devices sharing the same pointer) at the moment.
7284
 
    @param p_mi: media player.
7285
 
    @param num: number of the video (starting from, and most commonly 0).
7286
 
    @return: px abscissa, py ordinate.
7287
 
    '''
7288
 
    f = _Cfunctions.get('libvlc_video_get_cursor', None) or \
7289
 
        _Cfunction('libvlc_video_get_cursor', ((1,), (1,), (2,), (2,),), None,
7290
 
                   ctypes.c_int, MediaPlayer, ctypes.c_uint, ctypes.POINTER(ctypes.c_int), ctypes.POINTER(ctypes.c_int))
7291
 
    return f(p_mi, num)
7292
 
 
7293
 
 
7294
 
def libvlc_video_get_scale(p_mi):
7295
 
    '''Get the current video scaling factor.
7296
 
    See also L{libvlc_video_set_scale}().
7297
 
    @param p_mi: the media player.
7298
 
    @return: the currently configured zoom factor, or 0. if the video is set to fit to the output window/drawable automatically.
7299
 
    '''
7300
 
    f = _Cfunctions.get('libvlc_video_get_scale', None) or \
7301
 
        _Cfunction('libvlc_video_get_scale', ((1,),), None,
7302
 
                   ctypes.c_float, MediaPlayer)
7303
 
    return f(p_mi)
7304
 
 
7305
 
 
7306
 
def libvlc_video_set_scale(p_mi, f_factor):
7307
 
    '''Set the video scaling factor. That is the ratio of the number of pixels on
7308
 
    screen to the number of pixels in the original decoded video in each
7309
 
    dimension. Zero is a special value; it will adjust the video to the output
7310
 
    window/drawable (in windowed mode) or the entire screen.
7311
 
    Note that not all video outputs support scaling.
7312
 
    @param p_mi: the media player.
7313
 
    @param f_factor: the scaling factor, or zero.
7314
 
    '''
7315
 
    f = _Cfunctions.get('libvlc_video_set_scale', None) or \
7316
 
        _Cfunction('libvlc_video_set_scale', ((1,), (1,),), None,
7317
 
                   None, MediaPlayer, ctypes.c_float)
7318
 
    return f(p_mi, f_factor)
7319
 
 
7320
 
 
7321
 
def libvlc_video_get_aspect_ratio(p_mi):
7322
 
    '''Get current video aspect ratio.
7323
 
    @param p_mi: the media player.
7324
 
    @return: the video aspect ratio or None if unspecified (the result must be released with free() or L{libvlc_free}()).
7325
 
    '''
7326
 
    f = _Cfunctions.get('libvlc_video_get_aspect_ratio', None) or \
7327
 
        _Cfunction('libvlc_video_get_aspect_ratio', ((1,),), string_result,
7328
 
                   ctypes.c_void_p, MediaPlayer)
7329
 
    return f(p_mi)
7330
 
 
7331
 
 
7332
 
def libvlc_video_set_aspect_ratio(p_mi, psz_aspect):
7333
 
    '''Set new video aspect ratio.
7334
 
    @param p_mi: the media player.
7335
 
    @param psz_aspect: new video aspect-ratio or None to reset to default @note Invalid aspect ratios are ignored.
7336
 
    '''
7337
 
    f = _Cfunctions.get('libvlc_video_set_aspect_ratio', None) or \
7338
 
        _Cfunction('libvlc_video_set_aspect_ratio', ((1,), (1,),), None,
7339
 
                   None, MediaPlayer, ctypes.c_char_p)
7340
 
    return f(p_mi, psz_aspect)
7341
 
 
7342
 
 
7343
 
def libvlc_video_new_viewpoint():
7344
 
    '''Create a video viewpoint structure.
7345
 
    @return: video viewpoint or None (the result must be released with free() or L{libvlc_free}()).
7346
 
    @version: LibVLC 3.0.0 and later.
7347
 
    '''
7348
 
    f = _Cfunctions.get('libvlc_video_new_viewpoint', None) or \
7349
 
        _Cfunction('libvlc_video_new_viewpoint', (), None,
7350
 
                   ctypes.POINTER(VideoViewpoint))
7351
 
    return f()
7352
 
 
7353
 
 
7354
 
def libvlc_video_update_viewpoint(p_mi, p_viewpoint, b_absolute):
7355
 
    '''Update the video viewpoint information.
7356
 
    @note: It is safe to call this function before the media player is started.
7357
 
    @param p_mi: the media player.
7358
 
    @param p_viewpoint: video viewpoint allocated via L{libvlc_video_new_viewpoint}().
7359
 
    @param b_absolute: if true replace the old viewpoint with the new one. If false, increase/decrease it.
7360
 
    @return: -1 in case of error, 0 otherwise @note the values are set asynchronously, it will be used by the next frame displayed.
7361
 
    @version: LibVLC 3.0.0 and later.
7362
 
    '''
7363
 
    f = _Cfunctions.get('libvlc_video_update_viewpoint', None) or \
7364
 
        _Cfunction('libvlc_video_update_viewpoint', ((1,), (1,), (1,),), None,
7365
 
                   ctypes.c_int, MediaPlayer, ctypes.POINTER(VideoViewpoint), ctypes.c_bool)
7366
 
    return f(p_mi, p_viewpoint, b_absolute)
7367
 
 
7368
 
 
7369
 
def libvlc_video_get_spu(p_mi):
7370
 
    '''Get current video subtitle.
7371
 
    @param p_mi: the media player.
7372
 
    @return: the video subtitle selected, or -1 if none.
7373
 
    '''
7374
 
    f = _Cfunctions.get('libvlc_video_get_spu', None) or \
7375
 
        _Cfunction('libvlc_video_get_spu', ((1,),), None,
7376
 
                   ctypes.c_int, MediaPlayer)
7377
 
    return f(p_mi)
7378
 
 
7379
 
 
7380
 
def libvlc_video_get_spu_count(p_mi):
7381
 
    '''Get the number of available video subtitles.
7382
 
    @param p_mi: the media player.
7383
 
    @return: the number of available video subtitles.
7384
 
    '''
7385
 
    f = _Cfunctions.get('libvlc_video_get_spu_count', None) or \
7386
 
        _Cfunction('libvlc_video_get_spu_count', ((1,),), None,
7387
 
                   ctypes.c_int, MediaPlayer)
7388
 
    return f(p_mi)
7389
 
 
7390
 
 
7391
 
def libvlc_video_get_spu_description(p_mi):
7392
 
    '''Get the description of available video subtitles.
7393
 
    @param p_mi: the media player.
7394
 
    @return: list containing description of available video subtitles. It must be freed with L{libvlc_track_description_list_release}().
7395
 
    '''
7396
 
    f = _Cfunctions.get('libvlc_video_get_spu_description', None) or \
7397
 
        _Cfunction('libvlc_video_get_spu_description', ((1,),), None,
7398
 
                   ctypes.POINTER(TrackDescription), MediaPlayer)
7399
 
    return f(p_mi)
7400
 
 
7401
 
 
7402
 
def libvlc_video_set_spu(p_mi, i_spu):
7403
 
    '''Set new video subtitle.
7404
 
    @param p_mi: the media player.
7405
 
    @param i_spu: video subtitle track to select (i_id from track description).
7406
 
    @return: 0 on success, -1 if out of range.
7407
 
    '''
7408
 
    f = _Cfunctions.get('libvlc_video_set_spu', None) or \
7409
 
        _Cfunction('libvlc_video_set_spu', ((1,), (1,),), None,
7410
 
                   ctypes.c_int, MediaPlayer, ctypes.c_int)
7411
 
    return f(p_mi, i_spu)
7412
 
 
7413
 
 
7414
 
def libvlc_video_get_spu_delay(p_mi):
7415
 
    '''Get the current subtitle delay. Positive values means subtitles are being
7416
 
    displayed later, negative values earlier.
7417
 
    @param p_mi: media player.
7418
 
    @return: time (in microseconds) the display of subtitles is being delayed.
7419
 
    @version: LibVLC 2.0.0 or later.
7420
 
    '''
7421
 
    f = _Cfunctions.get('libvlc_video_get_spu_delay', None) or \
7422
 
        _Cfunction('libvlc_video_get_spu_delay', ((1,),), None,
7423
 
                   ctypes.c_int64, MediaPlayer)
7424
 
    return f(p_mi)
7425
 
 
7426
 
 
7427
 
def libvlc_video_set_spu_delay(p_mi, i_delay):
7428
 
    '''Set the subtitle delay. This affects the timing of when the subtitle will
7429
 
    be displayed. Positive values result in subtitles being displayed later,
7430
 
    while negative values will result in subtitles being displayed earlier.
7431
 
    The subtitle delay will be reset to zero each time the media changes.
7432
 
    @param p_mi: media player.
7433
 
    @param i_delay: time (in microseconds) the display of subtitles should be delayed.
7434
 
    @return: 0 on success, -1 on error.
7435
 
    @version: LibVLC 2.0.0 or later.
7436
 
    '''
7437
 
    f = _Cfunctions.get('libvlc_video_set_spu_delay', None) or \
7438
 
        _Cfunction('libvlc_video_set_spu_delay', ((1,), (1,),), None,
7439
 
                   ctypes.c_int, MediaPlayer, ctypes.c_int64)
7440
 
    return f(p_mi, i_delay)
7441
 
 
7442
 
 
7443
 
def libvlc_media_player_get_full_title_descriptions(p_mi, titles):
7444
 
    '''Get the full description of available titles.
7445
 
    @param p_mi: the media player.
7446
 
    @param titles: address to store an allocated array of title descriptions descriptions (must be freed with L{libvlc_title_descriptions_release}() by the caller) [OUT].
7447
 
    @return: the number of titles (-1 on error).
7448
 
    @version: LibVLC 3.0.0 and later.
7449
 
    '''
7450
 
    f = _Cfunctions.get('libvlc_media_player_get_full_title_descriptions', None) or \
7451
 
        _Cfunction('libvlc_media_player_get_full_title_descriptions', ((1,), (1,),), None,
7452
 
                   ctypes.c_int, MediaPlayer, ctypes.POINTER(ctypes.POINTER(TitleDescription)))
7453
 
    return f(p_mi, titles)
7454
 
 
7455
 
 
7456
 
def libvlc_title_descriptions_release(p_titles, i_count):
7457
 
    '''Release a title description.
7458
 
    @param p_titles: title description array to release.
7459
 
    @param i_count: number of title descriptions to release.
7460
 
    @version: LibVLC 3.0.0 and later.
7461
 
    '''
7462
 
    f = _Cfunctions.get('libvlc_title_descriptions_release', None) or \
7463
 
        _Cfunction('libvlc_title_descriptions_release', ((1,), (1,),), None,
7464
 
                   None, ctypes.POINTER(TitleDescription), ctypes.c_uint)
7465
 
    return f(p_titles, i_count)
7466
 
 
7467
 
 
7468
 
def libvlc_media_player_get_full_chapter_descriptions(p_mi, i_chapters_of_title, pp_chapters):
7469
 
    '''Get the full description of available chapters.
7470
 
    @param p_mi: the media player.
7471
 
    @param i_chapters_of_title: index of the title to query for chapters (uses current title if set to -1).
7472
 
    @param pp_chapters: address to store an allocated array of chapter descriptions descriptions (must be freed with L{libvlc_chapter_descriptions_release}() by the caller) [OUT].
7473
 
    @return: the number of chapters (-1 on error).
7474
 
    @version: LibVLC 3.0.0 and later.
7475
 
    '''
7476
 
    f = _Cfunctions.get('libvlc_media_player_get_full_chapter_descriptions', None) or \
7477
 
        _Cfunction('libvlc_media_player_get_full_chapter_descriptions', ((1,), (1,), (1,),), None,
7478
 
                   ctypes.c_int, MediaPlayer, ctypes.c_int, ctypes.POINTER(ctypes.POINTER(ChapterDescription)))
7479
 
    return f(p_mi, i_chapters_of_title, pp_chapters)
7480
 
 
7481
 
 
7482
 
def libvlc_chapter_descriptions_release(p_chapters, i_count):
7483
 
    '''Release a chapter description.
7484
 
    @param p_chapters: chapter description array to release.
7485
 
    @param i_count: number of chapter descriptions to release.
7486
 
    @version: LibVLC 3.0.0 and later.
7487
 
    '''
7488
 
    f = _Cfunctions.get('libvlc_chapter_descriptions_release', None) or \
7489
 
        _Cfunction('libvlc_chapter_descriptions_release', ((1,), (1,),), None,
7490
 
                   None, ctypes.POINTER(ChapterDescription), ctypes.c_uint)
7491
 
    return f(p_chapters, i_count)
7492
 
 
7493
 
 
7494
 
def libvlc_video_get_crop_geometry(p_mi):
7495
 
    '''Get current crop filter geometry.
7496
 
    @param p_mi: the media player.
7497
 
    @return: the crop filter geometry or None if unset.
7498
 
    '''
7499
 
    f = _Cfunctions.get('libvlc_video_get_crop_geometry', None) or \
7500
 
        _Cfunction('libvlc_video_get_crop_geometry', ((1,),), string_result,
7501
 
                   ctypes.c_void_p, MediaPlayer)
7502
 
    return f(p_mi)
7503
 
 
7504
 
 
7505
 
def libvlc_video_set_crop_geometry(p_mi, psz_geometry):
7506
 
    '''Set new crop filter geometry.
7507
 
    @param p_mi: the media player.
7508
 
    @param psz_geometry: new crop filter geometry (None to unset).
7509
 
    '''
7510
 
    f = _Cfunctions.get('libvlc_video_set_crop_geometry', None) or \
7511
 
        _Cfunction('libvlc_video_set_crop_geometry', ((1,), (1,),), None,
7512
 
                   None, MediaPlayer, ctypes.c_char_p)
7513
 
    return f(p_mi, psz_geometry)
7514
 
 
7515
 
 
7516
 
def libvlc_video_get_teletext(p_mi):
7517
 
    '''Get current teletext page requested or 0 if it's disabled.
7518
 
    Teletext is disabled by default, call L{libvlc_video_set_teletext}() to enable
7519
 
    it.
7520
 
    @param p_mi: the media player.
7521
 
    @return: the current teletext page requested.
7522
 
    '''
7523
 
    f = _Cfunctions.get('libvlc_video_get_teletext', None) or \
7524
 
        _Cfunction('libvlc_video_get_teletext', ((1,),), None,
7525
 
                   ctypes.c_int, MediaPlayer)
7526
 
    return f(p_mi)
7527
 
 
7528
 
 
7529
 
def libvlc_video_set_teletext(p_mi, i_page):
7530
 
    '''Set new teletext page to retrieve.
7531
 
    This function can also be used to send a teletext key.
7532
 
    @param p_mi: the media player.
7533
 
    @param i_page: teletex page number requested. This value can be 0 to disable teletext, a number in the range ]0;1000[ to show the requested page, or a \ref L{TeletextKey}. 100 is the default teletext page.
7534
 
    '''
7535
 
    f = _Cfunctions.get('libvlc_video_set_teletext', None) or \
7536
 
        _Cfunction('libvlc_video_set_teletext', ((1,), (1,),), None,
7537
 
                   None, MediaPlayer, ctypes.c_int)
7538
 
    return f(p_mi, i_page)
7539
 
 
7540
 
 
7541
 
def libvlc_video_get_track_count(p_mi):
7542
 
    '''Get number of available video tracks.
7543
 
    @param p_mi: media player.
7544
 
    @return: the number of available video tracks (int).
7545
 
    '''
7546
 
    f = _Cfunctions.get('libvlc_video_get_track_count', None) or \
7547
 
        _Cfunction('libvlc_video_get_track_count', ((1,),), None,
7548
 
                   ctypes.c_int, MediaPlayer)
7549
 
    return f(p_mi)
7550
 
 
7551
 
 
7552
 
def libvlc_video_get_track_description(p_mi):
7553
 
    '''Get the description of available video tracks.
7554
 
    @param p_mi: media player.
7555
 
    @return: list with description of available video tracks, or None on error. It must be freed with L{libvlc_track_description_list_release}().
7556
 
    '''
7557
 
    f = _Cfunctions.get('libvlc_video_get_track_description', None) or \
7558
 
        _Cfunction('libvlc_video_get_track_description', ((1,),), None,
7559
 
                   ctypes.POINTER(TrackDescription), MediaPlayer)
7560
 
    return f(p_mi)
7561
 
 
7562
 
 
7563
 
def libvlc_video_get_track(p_mi):
7564
 
    '''Get current video track.
7565
 
    @param p_mi: media player.
7566
 
    @return: the video track ID (int) or -1 if no active input.
7567
 
    '''
7568
 
    f = _Cfunctions.get('libvlc_video_get_track', None) or \
7569
 
        _Cfunction('libvlc_video_get_track', ((1,),), None,
7570
 
                   ctypes.c_int, MediaPlayer)
7571
 
    return f(p_mi)
7572
 
 
7573
 
 
7574
 
def libvlc_video_set_track(p_mi, i_track):
7575
 
    '''Set video track.
7576
 
    @param p_mi: media player.
7577
 
    @param i_track: the track ID (i_id field from track description).
7578
 
    @return: 0 on success, -1 if out of range.
7579
 
    '''
7580
 
    f = _Cfunctions.get('libvlc_video_set_track', None) or \
7581
 
        _Cfunction('libvlc_video_set_track', ((1,), (1,),), None,
7582
 
                   ctypes.c_int, MediaPlayer, ctypes.c_int)
7583
 
    return f(p_mi, i_track)
7584
 
 
7585
 
 
7586
 
def libvlc_video_take_snapshot(p_mi, num, psz_filepath, i_width, i_height):
7587
 
    '''Take a snapshot of the current video window.
7588
 
    If i_width AND i_height is 0, original size is used.
7589
 
    If i_width XOR i_height is 0, original aspect-ratio is preserved.
7590
 
    @param p_mi: media player instance.
7591
 
    @param num: number of video output (typically 0 for the first/only one).
7592
 
    @param psz_filepath: the path of a file or a folder to save the screenshot into.
7593
 
    @param i_width: the snapshot's width.
7594
 
    @param i_height: the snapshot's height.
7595
 
    @return: 0 on success, -1 if the video was not found.
7596
 
    '''
7597
 
    f = _Cfunctions.get('libvlc_video_take_snapshot', None) or \
7598
 
        _Cfunction('libvlc_video_take_snapshot', ((1,), (1,), (1,), (1,), (1,),), None,
7599
 
                   ctypes.c_int, MediaPlayer, ctypes.c_uint, ctypes.c_char_p, ctypes.c_int, ctypes.c_int)
7600
 
    return f(p_mi, num, psz_filepath, i_width, i_height)
7601
 
 
7602
 
 
7603
 
def libvlc_video_set_deinterlace(p_mi, psz_mode):
7604
 
    '''Enable or disable deinterlace filter.
7605
 
    @param p_mi: libvlc media player.
7606
 
    @param psz_mode: type of deinterlace filter, None to disable.
7607
 
    '''
7608
 
    f = _Cfunctions.get('libvlc_video_set_deinterlace', None) or \
7609
 
        _Cfunction('libvlc_video_set_deinterlace', ((1,), (1,),), None,
7610
 
                   None, MediaPlayer, ctypes.c_char_p)
7611
 
    return f(p_mi, psz_mode)
7612
 
 
7613
 
 
7614
 
def libvlc_video_get_marquee_int(p_mi, option):
7615
 
    '''Get an integer marquee option value.
7616
 
    @param p_mi: libvlc media player.
7617
 
    @param option: marq option to get See libvlc_video_marquee_int_option_t.
7618
 
    '''
7619
 
    f = _Cfunctions.get('libvlc_video_get_marquee_int', None) or \
7620
 
        _Cfunction('libvlc_video_get_marquee_int', ((1,), (1,),), None,
7621
 
                   ctypes.c_int, MediaPlayer, ctypes.c_uint)
7622
 
    return f(p_mi, option)
7623
 
 
7624
 
 
7625
 
def libvlc_video_get_marquee_string(p_mi, option):
7626
 
    '''Get a string marquee option value.
7627
 
    @param p_mi: libvlc media player.
7628
 
    @param option: marq option to get See libvlc_video_marquee_string_option_t.
7629
 
    '''
7630
 
    f = _Cfunctions.get('libvlc_video_get_marquee_string', None) or \
7631
 
        _Cfunction('libvlc_video_get_marquee_string', ((1,), (1,),), string_result,
7632
 
                   ctypes.c_void_p, MediaPlayer, ctypes.c_uint)
7633
 
    return f(p_mi, option)
7634
 
 
7635
 
 
7636
 
def libvlc_video_set_marquee_int(p_mi, option, i_val):
7637
 
    '''Enable, disable or set an integer marquee option
7638
 
    Setting libvlc_marquee_Enable has the side effect of enabling (arg !0)
7639
 
    or disabling (arg 0) the marq filter.
7640
 
    @param p_mi: libvlc media player.
7641
 
    @param option: marq option to set See libvlc_video_marquee_int_option_t.
7642
 
    @param i_val: marq option value.
7643
 
    '''
7644
 
    f = _Cfunctions.get('libvlc_video_set_marquee_int', None) or \
7645
 
        _Cfunction('libvlc_video_set_marquee_int', ((1,), (1,), (1,),), None,
7646
 
                   None, MediaPlayer, ctypes.c_uint, ctypes.c_int)
7647
 
    return f(p_mi, option, i_val)
7648
 
 
7649
 
 
7650
 
def libvlc_video_set_marquee_string(p_mi, option, psz_text):
7651
 
    '''Set a marquee string option.
7652
 
    @param p_mi: libvlc media player.
7653
 
    @param option: marq option to set See libvlc_video_marquee_string_option_t.
7654
 
    @param psz_text: marq option value.
7655
 
    '''
7656
 
    f = _Cfunctions.get('libvlc_video_set_marquee_string', None) or \
7657
 
        _Cfunction('libvlc_video_set_marquee_string', ((1,), (1,), (1,),), None,
7658
 
                   None, MediaPlayer, ctypes.c_uint, ctypes.c_char_p)
7659
 
    return f(p_mi, option, psz_text)
7660
 
 
7661
 
 
7662
 
def libvlc_video_get_logo_int(p_mi, option):
7663
 
    '''Get integer logo option.
7664
 
    @param p_mi: libvlc media player instance.
7665
 
    @param option: logo option to get, values of L{VideoLogoOption}.
7666
 
    '''
7667
 
    f = _Cfunctions.get('libvlc_video_get_logo_int', None) or \
7668
 
        _Cfunction('libvlc_video_get_logo_int', ((1,), (1,),), None,
7669
 
                   ctypes.c_int, MediaPlayer, ctypes.c_uint)
7670
 
    return f(p_mi, option)
7671
 
 
7672
 
 
7673
 
def libvlc_video_set_logo_int(p_mi, option, value):
7674
 
    '''Set logo option as integer. Options that take a different type value
7675
 
    are ignored.
7676
 
    Passing libvlc_logo_enable as option value has the side effect of
7677
 
    starting (arg !0) or stopping (arg 0) the logo filter.
7678
 
    @param p_mi: libvlc media player instance.
7679
 
    @param option: logo option to set, values of L{VideoLogoOption}.
7680
 
    @param value: logo option value.
7681
 
    '''
7682
 
    f = _Cfunctions.get('libvlc_video_set_logo_int', None) or \
7683
 
        _Cfunction('libvlc_video_set_logo_int', ((1,), (1,), (1,),), None,
7684
 
                   None, MediaPlayer, ctypes.c_uint, ctypes.c_int)
7685
 
    return f(p_mi, option, value)
7686
 
 
7687
 
 
7688
 
def libvlc_video_set_logo_string(p_mi, option, psz_value):
7689
 
    '''Set logo option as string. Options that take a different type value
7690
 
    are ignored.
7691
 
    @param p_mi: libvlc media player instance.
7692
 
    @param option: logo option to set, values of L{VideoLogoOption}.
7693
 
    @param psz_value: logo option value.
7694
 
    '''
7695
 
    f = _Cfunctions.get('libvlc_video_set_logo_string', None) or \
7696
 
        _Cfunction('libvlc_video_set_logo_string', ((1,), (1,), (1,),), None,
7697
 
                   None, MediaPlayer, ctypes.c_uint, ctypes.c_char_p)
7698
 
    return f(p_mi, option, psz_value)
7699
 
 
7700
 
 
7701
 
def libvlc_video_get_adjust_int(p_mi, option):
7702
 
    '''Get integer adjust option.
7703
 
    @param p_mi: libvlc media player instance.
7704
 
    @param option: adjust option to get, values of L{VideoAdjustOption}.
7705
 
    @version: LibVLC 1.1.1 and later.
7706
 
    '''
7707
 
    f = _Cfunctions.get('libvlc_video_get_adjust_int', None) or \
7708
 
        _Cfunction('libvlc_video_get_adjust_int', ((1,), (1,),), None,
7709
 
                   ctypes.c_int, MediaPlayer, ctypes.c_uint)
7710
 
    return f(p_mi, option)
7711
 
 
7712
 
 
7713
 
def libvlc_video_set_adjust_int(p_mi, option, value):
7714
 
    '''Set adjust option as integer. Options that take a different type value
7715
 
    are ignored.
7716
 
    Passing libvlc_adjust_enable as option value has the side effect of
7717
 
    starting (arg !0) or stopping (arg 0) the adjust filter.
7718
 
    @param p_mi: libvlc media player instance.
7719
 
    @param option: adust option to set, values of L{VideoAdjustOption}.
7720
 
    @param value: adjust option value.
7721
 
    @version: LibVLC 1.1.1 and later.
7722
 
    '''
7723
 
    f = _Cfunctions.get('libvlc_video_set_adjust_int', None) or \
7724
 
        _Cfunction('libvlc_video_set_adjust_int', ((1,), (1,), (1,),), None,
7725
 
                   None, MediaPlayer, ctypes.c_uint, ctypes.c_int)
7726
 
    return f(p_mi, option, value)
7727
 
 
7728
 
 
7729
 
def libvlc_video_get_adjust_float(p_mi, option):
7730
 
    '''Get float adjust option.
7731
 
    @param p_mi: libvlc media player instance.
7732
 
    @param option: adjust option to get, values of L{VideoAdjustOption}.
7733
 
    @version: LibVLC 1.1.1 and later.
7734
 
    '''
7735
 
    f = _Cfunctions.get('libvlc_video_get_adjust_float', None) or \
7736
 
        _Cfunction('libvlc_video_get_adjust_float', ((1,), (1,),), None,
7737
 
                   ctypes.c_float, MediaPlayer, ctypes.c_uint)
7738
 
    return f(p_mi, option)
7739
 
 
7740
 
 
7741
 
def libvlc_video_set_adjust_float(p_mi, option, value):
7742
 
    '''Set adjust option as float. Options that take a different type value
7743
 
    are ignored.
7744
 
    @param p_mi: libvlc media player instance.
7745
 
    @param option: adust option to set, values of L{VideoAdjustOption}.
7746
 
    @param value: adjust option value.
7747
 
    @version: LibVLC 1.1.1 and later.
7748
 
    '''
7749
 
    f = _Cfunctions.get('libvlc_video_set_adjust_float', None) or \
7750
 
        _Cfunction('libvlc_video_set_adjust_float', ((1,), (1,), (1,),), None,
7751
 
                   None, MediaPlayer, ctypes.c_uint, ctypes.c_float)
7752
 
    return f(p_mi, option, value)
7753
 
 
7754
 
 
7755
 
def libvlc_audio_output_list_get(p_instance):
7756
 
    '''Gets the list of available audio output modules.
7757
 
    @param p_instance: libvlc instance.
7758
 
    @return: list of available audio outputs. It must be freed with In case of error, None is returned.
7759
 
    '''
7760
 
    f = _Cfunctions.get('libvlc_audio_output_list_get', None) or \
7761
 
        _Cfunction('libvlc_audio_output_list_get', ((1,),), None,
7762
 
                   ctypes.POINTER(AudioOutput), Instance)
7763
 
    return f(p_instance)
7764
 
 
7765
 
 
7766
 
def libvlc_audio_output_list_release(p_list):
7767
 
    '''Frees the list of available audio output modules.
7768
 
    @param p_list: list with audio outputs for release.
7769
 
    '''
7770
 
    f = _Cfunctions.get('libvlc_audio_output_list_release', None) or \
7771
 
        _Cfunction('libvlc_audio_output_list_release', ((1,),), None,
7772
 
                   None, ctypes.POINTER(AudioOutput))
7773
 
    return f(p_list)
7774
 
 
7775
 
 
7776
 
def libvlc_audio_output_set(p_mi, psz_name):
7777
 
    '''Selects an audio output module.
7778
 
    @note: Any change will take be effect only after playback is stopped and
7779
 
    restarted. Audio output cannot be changed while playing.
7780
 
    @param p_mi: media player.
7781
 
    @param psz_name: name of audio output, use psz_name of See L{AudioOutput}.
7782
 
    @return: 0 if function succeeded, -1 on error.
7783
 
    '''
7784
 
    f = _Cfunctions.get('libvlc_audio_output_set', None) or \
7785
 
        _Cfunction('libvlc_audio_output_set', ((1,), (1,),), None,
7786
 
                   ctypes.c_int, MediaPlayer, ctypes.c_char_p)
7787
 
    return f(p_mi, psz_name)
7788
 
 
7789
 
 
7790
 
def libvlc_audio_output_device_enum(mp):
7791
 
    '''Gets a list of potential audio output devices,
7792
 
    See L{libvlc_audio_output_device_set}().
7793
 
    @note: Not all audio outputs support enumerating devices.
7794
 
    The audio output may be functional even if the list is empty (None).
7795
 
    @note: The list may not be exhaustive.
7796
 
    @warning: Some audio output devices in the list might not actually work in
7797
 
    some circumstances. By default, it is recommended to not specify any
7798
 
    explicit audio device.
7799
 
    @param mp: media player.
7800
 
    @return: A None-terminated linked list of potential audio output devices. It must be freed with L{libvlc_audio_output_device_list_release}().
7801
 
    @version: LibVLC 2.2.0 or later.
7802
 
    '''
7803
 
    f = _Cfunctions.get('libvlc_audio_output_device_enum', None) or \
7804
 
        _Cfunction('libvlc_audio_output_device_enum', ((1,),), None,
7805
 
                   ctypes.POINTER(AudioOutputDevice), MediaPlayer)
7806
 
    return f(mp)
7807
 
 
7808
 
 
7809
 
def libvlc_audio_output_device_list_get(p_instance, aout):
7810
 
    '''Gets a list of audio output devices for a given audio output module,
7811
 
    See L{libvlc_audio_output_device_set}().
7812
 
    @note: Not all audio outputs support this. In particular, an empty (None)
7813
 
    list of devices does B{not} imply that the specified audio output does
7814
 
    not work.
7815
 
    @note: The list might not be exhaustive.
7816
 
    @warning: Some audio output devices in the list might not actually work in
7817
 
    some circumstances. By default, it is recommended to not specify any
7818
 
    explicit audio device.
7819
 
    @param p_instance: libvlc instance.
7820
 
    @param aout: audio output name (as returned by L{libvlc_audio_output_list_get}()).
7821
 
    @return: A None-terminated linked list of potential audio output devices. It must be freed with L{libvlc_audio_output_device_list_release}().
7822
 
    @version: LibVLC 2.1.0 or later.
7823
 
    '''
7824
 
    f = _Cfunctions.get('libvlc_audio_output_device_list_get', None) or \
7825
 
        _Cfunction('libvlc_audio_output_device_list_get', ((1,), (1,),), None,
7826
 
                   ctypes.POINTER(AudioOutputDevice), Instance, ctypes.c_char_p)
7827
 
    return f(p_instance, aout)
7828
 
 
7829
 
 
7830
 
def libvlc_audio_output_device_list_release(p_list):
7831
 
    '''Frees a list of available audio output devices.
7832
 
    @param p_list: list with audio outputs for release.
7833
 
    @version: LibVLC 2.1.0 or later.
7834
 
    '''
7835
 
    f = _Cfunctions.get('libvlc_audio_output_device_list_release', None) or \
7836
 
        _Cfunction('libvlc_audio_output_device_list_release', ((1,),), None,
7837
 
                   None, ctypes.POINTER(AudioOutputDevice))
7838
 
    return f(p_list)
7839
 
 
7840
 
 
7841
 
def libvlc_audio_output_device_set(mp, module, device_id):
7842
 
    '''Configures an explicit audio output device.
7843
 
    If the module paramater is None, audio output will be moved to the device
7844
 
    specified by the device identifier string immediately. This is the
7845
 
    recommended usage.
7846
 
    A list of adequate potential device strings can be obtained with
7847
 
    L{libvlc_audio_output_device_enum}().
7848
 
    However passing None is supported in LibVLC version 2.2.0 and later only;
7849
 
    in earlier versions, this function would have no effects when the module
7850
 
    parameter was None.
7851
 
    If the module parameter is not None, the device parameter of the
7852
 
    corresponding audio output, if it exists, will be set to the specified
7853
 
    string. Note that some audio output modules do not have such a parameter
7854
 
    (notably MMDevice and PulseAudio).
7855
 
    A list of adequate potential device strings can be obtained with
7856
 
    L{libvlc_audio_output_device_list_get}().
7857
 
    @note: This function does not select the specified audio output plugin.
7858
 
    L{libvlc_audio_output_set}() is used for that purpose.
7859
 
    @warning: The syntax for the device parameter depends on the audio output.
7860
 
    Some audio output modules require further parameters (e.g. a channels map
7861
 
    in the case of ALSA).
7862
 
    @param mp: media player.
7863
 
    @param module: If None, current audio output module. if non-None, name of audio output module.
7864
 
    @param device_id: device identifier string.
7865
 
    @return: Nothing. Errors are ignored (this is a design bug).
7866
 
    '''
7867
 
    f = _Cfunctions.get('libvlc_audio_output_device_set', None) or \
7868
 
        _Cfunction('libvlc_audio_output_device_set', ((1,), (1,), (1,),), None,
7869
 
                   None, MediaPlayer, ctypes.c_char_p, ctypes.c_char_p)
7870
 
    return f(mp, module, device_id)
7871
 
 
7872
 
 
7873
 
def libvlc_audio_output_device_get(mp):
7874
 
    '''Get the current audio output device identifier.
7875
 
    This complements L{libvlc_audio_output_device_set}().
7876
 
    @warning: The initial value for the current audio output device identifier
7877
 
    may not be set or may be some unknown value. A LibVLC application should
7878
 
    compare this value against the known device identifiers (e.g. those that
7879
 
    were previously retrieved by a call to L{libvlc_audio_output_device_enum} or
7880
 
    L{libvlc_audio_output_device_list_get}) to find the current audio output device.
7881
 
    It is possible that the selected audio output device changes (an external
7882
 
    change) without a call to L{libvlc_audio_output_device_set}. That may make this
7883
 
    method unsuitable to use if a LibVLC application is attempting to track
7884
 
    dynamic audio device changes as they happen.
7885
 
    @param mp: media player.
7886
 
    @return: the current audio output device identifier None if no device is selected or in case of error (the result must be released with free() or L{libvlc_free}()).
7887
 
    @version: LibVLC 3.0.0 or later.
7888
 
    '''
7889
 
    f = _Cfunctions.get('libvlc_audio_output_device_get', None) or \
7890
 
        _Cfunction('libvlc_audio_output_device_get', ((1,),), string_result,
7891
 
                   ctypes.c_void_p, MediaPlayer)
7892
 
    return f(mp)
7893
 
 
7894
 
 
7895
 
def libvlc_audio_toggle_mute(p_mi):
7896
 
    '''Toggle mute status.
7897
 
    @param p_mi: media player @warning Toggling mute atomically is not always possible: On some platforms, other processes can mute the VLC audio playback stream asynchronously. Thus, there is a small race condition where toggling will not work. See also the limitations of L{libvlc_audio_set_mute}().
7898
 
    '''
7899
 
    f = _Cfunctions.get('libvlc_audio_toggle_mute', None) or \
7900
 
        _Cfunction('libvlc_audio_toggle_mute', ((1,),), None,
7901
 
                   None, MediaPlayer)
7902
 
    return f(p_mi)
7903
 
 
7904
 
 
7905
 
def libvlc_audio_get_mute(p_mi):
7906
 
    '''Get current mute status.
7907
 
    @param p_mi: media player.
7908
 
    @return: the mute status (boolean) if defined, -1 if undefined/unapplicable.
7909
 
    '''
7910
 
    f = _Cfunctions.get('libvlc_audio_get_mute', None) or \
7911
 
        _Cfunction('libvlc_audio_get_mute', ((1,),), None,
7912
 
                   ctypes.c_int, MediaPlayer)
7913
 
    return f(p_mi)
7914
 
 
7915
 
 
7916
 
def libvlc_audio_set_mute(p_mi, status):
7917
 
    '''Set mute status.
7918
 
    @param p_mi: media player.
7919
 
    @param status: If status is true then mute, otherwise unmute @warning This function does not always work. If there are no active audio playback stream, the mute status might not be available. If digital pass-through (S/PDIF, HDMI...) is in use, muting may be unapplicable. Also some audio output plugins do not support muting at all. @note To force silent playback, disable all audio tracks. This is more efficient and reliable than mute.
7920
 
    '''
7921
 
    f = _Cfunctions.get('libvlc_audio_set_mute', None) or \
7922
 
        _Cfunction('libvlc_audio_set_mute', ((1,), (1,),), None,
7923
 
                   None, MediaPlayer, ctypes.c_int)
7924
 
    return f(p_mi, status)
7925
 
 
7926
 
 
7927
 
def libvlc_audio_get_volume(p_mi):
7928
 
    '''Get current software audio volume.
7929
 
    @param p_mi: media player.
7930
 
    @return: the software volume in percents (0 = mute, 100 = nominal / 0dB).
7931
 
    '''
7932
 
    f = _Cfunctions.get('libvlc_audio_get_volume', None) or \
7933
 
        _Cfunction('libvlc_audio_get_volume', ((1,),), None,
7934
 
                   ctypes.c_int, MediaPlayer)
7935
 
    return f(p_mi)
7936
 
 
7937
 
 
7938
 
def libvlc_audio_set_volume(p_mi, i_volume):
7939
 
    '''Set current software audio volume.
7940
 
    @param p_mi: media player.
7941
 
    @param i_volume: the volume in percents (0 = mute, 100 = 0dB).
7942
 
    @return: 0 if the volume was set, -1 if it was out of range.
7943
 
    '''
7944
 
    f = _Cfunctions.get('libvlc_audio_set_volume', None) or \
7945
 
        _Cfunction('libvlc_audio_set_volume', ((1,), (1,),), None,
7946
 
                   ctypes.c_int, MediaPlayer, ctypes.c_int)
7947
 
    return f(p_mi, i_volume)
7948
 
 
7949
 
 
7950
 
def libvlc_audio_get_track_count(p_mi):
7951
 
    '''Get number of available audio tracks.
7952
 
    @param p_mi: media player.
7953
 
    @return: the number of available audio tracks (int), or -1 if unavailable.
7954
 
    '''
7955
 
    f = _Cfunctions.get('libvlc_audio_get_track_count', None) or \
7956
 
        _Cfunction('libvlc_audio_get_track_count', ((1,),), None,
7957
 
                   ctypes.c_int, MediaPlayer)
7958
 
    return f(p_mi)
7959
 
 
7960
 
 
7961
 
def libvlc_audio_get_track_description(p_mi):
7962
 
    '''Get the description of available audio tracks.
7963
 
    @param p_mi: media player.
7964
 
    @return: list with description of available audio tracks, or None. It must be freed with L{libvlc_track_description_list_release}().
7965
 
    '''
7966
 
    f = _Cfunctions.get('libvlc_audio_get_track_description', None) or \
7967
 
        _Cfunction('libvlc_audio_get_track_description', ((1,),), None,
7968
 
                   ctypes.POINTER(TrackDescription), MediaPlayer)
7969
 
    return f(p_mi)
7970
 
 
7971
 
 
7972
 
def libvlc_audio_get_track(p_mi):
7973
 
    '''Get current audio track.
7974
 
    @param p_mi: media player.
7975
 
    @return: the audio track ID or -1 if no active input.
7976
 
    '''
7977
 
    f = _Cfunctions.get('libvlc_audio_get_track', None) or \
7978
 
        _Cfunction('libvlc_audio_get_track', ((1,),), None,
7979
 
                   ctypes.c_int, MediaPlayer)
7980
 
    return f(p_mi)
7981
 
 
7982
 
 
7983
 
def libvlc_audio_set_track(p_mi, i_track):
7984
 
    '''Set current audio track.
7985
 
    @param p_mi: media player.
7986
 
    @param i_track: the track ID (i_id field from track description).
7987
 
    @return: 0 on success, -1 on error.
7988
 
    '''
7989
 
    f = _Cfunctions.get('libvlc_audio_set_track', None) or \
7990
 
        _Cfunction('libvlc_audio_set_track', ((1,), (1,),), None,
7991
 
                   ctypes.c_int, MediaPlayer, ctypes.c_int)
7992
 
    return f(p_mi, i_track)
7993
 
 
7994
 
 
7995
 
def libvlc_audio_get_channel(p_mi):
7996
 
    '''Get current audio channel.
7997
 
    @param p_mi: media player.
7998
 
    @return: the audio channel See L{AudioOutputChannel}.
7999
 
    '''
8000
 
    f = _Cfunctions.get('libvlc_audio_get_channel', None) or \
8001
 
        _Cfunction('libvlc_audio_get_channel', ((1,),), None,
8002
 
                   ctypes.c_int, MediaPlayer)
8003
 
    return f(p_mi)
8004
 
 
8005
 
 
8006
 
def libvlc_audio_set_channel(p_mi, channel):
8007
 
    '''Set current audio channel.
8008
 
    @param p_mi: media player.
8009
 
    @param channel: the audio channel, See L{AudioOutputChannel}.
8010
 
    @return: 0 on success, -1 on error.
8011
 
    '''
8012
 
    f = _Cfunctions.get('libvlc_audio_set_channel', None) or \
8013
 
        _Cfunction('libvlc_audio_set_channel', ((1,), (1,),), None,
8014
 
                   ctypes.c_int, MediaPlayer, ctypes.c_int)
8015
 
    return f(p_mi, channel)
8016
 
 
8017
 
 
8018
 
def libvlc_audio_get_delay(p_mi):
8019
 
    '''Get current audio delay.
8020
 
    @param p_mi: media player.
8021
 
    @return: the audio delay (microseconds).
8022
 
    @version: LibVLC 1.1.1 or later.
8023
 
    '''
8024
 
    f = _Cfunctions.get('libvlc_audio_get_delay', None) or \
8025
 
        _Cfunction('libvlc_audio_get_delay', ((1,),), None,
8026
 
                   ctypes.c_int64, MediaPlayer)
8027
 
    return f(p_mi)
8028
 
 
8029
 
 
8030
 
def libvlc_audio_set_delay(p_mi, i_delay):
8031
 
    '''Set current audio delay. The audio delay will be reset to zero each time the media changes.
8032
 
    @param p_mi: media player.
8033
 
    @param i_delay: the audio delay (microseconds).
8034
 
    @return: 0 on success, -1 on error.
8035
 
    @version: LibVLC 1.1.1 or later.
8036
 
    '''
8037
 
    f = _Cfunctions.get('libvlc_audio_set_delay', None) or \
8038
 
        _Cfunction('libvlc_audio_set_delay', ((1,), (1,),), None,
8039
 
                   ctypes.c_int, MediaPlayer, ctypes.c_int64)
8040
 
    return f(p_mi, i_delay)
8041
 
 
8042
 
 
8043
 
def libvlc_audio_equalizer_get_preset_count():
8044
 
    '''Get the number of equalizer presets.
8045
 
    @return: number of presets.
8046
 
    @version: LibVLC 2.2.0 or later.
8047
 
    '''
8048
 
    f = _Cfunctions.get('libvlc_audio_equalizer_get_preset_count', None) or \
8049
 
        _Cfunction('libvlc_audio_equalizer_get_preset_count', (), None,
8050
 
                   ctypes.c_uint)
8051
 
    return f()
8052
 
 
8053
 
 
8054
 
def libvlc_audio_equalizer_get_preset_name(u_index):
8055
 
    '''Get the name of a particular equalizer preset.
8056
 
    This name can be used, for example, to prepare a preset label or menu in a user
8057
 
    interface.
8058
 
    @param u_index: index of the preset, counting from zero.
8059
 
    @return: preset name, or None if there is no such preset.
8060
 
    @version: LibVLC 2.2.0 or later.
8061
 
    '''
8062
 
    f = _Cfunctions.get('libvlc_audio_equalizer_get_preset_name', None) or \
8063
 
        _Cfunction('libvlc_audio_equalizer_get_preset_name', ((1,),), None,
8064
 
                   ctypes.c_char_p, ctypes.c_uint)
8065
 
    return f(u_index)
8066
 
 
8067
 
 
8068
 
def libvlc_audio_equalizer_get_band_count():
8069
 
    '''Get the number of distinct frequency bands for an equalizer.
8070
 
    @return: number of frequency bands.
8071
 
    @version: LibVLC 2.2.0 or later.
8072
 
    '''
8073
 
    f = _Cfunctions.get('libvlc_audio_equalizer_get_band_count', None) or \
8074
 
        _Cfunction('libvlc_audio_equalizer_get_band_count', (), None,
8075
 
                   ctypes.c_uint)
8076
 
    return f()
8077
 
 
8078
 
 
8079
 
def libvlc_audio_equalizer_get_band_frequency(u_index):
8080
 
    '''Get a particular equalizer band frequency.
8081
 
    This value can be used, for example, to create a label for an equalizer band control
8082
 
    in a user interface.
8083
 
    @param u_index: index of the band, counting from zero.
8084
 
    @return: equalizer band frequency (Hz), or -1 if there is no such band.
8085
 
    @version: LibVLC 2.2.0 or later.
8086
 
    '''
8087
 
    f = _Cfunctions.get('libvlc_audio_equalizer_get_band_frequency', None) or \
8088
 
        _Cfunction('libvlc_audio_equalizer_get_band_frequency', ((1,),), None,
8089
 
                   ctypes.c_float, ctypes.c_uint)
8090
 
    return f(u_index)
8091
 
 
8092
 
 
8093
 
def libvlc_audio_equalizer_new():
8094
 
    '''Create a new default equalizer, with all frequency values zeroed.
8095
 
    The new equalizer can subsequently be applied to a media player by invoking
8096
 
    L{libvlc_media_player_set_equalizer}().
8097
 
    The returned handle should be freed via L{libvlc_audio_equalizer_release}() when
8098
 
    it is no longer needed.
8099
 
    @return: opaque equalizer handle, or None on error.
8100
 
    @version: LibVLC 2.2.0 or later.
8101
 
    '''
8102
 
    f = _Cfunctions.get('libvlc_audio_equalizer_new', None) or \
8103
 
        _Cfunction('libvlc_audio_equalizer_new', (), None,
8104
 
                   ctypes.c_void_p)
8105
 
    return f()
8106
 
 
8107
 
 
8108
 
def libvlc_audio_equalizer_new_from_preset(u_index):
8109
 
    '''Create a new equalizer, with initial frequency values copied from an existing
8110
 
    preset.
8111
 
    The new equalizer can subsequently be applied to a media player by invoking
8112
 
    L{libvlc_media_player_set_equalizer}().
8113
 
    The returned handle should be freed via L{libvlc_audio_equalizer_release}() when
8114
 
    it is no longer needed.
8115
 
    @param u_index: index of the preset, counting from zero.
8116
 
    @return: opaque equalizer handle, or None on error.
8117
 
    @version: LibVLC 2.2.0 or later.
8118
 
    '''
8119
 
    f = _Cfunctions.get('libvlc_audio_equalizer_new_from_preset', None) or \
8120
 
        _Cfunction('libvlc_audio_equalizer_new_from_preset', ((1,),), None,
8121
 
                   ctypes.c_void_p, ctypes.c_uint)
8122
 
    return f(u_index)
8123
 
 
8124
 
 
8125
 
def libvlc_audio_equalizer_release(p_equalizer):
8126
 
    '''Release a previously created equalizer instance.
8127
 
    The equalizer was previously created by using L{libvlc_audio_equalizer_new}() or
8128
 
    L{libvlc_audio_equalizer_new_from_preset}().
8129
 
    It is safe to invoke this method with a None p_equalizer parameter for no effect.
8130
 
    @param p_equalizer: opaque equalizer handle, or None.
8131
 
    @version: LibVLC 2.2.0 or later.
8132
 
    '''
8133
 
    f = _Cfunctions.get('libvlc_audio_equalizer_release', None) or \
8134
 
        _Cfunction('libvlc_audio_equalizer_release', ((1,),), None,
8135
 
                   None, ctypes.c_void_p)
8136
 
    return f(p_equalizer)
8137
 
 
8138
 
 
8139
 
def libvlc_audio_equalizer_set_preamp(p_equalizer, f_preamp):
8140
 
    '''Set a new pre-amplification value for an equalizer.
8141
 
    The new equalizer settings are subsequently applied to a media player by invoking
8142
 
    L{libvlc_media_player_set_equalizer}().
8143
 
    The supplied amplification value will be clamped to the -20.0 to +20.0 range.
8144
 
    @param p_equalizer: valid equalizer handle, must not be None.
8145
 
    @param f_preamp: preamp value (-20.0 to 20.0 Hz).
8146
 
    @return: zero on success, -1 on error.
8147
 
    @version: LibVLC 2.2.0 or later.
8148
 
    '''
8149
 
    f = _Cfunctions.get('libvlc_audio_equalizer_set_preamp', None) or \
8150
 
        _Cfunction('libvlc_audio_equalizer_set_preamp', ((1,), (1,),), None,
8151
 
                   ctypes.c_int, ctypes.c_void_p, ctypes.c_float)
8152
 
    return f(p_equalizer, f_preamp)
8153
 
 
8154
 
 
8155
 
def libvlc_audio_equalizer_get_preamp(p_equalizer):
8156
 
    '''Get the current pre-amplification value from an equalizer.
8157
 
    @param p_equalizer: valid equalizer handle, must not be None.
8158
 
    @return: preamp value (Hz).
8159
 
    @version: LibVLC 2.2.0 or later.
8160
 
    '''
8161
 
    f = _Cfunctions.get('libvlc_audio_equalizer_get_preamp', None) or \
8162
 
        _Cfunction('libvlc_audio_equalizer_get_preamp', ((1,),), None,
8163
 
                   ctypes.c_float, ctypes.c_void_p)
8164
 
    return f(p_equalizer)
8165
 
 
8166
 
 
8167
 
def libvlc_audio_equalizer_set_amp_at_index(p_equalizer, f_amp, u_band):
8168
 
    '''Set a new amplification value for a particular equalizer frequency band.
8169
 
    The new equalizer settings are subsequently applied to a media player by invoking
8170
 
    L{libvlc_media_player_set_equalizer}().
8171
 
    The supplied amplification value will be clamped to the -20.0 to +20.0 range.
8172
 
    @param p_equalizer: valid equalizer handle, must not be None.
8173
 
    @param f_amp: amplification value (-20.0 to 20.0 Hz).
8174
 
    @param u_band: index, counting from zero, of the frequency band to set.
8175
 
    @return: zero on success, -1 on error.
8176
 
    @version: LibVLC 2.2.0 or later.
8177
 
    '''
8178
 
    f = _Cfunctions.get('libvlc_audio_equalizer_set_amp_at_index', None) or \
8179
 
        _Cfunction('libvlc_audio_equalizer_set_amp_at_index', ((1,), (1,), (1,),), None,
8180
 
                   ctypes.c_int, ctypes.c_void_p, ctypes.c_float, ctypes.c_uint)
8181
 
    return f(p_equalizer, f_amp, u_band)
8182
 
 
8183
 
 
8184
 
def libvlc_audio_equalizer_get_amp_at_index(p_equalizer, u_band):
8185
 
    '''Get the amplification value for a particular equalizer frequency band.
8186
 
    @param p_equalizer: valid equalizer handle, must not be None.
8187
 
    @param u_band: index, counting from zero, of the frequency band to get.
8188
 
    @return: amplification value (Hz); NaN if there is no such frequency band.
8189
 
    @version: LibVLC 2.2.0 or later.
8190
 
    '''
8191
 
    f = _Cfunctions.get('libvlc_audio_equalizer_get_amp_at_index', None) or \
8192
 
        _Cfunction('libvlc_audio_equalizer_get_amp_at_index', ((1,), (1,),), None,
8193
 
                   ctypes.c_float, ctypes.c_void_p, ctypes.c_uint)
8194
 
    return f(p_equalizer, u_band)
8195
 
 
8196
 
 
8197
 
def libvlc_media_player_set_equalizer(p_mi, p_equalizer):
8198
 
    '''Apply new equalizer settings to a media player.
8199
 
    The equalizer is first created by invoking L{libvlc_audio_equalizer_new}() or
8200
 
    L{libvlc_audio_equalizer_new_from_preset}().
8201
 
    It is possible to apply new equalizer settings to a media player whether the media
8202
 
    player is currently playing media or not.
8203
 
    Invoking this method will immediately apply the new equalizer settings to the audio
8204
 
    output of the currently playing media if there is any.
8205
 
    If there is no currently playing media, the new equalizer settings will be applied
8206
 
    later if and when new media is played.
8207
 
    Equalizer settings will automatically be applied to subsequently played media.
8208
 
    To disable the equalizer for a media player invoke this method passing None for the
8209
 
    p_equalizer parameter.
8210
 
    The media player does not keep a reference to the supplied equalizer so it is safe
8211
 
    for an application to release the equalizer reference any time after this method
8212
 
    returns.
8213
 
    @param p_mi: opaque media player handle.
8214
 
    @param p_equalizer: opaque equalizer handle, or None to disable the equalizer for this media player.
8215
 
    @return: zero on success, -1 on error.
8216
 
    @version: LibVLC 2.2.0 or later.
8217
 
    '''
8218
 
    f = _Cfunctions.get('libvlc_media_player_set_equalizer', None) or \
8219
 
        _Cfunction('libvlc_media_player_set_equalizer', ((1,), (1,),), None,
8220
 
                   ctypes.c_int, MediaPlayer, ctypes.c_void_p)
8221
 
    return f(p_mi, p_equalizer)
8222
 
 
8223
 
 
8224
 
def libvlc_media_player_get_role(p_mi):
8225
 
    '''Gets the media role.
8226
 
    @param p_mi: media player.
8227
 
    @return: the media player role (\ref libvlc_media_player_role_t).
8228
 
    @version: LibVLC 3.0.0 and later.
8229
 
    '''
8230
 
    f = _Cfunctions.get('libvlc_media_player_get_role', None) or \
8231
 
        _Cfunction('libvlc_media_player_get_role', ((1,),), None,
8232
 
                   ctypes.c_int, MediaPlayer)
8233
 
    return f(p_mi)
8234
 
 
8235
 
 
8236
 
def libvlc_media_player_set_role(p_mi, role):
8237
 
    '''Sets the media role.
8238
 
    @param p_mi: media player.
8239
 
    @param role: the media player role (\ref libvlc_media_player_role_t).
8240
 
    @return: 0 on success, -1 on error.
8241
 
    '''
8242
 
    f = _Cfunctions.get('libvlc_media_player_set_role', None) or \
8243
 
        _Cfunction('libvlc_media_player_set_role', ((1,), (1,),), None,
8244
 
                   ctypes.c_int, MediaPlayer, ctypes.c_uint)
8245
 
    return f(p_mi, role)
8246
 
 
8247
 
 
8248
 
def libvlc_media_list_player_new(p_instance):
8249
 
    '''Create new media_list_player.
8250
 
    @param p_instance: libvlc instance.
8251
 
    @return: media list player instance or None on error.
8252
 
    '''
8253
 
    f = _Cfunctions.get('libvlc_media_list_player_new', None) or \
8254
 
        _Cfunction('libvlc_media_list_player_new', ((1,),), class_result(MediaListPlayer),
8255
 
                   ctypes.c_void_p, Instance)
8256
 
    return f(p_instance)
8257
 
 
8258
 
 
8259
 
def libvlc_media_list_player_release(p_mlp):
8260
 
    '''Release a media_list_player after use
8261
 
    Decrement the reference count of a media player object. If the
8262
 
    reference count is 0, then L{libvlc_media_list_player_release}() will
8263
 
    release the media player object. If the media player object
8264
 
    has been released, then it should not be used again.
8265
 
    @param p_mlp: media list player instance.
8266
 
    '''
8267
 
    f = _Cfunctions.get('libvlc_media_list_player_release', None) or \
8268
 
        _Cfunction('libvlc_media_list_player_release', ((1,),), None,
8269
 
                   None, MediaListPlayer)
8270
 
    return f(p_mlp)
8271
 
 
8272
 
 
8273
 
def libvlc_media_list_player_retain(p_mlp):
8274
 
    '''Retain a reference to a media player list object. Use
8275
 
    L{libvlc_media_list_player_release}() to decrement reference count.
8276
 
    @param p_mlp: media player list object.
8277
 
    '''
8278
 
    f = _Cfunctions.get('libvlc_media_list_player_retain', None) or \
8279
 
        _Cfunction('libvlc_media_list_player_retain', ((1,),), None,
8280
 
                   None, MediaListPlayer)
8281
 
    return f(p_mlp)
8282
 
 
8283
 
 
8284
 
def libvlc_media_list_player_event_manager(p_mlp):
8285
 
    '''Return the event manager of this media_list_player.
8286
 
    @param p_mlp: media list player instance.
8287
 
    @return: the event manager.
8288
 
    '''
8289
 
    f = _Cfunctions.get('libvlc_media_list_player_event_manager', None) or \
8290
 
        _Cfunction('libvlc_media_list_player_event_manager', ((1,),), class_result(EventManager),
8291
 
                   ctypes.c_void_p, MediaListPlayer)
8292
 
    return f(p_mlp)
8293
 
 
8294
 
 
8295
 
def libvlc_media_list_player_set_media_player(p_mlp, p_mi):
8296
 
    '''Replace media player in media_list_player with this instance.
8297
 
    @param p_mlp: media list player instance.
8298
 
    @param p_mi: media player instance.
8299
 
    '''
8300
 
    f = _Cfunctions.get('libvlc_media_list_player_set_media_player', None) or \
8301
 
        _Cfunction('libvlc_media_list_player_set_media_player', ((1,), (1,),), None,
8302
 
                   None, MediaListPlayer, MediaPlayer)
8303
 
    return f(p_mlp, p_mi)
8304
 
 
8305
 
 
8306
 
def libvlc_media_list_player_get_media_player(p_mlp):
8307
 
    '''Get media player of the media_list_player instance.
8308
 
    @param p_mlp: media list player instance.
8309
 
    @return: media player instance @note the caller is responsible for releasing the returned instance.
8310
 
    '''
8311
 
    f = _Cfunctions.get('libvlc_media_list_player_get_media_player', None) or \
8312
 
        _Cfunction('libvlc_media_list_player_get_media_player', ((1,),), class_result(MediaPlayer),
8313
 
                   ctypes.c_void_p, MediaListPlayer)
8314
 
    return f(p_mlp)
8315
 
 
8316
 
 
8317
 
def libvlc_media_list_player_set_media_list(p_mlp, p_mlist):
8318
 
    '''Set the media list associated with the player.
8319
 
    @param p_mlp: media list player instance.
8320
 
    @param p_mlist: list of media.
8321
 
    '''
8322
 
    f = _Cfunctions.get('libvlc_media_list_player_set_media_list', None) or \
8323
 
        _Cfunction('libvlc_media_list_player_set_media_list', ((1,), (1,),), None,
8324
 
                   None, MediaListPlayer, MediaList)
8325
 
    return f(p_mlp, p_mlist)
8326
 
 
8327
 
 
8328
 
def libvlc_media_list_player_play(p_mlp):
8329
 
    '''Play media list.
8330
 
    @param p_mlp: media list player instance.
8331
 
    '''
8332
 
    f = _Cfunctions.get('libvlc_media_list_player_play', None) or \
8333
 
        _Cfunction('libvlc_media_list_player_play', ((1,),), None,
8334
 
                   None, MediaListPlayer)
8335
 
    return f(p_mlp)
8336
 
 
8337
 
 
8338
 
def libvlc_media_list_player_pause(p_mlp):
8339
 
    '''Toggle pause (or resume) media list.
8340
 
    @param p_mlp: media list player instance.
8341
 
    '''
8342
 
    f = _Cfunctions.get('libvlc_media_list_player_pause', None) or \
8343
 
        _Cfunction('libvlc_media_list_player_pause', ((1,),), None,
8344
 
                   None, MediaListPlayer)
8345
 
    return f(p_mlp)
8346
 
 
8347
 
 
8348
 
def libvlc_media_list_player_set_pause(p_mlp, do_pause):
8349
 
    '''Pause or resume media list.
8350
 
    @param p_mlp: media list player instance.
8351
 
    @param do_pause: play/resume if zero, pause if non-zero.
8352
 
    @version: LibVLC 3.0.0 or later.
8353
 
    '''
8354
 
    f = _Cfunctions.get('libvlc_media_list_player_set_pause', None) or \
8355
 
        _Cfunction('libvlc_media_list_player_set_pause', ((1,), (1,),), None,
8356
 
                   None, MediaListPlayer, ctypes.c_int)
8357
 
    return f(p_mlp, do_pause)
8358
 
 
8359
 
 
8360
 
def libvlc_media_list_player_is_playing(p_mlp):
8361
 
    '''Is media list playing?
8362
 
    @param p_mlp: media list player instance.
8363
 
    @return: true for playing and false for not playing \libvlc_return_bool.
8364
 
    '''
8365
 
    f = _Cfunctions.get('libvlc_media_list_player_is_playing', None) or \
8366
 
        _Cfunction('libvlc_media_list_player_is_playing', ((1,),), None,
8367
 
                   ctypes.c_int, MediaListPlayer)
8368
 
    return f(p_mlp)
8369
 
 
8370
 
 
8371
 
def libvlc_media_list_player_get_state(p_mlp):
8372
 
    '''Get current libvlc_state of media list player.
8373
 
    @param p_mlp: media list player instance.
8374
 
    @return: L{State} for media list player.
8375
 
    '''
8376
 
    f = _Cfunctions.get('libvlc_media_list_player_get_state', None) or \
8377
 
        _Cfunction('libvlc_media_list_player_get_state', ((1,),), None,
8378
 
                   State, MediaListPlayer)
8379
 
    return f(p_mlp)
8380
 
 
8381
 
 
8382
 
def libvlc_media_list_player_play_item_at_index(p_mlp, i_index):
8383
 
    '''Play media list item at position index.
8384
 
    @param p_mlp: media list player instance.
8385
 
    @param i_index: index in media list to play.
8386
 
    @return: 0 upon success -1 if the item wasn't found.
8387
 
    '''
8388
 
    f = _Cfunctions.get('libvlc_media_list_player_play_item_at_index', None) or \
8389
 
        _Cfunction('libvlc_media_list_player_play_item_at_index', ((1,), (1,),), None,
8390
 
                   ctypes.c_int, MediaListPlayer, ctypes.c_int)
8391
 
    return f(p_mlp, i_index)
8392
 
 
8393
 
 
8394
 
def libvlc_media_list_player_play_item(p_mlp, p_md):
8395
 
    '''Play the given media item.
8396
 
    @param p_mlp: media list player instance.
8397
 
    @param p_md: the media instance.
8398
 
    @return: 0 upon success, -1 if the media is not part of the media list.
8399
 
    '''
8400
 
    f = _Cfunctions.get('libvlc_media_list_player_play_item', None) or \
8401
 
        _Cfunction('libvlc_media_list_player_play_item', ((1,), (1,),), None,
8402
 
                   ctypes.c_int, MediaListPlayer, Media)
8403
 
    return f(p_mlp, p_md)
8404
 
 
8405
 
 
8406
 
def libvlc_media_list_player_stop(p_mlp):
8407
 
    '''Stop playing media list.
8408
 
    @param p_mlp: media list player instance.
8409
 
    '''
8410
 
    f = _Cfunctions.get('libvlc_media_list_player_stop', None) or \
8411
 
        _Cfunction('libvlc_media_list_player_stop', ((1,),), None,
8412
 
                   None, MediaListPlayer)
8413
 
    return f(p_mlp)
8414
 
 
8415
 
 
8416
 
def libvlc_media_list_player_next(p_mlp):
8417
 
    '''Play next item from media list.
8418
 
    @param p_mlp: media list player instance.
8419
 
    @return: 0 upon success -1 if there is no next item.
8420
 
    '''
8421
 
    f = _Cfunctions.get('libvlc_media_list_player_next', None) or \
8422
 
        _Cfunction('libvlc_media_list_player_next', ((1,),), None,
8423
 
                   ctypes.c_int, MediaListPlayer)
8424
 
    return f(p_mlp)
8425
 
 
8426
 
 
8427
 
def libvlc_media_list_player_previous(p_mlp):
8428
 
    '''Play previous item from media list.
8429
 
    @param p_mlp: media list player instance.
8430
 
    @return: 0 upon success -1 if there is no previous item.
8431
 
    '''
8432
 
    f = _Cfunctions.get('libvlc_media_list_player_previous', None) or \
8433
 
        _Cfunction('libvlc_media_list_player_previous', ((1,),), None,
8434
 
                   ctypes.c_int, MediaListPlayer)
8435
 
    return f(p_mlp)
8436
 
 
8437
 
 
8438
 
def libvlc_media_list_player_set_playback_mode(p_mlp, e_mode):
8439
 
    '''Sets the playback mode for the playlist.
8440
 
    @param p_mlp: media list player instance.
8441
 
    @param e_mode: playback mode specification.
8442
 
    '''
8443
 
    f = _Cfunctions.get('libvlc_media_list_player_set_playback_mode', None) or \
8444
 
        _Cfunction('libvlc_media_list_player_set_playback_mode', ((1,), (1,),), None,
8445
 
                   None, MediaListPlayer, PlaybackMode)
8446
 
    return f(p_mlp, e_mode)
8447
 
 
8448
 
 
8449
 
# 5 function(s) blacklisted:
8450
 
#  libvlc_audio_output_get_device_type
8451
 
#  libvlc_audio_output_set_device_type
8452
 
#  libvlc_dialog_set_callbacks
8453
 
#  libvlc_printerr
8454
 
#  libvlc_set_exit_handler
8455
 
 
8456
 
# 54 function(s) not wrapped as methods:
8457
 
#  libvlc_audio_equalizer_get_amp_at_index
8458
 
#  libvlc_audio_equalizer_get_band_count
8459
 
#  libvlc_audio_equalizer_get_band_frequency
8460
 
#  libvlc_audio_equalizer_get_preamp
8461
 
#  libvlc_audio_equalizer_get_preset_count
8462
 
#  libvlc_audio_equalizer_get_preset_name
8463
 
#  libvlc_audio_equalizer_new
8464
 
#  libvlc_audio_equalizer_new_from_preset
8465
 
#  libvlc_audio_equalizer_release
8466
 
#  libvlc_audio_equalizer_set_amp_at_index
8467
 
#  libvlc_audio_equalizer_set_preamp
8468
 
#  libvlc_audio_output_device_list_release
8469
 
#  libvlc_audio_output_list_release
8470
 
#  libvlc_chapter_descriptions_release
8471
 
#  libvlc_clearerr
8472
 
#  libvlc_clock
8473
 
#  libvlc_dialog_dismiss
8474
 
#  libvlc_dialog_get_context
8475
 
#  libvlc_dialog_post_action
8476
 
#  libvlc_dialog_post_login
8477
 
#  libvlc_dialog_set_context
8478
 
#  libvlc_event_type_name
8479
 
#  libvlc_free
8480
 
#  libvlc_get_changeset
8481
 
#  libvlc_get_compiler
8482
 
#  libvlc_get_version
8483
 
#  libvlc_log_clear
8484
 
#  libvlc_log_close
8485
 
#  libvlc_log_count
8486
 
#  libvlc_log_get_context
8487
 
#  libvlc_log_get_iterator
8488
 
#  libvlc_log_get_object
8489
 
#  libvlc_media_discoverer_list_release
8490
 
#  libvlc_media_get_codec_description
8491
 
#  libvlc_media_slaves_release
8492
 
#  libvlc_media_tracks_release
8493
 
#  libvlc_module_description_list_release
8494
 
#  libvlc_new
8495
 
#  libvlc_renderer_discoverer_event_manager
8496
 
#  libvlc_renderer_discoverer_list_release
8497
 
#  libvlc_renderer_discoverer_release
8498
 
#  libvlc_renderer_discoverer_start
8499
 
#  libvlc_renderer_discoverer_stop
8500
 
#  libvlc_renderer_item_flags
8501
 
#  libvlc_renderer_item_hold
8502
 
#  libvlc_renderer_item_icon_uri
8503
 
#  libvlc_renderer_item_name
8504
 
#  libvlc_renderer_item_release
8505
 
#  libvlc_renderer_item_type
8506
 
#  libvlc_title_descriptions_release
8507
 
#  libvlc_track_description_list_release
8508
 
#  libvlc_track_description_release
8509
 
#  libvlc_video_new_viewpoint
8510
 
#  libvlc_vprinterr
8511
 
 
8512
 
# Start of footer.py #
8513
 
 
8514
 
# Backward compatibility
8515
 
def callbackmethod(callback):
8516
 
    """Now obsolete @callbackmethod decorator."""
8517
 
    return callback
8518
 
 
8519
 
 
8520
 
# libvlc_free is not present in some versions of libvlc. If it is not
8521
 
# in the library, then emulate it by calling libc.free
8522
 
if not hasattr(dll, 'libvlc_free'):
8523
 
    # need to find the free function in the C runtime. This is
8524
 
    # platform specific.
8525
 
    # For Linux and MacOSX
8526
 
    libc_path = find_library('c')
8527
 
    if libc_path:
8528
 
        libc = ctypes.CDLL(libc_path)
8529
 
        libvlc_free = libc.free
8530
 
    else:
8531
 
        # On win32, it is impossible to guess the proper lib to call
8532
 
        # (msvcrt, mingw...). Just ignore the call: it will memleak,
8533
 
        # but not prevent to run the application.
8534
 
        def libvlc_free(p):
8535
 
            pass
8536
 
 
8537
 
    # ensure argtypes is right, because default type of int won't
8538
 
    # work on 64-bit systems
8539
 
    libvlc_free.argtypes = [ctypes.c_void_p]
8540
 
 
8541
 
 
8542
 
# Version functions
8543
 
def _dot2int(v):
8544
 
    '''(INTERNAL) Convert 'i.i.i[.i]' str to int.
8545
 
    '''
8546
 
    t = [int(i) for i in v.split('.')]
8547
 
    if len(t) == 3:
8548
 
        if t[2] < 100:
8549
 
            t.append(0)
8550
 
        else:  # 100 is arbitrary
8551
 
            t[2:4] = divmod(t[2], 100)
8552
 
    elif len(t) != 4:
8553
 
        raise ValueError('"i.i.i[.i]": %r' % (v,))
8554
 
    if min(t) < 0 or max(t) > 255:
8555
 
        raise ValueError('[0..255]: %r' % (v,))
8556
 
    i = t.pop(0)
8557
 
    while t:
8558
 
        i = (i << 8) + t.pop(0)
8559
 
    return i
8560
 
 
8561
 
 
8562
 
def hex_version():
8563
 
    """Return the version of these bindings in hex or 0 if unavailable.
8564
 
    """
8565
 
    try:
8566
 
        return _dot2int(__version__)
8567
 
    except (NameError, ValueError):
8568
 
        return 0
8569
 
 
8570
 
 
8571
 
def libvlc_hex_version():
8572
 
    """Return the libvlc version in hex or 0 if unavailable.
8573
 
    """
8574
 
    try:
8575
 
        return _dot2int(bytes_to_str(libvlc_get_version()).split()[0])
8576
 
    except ValueError:
8577
 
        return 0
8578
 
 
8579
 
 
8580
 
def debug_callback(event, *args, **kwds):
8581
 
    '''Example callback, useful for debugging.
8582
 
    '''
8583
 
    l = ['event %s' % (event.type,)]
8584
 
    if args:
8585
 
        l.extend(map(str, args))
8586
 
    if kwds:
8587
 
        l.extend(sorted('%s=%s' % t for t in kwds.items()))
8588
 
    print('Debug callback (%s)' % ', '.join(l))
8589
 
 
8590
 
 
8591
 
if __name__ == '__main__':
8592
 
    logging.basicConfig(level=logging.DEBUG)
8593
 
    try:
8594
 
        from msvcrt import getch
8595
 
    except ImportError:
8596
 
        import termios
8597
 
        import tty
8598
 
 
8599
 
 
8600
 
        def getch():  # getchar(), getc(stdin)  #PYCHOK flake
8601
 
            fd = sys.stdin.fileno()
8602
 
            old = termios.tcgetattr(fd)
8603
 
            try:
8604
 
                tty.setraw(fd)
8605
 
                ch = sys.stdin.read(1)
8606
 
            finally:
8607
 
                termios.tcsetattr(fd, termios.TCSADRAIN, old)
8608
 
            return ch
8609
 
 
8610
 
 
8611
 
    def end_callback(event):
8612
 
        print('End of media stream (event %s)' % event.type)
8613
 
        sys.exit(0)
8614
 
 
8615
 
 
8616
 
    echo_position = False
8617
 
 
8618
 
 
8619
 
    def pos_callback(event, player):
8620
 
        if echo_position:
8621
 
            sys.stdout.write('\r%s to %.2f%% (%.2f%%)' % (event.type,
8622
 
                                                          event.u.new_position * 100,
8623
 
                                                          player.get_position() * 100))
8624
 
            sys.stdout.flush()
8625
 
 
8626
 
 
8627
 
    def print_version():
8628
 
        """Print version of this vlc.py and of the libvlc"""
8629
 
        try:
8630
 
            print('Build date: %s (%#x)' % (build_date, hex_version()))
8631
 
            print('LibVLC version: %s (%#x)' % (bytes_to_str(libvlc_get_version()), libvlc_hex_version()))
8632
 
            print('LibVLC compiler: %s' % bytes_to_str(libvlc_get_compiler()))
8633
 
            if plugin_path:
8634
 
                print('Plugin path: %s' % plugin_path)
8635
 
        except:
8636
 
            print('Error: %s' % sys.exc_info()[1])
8637
 
 
8638
 
 
8639
 
    if sys.argv[1:] and '-h' not in sys.argv[1:] and '--help' not in sys.argv[1:]:
8640
 
 
8641
 
        movie = os.path.expanduser(sys.argv.pop())
8642
 
        if not os.access(movie, os.R_OK):
8643
 
            print('Error: %s file not readable' % movie)
8644
 
            sys.exit(1)
8645
 
 
8646
 
        # Need --sub-source=marq in order to use marquee below
8647
 
        instance = Instance(["--sub-source=marq"] + sys.argv[1:])
8648
 
        try:
8649
 
            media = instance.media_new(movie)
8650
 
        except (AttributeError, NameError) as e:
8651
 
            print('%s: %s (%s %s vs LibVLC %s)' % (e.__class__.__name__, e,
8652
 
                                                   sys.argv[0], __version__,
8653
 
                                                   libvlc_get_version()))
8654
 
            sys.exit(1)
8655
 
        player = instance.media_player_new()
8656
 
        player.set_media(media)
8657
 
        player.play()
8658
 
 
8659
 
        # Some marquee examples.  Marquee requires '--sub-source marq' in the
8660
 
        # Instance() call above, see <http://www.videolan.org/doc/play-howto/en/ch04.html>
8661
 
        player.video_set_marquee_int(VideoMarqueeOption.Enable, 1)
8662
 
        player.video_set_marquee_int(VideoMarqueeOption.Size, 24)  # pixels
8663
 
        player.video_set_marquee_int(VideoMarqueeOption.Position, Position.Bottom)
8664
 
        if False:  # only one marquee can be specified
8665
 
            player.video_set_marquee_int(VideoMarqueeOption.Timeout, 5000)  # millisec, 0==forever
8666
 
            t = media.get_mrl()  # movie
8667
 
        else:  # update marquee text periodically
8668
 
            player.video_set_marquee_int(VideoMarqueeOption.Timeout, 0)  # millisec, 0==forever
8669
 
            player.video_set_marquee_int(VideoMarqueeOption.Refresh, 1000)  # millisec (or sec?)
8670
 
            ##t = '$L / $D or $P at $T'
8671
 
            t = '%Y-%m-%d  %H:%M:%S'
8672
 
        player.video_set_marquee_string(VideoMarqueeOption.Text, str_to_bytes(t))
8673
 
 
8674
 
        # Some event manager examples.  Note, the callback can be any Python
8675
 
        # callable and does not need to be decorated.  Optionally, specify
8676
 
        # any number of positional and/or keyword arguments to be passed
8677
 
        # to the callback (in addition to the first one, an Event instance).
8678
 
        event_manager = player.event_manager()
8679
 
        event_manager.event_attach(EventType.MediaPlayerEndReached, end_callback)
8680
 
        event_manager.event_attach(EventType.MediaPlayerPositionChanged, pos_callback, player)
8681
 
 
8682
 
 
8683
 
        def mspf():
8684
 
            """Milliseconds per frame"""
8685
 
            return int(1000 // (player.get_fps() or 25))
8686
 
 
8687
 
 
8688
 
        def print_info():
8689
 
            """Print information about the media"""
8690
 
            try:
8691
 
                print_version()
8692
 
                media = player.get_media()
8693
 
                print('State: %s' % player.get_state())
8694
 
                print('Media: %s' % bytes_to_str(media.get_mrl()))
8695
 
                print('Track: %s/%s' % (player.video_get_track(), player.video_get_track_count()))
8696
 
                print('Current time: %s/%s' % (player.get_time(), media.get_duration()))
8697
 
                print('Position: %s' % player.get_position())
8698
 
                print('FPS: %s (%d ms)' % (player.get_fps(), mspf()))
8699
 
                print('Rate: %s' % player.get_rate())
8700
 
                print('Video size: %s' % str(player.video_get_size(0)))  # num=0
8701
 
                print('Scale: %s' % player.video_get_scale())
8702
 
                print('Aspect ratio: %s' % player.video_get_aspect_ratio())
8703
 
            # print('Window:' % player.get_hwnd()
8704
 
            except Exception:
8705
 
                print('Error: %s' % sys.exc_info()[1])
8706
 
 
8707
 
 
8708
 
        def sec_forward():
8709
 
            """Go forward one sec"""
8710
 
            player.set_time(player.get_time() + 1000)
8711
 
 
8712
 
 
8713
 
        def sec_backward():
8714
 
            """Go backward one sec"""
8715
 
            player.set_time(player.get_time() - 1000)
8716
 
 
8717
 
 
8718
 
        def frame_forward():
8719
 
            """Go forward one frame"""
8720
 
            player.set_time(player.get_time() + mspf())
8721
 
 
8722
 
 
8723
 
        def frame_backward():
8724
 
            """Go backward one frame"""
8725
 
            player.set_time(player.get_time() - mspf())
8726
 
 
8727
 
 
8728
 
        def print_help():
8729
 
            """Print help"""
8730
 
            print('Single-character commands:')
8731
 
            for k, m in sorted(keybindings.items()):
8732
 
                m = (m.__doc__ or m.__name__).splitlines()[0]
8733
 
                print('  %s: %s.' % (k, m.rstrip('.')))
8734
 
            print('0-9: go to that fraction of the movie')
8735
 
 
8736
 
 
8737
 
        def quit_app():
8738
 
            """Stop and exit"""
8739
 
            sys.exit(0)
8740
 
 
8741
 
 
8742
 
        def toggle_echo_position():
8743
 
            """Toggle echoing of media position"""
8744
 
            global echo_position
8745
 
            echo_position = not echo_position
8746
 
 
8747
 
 
8748
 
        keybindings = {
8749
 
            ' ': player.pause,
8750
 
            '+': sec_forward,
8751
 
            '-': sec_backward,
8752
 
            '.': frame_forward,
8753
 
            ',': frame_backward,
8754
 
            'f': player.toggle_fullscreen,
8755
 
            'i': print_info,
8756
 
            'p': toggle_echo_position,
8757
 
            'q': quit_app,
8758
 
            '?': print_help,
8759
 
        }
8760
 
 
8761
 
        print('Press q to quit, ? to get help.%s' % os.linesep)
8762
 
        while True:
8763
 
            k = getch()
8764
 
            print('> %s' % k)
8765
 
            if k in keybindings:
8766
 
                keybindings[k]()
8767
 
            elif k.isdigit():
8768
 
                # jump to fraction of the movie.
8769
 
                player.set_position(float('0.' + k))
8770
 
 
8771
 
    else:
8772
 
        print('Usage: %s [options] <movie_filename>' % sys.argv[0])
8773
 
        print('Once launched, type ? for help.')
8774
 
        print('')
8775
 
        print_version()