2 * Copyright (c) 2011 Sveriges Television AB <info@casparcg.com>
4 * This file is part of CasparCG (www.casparcg.com).
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.
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.
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/>.
19 * Author: Robert Nagy, ronag89@gmail.com
25 #include "../monitor/monitor.h"
26 #include "../interaction/interaction_sink.h"
28 #include <common/forward.h>
29 #include <common/future_fwd.h>
30 #include <common/memory.h>
31 #include <common/tweener.h>
33 #include <boost/optional.hpp>
34 #include <boost/property_tree/ptree_fwd.hpp>
41 FORWARD2(caspar, diagnostics, class graph);
43 namespace caspar { namespace core {
45 //typedef reactive::observable<std::map<int, class draw_frame>> frame_observable;
47 class stage final : public interaction_sink
50 stage& operator=(const stage&);
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;
60 explicit stage(int channel_index, spl::shared_ptr<caspar::diagnostics::graph> graph);
64 std::map<int, draw_frame> operator()(const video_format_desc& format_desc);
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 = 0, const tweener& tween = L"linear");
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);
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);
86 monitor::subject& monitor_output();
89 //void subscribe(const frame_observable::observer_ptr& o) override;
90 //void unsubscribe(const frame_observable::observer_ptr& o) override;
94 void on_interaction(const interaction_event::ptr& event) override;
98 std::future<std::shared_ptr<frame_producer>> foreground(int index);
99 std::future<std::shared_ptr<frame_producer>> background(int index);
101 std::future<boost::property_tree::wptree> info() const;
102 std::future<boost::property_tree::wptree> info(int index) const;
104 std::future<boost::property_tree::wptree> delay_info() const;
105 std::future<boost::property_tree::wptree> delay_info(int layer) const;
108 spl::shared_ptr<impl> impl_;