@@ -38,8 +38,32 @@ class video_node final : public gfx_exec_node
3838 exec_context->ui ->unregister_node (id);
3939 }
4040
41+ void run (const ossia::token_request& tk, ossia::exec_state_facade e) noexcept override
42+ {
43+ // Consume the new value for the path input port if any
44+ auto & vp = this ->m_inlets [0 ]->target <ossia::value_port>()->get_data ();
45+ if (!vp.empty ())
46+ {
47+ auto & last = *vp.back ().value .target <std::string>();
48+ if (last != m_currentPath)
49+ {
50+ m_currentPath = last;
51+
52+ auto dec = Gfx::Video::makeDecoder (last);
53+ if (dec)
54+ {
55+ reload (dec, m_currentTempo);
56+ }
57+ vp.clear ();
58+ }
59+ }
60+
61+ gfx_exec_node::run (tk, e);
62+ }
63+
4164 void reload (const std::shared_ptr<video_decoder>& dec, std::optional<double > tempo)
4265 {
66+ m_currentTempo = tempo;
4367 impl = nullptr ;
4468
4569 if (id >= 0 )
@@ -70,8 +94,9 @@ class video_node final : public gfx_exec_node
7094
7195 score::gfx::VideoNode* impl{};
7296
73- private:
97+ std::string m_currentPath;
7498 std::shared_ptr<video_decoder> m_decoder;
99+ std::optional<double > m_currentTempo;
75100};
76101
77102class video_process final : public ossia::node_process
@@ -124,7 +149,7 @@ ProcessExecutorComponent::ProcessExecutorComponent(
124149 Gfx::Video::Model& element, const Execution::Context& ctx, QObject* parent)
125150 : ProcessComponent_T{element, ctx, " VideoExecutorComponent" , parent}
126151{
127- auto dec = element.makeDecoder ( );
152+ auto dec = makeDecoder ( element.absolutePath (). toStdString () );
128153 if (!dec)
129154 dec = std::make_shared<Video::video_decoder>(::Video::DecoderConfiguration{});
130155
@@ -134,6 +159,20 @@ ProcessExecutorComponent::ProcessExecutorComponent(
134159 auto n = ossia::make_node<video_node>(
135160 *ctx.execState , std::move (dec), tempo, ctx.doc .plugin <DocumentPlugin>().exec );
136161
162+ auto port = n->add_value_port ();
163+ /*
164+ for(std::size_t i = 0; i < 1; i++)
165+ {
166+ auto ctrl = qobject_cast<Process::ControlInlet*>(element.inlets()[i]);
167+ SCORE_ASSERT(ctrl);
168+ auto& p = n->add_control();
169+ p->value = ctrl->value();
170+
171+ QObject::connect(
172+ ctrl, &Process::ControlInlet::valueChanged, this, con_unvalidated{ctx, i, 0, n});
173+ }
174+ */
175+
137176 for (auto * outlet : element.outlets ())
138177 {
139178 if (auto out = qobject_cast<Gfx::TextureOutlet*>(outlet))
@@ -154,20 +193,22 @@ ProcessExecutorComponent::ProcessExecutorComponent(
154193 vn->impl ->setScaleMode (m);
155194 }
156195 });
157-
196+ /*
158197 con(element, &Gfx::Video::Model::pathChanged, this, [this](const QString& new_path) {
159198 std::optional<double> tempo;
160199 if(!this->process().ignoreTempo())
161200 tempo = this->process().nativeTempo();
162201
163- in_exec ([node = std::weak_ptr{node}, dec = this ->process ().makeDecoder (),
202+ in_exec([node = std::weak_ptr{node},
203+ dec = Gfx::Video::makeDecoder(this->process().absolutePath().toStdString()),
164204 tempo]() mutable {
165205 if(auto vn = static_cast<video_node*>(node.lock().get()); vn && vn->impl)
166206 {
167207 vn->reload(std::move(dec), tempo);
168208 }
169209 });
170210 });
211+ */
171212}
172213
173214void ProcessExecutorComponent::cleanup ()
0 commit comments