Package flumotion :: Package component :: Package producers :: Package webcam :: Module webcam
[hide private]

Source Code for Module flumotion.component.producers.webcam.webcam

 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 flumotion.common import gstreamer 
21   
22  from flumotion.component import feedcomponent 
23   
24  from flumotion.component.effects.colorbalance import colorbalance 
25   
26  __version__ = "$Rev$" 
27   
28   
29 -class Webcam(feedcomponent.ParseLaunchComponent):
30
31 - def get_pipeline_string(self, properties):
32 device = properties['device'] 33 34 # v4l was removed from the kernel, so v4l2 is default one 35 factory_name = properties.get('element-factory', 'v4l2src') 36 37 # Filtered caps 38 mime = properties.get('mime', 'video/x-raw-yuv') 39 colorspace = properties.get('format', 'I420') 40 width = properties.get('width', None) 41 height = properties.get('height', None) 42 43 string = mime 44 if mime == 'video/x-raw-yuv': 45 string += ",format=(fourcc)%s" % colorspace 46 if width: 47 string += ",width=%d" % width 48 if height: 49 string += ",height=%d" % height 50 if 'framerate' in properties: 51 f = properties['framerate'] 52 string += ",framerate=(fraction)%d/%d" % (f[0], f[1]) 53 54 if factory_name == 'v4lsrc': 55 factory_name += ' autoprobe=false autoprobe-fps=false copy-mode=1' 56 # v4l2src automatically copies 57 58 # FIXME: ffmpegcolorspace in the pipeline causes bad negotiation. 59 # hack in 0.9 to work around, not in 0.8 60 # correct solution would be to find the colorspaces, see halogen 61 # pipeline = 'v4lsrc name=source %s copy-mode=1 device=%s ! ' \ 62 # 'ffmpegcolorspace ! "%s" ! videorate ! "%s"' \ 63 # % (autoprobe, device, caps, caps) 64 return ('%s name=source device=%s ! %s ! videorate' 65 % (factory_name, device, string))
66
67 - def configure_pipeline(self, pipeline, properties):
68 # create and add colorbalance effect 69 source = pipeline.get_by_name('source') 70 hue = properties.get('hue', None) 71 saturation = properties.get('saturation', None) 72 brightness = properties.get('brightness', None) 73 contrast = properties.get('contrast', None) 74 cb = colorbalance.Colorbalance('outputColorbalance', source, 75 hue, saturation, brightness, contrast, pipeline) 76 self.addEffect(cb)
77