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