msmith - in flumotion/trunk: . flumotion/component/producers/playlist

flumotion-commit at lists.fluendo.com flumotion-commit at lists.fluendo.com
Tue May 15 16:47:09 CEST 2007


Author: msmith
Date: Tue May 15 16:47:07 2007
New Revision: 4948

Modified:
   flumotion/trunk/ChangeLog
   flumotion/trunk/flumotion/component/producers/playlist/playlist.py
   flumotion/trunk/flumotion/component/producers/playlist/playlistparser.py
Log:
        * flumotion/component/producers/playlist/playlist.py:
          Never schedule an item for the past or very recent future. Allow
          scheduling something 5 seconds or more in the future.

        * flumotion/component/producers/playlist/playlistparser.py:
          Fix duration adjustment for inserting new items.



Modified: flumotion/trunk/ChangeLog
==============================================================================
--- flumotion/trunk/ChangeLog	(original)
+++ flumotion/trunk/ChangeLog	Tue May 15 16:47:07 2007
@@ -1,3 +1,12 @@
+2007-05-15  Michael Smith <msmith at fluendo.com>
+
+	* flumotion/component/producers/playlist/playlist.py:
+	  Never schedule an item for the past or very recent future. Allow
+	  scheduling something 5 seconds or more in the future.
+
+	* flumotion/component/producers/playlist/playlistparser.py:
+	  Fix duration adjustment for inserting new items.
+
 2007-05-15  Andy Wingo  <wingo at pobox.com>
 
 	* flumotion/component/base/watcher.py: Update copyrights.

Modified: flumotion/trunk/flumotion/component/producers/playlist/playlist.py
==============================================================================
--- flumotion/trunk/flumotion/component/producers/playlist/playlist.py	(original)
+++ flumotion/trunk/flumotion/component/producers/playlist/playlist.py	Tue May 15 16:47:07 2007
@@ -220,20 +220,26 @@
         Schedule a given playlist item in our playback compositions.
         """
         start = item.timestamp - self.basetime
-        # This works around a bug in videotestsrc and videorate. TODO! This
-        # can be removed once we upgrade to a future version of gst-plugins-base
-        #start = (start / gst.SECOND) * gst.SECOND
         self.debug("Starting item %s in %d seconds", item.uri, start/gst.SECOND)
 
-        if start < 0:
-            if start + item.duration < 0:
+        # If we schedule things to start before the current pipeline position,
+        # gnonlin will adjust this to start now. However, it does this 
+        # separately for audio and video, so we start from different points,
+        # thus we're out of sync.
+        # So, always start slightly in the future... 5 seconds seems to work
+        # fine in practice.
+        now = self.pipeline.query_position(gst.FORMAT_TIME)[0] + 5 * gst.SECOND
+
+        if start < now:
+            if start + item.duration < now:
+                self.debug("Item too late; skipping entirely")
                 return
             else:
-                # If we're not too late for part of the file to be playable,
-                # then play it!
-                item.offset = -start
-                item.duration = item.duration + start
-                start = 0
+                change = now - start
+                self.debug("Starting item with offset %d", change)
+                item.duration -= change
+                item.offset += change
+                start = now
 
         if self._hasVideo and item.hasVideo:
             self.debug("Adding video source with start %d, duration %d, "

Modified: flumotion/trunk/flumotion/component/producers/playlist/playlistparser.py
==============================================================================
--- flumotion/trunk/flumotion/component/producers/playlist/playlistparser.py	(original)
+++ flumotion/trunk/flumotion/component/producers/playlist/playlistparser.py	Tue May 15 16:47:07 2007
@@ -178,7 +178,7 @@
         if prev and prev.timestamp + prev.duration > newitem.timestamp:
             self.debug("Changing duration of previous item from %d to %d", 
                 prev.duration, newitem.timestamp - prev.timestamp)
-            item.setDuration(newitem.timestamp - prev.timestamp)
+            prev.setDuration(newitem.timestamp - prev.timestamp)
 
         if next and newitem.timestamp + newitem.duration > next.timestamp:
             self.debug("Changing timestamp of next item from %d to %d to fit", 


More information about the flumotion-commit mailing list