]> git.sesse.net Git - casparcg/commitdiff
[image_producer] Added LENGTH parameter to allow for queueing with LOADBG AUTO.
authorHelge Norberg <helge.norberg@svt.se>
Thu, 26 Jan 2017 16:27:31 +0000 (17:27 +0100)
committerHelge Norberg <helge.norberg@svt.se>
Thu, 26 Jan 2017 16:27:31 +0000 (17:27 +0100)
CHANGELOG
modules/image/producer/image_producer.cpp

index a70c84c84a8cf1d99b53f46330024ae5bd8e0008..b62b3394eeadd2ceb7a2b578a47e37d58d3b6d70 100644 (file)
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -48,6 +48,8 @@ Producers
     + Fixed bug when INFO was used on a not yet playing framerate producer.\r
   o HTML producer:\r
     + Fixed bug where only URL:s with . in them where recognized.\r
+  o Image producer:\r
+    + Added LENGTH parameter to allow for queueing with LOADBG AUTO.\r
 \r
 Mixer\r
 -----\r
index 112922ac5f68fe450de2feec264398800f94066f..b1857407b9b726f47ea7e6544224468277ba546d 100644 (file)
@@ -40,6 +40,7 @@
 #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>
@@ -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<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_));
 
@@ -94,9 +97,10 @@ struct image_producer : public core::frame_producer_base
                        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));
 
@@ -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<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]"))
        {
@@ -258,7 +276,7 @@ spl::shared_ptr<core::frame_producer> 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<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);
@@ -273,7 +291,7 @@ spl::shared_ptr<core::frame_producer> create_producer(const core::frame_producer
        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);
 }
 
 
@@ -294,7 +312,8 @@ core::draw_frame create_thumbnail(const core::frame_producer_dependencies& depen
        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();
 }