]> git.sesse.net Git - casparcg/blob - core/producer/frame_producer.h
2.1.0: -frame_producer: Refactored last_frame.
[casparcg] / core / producer / frame_producer.h
1 /*\r
2 * Copyright (c) 2011 Sveriges Television AB <info@casparcg.com>\r
3 *\r
4 * This file is part of CasparCG (www.casparcg.com).\r
5 *\r
6 * CasparCG is free software: you can redistribute it and/or modify\r
7 * it under the terms of the GNU General Public License as published by\r
8 * the Free Software Foundation, either version 3 of the License, or\r
9 * (at your option) any later version.\r
10 *\r
11 * CasparCG is distributed in the hope that it will be useful,\r
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
14 * GNU General Public License for more details.\r
15 *\r
16 * You should have received a copy of the GNU General Public License\r
17 * along with CasparCG. If not, see <http://www.gnu.org/licenses/>.\r
18 *\r
19 * Author: Robert Nagy, ronag89@gmail.com\r
20 */\r
21 \r
22 #pragma once\r
23 \r
24 #include "../monitor/monitor.h"\r
25 \r
26 #include <common/forward.h>\r
27 #include <common/spl/memory.h>\r
28 #include <common/enum_class.h>\r
29 \r
30 #include <stdint.h>\r
31 #include <limits>\r
32 #include <functional>\r
33 #include <string>\r
34 #include <type_traits>\r
35 #include <vector>\r
36 \r
37 #include <boost/noncopyable.hpp>\r
38 #include <boost/property_tree/ptree_fwd.hpp>\r
39 \r
40 FORWARD1(caspar, class executor);\r
41 FORWARD1(boost, template<typename T> class unique_future);\r
42 \r
43 namespace caspar { namespace core {\r
44         \r
45 struct frame_producer : public monitor::observable\r
46                                           , boost::noncopyable\r
47 {\r
48         struct flags_def\r
49         {\r
50                 enum type\r
51                 {\r
52                         none            = 0,\r
53                         alpha_only      = 2,\r
54                         deinterlace     = 4,\r
55                 };\r
56         };\r
57         typedef enum_class<flags_def> flags;\r
58 \r
59         virtual ~frame_producer(){}     \r
60 \r
61         virtual std::wstring print() const = 0; // nothrow\r
62         virtual std::wstring name() const = 0;\r
63         virtual boost::property_tree::wptree info() const = 0;\r
64 \r
65         virtual boost::unique_future<std::wstring> call(const std::wstring&);\r
66 \r
67         virtual void leading_producer(const spl::shared_ptr<frame_producer>&) {}  // nothrow\r
68                 \r
69         virtual uint32_t nb_frames() const {return std::numeric_limits<uint32_t>::max();}\r
70         \r
71         virtual spl::shared_ptr<class draw_frame> receive(int fBlags) = 0;\r
72         virtual spl::shared_ptr<class draw_frame> last_frame() const;\r
73         \r
74         static const spl::shared_ptr<frame_producer>& empty(); // nothrow\r
75 \r
76         // monitor::observable\r
77 \r
78         virtual void subscribe(const monitor::observable::observer_ptr& o) {}\r
79         virtual void unsubscribe(const monitor::observable::observer_ptr& o) {}\r
80 };\r
81 \r
82 typedef std::function<spl::shared_ptr<core::frame_producer>(const spl::shared_ptr<struct frame_factory>&, const std::vector<std::wstring>&)> producer_factory_t;\r
83 void register_producer_factory(const producer_factory_t& factory); // Not thread-safe.\r
84 \r
85 spl::shared_ptr<core::frame_producer> create_producer(const spl::shared_ptr<frame_factory>&, const std::vector<std::wstring>& params);\r
86 spl::shared_ptr<core::frame_producer> create_producer(const spl::shared_ptr<frame_factory>&, const std::wstring& params);\r
87 \r
88 spl::shared_ptr<core::frame_producer> wrap_producer(spl::shared_ptr<core::frame_producer> producer);\r
89                 \r
90 }}\r