]> git.sesse.net Git - casparcg/blob - core/frame/frame.h
git-svn-id: https://casparcg.svn.sourceforge.net/svnroot/casparcg/server/branches...
[casparcg] / core / frame / frame.h
1 #pragma once\r
2 \r
3 #undef BOOST_PARAMETER_MAX_ARITY\r
4 #define BOOST_PARAMETER_MAX_ARITY 7\r
5 \r
6 #include "../video_format.h"\r
7 \r
8 #include <common/memory.h>\r
9 #include <common/forward.h>\r
10 #include <common/array.h>\r
11 \r
12 #include <boost/range.hpp>\r
13 #include <boost/any.hpp>\r
14 \r
15 #include <tbb/cache_aligned_allocator.h>\r
16 \r
17 #include <cstddef>\r
18 #include <cstdint>\r
19 \r
20 FORWARD1(boost, template<typename> class shared_future);\r
21 \r
22 namespace caspar { namespace core {\r
23         \r
24 typedef std::vector<int32_t, tbb::cache_aligned_allocator<int32_t>> audio_buffer;\r
25 \r
26 class mutable_frame sealed\r
27 {\r
28         mutable_frame(const mutable_frame&);\r
29         mutable_frame& operator=(const mutable_frame&);\r
30 public: \r
31 \r
32         // Static Members\r
33 \r
34         // Constructors\r
35 \r
36         explicit mutable_frame(std::vector<array<std::uint8_t>> image_buffers, \r
37                                                 audio_buffer audio_buffer, \r
38                                                 const void* tag, \r
39                                                 const struct pixel_format_desc& desc, \r
40                                                 double frame_rate, \r
41                                                 core::field_mode field_mode);\r
42         ~mutable_frame();\r
43 \r
44         // Methods\r
45 \r
46         mutable_frame(mutable_frame&& other);\r
47         mutable_frame& operator=(mutable_frame&& other);\r
48 \r
49         void swap(mutable_frame& other);\r
50                         \r
51         // Properties\r
52                         \r
53         const struct pixel_format_desc& pixel_format_desc() const;\r
54 \r
55         const array<std::uint8_t>& image_data(std::size_t index = 0) const;\r
56         const core::audio_buffer& audio_data() const;\r
57 \r
58         array<std::uint8_t>& image_data(std::size_t index = 0);\r
59         core::audio_buffer& audio_data();\r
60         \r
61         double frame_rate() const;\r
62         core::field_mode field_mode() const;\r
63 \r
64         std::size_t width() const;\r
65         std::size_t height() const;\r
66                                                                 \r
67         const void* stream_tag() const;\r
68         const void* data_tag() const;\r
69                         \r
70 private:\r
71         struct impl;\r
72         spl::unique_ptr<impl> impl_;\r
73 };\r
74 \r
75 class const_frame sealed\r
76 {\r
77 public: \r
78 \r
79         // Static Members\r
80 \r
81         static const const_frame& empty();\r
82 \r
83         // Constructors\r
84 \r
85         explicit const_frame(const void* tag = nullptr);\r
86         explicit const_frame(boost::shared_future<array<const std::uint8_t>> image, \r
87                                                 audio_buffer audio_buffer, \r
88                                                 const void* tag, \r
89                                                 const struct pixel_format_desc& desc, \r
90                                                 double frame_rate, \r
91                                                 core::field_mode field_mode);\r
92         const_frame(mutable_frame&& other);\r
93         ~const_frame();\r
94 \r
95         // Methods\r
96 \r
97         const_frame(const_frame&& other);\r
98         const_frame& operator=(const_frame&& other);\r
99         const_frame(const const_frame&);\r
100         const_frame& operator=(const const_frame& other);\r
101                                 \r
102         // Properties\r
103                                 \r
104         const struct pixel_format_desc& pixel_format_desc() const;\r
105 \r
106         array<const std::uint8_t> image_data(int index = 0) const;\r
107         const core::audio_buffer& audio_data() const;\r
108                 \r
109         double frame_rate() const;\r
110         core::field_mode field_mode() const;\r
111 \r
112         std::size_t width() const;\r
113         std::size_t height() const;\r
114         std::size_t size() const;\r
115                                                                 \r
116         const void* stream_tag() const;\r
117         const void* data_tag() const;\r
118 \r
119         bool operator==(const const_frame& other);\r
120         bool operator!=(const const_frame& other);\r
121         bool operator<(const const_frame& other);\r
122         bool operator>(const const_frame& other);\r
123                         \r
124 private:\r
125         struct impl;\r
126         spl::shared_ptr<impl> impl_;\r
127 };\r
128 \r
129 }}