]> git.sesse.net Git - casparcg/blob - core/producer/stage.h
Changed use of microsoft specific sealed keyword to /* final */ to indicate intent
[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 #include "../interaction/interaction_sink.h"
28
29 #include <common/forward.h>
30 #include <common/future_fwd.h>
31 #include <common/memory.h>
32 #include <common/tweener.h>
33
34 #include <boost/optional.hpp>
35 #include <boost/property_tree/ptree_fwd.hpp>
36
37 #include <functional>
38 #include <map>
39 #include <tuple>
40 #include <vector>
41
42 FORWARD2(caspar, diagnostics, class graph);
43
44 namespace caspar { namespace core {
45
46 typedef reactive::observable<std::map<int, class draw_frame>> frame_observable;
47         
48 class stage /* final */ : public monitor::observable, public frame_observable, public interaction_sink
49 {
50         stage(const stage&);
51         stage& operator=(const stage&);
52 public: 
53
54         // Static Members
55         
56         typedef std::function<struct frame_transform(struct frame_transform)> transform_func_t;
57         typedef std::tuple<int, transform_func_t, unsigned int, tweener> transform_tuple_t;
58
59         // Constructors
60
61         explicit stage(spl::shared_ptr<diagnostics::graph> graph);
62         
63         // Methods
64
65         std::map<int, class draw_frame> operator()(const struct video_format_desc& format_desc);
66
67         boost::unique_future<void>                      apply_transforms(const std::vector<transform_tuple_t>& transforms);
68         boost::unique_future<void>                      apply_transform(int index, const transform_func_t& transform, unsigned int mix_duration = 0, const tweener& tween = L"linear");
69         boost::unique_future<void>                      clear_transforms(int index);
70         boost::unique_future<void>                      clear_transforms();                             
71         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);
72         boost::unique_future<void>                      pause(int index);
73         boost::unique_future<void>                      play(int index);
74         boost::unique_future<void>                      stop(int index);
75         boost::unique_future<std::wstring>      call(int index, const std::vector<std::wstring>& params);
76         boost::unique_future<void>                      clear(int index);
77         boost::unique_future<void>                      clear();        
78         boost::unique_future<void>                      swap_layers(stage& other);
79         boost::unique_future<void>                      swap_layer(int index, int other_index);
80         boost::unique_future<void>                      swap_layer(int index, int other_index, stage& other);   
81
82         // monitor::observable
83
84         void subscribe(const monitor::observable::observer_ptr& o) override;
85         void unsubscribe(const monitor::observable::observer_ptr& o) override;
86         
87         // frame_observable
88
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         boost::unique_future<spl::shared_ptr<class frame_producer>>     foreground(int index);
99         boost::unique_future<spl::shared_ptr<class frame_producer>>     background(int index);
100
101         boost::unique_future<boost::property_tree::wptree>                      info() const;
102         boost::unique_future<boost::property_tree::wptree>                      info(int index) const;
103
104 private:
105         struct impl;
106         spl::shared_ptr<impl> impl_;
107 };
108
109 }}