Agora RTC Objective-C API Reference Refactor

NGIAgoraVideoFrame.h
Go to the documentation of this file.
1
2 // Copyright (c) 2020 Agora.io. All rights reserved
3
4 // This program is confidential and proprietary to Agora.io.
5 // And may not be copied, reproduced, modified, disclosed to others, published
6 // or used, in whole or in part, without the express prior written permission
7 // of Agora.io.
8
9 #pragma once // NOLINT(build/header_guard)
10
11 #include "AgoraBase.h"
12
13 #ifndef OPTIONAL_ENUM_CLASS
14 #if __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1800)
15 #define OPTIONAL_ENUM_CLASS enum class
16 #else
17 #define OPTIONAL_ENUM_CLASS enum
18 #endif
19 #endif
20
21 namespace agora {
22 namespace rtc {
23
29 struct TextureInfo {
30 OPTIONAL_ENUM_CLASS TextureType {
31 kGlTextureOes,
32 kGlTexture2D,
33 };
34 OPTIONAL_ENUM_CLASS EglContextType {
35 kEglContext10,
36 kEglContext14,
37 };
38
39 TextureType texture_type;
40 EglContextType context_type;
41 void* shared_context;
42 int texture_id;
43 float transform_matrix[16];
44 };
45
50 struct RawPixelBuffer {
51 OPTIONAL_ENUM_CLASS Format {
52 kUnknown,
53 kI420,
54 kI422,
55 kNV21,
56 kNV12,
57 kI010,
58 kRGBA,
59 kARGB,
60 kBGRA
61 };
62 Format format;
63 uint8_t* data;
64 int size;
65 };
66
67 struct PaddedRawPixelBuffer {
68 RawPixelBuffer::Format format;
69 uint8_t* data;
70 int size;
71 int stride;
72 PaddedRawPixelBuffer()
73 : data(NULL), size(0), stride(0) {}
74 };
75
76 struct ColorSpace {
77 enum PrimaryID {
78 // The indices are equal to the values specified in T-REC H.273 Table 2.
79 PRIMARYID_BT709 = 1,
80 PRIMARYID_UNSPECIFIED = 2,
81 PRIMARYID_BT470M = 4,
82 PRIMARYID_BT470BG = 5,
83 PRIMARYID_SMPTE170M = 6, // Identical to BT601
84 PRIMARYID_SMPTE240M = 7,
85 PRIMARYID_FILM = 8,
86 PRIMARYID_BT2020 = 9,
87 PRIMARYID_SMPTEST428 = 10,
88 PRIMARYID_SMPTEST431 = 11,
89 PRIMARYID_SMPTEST432 = 12,
90 PRIMARYID_JEDECP22 = 22, // Identical to EBU3213-E
91 };
92
93 enum RangeID {
94 // The indices are equal to the values specified at
95 // https://www.webmproject.org/docs/container/#colour for the element Range.
96 RANGEID_INVALID = 0,
97 // Limited Rec. 709 color range with RGB values ranging from 16 to 235.
98 RANGEID_LIMITED = 1,
99 // Full RGB color range with RGB valees from 0 to 255.
100 RANGEID_FULL = 2,
101 // Range is defined by MatrixCoefficients/TransferCharacteristics.
102 RANGEID_DERIVED = 3,
103 };
104
105 enum MatrixID {
106 // The indices are equal to the values specified in T-REC H.273 Table 4.
107 MATRIXID_RGB = 0,
108 MATRIXID_BT709 = 1,
109 MATRIXID_UNSPECIFIED = 2,
110 MATRIXID_FCC = 4,
111 MATRIXID_BT470BG = 5,
112 MATRIXID_SMPTE170M = 6,
113 MATRIXID_SMPTE240M = 7,
114 MATRIXID_YCOCG = 8,
115 MATRIXID_BT2020_NCL = 9,
116 MATRIXID_BT2020_CL = 10,
117 MATRIXID_SMPTE2085 = 11,
118 MATRIXID_CDNCLS = 12,
119 MATRIXID_CDCLS = 13,
120 MATRIXID_BT2100_ICTCP = 14,
121 };
122
123 enum TransferID {
124 // The indices are equal to the values specified in T-REC H.273 Table 3.
125 TRANSFERID_BT709 = 1,
126 TRANSFERID_UNSPECIFIED = 2,
127 TRANSFERID_GAMMA22 = 4,
128 TRANSFERID_GAMMA28 = 5,
129 TRANSFERID_SMPTE170M = 6,
130 TRANSFERID_SMPTE240M = 7,
131 TRANSFERID_LINEAR = 8,
132 TRANSFERID_LOG = 9,
133 TRANSFERID_LOG_SQRT = 10,
134 TRANSFERID_IEC61966_2_4 = 11,
135 TRANSFERID_BT1361_ECG = 12,
136 TRANSFERID_IEC61966_2_1 = 13,
137 TRANSFERID_BT2020_10 = 14,
138 TRANSFERID_BT2020_12 = 15,
139 TRANSFERID_SMPTEST2084 = 16,
140 TRANSFERID_SMPTEST428 = 17,
141 TRANSFERID_ARIB_STD_B67 = 18,
142 };
143
144 PrimaryID primaries;
145 TransferID transfer;
146 MatrixID matrix;
147 RangeID range;
148
149 ColorSpace()
150 : primaries(PRIMARYID_UNSPECIFIED), transfer(TRANSFERID_UNSPECIFIED),
151 matrix(MATRIXID_UNSPECIFIED), range(RANGEID_INVALID) {}
152 };
153
158 struct VideoFrameData {
159 OPTIONAL_ENUM_CLASS Type {
160 kRawPixels, // Raw pixels in memory
161 kTexture, // Deprecated Android: GL_TEXTURE_2D/GL_TEXTURE_OES
162 kCVPixelBuffer, // iOS: CVPixelBufferRef
163 kPaddedRawPixels, // Raw pixels with paddings
164 kTextureOES,// Android: GL_TEXTURE_OES
165 kTexture2D, // Android: GL_TEXTURE_2D
166 };
167 Type type;
168 union {
169 TextureInfo texture; // Android (To be supported)
170 RawPixelBuffer pixels; // All platform
171 void* cvpixelbuffer; // iOS (To be supported)
172 };
173 int width;
174 int height;
175 int rotation;
176 ColorSpace color_space;
177 int64_t timestamp_ms; // Capture time in milli-seconds
178 };
179
180 struct VideoFrameDataV2 : public VideoFrameData {
181 PaddedRawPixelBuffer padded_pixels; // All platform
182 };
183
184 OPTIONAL_ENUM_CLASS VideoFrameMetaDataType {
185 kAlphaChannel,
186 kScreenMetaInfo,
187 kVideoSourceType,
188 kFaceInfo,
189 kFaceCaptureInfo,
190 // Add other types afterwards
191 };
192
193 struct AlphaChannel {
194 uint8_t* data;
195 int size;
196 };
197
198 typedef int32_t VideoSourceType;
199
204 class IVideoFrame : public RefCountInterface {
205 public:
212 virtual int getVideoFrameData(VideoFrameData& data) const = 0;
213
223 virtual int fillVideoFrameData(const VideoFrameData& data) = 0;
224
234 virtual int getVideoFrameMetaData(VideoFrameMetaDataType type, void* data) = 0;
235
245 virtual int fillVideoFrameMetaData(VideoFrameMetaDataType type, const void* data) = 0;
246
247 protected:
248 ~IVideoFrame() {}
249 };
250
251 class IVideoFrameMemoryPool : public RefCountInterface {
252 public:
259 virtual agora::agora_refptr<IVideoFrame> createVideoFrame(
260 const VideoFrameData& data, const VideoFrameMetaDataType* metatypes = NULL, int count = 0) = 0;
261
262 protected:
263 virtual ~IVideoFrameMemoryPool() {}
264 };
265
266 } // namespace rtc
267 } // namespace agora
agora::rtc::ColorSpace::MATRIXID_RGB
@ MATRIXID_RGB
Definition: NGIAgoraVideoFrame.h:107
agora::rtc::TextureInfo::TextureType
OPTIONAL_ENUM_CLASS TextureType
Definition: NGIAgoraVideoFrame.h:30
agora::rtc::TextureInfo
Definition: NGIAgoraVideoFrame.h:29
agora::rtc::IVideoFrame::fillVideoFrameMetaData
virtual int fillVideoFrameMetaData(VideoFrameMetaDataType type, const void *data)=0
agora::rtc::ColorSpace::TRANSFERID_SMPTEST2084
@ TRANSFERID_SMPTEST2084
Definition: NGIAgoraVideoFrame.h:139
agora::rtc::IVideoFrameMemoryPool::~IVideoFrameMemoryPool
virtual ~IVideoFrameMemoryPool()
Definition: NGIAgoraVideoFrame.h:263
agora::rtc::ColorSpace::TRANSFERID_ARIB_STD_B67
@ TRANSFERID_ARIB_STD_B67
Definition: NGIAgoraVideoFrame.h:141
agora::rtc::ColorSpace::RANGEID_FULL
@ RANGEID_FULL
Definition: NGIAgoraVideoFrame.h:100
agora::rtc::ColorSpace::TRANSFERID_LINEAR
@ TRANSFERID_LINEAR
Definition: NGIAgoraVideoFrame.h:131
agora::rtc::ColorSpace::MATRIXID_BT709
@ MATRIXID_BT709
Definition: NGIAgoraVideoFrame.h:108
AgoraBase.h
agora::rtc::RawPixelBuffer::data
uint8_t * data
Definition: NGIAgoraVideoFrame.h:63
agora::rtc::ColorSpace::RANGEID_INVALID
@ RANGEID_INVALID
Definition: NGIAgoraVideoFrame.h:96
agora::rtc::ColorSpace::transfer
TransferID transfer
Definition: NGIAgoraVideoFrame.h:145
agora::agora_refptr
Definition: AgoraRefPtr.h:44
agora::rtc::VideoFrameData::timestamp_ms
int64_t timestamp_ms
Definition: NGIAgoraVideoFrame.h:177
agora::rtc::ColorSpace::PRIMARYID_SMPTEST431
@ PRIMARYID_SMPTEST431
Definition: NGIAgoraVideoFrame.h:88
agora::rtc::ColorSpace::TransferID
TransferID
Definition: NGIAgoraVideoFrame.h:123
agora::rtc::ColorSpace::primaries
PrimaryID primaries
Definition: NGIAgoraVideoFrame.h:144
agora::rtc::AlphaChannel
Definition: NGIAgoraVideoFrame.h:193
agora::rtc::ColorSpace::MATRIXID_BT2020_NCL
@ MATRIXID_BT2020_NCL
Definition: NGIAgoraVideoFrame.h:115
agora::rtc::VideoFrameDataV2::padded_pixels
PaddedRawPixelBuffer padded_pixels
Definition: NGIAgoraVideoFrame.h:181
agora::rtc::ColorSpace::TRANSFERID_IEC61966_2_1
@ TRANSFERID_IEC61966_2_1
Definition: NGIAgoraVideoFrame.h:136
agora::rtc::IVideoFrame::getVideoFrameData
virtual int getVideoFrameData(VideoFrameData &data) const =0
agora::rtc::ColorSpace::matrix
MatrixID matrix
Definition: NGIAgoraVideoFrame.h:146
agora::rtc::VideoFrameData::color_space
ColorSpace color_space
Definition: NGIAgoraVideoFrame.h:176
agora::rtc::ColorSpace::MatrixID
MatrixID
Definition: NGIAgoraVideoFrame.h:105
agora::rtc::ColorSpace::MATRIXID_SMPTE2085
@ MATRIXID_SMPTE2085
Definition: NGIAgoraVideoFrame.h:117
agora::rtc::ColorSpace::PRIMARYID_JEDECP22
@ PRIMARYID_JEDECP22
Definition: NGIAgoraVideoFrame.h:90
agora::rtc::TextureInfo::transform_matrix
float transform_matrix[16]
Definition: NGIAgoraVideoFrame.h:43
agora::rtc::ColorSpace::PRIMARYID_BT2020
@ PRIMARYID_BT2020
Definition: NGIAgoraVideoFrame.h:86
agora::rtc::VideoSourceType
int32_t VideoSourceType
Definition: NGIAgoraVideoFrame.h:198
agora::rtc::RawPixelBuffer::size
int size
Definition: NGIAgoraVideoFrame.h:64
agora::rtc::TextureInfo::shared_context
void * shared_context
Definition: NGIAgoraVideoFrame.h:41
agora::rtc::ColorSpace::MATRIXID_BT470BG
@ MATRIXID_BT470BG
Definition: NGIAgoraVideoFrame.h:111
agora
Definition: AgoraAtomicOps.h:21
agora::rtc::VideoFrameData
Definition: NGIAgoraVideoFrame.h:158
agora::rtc::ColorSpace::TRANSFERID_UNSPECIFIED
@ TRANSFERID_UNSPECIFIED
Definition: NGIAgoraVideoFrame.h:126
agora::rtc::ColorSpace::MATRIXID_UNSPECIFIED
@ MATRIXID_UNSPECIFIED
Definition: NGIAgoraVideoFrame.h:109
OPTIONAL_ENUM_CLASS
#define OPTIONAL_ENUM_CLASS
Definition: NGIAgoraVideoFrame.h:17
agora::rtc::VideoFrameData::rotation
int rotation
Definition: NGIAgoraVideoFrame.h:175
agora::rtc::ColorSpace::TRANSFERID_LOG_SQRT
@ TRANSFERID_LOG_SQRT
Definition: NGIAgoraVideoFrame.h:133
agora::rtc::ColorSpace::TRANSFERID_IEC61966_2_4
@ TRANSFERID_IEC61966_2_4
Definition: NGIAgoraVideoFrame.h:134
agora::rtc::ColorSpace::TRANSFERID_GAMMA28
@ TRANSFERID_GAMMA28
Definition: NGIAgoraVideoFrame.h:128
agora::rtc::ColorSpace::TRANSFERID_SMPTE170M
@ TRANSFERID_SMPTE170M
Definition: NGIAgoraVideoFrame.h:129
agora::rtc::PaddedRawPixelBuffer::format
RawPixelBuffer::Format format
Definition: NGIAgoraVideoFrame.h:68
agora::rtc::ColorSpace::PRIMARYID_SMPTE240M
@ PRIMARYID_SMPTE240M
Definition: NGIAgoraVideoFrame.h:84
agora::rtc::ColorSpace::MATRIXID_CDCLS
@ MATRIXID_CDCLS
Definition: NGIAgoraVideoFrame.h:119
agora::rtc::IVideoFrameMemoryPool
Definition: NGIAgoraVideoFrame.h:251
agora::rtc::ColorSpace::PRIMARYID_UNSPECIFIED
@ PRIMARYID_UNSPECIFIED
Definition: NGIAgoraVideoFrame.h:80
agora::rtc::ColorSpace::PRIMARYID_BT709
@ PRIMARYID_BT709
Definition: NGIAgoraVideoFrame.h:79
agora::rtc::VideoFrameData::cvpixelbuffer
void * cvpixelbuffer
Definition: NGIAgoraVideoFrame.h:171
agora::rtc::ColorSpace::PRIMARYID_SMPTE170M
@ PRIMARYID_SMPTE170M
Definition: NGIAgoraVideoFrame.h:83
agora::rtc::ColorSpace::MATRIXID_YCOCG
@ MATRIXID_YCOCG
Definition: NGIAgoraVideoFrame.h:114
agora::rtc::VideoFrameData::height
int height
Definition: NGIAgoraVideoFrame.h:174
agora::rtc::RawPixelBuffer::Format
OPTIONAL_ENUM_CLASS Format
Definition: NGIAgoraVideoFrame.h:51
agora::rtc::ColorSpace::MATRIXID_SMPTE170M
@ MATRIXID_SMPTE170M
Definition: NGIAgoraVideoFrame.h:112
agora::rtc::VideoFrameMetaDataType
OPTIONAL_ENUM_CLASS VideoFrameMetaDataType
Definition: NGIAgoraVideoFrame.h:184
agora::rtc::ColorSpace::RANGEID_DERIVED
@ RANGEID_DERIVED
Definition: NGIAgoraVideoFrame.h:102
agora::rtc::PaddedRawPixelBuffer::PaddedRawPixelBuffer
PaddedRawPixelBuffer()
Definition: NGIAgoraVideoFrame.h:72
agora::rtc::ColorSpace::TRANSFERID_SMPTE240M
@ TRANSFERID_SMPTE240M
Definition: NGIAgoraVideoFrame.h:130
agora::rtc::ColorSpace::MATRIXID_BT2020_CL
@ MATRIXID_BT2020_CL
Definition: NGIAgoraVideoFrame.h:116
agora::rtc::PaddedRawPixelBuffer::size
int size
Definition: NGIAgoraVideoFrame.h:70
agora::rtc::ColorSpace::TRANSFERID_SMPTEST428
@ TRANSFERID_SMPTEST428
Definition: NGIAgoraVideoFrame.h:140
agora::rtc::ColorSpace
Definition: NGIAgoraVideoFrame.h:76
agora::rtc::ColorSpace::TRANSFERID_BT1361_ECG
@ TRANSFERID_BT1361_ECG
Definition: NGIAgoraVideoFrame.h:135
agora::rtc::ColorSpace::TRANSFERID_LOG
@ TRANSFERID_LOG
Definition: NGIAgoraVideoFrame.h:132
agora::rtc::TextureInfo::texture_type
TextureType texture_type
Definition: NGIAgoraVideoFrame.h:39
agora::rtc::ColorSpace::PRIMARYID_BT470M
@ PRIMARYID_BT470M
Definition: NGIAgoraVideoFrame.h:81
agora::rtc::AlphaChannel::size
int size
Definition: NGIAgoraVideoFrame.h:195
agora::rtc::PaddedRawPixelBuffer::data
uint8_t * data
Definition: NGIAgoraVideoFrame.h:69
agora::rtc::ColorSpace::TRANSFERID_BT2020_12
@ TRANSFERID_BT2020_12
Definition: NGIAgoraVideoFrame.h:138
agora::rtc::PaddedRawPixelBuffer
Definition: NGIAgoraVideoFrame.h:67
agora::rtc::ColorSpace::TRANSFERID_GAMMA22
@ TRANSFERID_GAMMA22
Definition: NGIAgoraVideoFrame.h:127
agora::rtc::ColorSpace::MATRIXID_SMPTE240M
@ MATRIXID_SMPTE240M
Definition: NGIAgoraVideoFrame.h:113
agora::rtc::ColorSpace::PRIMARYID_SMPTEST428
@ PRIMARYID_SMPTEST428
Definition: NGIAgoraVideoFrame.h:87
agora::rtc::VideoFrameData::pixels
RawPixelBuffer pixels
Definition: NGIAgoraVideoFrame.h:170
agora::rtc::ColorSpace::PRIMARYID_FILM
@ PRIMARYID_FILM
Definition: NGIAgoraVideoFrame.h:85
agora::rtc::ColorSpace::MATRIXID_CDNCLS
@ MATRIXID_CDNCLS
Definition: NGIAgoraVideoFrame.h:118
agora::RefCountInterface
Definition: AgoraRefPtr.h:31
agora::rtc::VideoFrameDataV2
Definition: NGIAgoraVideoFrame.h:180
agora::rtc::IVideoFrame::fillVideoFrameData
virtual int fillVideoFrameData(const VideoFrameData &data)=0
agora::rtc::ColorSpace::ColorSpace
ColorSpace()
Definition: NGIAgoraVideoFrame.h:149
agora::rtc::RawPixelBuffer
Definition: NGIAgoraVideoFrame.h:50
agora::rtc::ColorSpace::TRANSFERID_BT709
@ TRANSFERID_BT709
Definition: NGIAgoraVideoFrame.h:125
agora::rtc::ColorSpace::TRANSFERID_BT2020_10
@ TRANSFERID_BT2020_10
Definition: NGIAgoraVideoFrame.h:137
agora::rtc::ColorSpace::PrimaryID
PrimaryID
Definition: NGIAgoraVideoFrame.h:77
agora::rtc::IVideoFrame
Definition: NGIAgoraVideoFrame.h:204
agora::rtc::VideoFrameData::type
Type type
Definition: NGIAgoraVideoFrame.h:167
agora::rtc::ColorSpace::RangeID
RangeID
Definition: NGIAgoraVideoFrame.h:93
agora::rtc::ColorSpace::PRIMARYID_BT470BG
@ PRIMARYID_BT470BG
Definition: NGIAgoraVideoFrame.h:82
agora::rtc::ColorSpace::RANGEID_LIMITED
@ RANGEID_LIMITED
Definition: NGIAgoraVideoFrame.h:98
agora::rtc::ColorSpace::MATRIXID_BT2100_ICTCP
@ MATRIXID_BT2100_ICTCP
Definition: NGIAgoraVideoFrame.h:120
agora::rtc::VideoFrameData::width
int width
Definition: NGIAgoraVideoFrame.h:173
agora::rtc::VideoFrameData::texture
TextureInfo texture
Definition: NGIAgoraVideoFrame.h:169
agora::rtc::ColorSpace::range
RangeID range
Definition: NGIAgoraVideoFrame.h:147
agora::rtc::ColorSpace::MATRIXID_FCC
@ MATRIXID_FCC
Definition: NGIAgoraVideoFrame.h:110
agora::rtc::TextureInfo::context_type
EglContextType context_type
Definition: NGIAgoraVideoFrame.h:40
agora::rtc::IVideoFrame::~IVideoFrame
~IVideoFrame()
Definition: NGIAgoraVideoFrame.h:248
agora::rtc::TextureInfo::texture_id
int texture_id
Definition: NGIAgoraVideoFrame.h:42
agora::rtc::TextureInfo::EglContextType
OPTIONAL_ENUM_CLASS EglContextType
Definition: NGIAgoraVideoFrame.h:34
agora::rtc::IVideoFrameMemoryPool::createVideoFrame
virtual agora::agora_refptr< IVideoFrame > createVideoFrame(const VideoFrameData &data, const VideoFrameMetaDataType *metatypes=NULL, int count=0)=0
agora::rtc::ColorSpace::PRIMARYID_SMPTEST432
@ PRIMARYID_SMPTEST432
Definition: NGIAgoraVideoFrame.h:89
agora::rtc::PaddedRawPixelBuffer::stride
int stride
Definition: NGIAgoraVideoFrame.h:71
agora::rtc::VideoFrameData::Type
OPTIONAL_ENUM_CLASS Type
Definition: NGIAgoraVideoFrame.h:159
agora::rtc::RawPixelBuffer::format
Format format
Definition: NGIAgoraVideoFrame.h:62
agora::rtc::IVideoFrame::getVideoFrameMetaData
virtual int getVideoFrameMetaData(VideoFrameMetaDataType type, void *data)=0
agora::rtc::AlphaChannel::data
uint8_t * data
Definition: NGIAgoraVideoFrame.h:194