#include <common/log.h>
#include <common/array.h>
#include <common/base64.h>
+#include <common/param.h>
#include <common/os/filesystem.h>
#include <boost/filesystem.hpp>
core::monitor::subject monitor_subject_;
const std::wstring description_;
const spl::shared_ptr<core::frame_factory> frame_factory_;
+ const uint32_t length_;
core::draw_frame frame_ = core::draw_frame::empty();
core::constraints constraints_;
- image_producer(const spl::shared_ptr<core::frame_factory>& frame_factory, const std::wstring& description, bool thumbnail_mode)
+ image_producer(const spl::shared_ptr<core::frame_factory>& frame_factory, const std::wstring& description, bool thumbnail_mode, uint32_t length)
: description_(description)
, frame_factory_(frame_factory)
+ , length_(length)
{
load(load_image(description_));
CASPAR_LOG(info) << print() << L" Initialized";
}
- image_producer(const spl::shared_ptr<core::frame_factory>& frame_factory, const void* png_data, size_t size)
+ image_producer(const spl::shared_ptr<core::frame_factory>& frame_factory, const void* png_data, size_t size, uint32_t length)
: description_(L"png from memory")
, frame_factory_(frame_factory)
+ , length_(length)
{
load(load_png_from_memory(png_data, size));
return frame_;
}
+ uint32_t nb_frames() const override
+ {
+ return length_;
+ }
+
core::constraints& pixel_constraints() override
{
return constraints_;
void describe_producer(core::help_sink& sink, const core::help_repository& repo)
{
sink.short_description(L"Loads a still image.");
- sink.syntax(L"{[image_file:string]},{[PNG_BASE64] [encoded:string]}");
+ sink.syntax(L"{[image_file:string]},{[PNG_BASE64] [encoded:string]} {LENGTH [length:int]}");
sink.para()->text(L"Loads a still image, either from disk or via a base64 encoded image submitted via AMCP.");
+ sink.para()->text(L"The ")->code(L"length")->text(L" parameter can be used to limit the number of frames that the image will be shown for.");
sink.para()->text(L"Examples:");
sink.example(L">> PLAY 1-10 image_file", L"Plays an image from the media folder.");
sink.example(L">> PLAY 1-10 [PNG_BASE64] data...", L"Plays a PNG image transferred as a base64 encoded string.");
+ sink.example(
+ L">> PLAY 1-10 slide_show1 LENGTH 100\n"
+ L">> LOADBG 1-10 slide_show2 LENGTH 100 MIX 20 AUTO\n"
+ L"delay until foreground layer becomes slide_show2 and then\n"
+ L">> LOADBG 1-10 slide_show3 LENGTH 100 MIX 20 AUTO\n"
+ L"delay until foreground layer becomes slide_show3 and then\n"
+ L">> LOADBG 1-10 EMPTY MIX 20 AUTO\n", L"Plays a slide show of 3 images for 100 frames each and fades to black.");
}
static const auto g_extensions = {
spl::shared_ptr<core::frame_producer> create_producer(const core::frame_producer_dependencies& dependencies, const std::vector<std::wstring>& params)
{
+ auto length = get_param(L"LENGTH", params, std::numeric_limits<uint32_t>::max());
if (boost::iequals(params.at(0), L"[IMG_SEQUENCE]"))
{
auto png_data = from_base64(std::string(params.at(1).begin(), params.at(1).end()));
- return spl::make_shared<image_producer>(dependencies.frame_factory, png_data.data(), png_data.size());
+ return spl::make_shared<image_producer>(dependencies.frame_factory, png_data.data(), png_data.size(), length);
}
std::wstring filename = env::media_folder() + params.at(0);
if(ext == g_extensions.end())
return core::frame_producer::empty();
- return spl::make_shared<image_producer>(dependencies.frame_factory, *caspar::find_case_insensitive(filename + *ext), false);
+ return spl::make_shared<image_producer>(dependencies.frame_factory, *caspar::find_case_insensitive(filename + *ext), false, length);
}
spl::shared_ptr<core::frame_producer> producer = spl::make_shared<image_producer>(
dependencies.frame_factory,
*caspar::find_case_insensitive(filename + *ext),
- true);
+ true,
+ 1);
return producer->receive();
}