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