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

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

 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 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.component import feedcomponent 
25   
26 -class XProducerMedium(feedcomponent.FeedComponentMedium):
27 - def __init__(self, comp):
29
30 - def setup(self, config):
31 # called after component's setup 32 # connect to pattern notify 33 source = self.comp.get_element('source') 34 source.connect('notify::pattern', self.cb_pattern_notify)
35
36 - def cb_pattern_notify(self, object, pspec):
37 pattern = object.get_property('pattern') 38 self.debug('pattern has changed, notifying') 39 self.callRemote('adminCallRemote', 'propertyChanged', 'pattern', 40 int(pattern))
41
42 -class XProducer(feedcomponent.ParseLaunchComponent):
43 44 componentMediumClass = XProducerMedium 45
46 - def get_pipeline_string(self, properties):
47 # Filtered caps 48 struct = gst.structure_from_string("video/x-raw-rgb") 49 for k in 'width', 'height': 50 if k in properties: 51 struct[k] = properties[k] 52 53 if 'framerate' in properties: 54 framerate = properties['framerate'] 55 else: 56 # use a low default, this can be CPU-intensive 57 framerate = (5, 1) 58 59 if gst.gst_version < (0,9): 60 struct['framerate'] = float(framerate[0]) / framerate[1] 61 else: 62 struct['framerate'] = gst.Fraction(framerate[0], framerate[1]) 63 64 caps = gst.Caps(struct) 65 66 return 'ximagesrc name=source ! videoscale ! %s' % caps
67 68 # Set properties
69 - def configure_pipeline(self, pipeline, properties):
70 source = self.get_element('source') 71 if 'show-pointer' in properties: 72 source.set_property('show-pointer', properties['show-pointer'])
73