From dc018024f93121a8f7e16b6eff2a034a66de9f8a Mon Sep 17 00:00:00 2001 From: Stein Magnus Jodal Date: Tue, 3 May 2011 10:04:20 +0200 Subject: [PATCH] Move BaseOutput from mopidy.gstreamer to mopidy.outputs --- mopidy/gstreamer.py | 40 ----------------------------- mopidy/outputs.py | 61 ++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 60 insertions(+), 41 deletions(-) diff --git a/mopidy/gstreamer.py b/mopidy/gstreamer.py index ddcc6a56..0c356c45 100644 --- a/mopidy/gstreamer.py +++ b/mopidy/gstreamer.py @@ -22,46 +22,6 @@ default_caps = gst.Caps(""" signed=(boolean)true, rate=(int)44100""") -class BaseOutput(object): - def connect_bin(self, pipeline, element_to_link_to): - """ - Connect output bin to pipeline and given element. - """ - description = 'queue ! %s' % self.describe_bin() - logger.debug('Adding new output to tee: %s', description) - - output = self.parse_bin(description) - self.modify_bin(output) - - pipeline.add(output) - output.sync_state_with_parent() - gst.element_link_many(element_to_link_to, output) - - def parse_bin(self, description): - return gst.parse_bin_from_description(description, True) - - def modify_bin(self, output): - """ - Modifies bin before it is installed if needed - """ - pass - - def describe_bin(self): - """ - Describe bin to be parsed. - - Must be implemented by subclasses. - """ - raise NotImplementedError - - def set_properties(self, element, properties): - """ - Set properties on element if they have a value. - """ - for key, value in properties.items(): - if value: - element.set_property(key, value) - class GStreamer(ThreadingActor): """ diff --git a/mopidy/outputs.py b/mopidy/outputs.py index 5a57f446..3aac4105 100644 --- a/mopidy/outputs.py +++ b/mopidy/outputs.py @@ -1,17 +1,76 @@ +import logging + +import pygst +pygst.require('0.10') +import gst + from mopidy import settings -from mopidy.gstreamer import BaseOutput + +logger = logging.getLogger('mopidy.outputs') + + +class BaseOutput(object): + """TODO adamcik""" + + def connect_bin(self, pipeline, element_to_link_to): + """ + Connect output bin to pipeline and given element. + """ + description = 'queue ! %s' % self.describe_bin() + logger.debug('Adding new output to tee: %s', description) + + output = self.parse_bin(description) + self.modify_bin(output) + + pipeline.add(output) + output.sync_state_with_parent() + gst.element_link_many(element_to_link_to, output) + + def parse_bin(self, description): + return gst.parse_bin_from_description(description, True) + + def modify_bin(self, output): + """ + Modifies bin before it is installed if needed + """ + pass + + def describe_bin(self): + """ + Describe bin to be parsed. + + Must be implemented by subclasses. + """ + raise NotImplementedError + + def set_properties(self, element, properties): + """ + Set properties on element if they have a value. + """ + for key, value in properties.items(): + if value: + element.set_property(key, value) + class LocalOutput(BaseOutput): + """TODO adamcik""" + def describe_bin(self): if settings.LOCAL_OUTPUT_OVERRIDE: return settings.LOCAL_OUTPUT_OVERRIDE return 'autoaudiosink' + class NullOutput(BaseOutput): + """TODO adamcik""" + def describe_bin(self): return 'fakesink' + class ShoutcastOutput(BaseOutput): + """TODO adamcik""" + def describe_bin(self): if settings.SHOUTCAST_OUTPUT_OVERRIDE: return settings.SHOUTCAST_OUTPUT_OVERRIDE