]> git.sesse.net Git - casparcg/blobdiff - modules/image/consumer/image_consumer.cpp
Created a consumer that provides sync to a channel based on the pace of another chann...
[casparcg] / modules / image / consumer / image_consumer.cpp
index bfc18c524c80bd4db40adf0b69eba2a88d4001ad..4730402d7566fae1dba51a455bcf176811e4ff5a 100644 (file)
@@ -27,6 +27,7 @@
 #include <common/utf.h>
 #include <common/array.h>
 #include <common/future.h>
+#include <common/os/general_protection_fault.h>
 
 #include <core/consumer/frame_consumer.h>
 #include <core/video_format.h>
@@ -65,7 +66,11 @@ void write_cropped_png(
 
        std::copy(thumbnail_view.begin(), thumbnail_view.end(), destination_view.begin());
        FreeImage_FlipVertical(bitmap.get());
+#ifdef WIN32
        FreeImage_SaveU(FIF_PNG, bitmap.get(), output_file.wstring().c_str(), 0);
+#else
+       FreeImage_Save(FIF_PNG, bitmap.get(), u8(output_file.wstring()).c_str(), 0);
+#endif
 }
 
 struct image_consumer : public core::frame_consumer
@@ -81,20 +86,27 @@ public:
        {
        }
 
-       void initialize(const core::video_format_desc&, int) override
+       void initialize(const core::video_format_desc&, const core::audio_channel_layout&, int) override
+       {
+       }
+
+       int64_t presentation_frame_age_millis() const override
        {
+               return 0;
        }
-       
+
        std::future<bool> send(core::const_frame frame) override
        {
                auto filename = filename_;
 
                boost::thread async([frame, filename]
                {
+                       ensure_gpf_handler_installed_for_thread("image-consumer");
+
                        try
                        {
                                auto filename2 = filename;
-                               
+
                                if (filename2.empty())
                                        filename2 = env::media_folder() +  boost::posix_time::to_iso_wstring(boost::posix_time::second_clock::local_time()) + L".png";
                                else
@@ -123,7 +135,7 @@ public:
        {
                return L"image[]";
        }
-       
+
        std::wstring name() const override
        {
                return L"image";
@@ -164,7 +176,8 @@ void describe_consumer(core::help_sink& sink, const core::help_repository& repo)
        sink.example(L">> ADD 1 IMAGE", L"creating media/20130228T210946.png if the current time is 2013-02-28 21:09:46.");
 }
 
-spl::shared_ptr<core::frame_consumer> create_consumer(const std::vector<std::wstring>& params, core::interaction_sink*)
+spl::shared_ptr<core::frame_consumer> create_consumer(
+               const std::vector<std::wstring>& params, core::interaction_sink*, std::vector<spl::shared_ptr<core::video_channel>> channels)
 {
        if (params.size() < 1 || !boost::iequals(params.at(0), L"IMAGE"))
                return core::frame_consumer::empty();