msmith - in flumotion/trunk: . flumotion/component flumotion/component/consumers/httpstreamer

flumotion-commit at lists.fluendo.com flumotion-commit at lists.fluendo.com
Mon May 28 15:56:59 CEST 2007


Author: msmith
Date: Mon May 28 15:56:56 2007
New Revision: 5056

Modified:
   flumotion/trunk/ChangeLog
   flumotion/trunk/flumotion/component/consumers/httpstreamer/http.py
   flumotion/trunk/flumotion/component/feedcomponent.py
   flumotion/trunk/flumotion/component/feedcomponent010.py
Log:
        * flumotion/component/feedcomponent010.py:
          Make link() return a deferred that fires when the pipeline goes
          playing; removes special-casing in statechange message handlers.
        * flumotion/component/feedcomponent.py:
          Now that link() returns a deferred, use that deferred.
        * flumotion/component/consumers/httpstreamer/http.py:
          If using a porter, don't go happy until we've logged in.
          Fixes #537.



Modified: flumotion/trunk/ChangeLog
==============================================================================
--- flumotion/trunk/ChangeLog	(original)
+++ flumotion/trunk/ChangeLog	Mon May 28 15:56:56 2007
@@ -1,5 +1,16 @@
 2007-05-28  Michael Smith <msmith at fluendo.com>
 
+	* flumotion/component/feedcomponent010.py:
+	  Make link() return a deferred that fires when the pipeline goes
+	  playing; removes special-casing in statechange message handlers.
+	* flumotion/component/feedcomponent.py:
+	  Now that link() returns a deferred, use that deferred.
+	* flumotion/component/consumers/httpstreamer/http.py:
+	  If using a porter, don't go happy until we've logged in.
+	  Fixes #537.
+
+2007-05-28  Michael Smith <msmith at fluendo.com>
+
 	* flumotion/component/consumers/httpstreamer/resources.py:
 	  Improve positioning of parentheses.
 

Modified: flumotion/trunk/flumotion/component/consumers/httpstreamer/http.py
==============================================================================
--- flumotion/trunk/flumotion/component/consumers/httpstreamer/http.py	(original)
+++ flumotion/trunk/flumotion/component/consumers/httpstreamer/http.py	Mon May 28 15:56:56 2007
@@ -670,6 +670,11 @@
             raise errors.WrongStateError(
                 "Can't specify porter details in master mode")
 
+    def do_pipeline_playing(self):
+        # Override this to not set the component happy; instead do this once
+        # both the pipeline has started AND we've logged in to the porter.
+        pass
+
     def do_start(self, *args, **kwargs):
         root = resources.HTTPRoot()
         # TwistedWeb wants the child path to not include the leading /
@@ -707,7 +712,7 @@
                 fdserver.FDConnector, self._porterPath, 
                 self._pbclient, 10, checkPID=False)
 
-            return defer.DeferredList([d1, d2])
+            d = defer.DeferredList([d1, d2])
         else:
             # Streamer is standalone.
             try:
@@ -715,7 +720,7 @@
                 iface = self.iface or ""
                 reactor.listenTCP(self.port, server.Site(resource=root), 
                     interface=iface)
-                return feedcomponent.ParseLaunchComponent.do_start(self, *args, 
+                d = feedcomponent.ParseLaunchComponent.do_start(self, *args, 
                     **kwargs)
             except error.CannotListenError:
                 t = 'Port %d is not available.' % self.port
@@ -725,5 +730,10 @@
                 self.addMessage(m)
                 self.setMood(moods.sad)
                 return defer.fail(errors.ComponentStartHandledError(t))
+        def turnHappy(res):
+            self.debug("Turned happy!")
+            self.setMood(moods.happy)
+        d.addCallback(turnHappy)
+        return d
 
 pygobject.type_register(MultifdSinkStreamer)

Modified: flumotion/trunk/flumotion/component/feedcomponent.py
==============================================================================
--- flumotion/trunk/flumotion/component/feedcomponent.py	(original)
+++ flumotion/trunk/flumotion/component/feedcomponent.py	Mon May 28 15:56:56 2007
@@ -480,9 +480,7 @@
         if clocking:
             self.set_master_clock(*clocking)
 
-        self.link()
-
-        return defer.succeed(None)
+        return self.link()
 
 class Effect(log.Loggable):
     """

Modified: flumotion/trunk/flumotion/component/feedcomponent010.py
==============================================================================
--- flumotion/trunk/flumotion/component/feedcomponent010.py	(original)
+++ flumotion/trunk/flumotion/component/feedcomponent010.py	Mon May 28 15:56:56 2007
@@ -392,6 +392,8 @@
         self.feeder_names = [] # list of feedId
 
         self._inactiveEaters = [] # list of feedId's
+        self._inactivated = False
+
         # feedId -> dict of lastTime, lastConnectTime, lastConnectD,
         # checkEaterDC,
         self._eaterStatus = {}
@@ -502,6 +504,7 @@
         else:
             self._inactiveEaters.append(feedId)
         self.setMood(moods.hungry)
+        self._inactivated = True
 
     def eaterSetActive(self, feedId):
         """
@@ -513,8 +516,11 @@
             self.warning('Eater of %s was already active' % feedId)
         else:
             self._inactiveEaters.remove(feedId)
-        if not self._inactiveEaters:
+        if not self._inactiveEaters and self._inactivated:
+            # We never go happy initially because of this; only if we went
+            # hungry because of an eater being inactive.
             self.setMood(moods.happy)
+            self._inactivated = False
     # FIXME: it may make sense to have an updateMood method, that can be used
     # by the two previous methods, but also in other places, and then
     # overridden.  That would make us have to publicize inactiveEaters
@@ -670,9 +676,6 @@
             if src == self.pipeline:
                 self.log('state change: %r %s->%s'
                     % (src, old.value_nick, new.value_nick)) 
-                if old == gst.STATE_PAUSED and new == gst.STATE_PLAYING:
-                    self.do_pipeline_playing()
-
                 change = self._getStateChange(old,new)
                 if change in self._stateChangeDeferreds:
                     dlist = self._stateChangeDeferreds[change]
@@ -756,8 +759,6 @@
                 s = message.structure
                 self.eaterOffsetDiscont(feedId, s["prev-offset-end"],
                     s["cur-offset"])
-
-
         else:
             self.log('message received: %r' % message)
 
@@ -945,6 +946,10 @@
         self.debug("Setting pipeline %r to GST_STATE_PLAYING", self.pipeline)
         self.pipeline.set_state(gst.STATE_PLAYING)
 
+        d = self._addStateChangeDeferred(gst.STATE_CHANGE_PAUSED_TO_PLAYING)
+        d.addCallback(lambda x: self.do_pipeline_playing())
+        return d
+
     def _feeder_probe_calllater(self):
         for feedId, feeder in self._feeders.items():
             feederElement = self.get_element("feeder:%s" % feedId)


More information about the flumotion-commit mailing list