mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-23 10:11:08 +00:00
python: Add a Timeline.iter_clips() helper to iterate clips
This commit is contained in:
parent
9ec1ebfbdf
commit
3b182342e0
2 changed files with 19 additions and 0 deletions
|
@ -98,6 +98,16 @@ class Asset(GES.Asset):
|
||||||
Asset = override(Asset)
|
Asset = override(Asset)
|
||||||
__all__.append('Asset')
|
__all__.append('Asset')
|
||||||
|
|
||||||
|
class Timeline(GES.Timeline):
|
||||||
|
def iter_clips(self):
|
||||||
|
"""Iterate all clips in a timeline"""
|
||||||
|
for layer in self.get_layers():
|
||||||
|
for clip in layer.get_clips():
|
||||||
|
yield clip
|
||||||
|
|
||||||
|
Timeline = override(Timeline)
|
||||||
|
__all__.append('Timeline')
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from gi.repository import Gst
|
from gi.repository import Gst
|
||||||
Gst
|
Gst
|
||||||
|
|
|
@ -102,6 +102,15 @@ class TestTimeline(common.GESSimpleTimelineTest):
|
||||||
self.assertEqual(timeline.get_asset(), project)
|
self.assertEqual(timeline.get_asset(), project)
|
||||||
self.assertEqual(len(project.list_assets(GES.Extractable)), 2)
|
self.assertEqual(len(project.list_assets(GES.Extractable)), 2)
|
||||||
|
|
||||||
|
def test_iter_timeline(self):
|
||||||
|
all_clips = set()
|
||||||
|
for l in range(5):
|
||||||
|
self.timeline.append_layer()
|
||||||
|
for _ in range(5):
|
||||||
|
all_clips.add(self.append_clip(l))
|
||||||
|
self.assertEqual(set(self.timeline.iter_clips()), all_clips)
|
||||||
|
|
||||||
|
|
||||||
def test_nested_serialization(self):
|
def test_nested_serialization(self):
|
||||||
nested_timeline = common.create_project(with_group=True, saved=True)
|
nested_timeline = common.create_project(with_group=True, saved=True)
|
||||||
nested_project = nested_timeline.get_asset()
|
nested_project = nested_timeline.get_asset()
|
||||||
|
|
Loading…
Reference in a new issue