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 twisted.internet import defer 25 26 from flumotion.common import errors, gstreamer, messages 27 from flumotion.common.i18n import N_, gettexter 28 from flumotion.component import feedcomponent 29 from flumotion.component.effects.volume import volume 30 from flumotion.worker.checks import check 31 32 __version__ = "$Rev: 7649 $" 33 T_ = gettexter() 34 35 49 5052 componentMediumClass = AudioTestMedium 5314355 self.uiState.addKey('wave-names', 56 ['Sine', 'Square', 'Saw', 'Triangle']) 57 self.uiState.addKey('wave', 0) 58 self.uiState.addKey('frequency', 440) 59 self.uiState.addKey('samplerate', 441000)6062 levelD = check.do_check(self, check.checkPlugin, 'level', 'level') 63 audiotestD = check.do_check(self, check.checkPlugin, 'audiotestsrc', 64 'audiotestsrc') 65 volumeD = check.do_check(self, check.checkPlugin, 'volume', 'volume') 66 dl = defer.DeferredList([levelD, audiotestD, volumeD]) 67 return dl6870 samplerate = properties.get('samplerate', 44100) 71 self.samplerate = samplerate 72 volume = properties.get('volume', 1.0) 73 74 is_live = 'is-live=true' 75 source = 'audiotestsrc' 76 77 if not gstreamer.element_factory_exists(source): 78 raise errors.MissingElementError(source) 79 80 return ('%s name=source %s ! identity name=identity silent=TRUE ! ' \ 81 'audio/x-raw-int,rate=%d ! ' \ 82 'volume name=volume volume=%f ! level name=level' 83 % (source, is_live, samplerate, volume))8486 87 self.fixRenamedProperties(properties, [ 88 ('freq', 'frequency'), 89 ]) 90 91 element = self.get_element('source') 92 if 'frequency' in properties: 93 element.set_property('freq', properties['frequency']) 94 self.uiState.set('frequency', properties['frequency']) 95 96 if 'drop-probability' in properties: 97 vt = gstreamer.get_plugin_version('coreelements') 98 if not vt: 99 raise errors.MissingElementError('identity') 100 if not vt > (0, 10, 12, 0): 101 self.addMessage( 102 messages.Warning(T_(N_( 103 "The 'drop-probability' property is specified, but " 104 "it only works with GStreamer core newer than 0.10.12." 105 " You should update your version of GStreamer.")))) 106 else: 107 drop_probability = properties['drop-probability'] 108 if drop_probability < 0.0 or drop_probability > 1.0: 109 self.addMessage( 110 messages.Warning(T_(N_( 111 "The 'drop-probability' property can only be " 112 "between 0.0 and 1.0.")))) 113 else: 114 identity = self.get_element('identity') 115 identity.set_property('drop-probability', 116 drop_probability) 117 118 self.uiState.set('samplerate', self.samplerate) 119 self.uiState.set('wave', int(element.get_property('wave'))) 120 121 level = pipeline.get_by_name('level') 122 vol = volume.Volume('volume', level, pipeline) 123 self.addEffect(vol)124126 self.debug("Volume set to %d" % value) 127 element = self.get_element('volume') 128 element.set_property('volume', value)129 133135 element = self.get_element('source') 136 element.set_property('freq', frequency) 137 self.uiState.set('frequency', frequency)138140 element = self.get_element('source') 141 element.set_property('wave', wave) 142 self.uiState.set('wave', wave)
Trees | Indices | Help |
---|
Generated by Epydoc 3.0.1 on Sun Nov 15 09:17:54 2009 | http://epydoc.sourceforge.net |