Package flumotion :: Package component :: Package converters :: Package overlay :: Module overlay
[hide private]

Source Code for Module flumotion.component.converters.overlay.overlay

 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 os 
23  import tempfile 
24   
25   
26  from twisted.internet import defer 
27   
28  from flumotion.common import log, messages 
29   
30  from flumotion.component import feedcomponent 
31  from flumotion.component.converters.overlay import genimg 
32   
33  N_ = messages.N_ 
34  T_ = messages.gettexter('flumotion') 
35   
36   
37 -class Overlay(feedcomponent.ParseLaunchComponent):
38 checkTimestamp = True 39 checkOffset = True 40 _filename = None 41
42 - def get_pipeline_string(self, properties):
43 # the order here is important; to have our eater be the reference 44 # stream for videomixer it needs to be specified last 45 pipeline = ( 46 'filesrc name=source blocksize=100000 ! pngdec ! alphacolor ! ' 47 'videomixer name=mix ! @feeder:default@ ' 48 '@eater:default@ ! ffmpegcolorspace ! mix.') 49 50 return pipeline
51
52 - def configure_pipeline(self, pipeline, properties):
53 p = properties 54 self.fixRenamedProperties(p, [ 55 ('show_text', 'show-text'), 56 ('fluendo_logo', 'fluendo-logo'), 57 ('cc_logo', 'cc-logo'), 58 ('xiph_logo', 'xiph-logo') 59 ]) 60 61 # create temp file 62 (fd, self._filename) = tempfile.mkstemp('flumotion.png') 63 os.close(fd) 64 65 text = None 66 if p.get('show-text', False): 67 text = p.get('text', 'set the "text" property') 68 overflow = genimg.generate_overlay(self._filename, 69 text, 70 p.get('fluendo-logo', False), 71 p.get('cc-logo', False), 72 p.get('xiph-logo', False), 73 p['width'], 74 p['height']) 75 if overflow: 76 m = messages.Warning( 77 T_(N_("Overlayed text '%s' too wide for the video image."), 78 text), id = "text-too-wide") 79 self.addMessage(m) 80 81 source = self.get_element('source') 82 source.set_property('location', self._filename)
83
84 - def do_stop(self):
85 # clean up our temp file 86 if self._filename: 87 self.debug('Removing temporary overlay file %s' % self._filename) 88 os.unlink(self._filename) 89 self._filename = None 90 else: 91 self.debug("Temporary overlay already gone, " \ 92 "did we not start up correctly ?")
93