Package flumotion :: Package component :: Package combiners :: Package switch :: Module patternswitch
[hide private]

Source Code for Module flumotion.component.combiners.switch.patternswitch

 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 errors, messages 
21  from flumotion.common.i18n import N_, gettexter 
22  from flumotion.component import feedcomponent 
23  from flumotion.component.combiners.switch import basicwatchdog 
24   
25  __version__ = "$Rev$" 
26  T_ = gettexter() 
27   
28   
29 -class PatternEventSwitcher(basicwatchdog.AVBasicWatchdog):
30 logCategory = "comb-av-pattern-switcher" 31
32 - def do_check(self):
33 d = basicwatchdog.AVBasicWatchdog.do_check(self) 34 35 def checkConfig(result): 36 props = self.config['properties'] 37 eaterName = props.get('eater-with-stream-markers', None) 38 if eaterName != 'video-master' and eaterName != 'video-backup': 39 warnStr = N_("The value provided for the " \ 40 "eater-with-stream-markers property " \ 41 "must be one of video-backup, video-master.") 42 self.warning(warnStr) 43 self.addMessage(messages.Error(T_(N_(warnStr)), 44 mid="eater-with-stream-markers-wrong")) 45 return result
46 d.addCallback(checkConfig) 47 return d
48
49 - def configure_pipeline(self, pipeline, properties):
50 basicwatchdog.AVBasicWatchdog.configure_pipeline(self, pipeline, 51 properties) 52 # set event probe to react to video mark events 53 eaterName = properties.get('eater-with-stream-markers', 54 'video-backup') 55 sinkpad = self.videoSwitchElement.get_pad(self.switchPads[eaterName]) 56 sinkpad.add_event_probe(self._markers_event_probe)
57
58 - def _markers_event_probe(self, element, event):
59 if event.type == gst.EVENT_CUSTOM_DOWNSTREAM: 60 evt_struct = event.get_structure() 61 if evt_struct.get_name() == 'FluStreamMark': 62 if evt_struct['action'] == 'start': 63 self.switch_to("backup") 64 65 elif evt_struct['action'] == 'stop': 66 self.switch_to("master") 67 return True
68