return L"202 CG OK\r\n";
}
+spl::shared_ptr<core::cg_proxy> get_expected_cg_proxy(command_context& ctx)
+{
+ auto proxy = ctx.cg_registry->get_proxy(spl::make_shared_ptr(ctx.channel.channel), ctx.layer_index(core::cg_proxy::DEFAULT_LAYER));
+
+ if (proxy == cg_proxy::empty())
+ CASPAR_THROW_EXCEPTION(file_not_found() << msg_info(L"No CG proxy running on layer"));
+
+ return proxy;
+}
+
void cg_stop_describer(core::help_sink& sink, const core::help_repository& repo)
{
sink.short_description(L"Stop and remove a template.");
std::wstring cg_stop_command(command_context& ctx)
{
int layer = get_and_validate_layer(ctx.parameters.at(0));
- ctx.cg_registry->get_proxy(spl::make_shared_ptr(ctx.channel.channel), ctx.layer_index(core::cg_proxy::DEFAULT_LAYER))->stop(layer, 0);
+ get_expected_cg_proxy(ctx)->stop(layer, 0);
return L"202 CG OK\r\n";
}
std::wstring cg_next_command(command_context& ctx)
{
int layer = get_and_validate_layer(ctx.parameters.at(0));
- ctx.cg_registry->get_proxy(spl::make_shared_ptr(ctx.channel.channel), ctx.layer_index(core::cg_proxy::DEFAULT_LAYER))->next(layer);
+ get_expected_cg_proxy(ctx)->next(layer);
return L"202 CG OK\r\n";
}
std::wstring cg_remove_command(command_context& ctx)
{
int layer = get_and_validate_layer(ctx.parameters.at(0));
- ctx.cg_registry->get_proxy(spl::make_shared_ptr(ctx.channel.channel), ctx.layer_index(core::cg_proxy::DEFAULT_LAYER))->remove(layer);
+ get_expected_cg_proxy(ctx)->remove(layer);
return L"202 CG OK\r\n";
}
dataString = read_file(boost::filesystem::path(filename));
}
- ctx.cg_registry->get_proxy(
- spl::make_shared_ptr(ctx.channel.channel),
- ctx.layer_index(core::cg_proxy::DEFAULT_LAYER))
- ->update(layer, dataString);
+ get_expected_cg_proxy(ctx)->update(layer, dataString);
return L"202 CG OK\r\n";
}
std::wstringstream replyString;
replyString << L"201 CG OK\r\n";
int layer = get_and_validate_layer(ctx.parameters.at(0));
- auto result = ctx.cg_registry->get_proxy(
- spl::make_shared_ptr(ctx.channel.channel),
- ctx.layer_index(core::cg_proxy::DEFAULT_LAYER))
- ->invoke(layer, ctx.parameters.at(1));
+ auto result = get_expected_cg_proxy(ctx)->invoke(layer, ctx.parameters.at(1));
replyString << result << L"\r\n";
return replyString.str();
if (ctx.parameters.empty())
{
- auto info = ctx.cg_registry->get_proxy(
- spl::make_shared_ptr(ctx.channel.channel),
- ctx.layer_index(core::cg_proxy::DEFAULT_LAYER))
- ->template_host_info();
+ auto info = get_expected_cg_proxy(ctx)->template_host_info();
replyString << info << L"\r\n";
}
else
{
int layer = get_and_validate_layer(ctx.parameters.at(0));
- auto desc = ctx.cg_registry->get_proxy(
- spl::make_shared_ptr(ctx.channel.channel),
- ctx.layer_index(core::cg_proxy::DEFAULT_LAYER))
- ->description(layer);
+ auto desc = get_expected_cg_proxy(ctx)->description(layer);
replyString << desc << L"\r\n";
}
void commit_deferred()
{
- ctx_.channel.channel->stage().apply_transforms(
- std::move(deferred_transforms_[ctx_.channel_index]));
+ auto& transforms = deferred_transforms_[ctx_.channel_index];
+ ctx_.channel.channel->stage().apply_transforms(transforms).get();
+ transforms.clear();
}
void apply()
auto path = itr->path();
auto file = path.replace_extension(L"").filename().wstring();
if (boost::iequals(file, ctx.parameters.at(0)))
- info += MediaInfo(itr->path(), ctx.media_info_repo) + L"\r\n";
+ info += MediaInfo(itr->path(), ctx.media_info_repo);
}
if (info.empty())
for (auto& thread : get_thread_infos())
{
- replyString << thread->native_id << L"\t" << u16(thread->name) << L"\r\n";
+ replyString << thread->native_id << L" " << u16(thread->name) << L"\r\n";
}
replyString << L"\r\n";
return replyString.str();
}
+void info_delay_describer(core::help_sink& sink, const core::help_repository& repo)
+{
+ sink.short_description(L"Get the current delay on a channel or a layer.");
+ sink.syntax(L"INFO [video_channel:int]{-[layer:int]} DELAY");
+ sink.para()->text(L"Get the current delay on the specified channel or layer.");
+}
+
+std::wstring info_delay_command(command_context& ctx)
+{
+ boost::property_tree::wptree info;
+ auto layer = ctx.layer_index(std::numeric_limits<int>::min());
+
+ if (layer == std::numeric_limits<int>::min())
+ info.add_child(L"channel-delay", ctx.channel.channel->delay_info());
+ else
+ info.add_child(L"layer-delay", ctx.channel.channel->stage().delay_info(layer).get())
+ .add(L"index", layer);
+
+ return create_info_xml_reply(info, L"DELAY");
+}
+
void diag_describer(core::help_sink& sink, const core::help_repository& repo)
{
sink.short_description(L"Open the diagnostics window.");
repo.register_command( L"Query Commands", L"INFO SERVER", info_server_describer, info_server_command, 0);
repo.register_command( L"Query Commands", L"INFO QUEUES", info_queues_describer, info_queues_command, 0);
repo.register_command( L"Query Commands", L"INFO THREADS", info_threads_describer, info_threads_command, 0);
+ repo.register_channel_command( L"Query Commands", L"INFO DELAY", info_delay_describer, info_delay_command, 0);
repo.register_command( L"Query Commands", L"DIAG", diag_describer, diag_command, 0);
repo.register_command( L"Query Commands", L"BYE", bye_describer, bye_command, 0);
repo.register_command( L"Query Commands", L"KILL", kill_describer, kill_command, 0);