]> git.sesse.net Git - casparcg/blob - core/producer/frame_producer.h
2.0.0.2: Improved int type size safety.
[casparcg] / core / producer / frame_producer.h
1 /*\r
2 * copyright (c) 2010 Sveriges Television AB <info@casparcg.com>\r
3 *\r
4 *  This file is part of CasparCG.\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 */\r
20 #pragma once\r
21 \r
22 #include "frame/basic_frame.h"\r
23 #include "frame/audio_transform.h"\r
24 \r
25 #include <common/memory/safe_ptr.h>\r
26 \r
27 #include "frame/frame_factory.h"\r
28 \r
29 #include <boost/noncopyable.hpp>\r
30 \r
31 #include <functional>\r
32 #include <string>\r
33 #include <vector>\r
34 \r
35 namespace caspar { namespace core {\r
36 \r
37 class basic_frame;\r
38 \r
39 class frame_producer : boost::noncopyable\r
40 {\r
41 public:\r
42         frame_producer() : last_frame_(core::basic_frame::empty()){}\r
43         virtual ~frame_producer(){}     \r
44 \r
45         virtual std::wstring print() const = 0; // nothrow\r
46 \r
47         virtual void param(const std::wstring&){}\r
48 \r
49         virtual safe_ptr<frame_producer> get_following_producer() const {return frame_producer::empty();}  // nothrow\r
50         virtual void set_leading_producer(const safe_ptr<frame_producer>&) {}  // nothrow\r
51                 \r
52         static const safe_ptr<frame_producer>& empty(); // nothrow\r
53 \r
54         safe_ptr<core::basic_frame> last_frame() const {return last_frame_;}\r
55         \r
56 private:\r
57         friend safe_ptr<basic_frame> receive(const safe_ptr<frame_producer>& producer);\r
58 \r
59         virtual safe_ptr<basic_frame> receive() = 0;\r
60 \r
61         safe_ptr<basic_frame> receive_save_last();\r
62 \r
63         safe_ptr<core::basic_frame> last_frame_;\r
64 };\r
65 \r
66 safe_ptr<basic_frame> receive(const safe_ptr<frame_producer>& producer);\r
67 safe_ptr<basic_frame> receive_and_follow(safe_ptr<frame_producer>& producer);\r
68 safe_ptr<basic_frame> receive_and_follow_w_last(safe_ptr<frame_producer>& producer);\r
69 \r
70 typedef std::function<safe_ptr<core::frame_producer>(const safe_ptr<frame_factory>&, const std::vector<std::wstring>&)> producer_factory_t;\r
71 void register_producer_factory(const producer_factory_t& factory); // Not thread-safe.\r
72 safe_ptr<core::frame_producer> create_producer(const safe_ptr<frame_factory>&, const std::vector<std::wstring>& params);\r
73 \r
74 \r
75 }}\r