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 -class Icecast(feedcomponent.ParseLaunchComponent):
27
28 - def get_pipeline_string(self, properties):
29 return "gnomevfssrc name=src ! typefind name=tf"
30
31 - def configure_pipeline(self, pipeline, properties):
32 # Later, when the typefind element has successfully found the type 33 # of the data, we'll rebuild the pipeline. 34 def have_caps(tf, prob, caps): 35 capsname = caps[0].get_name() 36 # We should add appropriate parsers for any given format here. For 37 # some it's critical for this to work at all, for others it's needed 38 # for timestamps (thus for things like time-based burst-on-connect) 39 # Currently, we only handle ogg. 40 parser = None 41 if capsname == 'application/ogg': 42 parser = gst.element_factory_make('oggparse') 43 elif capsname == 'audio/mpeg': 44 parser = gst.element_factory_make('mp3parse') 45 46 if parser: 47 parser.set_state(gst.STATE_PLAYING) 48 pipeline.add(parser) 49 # Relink - unlink typefind from the bits that follow it (the 50 # gdp payloader), link in the parser, relink to the payloader. 51 pad = tf.get_pad('src') 52 peer = pad.get_peer() 53 pad.unlink(peer) 54 tf.link(parser) 55 parser.link(peer.get_parent())
56 57 src = pipeline.get_by_name('src') 58 src.set_property('location', properties['url']) 59 60 typefind = pipeline.get_by_name('tf') 61 typefind.connect('have-type', have_caps)
62