Skip to content

Commit

Permalink
feat: LOAD command without parameters will put the background clip in…
Browse files Browse the repository at this point in the history
…to the 'preview' state (same as doing a LOAD of it to begin with)
  • Loading branch information
Julusian committed Aug 20, 2020
1 parent f1a55f7 commit 3e29a65
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 17 deletions.
17 changes: 12 additions & 5 deletions src/core/producer/layer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,17 +45,23 @@ struct layer::impl

void resume() { paused_ = false; }

void load(spl::shared_ptr<frame_producer> producer, bool preview, bool auto_play)
void load(spl::shared_ptr<frame_producer> 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;
}
}

Expand Down Expand Up @@ -160,6 +166,7 @@ void layer::load(spl::shared_ptr<frame_producer> 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(); }
Expand Down
1 change: 1 addition & 0 deletions src/core/producer/layer.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ class layer final

void load(spl::shared_ptr<frame_producer> producer, bool preview, bool auto_play = false);
void play();
void preview();
void pause();
void resume();
void stop();
Expand Down
6 changes: 6 additions & 0 deletions src/core/producer/stage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,11 @@ struct stage::impl : public std::enable_shared_from_this<impl>
{
return executor_.begin_invoke([=] { get_layer(index).load(producer, preview, auto_play); });
}

std::future<void> preview(int index)
{
return executor_.begin_invoke([=] { get_layer(index).preview(); });
}

std::future<void> pause(int index)
{
Expand Down Expand Up @@ -369,6 +374,7 @@ std::future<void> stage::load(int index, const spl::shared_ptr<frame_producer>&
{
return impl_->load(index, producer, preview, auto_play);
}
std::future<void> stage::preview(int index) { return impl_->preview(index); }
std::future<void> stage::pause(int index) { return impl_->pause(index); }
std::future<void> stage::resume(int index) { return impl_->resume(index); }
std::future<void> stage::play(int index) { return impl_->play(index); }
Expand Down
1 change: 1 addition & 0 deletions src/core/producer/stage.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ class stage final
std::future<frame_transform> get_current_transform(int index);
std::future<void>
load(int index, const spl::shared_ptr<frame_producer>& producer, bool preview = false, bool auto_play = false);
std::future<void> preview(int index);
std::future<void> pause(int index);
std::future<void> resume(int index);
std::future<void> play(int index);
Expand Down
29 changes: 17 additions & 12 deletions src/protocol/amcp/AMCPCommandsImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 3e29a65

Please sign in to comment.