]> git.sesse.net Git - casparcg/blob - core/producer/frame_producer.h
c13e30fdc481f1df32f8377142c264a4ae000484
[casparcg] / core / producer / frame_producer.h
1 /*\r
2 * Copyright 2013 Sveriges Television AB http://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/memory/safe_ptr.h>\r
27 #include <common/exception/exceptions.h>\r
28 \r
29 #include <boost/noncopyable.hpp>\r
30 \r
31 #include <algorithm>\r
32 #include <functional>\r
33 #include <string>\r
34 #include <vector>\r
35 #include <stdint.h>\r
36 #include <numeric>\r
37 \r
38 #include <boost/thread/future.hpp>\r
39 #include <boost/property_tree/ptree_fwd.hpp>\r
40 \r
41 namespace caspar { \r
42         \r
43 class executor;\r
44         \r
45 namespace core {\r
46 \r
47 class basic_frame;\r
48 class parameters;\r
49 struct frame_factory;\r
50 struct media_info;\r
51 \r
52 struct frame_producer : boost::noncopyable\r
53 {\r
54 public:\r
55         enum hints\r
56         {\r
57                 NO_HINT = 0,\r
58                 ALPHA_HINT = 1,\r
59                 DEINTERLACE_HINT\r
60         };\r
61 \r
62         virtual ~frame_producer(){}     \r
63 \r
64         virtual std::wstring print() const = 0; // nothrow\r
65         virtual boost::property_tree::wptree info() const = 0;\r
66 \r
67         virtual boost::unique_future<std::wstring> call(const std::wstring&) \r
68         {\r
69                 BOOST_THROW_EXCEPTION(not_supported());\r
70         }\r
71 \r
72         virtual safe_ptr<frame_producer> get_following_producer() const {return frame_producer::empty();}  // nothrow\r
73         virtual void set_leading_producer(const safe_ptr<frame_producer>&) {}  // nothrow\r
74                 \r
75         virtual uint32_t nb_frames() const {return std::numeric_limits<uint32_t>::max();}\r
76         \r
77         virtual safe_ptr<basic_frame> receive(int hints) = 0;\r
78         virtual safe_ptr<core::basic_frame> last_frame() const = 0;\r
79         virtual safe_ptr<basic_frame> create_thumbnail_frame(media_info& additional_info);\r
80 \r
81         static const safe_ptr<frame_producer>& empty(); // nothrow\r
82 \r
83         virtual monitor::subject& monitor_output() = 0;\r
84 };\r
85 \r
86 safe_ptr<basic_frame> receive_and_follow(safe_ptr<frame_producer>& producer, int hints);\r
87 \r
88 typedef std::function<safe_ptr<core::frame_producer>(const safe_ptr<frame_factory>&, const core::parameters& params)> producer_factory_t;\r
89 void register_producer_factory(const producer_factory_t& factory); // Not thread-safe.\r
90 void register_thumbnail_producer_factory(const producer_factory_t& factory); // Not thread-safe.\r
91 safe_ptr<core::frame_producer> create_producer(const safe_ptr<frame_factory>&, const core::parameters& params);\r
92 safe_ptr<core::frame_producer> create_producer(const safe_ptr<frame_factory>&, const std::wstring& params);\r
93 safe_ptr<core::frame_producer> create_producer_destroy_proxy(safe_ptr<core::frame_producer> producer);\r
94 safe_ptr<core::frame_producer> create_producer_print_proxy(safe_ptr<core::frame_producer> producer);\r
95 safe_ptr<core::frame_producer> create_thumbnail_producer(const safe_ptr<frame_factory>& factory, const std::wstring& media_file);\r
96 void destroy_producers_synchronously();\r
97 \r
98 }}\r