]> git.sesse.net Git - casparcg/blob - core/producer/frame/basic_frame.h
2.0. Updated rendered and fixed some interlacing bugs.
[casparcg] / core / producer / frame / basic_frame.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_visitor.h"\r
23 \r
24 #include <core/video_format.h>\r
25 \r
26 #include <common/memory/safe_ptr.h>\r
27 \r
28 #include <boost/range/iterator_range.hpp>\r
29 \r
30 #include <vector>\r
31 \r
32 namespace caspar { namespace core {\r
33 \r
34 class image_transform;\r
35 class audio_transform;\r
36                 \r
37 class basic_frame\r
38 {\r
39         basic_frame(std::vector<safe_ptr<basic_frame>>&& frames);\r
40 public:\r
41         basic_frame();  \r
42         basic_frame(const safe_ptr<basic_frame>& frame);\r
43         basic_frame(safe_ptr<basic_frame>&& frame);\r
44         basic_frame(const std::vector<safe_ptr<basic_frame>>& frames);\r
45 \r
46         void swap(basic_frame& other);\r
47         \r
48         basic_frame(const basic_frame& other);\r
49         basic_frame(basic_frame&& other);\r
50 \r
51         basic_frame& operator=(const basic_frame& other);\r
52         basic_frame& operator=(basic_frame&& other);\r
53         \r
54         const image_transform& get_image_transform() const;\r
55         image_transform& get_image_transform();\r
56 \r
57         const audio_transform& get_audio_transform() const;\r
58         audio_transform& get_audio_transform();\r
59 \r
60         core::video_mode::type get_mode() const;\r
61                 \r
62         static safe_ptr<basic_frame> interlace(const safe_ptr<basic_frame>& frame1, const safe_ptr<basic_frame>& frame2, video_mode::type mode);\r
63         static safe_ptr<basic_frame> combine(const safe_ptr<basic_frame>& frame1, const safe_ptr<basic_frame>& frame2);\r
64         static safe_ptr<basic_frame> fill_and_key(const safe_ptr<basic_frame>& fill, const safe_ptr<basic_frame>& key);\r
65                 \r
66         static const safe_ptr<basic_frame>& eof()\r
67         {\r
68                 static safe_ptr<basic_frame> frame = make_safe<basic_frame>();\r
69                 return frame;\r
70         }\r
71 \r
72         static const safe_ptr<basic_frame>& empty()\r
73         {\r
74                 static safe_ptr<basic_frame> frame = make_safe<basic_frame>();\r
75                 return frame;\r
76         }\r
77 \r
78         static const safe_ptr<basic_frame>& late()\r
79         {\r
80                 static safe_ptr<basic_frame> frame = make_safe<basic_frame>();\r
81                 return frame;\r
82         }\r
83         \r
84         virtual void accept(frame_visitor& visitor);\r
85 \r
86         virtual std::wstring print() const;\r
87 private:\r
88         struct implementation;\r
89         safe_ptr<implementation> impl_;\r
90 };\r
91 \r
92 safe_ptr<basic_frame> disable_audio(const safe_ptr<basic_frame>& frame);\r
93 \r
94 inline bool is_concrete_frame(const safe_ptr<basic_frame>& frame)\r
95 {\r
96         return frame != basic_frame::empty() && frame != basic_frame::eof() && frame != basic_frame::late();\r
97 }\r
98 \r
99 inline bool is_concrete_frame(const std::shared_ptr<basic_frame>& frame)\r
100 {\r
101         return frame != nullptr && frame.get() != basic_frame::empty().get() && frame.get() != basic_frame::eof().get() && frame.get() != basic_frame::late().get();\r
102 }\r
103 \r
104 }}