]> git.sesse.net Git - casparcg/blobdiff - core/producer/stage.cpp
git-svn-id: https://casparcg.svn.sourceforge.net/svnroot/casparcg/server/branches...
[casparcg] / core / producer / stage.cpp
index 7b410513676179d566e1ae3ef18776333e168de8..517036f7947d9fb1c9e2eb5d7ab338ba74539949 100644 (file)
@@ -29,6 +29,7 @@
 #include "../frame/frame_factory.h"\r
 \r
 #include <common/executor.h>\r
+#include <common/future.h>\r
 #include <common/diagnostics/graph.h>\r
 \r
 #include <core/frame/frame_transform.h>\r
@@ -100,27 +101,15 @@ public:
        {\r
                auto& layer             = layers_[index];\r
                auto& tween             = tweens_[index];\r
-               auto transform  = tween.fetch_and_tick(1);\r
-\r
-               frame_producer::flags flags = frame_producer::flags::none;\r
-               if(format_desc.field_mode != field_mode::progressive)\r
-               {\r
-                       flags |= std::abs(transform.image_transform.fill_scale[1]  - 1.0) > 0.0001 ? frame_producer::flags::deinterlace : frame_producer::flags::none;\r
-                       flags |= std::abs(transform.image_transform.fill_translation[1])  > 0.0001 ? frame_producer::flags::deinterlace : frame_producer::flags::none;\r
-               }\r
-\r
-               if(transform.image_transform.is_key)\r
-                       flags |= frame_producer::flags::alpha_only;\r
-               \r
-               auto frame = layer.receive(flags, format_desc); \r
                                \r
-               auto frame1 = core::draw_frame(frame);\r
-               frame1.transform() = transform;\r
+               auto frame  = layer.receive(format_desc);                                       \r
+               auto frame1 = frame;\r
+               frame1.transform() *= tween.fetch_and_tick(1);\r
 \r
                if(format_desc.field_mode != core::field_mode::progressive)\r
                {                               \r
-                       auto frame2 = core::draw_frame(frame);\r
-                       frame2.transform() = tween.fetch_and_tick(1);\r
+                       auto frame2 = frame;\r
+                       frame2.transform() *= tween.fetch_and_tick(1);\r
                        frame1 = core::draw_frame::interlace(frame1, frame2, format_desc.field_mode);\r
                }\r
 \r
@@ -138,9 +127,9 @@ public:
                return it->second;\r
        }\r
                \r
