]> git.sesse.net Git - casparcg/blob - core/frame/frame.h
[text_producer] Don't upload texture atlas to GPU every time the text or tracking...
[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         struct impl;
79 public:
80
81         // Static Members
82
83         static const const_frame& empty();
84
85         // Constructors
86
87         explicit const_frame(const void* tag = nullptr);
88         explicit const_frame(std::shared_future<array<const std::uint8_t>> image,
89                                                 audio_buffer audio_data,
90                                                 const void* tag,
91                                                 const pixel_format_desc& desc,
92                                                 const audio_channel_layout& channel_layout);
93         const_frame(mutable_frame&& other);
94         ~const_frame();
95
96         // Methods
97
98         const_frame(const_frame&& other);
99         const_frame& operator=(const_frame&& other);
100         const_frame(const const_frame&);
101         const_frame(const const_frame::impl&);
102         const_frame& operator=(const const_frame& other);
103
104         const_frame key_only() const;
105
106         // Properties
107
108         const core::pixel_format_desc& pixel_format_desc() const;
109         const core::audio_channel_layout& audio_channel_layout() const;
110
111         array<const std::uint8_t> image_data(int index = 0) const;
112         const core::audio_buffer& audio_data() const;
113
114         std::size_t width() const;
115         std::size_t height() const;
116         std::size_t size() const;
117
118         const void* stream_tag() const;
119
120         const core::frame_geometry& geometry() const;
121         const_frame with_geometry(const frame_geometry& g) const;
122         int64_t get_age_millis() const;
123
124         bool operator==(const const_frame& other);
125         bool operator!=(const const_frame& other);
126         bool operator<(const const_frame& other);
127         bool operator>(const const_frame& other);
128
129 private:
130         spl::shared_ptr<impl> impl_;
131 };
132
133 }}