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

Proposed by Tim Bentley
Status: Superseded
Proposed branch: lp:~trb143/openlp/media_state
Merge into: lp:openlp
Diff against target: 8464 lines (+3680/-2310)
46 files modified
openlp/core/app.py (+5/-1)
openlp/core/common/actions.py (+1/-1)
openlp/core/common/mixins.py (+2/-1)
openlp/core/common/registry.py (+7/-0)
openlp/core/lib/mediamanageritem.py (+37/-26)
openlp/core/lib/plugin.py (+5/-4)
openlp/core/lib/pluginmanager.py (+66/-44)
openlp/core/lib/serviceitem.py (+7/-2)
openlp/core/loader.py (+48/-0)
openlp/core/state.py (+173/-0)
openlp/core/ui/icons.py (+1/-1)
openlp/core/ui/maindisplay.py (+0/-107)
openlp/core/ui/mainwindow.py (+0/-23)
openlp/core/ui/media/__init__.py (+1/-38)
openlp/core/ui/media/mediacontroller.py (+71/-164)
openlp/core/ui/media/playertab.py (+0/-1)
openlp/core/ui/media/vendor/mediainfoWrapper.py (+0/-128)
openlp/core/ui/media/vendor/vlc.py (+2900/-1193)
openlp/core/ui/media/vlcplayer.py (+4/-4)
openlp/core/ui/pluginform.py (+3/-2)
openlp/core/ui/settingsform.py (+0/-6)
openlp/core/ui/slidecontroller.py (+54/-108)
openlp/core/widgets/views.py (+1/-1)
openlp/plugins/alerts/alertsplugin.py (+3/-0)
openlp/plugins/bibles/bibleplugin.py (+3/-0)
openlp/plugins/custom/customplugin.py (+3/-0)
openlp/plugins/images/imageplugin.py (+3/-0)
openlp/plugins/media/lib/mediaitem.py (+50/-146)
openlp/plugins/media/mediaplugin.py (+3/-52)
openlp/plugins/presentations/presentationplugin.py (+3/-0)
openlp/plugins/songs/lib/mediaitem.py (+17/-6)
openlp/plugins/songs/songsplugin.py (+3/-0)
openlp/plugins/songusage/songusageplugin.py (+3/-0)
scripts/check_dependencies.py (+2/-1)
scripts/jenkins_script.py (+6/-5)
tests/functional/openlp_core/lib/test_serviceitem.py (+5/-1)
tests/functional/openlp_core/test_state.py (+150/-0)
tests/functional/openlp_core/ui/media/test_mediacontroller.py (+32/-101)
tests/functional/openlp_core/ui/test_maindisplay.py (+1/-16)
tests/functional/openlp_core/ui/test_media.py (+5/-5)
tests/functional/openlp_plugins/media/test_mediaplugin.py (+1/-27)
tests/interfaces/openlp_core/lib/test_pluginmanager.py (+1/-1)
tests/interfaces/openlp_core/ui/media/__init__.py (+0/-21)
tests/interfaces/openlp_core/ui/media/vendor/__init__.py (+0/-21)
tests/interfaces/openlp_core/ui/media/vendor/test_mediainfoWrapper.py (+0/-48)
tests/openlp_core/projectors/test_projector_db.py (+0/-4)
To merge this branch: bzr merge lp:~trb143/openlp/media_state
Reviewer Review Type Date Requested Status
OpenLP Core Pending
Review via email: mp+359973@code.launchpad.net

This proposal has been superseded by a proposal from 2018-12-02.

Commit message

This is to do a code review and see what mess is left

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

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

lp:~trb143/openlp/media_state updated
2855. By Tim Bentley

Fix tests and code

2856. By Tim Bentley

Fix tests and code

2857. By Tim Bentley

Fix tests and code

2858. By Tim Bentley

Fix tests and code

2859. By Tim Bentley

Fix tests and code

2860. By Tim Bentley

Fix tests and code

2861. By Tim Bentley

Fix tests and code

2862. By Tim Bentley

Fix tests and code

2863. By Tim Bentley

Fix tests and code

2864. By Tim Bentley

Fix tests

2865. By Tim Bentley

Fix tests

2866. By Tim Bentley

Fix tests

2867. By Tim Bentley

Fix tests

2868. By Tim Bentley

Fix tests

2869. By Tim Bentley

Fix tests

2870. By Tim Bentley

Fix tests

2871. By Tim Bentley

Fix tests

2872. By Tim Bentley

Fix tests

2873. By Tim Bentley

Fix tests

2874. By Tim Bentley

Fix tests

2875. By Tim Bentley

Fix tests

2876. By Tim Bentley

test fixing

2877. By Tim Bentley

test fixing

2878. By Tim Bentley

test fixing

2879. By Tim Bentley

fixes

2880. By Tim Bentley

fixes

2881. By Tim Bentley

fixes

2882. By Tim Bentley

fix bits

2883. By Tim Bentley

fix bits

2884. By Tim Bentley

fixes

2885. By Tim Bentley

fixes

2886. By Tim Bentley

fixes

2887. By Tim Bentley

fixes

2888. By Tim Bentley

remove unneeded

2889. By Tim Bentley

try again

2890. By Tim Bentley

for fixes

2891. By Tim Bentley

for fixes

2892. By Tim Bentley

for fixes

2893. By Tim Bentley

for fixes

2894. By Tim Bentley

for fixes

2895. By Tim Bentley

for fixes

2896. By Tim Bentley

for fixes

2897. By Tim Bentley

for fixes

2898. By Tim Bentley

for fixes

2899. By Tim Bentley

for fixes

2900. By Tim Bentley

for fixes

2901. By Tim Bentley

try again

2902. By Tim Bentley

try again

2903. By Tim Bentley

try again

2904. By Tim Bentley

try again

2905. By Tim Bentley

try again

2906. By Tim Bentley

try again

2907. By Tim Bentley

try again

2908. By Tim Bentley

try again

2909. By Tim Bentley

try again

2910. By Tim Bentley

pep8

2911. By Tim Bentley

pep8

2912. By Tim Bentley

pep8

2913. By Tim Bentley

pep8

2914. By Tim Bentley

pep8

2915. By Tim Bentley

Fix doc strings

2916. By Tim Bentley

fix code

2917. By Tim Bentley

fix code

2918. By Tim Bentley

fix

2919. By Tim Bentley

settings updates

2920. By Tim Bentley

Move settings

2921. By Tim Bentley

clean ups and settings

2922. By Tim Bentley

More stream stuff

2923. By Tim Bentley

Add settings tab

2924. By Tim Bentley

Head

2925. By Tim Bentley

Head 2

2926. By Tim Bentley

Media is now playing again - just

2927. By Tim Bentley

head

2928. By Tim Bentley

media now works and plays

2929. By Tim Bentley

vlc tests pass

2930. By Tim Bentley

fix pep8.5

2931. By Tim Bentley

fix pep8.5

2932. By Tim Bentley

Fixes and handle missing display

2933. By Tim Bentley

handle missing live display preserve prview

2934. By Tim Bentley

add experimental flag

2935. By Tim Bentley

pep8

2936. By Tim Bentley

head

Unmerged revisions

Preview Diff

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