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

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

 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  from flumotion.component import feedcomponent 
19  from flumotion.common import errors 
20   
21  from flumotion.component.combiners.switch import switch 
22   
23  __version__ = "$Rev$" 
24   
25   
26  # These basic watchdog components switch to backup 
27  # when the master eater(s) have gone hungry 
28   
29   
30 -class SingleBasicWatchdog(switch.SingleSwitch):
31 logCategory = "comb-single-basic-watchdog" 32
33 - def init(self):
34 switch.SingleSwitch.init(self) 35 # startedFine is set to True when all sink pads to all switch elements 36 # have received data 37 self.startedFine = False 38 self._started = []
39
40 - def feedSetInactive(self, feed):
41 switch.SingleSwitch.feedSetInactive(self, feed) 42 if self.startedFine: 43 self.auto_switch() 44 else: 45 if feed in self._started: 46 self._started.remove(feed)
47
48 - def feedSetActive(self, feed):
49 switch.SingleSwitch.feedSetActive(self, feed) 50 if self.startedFine: 51 self.auto_switch() 52 else: 53 self._started.append(feed) 54 allStarted = True 55 # check if all feeds started 56 for lf in self.logicalFeeds: 57 if lf not in self._started: 58 allStarted = False 59 break 60 if allStarted: 61 self.startedFine = True 62 self._started = []
63 64
65 -class AVBasicWatchdog(switch.AVSwitch):
66 logCategory = "comb-av-basic-watchdog" 67
68 - def init(self):
69 switch.AVSwitch.init(self) 70 # startedFine is set to True when all sink pads to all switch elements 71 # have received data 72 self.startedFine = False 73 self._started = []
74
75 - def feedSetInactive(self, feed):
76 switch.AVSwitch.feedSetInactive(self, feed) 77 if self.startedFine: 78 self.auto_switch() 79 else: 80 if feed in self._started: 81 self._started.remove(feed)
82
83 - def feedSetActive(self, feed):
84 switch.AVSwitch.feedSetActive(self, feed) 85 if self.startedFine: 86 self.auto_switch() 87 else: 88 self._started.append(feed) 89 allStarted = True 90 # check if all feeds started 91 for lf in self.logicalFeeds: 92 if lf not in self._started: 93 allStarted = False 94 break 95 if allStarted: 96 self.startedFine = True 97 self._started = []
98