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