zaheer - in flumotion/trunk: . flumotion/component/combiners/switch

flumotion-commit at lists.fluendo.com flumotion-commit at lists.fluendo.com
Mon May 14 20:10:29 CEST 2007


Author: zaheer
Date: Mon May 14 20:10:27 2007
New Revision: 4945

Modified:
   flumotion/trunk/ChangeLog
   flumotion/trunk/flumotion/component/combiners/switch/basicwatchdog.py
   flumotion/trunk/flumotion/component/combiners/switch/switch.py
Log:
	* flumotion/component/combiners/switch/basicwatchdog.py
	  (SingleBasicWatchdog.eaterSetInactive,
	  SingleBasicWatchdog.eaterSetActive, AVBasicWatchdog,
	  AVBasicWatchdog.eaterSetInactive, AVBasicWatchdog.eaterSetActive,
	  AVBasicWatchdog.isActive):
	* flumotion/component/combiners/switch/switch.py (Switch.isActive,
	  SingleSwitch, SingleSwitch.switchToMaster,
	  SingleSwitch.switchToBackup, AVSwitch.switchToMaster,
	  AVSwitch.switchToBackup, AVSwitch._setLastTimestamp):
	Set the stop value on the switches so that the resulting stream
	is synched if video or audio stops before the other.
	Do not allow switching to master or backup if eaters are inactive.



Modified: flumotion/trunk/ChangeLog
==============================================================================
--- flumotion/trunk/ChangeLog	(original)
+++ flumotion/trunk/ChangeLog	Mon May 14 20:10:27 2007
@@ -1,3 +1,18 @@
+2007-05-14  Zaheer Abbas Merali  <zaheerabbas at merali dot org>
+
+	* flumotion/component/combiners/switch/basicwatchdog.py
+	  (SingleBasicWatchdog.eaterSetInactive,
+	  SingleBasicWatchdog.eaterSetActive, AVBasicWatchdog,
+	  AVBasicWatchdog.eaterSetInactive, AVBasicWatchdog.eaterSetActive,
+	  AVBasicWatchdog.isActive):
+	* flumotion/component/combiners/switch/switch.py (Switch.isActive,
+	  SingleSwitch, SingleSwitch.switchToMaster,
+	  SingleSwitch.switchToBackup, AVSwitch.switchToMaster,
+	  AVSwitch.switchToBackup, AVSwitch._setLastTimestamp):
+	Set the stop value on the switches so that the resulting stream
+	is synched if video or audio stops before the other.
+	Do not allow switching to master or backup if eaters are inactive.
+
 2007-05-14  Andy Wingo  <wingo at pobox.com>
 
 	* flumotion/admin/gtk/main.py (startAdminFromGreeter.failed): This

Modified: flumotion/trunk/flumotion/component/combiners/switch/basicwatchdog.py
==============================================================================
--- flumotion/trunk/flumotion/component/combiners/switch/basicwatchdog.py	(original)
+++ flumotion/trunk/flumotion/component/combiners/switch/basicwatchdog.py	Mon May 14 20:10:27 2007
@@ -31,43 +31,35 @@
 
     def eaterSetInactive(self, feedId):
         switch.SingleSwitch.eaterSetInactive(self, feedId)
-        eaterName = self.get_eater_name_for_feedid(feedId)
+        eaterName = self.get_eater_name_for_feedId(feedId)
         if "master" in eaterName and self.isActive("backup"):
             self.switchToBackup()
 
     def eaterSetActive(self, feedId):
         switch.SingleSwitch.eaterSetActive(self, feedId)
-        eaterName = self.get_eater_name_for_feedid(feedId)
+        eaterName = self.get_eater_name_for_feedId(feedId)
         if "master" in eaterName:
             self.switchToMaster()
 
-    def isActive(self, eaterSubstring):
-        # eaterSubstring is "master" or "backup"
-        for eaterFeedId in self._inactiveEaters:
-            eaterName = self.get_eater_name_for_feedid(eaterFeedId)
-            if eaterSubstring in eaterName:
-                return False
-        return True
-
 class AVBasicWatchdog(switch.AVSwitch):
     logCategory = "comb-av-basic-watchdog"
 
     def eaterSetInactive(self, feedId):
         switch.AVSwitch.eaterSetInactive(self, feedId)
-        eaterName = self.get_eater_name_for_feedid(feedId)
+        eaterName = self.get_eater_name_for_feedId(feedId)
         if "master" in eaterName and self.isActive("backup"):
             self.switchToBackup()
 
     def eaterSetActive(self, feedId):
         switch.AVSwitch.eaterSetActive(self, feedId)
