]> git.sesse.net Git - casparcg/blob - core/frame/frame.h
Merge branch '2.1.0' of https://github.com/CasparCG/Server into 2.1.0
[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
12 #include <boost/range.hpp>
13 #include <boost/any.hpp>
14
15 #include <tbb/cache_aligned_allocator.h>
16
17 #include <cstddef>
18 #include <cstdint>
19
20 FORWARD1(boost, template<typename> class shared_future);
21
22 namespace caspar { namespace core {
23         
24 typedef std::vector<int32_t, tbb::cache_aligned_allocator<int32_t>> audio_buffer;
25 class frame_geometry;
26
27 class mutable_frame /* final */
28 {
29         mutable_frame(const mutable_frame&);
30         mutable_frame& operator=(const mutable_frame&);
31 public: 
32
33         // Static Members
34
35         // Constructors
36
37         explicit mutable_frame(std::vector<array<std::uint8_t>> image_buffers, 
38                                                 audio_buffer audio_buffer, 
39                                                 const void* tag, 
40                                                 const struct pixel_format_desc& desc);
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 struct pixel_format_desc& pixel_format_desc() const;
53
54         const array<std::uint8_t>& image_data(std::size_t index = 0) const;
55         const core::audio_buffer& audio_data() const;
56
57         array<std::uint8_t>& image_data(std::size_t index = 0);
58         core::audio_buffer& audio_data();
59         
60         std::size_t width() const;
61         std::size_t height() const;
62                                                                 
63         const void* stream_tag() const;
64         const void* data_tag() const;
65
66         const core::frame_geometry& geometry() const;
67         void set_geometry(const frame_geometry& g);
68                         
69 private:
70         struct impl;
71         spl::unique_ptr<impl> impl_;
72 };
73
74 class const_frame /* final */
75 {
76 public: 
77
78         // Static Members
79
80         static const const_frame& empty();
81
82         // Constructors
83
84         explicit const_frame(const void* tag = nullptr);
85         explicit const_frame(boost::shared_future<array<const std::uint8_t>> image, 
86                                                 audio_buffer audio_buffer, 
87                                                 const void* tag, 
88                                                 const struct pixel_format_desc& desc);
89         const_frame(mutable_frame&& other);
90         ~const_frame();
91
92         // Methods
93
94         const_frame(const_frame&& other);
95         const_frame& operator=(const_frame&& other);
96         const_frame(const const_frame&);
97         const_frame& operator=(const const_frame& other);
98                                 
99         // Properties
100                                 
101         const struct pixel_format_desc& pixel_format_desc() const;
102
103         array<const std::uint8_t> image_data(int index = 0) const;
104         const core::audio_buffer& audio_data() const;
105                 
106         std::size_t width() const;
107         std::size_t height() const;
108         std::size_t size() const;
109                                                                 
110         const void* stream_tag() const;
111         const void* data_tag() const;
112
113         const core::frame_geometry& geometry() const;
114         void set_geometry(const frame_geometry& g);
115
116         bool operator==(const const_frame& other);
117         bool operator!=(const const_frame& other);
118         bool operator<(const const_frame& other);
119         bool operator>(const const_frame& other);
120                         
121 private:
122         struct impl;
123         spl::shared_ptr<impl> impl_;
124 };
125
126 }}