X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=image_input.h;fp=image_input.h;h=fbda72de6c36ddf69f660db77b78024afb5fc8cb;hb=cfa98a26d7b16b97a406c82930a1fc61a119183f;hp=3fad845ea83351a43271fc1d357b4a7d7f162356;hpb=9048c4b2d5758b3384232aaa1c28f33631633fa5;p=nageru diff --git a/image_input.h b/image_input.h index 3fad845..fbda72d 100644 --- a/image_input.h +++ b/image_input.h @@ -3,21 +3,39 @@ #include #include +#include #include +#include + +#include #include // An output that takes its input from a static image, loaded with ffmpeg. -// comes from a single 2D array with chunky pixels. +// comes from a single 2D array with chunky pixels. The image is refreshed +// from disk about every second. class ImageInput : public movit::FlatInput { public: ImageInput(const std::string &filename); std::string effect_type_id() const override { return "ImageInput"; } + void set_gl_state(GLuint glsl_program_num, const std::string& prefix, unsigned *sampler_num) override; private: - static const uint8_t *load_image(const std::string &filename); - static std::map> all_images; + struct Image { + std::unique_ptr pixels; + timespec last_modified; + }; + + std::string filename; + std::shared_ptr current_image; + + static std::shared_ptr load_image(const std::string &filename); + static std::shared_ptr load_image_raw(const std::string &filename); + static void update_thread_func(const std::string &filename, const timespec &first_modified); + static std::mutex all_images_lock; + static std::map> all_images; + static std::map update_threads; }; #endif // !defined(_IMAGE_INPUT_H)