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

« back to all changes in this revision

Viewing changes to pitivi/timeline/track.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:
16
16
#
17
17
# You should have received a copy of the GNU Lesser General Public
18
18
# License along with this program; if not, write to the
19
 
# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20
 
# Boston, MA 02111-1307, USA.
 
19
# Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
 
20
# Boston, MA 02110-1301, USA.
21
21
 
22
22
import gst
23
23
import gobject
32
32
from pitivi.elements.mixer import SmartAdderBin, SmartVideomixerBin
33
33
from pitivi.timeline.gap import Gap
34
34
 
 
35
 
35
36
class TrackError(Exception):
36
37
    pass
37
38
 
 
39
 
38
40
class Keyframe(Signallable):
39
41
 
40
42
    """Represents a single point on an interpolation curve"""
41
43
 
42
44
    __signals__ = {
43
 
        "value-changed" : ['value'],
44
 
        "time-changed" : ['time'],
45
 
        "mode-changed" : ['mode'],
 
45
        "value-changed": ['value'],
 
46
        "time-changed": ['time'],
 
47
        "mode-changed": ['mode'],
46
48
    }
47
49
 
48
50
    def __init__(self, parent):
106
108
            return cmp(self.time, other.time)
107
109
        return self
108
110
 
 
111
 
109
112
class FixedKeyframe(Keyframe):
110
113
 
111
114
    def setTime(self, time):
113
116
 
114
117
    time = property(Keyframe.getTime, setTime)
115
118
 
 
119
 
116
120
class Interpolator(Signallable, Loggable):
117
121
 
118
122
    """The bridge between the gstreamer dynamic property API and pitivi track
132
136
    """
133
137
 
134
138
    __signals__ = {
135
 
        'keyframe-added' : ['keyframe'],
136
 
        'keyframe-removed' : ['keyframe', 'old_value'],
137
 
        'keyframe-moved' : ['keyframe', 'old_value'],
 
139
        'keyframe-added': ['keyframe'],
 
140
        'keyframe-removed': ['keyframe', 'old_value'],
 
141
        'keyframe-moved': ['keyframe', 'old_value'],
138
142
    }
139
143
 
140
144
    def __init__(self, trackobject, element, prop, minimum=None, maximum=None,
300
304
 
301
305
    keyframes = property(getKeyframes)
302
306
 
 
307
 
303
308
class TrackObject(Signallable, Loggable):
304
309
 
305
310
    __signals__ = {
309
314
        'out-point-changed': ['out-point'],
310
315
        'media-duration-changed': ['media-duration'],
311
316
        'priority-changed': ['priority'],
312
 
        'selected-changed' : ['state'],
313
 
        'stagger-changed' : ['stagger'],
314
 
        'active-changed' : ['active'],
 
317
        'selected-changed': ['state'],
 
318
        'stagger-changed': ['stagger'],
 
319
        'active-changed': ['active'],
315
320
    }
316
321
 
317
322
    def __init__(self, factory, stream, start=0,
543
548
        if priority != self._public_priority:
544
549
            self._updatePriority(priority)
545
550
 
546
 
    def _getTruePriority (self, priority):
 
551
    def _getTruePriority(self, priority):
547
552
        """ calculate the priority the contained gnlobject should have """
548
553
        if self.stream_type is VideoStream:
549
554
            return 3 + self._stagger + (3 * priority)
693
698
            public_priority = (true_priority - 2 - self._stagger) // 3
694
699
        elif self.stream_type is AudioStream:
695
700
            true_priority = obj.props.priority
696
 
            public_priority = (true_priority - 2 - (2 * self._stagger))// 4
 
701
            public_priority = (true_priority - 2 - (2 * self._stagger)) // 4
697
702
        if self._public_priority != public_priority:
698
703
            self._public_priority = public_priority
699
704
            self.emit('priority-changed', public_priority)
733
738
            self._updatePriority(self._public_priority)
734
739
            self.emit("stagger-changed", self._stagger)
735
740
 
 
741
 
736
742
class SourceTrackObject(TrackObject):
737
743
 
738
744
    numobjs = 0
744
750
        SourceTrackObject.numobjs += 1
745
751
        return source
746
752
 
 
753
 
747
754
class TrackEffect(TrackObject):
748
755
 
749
756
    numobjs = 0
792
799
        effect_bin = list(self.gnl_object.elements())[0]
793
800
        return effect_bin.get_by_name("effect")
794
801
 
 
802
 
795
803
class Transition(Signallable):
796
804
 
797
805
    __signals__ = {
798
 
        "start-changed" : ["start"],
799
 
        "duration-changed" : ["duration"],
800
 
        "priority-changed" : ["priority"],
 
806
        "start-changed": ["start"],
 
807
        "duration-changed": ["duration"],
 
808
        "priority-changed": ["priority"],
801
809
    }
802
810
 
803
811
    def __init__(self, a, b):
868
876
    def removeThyselfFromComposition(self, composition):
869
877
        pass
870
878
 
 
879
 
871
880
class VideoTransition(Transition):
872
881
 
873
882
    caps = gst.Caps("video/x-raw-yuv,format=(fourcc)AYUV")
913
922
            self.controller.set("alpha", 0, 1.0)
914
923
            self.controller.set("alpha", self.duration, 0.0)
915
924
 
 
925
 
916
926
class AudioTransition(Transition):
917
927
 
918
928
    def _makeGnlObject(self):
934
944
 
935
945
        self.b_operation.props.media_start = 0
936
946
 
937
 
 
938
947
    def addThyselfToComposition(self, composition):
939
948
        composition.add(self.a_operation, self.b_operation)
940
949
 
967
976
        self.b_controller.set("volume", 0, 0.0)
968
977
        self.b_controller.set("volume", self.duration, 1.0)
969
978
 
 
979
 
970
980
class Track(Signallable, Loggable):
971
981
    logCategory = "track"
972
982
 
976
986
        'track-object-added': ['track_object'],
977
987
        'track-object-removed': ['track_object'],
978
988
        'max-priority-changed': ['track_object'],
979
 
        'transition-added' : ['transition'],
980
 
        'transition-removed' : ['transition'],
 
989
        'transition-added': ['transition'],
 
990
        'transition-removed': ['transition'],
981
991
    }
982
992
 
983
993
    def __init__(self, stream):