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