From 4d9e9534d16443deeafc51fe032e2e1161500def Mon Sep 17 00:00:00 2001 From: Helge Norberg Date: Thu, 26 Jan 2017 17:27:31 +0100 Subject: [PATCH] [image_producer] Added LENGTH parameter to allow for queueing with LOADBG AUTO. --- CHANGELOG | 2 ++ modules/image/producer/image_producer.cpp | 31 ++++++++++++++++++----- 2 files changed, 27 insertions(+), 6 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index a70c84c84..b62b3394e 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -48,6 +48,8 @@ Producers + Fixed bug when INFO was used on a not yet playing framerate producer. o HTML producer: + Fixed bug where only URL:s with . in them where recognized. + o Image producer: + + Added LENGTH parameter to allow for queueing with LOADBG AUTO. Mixer ----- diff --git a/modules/image/producer/image_producer.cpp b/modules/image/producer/image_producer.cpp index 112922ac5..b1857407b 100644 --- a/modules/image/producer/image_producer.cpp +++ b/modules/image/producer/image_producer.cpp @@ -40,6 +40,7 @@ #include #include #include +#include #include #include @@ -79,12 +80,14 @@ struct image_producer : public core::frame_producer_base core::monitor::subject monitor_subject_; const std::wstring description_; const spl::shared_ptr frame_factory_; + const uint32_t length_; core::draw_frame frame_ = core::draw_frame::empty(); core::constraints constraints_; - image_producer(const spl::shared_ptr& frame_factory, const std::wstring& description, bool thumbnail_mode) + image_producer(const spl::shared_ptr& frame_factory, const std::wstring& description, bool thumbnail_mode, uint32_t length) : description_(description) , frame_factory_(frame_factory) + , length_(length) { load(load_image(description_)); @@ -94,9 +97,10 @@ struct image_producer : public core::frame_producer_base CASPAR_LOG(info) << print() << L" Initialized"; } - image_producer(const spl::shared_ptr& frame_factory, const void* png_data, size_t size) + image_producer(const spl::shared_ptr& 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)); @@ -131,6 +135,11 @@ struct image_producer : public core::frame_producer_base return frame_; } + uint32_t nb_frames() const override + { + return length_; + } + core::constraints& pixel_constraints() override { return constraints_; @@ -178,11 +187,19 @@ public: 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 = { @@ -202,6 +219,7 @@ static const auto g_extensions = { spl::shared_ptr create_producer(const core::frame_producer_dependencies& dependencies, const std::vector& params) { + auto length = get_param(L"LENGTH", params, std::numeric_limits::max()); if (boost::iequals(params.at(0), L"[IMG_SEQUENCE]")) { @@ -258,7 +276,7 @@ spl::shared_ptr create_producer(const core::frame_producer auto png_data = from_base64(std::string(params.at(1).begin(), params.at(1).end())); - return spl::make_shared(dependencies.frame_factory, png_data.data(), png_data.size()); + return spl::make_shared(dependencies.frame_factory, png_data.data(), png_data.size(), length); } std::wstring filename = env::media_folder() + params.at(0); @@ -273,7 +291,7 @@ spl::shared_ptr create_producer(const core::frame_producer if(ext == g_extensions.end()) return core::frame_producer::empty(); - return spl::make_shared(dependencies.frame_factory, *caspar::find_case_insensitive(filename + *ext), false); + return spl::make_shared(dependencies.frame_factory, *caspar::find_case_insensitive(filename + *ext), false, length); } @@ -294,7 +312,8 @@ core::draw_frame create_thumbnail(const core::frame_producer_dependencies& depen spl::shared_ptr producer = spl::make_shared( dependencies.frame_factory, *caspar::find_case_insensitive(filename + *ext), - true); + true, + 1); return producer->receive(); } -- 2.39.2