[pitivi] timeline: Fix update_clips_asset
- From: Alexandru Băluț <alexbalut src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pitivi] timeline: Fix update_clips_asset
- Date: Sun, 25 Oct 2020 07:15:51 +0000 (UTC)
commit bf12450ccd9fe99e74d3db000524909ee4361521
Author: Yatin Maan <yatinmaan1 gmail com>
Date: Mon Oct 19 19:38:22 2020 +0530
timeline: Fix update_clips_asset
Add test for timeline proxy switching
Fixes #2371
pitivi/medialibrary.py | 2 +-
pitivi/timeline/timeline.py | 26 +++++++++++++++++---------
tests/common.py | 10 ++++++----
tests/test_medialibrary.py | 36 ++++++++++++++++++++++++++++++++++++
tests/test_timeline_timeline.py | 2 +-
5 files changed, 61 insertions(+), 15 deletions(-)
---
diff --git a/pitivi/medialibrary.py b/pitivi/medialibrary.py
index 512c39891..0e307aa63 100644
--- a/pitivi/medialibrary.py
+++ b/pitivi/medialibrary.py
@@ -927,7 +927,7 @@ class MediaLibraryWidget(Gtk.Box, Loggable):
self._add_asset(asset)
if self._project.loaded:
- self.app.gui.editor.timeline_ui.update_clips_asset(asset, proxy)
+ self.app.gui.editor.timeline_ui.update_clips_asset(asset)
def _asset_added_cb(self, unused_project, asset):
"""Checks whether the asset added to the project should be shown."""
diff --git a/pitivi/timeline/timeline.py b/pitivi/timeline/timeline.py
index 38f8dd8e7..fb2e8036a 100644
--- a/pitivi/timeline/timeline.py
+++ b/pitivi/timeline/timeline.py
@@ -44,7 +44,6 @@ from pitivi.timeline.ruler import TimelineScaleRuler
from pitivi.undo.timeline import CommitTimelineFinalizingAction
from pitivi.utils.loggable import Loggable
from pitivi.utils.misc import asset_get_duration
-from pitivi.utils.proxy import get_proxy_target
from pitivi.utils.timeline import EditingContext
from pitivi.utils.timeline import SELECT
from pitivi.utils.timeline import Selection
@@ -1464,21 +1463,30 @@ class TimelineContainer(Gtk.Grid, Zoomable, Loggable):
# Public API
- def update_clips_asset(self, asset, proxy):
+ def update_clips_asset(self, asset):
"""Updates the relevant clips to use the asset or the proxy.
Args:
- asset (GES.Asset): Only the clips who's current asset's target is
- this will be updated.
- proxy (Ges.Asset): The proxy to use, or None to use the asset itself.
+ asset (GES.Asset): Only the clips which contain this asset will be
+ updated.
"""
- original_asset = get_proxy_target(asset)
- replacement_asset = proxy or asset
+ proxy = asset.props.proxy
+
+ if not proxy:
+ proxy_uris = (self.app.proxy_manager.get_proxy_uri(asset),
+ self.app.proxy_manager.get_proxy_uri(asset, scaled=True))
+
for clip in self.timeline.clips():
if not isinstance(clip, GES.UriClip):
continue
- if get_proxy_target(clip) == original_asset:
- clip.set_asset(replacement_asset)
+
+ if not proxy:
+ if clip.get_asset().props.id in proxy_uris:
+ clip.set_asset(asset)
+ else:
+ if clip.get_asset() == asset:
+ clip.set_asset(proxy)
+
self._project.pipeline.commit_timeline()
def insert_assets(self, assets, position=None):
diff --git a/tests/common.py b/tests/common.py
index aadce0839..50d7b96fb 100644
--- a/tests/common.py
+++ b/tests/common.py
@@ -123,11 +123,13 @@ def create_pitivi(**settings):
return app
-def create_timeline_container(**settings):
- app = create_pitivi_mock(leftClickAlsoSeeks=False, **settings)
- app.project_manager = ProjectManager(app)
- project = app.project_manager.new_blank_project()
+def create_timeline_container(app=None, **settings):
+ if not app:
+ app = create_pitivi_mock(leftClickAlsoSeeks=False, **settings)
+ app.project_manager = ProjectManager(app)
+ app.project_manager.new_blank_project()
+ project = app.project_manager.current_project
timeline_container = TimelineContainer(app, app.gui.editor.editor_state)
timeline_container.set_project(project)
diff --git a/tests/test_medialibrary.py b/tests/test_medialibrary.py
index 6c641870d..daef7f720 100644
--- a/tests/test_medialibrary.py
+++ b/tests/test_medialibrary.py
@@ -390,6 +390,42 @@ class TestMediaLibrary(BaseTestMediaLibrary):
self.assertEqual(clip.props.duration, duration)
self.assertEqual(clip.props.max_duration, duration)
+ def test_timeline_proxy_switching(self):
+ sample_name = "30fps_numeroted_frames_red.mkv"
+ with common.cloned_sample(sample_name):
+ self.check_import([sample_name], proxying_strategy=ProxyingStrategy.NOTHING)
+
+ common.create_timeline_container(self.app)
+ timeline = self.app.project_manager.current_project.ges_timeline
+
+ asset = self.medialibrary.store[0].asset
+ timeline.append_layer().add_asset(asset, 0, 0, Gst.CLOCK_TIME_NONE,
+ GES.TrackType.VIDEO)
+
+ def check_timeline_clip(expected_asset):
+ for layer in timeline.layers:
+ for clip in layer.get_clips():
+ self.assertEqual(clip.get_asset(), expected_asset)
+
+ # Check asset is in the timeline
+ check_timeline_clip(asset)
+
+ # Check asset is replaced by scaled proxy
+ scaled_proxy = self.check_add_proxy(asset, scaled=True)
+ check_timeline_clip(scaled_proxy)
+
+ # Check proxy is replaced back by asset
+ self.check_disable_proxy(scaled_proxy, asset, delete=True)
+ check_timeline_clip(asset)
+
+ # Check asset is replaced by HQ proxy
+ hq_proxy = self.check_add_proxy(asset)
+ check_timeline_clip(hq_proxy)
+
+ # Check proxy was replaced back by asset
+ self.check_disable_proxy(hq_proxy, asset, delete=True)
+ check_timeline_clip(asset)
+
def test_regenerate_scaled_proxy(self):
sample_name = "30fps_numeroted_frames_red.mkv"
with common.cloned_sample(sample_name):
diff --git a/tests/test_timeline_timeline.py b/tests/test_timeline_timeline.py
index 65cfd3e5a..f52d65c51 100644
--- a/tests/test_timeline_timeline.py
+++ b/tests/test_timeline_timeline.py
@@ -779,7 +779,7 @@ class TestTimelineContainer(common.TestCase):
self.assertListEqual(list(timeline_container.timeline.clips()), [title_clip])
# Check the title clips are ignored.
- timeline_container.update_clips_asset(mock.Mock(), mock.Mock())
+ timeline_container.update_clips_asset(mock.Mock())
class TestClipsEdges(common.TestCase):
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]