Package common :: Module multimedia_helpers
[hide private]
[frames] | no frames]

Source Code for Module common.multimedia_helpers

  1  ## 
  2  ## Copyright (C) 2009 Thibaut GIRKA <thib AT sitedethib.com> 
  3  ## 
  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. 
  7  ## 
  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. 
 12  ## 
 13   
 14  import gst 
 15   
 16   
17 -class DeviceManager(object):
18 - def __init__(self):
19 self.devices = {}
20
21 - def detect(self):
22 self.devices = {}
23
24 - def get_devices(self):
25 if not self.devices: 26 self.detect() 27 return self.devices
28
29 - def detect_element(self, name, text, pipe='%s'):
30 try: 31 element = gst.element_factory_make(name, '%spresencetest' % name) 32 if isinstance(element, gst.interfaces.PropertyProbe): 33 element.set_state(gst.STATE_READY) 34 element.probe_property_name('device') 35 devices = element.probe_get_values_name('device') 36 if devices: 37 self.devices[text % _(' Default device')] = pipe % name 38 for device in devices: 39 element.set_state(gst.STATE_NULL) 40 element.set_property('device', device) 41 element.set_state(gst.STATE_READY) 42 device_name = element.get_property('device-name') 43 self.devices[text % device_name] = pipe % '%s device=%s' % (name, device) 44 element.set_state(gst.STATE_NULL) 45 else: 46 self.devices[text] = pipe % name 47 except gst.ElementNotFoundError: 48 print 'element \'%s\' not found' % name
49 50
51 -class AudioInputManager(DeviceManager):
52 - def detect(self):
53 self.devices = {} 54 # Test src 55 self.detect_element('audiotestsrc', _('Audio test'), 56 '%s is-live=true name=gajim_vol') 57 # Auto src 58 self.detect_element('autoaudiosrc', _('Autodetect'), 59 '%s ! volume name=gajim_vol') 60 # Alsa src 61 self.detect_element('alsasrc', _('ALSA: %s'), 62 '%s ! volume name=gajim_vol')
63 64
65 -class AudioOutputManager(DeviceManager):
66 - def detect(self):
67 self.devices = {} 68 # Fake sink 69 self.detect_element('fakesink', _('Fake audio output')) 70 # Auto sink 71 self.detect_element('autoaudiosink', _('Autodetect')) 72 # Alsa sink 73 self.detect_element('alsasink', _('ALSA: %s'), 74 '%s sync=false')
75 76
77 -class VideoInputManager(DeviceManager):
78 - def detect(self):
79 self.devices = {} 80 # Test src 81 self.detect_element('videotestsrc', _('Video test'), 82 '%s is-live=true ! video/x-raw-yuv,framerate=10/1') 83 # Auto src 84 self.detect_element('autovideosrc', _('Autodetect')) 85 # V4L2 src 86 self.detect_element('v4l2src', _('V4L2: %s'))
87 # Funny things, just to test... 88 # self.devices['GOOM'] = 'audiotestsrc ! goom' 89 # self.devices['screen'] = 'ximagesrc' 90 91
92 -class VideoOutputManager(DeviceManager):
93 - def detect(self):
94 self.devices = {} 95 # Fake video output 96 self.detect_element('fakesink', _('Fake audio output')) 97 # Auto sink 98 self.detect_element('xvimagesink', _('X Window System (X11/XShm/Xv): %s')) 99 # ximagesink 100 self.detect_element('ximagesink', _('X Window System (without Xv)')) 101 self.detect_element('autovideosink', _('Autodetect'))
102