-       void apply_transforms(const std::vector<std::tuple<int, stage::transform_func_t, unsigned int, tweener>>& transforms)\r
+       boost::unique_future<void> apply_transforms(const std::vector<std::tuple<int, stage::transform_func_t, unsigned int, tweener>>& transforms)\r
        {\r
-               executor_.begin_invoke([=]\r
+               return executor_.begin_invoke([=]\r
                {\r
                        BOOST_FOREACH(auto& transform, transforms)\r
                        {\r
@@ -151,9 +140,9 @@ public:
                }, task_priority::high_priority);\r
        }\r
                                                \r
-       void apply_transform(int index, const stage::transform_func_t& transform, unsigned int mix_duration, const tweener& tween)\r
+       boost::unique_future<void> apply_transform(int index, const stage::transform_func_t& transform, unsigned int mix_duration, const tweener& tween)\r
        {\r
-               executor_.begin_invoke([=]\r
+               return executor_.begin_invoke([=]\r
                {\r
                        auto src = tweens_[index].fetch();\r
                        auto dst = transform(src);\r
@@ -161,76 +150,76 @@ public:
                }, task_priority::high_priority);\r
        }\r
 \r
-       void clear_transforms(int index)\r
+       boost::unique_future<void> clear_transforms(int index)\r
        {\r
-               executor_.begin_invoke([=]\r
+               return executor_.begin_invoke([=]\r
                {\r
                        tweens_.erase(index);\r
                }, task_priority::high_priority);\r
        }\r
 \r
-       void clear_transforms()\r
+       boost::unique_future<void> clear_transforms()\r
        {\r
-               executor_.begin_invoke([=]\r
+               return executor_.begin_invoke([=]\r
                {\r
                        tweens_.clear();\r
                }, task_priority::high_priority);\r
        }\r
                \r
-       void load(int index, const spl::shared_ptr<frame_producer>& producer, const boost::optional<int32_t>& auto_play_delta)\r
+       boost::unique_future<void> load(int index, const spl::shared_ptr<frame_producer>& producer, bool preview, const boost::optional<int32_t>& auto_play_delta)\r
        {\r
-               executor_.begin_invoke([=]\r
+               return executor_.begin_invoke([=]\r
                {\r
-                       get_layer(index).load(producer, auto_play_delta);                       \r
+                       get_layer(index).load(producer, preview, auto_play_delta);                      \r
                }, task_priority::high_priority);\r
        }\r
 \r
-       void pause(int index)\r
+       boost::unique_future<void> pause(int index)\r
        {               \r
-               executor_.begin_invoke([=]\r
+               return executor_.begin_invoke([=]\r
                {\r
                        layers_[index].pause();\r
                }, task_priority::high_priority);\r
        }\r
 \r
-       void play(int index)\r
+       boost::unique_future<void> play(int index)\r
        {               \r
-               executor_.begin_invoke([=]\r
+               return executor_.begin_invoke([=]\r
                {\r
                        layers_[index].play();\r
                }, task_priority::high_priority);\r
        }\r
 \r
-       void stop(int index)\r
+       boost::unique_future<void> stop(int index)\r
        {               \r
-               executor_.begin_invoke([=]\r
+               return executor_.begin_invoke([=]\r
                {\r
                        layers_[index].stop();\r
                }, task_priority::high_priority);\r
        }\r
 \r
-       void clear(int index)\r
+       boost::unique_future<void> clear(int index)\r
        {\r
-               executor_.begin_invoke([=]\r
+               return executor_.begin_invoke([=]\r
                {\r
                        layers_.erase(index);\r
                }, task_priority::high_priority);\r
        }\r
                \r
-       void clear()\r
+       boost::unique_future<void> clear()\r
        {\r
-               executor_.begin_invoke([=]\r
+               return executor_.begin_invoke([=]\r
                {\r
                        layers_.clear();\r
                }, task_priority::high_priority);\r
        }       \r
                \r
-       void swap_layers(stage& other)\r
+       boost::unique_future<void> swap_layers(stage& other)\r
        {\r
                auto other_impl = other.impl_;\r
 \r
                if(other_impl.get() == this)\r
-                       return;\r
+                       return async(launch::deferred, []{});\r
                \r
                auto func = [=]\r
                {\r
@@ -251,26 +240,27 @@ public:
                        BOOST_FOREACH(auto& layer, other_layers)\r
                                layer.subscribe(event_subject_);\r
                };              \r
-               executor_.begin_invoke([=]\r
+\r
+               return executor_.begin_invoke([=]\r
                {\r
                        other_impl->executor_.invoke(func, task_priority::high_priority);\r
                }, task_priority::high_priority);\r
        }\r
 \r
-       void swap_layer(int index, int other_index)\r
+       boost::unique_future<void> swap_layer(int index, int other_index)\r
        {\r
-               executor_.begin_invoke([=]\r
+               return executor_.begin_invoke([=]\r
                {\r
                        std::swap(layers_[index], layers_[other_index]);\r
                }, task_priority::high_priority);\r
        }\r
 \r
-       void swap_layer(int index, int other_index, stage& other)\r
+       boost::unique_future<void> swap_layer(int index, int other_index, stage& other)\r
        {\r
                auto other_impl = other.impl_;\r
 \r
                if(other_impl.get() == this)\r
-                       swap_layer(index, other_index);\r
+                       return swap_layer(index, other_index);\r
                else\r
                {\r
                        auto func = [=]\r
@@ -286,7 +276,8 @@ public:
                                my_layer.subscribe(event_subject_);\r
                                other_layer.subscribe(other_impl->event_subject_);\r
                        };              \r
-                       executor_.begin_invoke([=]\r
+\r
+                       return executor_.begin_invoke([=]\r
                        {\r
                                other_impl->executor_.invoke(func, task_priority::high_priority);\r
                        }, task_priority::high_priority);\r
@@ -328,22 +319,31 @@ public:
                        return layers_[index].info();\r
                }, task_priority::high_priority);\r
        }               \r
+       \r
+       boost::unique_future<std::wstring> call(int index, const std::wstring& params)\r
+       {\r
+               return flatten(executor_.begin_invoke([=]\r
+               {\r
+                       return make_shared(layers_[index].foreground()->call(params));\r
+               }, task_priority::high_priority));\r
+       }\r
 };\r
 \r
 stage::stage(spl::shared_ptr<diagnostics::graph> graph) : impl_(new impl(std::move(graph))){}\r
-void stage::apply_transforms(const std::vector<stage::transform_tuple_t>& transforms){impl_->apply_transforms(transforms);}\r
-void stage::apply_transform(int index, const std::function<core::frame_transform(core::frame_transform)>& transform, unsigned int mix_duration, const tweener& tween){impl_->apply_transform(index, transform, mix_duration, tween);}\r
-void stage::clear_transforms(int index){impl_->clear_transforms(index);}\r
-void stage::clear_transforms(){impl_->clear_transforms();}\r
-void stage::load(int index, const spl::shared_ptr<frame_producer>& producer, const boost::optional<int32_t>& auto_play_delta){impl_->load(index, producer, auto_play_delta);}\r
-void stage::pause(int index){impl_->pause(index);}\r
-void stage::play(int index){impl_->play(index);}\r
-void stage::stop(int index){impl_->stop(index);}\r
-void stage::clear(int index){impl_->clear(index);}\r
-void stage::clear(){impl_->clear();}\r
-void stage::swap_layers(stage& other){impl_->swap_layers(other);}\r
-void stage::swap_layer(int index, int other_index){impl_->swap_layer(index, other_index);}\r
-void stage::swap_layer(int index, int other_index, stage& other){impl_->swap_layer(index, other_index, other);}\r
+boost::unique_future<std::wstring> stage::call(int index, const std::wstring& params){return impl_->call(index, params);}\r
+boost::unique_future<void> stage::apply_transforms(const std::vector<stage::transform_tuple_t>& transforms){return impl_->apply_transforms(transforms);}\r
+boost::unique_future<void> stage::apply_transform(int index, const std::function<core::frame_transform(core::frame_transform)>& transform, unsigned int mix_duration, const tweener& tween){return impl_->apply_transform(index, transform, mix_duration, tween);}\r
+boost::unique_future<void> stage::clear_transforms(int index){return impl_->clear_transforms(index);}\r
+boost::unique_future<void> stage::clear_transforms(){return impl_->clear_transforms();}\r
+boost::unique_future<void> stage::load(int index, const spl::shared_ptr<frame_producer>& producer, bool preview, const boost::optional<int32_t>& auto_play_delta){return impl_->load(index, producer, preview, auto_play_delta);}\r
+boost::unique_future<void> stage::pause(int index){return impl_->pause(index);}\r
+boost::unique_future<void> stage::play(int index){return impl_->play(index);}\r
+boost::unique_future<void> stage::stop(int index){return impl_->stop(index);}\r
+boost::unique_future<void> stage::clear(int index){return impl_->clear(index);}\r
+boost::unique_future<void> stage::clear(){return impl_->clear();}\r
+boost::unique_future<void> stage::swap_layers(stage& other){return impl_->swap_layers(other);}\r
+boost::unique_future<void> stage::swap_layer(int index, int other_index){return impl_->swap_layer(index, other_index);}\r
+boost::unique_future<void> stage::swap_layer(int index, int other_index, stage& other){return impl_->swap_layer(index, other_index, other);}\r
 boost::unique_future<spl::shared_ptr<frame_producer>> stage::foreground(int index) {return impl_->foreground(index);}\r
 boost::unique_future<spl::shared_ptr<frame_producer>> stage::background(int index) {return impl_->background(index);}\r
 boost::unique_future<boost::property_tree::wptree> stage::info() const{return impl_->info();}\r