1
# PiTiVi , Non-linear video editor
5
# Copyright (c) 2005, Edward Hervey <bilboed@bilboed.com>
7
# This program is free software; you can redistribute it and/or
8
# modify it under the terms of the GNU Lesser General Public
9
# License as published by the Free Software Foundation; either
10
# version 2.1 of the License, or (at your option) any later version.
12
# This program is distributed in the hope that it will be useful,
13
# but WITHOUT ANY WARRANTY; without even the implied warranty of
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15
# Lesser General Public License for more details.
17
# You should have received a copy of the GNU Lesser General Public
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.
23
Timeline and timeline objects
29
from pitivi.settings import ExportSettings
30
from composition import TimelineComposition
31
from objects import MEDIA_TYPE_AUDIO, MEDIA_TYPE_VIDEO
33
class Timeline(gobject.GObject):
35
Fully fledged timeline
38
# TODO make the compositions more versatile
39
# for the time being we hardcode an audio and a video composition
41
def __init__(self, project):
42
gst.log("new Timeline for project %s" % project)
43
gobject.GObject.__init__(self)
44
self.project = project
46
self.timeline = gst.Bin("timeline-" + project.name)
49
def _fillContents(self):
50
# TODO create the initial timeline according to the project settings
51
self.audiocomp = TimelineComposition(media_type = MEDIA_TYPE_AUDIO, name="audiocomp")
52
self.videocomp = TimelineComposition(media_type = MEDIA_TYPE_VIDEO, name="videocomp")
53
self.videocomp.linkObject(self.audiocomp)
55
# add default audio/video sources
56
defaultaudio = gst.element_factory_make("audiotestsrc")
57
defaultaudio.props.volume = 0
58
defaultaudiosource = gst.element_factory_make("gnlsource", "defaultaudiosource")
59
defaultaudiosource.add(defaultaudio)
60
self.audiocomp.setDefaultSource(defaultaudiosource)
62
defaultvideo = gst.element_factory_make("videotestsrc")
63
defaultvideo.props.pattern = 2
64
defaultvideosource = gst.element_factory_make("gnlsource", "defaultvideosource")
65
defaultvideosource.add(defaultvideo)
66
self.videocomp.setDefaultSource(defaultvideosource)
68
self.timeline.add(self.audiocomp.gnlobject,
69
self.videocomp.gnlobject)
70
self.audiocomp.gnlobject.connect("pad-added", self._newAudioPadCb)
71
self.videocomp.gnlobject.connect("pad-added", self._newVideoPadCb)
72
self.audiocomp.gnlobject.connect("pad-removed", self._removedAudioPadCb)
73
self.videocomp.gnlobject.connect("pad-removed", self._removedVideoPadCb)
75
def _newAudioPadCb(self, unused_audiocomp, pad):
76
asrc = gst.GhostPad("asrc", pad)
78
self.timeline.add_pad(asrc)
80
def _newVideoPadCb(self, unused_videocomp, pad):
81
vsrc = gst.GhostPad("vsrc", pad)
83
self.timeline.add_pad(vsrc)
85
def _removedAudioPadCb(self, unused_audiocomp, unused_pad):
86
self.timeline.remove_pad(self.timeline.get_pad("asrc"))
88
def _removedVideoPadCb(self, unused_audiocomp, unused_pad):
89
self.timeline.remove_pad(self.timeline.get_pad("vsrc"))
91
def getAutoSettings(self):
92
v = self.videocomp._getAutoSettings()
93
a = self.audiocomp._getAutoSettings()
96
# return an ExportSettings containing the combination of
97
# the autosettings from the audio and video composition.
100
s.videowidth = v.videowidth
101
s.videoheight = v.videoheight
102
s.videorate = v.videorate
103
s.videopar = v.videopar
105
s.audiochannels = a.audiochannels
106
s.audiorate = a.audiorate
107
s.audiodepth = a.audiodepth