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