diff --git a/src/core/producer/layer.cpp b/src/core/producer/layer.cpp index 893bd27802..5cf3024622 100644 --- a/src/core/producer/layer.cpp +++ b/src/core/producer/layer.cpp @@ -45,17 +45,23 @@ struct layer::impl void resume() { paused_ = false; } - void load(spl::shared_ptr producer, bool preview, bool auto_play) + void load(spl::shared_ptr producer, bool preview_producer, bool auto_play) { background_ = std::move(producer); auto_play_ = auto_play; if (auto_play_ && foreground_ == frame_producer::empty()) { play(); - } else if (preview) { - foreground_ = std::move(background_); - background_ = frame_producer::empty(); - paused_ = true; + } else if (preview_producer) { + preview(true); + } + } + + void preview(bool force) + { + if (force || background_ != frame_producer::empty()) { + play(); + paused_ = true; } } @@ -160,6 +166,7 @@ void layer::load(spl::shared_ptr frame_producer, bool preview, b return impl_->load(std::move(frame_producer), preview, auto_play); } void layer::play() { impl_->play(); } +void layer::preview() { impl_->preview(false); } void layer::pause() { impl_->pause(); } void layer::resume() { impl_->resume(); } void layer::stop() { impl_->stop(); } diff --git a/src/core/producer/layer.h b/src/core/producer/layer.h index 688e50fa8f..cda49ff4c9 100644 --- a/src/core/producer/layer.h +++ b/src/core/producer/layer.h @@ -45,6 +45,7 @@ class layer final void load(spl::shared_ptr producer, bool preview, bool auto_play = false); void play(); + void preview(); void pause(); void resume(); void stop(); diff --git a/src/core/producer/stage.cpp b/src/core/producer/stage.cpp index edbacb9f67..18110e509e 100644 --- a/src/core/producer/stage.cpp +++ b/src/core/producer/stage.cpp @@ -230,6 +230,11 @@ struct stage::impl : public std::enable_shared_from_this { return executor_.begin_invoke([=] { get_layer(index).load(producer, preview, auto_play); }); } + + std::future preview(int index) + { + return executor_.begin_invoke([=] { get_layer(index).preview(); }); + } std::future pause(int index) { @@ -369,6 +374,7 @@ std::future stage::load(int index, const spl::shared_ptr& { return impl_->load(index, producer, preview, auto_play); } +std::future stage::preview(int index) { return impl_->preview(index); } std::future stage::pause(int index) { return impl_->pause(index); } std::future stage::resume(int index) { return impl_->resume(index); } std::future stage::play(int index) { return impl_->play(index); } diff --git a/src/core/producer/stage.h b/src/core/producer/stage.h index 0aaca31e03..b8d276d816 100644 --- a/src/core/producer/stage.h +++ b/src/core/producer/stage.h @@ -71,6 +71,7 @@ class stage final std::future get_current_transform(int index); std::future load(int index, const spl::shared_ptr& producer, bool preview = false, bool auto_play = false); + std::future preview(int index); std::future pause(int index); std::future resume(int index); std::future play(int index); diff --git a/src/protocol/amcp/AMCPCommandsImpl.cpp b/src/protocol/amcp/AMCPCommandsImpl.cpp index e87653bfa5..ee244fbc6c 100644 --- a/src/protocol/amcp/AMCPCommandsImpl.cpp +++ b/src/protocol/amcp/AMCPCommandsImpl.cpp @@ -267,18 +267,23 @@ std::wstring load_command(command_context& ctx) core::diagnostics::call_context::for_thread().video_channel = ctx.channel_index + 1; core::diagnostics::call_context::for_thread().layer = ctx.layer_index(); - try { - auto pFP = - ctx.producer_registry->create_producer(get_producer_dependencies(ctx.channel.channel, ctx), ctx.parameters); - auto pFP2 = create_transition_producer(pFP, transition_info{}); - - ctx.channel.channel->stage().load(ctx.layer_index(), pFP2, true); - } catch (file_not_found&) { - if (contains_param(L"CLEAR_ON_404", ctx.parameters)) { - ctx.channel.channel->stage().load( - ctx.layer_index(), core::create_color_producer(ctx.channel.channel->frame_factory(), 0), true); + if (ctx.parameters.empty()) { + // Must be a promoting load + ctx.channel.channel->stage().preview(ctx.layer_index()); + } else { + try { + auto pFP = ctx.producer_registry->create_producer(get_producer_dependencies(ctx.channel.channel, ctx), + ctx.parameters); + auto pFP2 = create_transition_producer(pFP, transition_info{}); + + ctx.channel.channel->stage().load(ctx.layer_index(), pFP2, true); + } catch (file_not_found&) { + if (contains_param(L"CLEAR_ON_404", ctx.parameters)) { + ctx.channel.channel->stage().load( + ctx.layer_index(), core::create_color_producer(ctx.channel.channel->frame_factory(), 0), true); + } + throw; } - throw; } return L"202 LOAD OK\r\n"; @@ -1520,7 +1525,7 @@ std::wstring gl_gc_command(command_context& ctx) void register_commands(amcp_command_repository& repo) { repo.register_channel_command(L"Basic Commands", L"LOADBG", loadbg_command, 1); - repo.register_channel_command(L"Basic Commands", L"LOAD", load_command, 1); + repo.register_channel_command(L"Basic Commands", L"LOAD", load_command, 0); repo.register_channel_command(L"Basic Commands", L"PLAY", play_command, 0); repo.register_channel_command(L"Basic Commands", L"PAUSE", pause_command, 0); repo.register_channel_command(L"Basic Commands", L"RESUME", resume_command, 0);