Package flumotion :: Package worker :: Package checks :: Module audio
[hide private]

Source Code for Module flumotion.worker.checks.audio

 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  from flumotion.worker.checks import check 
23  from flumotion.common import messages, log 
24   
25  import gst 
26   
27  from gst010 import do_element_check 
28   
29 -def checkMixerTracks(source_factory, device, channels, id=None):
30 """ 31 Probe the given GStreamer element factory with the given device for 32 audio mixer tracks. 33 Return a deferred firing a result. 34 35 The result is either: 36 - succesful, with a None value: no device found 37 - succesful, with a human-readable device name and a list of mixer 38 track labels. 39 - failed 40 41 @rtype: L{twisted.internet.defer.Deferred} 42 """ 43 result = messages.Result() 44 45 def get_tracks(element): 46 # Only mixers have list_tracks. Why is this a perm error? FIXME in 0.9? 47 if not element.implements_interface(gst.interfaces.Mixer): 48 msg = 'Cannot get mixer tracks from the device. '\ 49 'Check permissions on the mixer device.' 50 log.debug('checks', "returning failure: %s" % msg) 51 raise check.CheckProcError(msg) 52 return (element.get_property('device-name'), 53 [track.label for track in element.list_tracks()])
54 55 pipeline = '%s name=source device=%s ! audio/x-raw-int,channels=%d ! fakesink' % (source_factory, device, channels) 56 d = do_element_check(pipeline, 'source', get_tracks, 57 set_state_deferred = True) 58 59 d.addCallback(check.callbackResult, result) 60 d.addErrback(check.errbackNotFoundResult, result, id, device) 61 d.addErrback(check.errbackResult, result, id, device) 62 63 return d 64