[pitivi: 3/10] Revert "timeline/track.py: Reliable implementation of TrackEffect.getElement()"



commit 530d3b8ae3290a6b7ceb0806ef6b6f911ad4b6e6
Author: Alessandro Decina <alessandro d gmail com>
Date:   Thu Sep 23 13:41:42 2010 +0200

    Revert "timeline/track.py: Reliable implementation of TrackEffect.getElement()"
    
    This reverts commit 71624851f77e79a4c13046b29e0a8666f4f8fae7.
    
    Conflicts:
    
    	pitivi/timeline/track.py

 pitivi/factories/operation.py     |   34 ++++------------------------------
 pitivi/timeline/track.py          |   24 +++++-------------------
 tests/test_factories_operation.py |    4 ++--
 3 files changed, 11 insertions(+), 51 deletions(-)
---
diff --git a/pitivi/factories/operation.py b/pitivi/factories/operation.py
index 9f2f2b4..c5118bb 100644
--- a/pitivi/factories/operation.py
+++ b/pitivi/factories/operation.py
@@ -21,7 +21,7 @@
 # Boston, MA 02111-1307, USA.
 
 import gst
-from pitivi.factories.base import OperationFactory, ObjectFactoryError
+from pitivi.factories.base import OperationFactory
 from pitivi.stream import AudioStream, VideoStream
 
 from gettext import gettext as _
@@ -56,7 +56,7 @@ class TransformFactory(OperationFactory):
     def _requestNewInputStream(self, *args):
         raise OperationFactoryError("TransformFactory doesn't allow request pads")
 
-class EffectFactory(TransformFactory):
+class EffectFactory (TransformFactory):
     """
     Factories that applies an effect on a stream
     """
@@ -78,33 +78,6 @@ class EffectFactory(TransformFactory):
     def getCategories(self):
         return self.categories
 
-    def makeBin(self, input_stream=None, output_stream=None):
-        """
-        Create a bin that consumes the stream described by C{input_stream}.
-
-        If C{input_stream} and/or C{output_stream} are None, it's up to the
-        implementations to return a suitable "default" bin.
-
-        @param input_stream: A L{MultimediaStream}
-        @param output_stream: A L{MultimediaStream}
-        @return: A bin and the element
-        @rtype: C{gst.Bin} and C{gst.Element}
-
-        @see: L{releaseBin}
-        """
-
-        if input_stream is not None and \
-                input_stream not in self.input_streams:
-            raise ObjectFactoryError('unknown stream')
-
-        bin, fx = self._makeBin(input_stream)
-        bin.factory = self
-        self.bins.append(bin)
-        self.current_bins += 1
-        self.emit('bin-created', bin)
-
-        return bin, fx
-
     def _makeBin (self, *args):
         bin = gst.Bin()
         fx = gst.element_factory_make(self.effectname)
@@ -120,13 +93,14 @@ class EffectFactory(TransformFactory):
         bin.add_pad(gst.GhostPad("sink", csp.get_pad("sink")))
         bin.add_pad(gst.GhostPad("src", fx.get_pad("src")))
 
-        return bin, fx
+        return bin
 
     def _releaseBin(self, bin):
         elements = bin.elements()
         for element in elements.next():
             del element
 
+
     def addInputStream(self, stream):
         return OperationFactory.addInputStream(self, stream)
 
diff --git a/pitivi/timeline/track.py b/pitivi/timeline/track.py
index 1b35d2c..2b87944 100644
--- a/pitivi/timeline/track.py
+++ b/pitivi/timeline/track.py
@@ -644,14 +644,11 @@ class TrackObject(Signallable, Loggable):
         if self.gnl_object is None:
             raise TrackError()
 
-        bin = self._getBin()
+        bin = self.factory.makeBin(self.stream)
         self.gnl_object.add(bin)
         self._rebuild_interpolators = True
         self._maybeBuildInterpolators()
 
-    def _getBin(self):
-        return self.factory.makeBin(self.stream)
-
     def releaseBin(self):
         for bin in list(self.gnl_object.elements()):
             self.gnl_object.remove(bin)
@@ -741,14 +738,6 @@ class TrackEffect(TrackObject):
 
     numobjs = 0
 
-    def __init__(self, factory, stream, start=0,
-            duration=0, in_point=0,
-            media_duration=0, priority=0):
-        TrackObject.__init__(self, factory, stream, start=start,
-                             duration=duration, in_point=in_point,
-                             media_duration=media_duration, priority=priority)
-        self._element = None
-
     def _makeGnlObject(self):
         effect = gst.element_factory_make('gnloperation',
             "gnloperation: " + self.factory.__class__.__name__ +
@@ -756,12 +745,6 @@ class TrackEffect(TrackObject):
         TrackEffect.numobjs += 1
         return effect
 
-    def _getBin(self):
-        bin, fx = self.factory.makeBin(self.stream)
-        self._element = fx
-
-        return bin
-
     def copy(self):
         other = TrackObject.copy(self)
 
@@ -780,7 +763,10 @@ class TrackEffect(TrackObject):
         Permit to get the gst.Element inside the gnl_object that correspond
         to the track factory
         """
-        return self._element
+        #Should we find a better implementation?
+        for element in self.gnl_object.recurse():
+            if self.factory.name in element.get_name():
+                return element
 
 class Transition(Signallable):
 
diff --git a/tests/test_factories_operation.py b/tests/test_factories_operation.py
index d36ba69..df01b0b 100644
--- a/tests/test_factories_operation.py
+++ b/tests/test_factories_operation.py
@@ -40,8 +40,8 @@ class TestEffectFactory(TestCase):
         self.factory.addInputStream(self.stream)
 
     def testMakeBin (self):
-        bin, fx = self.factory.makeBin()
-        bin2, fx = self.factory.makeBin()
+        bin = self.factory.makeBin()
+        bin2 = self.factory.makeBin()
         csp = bin.elements().next()
         self.failUnless(isinstance(bin, gst.Bin))
         self.failUnless(csp)



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