]> git.sesse.net Git - casparcg/blob - core/producer/stage.h
9a60b192cc1dee7e15f7da959a864bd67a0ed759
[casparcg] / core / producer / stage.h
1 /*\r
2 * Copyright (c) 2011 Sveriges Television AB <info@casparcg.com>\r
3 *\r
4 * This file is part of CasparCG (www.casparcg.com).\r
5 *\r
6 * CasparCG is free software: you can redistribute it and/or modify\r
7 * it under the terms of the GNU General Public License as published by\r
8 * the Free Software Foundation, either version 3 of the License, or\r
9 * (at your option) any later version.\r
10 *\r
11 * CasparCG is distributed in the hope that it will be useful,\r
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
14 * GNU General Public License for more details.\r
15 *\r
16 * You should have received a copy of the GNU General Public License\r
17 * along with CasparCG. If not, see <http://www.gnu.org/licenses/>.\r
18 *\r
19 * Author: Robert Nagy, ronag89@gmail.com\r
20 */\r
21 \r
22 #pragma once\r
23 \r
24 #include "frame_producer.h"\r
25 \r
26 #include "../monitor/monitor.h"\r
27 \r
28 #include <common/forward.h>\r
29 #include <common/future_fwd.h>\r
30 #include <common/memory.h>\r
31 #include <common/tweener.h>\r
32 \r
33 #include <boost/optional.hpp>\r
34 #include <boost/property_tree/ptree_fwd.hpp>\r
35 \r
36 #include <functional>\r
37 #include <map>\r
38 #include <tuple>\r
39 #include <vector>\r
40 \r
41 FORWARD2(caspar, diagnostics, class graph);\r
42 \r
43 namespace caspar { namespace core {\r
44 \r
45 typedef reactive::observable<std::map<int, class draw_frame>> frame_observable;\r
46         \r
47 class stage sealed : public monitor::observable, public frame_observable\r
48 {\r
49         stage(const stage&);\r
50         stage& operator=(const stage&);\r
51 public: \r
52 \r
53         // Static Members\r
54         \r
55         typedef std::function<struct frame_transform(struct frame_transform)> transform_func_t;\r
56         typedef std::tuple<int, transform_func_t, unsigned int, tweener> transform_tuple_t;\r
57 \r
58         // Constructors\r
59 \r
60         explicit stage(spl::shared_ptr<diagnostics::graph> graph);\r
61         \r
62         // Methods\r
63 \r
64         std::map<int, class draw_frame> operator()(const struct video_format_desc& format_desc);\r
65 \r
66         boost::unique_future<void>                      apply_transforms(const std::vector<transform_tuple_t>& transforms);\r
67         boost::unique_future<void>                      apply_transform(int index, const transform_func_t& transform, unsigned int mix_duration = 0, const tweener& tween = L"linear");\r
68         boost::unique_future<void>                      clear_transforms(int index);\r
69         boost::unique_future<void>                      clear_transforms();                             \r
70         boost::unique_future<void>                      load(int index, const spl::shared_ptr<class frame_producer>& producer, bool preview = false, const boost::optional<int32_t>& auto_play_delta = nullptr);\r
71         boost::unique_future<void>                      pause(int index);\r
72         boost::unique_future<void>                      play(int index);\r
73         boost::unique_future<void>                      stop(int index);\r
74         boost::unique_future<std::wstring>      call(int index, const std::wstring& params);\r
75         boost::unique_future<void>                      clear(int index);\r
76         boost::unique_future<void>                      clear();        \r
77         boost::unique_future<void>                      swap_layers(stage& other);\r
78         boost::unique_future<void>                      swap_layer(int index, int other_index);\r
79         boost::unique_future<void>                      swap_layer(int index, int other_index, stage& other);   \r
80 \r
81         // monitor::observable\r
82 \r
83         void subscribe(const monitor::observable::observer_ptr& o) override;\r
84         void unsubscribe(const monitor::observable::observer_ptr& o) override;\r
85         \r
86         // frame_observable\r
87 \r
88         void subscribe(const frame_observable::observer_ptr& o) override;\r
89         void unsubscribe(const frame_observable::observer_ptr& o) override;\r
90 \r
91         // Properties\r
92 \r
93         boost::unique_future<spl::shared_ptr<class frame_producer>>     foreground(int index);\r
94         boost::unique_future<spl::shared_ptr<class frame_producer>>     background(int index);\r
95 \r
96         boost::unique_future<boost::property_tree::wptree>                      info() const;\r
97         boost::unique_future<boost::property_tree::wptree>                      info(int index) const;\r
98 \r
99 private:\r
100         struct impl;\r
101         spl::shared_ptr<impl> impl_;\r
102 };\r
103 \r
104 }}