~ubuntu-branches/ubuntu/trusty/pitivi/trusty

« back to all changes in this revision

Viewing changes to pitivi/factories/operation.py

  • Committer: Bazaar Package Importer
  • Author(s): Sebastien Bacher
  • Date: 2011-07-07 13:43:47 UTC
  • mto: (6.1.9 sid) (1.2.12)
  • mto: This revision was merged to the branch mainline in revision 32.
  • Revision ID: james.westby@ubuntu.com-20110707134347-cari9kxjiakzej9z
Tags: upstream-0.14.1
ImportĀ upstreamĀ versionĀ 0.14.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/usr/bin/python
2
1
# PiTiVi , Non-linear video editor
3
2
#
4
3
#       operation.py
17
16
#
18
17
# You should have received a copy of the GNU Lesser General Public
19
18
# License along with this program; if not, write to the
20
 
# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
21
 
# Boston, MA 02111-1307, USA.
 
19
# Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
 
20
# Boston, MA 02110-1301, USA.
22
21
 
23
22
import gst
24
23
from pitivi.factories.base import OperationFactory
26
25
 
27
26
from gettext import gettext as _
28
27
 
 
28
 
29
29
# FIXME: define a proper hierarchy
30
30
class OperationFactoryError(Exception):
31
31
    pass
32
32
 
 
33
 
33
34
class ModifierFactoryError(OperationFactoryError):
34
35
    pass
35
36
 
 
37
 
36
38
class TransformFactory(OperationFactory):
37
39
    """
38
40
    Factories that take exactly one input stream and output exactly one output
56
58
    def _requestNewInputStream(self, *args):
57
59
        raise OperationFactoryError("TransformFactory doesn't allow request pads")
58
60
 
59
 
class EffectFactory (TransformFactory):
 
61
 
 
62
class EffectFactory(TransformFactory):
60
63
    """
61
64
    Factories that applies an effect on a stream
62
65
    """
63
 
    def __init__ (self, effect, name='', categories=[_("Uncategorized")],
 
66
    def __init__(self, effect, name='', categories=[_("Uncategorized")],
64
67
                  human_name="", description="", icon=None):
65
68
        TransformFactory.__init__(self, name)
66
69
        self.effectname = effect
78
81
    def getCategories(self):
79
82
        return self.categories
80
83
 
81
 
    def _makeBin (self, *args):
 
84
    def _makeBin(self, *args):
82
85
        bin = gst.Bin()
83
86
        fx = gst.element_factory_make(self.effectname, "effect")
84
87
        if isinstance(self.input_streams[0], VideoStream):
100
103
        for element in elements.next():
101
104
            del element
102
105
 
103
 
 
104
106
    def addInputStream(self, stream):
105
107
        return OperationFactory.addInputStream(self, stream)
106
108
 
107
109
    def addOutputStream(self, stream):
108
110
        return OperationFactory.addOutputStream(self, stream)
109
111
 
 
112
 
110
113
class StreamModifierFactory(TransformFactory):
111
114
    """
112
115
    Factories that modify the nature/type of a stream.
113
116
    """
114
117
    pass
115
118
 
 
119
 
116
120
class AudioModifierFactory(StreamModifierFactory):
117
121
 
118
122
    def _makeBin(self, *args):
145
149
        b.add_pad(gsrc)
146
150
        return b
147
151
 
 
152
 
148
153
class VideoModifierFactory(StreamModifierFactory):
149
154
 
150
155
    def _makeBin(self, *args):
188
193
        b.add_pad(gsrc)
189
194
        return b
190
195
 
 
196
 
191
197
def get_modifier_for_stream(input_stream=None, output_stream=None):
192
198
    """
193
199
    Returns a L{StreamModifierFactory} for the given streams.