Home | Trees | Indices | Help |
---|
|
1 # -*- coding: utf-8 -*- 2 # Elisa - Home multimedia server 3 # Copyright (C) 2006-2008 Fluendo Embedded S.L. (www.fluendo.com). 4 # All rights reserved. 5 # 6 # This file is available under one of two license agreements. 7 # 8 # This file is licensed under the GPL version 3. 9 # See "LICENSE.GPL" in the root of this distribution including a special 10 # exception to use Elisa with Fluendo's plugins. 11 # 12 # The GPL part of Elisa is also available under a commercial licensing 13 # agreement from Fluendo. 14 # See "LICENSE.Elisa" in the root directory of this distribution package 15 # for details on that license. 16 17 """ 18 Find a usable Player Engine with the PlayerEngineRegistry 19 """ 20 21 __maintainer__ = 'Benjamin Kampmann <benjamin@fluendo.com>' 22 23 24 from elisa.core import log, common 25 from elisa.core.utils import classinit 26 27 import pygst 28 pygst.require('0.10') 29 import gst 30 33 3436 """ 37 The PlayerEngineRegistry has the responsability to create 38 L{elisa.base_components.player_engine.PlayerEngine} instances 39 given URI schemes. 40 """ 41 42 # Allows property fget/fset/fdel/doc overriding 43 __metaclass__ = classinit.ClassInitMeta 44 __classinit__ = classinit.build_properties 4512047 log.Loggable.__init__(self) 48 self._engines_by_scheme = {} 49 # FIXME: This should be configurable 50 self._audiosink = 'autoaudiosink' 51 self._audiosettings = {}52 53 5759 """ Ask the plugin registry to create all the providers 60 components defined in section 'general' of the config 61 """ 62 63 # FIXME: the default value is just temporary. Remove it soon! 64 application = common.application 65 engine_names = application.config.get_option('player_engines', 66 section='general', 67 default=['base:playbin_engine']) 68 69 plugin_registry = application.plugin_registry 70 71 for name in engine_names: 72 engine_class = plugin_registry.get_component_class(name) 73 74 if not engine_class: 75 # the class could not be found 76 self.warning("Could not find the class for the player engine" 77 " component %s" % name) 78 continue 79 80 schemes = engine_class.uri_schemes 81 for key, value in schemes.iteritems(): 82 if key in self._engines_by_scheme.keys(): 83 before_engine_class = plugin_registry.get_component_class( 84 self._engines_by_scheme[key]) 85 86 if before_engine_class.uri_schemes[key] > value: 87 self.debug("Replacing %s with %s for scheme %s" % 88 ( self._engines_by_scheme[key], name, key) ) 89 90 self._engines_by_scheme[key] = name 91 else: 92 self.debug("Adding %s for scheme %s" % (name, key)) 93 self._engines_by_scheme[key] = name94 9799 """ 100 Create a B{new} player engine instance for the given URI scheme. 101 102 @param scheme: the uri scheme that the new engine has to support 103 @type scheme: string 104 105 @raise: L{elisa.core.player_engine_registry.NoEngineFound} 106 if no engine is found 107 108 @rtype: L{elisa.base_components.player_engine.PlayerEngine} or 109 None 110 """ 111 self.debug("Creating new engine for %s" % scheme) 112 113 if scheme not in self._engines_by_scheme.keys(): 114 raise NoEngineFound() 115 116 plugin_registry = common.application.plugin_registry 117 component = self._engines_by_scheme[scheme] 118 119 return plugin_registry.create_component(component)
Home | Trees | Indices | Help |
---|
Generated by Epydoc 3.0beta1 on Wed Jan 16 19:10:36 2008 | http://epydoc.sourceforge.net |