-        eaterName = self.get_eater_name_for_feedid(feedId)
+        eaterName = self.get_eater_name_for_feedId(feedId)
         if "master" in eaterName:
             self.switchToMaster()
 
     def isActive(self, eaterSubstring):
         # eaterSubstring is "master" or "backup"
         for eaterFeedId in self._inactiveEaters:
-            eaterName = self.get_eater_name_for_feedid(eaterFeedId)
+            eaterName = self.get_eater_name_for_feedId(eaterFeedId)
             if eaterSubstring in eaterName:
                 return False
         return True

Modified: flumotion/trunk/flumotion/component/combiners/switch/switch.py
==============================================================================
--- flumotion/trunk/flumotion/component/combiners/switch/switch.py	(original)
+++ flumotion/trunk/flumotion/component/combiners/switch/switch.py	Mon May 14 20:10:27 2007
@@ -54,6 +54,14 @@
         raise errors.NotImplementedError('subclasses should implement '
                                          'switchToBackup')
 
+    def isActive(self, eaterSubstring):
+        # eaterSubstring is "master" or "backup"
+        for eaterFeedId in self._inactiveEaters:
+            eaterName = self.get_eater_name_for_feedId(eaterFeedId)
+            if eaterSubstring in eaterName:
+                return False
+        return True
+
 class SingleSwitch(Switch):
     logCategory = "comb-single-switch"
 
@@ -103,14 +111,23 @@
         self.uiState.set("active-eater", "master")
 
     def switchToMaster(self):
-        self.switchElement.set_property("active-pad",
-            self.switchPads["master"])
-        self.uiState.set("active-eater", "master")
+        if self.isActive("master"):
+            self.switchElement.set_property("active-pad",
+                self.switchPads["master"])
+            self.uiState.set("active-eater", "master")
+        else:
+            self.warning("Could not switch to master because the master eater "
+                "is not active.")
         
     def switchToBackup(self):
-        self.switchElement.set_property("active-pad",
-            self.switchPads["backup"])
-        self.uiState.set("active-eater", "backup")
+        if self.isActive("backup"):
+            self.switchElement.set_property("active-pad",
+                self.switchPads["backup"])
+            self.uiState.set("active-eater", "backup")
+        else:
+            self.warning("Could not switch to backup because the backup eater "
+                "is not active.")
+    
 
 class AVSwitch(Switch):
     logCategory = "comb-av-switch"
@@ -181,15 +198,37 @@
         self.uiState.set("active-eater", "master")
 
     def switchToMaster(self):
-        self.videoSwitchElement.set_property("active-pad",
-            self.switchPads["video-master"])
-        self.audioSwitchElement.set_property("active-pad",
-            self.switchPads["audio-master"])
-        self.uiState.set("active-eater", "master")
+        if self.isActive("master"):
+            self._setLastTimestamp()
+            self.videoSwitchElement.set_property("active-pad",
+                self.switchPads["video-master"])
+            self.audioSwitchElement.set_property("active-pad",
+                self.switchPads["audio-master"])
+            self.uiState.set("active-eater", "master")
+        else:
+            self.warning("Could not switch to master because at least "
+                "one of the master eaters is not active.")
+
         
     def switchToBackup(self):
-        self.videoSwitchElement.set_property("active-pad",
-            self.switchPads["video-backup"])
-        self.audioSwitchElement.set_property("active-pad",
-            self.switchPads["audio-backup"])
-        self.uiState.set("active-eater", "backup")
+        if self.isActive("backup"):
+            self._setLastTimestamp()
+            self.videoSwitchElement.set_property("active-pad",
+                self.switchPads["video-backup"])
+            self.audioSwitchElement.set_property("active-pad",
+                self.switchPads["audio-backup"])
+            self.uiState.set("active-eater", "backup")
+        else:
+            self.warning("Could not switch to backup because at least "
+                "one of the backup eaters is not active.")
+
+    def _setLastTimestamp(self):
+        vswTs = self.videoSwitchElement.get_property("last-timestamp")
+        aswTs = self.audioSwitchElement.get_property("last-timestamp")
+
+        if aswTs > vswTs:
+            self.videoSwitchElement.set_property("stop-value",
+                aswTs)
+        else:
+            self.audioSwitchElement.set_property("stop-value",
+                vswTs)


More information about the flumotion-commit mailing list