2 ## Copyright (C) 2009 Thibaut GIRKA <thib AT sitedethib.com>
4 ## This program is free software; you can redistribute it and/or modify
5 ## it under the terms of the GNU General Public License as published
6 ## by the Free Software Foundation; version 2 only.
8 ## This program is distributed in the hope that it will be useful,
9 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
10 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 ## GNU General Public License for more details.
17 class DeviceManager(object):
24 def get_devices(self
):
29 def detect_element(self
, name
, text
, pipe
='%s'):
31 if gst
.element_factory_find(name
):
32 element
= gst
.element_factory_make(name
,
33 '%spresencetest' % name
)
34 if isinstance(element
, gst
.interfaces
.PropertyProbe
):
35 element
.set_state(gst
.STATE_READY
)
36 element
.probe_property_name('device')
37 devices
= element
.probe_get_values_name('device')
39 self
.devices
[text
% _(' Default device')] = pipe
% name
40 for device
in devices
:
41 element
.set_state(gst
.STATE_NULL
)
42 element
.set_property('device', device
)
43 element
.set_state(gst
.STATE_READY
)
44 device_name
= element
.get_property('device-name')
45 self
.devices
[text
% device_name
] = pipe
% \
46 '%s device=%s' % (name
, device
)
47 element
.set_state(gst
.STATE_NULL
)
49 self
.devices
[text
] = pipe
% name
52 except gst
.ElementNotFoundError
:
53 print 'element \'%s\' not found' % name
56 class AudioInputManager(DeviceManager
):
60 self
.detect_element('audiotestsrc', _('Audio test'),
61 '%s is-live=true name=gajim_vol')
63 self
.detect_element('autoaudiosrc', _('Autodetect'),
64 '%s ! volume name=gajim_vol')
66 self
.detect_element('alsasrc', _('ALSA: %s'),
67 '%s ! volume name=gajim_vol')
69 self
.detect_element('pulsesrc', _('Pulse: %s'),
70 '%s ! volume name=gajim_vol')
73 class AudioOutputManager(DeviceManager
):
77 self
.detect_element('fakesink', _('Fake audio output'))
79 self
.detect_element('autoaudiosink', _('Autodetect'))
81 self
.detect_element('alsasink', _('ALSA: %s'), '%s sync=false')
83 self
.detect_element('pulsesink', _('Pulse: %s'), '%s sync=true')
86 class VideoInputManager(DeviceManager
):
90 self
.detect_element('videotestsrc', _('Video test'),
91 '%s is-live=true ! video/x-raw-yuv,framerate=10/1')
93 self
.detect_element('autovideosrc', _('Autodetect'))
95 self
.detect_element('v4l2src', _('V4L2: %s'))
96 # Funny things, just to test...
97 # self.devices['GOOM'] = 'audiotestsrc ! goom'
98 # self.devices['screen'] = 'ximagesrc'
101 class VideoOutputManager(DeviceManager
):
105 self
.detect_element('fakesink', _('Fake audio output'))
107 self
.detect_element('xvimagesink',
108 _('X Window System (X11/XShm/Xv): %s'))
110 self
.detect_element('ximagesink', _('X Window System (without Xv)'))
111 self
.detect_element('autovideosink', _('Autodetect'))