]> git.sesse.net Git - casparcg/blob - core/producer/stage.h
Made it possible to equality compare tweener objects
[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 "../fwd.h"
25 #include "../monitor/monitor.h"
26 #include "../interaction/interaction_sink.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 final : public interaction_sink
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(int channel_index, spl::shared_ptr<caspar::diagnostics::graph> graph);
61         
62         // Methods
63
64         std::map<int, draw_frame>               operator()(const video_format_desc& format_desc);
65
66         std::future<void>                               apply_transforms(const std::vector<transform_tuple_t>& transforms);
67         std::future<void>                               apply_transform(int index, const transform_func_t& transform, unsigned int mix_duration, const tweener& tween);
68         std::future<void>                               clear_transforms(int index);
69         std::future<void>                               clear_transforms();
70         std::future<frame_transform>    get_current_transform(int index);
71         std::future<void>                               load(int index, const spl::shared_ptr<frame_producer>& producer, bool preview = false, const boost::optional<int32_t>& auto_play_delta = boost::optional<int32_t>());
72         std::future<void>                               pause(int index);
73         std::future<void>                               resume(int index);
74         std::future<void>                               play(int index);
75         std::future<void>                               stop(int index);
76         std::future<std::wstring>               call(int index, const std::vector<std::wstring>& params);
77         std::future<void>                               clear(int index);
78         std::future<void>                               clear();
79         std::future<void>                               swap_layers(stage& other, bool swap_transforms);
80         std::future<void>                               swap_layer(int index, int other_index, bool swap_transforms);
81         std::future<void>                               swap_layer(int index, int other_index, stage& other, bool swap_transforms);
82
83         void                                                    add_layer_consumer(void* token, int layer, const spl::shared_ptr<write_frame_consumer>& layer_consumer);
84         void                                                    remove_layer_consumer(void* token, int layer);
85
86         monitor::subject& monitor_output();     
87
88         // frame_observable
89         //void subscribe(const frame_observable::observer_ptr& o) override;
90         //void unsubscribe(const frame_observable::observer_ptr& o) override;
91
92         // interaction_sink
93
94         void on_interaction(const interaction_event::ptr& event) override;
95
96         // Properties
97
98         std::future<std::shared_ptr<frame_producer>>    foreground(int index);
99         std::future<std::shared_ptr<frame_producer>>    background(int index);
100
101         std::future<boost::property_tree::wptree>               info() const;
102         std::future<boost::property_tree::wptree>               info(int index) const;
103
104         std::future<boost::property_tree::wptree>               delay_info() const;
105         std::future<boost::property_tree::wptree>               delay_info(int layer) const;
106 private:
107         struct impl;
108         spl::shared_ptr<impl> impl_;
109 };
110
111 }}