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
24 #include "../monitor/monitor.h"
25 #include "../video_format.h"
26 #include "../interaction/interaction_sink.h"
29 #include <common/forward.h>
30 #include <common/future_fwd.h>
31 #include <common/memory.h>
32 #include <common/enum_class.h>
38 #include <type_traits>
41 #include <boost/property_tree/ptree_fwd.hpp>
43 FORWARD1(caspar, class executor);
45 namespace caspar { namespace core {
51 binding<double> width;
52 binding<double> height;
54 constraints(double width, double height);
59 class frame_producer : public interaction_sink
61 frame_producer(const frame_producer&);
62 frame_producer& operator=(const frame_producer&);
67 static const spl::shared_ptr<frame_producer>& empty();
72 virtual ~frame_producer(){}
76 virtual class draw_frame receive() = 0;
77 virtual boost::unique_future<std::wstring> call(const std::vector<std::wstring>& params) = 0;
78 virtual variable& get_variable(const std::wstring& name) = 0;
79 virtual const std::vector<std::wstring>& get_variables() const = 0;
81 // monitor::observable
83 virtual monitor::source& monitor_output() = 0;
86 virtual void on_interaction(const interaction_event::ptr& event) override { }
87 virtual bool collides(double x, double y) const override { return false; }
92 virtual void paused(bool value) = 0;
93 virtual std::wstring print() const = 0;
94 virtual std::wstring name() const = 0;
95 virtual boost::property_tree::wptree info() const = 0;
96 virtual uint32_t nb_frames() const = 0;
97 virtual uint32_t frame_number() const = 0;
98 virtual class draw_frame last_frame() = 0;
99 virtual class draw_frame create_thumbnail_frame() = 0;
100 virtual constraints& pixel_constraints() = 0;
101 virtual void leading_producer(const spl::shared_ptr<frame_producer>&) {}
104 class frame_producer_base : public frame_producer
107 frame_producer_base();
108 virtual ~frame_producer_base(){}
112 virtual boost::unique_future<std::wstring> call(const std::vector<std::wstring>& params) override;
113 virtual variable& get_variable(const std::wstring& name) override;
114 virtual const std::vector<std::wstring>& get_variables() const override;
116 // monitor::observable
120 void paused(bool value) override;
121 uint32_t nb_frames() const override;
122 uint32_t frame_number() const override;
123 virtual class draw_frame last_frame() override;
124 virtual class draw_frame create_thumbnail_frame() override;
127 virtual class draw_frame receive() override;
128 virtual class draw_frame receive_impl() = 0;
132 std::shared_ptr<impl> impl_;
135 typedef std::function<spl::shared_ptr<core::frame_producer>(const spl::shared_ptr<class frame_factory>&, const video_format_desc& format_desc, const std::vector<std::wstring>&)> producer_factory_t;
136 void register_producer_factory(const producer_factory_t& factory); // Not thread-safe.
137 void register_thumbnail_producer_factory(const producer_factory_t& factory); // Not thread-safe.
139 spl::shared_ptr<core::frame_producer> create_producer(const spl::shared_ptr<frame_factory>&, const video_format_desc& format_desc, const std::vector<std::wstring>& params);
140 spl::shared_ptr<core::frame_producer> create_producer(const spl::shared_ptr<frame_factory>&, const video_format_desc& format_desc, const std::wstring& params);
142 spl::shared_ptr<core::frame_producer> create_destroy_proxy(spl::shared_ptr<core::frame_producer> producer);
143 spl::shared_ptr<core::frame_producer> create_thumbnail_producer(const spl::shared_ptr<frame_factory>&, const video_format_desc& format_desc, const std::wstring& media_file);