]> git.sesse.net Git - casparcg/blobdiff - core/producer/scene/scene_producer.h
[scene_producer] Added possibility to CALL/CG PLAY/CG STOP/CG NEXT/CG INVOKE layers...
[casparcg] / core / producer / scene / scene_producer.h
index 5e8f27b057d7a86905a91ff2d11e206c5e9f2265..a7c37710c31e7d7a1674cdfadccf0f4b2e8352a8 100644 (file)
 #include <common/log.h>
 
 #include "../frame_producer.h"
+#include "../../fwd.h"
 
 #include "../binding.h"
 #include "../variable.h"
 
-namespace caspar { namespace core {
-
-class frame_factory;
-
-namespace scene {
+namespace caspar { namespace core { namespace scene {
 
 struct coord
 {
@@ -43,8 +40,15 @@ struct coord
 struct rect
 {
        coord upper_left;
-       binding<double> width;
-       binding<double> height;
+       coord lower_right;
+};
+
+struct corners
+{
+       coord upper_left;
+       coord upper_right;
+       coord lower_right;
+       coord lower_left;
 };
 
 struct adjustments
@@ -54,25 +58,43 @@ struct adjustments
        adjustments();
 };
 
+struct chroma_key
+{
+       binding<bool>                           enable;
+       binding<double>                         target_hue;
+       binding<double>                         hue_width;
+       binding<double>                         min_saturation;
+       binding<double>                         min_brightness;
+       binding<double>                         softness;
+       binding<double>                         spill;
+       binding<double>                         spill_darken;
+};
+
 struct layer
 {
-       binding<std::wstring> name;
-       coord position;
-       rect clipping;
-       adjustments adjustments;
-       binding<spl::shared_ptr<frame_producer>> producer;
-       binding<bool> hidden;
-       binding<bool> is_key;
+       binding<std::wstring>                                           name;
+       scene::coord                                                            anchor;
+       scene::coord                                                            position;
+       scene::rect                                                                     crop;
+       scene::corners                                                          perspective;
+       binding<double>                                                         rotation;
+       scene::adjustments                                                      adjustments;
+       binding<spl::shared_ptr<frame_producer>>        producer;
+       binding<bool>                                                           hidden;
+       binding<bool>                                                           is_key;
+       binding<bool>                                                           use_mipmap;
+       binding<core::blend_mode>                                       blend_mode;
+       scene::chroma_key                                                       chroma_key;
 
        explicit layer(const std::wstring& name, const spl::shared_ptr<frame_producer>& producer);
 };
 
 struct keyframe
 {
-       std::function<void ()> on_start_animate;
-       std::function<void (int64_t start_frame, int64_t current_frame)> on_animate_to;
-       std::function<void ()> on_destination_frame;
-       int64_t destination_frame;
+       std::function<void ()>                                                                                          on_start_animate;
+       std::function<void (int64_t start_frame, int64_t current_frame)>        on_animate_to;
+       std::function<void ()>                                                                                          on_destination_frame;
+       int64_t                                                                                                                         destination_frame;
 public:
        keyframe(int64_t destination_frame)
                : destination_frame(destination_frame)
@@ -80,27 +102,40 @@ public:
        }
 };
 
+enum class mark_action
+{
+       start,
+       stop,
+       jump_to,
+       remove
+};
+
+mark_action get_mark_action(const std::wstring& name);
+
 class scene_producer : public frame_producer_base
 {
 public:
-       scene_producer(int width, int height);
+       scene_producer(std::wstring producer_name, std::wstring template_name, int width, int height, const video_format_desc& format_desc);
        ~scene_producer();
 
-       class draw_frame receive_impl() override;
+       draw_frame receive_impl() override;
        constraints& pixel_constraints() override;
        void on_interaction(const interaction_event::ptr& event) override;
        bool collides(double x, double y) const override;
        std::wstring print() const override;
        std::wstring name() const override;
-       boost::unique_future<std::wstring>      call(const std::vector<std::wstring>& params) override;
+       std::future<std::wstring> call(const std::vector<std::wstring>& params) override;
        boost::property_tree::wptree info() const override;
-       void subscribe(const monitor::observable::observer_ptr& o) override;
-       void unsubscribe(const monitor::observable::observer_ptr& o) override;
+       monitor::subject& monitor_output();
+
        layer& create_layer(
                        const spl::shared_ptr<frame_producer>& producer, int x, int y, const std::wstring& name);
        layer& create_layer(
                        const spl::shared_ptr<frame_producer>& producer, const std::wstring& name);
-       binding<int64_t> frame();
+       void reverse_layers();
+       layer& get_layer(const std::wstring& name);
+
+       binding<int64_t> timeline_frame();
        binding<double> speed();
 
        template<typename T> binding<T>& create_variable(
@@ -165,7 +200,7 @@ public:
                                                        static_cast<double>(duration)));
 
                                        to_affect.set(tweened);
-                                       
+
                                        //CASPAR_LOG(info) << relative_frame << L" " << *start_value << L" " << duration << L" " << tweened;
                                };
 
@@ -191,6 +226,9 @@ public:
                store_keyframe(to_affect.identity(), k);
        }
 
+       void add_mark(int64_t at_frame, mark_action action, const std::wstring& label);
+       void add_task(binding<bool> when, std::function<void ()> task);
+
        core::variable& get_variable(const std::wstring& name) override;
        const std::vector<std::wstring>& get_variables() const override;
 private:
@@ -202,6 +240,4 @@ private:
        std::unique_ptr<impl> impl_;
 };
 
-spl::shared_ptr<frame_producer> create_dummy_scene_producer(const spl::shared_ptr<frame_factory>& frame_factory, const video_format_desc& format_desc, const std::vector<std::wstring>& params);
-
 }}}