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