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