[pitivi] Make TrackObjects take a stream parameter.



commit f046a0c7a5632fe2e1c08226098e9a82a5fd7472
Author: Alessandro Decina <alessandro decina collabora co uk>
Date:   Thu Mar 26 14:05:51 2009 +0100

    Make TrackObjects take a stream parameter.
    
    This should make files with multiple a/v streams work. It's also needed during
    project loading.
---
 pitivi/timeline/timeline.py    |    2 +-
 pitivi/timeline/track.py       |   19 ++++++++++---------
 tests/test_timeline.py         |   18 +++++++++---------
 tests/test_timeline_factory.py |    8 ++++----
 tests/test_track.py            |   14 +++++++-------
 5 files changed, 31 insertions(+), 30 deletions(-)

diff --git a/pitivi/timeline/timeline.py b/pitivi/timeline/timeline.py
index 2de98e1..f8a9446 100644
--- a/pitivi/timeline/timeline.py
+++ b/pitivi/timeline/timeline.py
@@ -537,7 +537,7 @@ class Timeline(object ,Signallable):
         start = 0
         for stream, track in stream_map.iteritems():
             start = max(start, track.duration)
-            track_object = SourceTrackObject(factory)
+            track_object = SourceTrackObject(factory, stream)
             track.addTrackObject(track_object)
             timeline_object.addTrackObject(track_object)
 
diff --git a/pitivi/timeline/track.py b/pitivi/timeline/track.py
index 9913f23..869aa7a 100644
--- a/pitivi/timeline/track.py
+++ b/pitivi/timeline/track.py
@@ -42,10 +42,11 @@ class TrackObject(object, Signallable):
         'selected-changed' : ['state'],
     }
 
