Create set_properties helper for BaseOutput

This commit is contained in:
Thomas Adamcik 2011-04-25 17:15:43 +02:00
parent 1c233a3f8a
commit 5c19bf8434
2 changed files with 14 additions and 8 deletions

View File

@ -45,6 +45,15 @@ class BaseOutput(object):
"""
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):
"""
Audio output through `GStreamer <http://gstreamer.freedesktop.org/>`_.

View File

@ -15,20 +15,17 @@ class ShoutcastOutput(BaseOutput):
def describe_bin(self):
if settings.SHOUTCAST_OVERRIDE:
return settings.SHOUTCAST_OVERRIDE
return 'audioconvert ! %s ! shout2send name=shoutcast' \
% settings.SHOUTCAST_ENCODER
def modify_bin(self, output):
shoutcast = output.get_by_name('shoutcast')
properties = {
if settings.SHOUTCAST_OVERRIDE:
return
self.set_properties(output.get_by_name('shoutcast'), {
u'ip': settings.SHOUTCAST_SERVER,
u'mount': settings.SHOUTCAST_MOUNT,
u'port': settings.SHOUTCAST_PORT,
u'username': settings.SHOUTCAST_USER,
u'password': settings.SHOUTCAST_PASSWORD,
}
for key, value in properties.items():
if value:
shoutcast.set_property(key, value)
})