From 25500818707e870c33bf76e46a72949e9920324d Mon Sep 17 00:00:00 2001 From: Ken McGaugh Date: Sat, 24 Jan 2026 11:02:47 +1300 Subject: [PATCH] Added support for specifying timelines to import via an URI instead of posix path to an OTIO file. Signed-off-by: Ken McGaugh --- src/playlist/src/playlist_actor.cpp | 104 ++++++++++-------- .../src/plugin_manager_actor.cpp | 43 ++++++++ 2 files changed, 104 insertions(+), 43 deletions(-) diff --git a/src/playlist/src/playlist_actor.cpp b/src/playlist/src/playlist_actor.cpp index 3612fdc36..57fa16a87 100644 --- a/src/playlist/src/playlist_actor.cpp +++ b/src/playlist/src/playlist_actor.cpp @@ -1916,50 +1916,68 @@ caf::message_handler PlaylistActor::message_handler() { try { caf::scoped_actor sys(system()); - auto global = system().registry().template get(global_registry); - auto epa = request_receive(*sys, global, global::get_python_atom_v); - // spdlog::warn("Load from python"); - // request otio xml from embedded_python. - mail(session::import_atom_v, path) - .request(epa, infinite) - .then( - [=](const std::string &data) mutable { - // got data create timeline and load it.. - const auto name = fs::path(uri_to_posix_path(path)).stem().string(); - // spdlog::warn("Loaded from python {}", name); - mail(create_timeline_atom_v, name, uuid_before, false, false) - .request(actor_cast(this), infinite) - .then( - [=](const utility::UuidUuidActor &uua) mutable { - // request loading of timeline - if (not wait) { - anon_mail(session::import_atom_v, path, data) - .send(uua.second.actor()); - rp.deliver(uua.second); - } else { - mail(session::import_atom_v, path, data) - .request(uua.second.actor(), infinite) - .then( - [=](const bool) mutable { - rp.deliver(uua.second); - }, - [=](error &err) mutable { - spdlog::warn( - "{} {}", - __PRETTY_FUNCTION__, - to_string(err)); - rp.deliver(std::move(err)); - }); - } - }, - [=](error &err) mutable { - spdlog::warn( - "{} {}", __PRETTY_FUNCTION__, to_string(err)); - rp.deliver(std::move(err)); - }); - }, - [=](error &err) mutable { rp.deliver(std::move(err)); }); + if (path.scheme() != "file") { + + // Send path URI to data_source plugins to create and populate the timeline. + auto pm = system().registry().template get(plugin_manager_registry); + mail(data_source::use_data_atom_v, path, + caf::actor_cast(this), base_.media_rate(), uuid_before, wait) + .request(pm, infinite) + .then( + [=](const UuidActor &ua) mutable { + rp.deliver(ua); + }, + [=](error &err) mutable { rp.deliver(std::move(err)); }); + + } else { + + auto global = system().registry().template get(global_registry); + auto epa = request_receive(*sys, global, global::get_python_atom_v); + // spdlog::warn("Load from python"); + // request otio xml from embedded_python. + mail(session::import_atom_v, path) + .request(epa, infinite) + .then( + [=](const std::string &data) mutable { + // got data create timeline and load it.. + const auto name = fs::path(uri_to_posix_path(path)).stem().string(); + // spdlog::warn("Loaded from python {}", name); + mail(create_timeline_atom_v, name, uuid_before, false, false) + .request(actor_cast(this), infinite) + .then( + [=](const utility::UuidUuidActor &uua) mutable { + // request loading of timeline + if (not wait) { + anon_mail(session::import_atom_v, path, data) + .send(uua.second.actor()); + rp.deliver(uua.second); + } else { + mail(session::import_atom_v, path, data) + .request(uua.second.actor(), infinite) + .then( + [=](const bool) mutable { + rp.deliver(uua.second); + }, + + [=](error &err) mutable { + spdlog::warn( + "{} {}", + __PRETTY_FUNCTION__, + to_string(err)); + rp.deliver(std::move(err)); + }); + } + }, + [=](error &err) mutable { + spdlog::warn( + "{} {}", __PRETTY_FUNCTION__, to_string(err)); + rp.deliver(std::move(err)); + }); + }, + [=](error &err) mutable { rp.deliver(std::move(err)); }); + + } } catch (const std::exception &err) { rp.deliver(make_error(xstudio_error::error, err.what())); } diff --git a/src/plugin_manager/src/plugin_manager_actor.cpp b/src/plugin_manager/src/plugin_manager_actor.cpp index a405a00c0..36b7e09b9 100644 --- a/src/plugin_manager/src/plugin_manager_actor.cpp +++ b/src/plugin_manager/src/plugin_manager_actor.cpp @@ -101,6 +101,49 @@ PluginManagerActor::PluginManagerActor(caf::actor_config &cfg) : caf::event_base return rp; }, + // helper for dealing with URI's that create and return a timeline + [=](data_source::use_data_atom, + const caf::uri &uri, + const caf::actor &playlist_actor, + const FrameRate &media_rate, + const utility::Uuid &uuid_before, + const bool wait) -> result { + // send to resident enabled datasource plugins + auto actors = std::vector(); + + for (const auto &i : manager_.factories()) { + if (i.second.factory()->type() & PluginFlags::PF_DATA_SOURCE and + resident_.count(i.first)) + actors.push_back(resident_[i.first]); + } + + if (actors.empty()) + return UuidActor(); + + auto rp = make_response_promise(); + + fan_out_request( + actors, + infinite, + data_source::use_data_atom_v, + uri, + playlist_actor, + media_rate, + uuid_before, + wait) + .then( + [=](const std::vector results) mutable { + for (const auto &i : results) { + if (i) + return rp.deliver(i); + } + rp.deliver(UuidActor()); + }, + [=](error &err) mutable { rp.deliver(std::move(err)); }); + + return rp; + }, + // helper for dealing with Media sources back population's [=](data_source::use_data_atom, const caf::actor &media,