coherence.backend (module)¶
Backend¶
A set of base classes related with backends.
BackendStore
¶
The base class for all MediaServer backend stores.
AbstractBackendStore
¶
Inherits from BackendStore
and extends his capabilities.
BackendItem
¶
The base class for all MediaServer backend items.
Container
¶
The base class for all containers. Actually his base class is the BackendItem with a few modifications which extends his capabilities to store backend items.
LazyContainer
¶
Inherits from Container
and extends his capabilities.
BackendRssMixin
¶
A base class intended to be implemented into a subclass which creates a deferred chain to retrieve a RDF file, parse it, extract the metadata and reschedule itself.
Note
RDF (Resource Description Framework) is a family of World Wide Web Consortium specifications originally designed as a metadata data model.
See also
RDF extended information at wikipedia: https://en.wikipedia.org/wiki/Resource_Description_Framework
-
class
Backend
(server, *args, **kwargs)[source]¶ Bases:
eventdispatcher.eventdispatcher.EventDispatcher
,coherence.log.LogAble
,coherence.extern.simple_plugin.Plugin
In the
Backend
class we initialize the very basic stuff needed to create a Backend and registers some basic events needed to be successfully detected by our server.The init method for a backend, should probably most of the time be overwritten when the init is done and send a signal to its device. We can send this signal via two methods, depending on the nature of our backend. For instance, if we want that the backend to be notified without fetching any data we could simply set the attribute
init_completed
equal to True at the end of our init method of the backend, but in some cases, we will want to send this signal after some deferred call returns a result…in that case we should process slightly differently, you can see how to do that at the end of the init method of the classBackendBaseStore
.After that, the device will then setup, announce itself and should call to the backend’s method
upnp_init()
.-
Changed in version 0.9.0:
Introduced inheritance from EventDispatcher
The emitted events changed:
Coherence.UPnP.Backend.init_completed => backend_init_completed
Added new event: backend_init_failed
Added new method
on_init_failed()
Moved class method init_completed to on_init_completed and added class variable
init_completed
Note
We can also use this init class to do whatever is necessary with the stuff we can extract from the config dict, connect maybe to an external data-source and start up the backend or if there are any UPnP service actions (Like maybe upnp_Browse for the CDS Browse action), that can’t be handled by the service classes itself, or need some special adjustments for the backend, they probably will need to be defined into the method
__init__()
.- Parameters
server (object) – This usually should be an instance of our main class
Coherence
(the UPnP device that’s hosting our backend).*args (list) – A list with extra arguments for the backend. This, must be implemented into the subclass (if needed).
**kwargs (dict) – An unpacked dictionary with the backend’s configuration.
-
logCategory
= 'backend'¶
-
implements
= []¶ A list of the device classe like:
[‘MediaServer’,’MediaRenderer’]
-
init_completed
¶ To know whenever the backend init has completed. This has to be done in the actual backend, maybe it has to wait for an answer from an external data-source first…so…the backend should set this variable to True, then the method
on_init_completed()
will be automatically triggered dispatching an event announcing that the backend has been initialized.
-
__init__
(server, *args, **kwargs)[source]¶ - Parameters
server (object) – This usually should be an instance of our main class
Coherence
(the UPnP device that’s hosting our backend).*args (list) – A list with extra arguments for the backend. This, must be implemented into the subclass (if needed).
**kwargs (dict) – An unpacked dictionary with the backend’s configuration.
-
on_init_completed
(*args, **kwargs)[source]¶ Inform Coherence that this backend is ready for announcement. This method just accepts any form of arguments as we don’t under which circumstances it is called.
-
class
BackendStore
(server, *args, **kwargs)[source]¶ Bases:
coherence.backend.Backend
The base class for all MediaServer backend stores. Inherits from class
Backend
and extends his capabilities to make easy to create a Backend Store by setting an initial wmc mapping, and defining some attributes and methods needed by a Backend Store.- Parameters
server (object) – This usually should be an instance of our main class
Coherence
(the UPnP device that’s hosting our backend).*args (list) – A list with extra arguments for the backend. This, must be implemented into the subclass (if needed).
**kwargs (dict) – An unpacked dictionary with the backend’s configuration.
Note
In case we want so serve something via the MediaServer web backend, the class
BackendItem
should pass an URI assembled of urlbase + ‘/’ + id to theResource
.Warning
Remember to sent the event init_completed via setting to True the attribute
init_completed
. Check the base classBackend
for instructions about how to do it.-
logCategory
= 'backend_store'¶
-
__init__
(server, *args, **kwargs)[source]¶ - Parameters
server (object) – This usually should be an instance of our main class
Coherence
(the UPnP device that’s hosting our backend).*args (list) – A list with extra arguments for the backend. This, must be implemented into the subclass (if needed).
**kwargs (dict) – An unpacked dictionary with the backend’s configuration.
Note
In case we want so serve something via the MediaServer web backend, the class
BackendItem
should pass an URI assembled of urlbase + ‘/’ + id to theResource
.Warning
Remember to sent the event init_completed via setting to True the attribute
init_completed
. Check the base classBackend
for instructions about how to do it.
-
release
()[source]¶ If anything needs to be cleaned up upon shutdown of this backend, this is the place for it. Should be overwritten in subclass.
-
_get_all_items
(id)[source]¶ A helper method to get all items as a response to some XBox 360 UPnP Search action probably never be used as the backend will overwrite the wmc_mapping with more appropriate methods.
-
get_by_id
(id)[source]¶ - Parameters
id (object) – is the id property of our DIDLLite item
- Returns
None when no matching item for that id is found,
a BackendItem,
or a Deferred
Called by the CDS or the MediaServer web.
Note
if this MediaServer implements containers that can share their content, like ‘all tracks’, ‘album’ and ‘album_of_artist’ (they all have the same track item as content), then the id may be passed by the CDS like this:
‘id@container’ or ‘id@container@container@container…’
therefore a
if isinstance(id, basestring): id = id.split('@',1) id = id[0]
may be appropriate as the first thing to do when entering this method.
-
class
BackendItem
(*args, **kwargs)[source]¶ Bases:
eventdispatcher.eventdispatcher.EventDispatcher
,coherence.log.LogAble
This is the base class for all MediaServer backend items.
Most of the time we collect the necessary data for an UPnP ContentDirectoryService Container or Object and instantiate it into the
__init__()
self.item = DIDLLite.Container(id,parent_id,name,...)
or
self.item = DIDLLite.MusicTrack(id,parent_id,name,...)
To make that a valid UPnP CDS Object it needs one or more DIDLLite.
Resource
self.item.res = [] res = DIDLLite.Resource(url, f'http-get:*:{mimetype}:*') res.size = size self.item.res.append(res)
Note
url should be the urlbase of our backend + ‘/’ + our id.
-
Changed in version 0.9.0:
Introduced inheritance from EventDispatcher
Moved class variable
update_id
to classContainer.update_id
Added class variable
mimetype
to benefit from the EventDispatcher’s properties
-
logCategory
= 'backend_item'¶
-
name
= 'backend_item_name'¶ the basename of a file, the album title, the artists name…is expected to be unicode
-
location
= None¶ the filepath of our media file, or alternatively a FilePath or a ReverseProxyResource object
-
cover
= None¶ if we have some album art image, let’s put the filepath or link into here
-
store
= None¶ The backend store.
-
storage_id
= None¶ The id of the backend store.
-
mimetype
¶ The mimetype variable describes the protocol info for the object.
-
get_child_count
()[source]¶ Called by the CDS.
- Returns
the number of its childs - len(childs)
or a Deferred
-
get_item
()[source]¶ Called by the CDS and the MediaServer web.
- Returns
an UPnP ContentDirectoryServer DIDLLite object
or a Deferred
-
get_name
()[source]¶ Called by the MediaServer web.
- Returns
the name of the item, it is always expected to be in unicode.
-
class
BackendRssMixin
[source]¶ Bases:
object
-
class
Container
(parent, title)[source]¶ Bases:
coherence.backend.BackendItem
Represents a backend item which will contains backend items inside.
-
Changed in version 0.9.0:
Added static class variable
update_id
Changed some variables to benefit from the EventDispatcher’s properties:
-
update_id
¶ It represents the update id of thhe container. This should be incremented on every modification of the UPnP ContentDirectoryService Container, as we do in methods
add_child()
andremove_child()
.
-
children
¶ A list of the backend items.
-
children_ids
¶ A dictionary of the backend items by his id.
-
children_by_external_id
¶ A dictionary of the backend items by his external id.
-
parent_id
= -1¶ The id of the parent object. This will be automatically set whenever we set the attribute
parent
.
-
mimetype
= 'directory'¶ The mimetype variable describes the protocol info for the object. In a
Container
this should be set to value directory or root.
-
parent
¶ The parent object for this class.
-
get_child_count
()[source]¶ Called by the CDS.
- Returns
the number of its childs - len(childs)
or a Deferred
-
get_path
()[source]¶ Called by the MediaServer web.
- Returns
the filepath where to find the media file that this item does refer to.
-
get_item
()[source]¶ Called by the CDS and the MediaServer web.
- Returns
an UPnP ContentDirectoryServer DIDLLite object
or a Deferred
-
class
LazyContainer
(parent, title, external_id=None, refresh=0, childrenRetriever=None, **kwargs)[source]¶ Bases:
coherence.backend.Container
-
logCategory
= 'lazyContainer'¶
-
-
class
AbstractBackendStore
(server, **kwargs)[source]¶ Bases:
coherence.backend.BackendStore
-
get_by_id
(id)[source]¶ - Parameters
id (object) – is the id property of our DIDLLite item
- Returns
None when no matching item for that id is found,
a BackendItem,
or a Deferred
Called by the CDS or the MediaServer web.
Note
if this MediaServer implements containers that can share their content, like ‘all tracks’, ‘album’ and ‘album_of_artist’ (they all have the same track item as content), then the id may be passed by the CDS like this:
‘id@container’ or ‘id@container@container@container…’
therefore a
if isinstance(id, basestring): id = id.split('@',1) id = id[0]
may be appropriate as the first thing to do when entering this method.
-
coherence.base (module)¶
Base¶
The core of the project. Holds the class Coherence
intended to be used
to manage all the resources of the project. Also contains some other classes
which are vital to the project.
SimpleRoot
¶
A web resource representing a web site. Used to build the contents browser for
our instance of a WebServer
or WebServerUi
.
WebServer
¶
A class which takes care of dealing with the web representation of the running
Coherence
’s instance. This is the default webserver used.
WebServerUi
¶
The default web server, WebServer
, can be replaced by this class which
will do the same thing as the default web server, but with a more polished
interface.
Coherence
¶
The Main class of the Cohen3 project. The Coherence class controls all the servers initialization depending on the configuration passed.
-
class
SimpleRoot
(coherence)[source]¶ Bases:
twisted.web.resource.Resource
,coherence.log.LogAble
-
addSlash
= True¶
-
logCategory
= 'coherence'¶
-
getChild
(name, request)[source]¶ Retrieve a ‘child’ resource from me.
Implement this to create dynamic resource generation – resources which are always available may be registered with self.putChild().
This will not be called if the class-level variable ‘isLeaf’ is set in your subclass; instead, the ‘postpath’ attribute of the request will be left as a list of the remaining path elements.
For example, the URL /foo/bar/baz will normally be:
| site.resource.getChild('foo').getChild('bar').getChild('baz').
However, if the resource returned by ‘bar’ has isLeaf set to true, then the getChild call will never be made on it.
Parameters and return value have the same meaning and requirements as those defined by L{IResource.getChildWithDefault}.
-
render
(request)[source]¶ Render a given resource. See L{IResource}’s render method.
I delegate to methods of self with the form ‘render_METHOD’ where METHOD is the HTTP that was used to make the request. Examples: render_GET, render_HEAD, render_POST, and so on. Generally you should implement those methods instead of overriding this one.
render_METHOD methods are expected to return a byte string which will be the rendered page, unless the return value is C{server.NOT_DONE_YET}, in which case it is this class’s responsibility to write the results using C{request.write(data)} and then call C{request.finish()}.
Old code that overrides render() directly is likewise expected to return a byte string or NOT_DONE_YET.
@see: L{IResource.render}
-
-
class
WebServer
(ui, port, coherence)[source]¶ Bases:
coherence.log.LogAble
-
logCategory
= 'webserver'¶
-
-
class
WebServerUi
(port, coherence, unittests=False)[source]¶ Bases:
coherence.base.WebServer
-
logCategory
= 'webserverui'¶
-
-
class
Plugins
(ids=('coherence.plugins.backend.media_server', 'coherence.plugins.backend.media_renderer', 'coherence.plugins.backend.binary_light', 'coherence.plugins.backend.dimmable_light'))[source]¶ Bases:
coherence.log.LogAble
-
logCategory
= 'plugins'¶
-
_valids
= ('coherence.plugins.backend.media_server', 'coherence.plugins.backend.media_renderer', 'coherence.plugins.backend.binary_light', 'coherence.plugins.backend.dimmable_light')¶
-
_plugins
= {}¶
-
_Plugins__initialized
= False¶
-
_Plugins__instance
= None¶
-
-
class
Coherence
(config=None)[source]¶ Bases:
eventdispatcher.eventdispatcher.EventDispatcher
,coherence.log.LogAble
The Main class of the Cohen3 project. The Coherence class controls all the servers initialization depending on the configuration passed. It is also capable of initialize the plugins defined in config variable or by configuration file. It supports the creation of multiple servers at once.
Example of a simple server via plugin AppleTrailersStore:
from coherence.base import Coherence from coherence.upnp.core.uuid import UUID from twisted.internet import reactor new_uuid = UUID() coherence = Coherence( {'logmode': 'info', 'controlpoint': 'yes', 'plugin': [{'backend': 'AppleTrailersStore', 'name': 'Cohen3 Example FSStore', 'uuid': new_uuid, } ] } ) reactor.run()
-
Changed in version 0.9.0:
Introduced inheritance from EventDispatcher
The emitted events changed:
Coherence.UPnP.Device.detection_completed => coherence_device_detection_completed
Coherence.UPnP.Device.removed => coherence_device_removed
Coherence.UPnP.RootDevice.removed => coherence_root_device_removed
Changed some variables to benefit from the EventDispatcher’s properties:
-
logCategory
= 'coherence'¶
-
devices
¶ A list of the added devices.
-
children
¶ A dict containing the web resources.
-
_callbacks
¶ A dict containing the callbacks, used by the methods
subscribe()
andunsubscribe()
.
-
active_backends
¶ A dict containing the active backends.
-
ctrl
¶ A coherence’s instance of class
ControlPoint
. This will be enabled if we request it by config dict or configuration file via keyword controlpoint = yes.
-
dbus
¶ A coherence’s instance of class
DBusPontoon
. This will be enabled if we request it by config dict or configuration file via keyword use_dbus = yes.
-
json
¶ A coherence’s instance of class
JsonInterface
. This will be enabled if we request it by config dict or configuration file via keyword json = yes.
-
msearch
¶ A coherence’s instance of class
MSearch
. This is automatically enabled whenCoherence
is initialized
-
ssdp_server
¶ A coherence’s instance of class
SSDPServer
. This is automatically enabled whenCoherence
is initialized
-
transcoder_manager
¶ A coherence’s instance of class
TranscoderManager
. This will be enabled if we request itby config dict or configuration file via keyword transcoding = yes.
-
web_server
¶ A coherence’s instance of class
WebServer
orWebServerUi
. We can request our preference by config dict or configuration file. If we use the keyword web-ui = yes, then the classWebServerUi
will be used, otherwise, the enabled web server will be of classWebServer
.
-
setup_part2
()[source]¶ Initializes the basic and optional services/devices and the enabled plugins (backends).
-
remove_plugin
(plugin)[source]¶ Removes a backend from Coherence
- Parameters
plugin (object) – is the object return by add_plugin or an UUID string.
-
store_plugin_config
(uuid, items)[source]¶ Find the backend with uuid and store in its the config the key and value pair(s).
-
_Coherence__cls
= None¶
-
_Coherence__incarnations
= 0¶
-
_Coherence__initialized
= False¶
-
_Coherence__instance
= None¶
-
is_device_added
(infos)[source]¶ Check if the device exists in our list of created
devices
.- Parameters
infos (dict) – Information about the device
- Returns
True if the device exists in our list of
devices
, otherwise, returns False.
New in version 0.9.0.
-
static
check_louie
(receiver, signal, method='connect')[source]¶ Check if the connect or disconnect method’s arguments are valid in order to automatically convert to EventDispatcher’s bind The old valid signals are:
Coherence.UPnP.Device.detection_completed
Coherence.UPnP.RootDevice.detection_completed
Coherence.UPnP.Device.removed
Coherence.UPnP.RootDevice.removed
New in version 0.9.0.
-
connect
(receiver, signal=None, sender=None, weak=True)[source]¶ Wrapper method around the deprecated method louie.connect. It will check if the passed signal is supported by executing the method
check_louie()
.Warning
This will probably be removed at some point, if you use the connect method you should migrate to the new event system EventDispatcher.
Changed in version 0.9.0: Added EventDispatcher’s compatibility for some basic signals
-
disconnect
(receiver, signal=None, sender=None, weak=True)[source]¶ Wrapper method around the deprecated method louie.disconnect. It will check if the passed signal is supported by executing the method
check_louie()
.Warning
This will probably be removed at some point, if you use the disconnect method you should migrate to the new event system EventDispatcher.
Changed in version 0.9.0: Added EventDispatcher’s compatibility for some basic signals
coherence.dbus_constants (module)¶
coherence.dbus_service (module)¶
coherence.json_service (module)¶
-
class
JsonInterface
(controlpoint)[source]¶ Bases:
twisted.web.resource.Resource
,coherence.log.LogAble
-
logCategory
= 'json'¶
-
getChildWithDefault
(path, request)[source]¶ Retrieve a static or dynamically generated child resource from me.
First checks if a resource was added manually by putChild, and then call getChild to check for dynamic resources. Only override if you want to affect behaviour of all child lookups, rather than just dynamic ones.
This will check to see if I have a pre-registered child resource of the given name, and call getChild if I do not.
@see: L{IResource.getChildWithDefault}
-
coherence.log (module)¶
-
class
ColoredFormatter
(msg, use_color=True)[source]¶ Bases:
logging.Formatter
-
format
(record)[source]¶ Format the specified record as text.
The record’s attribute dictionary is used as the operand to a string formatting operation which yields the returned string. Before formatting the dictionary, a couple of preparatory steps are carried out. The message attribute of the record is computed using LogRecord.getMessage(). If the formatting string uses the time (as determined by a call to usesTime(), formatTime() is called to format the event time. If there is exception information, it is formatted using formatException() and appended to the message.
-
-
class
ColoredLogger
(name)[source]¶ Bases:
logging.Logger
-
FORMAT
= '[%(levelname)-18s][$BOLD%(name)-15s$RESET] %(message)s ($BOLD%(filename)s$RESET:%(lineno)d)'¶
-
COLOR_FORMAT
= '[%(levelname)-18s][\x1b[1m%(name)-15s\x1b[0m] %(message)s (\x1b[1m%(filename)s\x1b[0m:%(lineno)d)'¶
-
-
class
LogAble
[source]¶ Bases:
object
Base class for objects that want to be able to log messages with different level of severity. The levels are, in order from least to most: log, debug, info, warning, error.
-
logCategory
= 'default'¶ Implementors can provide a category to log their messages under.
-
_Loggable__logger
= None¶
-
FORMAT
= '[%(levelname)-18s][$BOLD%(name)-15s$RESET] %(message)s ($BOLD%(filename)s$RESET:%(lineno)d)'¶
-
COLOR_FORMAT
= '[%(levelname)-18s][\x1b[1m%(name)-15s\x1b[0m] %(message)s (\x1b[1m%(filename)s\x1b[0m:%(lineno)d)'¶
-
fatal
(message, *args, **kwargs)¶
-
warn
(message, *args, **kwargs)¶
-
msg
(message, *args, **kwargs)¶
-
coherence.transcoder (module)¶
Transcoder classes to be used in combination with a Coherence MediaServer, using GStreamer pipelines for the actually work and feeding the output into a http response.
-
class
InternalTranscoder
[source]¶ Bases:
object
Just a class to inherit from and which we can look for upon creating our list of available transcoders.
-
class
FakeTransformer
(destination=None, request=None)[source]¶ Bases:
gi.repository.Gst.Element
,coherence.log.LogAble
-
logCategory
= 'faker_datasink'¶
-
_sinkpadtemplate
= <Gst.PadTemplate object at 0x7f2a9b219948 (GstPadTemplate at 0x38159f0)>¶
-
_srcpadtemplate
= <Gst.PadTemplate object at 0x7f2a9b219510 (GstPadTemplate at 0x3815a80)>¶
-
-
class
DataSink
(destination=None, request=None)[source]¶ Bases:
gi.repository.Gst.Element
,coherence.log.LogAble
-
logCategory
= 'transcoder_datasink'¶
-
_sinkpadtemplate
= <Gst.PadTemplate object at 0x7f2a9b219a68 (GstPadTemplate at 0x3815b10)>¶
-
-
class
GStreamerPipeline
(pipeline, content_type)[source]¶ Bases:
twisted.web.resource.Resource
,coherence.log.LogAble
-
logCategory
= 'gstreamer'¶
-
addSlash
= True¶
-
getChild
(name, request)[source]¶ Retrieve a ‘child’ resource from me.
Implement this to create dynamic resource generation – resources which are always available may be registered with self.putChild().
This will not be called if the class-level variable ‘isLeaf’ is set in your subclass; instead, the ‘postpath’ attribute of the request will be left as a list of the remaining path elements.
For example, the URL /foo/bar/baz will normally be:
| site.resource.getChild('foo').getChild('bar').getChild('baz').
However, if the resource returned by ‘bar’ has isLeaf set to true, then the getChild call will never be made on it.
Parameters and return value have the same meaning and requirements as those defined by L{IResource.getChildWithDefault}.
-
-
class
BaseTranscoder
(uri, destination=None, content_type=None)[source]¶ Bases:
twisted.web.resource.Resource
,coherence.log.LogAble
-
logCategory
= 'transcoder'¶
-
addSlash
= True¶
-
getChild
(name, request)[source]¶ Retrieve a ‘child’ resource from me.
Implement this to create dynamic resource generation – resources which are always available may be registered with self.putChild().
This will not be called if the class-level variable ‘isLeaf’ is set in your subclass; instead, the ‘postpath’ attribute of the request will be left as a list of the remaining path elements.
For example, the URL /foo/bar/baz will normally be:
| site.resource.getChild('foo').getChild('bar').getChild('baz').
However, if the resource returned by ‘bar’ has isLeaf set to true, then the getChild call will never be made on it.
Parameters and return value have the same meaning and requirements as those defined by L{IResource.getChildWithDefault}.
-
-
class
PCMTranscoder
(uri, destination=None, content_type=None)[source]¶ Bases:
coherence.transcoder.BaseTranscoder
,coherence.transcoder.InternalTranscoder
-
contentType
= 'audio/L16;rate=44100;channels=2'¶
-
name
= 'lpcm'¶
-
-
class
WAVTranscoder
(uri, destination=None, content_type=None)[source]¶ Bases:
coherence.transcoder.BaseTranscoder
,coherence.transcoder.InternalTranscoder
-
contentType
= 'audio/x-wav'¶
-
name
= 'wav'¶
-
-
class
MP3Transcoder
(uri, destination=None, content_type=None)[source]¶ Bases:
coherence.transcoder.BaseTranscoder
,coherence.transcoder.InternalTranscoder
-
contentType
= 'audio/mpeg'¶
-
name
= 'mp3'¶
-
-
class
MP4Transcoder
(uri, destination=None, content_type=None)[source]¶ Bases:
coherence.transcoder.BaseTranscoder
,coherence.transcoder.InternalTranscoder
Only works if H264 inside Quicktime/MP4 container is input Source has to be a valid uri
-
contentType
= 'video/mp4'¶
-
name
= 'mp4'¶
-
-
class
MP2TSTranscoder
(uri, destination=None, content_type=None)[source]¶ Bases:
coherence.transcoder.BaseTranscoder
,coherence.transcoder.InternalTranscoder
-
contentType
= 'video/mpeg'¶
-
name
= 'mpegts'¶
-
-
class
ThumbTranscoder
(uri, destination=None, content_type=None)[source]¶ Bases:
coherence.transcoder.BaseTranscoder
,coherence.transcoder.InternalTranscoder
Should create a valid thumbnail according to the DLNA spec
Warning
Neither width nor height must exceed 160px
-
contentType
= 'image/jpeg'¶
-
name
= 'thumb'¶
-
-
class
GStreamerTranscoder
(uri, destination=None, content_type=None)[source]¶ Bases:
coherence.transcoder.BaseTranscoder
A generic Transcoder based on GStreamer.
-
pipeline_description
= None¶ The pipeline which will be parsed upon calling the start method, has to be set as the attribute
pipeline_description
to the instantiated class.
-
-
class
ExternalProcessProtocol
(caller)[source]¶ Bases:
twisted.internet.protocol.ProcessProtocol
-
connectionMade
()[source]¶ Called when a connection is made.
This may be considered the initializer of the protocol, because it is called when the connection is completed. For clients, this is called once the connection to the server has been established; for servers, this is called after an accept() call stops blocking and a socket has been received. If you need to send any greeting or initial message, do it here.
-
-
class
ExternalProcessProducer
(pipeline, request)[source]¶ Bases:
object
-
logCategory
= 'externalprocess'¶
-
-
class
ExternalProcessPipeline
(uri)[source]¶ Bases:
twisted.web.resource.Resource
,coherence.log.LogAble
-
logCategory
= 'externalprocess'¶
-
addSlash
= False¶
-
pipeline_description
= None¶
-
contentType
= None¶
-
getChildWithDefault
(path, request)[source]¶ Retrieve a static or dynamically generated child resource from me.
First checks if a resource was added manually by putChild, and then call getChild to check for dynamic resources. Only override if you want to affect behaviour of all child lookups, rather than just dynamic ones.
This will check to see if I have a pre-registered child resource of the given name, and call getChild if I do not.
@see: L{IResource.getChildWithDefault}
-
render
(request)[source]¶ Render a given resource. See L{IResource}’s render method.
I delegate to methods of self with the form ‘render_METHOD’ where METHOD is the HTTP that was used to make the request. Examples: render_GET, render_HEAD, render_POST, and so on. Generally you should implement those methods instead of overriding this one.
render_METHOD methods are expected to return a byte string which will be the rendered page, unless the return value is C{server.NOT_DONE_YET}, in which case it is this class’s responsibility to write the results using C{request.write(data)} and then call C{request.finish()}.
Old code that overrides render() directly is likewise expected to return a byte string or NOT_DONE_YET.
@see: L{IResource.render}
-
-
class
TranscoderManager
(coherence=None)[source]¶ Bases:
coherence.log.LogAble
Singleton class which holds information about all available transcoders. They are put into a transcoders dict with their id as the key.
We collect all internal transcoders by searching for all subclasses of InternalTranscoder, the class will be the value.
Transcoders defined in the config are parsed and stored as a dict in the transcoders dict.
In the config, a transcoder description has to look like this:
* preliminary, will be extended and might even change without further notice *
<transcoder> <pipeline>%s ...</pipeline> <!-- we need a %s here to insert the source uri (or can we have all the times pipelines we can prepend with a '%s !') and an element named mux where we can attach our sink --> <type>gstreamer</type> <!-- could be gstreamer or process --> <name>mpegts</name> <target>video/mpeg</target> <fourth_field> <!-- value for the 4th field of the protocolInfo phalanx, default is '*' --> </transcoder>
Initializes the class
TranscoderManager
.It should be called at least once with the main
Coherence
class passed as an argument, so we have access to the config.-
logCategory
= 'transcoder_manager'¶
-
_instance_
= None¶
-
__init__
(coherence=None)[source]¶ Initializes the class
TranscoderManager
.It should be called at least once with the main
Coherence
class passed as an argument, so we have access to the config.
-