Move output connection code to gstreamer
This commit is contained in:
parent
d136984f9f
commit
0ec662db63
@ -70,8 +70,7 @@ class GStreamer(ThreadingActor):
|
||||
self._pipeline.get_by_name('convert').get_pad('sink'))
|
||||
|
||||
for output in settings.OUTPUTS:
|
||||
output_cls = get_class(output)()
|
||||
output_cls.connect_bin(self._pipeline, self._tee)
|
||||
self.connect_output(get_class(output))
|
||||
|
||||
# Setup bus and message processor
|
||||
bus = self._pipeline.get_bus()
|
||||
@ -262,3 +261,16 @@ class GStreamer(ThreadingActor):
|
||||
}
|
||||
logger.debug('Setting tags to: %s', tags)
|
||||
self._taginject.set_property('tags', tags)
|
||||
|
||||
def connect_output(self, cls):
|
||||
"""
|
||||
Connect output to pipeline.
|
||||
|
||||
:param output: output to connect to our pipeline.
|
||||
:type output: :class:`BaseOutput`
|
||||
"""
|
||||
output = cls().get_bin()
|
||||
|
||||
self._pipeline.add(output)
|
||||
output.sync_state_with_parent() # Required to add to running pipe
|
||||
gst.element_link_many(self._tee, output)
|
||||
|
||||
@ -1,38 +1,25 @@
|
||||
import logging
|
||||
|
||||
import pygst
|
||||
pygst.require('0.10')
|
||||
import gst
|
||||
|
||||
logger = logging.getLogger('mopidy.outputs')
|
||||
import logging
|
||||
|
||||
logger = logging.getLogger('mopidy.outputs')
|
||||
|
||||
class BaseOutput(object):
|
||||
"""Base class for providing support for multiple pluggable outputs."""
|
||||
|
||||
def connect_bin(self, pipeline, element):
|
||||
def get_bin(self):
|
||||
"""
|
||||
Connect output bin to pipeline and given element.
|
||||
|
||||
In normal cases the element will probably be a `tee`,
|
||||
thus allowing us to connect any number of outputs. This
|
||||
however is why each bin is forced to have its own `queue`
|
||||
after the `tee`.
|
||||
|
||||
:param pipeline: gst.Pipeline to add output to.
|
||||
:type pipeline: :class:`gst.Pipeline`
|
||||
:param element: gst.Element in pipeline to connect output to.
|
||||
:type element: :class:`gst.Element`
|
||||
Build output bin that will attached to pipeline.
|
||||
"""
|
||||
description = 'queue ! %s' % self.describe_bin()
|
||||
logger.debug('Adding new output to tee: %s', description)
|
||||
logger.debug('Creating new output: %s', description)
|
||||
|
||||
output = gst.parse_bin_from_description(description, True)
|
||||
self.modify_bin(output)
|
||||
|
||||
pipeline.add(output)
|
||||
output.sync_state_with_parent() # Required to add to running pipe
|
||||
gst.element_link_many(element, output)
|
||||
return output
|
||||
|
||||
def modify_bin(self, output):
|
||||
"""
|
||||
|
||||
Loading…
Reference in New Issue
Block a user