-    def __init__(self, factory, start=0,
+    def __init__(self, factory, stream, start=0,
             duration=0, in_point=0,
             media_duration=0, priority=0):
         self.factory = factory
+        self.stream = stream
         self.track = None
         self.timeline_object = None
         self.gnl_object = obj = self._makeGnlObject()
@@ -80,7 +81,7 @@ class TrackObject(object, Signallable):
 
     def copy(self):
         cls = self.__class__
-        other = cls(self.factory, start=self.start,
+        other = cls(self.factory, self.stream, start=self.start,
             duration=self.duration, in_point=self.in_point,
             media_duration=self.media_duration, priority=self.priority)
         other.trimmed_start = self.trimmed_start
@@ -235,7 +236,7 @@ class TrackObject(object, Signallable):
         if self.track is None:
             raise TrackError()
 
-        bin = self.factory.makeBin(self.track.stream)
+        bin = self.factory.makeBin(self.stream)
         self.gnl_object.add(bin)
 
     def releaseBin(self):
@@ -318,21 +319,21 @@ class Track(object, Signallable):
 
     def _getDefaultTrackObjectForStream(self, stream):
         if isinstance(stream, VideoStream):
-            return self._getDefaultVideoTrackObject()
+            return self._getDefaultVideoTrackObject(stream)
         elif isinstance(stream, AudioStream):
-            return self._getDefaultAudioTrackObject()
+            return self._getDefaultAudioTrackObject(stream)
 
         return None
 
-    def _getDefaultVideoTrackObject(self):
+    def _getDefaultVideoTrackObject(self, stream):
         factory = VideoTestSourceFactory(pattern='black')
-        track_object = SourceTrackObject(factory)
+        track_object = SourceTrackObject(factory, stream)
 
         return track_object
 
-    def _getDefaultAudioTrackObject(self):
+    def _getDefaultAudioTrackObject(self, stream):
         factory = AudioTestSourceFactory(wave='silence')
-        track_object = SourceTrackObject(factory)
+        track_object = SourceTrackObject(factory, stream)
 
         return track_object
 
diff --git a/tests/test_timeline.py b/tests/test_timeline.py
index f13f804..e116e2f 100644
--- a/tests/test_timeline.py
+++ b/tests/test_timeline.py
@@ -50,8 +50,8 @@ class TestTimelineObjectAddRemoveTrackObjects(TestCase):
         stream = AudioStream(gst.Caps('audio/x-raw-int'))
         factory.addOutputStream(stream)
         track = Track(stream)
-        track_object1 = SourceTrackObject(factory)
-        track_object2 = SourceTrackObject(factory)
+        track_object1 = SourceTrackObject(factory, stream)
+        track_object2 = SourceTrackObject(factory, stream)
 
         track.addTrackObject(track_object1)
         timeline_object1.addTrackObject(track_object1)
@@ -86,8 +86,8 @@ class TestTimelineObjectProperties(TestCase):
         stream = AudioStream(gst.Caps('audio/x-raw-int'))
         factory.addOutputStream(stream)
         self.track = Track(stream)
-        self.track_object1 = SourceTrackObject(factory)
-        self.track_object2 = SourceTrackObject(factory)
+        self.track_object1 = SourceTrackObject(factory, stream)
+        self.track_object2 = SourceTrackObject(factory, stream)
         self.track.addTrackObject(self.track_object1)
         self.track.addTrackObject(self.track_object2)
 
@@ -291,8 +291,8 @@ class TestTimelineAddRemoveTimelineObjects(TestCase):
         timeline = Timeline()
         track = Track(stream)
 
-        track_object1 = SourceTrackObject(factory)
-        track_object2 = SourceTrackObject(factory)
+        track_object1 = SourceTrackObject(factory, stream)
+        track_object2 = SourceTrackObject(factory, stream)
         track.addTrackObject(track_object1)
         track.addTrackObject(track_object2)
 
@@ -349,9 +349,9 @@ class TestLink(TestCase):
         self.factory.addOutputStream(self.stream)
         self.track1 = Track(self.stream)
         self.track2 = Track(self.stream)
-        self.track_object1 = SourceTrackObject(self.factory)
-        self.track_object2 = SourceTrackObject(self.factory)
-        self.track_object3 = SourceTrackObject(self.factory)
+        self.track_object1 = SourceTrackObject(self.factory, self.stream)
+        self.track_object2 = SourceTrackObject(self.factory, self.stream)
+        self.track_object3 = SourceTrackObject(self.factory, self.stream)
         self.track1.addTrackObject(self.track_object1)
         self.track1.addTrackObject(self.track_object2)
         self.track2.addTrackObject(self.track_object3)
diff --git a/tests/test_timeline_factory.py b/tests/test_timeline_factory.py
index 2a8060f..8c0f732 100644
--- a/tests/test_timeline_factory.py
+++ b/tests/test_timeline_factory.py
@@ -168,7 +168,7 @@ class TestTimelineSourceFactoryPipeline(MainLoopTestCase):
 
         timeline = Timeline()
         track = Track(stream)
-        track_object1 = SourceTrackObject(video_factory1)
+        track_object1 = SourceTrackObject(video_factory1, stream)
         track_object1.start = 1 * gst.SECOND
         track.addTrackObject(track_object1)
         timeline.addTrack(track)
@@ -215,7 +215,7 @@ class TestTimelineSourceFactoryPipeline(MainLoopTestCase):
 
         timeline = Timeline()
         track = Track(stream)
-        track_object1 = SourceTrackObject(audio_factory1)
+        track_object1 = SourceTrackObject(audio_factory1, stream)
         track_object1.start = 2 * gst.SECOND
         track.addTrackObject(track_object1)
         timeline.addTrack(track)
@@ -269,12 +269,12 @@ class TestTimelineSourceFactoryPipeline(MainLoopTestCase):
         video_track = Track(video_stream)
         audio_track = Track(audio_stream)
 
-        track_object1 = SourceTrackObject(audio_factory1)
+        track_object1 = SourceTrackObject(audio_factory1, audio_stream)
         track_object1.start = 2 * gst.SECOND
         audio_track.addTrackObject(track_object1)
         timeline.addTrack(audio_track)
 
-        track_object2 = SourceTrackObject(video_factory1)
+        track_object2 = SourceTrackObject(video_factory1, video_stream)
         track_object2.start = 2 * gst.SECOND
         video_track.addTrackObject(track_object2)
         timeline.addTrack(video_track)
diff --git a/tests/test_track.py b/tests/test_track.py
index d1e9e56..6e258a3 100644
--- a/tests/test_track.py
+++ b/tests/test_track.py
@@ -49,7 +49,7 @@ class TestTrackObject(TestCase):
         self.factory = StubFactory()
         gst.debug("%r" % self.factory.duration)
         self.factory.addOutputStream(stream)
-        self.track_object = SourceTrackObject(self.factory)
+        self.track_object = SourceTrackObject(self.factory, stream)
         self.monitor = TrackSignalMonitor(self.track_object)
 
     def tearDown(self):
@@ -296,7 +296,7 @@ class TestTrack(TestCase):
         track2 = self.track2
 
         # add an object
-        obj1 = SourceTrackObject(factory)
+        obj1 = SourceTrackObject(factory, stream)
         self.failUnlessEqual(obj1.track, None)
         track1.addTrackObject(obj1)
         self.failIfEqual(obj1.track, None)
@@ -308,7 +308,7 @@ class TestTrack(TestCase):
         self.failUnlessRaises(TrackError, track2.addTrackObject, obj1)
 
         # add a second object
-        obj2 = SourceTrackObject(factory)
+        obj2 = SourceTrackObject(factory, stream)
         self.failUnlessEqual(obj2.track, None)
         track1.addTrackObject(obj2)
         self.failIfEqual(obj2.track, None)
@@ -332,7 +332,7 @@ class TestTrack(TestCase):
 
         objs = []
         for i in xrange(10):
-            obj = SourceTrackObject(factory)
+            obj = SourceTrackObject(factory, self.stream)
             objs.append(obj)
             track.addTrackObject(obj)
 
@@ -348,19 +348,19 @@ class TestTrack(TestCase):
         track = self.track1
         factory = self.factory
 
-        obj1 = SourceTrackObject(factory)
+        obj1 = SourceTrackObject(factory, self.stream)
         obj1.priority = 10
 
         self.failUnlessEqual(track.max_priority, 0)
         track.addTrackObject(obj1)
         self.failUnlessEqual(track.max_priority, 10)
 
-        obj2 = SourceTrackObject(factory)
+        obj2 = SourceTrackObject(factory, self.stream)
         obj2.priority = 5
         track.addTrackObject(obj2)
         self.failUnlessEqual(track.max_priority, 10)
 
-        obj3 = SourceTrackObject(factory)
+        obj3 = SourceTrackObject(factory, self.stream)
         obj3.priority = 14
         track.addTrackObject(obj3)
         self.failUnlessEqual(track.max_priority, 14)



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]