]> git.sesse.net Git - casparcg/blob - core/producer/stage.h
604999ab3b2d5604b7197a377449a5a836f73c78
[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 <tuple>\r
38 #include <vector>\r
39 \r
40 FORWARD2(caspar, diagnostics, class graph);\r
41 \r
42 namespace caspar { namespace core {\r
43         \r
44 class stage sealed : public monitor::observable\r
45 {\r
46         stage(const stage&);\r
47         stage& operator=(const stage&);\r
48 public: \r
49 \r
50         // Static Members\r
51         \r
52         typedef std::function<struct frame_transform(struct frame_transform)> transform_func_t;\r
53         typedef std::tuple<int, transform_func_t, unsigned int, tweener> transform_tuple_t;\r
54 \r
55         // Constructors\r
56 \r
57         explicit stage(spl::shared_ptr<diagnostics::graph> graph);\r
58         \r
59         // Methods\r
60 \r
61         std::map<int, class draw_frame> operator()(const struct video_format_desc& format_desc);\r
62 \r
63         void apply_transforms(const std::vector<transform_tuple_t>& transforms);\r
64         void apply_transform(int index, const transform_func_t& transform, unsigned int mix_duration = 0, const tweener& tween = L"linear");\r
65         void clear_transforms(int index);\r
66         void clear_transforms();\r
67                                 \r
68         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
69         void pause(int index);\r
70         void play(int index);\r
71         void stop(int index);\r
72         void clear(int index);\r
73         void clear();   \r
74         void swap_layers(stage& other);\r
75         void swap_layer(int index, int other_index);\r
76         void swap_layer(int index, int other_index, stage& other);\r
77         \r
78         boost::unique_future<std::wstring> call(int index, const std::wstring& params);\r
79 \r
80         // monitor::observable\r
81 \r
82         void subscribe(const monitor::observable::observer_ptr& o) override;\r
83         void unsubscribe(const monitor::observable::observer_ptr& o) override;\r
84 \r
85         // Properties\r
86 \r
87         boost::unique_future<spl::shared_ptr<class frame_producer>>     foreground(int index);\r
88         boost::unique_future<spl::shared_ptr<class frame_producer>>     background(int index);\r
89 \r
90         boost::unique_future<boost::property_tree::wptree>                      info() const;\r
91         boost::unique_future<boost::property_tree::wptree>                      info(int index) const;\r
92 \r
93 private:\r
94         struct impl;\r
95         spl::shared_ptr<impl> impl_;\r
96 };\r
97 \r
98 }}