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