Trees | Indices | Help |
---|
|
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 from flumotion.common import errors, gstreamer, messages 26 from flumotion.component.effects.volume import volume 27 28 from flumotion.common.messages import N_ 29 T_ = messages.gettexter('flumotion') 30 4345 componentMediumClass = AudioTestMedium 4612848 self.uiState.addKey('wave-names', 49 ['Sine', 'Square', 'Saw', 'Triangle']) 50 self.uiState.addKey('wave', 0) 51 self.uiState.addKey('frequency', 440) 52 self.uiState.addKey('rate', 8000)5355 rate = properties.get('rate', 8000) 56 self.rate = rate 57 volume = properties.get('volume', 1.0) 58 59 is_live = 'is-live=true' 60 source = 'audiotestsrc' 61 62 if not gstreamer.element_factory_exists(source): 63 raise errors.MissingElementError(source) 64 65 return ('%s name=source %s ! identity name=identity silent=TRUE ! ' \ 66 'audio/x-raw-int,rate=%d ! ' \ 67 'volume name=volume volume=%f ! level name=level' 68 % (source, is_live, rate, volume))6971 72 self.fixRenamedProperties(properties, [ 73 ('freq', 'frequency'), 74 ]) 75 76 element = self.get_element('source') 77 if properties.has_key('frequency'): 78 element.set_property('freq', properties['frequency']) 79 self.uiState.set('frequency', properties['frequency']) 80 81 if 'drop-probability' in properties: 82 vt = gstreamer.get_plugin_version('coreelements') 83 if not vt: 84 raise errors.MissingElementError('identity') 85 if not vt > (0, 10, 12, 0): 86 self.addMessage( 87 messages.Warning(T_(N_( 88 "The 'drop-probability' property is specified, but " 89 "it only works with GStreamer core newer than 0.10.12. " 90 "You should update your version of GStreamer.")))) 91 else: 92 drop_probability = properties['drop-probability'] 93 if drop_probability < 0.0 or drop_probability > 1.0: 94 self.addMessage( 95 messages.Warning(T_(N_( 96 "The 'drop-probability' property can only be " 97 "between 0.0 and 1.0.")))) 98 else: 99 identity = self.get_element('identity') 100 identity.set_property('drop-probability', 101 drop_probability) 102 103 self.uiState.set('rate', self.rate) 104 self.uiState.set('wave', int(element.get_property('wave'))) 105 106 level = pipeline.get_by_name('level') 107 vol = volume.Volume('volume', level, pipeline) 108 self.addEffect(vol)109111 self.debug("Volume set to %d" % value) 112 element = self.get_element('volume') 113 element.set_property('volume', value)114 118120 element = self.get_element('source') 121 element.set_property('freq', frequency) 122 self.uiState.set('frequency', frequency)123125 element = self.get_element('source') 126 element.set_property('wave', wave) 127 self.uiState.set('wave', wave)
Trees | Indices | Help |
---|
Generated by Epydoc 3.0.1 on Fri Apr 11 07:40:41 2008 | http://epydoc.sourceforge.net |