Package flumotion :: Package component :: Package producers :: Package icecast :: Module icecast
[hide private]

Source Code for Module flumotion.component.producers.icecast.icecast

 1  # -*- Mode: Python -*- 
 2  # vi:si:et:sw=4:sts=4:ts=4 
 3  # 
 4  # Flumotion - a streaming media server 
 5  # Copyright (C) 2004,2005,2006,2007 Fluendo, S.L. (www.fluendo.com). 
 6  # All rights reserved. 
 7   
 8  # This file may be distributed and/or modified under the terms of 
 9  # the GNU General Public License version 2 as published by 
10  # the Free Software Foundation. 
11  # This file is distributed without any warranty; without even the implied 
12  # warranty of merchantability or fitness for a particular purpose. 
13  # See "LICENSE.GPL" in the source distribution for more information. 
14   
15  # Licensees having purchased or holding a valid Flumotion Advanced 
16  # Streaming Server license may use this file in accordance with the 
17  # Flumotion Advanced Streaming Server Commercial License Agreement. 
18  # See "LICENSE.Flumotion" in the source distribution for more information. 
19   
20  # Headers in this file shall remain intact. 
21   
22  import gst 
23   
24  from flumotion.component import feedcomponent 
25   
26  __version__ = "$Rev: 6125 $" 
27   
28   
29 -class Icecast(feedcomponent.ParseLaunchComponent):
30
31 - def get_pipeline_string(self, properties):
32 return "gnomevfssrc name=src ! typefind name=tf"
33
34 - def configure_pipeline(self, pipeline, properties):
35 # Later, when the typefind element has successfully found the type 36 # of the data, we'll rebuild the pipeline. 37 def have_caps(tf, prob, caps): 38 capsname = caps[0].get_name() 39 # We should add appropriate parsers for any given format here. For 40 # some it's critical for this to work at all, for others it's needed 41 # for timestamps (thus for things like time-based burst-on-connect) 42 # Currently, we only handle ogg. 43 parser = None 44 if capsname == 'application/ogg': 45 parser = gst.element_factory_make('oggparse') 46 elif capsname == 'audio/mpeg': 47 parser = gst.element_factory_make('mp3parse') 48 49 if parser: 50 parser.set_state(gst.STATE_PLAYING) 51 pipeline.add(parser) 52 # Relink - unlink typefind from the bits that follow it (the 53 # gdp payloader), link in the parser, relink to the payloader. 54 pad = tf.get_pad('src') 55 peer = pad.get_peer() 56 pad.unlink(peer) 57 tf.link(parser) 58 parser.link(peer.get_parent())
59 60 src = pipeline.get_by_name('src') 61 src.set_property('location', properties['url']) 62 63 typefind = pipeline.get_by_name('tf') 64 typefind.connect('have-type', have_caps)
65