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,2008,2009 Fluendo, S.L. 6 # Copyright (C) 2010,2011 Flumotion Services, S.A. 7 # All rights reserved. 8 # 9 # This file may be distributed and/or modified under the terms of 10 # the GNU Lesser General Public License version 2.1 as published by 11 # the Free Software Foundation. 12 # This file is distributed without any warranty; without even the implied 13 # warranty of merchantability or fitness for a particular purpose. 14 # See "LICENSE.LGPL" in the source distribution for more information. 15 # 16 # Headers in this file shall remain intact. 17 18 import gst 19 20 from twisted.internet import defer 21 22 from flumotion.common import errors, gstreamer, messages 23 from flumotion.common.i18n import N_, gettexter 24 from flumotion.component import feedcomponent 25 from flumotion.component.effects.volume import volume 26 from flumotion.worker.checks import check 27 28 __version__ = "$Rev$" 29 T_ = gettexter() 30 31 45 4648 componentMediumClass = AudioTestMedium 4913951 self.uiState.addKey('wave', 0) 52 self.uiState.addKey('frequency', 440) 53 self.uiState.addKey('samplerate', 44100)5456 levelD = check.do_check(self, check.checkPlugin, 'level', 'level') 57 audiotestD = check.do_check(self, check.checkPlugin, 'audiotestsrc', 58 'audiotestsrc') 59 volumeD = check.do_check(self, check.checkPlugin, 'volume', 'volume') 60 dl = defer.DeferredList([levelD, audiotestD, volumeD]) 61 return dl6264 samplerate = properties.get('samplerate', 44100) 65 wave = properties.get('wave', 0) 66 self.samplerate = samplerate 67 volume = properties.get('volume', 1.0) 68 69 is_live = 'is-live=true' 70 source = 'audiotestsrc' 71 72 if not gstreamer.element_factory_exists(source): 73 raise errors.MissingElementError(source) 74 75 return ('%s name=source wave=%s %s ! ' \ 76 'identity name=identity silent=TRUE ! ' \ 77 'audio/x-raw-int,rate=%d ! ' \ 78 'volume name=volume volume=%f ! level name=level' 79 % (source, wave, is_live, samplerate, volume))8082 83 self.fixRenamedProperties(properties, [ 84 ('freq', 'frequency'), 85 ]) 86 87 element = self.get_element('source') 88 if 'frequency' in properties: 89 element.set_property('freq', properties['frequency']) 90 self.uiState.set('frequency', properties['frequency']) 91 92 if 'drop-probability' in properties: 93 vt = gstreamer.get_plugin_version('coreelements') 94 if not vt: 95 raise errors.MissingElementError('identity') 96 if not vt > (0, 10, 12, 0): 97 self.addMessage( 98 messages.Warning(T_(N_( 99 "The 'drop-probability' property is specified, but " 100 "it only works with GStreamer core newer than 0.10.12." 101 " You should update your version of GStreamer.")))) 102 else: 103 drop_probability = properties['drop-probability'] 104 if drop_probability < 0.0 or drop_probability > 1.0: 105 self.addMessage( 106 messages.Warning(T_(N_( 107 "The 'drop-probability' property can only be " 108 "between 0.0 and 1.0.")))) 109 else: 110 identity = self.get_element('identity') 111 identity.set_property('drop-probability', 112 drop_probability) 113 114 self.uiState.set('samplerate', self.samplerate) 115 self.uiState.set('wave', int(element.get_property('wave'))) 116 117 level = pipeline.get_by_name('level') 118 vol = volume.Volume('volume', level, pipeline) 119 self.addEffect(vol)120122 self.debug("Volume set to %d" % value) 123 element = self.get_element('volume') 124 element.set_property('volume', value)125 129131 element = self.get_element('source') 132 element.set_property('freq', frequency) 133 self.uiState.set('frequency', frequency)134136 element = self.get_element('source') 137 element.set_property('wave', wave) 138 self.uiState.set('wave', wave)
Trees | Indices | Help |
---|
Generated by Epydoc 3.0.1 on Tue Aug 13 06:17:24 2013 | http://epydoc.sourceforge.net |