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