]> git.sesse.net Git - casparcg/blob - core/frame/frame.h
[general] Abstracted the concept of a key only frame so that readers of const_frame...
[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 "../fwd.h"
7
8 #include <common/memory.h>
9 #include <common/forward.h>
10 #include <common/array.h>
11 #include <common/future_fwd.h>
12 #include <common/cache_aligned_vector.h>
13 #include <common/timer.h>
14
15 #include <cstddef>
16 #include <cstdint>
17
18 FORWARD1(boost, template<typename> class shared_future);
19
20 namespace caspar { namespace core {
21
22 typedef caspar::array<const int32_t> audio_buffer;
23 typedef cache_aligned_vector<int32_t> mutable_audio_buffer;
24 class frame_geometry;
25
26 class mutable_frame final
27 {
28         mutable_frame(const mutable_frame&);
29         mutable_frame& operator=(const mutable_frame&);
30 public:
31
32         // Static Members
33
34         // Constructors
35
36         explicit mutable_frame(std::vector<array<std::uint8_t>> image_buffers,
37                                                 mutable_audio_buffer audio_data,
38                                                 const void* tag,
39                                                 const pixel_format_desc& desc,
40                                                 const audio_channel_layout& channel_layout);
41         ~mutable_frame();
42
43         // Methods
44
45         mutable_frame(mutable_frame&& other);
46         mutable_frame& operator=(mutable_frame&& other);
47
48         void swap(mutable_frame& other);
49
50         // Properties
51
52         const core::pixel_format_desc& pixel_format_desc() const;
53         const core::audio_channel_layout& audio_channel_layout() const;
54
55         const array<std::uint8_t>& image_data(std::size_t index = 0) const;
56         const core::mutable_audio_buffer& audio_data() const;
57
58         array<std::uint8_t>& image_data(std::size_t index = 0);
59         core::mutable_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
66         const core::frame_geometry& geometry() const;
67         void set_geometry(const frame_geometry& g);
68
69         caspar::timer since_created() const;
70
71 private:
72         struct impl;
73         spl::unique_ptr<impl> impl_;
74 };
75
76 class const_frame final
77 {
78 public:
79
80         // Static Members
81
82         static const const_frame& empty();
83
84         // Constructors
85
86         explicit const_frame(const void* tag = nullptr);
87         explicit const_frame(std::shared_future<array<const std::uint8_t>> image,
88                                                 audio_buffer audio_data,
89                                                 const void* tag,
90                                                 const pixel_format_desc& desc,
91                                                 const audio_channel_layout& channel_layout);
92         const_frame(mutable_frame&& other);
93         ~const_frame();
94
95         // Methods
96
97         const_frame(const_frame&& other);
98         const_frame& operator=(const_frame&& other);
99         const_frame(const const_frame&);
100         const_frame& operator=(const const_frame& other);
101
102         const_frame key_only() const;
103
104         // Properties
105
106         const core::pixel_format_desc& pixel_format_desc() const;
107         const core::audio_channel_layout& audio_channel_layout() const;
108
109         array<const std::uint8_t> image_data(int index = 0) const;
110         const core::audio_buffer& audio_data() const;
111
112         std::size_t width() const;
113         std::size_t height() const;
114         std::size_t size() const;
115
116         const void* stream_tag() const;
117
118         const core::frame_geometry& geometry() const;
119         void set_geometry(const frame_geometry& g);
120         int64_t get_age_millis() const;
121
122         bool operator==(const const_frame& other);
123         bool operator!=(const const_frame& other);
124         bool operator<(const const_frame& other);
125         bool operator>(const const_frame& other);
126
127 private:
128         struct impl;
129         spl::shared_ptr<impl> impl_;
130 };
131
132 }}