mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 12:11:13 +00:00
ges: Fix reloading UriClipAsset synchronously
And add tests for that
This commit is contained in:
parent
e41a6b6fac
commit
4c985b4155
2 changed files with 55 additions and 3 deletions
|
@ -251,6 +251,15 @@ _check_and_update_parameters (GType * extractable_type, const gchar * id,
|
|||
static gboolean
|
||||
start_loading (GESAsset * asset)
|
||||
{
|
||||
GInitableIface *iface;
|
||||
|
||||
iface = g_type_interface_peek (GES_ASSET_GET_CLASS (asset), G_TYPE_INITABLE);
|
||||
|
||||
if (!iface->init) {
|
||||
GST_INFO_OBJECT (asset, "Can not start loading sync, as no ->init vmethod");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
ges_asset_cache_put (gst_object_ref (asset), NULL);
|
||||
return ges_asset_cache_set_loaded (asset->priv->extractable_type,
|
||||
asset->priv->id, NULL);
|
||||
|
@ -1493,6 +1502,9 @@ ges_asset_needs_reload (GType extractable_type, const gchar * id)
|
|||
GESAsset *asset;
|
||||
GError *error = NULL;
|
||||
|
||||
g_return_val_if_fail (g_type_is_a (extractable_type, GES_TYPE_EXTRACTABLE),
|
||||
FALSE);
|
||||
|
||||
real_id = _check_and_update_parameters (&extractable_type, id, &error);
|
||||
if (error) {
|
||||
_ensure_asset_for_wrong_id (id, extractable_type, error);
|
||||
|
|
|
@ -21,6 +21,7 @@ from . import overrides_hack
|
|||
|
||||
import os
|
||||
import gi
|
||||
import tempfile
|
||||
|
||||
gi.require_version("Gst", "1.0")
|
||||
gi.require_version("GES", "1.0")
|
||||
|
@ -31,6 +32,12 @@ from gi.repository import GES # noqa
|
|||
import unittest # noqa
|
||||
from unittest import mock
|
||||
|
||||
try:
|
||||
gi.require_version("GstTranscoder", "1.0")
|
||||
from gi.repository import GstTranscoder
|
||||
except ValueError:
|
||||
GstTranscoder = None
|
||||
|
||||
from . import common
|
||||
from .common import GESSimpleTimelineTest # noqa
|
||||
|
||||
|
@ -51,12 +58,45 @@ class TestTimeline(GESSimpleTimelineTest):
|
|||
Gst.filename_to_uri(os.path.join(__file__, "../../assets/png.png")))
|
||||
|
||||
def test_request_relocated_twice(self):
|
||||
mainloop = common.create_main_loop()
|
||||
|
||||
GES.add_missing_uri_relocation_uri(Gst.filename_to_uri(os.path.join(__file__, "../../")), True)
|
||||
proj = GES.Project.new()
|
||||
|
||||
asset = proj.create_asset_sync("file:///png.png", GES.UriClip)
|
||||
self.assertIsNotNone(asset)
|
||||
asset = proj.create_asset_sync("file:///png.png", GES.UriClip)
|
||||
self.assertIsNotNone(asset)
|
||||
self.assertIsNotNone(asset)
|
||||
|
||||
@unittest.skipIf(GstTranscoder is None, "GstTranscoder is not available")
|
||||
@unittest.skipIf(Gst.ElementFactory.make("testsrcbin") is None, "testbinsrc is not available")
|
||||
def test_reload_asset(self):
|
||||
with tempfile.NamedTemporaryFile(suffix=".ogg") as f:
|
||||
uri = Gst.filename_to_uri(f.name)
|
||||
transcoder = GstTranscoder.Transcoder.new("testbin://video,num-buffers=30",
|
||||
uri, "application/ogg:video/x-theora:audio/x-vorbis")
|
||||
transcoder.run()
|
||||
|
||||
asset0 = GES.UriClipAsset.request_sync(uri)
|
||||
self.assertEqual(asset0.props.duration, Gst.SECOND)
|
||||
|
||||
transcoder = GstTranscoder.Transcoder.new("testbin://video,num-buffers=60",
|
||||
uri, "application/ogg:video/x-theora:audio/x-vorbis")
|
||||
transcoder.run()
|
||||
|
||||
GES.Asset.needs_reload(GES.UriClip, uri)
|
||||
asset1 = GES.UriClipAsset.request_sync(uri)
|
||||
self.assertEqual(asset1.props.duration, 2 * Gst.SECOND)
|
||||
self.assertEqual(asset1, asset0)
|
||||
|
||||
transcoder = GstTranscoder.Transcoder.new("testbin://video,num-buffers=90",
|
||||
uri, "application/ogg:video/x-theora:audio/x-vorbis")
|
||||
transcoder.run()
|
||||
mainloop = common.create_main_loop()
|
||||
def asset_loaded_cb(_, res, mainloop):
|
||||
asset2 = GES.Asset.request_finish(res)
|
||||
self.assertEqual(asset2.props.duration, 3 * Gst.SECOND)
|
||||
self.assertEqual(asset2, asset0)
|
||||
mainloop.quit()
|
||||
|
||||
GES.Asset.needs_reload(GES.UriClip, uri)
|
||||
GES.Asset.request_async(GES.UriClip, uri, None, asset_loaded_cb, mainloop)
|
||||
mainloop.run()
|
||||
|
|
Loading…
Reference in a new issue