]> git.sesse.net Git - casparcg/blob - core/frame/frame.h
set svn:eol-style native on .h and .cpp files
[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
26 class mutable_frame sealed
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                                                 audio_buffer audio_buffer, 
38                                                 const void* tag, 
39                                                 const struct pixel_format_desc& desc);
40         ~mutable_frame();
41
42         // Methods
43
44         mutable_frame(mutable_frame&& other);
45         mutable_frame& operator=(mutable_frame&& other);
46
47         void swap(mutable_frame& other);
48                         
49         // Properties
50                         
51         const struct pixel_format_desc& pixel_format_desc() const;
52
53         const array<std::uint8_t>& image_data(std::size_t index = 0) const;
54         const core::audio_buffer& audio_data() const;
55
56         array<std::uint8_t>& image_data(std::size_t index = 0);
57         core::audio_buffer& audio_data();
58         
59         std::size_t width() const;
60         std::size_t height() const;
61                                                                 
62         const void* stream_tag() const;
63         const void* data_tag() const;
64                         
65 private:
66         struct impl;
67         spl::unique_ptr<impl> impl_;
68 };
69
70 class const_frame sealed
71 {
72 public: 
73
74         // Static Members
75
76         static const const_frame& empty();
77
78         // Constructors
79
80         explicit const_frame(const void* tag = nullptr);
81         explicit const_frame(boost::shared_future<array<const std::uint8_t>> image, 
82                                                 audio_buffer audio_buffer, 
83                                                 const void* tag, 
84                                                 const struct pixel_format_desc& desc);
85         const_frame(mutable_frame&& other);
86         ~const_frame();
87
88         // Methods
89
90         const_frame(const_frame&& other);
91         const_frame& operator=(const_frame&& other);
92         const_frame(const const_frame&);
93         const_frame& operator=(const const_frame& other);
94                                 
95         // Properties
96                                 
97         const struct pixel_format_desc& pixel_format_desc() const;
98
99         array<const std::uint8_t> image_data(int index = 0) const;
100         const core::audio_buffer& audio_data() const;
101                 
102         std::size_t width() const;
103         std::size_t height() const;
104         std::size_t size() const;
105                                                                 
106         const void* stream_tag() const;
107         const void* data_tag() const;
108
109         bool operator==(const const_frame& other);
110         bool operator!=(const const_frame& other);
111         bool operator<(const const_frame& other);
112         bool operator>(const const_frame& other);
113                         
114 private:
115         struct impl;
116         spl::shared_ptr<impl> impl_;
117 };
118
119 }}