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 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 
24   
25  from flumotion.component.combiners.switch import switch 
26   
27  __version__ = "$Rev: 6486 $" 
28   
29   
30  # These basic watchdog components switch to backup 
31  # when the master eater(s) have gone hungry 
32 -class SingleBasicWatchdog(switch.SingleSwitch):
33 logCategory = "comb-single-basic-watchdog" 34
35 - def init(self):
36 switch.SingleSwitch.init(self) 37 # startedFine is set to True when all sink pads to all switch elements 38 # have received data 39 self.startedFine = False
40
41 - def feedSetInactive(self, feed):
42 switch.SingleSwitch.feedSetInactive(self, feed) 43 if self.startedFine: 44 self.auto_switch() 45 else: 46 if feed in self._started: 47 self._started.remove(feed)
48
49 - def feedSetActive(self, feed):
50 switch.SingleSwitch.feedSetActive(self, feed) 51 if self.startedFine: 52 self.auto_switch() 53 else: 54 self._started.append(feed) 55 allStarted = True 56 # check if all feeds started 57 for lf in self.logicalFeeds: 58 if lf not in self._started: 59 allStarted = False 60 break 61 if allStarted: 62 self.startedFine = True 63 self._started = []
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