From d136984f9fcd2d18a2827ae94347ae2aece125f3 Mon Sep 17 00:00:00 2001 From: Thomas Adamcik Date: Fri, 13 May 2011 20:13:00 +0200 Subject: [PATCH] Split outputs into seperate files --- docs/api/outputs.rst | 8 ++-- docs/modules/outputs.rst | 8 ++-- mopidy/outputs/__init__.py | 77 ------------------------------------- mopidy/outputs/custom.py | 26 +++++++++++++ mopidy/outputs/local.py | 12 ++++++ mopidy/outputs/null.py | 16 ++++++++ mopidy/outputs/shoutcast.py | 25 ++++++++++++ mopidy/settings.py | 4 +- 8 files changed, 89 insertions(+), 87 deletions(-) create mode 100644 mopidy/outputs/custom.py create mode 100644 mopidy/outputs/local.py create mode 100644 mopidy/outputs/null.py create mode 100644 mopidy/outputs/shoutcast.py diff --git a/docs/api/outputs.rst b/docs/api/outputs.rst index 062eabdd..d801116d 100644 --- a/docs/api/outputs.rst +++ b/docs/api/outputs.rst @@ -13,7 +13,7 @@ Outputs are used by :mod:`mopidy.gstreamer` to output audio in some way. Output implementations ====================== -* :class:`mopidy.outputs.CustomOutput` -* :class:`mopidy.outputs.LocalOutput` -* :class:`mopidy.outputs.NullOutput` -* :class:`mopidy.outputs.ShoutcastOutput` +* :class:`mopidy.outputs.custom.CustomOutput` +* :class:`mopidy.outputs.local.LocalOutput` +* :class:`mopidy.outputs.null.NullOutput` +* :class:`mopidy.outputs.shoutcast.ShoutcastOutput` diff --git a/docs/modules/outputs.rst b/docs/modules/outputs.rst index 7da29fbc..c7a45d84 100644 --- a/docs/modules/outputs.rst +++ b/docs/modules/outputs.rst @@ -6,10 +6,10 @@ The following GStreamer audio outputs implements the :ref:`output-api`. .. inheritance-diagram:: mopidy.outputs -.. autoclass:: mopidy.outputs.CustomOutput +.. autoclass:: mopidy.outputs.custom.CustomOutput -.. autoclass:: mopidy.outputs.LocalOutput +.. autoclass:: mopidy.outputs.local.LocalOutput -.. autoclass:: mopidy.outputs.NullOutput +.. autoclass:: mopidy.outputs.null.NullOutput -.. autoclass:: mopidy.outputs.ShoutcastOutput +.. autoclass:: mopidy.outputs.shoutcast.ShoutcastOutput diff --git a/mopidy/outputs/__init__.py b/mopidy/outputs/__init__.py index d1512617..a3aff0d8 100644 --- a/mopidy/outputs/__init__.py +++ b/mopidy/outputs/__init__.py @@ -4,8 +4,6 @@ import pygst pygst.require('0.10') import gst -from mopidy import settings - logger = logging.getLogger('mopidy.outputs') @@ -76,78 +74,3 @@ class BaseOutput(object): for key, value in properties.items(): if value is not None: element.set_property(key, value) - - -class CustomOutput(BaseOutput): - """ - Custom output for using alternate setups. - - This output is intended to handle two main cases: - - 1. Simple things like switching which sink to use. Say :class:`LocalOutput` - doesn't work for you and you want to switch to ALSA, simple. Set - :attr:`mopidy.settings.CUSTOM_OUTPUT` to ``alsasink`` and you are good - to go. Some possible sinks include: - - - alsasink - - osssink - - pulsesink - - ...and many more - - 2. Advanced setups that require complete control of the output bin. For - these cases setup :attr:`mopidy.settings.CUSTOM_OUTPUT` with a - :command:`gst-launch` compatible string describing the target setup. - - """ - def describe_bin(self): - return settings.CUSTOM_OUTPUT - - -class LocalOutput(BaseOutput): - """ - Basic output to local audio sink. - - This output will normally tell GStreamer to choose whatever it thinks is - best for your system. In other words this is usually a sane choice. - """ - - def describe_bin(self): - return 'autoaudiosink' - - -class NullOutput(BaseOutput): - """ - Fall-back null output. - - This output will not output anything. It is intended as a fall-back for - when setup of all other outputs have failed and should not be used by end - users. Inserting this output in such a case ensures that the pipeline does - not crash. - """ - - def describe_bin(self): - return 'fakesink' - - -class ShoutcastOutput(BaseOutput): - """ - Shoutcast streaming output. - - This output allows for streaming to an icecast server or anything else that - supports Shoutcast. The output supports setting for: server address, port, - mount point, user, password and encoder to use. Please see - :class:`mopidy.settings` for details about settings. - """ - - def describe_bin(self): - return 'audioconvert ! %s ! shout2send name=shoutcast' \ - % settings.SHOUTCAST_OUTPUT_ENCODER - - def modify_bin(self, output): - self.set_properties(output.get_by_name('shoutcast'), { - u'ip': settings.SHOUTCAST_OUTPUT_SERVER, - u'mount': settings.SHOUTCAST_OUTPUT_MOUNT, - u'port': settings.SHOUTCAST_OUTPUT_PORT, - u'username': settings.SHOUTCAST_OUTPUT_USERNAME, - u'password': settings.SHOUTCAST_OUTPUT_PASSWORD, - }) diff --git a/mopidy/outputs/custom.py b/mopidy/outputs/custom.py new file mode 100644 index 00000000..c5ca30bb --- /dev/null +++ b/mopidy/outputs/custom.py @@ -0,0 +1,26 @@ +from mopidy import settings +from mopidy.outputs import BaseOutput + +class CustomOutput(BaseOutput): + """ + Custom output for using alternate setups. + + This output is intended to handle two main cases: + + 1. Simple things like switching which sink to use. Say :class:`LocalOutput` + doesn't work for you and you want to switch to ALSA, simple. Set + :attr:`mopidy.settings.CUSTOM_OUTPUT` to ``alsasink`` and you are good + to go. Some possible sinks include: + + - alsasink + - osssink + - pulsesink + - ...and many more + + 2. Advanced setups that require complete control of the output bin. For + these cases setup :attr:`mopidy.settings.CUSTOM_OUTPUT` with a + :command:`gst-launch` compatible string describing the target setup. + + """ + def describe_bin(self): + return settings.CUSTOM_OUTPUT diff --git a/mopidy/outputs/local.py b/mopidy/outputs/local.py new file mode 100644 index 00000000..e004a076 --- /dev/null +++ b/mopidy/outputs/local.py @@ -0,0 +1,12 @@ +from mopidy.outputs import BaseOutput + +class LocalOutput(BaseOutput): + """ + Basic output to local audio sink. + + This output will normally tell GStreamer to choose whatever it thinks is + best for your system. In other words this is usually a sane choice. + """ + + def describe_bin(self): + return 'autoaudiosink' diff --git a/mopidy/outputs/null.py b/mopidy/outputs/null.py new file mode 100644 index 00000000..975b9724 --- /dev/null +++ b/mopidy/outputs/null.py @@ -0,0 +1,16 @@ +from mopidy.outputs import BaseOutput + +class NullOutput(BaseOutput): + """ + Fall-back null output. + + This output will not output anything. It is intended as a fall-back for + when setup of all other outputs have failed and should not be used by end + users. Inserting this output in such a case ensures that the pipeline does + not crash. + """ + + def describe_bin(self): + return 'fakesink' + + diff --git a/mopidy/outputs/shoutcast.py b/mopidy/outputs/shoutcast.py new file mode 100644 index 00000000..d13b1085 --- /dev/null +++ b/mopidy/outputs/shoutcast.py @@ -0,0 +1,25 @@ +from mopidy import settings +from mopidy.outputs import BaseOutput + +class ShoutcastOutput(BaseOutput): + """ + Shoutcast streaming output. + + This output allows for streaming to an icecast server or anything else that + supports Shoutcast. The output supports setting for: server address, port, + mount point, user, password and encoder to use. Please see + :class:`mopidy.settings` for details about settings. + """ + + def describe_bin(self): + return 'audioconvert ! %s ! shout2send name=shoutcast' \ + % settings.SHOUTCAST_OUTPUT_ENCODER + + def modify_bin(self, output): + self.set_properties(output.get_by_name('shoutcast'), { + u'ip': settings.SHOUTCAST_OUTPUT_SERVER, + u'mount': settings.SHOUTCAST_OUTPUT_MOUNT, + u'port': settings.SHOUTCAST_OUTPUT_PORT, + u'username': settings.SHOUTCAST_OUTPUT_USERNAME, + u'password': settings.SHOUTCAST_OUTPUT_PASSWORD, + }) diff --git a/mopidy/settings.py b/mopidy/settings.py index 1aa4a630..414c79ee 100644 --- a/mopidy/settings.py +++ b/mopidy/settings.py @@ -173,10 +173,10 @@ MPD_SERVER_PORT = 6600 #: Default:: #: #: OUTPUTS = ( -#: u'mopidy.outputs.LocalOutput', +#: u'mopidy.outputs.local.LocalOutput', #: ) OUTPUTS = ( - u'mopidy.outputs.LocalOutput', + u'mopidy.outputs.local.LocalOutput', ) #: Servar that runs Shoutcast server to send stream to.