本文整理汇总了Python中pitivi.timeline.track.SourceTrackObject类的典型用法代码示例。如果您正苦于以下问题:Python SourceTrackObject类的具体用法?Python SourceTrackObject怎么用?Python SourceTrackObject使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SourceTrackObject类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testCopyMakeBinNotCalled
def testCopyMakeBinNotCalled(self):
factory = self.factory
stream = self.stream
obj1 = SourceTrackObject(factory, stream)
# this used to raise an exception
obj2 = obj1.copy()
self.failUnlessEqual(obj1.start, obj2.start)
示例2: configureStreams
def configureStreams(self, inputs, offsets):
count = 0
for i in inputs:
factory = self.facs[i][0]
stream = self.facs[i][1]
track_object = SourceTrackObject(factory, stream)
self.track_objects.append(track_object)
track_object.start = offsets[count]
self.track.addTrackObject(track_object)
count += 1
示例3: testMaxPriority
def testMaxPriority(self):
track = self.track1
factory = self.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, self.stream)
obj2.priority = 5
track.addTrackObject(obj2)
self.failUnlessEqual(track.max_priority, 10)
obj3 = SourceTrackObject(factory, self.stream)
obj3.priority = 14
track.addTrackObject(obj3)
self.failUnlessEqual(track.max_priority, 14)
obj3.priority = 9
self.failUnlessEqual(track.max_priority, 10)
obj2.priority = 11
self.failUnlessEqual(track.max_priority, 11)
track.removeTrackObject(obj1)
self.failUnlessEqual(track.max_priority, 11)
track.removeTrackObject(obj2)
self.failUnlessEqual(track.max_priority, 9)
track.removeTrackObject(obj3)
self.failUnlessEqual(track.max_priority, 0)
示例4: setUp
def setUp(self):
TestCase.setUp(self)
stream = AudioStream(gst.Caps("audio/x-raw-int"))
self.factory = StubFactory()
gst.debug("%r" % self.factory.duration)
self.factory.addOutputStream(stream)
self.track_object = SourceTrackObject(self.factory, stream)
self.monitor = TrackSignalMonitor(self.track_object)
示例5: testAudioOnly
def testAudioOnly(self):
audio_factory1 = AudioTestSourceFactory(3)
audio_factory1.duration = 10 * gst.SECOND
stream = AudioStream(gst.Caps('audio/x-raw-int'), 'src0')
audio_factory1.addOutputStream(stream)
timeline = Timeline()
track = Track(stream)
track_object1 = SourceTrackObject(audio_factory1, stream)
track_object1.start = 2 * gst.SECOND
track.addTrackObject(track_object1)
timeline.addTrack(track)
factory = TimelineSourceFactory(timeline)
bin = factory.makeBin()
self.failUnlessEqual(len(list(bin)), 1)
self.failUnlessEqual(factory.duration, 12 * gst.SECOND)
fakesink = gst.element_factory_make('fakesink')
def bin_pad_added_cb(bin, pad):
pad.link(fakesink.get_pad('sink'))
bin.connect('pad-added', bin_pad_added_cb)
def error_cb(bus, message):
gerror, debug = message.parse_error()
self.fail('%s: %s' % (gerror.message, debug))
def eos_cb(bus, message):
self.loop.quit()
pipeline = gst.Pipeline()
bus = pipeline.get_bus()
bus.add_signal_watch()
bus.connect('message::error', error_cb)
bus.connect('message::eos', eos_cb)
pipeline.add(bin)
pipeline.add(fakesink)
pipeline.set_state(gst.STATE_PLAYING)
self.loop.run()
pipeline.set_state(gst.STATE_NULL)
factory.clean()
示例6: testGetTrackObjectsGroupedByLayer
def testGetTrackObjectsGroupedByLayer(self):
factory = self.factory
stream = self.stream
track1 = self.track1
test_data = [
("a", 0, 10, 0),
("b", 5, 15, 0),
("c", 20, 25, 0),
("d", 30, 35, 0),
("e", 30, 35, 2),
("f", 35, 45, 0),
("g", 40, 50, 0),
("h", 50, 60, 0),
("i", 55, 65, 1),
("j", 57, 60, 2),
("k", 62, 70, 3),
("l", 63, 67, 0),
]
expected = [
["a", "b", "c", "d", "f", "g", "h", "l"],
["i"],
["e", "j"],
["k"]
]
objs = {}
for name, start, end, priority in test_data:
obj = SourceTrackObject(factory, stream)
obj.start = start * gst.SECOND
obj.duration = end * gst.SECOND - obj.start
obj.priority = priority
track1.addTrackObject(obj)
objs[obj] = name
result = [[objs[obj] for obj in layer] for layer in
track1.getTrackObjectsGroupedByLayer()]
self.failUnlessEqual(result, expected)
示例7: testSplitObjectKeyframes
def testSplitObjectKeyframes(self):
DURATION = 10 * gst.SECOND
factory = AudioTestSourceFactory()
factory.duration = DURATION
stream_ = AudioStream(gst.Caps("audio/x-raw-int"))
obj = SourceTrackObject(factory, stream_)
track = Track(stream_)
track.addTrackObject(obj)
obj.start = 3 * gst.SECOND
obj.duration = DURATION
# create a three keyframes at: 3, 6 and 9 seconds
interpolator = obj.getInterpolator("volume")
keyframes = dict(((t * gst.SECOND, (t % 2, gst.INTERPOLATE_LINEAR))
for t in xrange(3, 10, 3)))
expected = []
expected2 = []
for time, (value, mode) in keyframes.iteritems():
kf = interpolator.newKeyframe(time, value, mode)
if time < (5 * gst.SECOND):
expected.append(kf)
else:
expected2.append(kf)
def getKeyframes(obj):
keyframes = obj.getInterpolator("volume").getInteriorKeyframes()
return list(keyframes)
obj2 = obj.splitObject(8 * gst.SECOND)
keyframes = getKeyframes(obj)
keyframes2 = getKeyframes(obj2)
self.failUnlessEqual(keyframes, expected)
self.failUnlessEqual(keyframes2, expected2)
示例8: addClip
def addClip(name, start, end):
obj = SourceTrackObject(factory, stream)
obj.start = start * gst.SECOND
obj.in_point = 0
obj.duration = end * gst.SECOND - obj.start
obj.media_duration = obj.duration
obj.name = name
names[obj] = name
objs[name] = obj
track1.addTrackObject(obj)
示例9: testGetNextTrackObject
def testGetNextTrackObject(self):
factory = self.factory
stream = self.stream
track1 = self.track1
obj1 = SourceTrackObject(factory, stream)
track1.addTrackObject(obj1)
obj2 = SourceTrackObject(factory, stream)
track1.addTrackObject(obj2)
obj3 = SourceTrackObject(factory, stream)
track1.addTrackObject(obj3)
obj4 = SourceTrackObject(factory, stream)
track1.addTrackObject(obj4)
obj1.start = 1 * gst.SECOND
obj1.duration = 5 * gst.SECOND
obj1.priority = 1
obj2.start = 8 * gst.SECOND
obj2.duration = 5 * gst.SECOND
obj2.priority = 1
obj3.start = 6 * gst.SECOND
obj3.duration = 5 * gst.SECOND
obj3.priority = 2
obj4.start = 7 * gst.SECOND
obj4.duration = 5 * gst.SECOND
obj4.priority = 3
# no next object
self.failUnlessRaises(TrackError, track1.getNextTrackObject, obj2)
# same priority
prev = track1.getNextTrackObject(obj1)
self.failUnlessEqual(prev, obj2)
# given priority
prev = track1.getNextTrackObject(obj1, priority=2)
self.failUnlessEqual(prev, obj3)
# any priority
prev = track1.getNextTrackObject(obj3, priority=None)
self.failUnlessEqual(prev, obj4)
示例10: TestTrackObject
class TestTrackObject(TestCase):
def setUp(self):
TestCase.setUp(self)
stream = AudioStream(gst.Caps("audio/x-raw-int"))
self.factory = StubFactory()
gst.debug("%r" % self.factory.duration)
self.factory.addOutputStream(stream)
self.track_object = SourceTrackObject(self.factory, stream)
self.monitor = TrackSignalMonitor(self.track_object)
def tearDown(self):
self.monitor = None
self.track_object.release()
self.track_oject = None
self.factory = None
TestCase.tearDown(self)
def testDefaultProperties(self):
obj = self.track_object
self.failUnlessEqual(obj.start, 0)
self.failUnlessEqual(obj.duration, self.factory.duration)
self.failUnlessEqual(obj.in_point, 0)
self.failUnlessEqual(obj.out_point, self.factory.duration)
self.failUnlessEqual(obj.media_duration, self.factory.duration)
self.failUnlessEqual(obj.rate, 1)
self.failUnlessEqual(obj.priority, 0)
gnl_object = obj.gnl_object
self.failUnlessEqual(gnl_object.props.start, 0)
self.failUnlessEqual(gnl_object.props.duration, self.factory.duration)
self.failUnlessEqual(gnl_object.props.media_start, 0)
self.failUnlessEqual(gnl_object.props.media_stop,
self.factory.duration)
self.failUnlessEqual(gnl_object.props.media_duration,
self.factory.duration)
self.failUnlessEqual(gnl_object.props.rate, 1)
self.failUnlessEqual(obj.priority, 0)
def testChangePropertiesFromTrackObject(self):
obj = self.track_object
gnl_object = obj.gnl_object
start = 1 * gst.SECOND
obj.start = start
self.failUnlessEqual(obj.start, start)
self.failUnlessEqual(gnl_object.props.start, start)
self.failUnlessEqual(self.monitor.start_changed_count, 1)
duration = 10 * gst.SECOND
obj.duration = duration
self.failUnlessEqual(obj.duration, duration)
self.failUnlessEqual(gnl_object.props.duration, duration)
self.failUnlessEqual(self.monitor.duration_changed_count, 1)
in_point = 5 * gst.SECOND
obj.in_point = in_point
self.failUnlessEqual(obj.in_point, in_point)
self.failUnlessEqual(gnl_object.props.media_start, in_point)
self.failUnlessEqual(self.monitor.in_point_changed_count, 1)
media_duration = 5 * gst.SECOND
obj.media_duration = media_duration
self.failUnlessEqual(obj.media_duration, media_duration)
self.failUnlessEqual(gnl_object.props.media_duration, media_duration)
self.failUnlessEqual(obj.out_point, in_point + media_duration)
self.failUnlessEqual(gnl_object.props.media_stop,
in_point + media_duration)
self.failUnlessEqual(self.monitor.media_duration_changed_count, 1)
self.failUnlessEqual(self.monitor.out_point_changed_count, 1)
# test video stream$
obj.stream_type = VideoStream
priority = 100
gnl_priority = 3 * 100 + 3 + obj._stagger
obj.priority = priority
self.failUnlessEqual(obj.priority, priority)
self.failUnlessEqual(gnl_object.props.priority, gnl_priority)
self.failUnlessEqual(self.monitor.priority_changed_count, 1)
# test audio stream
obj.stream_type = AudioStream
priority = 55
gnl_priority = 4 * 55 + 3 + 2 * obj._stagger
obj.priority = priority
self.failUnlessEqual(obj.priority, priority)
self.failUnlessEqual(gnl_object.props.priority, gnl_priority)
self.failUnlessEqual(self.monitor.priority_changed_count, 2)
def testChangePropertiesFromGnlObject(self):
obj = self.track_object
gnl_object = obj.gnl_object
start = 1 * gst.SECOND
gnl_object.props.start = start
self.failUnlessEqual(obj.start, start)
self.failUnlessEqual(self.monitor.start_changed_count, 1)
duration = 10 * gst.SECOND
gnl_object.props.duration = duration
#.........这里部分代码省略.........
示例11: testSplitObject
def testSplitObject(self):
DURATION = 10 * gst.SECOND
factory = AudioTestSourceFactory()
factory.duration = DURATION
stream_ = AudioStream(gst.Caps("audio/x-raw-int"))
obj = SourceTrackObject(factory, stream_)
track = Track(stream_)
track.addTrackObject(obj)
obj.start = 3 * gst.SECOND
obj.duration = DURATION
# create a zig-zag volume curve
interpolator = obj.getInterpolator("volume")
expected = dict(((t * gst.SECOND, (t % 2, gst.INTERPOLATE_LINEAR))
for t in xrange(3, 10, 3)))
for time, (value, mode) in expected.iteritems():
interpolator.newKeyframe(time, value, mode)
def getKeyframes(obj):
keyframes = obj.getInterpolator("volume").getInteriorKeyframes()
return dict(((kf.time, (kf.value, kf.mode)) for kf in keyframes))
monitor = TrackSignalMonitor(obj)
self.failUnlessRaises(TrackError, obj.splitObject, 2 * gst.SECOND)
self.failUnlessRaises(TrackError, obj.splitObject, 14 * gst.SECOND)
# should these be possible (ie create empty objects) ?
self.failUnlessRaises(TrackError, obj.splitObject, 3 * gst.SECOND)
self.failUnlessRaises(TrackError, obj.splitObject, 13 * gst.SECOND)
# splitObject at 4s should result in:
# obj (start 3, end 4) other1 (start 4, end 13)
other1 = obj.splitObject(4 * gst.SECOND)
self.failUnlessEqual(expected, getKeyframes(other1))
self.failUnlessEqual(obj.start, 3 * gst.SECOND)
self.failUnlessEqual(obj.in_point, 0 * gst.SECOND)
self.failUnlessEqual(obj.duration, 1 * gst.SECOND)
self.failUnlessEqual(obj.rate, 1)
self.failUnlessEqual(other1.start, 4 * gst.SECOND)
self.failUnlessEqual(other1.in_point, 1 * gst.SECOND)
self.failUnlessEqual(other1.duration, 9 * gst.SECOND)
self.failUnlessEqual(other1.rate, 1)
self.failUnlessEqual(monitor.start_changed_count, 0)
self.failUnlessEqual(monitor.duration_changed_count, 1)
# move other1 back to start = 1
other1.start = 1 * gst.SECOND
# splitObject again other1
monitor = TrackSignalMonitor(other1)
other2 = other1.splitObject(6 * gst.SECOND)
self.failUnlessEqual(other1.start, 1 * gst.SECOND)
self.failUnlessEqual(other1.in_point, 1 * gst.SECOND)
self.failUnlessEqual(other1.duration, 5 * gst.SECOND)
self.failUnlessEqual(other1.rate, 1)
self.failUnlessEqual(other2.start, 6 * gst.SECOND)
self.failUnlessEqual(other2.in_point, 6 * gst.SECOND)
self.failUnlessEqual(other2.duration, 4 * gst.SECOND)
self.failUnlessEqual(other2.rate, 1)
self.failUnlessEqual(monitor.start_changed_count, 0)
self.failUnlessEqual(monitor.duration_changed_count, 1)
示例12: testUpdatesAfterEnablingUpdates
def testUpdatesAfterEnablingUpdates(self):
factory = self.factory
stream = self.stream
track1 = self.track1
test_data = [
("a", 0, 10),
("b", 5, 15),
("c", 20, 25),
("d", 30, 35),
("e", 30, 35),
("f", 35, 45),
("g", 40, 50),
("h", 50, 60),
("i", 55, 65),
("j", 57, 60),
("k", 62, 70),
("l", 63, 67),
]
expected = [("a", "b"), ("d", "e"), ("f", "g")]
result = []
added = set()
removed = set()
def transitionAddedCb(track, transition):
pair =(names[transition.a], names[transition.b])
result.append(pair)
added.add(pair)
def transitionRemovedCb(track, transition):
pair = (names[transition.a], names[transition.b])
result.remove(pair)
removed.add(pair)
track1.connect("transition-added", transitionAddedCb)
track1.connect("transition-removed", transitionRemovedCb)
objs = {}
names = {}
for name, start, end in test_data:
obj = SourceTrackObject(factory, stream)
obj.start = start * gst.SECOND
obj.in_point = 0
obj.duration = end * gst.SECOND - obj.start
obj.media_duration = obj.duration
names[obj] = name
objs[name] = obj
track1.addTrackObject(obj)
self.failUnlessEqual(result, expected)
track1.disableUpdates()
# move c so that it overlaps with b
# move g so that it overlaps d, e, f
# update the transitions, check that we have the expected
# configuration
test_data = [
("c", 12, 20),
("g", 30, 46),
]
expected = [("a", "b"), ("b", "c")]
added = set()
removed = set()
for name, start, end in test_data:
objs[name].start = start * gst.SECOND
objs[name].duration = (end - start) * gst.SECOND
track1.enableUpdates()
self.failUnlessEqual(result, expected)
# check that *only* (b, c) was added in the update
self.failUnlessEqual(added, set([("b", "c")]))
# check that *only* (d, e) was removed in the update
self.failUnlessEqual(removed, set([("d", "e"), ("f", "g")]))
# move c to a different layer. check that (b, c) transition is removed
track1.disableUpdates()
added = set()
removed = set()
objs["c"].priority = 1
expected = [("a", "b")]
track1.enableUpdates()
self.failUnlessEqual(result, expected)
self.failUnlessEqual(added, set())
self.failUnlessEqual(removed, set([("b", "c")]))
示例13: testUpdateAfterAddingAndRemovingTrackObjects
def testUpdateAfterAddingAndRemovingTrackObjects(self):
factory = self.factory
stream = self.stream
track1 = self.track1
test_data = [
("a", 0, 10),
("b", 5, 15),
("c", 20, 25),
("d", 30, 35),
("f", 35, 45),
("g", 40, 50),
("e", 30, 35),
("h", 50, 60),
("i", 55, 65),
("j", 57, 60),
("k", 62, 70),
("l", 63, 67),
]
# object j makes track arrangment invalid
valid_in_order = [True for x in "abcdefghi"]
valid_in_order.extend([False, False, False])
added_in_order = [("a", "b"), ("f", "g"), ("d", "e"),
("h", "i"), ("i", "k"), ("h", "i")]
removed_in_order = [("h", "i"), ("i", "k")]
objs = {}
names = {}
added = []
removed = []
def transitionAddedCb(track, transition):
added.append((names[transition.a],
names[transition.b]))
def transitionRemovedCb(track, transition):
removed.append((names[transition.a],
names[transition.b]))
track1.connect("transition-added", transitionAddedCb)
track1.connect("transition-removed", transitionRemovedCb)
valid = []
for name, start, end in test_data:
obj = SourceTrackObject(factory, stream)
obj.start = start * gst.SECOND
obj.in_point = 0
obj.duration = end * gst.SECOND - obj.start
obj.media_duration = obj.duration
names[obj] = name
objs[name] = obj
track1.addTrackObject(obj)
valid.append(track1.valid_arrangement)
# removing this object brings (h, i) back
track1.removeTrackObject(objs["j"])
self.failUnlessEqual(added, added_in_order)
self.failUnlessEqual(removed, removed_in_order)
self.failUnlessEqual(valid, valid_in_order)
# removing this should make the track valid again
track1.removeTrackObject(objs["l"])
self.failUnlessEqual(track1.valid_arrangement,
True)
示例14: testAddRemoveTransitions
def testAddRemoveTransitions(self):
factory = self.factory
track1 = self.track1
track1._update_transitions = False
stream = self.stream
test_data = [
("a", 0, 10),
("b", 5, 15),
("c", 15, 20),
("d", 30, 35),
("e", 30, 35),
]
transitions = [
("a", "b"),
("d", "e"),
]
objs = {}
names = {}
for name, start, end in test_data:
obj = SourceTrackObject(factory, stream)
obj.start = start * gst.SECOND
obj.in_point = 0
obj.duration = end * gst.SECOND - obj.start
obj.media_duration = obj.duration
track1.addTrackObject(obj)
names[obj] = name
objs[name] = obj
result = []
transition_objects = {}
def addTransition(b, c):
tr = Transition(objs[b], objs[c])
track1.addTransition(tr)
def transitionAddedCb(track, transition):
values =(names[transition.a], names[transition.b])
result.append(values)
transition_objects[values] = transition
def transitionRemovedCb(track, transition):
values =(names[transition.a], names[transition.b])
result.remove(values)
track1.connect("transition-added", transitionAddedCb)
track1.connect("transition-removed", transitionRemovedCb)
# add transitions and check that initial properties are properly
# evaluated
for a, b in transitions:
addTransition(a, b)
self.failUnlessEqual(result, transitions)
# check that adding a transition with a bogus track object raises an
# error
track1.removeTrackObject(objs["c"])
self.failUnlessRaises(TrackError, addTransition, "b", "c")
# check that adding a transition that already exists raises an error
self.failUnlessRaises(TrackError, addTransition, "d", "e")
# check that removing a transition directly works
track1.removeTransition(transition_objects["d", "e"])
self.failUnlessEqual(result, [("a", "b")])
# check tht we can restore a transition after deleting it
addTransition("d", "e")
self.failUnlessEqual(result, [("a", "b"), ("d", "e")])
示例15: testGetValidTransitionSlots
def testGetValidTransitionSlots(self):
factory = self.factory
stream = self.stream
track1 = self.track1
test_data = [
("a", 0, 10),
("b", 5, 15),
("c", 20, 25),
("d", 30, 35),
("e", 30, 35),
("f", 35, 45),
("g", 40, 50),
("h", 50, 60),
("i", 55, 65),
("j", 57, 60),
("k", 62, 70),
("l", 63, 67),
]
expected = [["a", "b"], ["d", "e"], ["f", "g"]]
objs = {}
names = {}
ordered = []
for name, start, end in test_data:
obj = SourceTrackObject(factory, stream)
obj.start = start * gst.SECOND
obj.duration = end * gst.SECOND - obj.start
track1.addTrackObject(obj)
objs[name] = obj
names[obj] = name
ordered.append(obj)
slots, valid = track1.getValidTransitionSlots(ordered)
result = [[names[obj] for obj in layer] for layer in
slots]
self.failUnlessEqual(result, expected)
self.failUnlessEqual(track1.valid_arrangement, False)
test_data = [
("a", 0, 5),
("b", 9, 12),
("c", 8, 13)
]
ordered = []
for name, start, end in test_data:
ordered.append(objs[name])
objs[name].start = gst.SECOND * start
objs[name].duration = gst.SECOND * (end - start)
slots, valid = track1.getValidTransitionSlots(ordered)
self.failUnlessEqual(valid, False)
test_data = [
("a", 0, 5),
("b", 1, 4),
("c", 8, 13),
]
ordered = []
for name, start, end in test_data:
ordered.append(objs[name])
objs[name].start = gst.SECOND * start
objs[name].duration = gst.SECOND * (end - start)
slots, valid = track1.getValidTransitionSlots(ordered)
self.failUnlessEqual(valid, False)