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