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

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

 1  # -*- Mode: Python; test-case-name:flumotion.test.test_soundcard -*- 
 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  import gst.interfaces 
24   
25  from twisted.internet import defer 
26   
27  from flumotion.component import feedcomponent 
28  from flumotion.component.effects.volume import volume 
29   
30       
31 -class Soundcard(feedcomponent.ParseLaunchComponent):
32 - def do_check(self):
33 self.debug('running PyGTK/PyGST checks') 34 from flumotion.component.producers import checks 35 d1 = checks.checkTicket347() 36 d2 = checks.checkTicket348() 37 dl = defer.DeferredList([d1, d2]) 38 dl.addCallback(self._checkCallback) 39 return dl
40
41 - def _checkCallback(self, results):
42 for (state, result) in results: 43 for m in result.messages: 44 self.addMessage(m)
45
46 - def get_pipeline_string(self, properties):
47 element = properties.get('source-element', 'alsasrc') 48 device = properties.get('device', 'hw:0') 49 rate = properties.get('rate', 44100) 50 depth = properties.get('depth', 16) 51 channels = properties.get('channels', 2) 52 53 # FIXME: why do we not connect to state_changed_cb so correct 54 # soundcard input is used? 55 56 # FIXME: we should find a way to figure out what the card supports, 57 # so we can add in correct elements on the fly 58 # just adding audioscale and audioconvert always makes the soundcard 59 # open in 1000 Hz, mono 60 caps = 'audio/x-raw-int,rate=(int)%d,depth=%d,channels=%d' % ( 61 rate, depth, channels) 62 pipeline = '%s device=%s ! %s ! level name=volumelevel message=true' % ( 63 element, device, caps) 64 65 return pipeline
66
67 - def configure_pipeline(self, pipeline, properties):
68 # add volume effect 69 comp_level = pipeline.get_by_name('volumelevel') 70 vol = volume.Volume('inputVolume', comp_level, pipeline) 71 self.addEffect(vol)
72
73 - def state_changed_cb(self, element, old, new, trackLabel):
74 if old == gst.STATE_NULL and new == gst.STATE_READY: 75 for track in element.list_tracks(): 76 element.set_record(track, track.label == trackLabel)
77
78 - def setVolume(self, value):
79 self.debug("Volume set to: %d" % (value)) 80 self.warning("FIXME: soundcard.setVolume not implemented yet")
81
82 - def getVolume(self):
83 self.warning("FIXME: soundcard.getVolume not implemented yet") 84 return 1.0
85