]> git.sesse.net Git - casparcg/blob - core/frame/frame.h
2.1.0: Put "array" into its own file, common/memory/array.
[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 const_frame sealed\r
26 {\r
27 public: \r
28 \r
29         // Static Members\r
30 \r
31         static const const_frame& empty();\r
32 \r
33         // Constructors\r
34 \r
35         explicit const_frame(const void* tag = nullptr);\r
36         explicit const_frame(boost::shared_future<const_array> image, \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         ~const_frame();\r
43 \r
44         // Methods\r
45 \r
46         const_frame(const_frame&& other);\r
47         const_frame& operator=(const_frame&& other);\r
48         const_frame(const const_frame&);\r
49         const_frame& operator=(const const_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 image_data() const;\r
56         const core::audio_buffer& audio_data() const;\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         std::size_t size() const;\r
64                                                                 \r
65         const void* tag() const;\r
66 \r
67         bool operator==(const const_frame& other);\r
68         bool operator!=(const const_frame& other);\r
69                         \r
70 private:\r
71         struct impl;\r
72         spl::shared_ptr<impl> impl_;\r
73 };\r
74 \r
75 class mutable_frame sealed\r
76 {\r
77         mutable_frame(const mutable_frame&);\r
78         mutable_frame& operator=(const mutable_frame&);\r
79 public: \r
80 \r
81         // Static Members\r
82 \r
83         // Constructors\r
84 \r
85         explicit mutable_frame(std::vector<mutable_array> image_buffers, \r
86                                                 audio_buffer audio_buffer, \r
87                                                 const void* tag, \r
88                                                 const struct pixel_format_desc& desc, \r
89                                                 double frame_rate, \r
90                                                 core::field_mode field_mode);\r
91         ~mutable_frame();\r
92 \r
93         // Methods\r
94 \r
95         mutable_frame(mutable_frame&& other);\r
96         mutable_frame& operator=(mutable_frame&& other);\r
97 \r
98         void swap(mutable_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 mutable_array& image_data(std::size_t index = 0) const;\r
105         const core::audio_buffer& audio_data() const;\r
106 \r
107         mutable_array& image_data(std::size_t index = 0);\r
108         core::audio_buffer& audio_data();\r
109         \r
110         double frame_rate() const;\r
111         core::field_mode field_mode() const;\r
112 \r
113         std::size_t width() const;\r
114         std::size_t height() const;\r
115                                                                 \r
116         const void* tag() const;\r
117                         \r
118 private:\r
119         struct impl;\r
120         spl::unique_ptr<impl> impl_;\r
121 };\r
122 }}