Create set_properties helper for BaseOutput
This commit is contained in:
parent
1c233a3f8a
commit
5c19bf8434
@ -45,6 +45,15 @@ class BaseOutput(object):
|
|||||||
"""
|
"""
|
||||||
raise NotImplementedError
|
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):
|
class GStreamer(ThreadingActor):
|
||||||
"""
|
"""
|
||||||
Audio output through `GStreamer <http://gstreamer.freedesktop.org/>`_.
|
Audio output through `GStreamer <http://gstreamer.freedesktop.org/>`_.
|
||||||
|
|||||||
@ -15,20 +15,17 @@ class ShoutcastOutput(BaseOutput):
|
|||||||
def describe_bin(self):
|
def describe_bin(self):
|
||||||
if settings.SHOUTCAST_OVERRIDE:
|
if settings.SHOUTCAST_OVERRIDE:
|
||||||
return settings.SHOUTCAST_OVERRIDE
|
return settings.SHOUTCAST_OVERRIDE
|
||||||
|
|
||||||
return 'audioconvert ! %s ! shout2send name=shoutcast' \
|
return 'audioconvert ! %s ! shout2send name=shoutcast' \
|
||||||
% settings.SHOUTCAST_ENCODER
|
% settings.SHOUTCAST_ENCODER
|
||||||
|
|
||||||
def modify_bin(self, output):
|
def modify_bin(self, output):
|
||||||
shoutcast = output.get_by_name('shoutcast')
|
if settings.SHOUTCAST_OVERRIDE:
|
||||||
properties = {
|
return
|
||||||
|
|
||||||
|
self.set_properties(output.get_by_name('shoutcast'), {
|
||||||
u'ip': settings.SHOUTCAST_SERVER,
|
u'ip': settings.SHOUTCAST_SERVER,
|
||||||
u'mount': settings.SHOUTCAST_MOUNT,
|
u'mount': settings.SHOUTCAST_MOUNT,
|
||||||
u'port': settings.SHOUTCAST_PORT,
|
u'port': settings.SHOUTCAST_PORT,
|
||||||
u'username': settings.SHOUTCAST_USER,
|
u'username': settings.SHOUTCAST_USER,
|
||||||
u'password': settings.SHOUTCAST_PASSWORD,
|
u'password': settings.SHOUTCAST_PASSWORD,
|
||||||
}
|
})
|
||||||
|
|
||||||
for key, value in properties.items():
|
|
||||||
if value:
|
|
||||||
shoutcast.set_property(key, value)
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user