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