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
28 struct RawPixelBuffer {
29 OPTIONAL_ENUM_CLASS Format {
30 kUnknown,
31 kI420,
32 kI422,
33 kNV21,
34 kNV12,
35 kI010,
36 kRGBA,
37 kARGB,
38 kBGRA,
39 kABGR
40 };
41 Format format;
42 uint8_t* data;
43 int size;
44 };
45
46 struct PaddedRawPixelBuffer {
47 RawPixelBuffer::Format format;
48 uint8_t* data_y;
49 int stride_y;
50 uint8_t* data_u;
51 int stride_u;
52 uint8_t* data_v;
53 int stride_v;
54 PaddedRawPixelBuffer()
55 : data_y(NULL), stride_y(0), data_u(NULL), stride_u(0), data_v(NULL), stride_v(0) {}
56 };
57
58
64 struct TextureInfo {
65 OPTIONAL_ENUM_CLASS TextureType {
66 kGlTextureOes,
67 kGlTexture2D,
68 };
69 OPTIONAL_ENUM_CLASS EglContextType {
70 kEglContext10,
71 kEglContext14,
72 };
73
74 TextureType texture_type;
75 EglContextType context_type;
76 void* shared_context;
77 int texture_id;
78 int64_t fence_object;
79 int frame_buffer_id;
80 float transform_matrix[16];
81
82 // for double buffer data
83 RawPixelBuffer::Format raw_data_format;
84 uint8_t* raw_data;
85 int64_t raw_data_size;
86 int raw_data_stride;
87 };
88
93 struct VideoFrameData {
94 OPTIONAL_ENUM_CLASS Type {
95 kRawPixels, // Raw pixels in memory
96 kTexture, // Deprecated Android: GL_TEXTURE_2D/GL_TEXTURE_OES
97 kCVPixelBuffer, // iOS: CVPixelBufferRef
98 kPaddedRawPixels, // Raw pixels with paddings
99 kTextureOES,// Android: GL_TEXTURE_OES
100 kTexture2D, // Android: GL_TEXTURE_2D
101 };
102 Type type;
103 union {
104 TextureInfo texture; // Android (To be supported)
105 RawPixelBuffer pixels; // All platform
106 void* cvpixelbuffer; // iOS (To be supported)
107 };
108 int width;
109 int height;
110 int rotation;
111 agora::media::base::ColorSpace color_space;
112 int64_t timestamp_ms; // Capture time in milli-seconds
113 };
114
115 struct VideoFrameDataV2 : public VideoFrameData {
116 PaddedRawPixelBuffer padded_pixels; // All platform
117 };
118
119 OPTIONAL_ENUM_CLASS VideoFrameMetaDataType {
120 kAlphaChannel,
121 kScreenMetaInfo,
122 kVideoSourceType,
123 kFaceInfo,
124 kFaceCaptureInfo,
125 kGravityRotation,
126 // Add other types afterwards
127 };
128
129 OPTIONAL_ENUM_CLASS VideoFrameGravityRotation {
130 kGravityRotation_Unknown = -1,
131 kGravityRotation_0 = 0,
132 kGravityRotation_90 = 90,
133 kGravityRotation_180 = 180,
134 kGravityRotation_270 = 270
135 };
136
137 struct AlphaChannel {
138 uint8_t* data;
139 int size;
140 };
141
142 typedef int32_t VideoSourceType;
143
148 class IVideoFrame : public RefCountInterface {
149 public:
156 virtual int getVideoFrameData(VideoFrameData& data) const = 0;
157
167 virtual int fillVideoFrameData(const VideoFrameData& data) = 0;
168
178 virtual int getVideoFrameMetaData(VideoFrameMetaDataType type, void* data) = 0;
179
189 virtual int fillVideoFrameMetaData(VideoFrameMetaDataType type, const void* data) = 0;
190
191 protected:
192 ~IVideoFrame() {}
193 };
194
195 class IVideoFrameMemoryPool : public RefCountInterface {
196 public:
203 virtual agora::agora_refptr<IVideoFrame> createVideoFrame(
204 const VideoFrameData& data, const VideoFrameMetaDataType* metatypes = NULL, int count = 0) = 0;
205
206 protected:
207 virtual ~IVideoFrameMemoryPool() {}
208 };
209
210 } // namespace rtc
211 } // namespace agora
agora::rtc::TextureInfo::TextureType
OPTIONAL_ENUM_CLASS TextureType
Definition: NGIAgoraVideoFrame.h:65
agora::rtc::TextureInfo::fence_object
int64_t fence_object
Definition: NGIAgoraVideoFrame.h:78
agora::rtc::TextureInfo
Definition: NGIAgoraVideoFrame.h:64
agora::rtc::IVideoFrame::fillVideoFrameMetaData
virtual int fillVideoFrameMetaData(VideoFrameMetaDataType type, const void *data)=0
agora::rtc::IVideoFrameMemoryPool::~IVideoFrameMemoryPool
virtual ~IVideoFrameMemoryPool()
Definition: NGIAgoraVideoFrame.h:207
agora::rtc::TextureInfo::raw_data
uint8_t * raw_data
Definition: NGIAgoraVideoFrame.h:84
AgoraBase.h
agora::rtc::RawPixelBuffer::data
uint8_t * data
Definition: NGIAgoraVideoFrame.h:42
agora::rtc::TextureInfo::raw_data_stride
int raw_data_stride
Definition: NGIAgoraVideoFrame.h:86
agora::agora_refptr
Definition: AgoraRefPtr.h:44
agora::rtc::VideoFrameData::timestamp_ms
int64_t timestamp_ms
Definition: NGIAgoraVideoFrame.h:112
agora::rtc::VideoFrameData::color_space
agora::media::base::ColorSpace color_space
Definition: NGIAgoraVideoFrame.h:111
agora::rtc::AlphaChannel
Definition: NGIAgoraVideoFrame.h:137
agora::rtc::VideoFrameDataV2::padded_pixels
PaddedRawPixelBuffer padded_pixels
Definition: NGIAgoraVideoFrame.h:116
agora::rtc::IVideoFrame::getVideoFrameData
virtual int getVideoFrameData(VideoFrameData &data) const =0
agora::rtc::TextureInfo::transform_matrix
float transform_matrix[16]
Definition: NGIAgoraVideoFrame.h:80
agora::rtc::VideoSourceType
int32_t VideoSourceType
Definition: NGIAgoraVideoFrame.h:142
agora::rtc::RawPixelBuffer::size
int size
Definition: NGIAgoraVideoFrame.h:43
agora::rtc::TextureInfo::shared_context
void * shared_context
Definition: NGIAgoraVideoFrame.h:76
agora::rtc::VideoFrameGravityRotation
OPTIONAL_ENUM_CLASS VideoFrameGravityRotation
Definition: NGIAgoraVideoFrame.h:129
agora
Definition: AgoraAtomicOps.h:21
agora::rtc::VideoFrameData
Definition: NGIAgoraVideoFrame.h:93
OPTIONAL_ENUM_CLASS
#define OPTIONAL_ENUM_CLASS
Definition: NGIAgoraVideoFrame.h:17
agora::rtc::VideoFrameData::rotation
int rotation
Definition: NGIAgoraVideoFrame.h:110
agora::media::base::ColorSpace
Definition: AgoraMediaBase.h:637
agora::rtc::TextureInfo::raw_data_format
RawPixelBuffer::Format raw_data_format
Definition: NGIAgoraVideoFrame.h:83
agora::rtc::PaddedRawPixelBuffer::format
RawPixelBuffer::Format format
Definition: NGIAgoraVideoFrame.h:47
agora::rtc::IVideoFrameMemoryPool
Definition: NGIAgoraVideoFrame.h:195
agora::rtc::VideoFrameData::cvpixelbuffer
void * cvpixelbuffer
Definition: NGIAgoraVideoFrame.h:106
agora::rtc::VideoFrameData::height
int height
Definition: NGIAgoraVideoFrame.h:109
agora::rtc::RawPixelBuffer::Format
OPTIONAL_ENUM_CLASS Format
Definition: NGIAgoraVideoFrame.h:29
agora::rtc::VideoFrameMetaDataType
OPTIONAL_ENUM_CLASS VideoFrameMetaDataType
Definition: NGIAgoraVideoFrame.h:119
agora::rtc::PaddedRawPixelBuffer::PaddedRawPixelBuffer
PaddedRawPixelBuffer()
Definition: NGIAgoraVideoFrame.h:54
agora::rtc::PaddedRawPixelBuffer::data_v
uint8_t * data_v
Definition: NGIAgoraVideoFrame.h:52
agora::rtc::PaddedRawPixelBuffer::stride_u
int stride_u
Definition: NGIAgoraVideoFrame.h:51
agora::rtc::PaddedRawPixelBuffer::data_y
uint8_t * data_y
Definition: NGIAgoraVideoFrame.h:48
agora::rtc::TextureInfo::texture_type
TextureType texture_type
Definition: NGIAgoraVideoFrame.h:74
agora::rtc::AlphaChannel::size
int size
Definition: NGIAgoraVideoFrame.h:139
agora::rtc::PaddedRawPixelBuffer
Definition: NGIAgoraVideoFrame.h:46
agora::rtc::VideoFrameData::pixels
RawPixelBuffer pixels
Definition: NGIAgoraVideoFrame.h:105
agora::RefCountInterface
Definition: AgoraRefPtr.h:31
agora::rtc::VideoFrameDataV2
Definition: NGIAgoraVideoFrame.h:115
agora::rtc::IVideoFrame::fillVideoFrameData
virtual int fillVideoFrameData(const VideoFrameData &data)=0
agora::rtc::RawPixelBuffer
Definition: NGIAgoraVideoFrame.h:28
agora::rtc::PaddedRawPixelBuffer::data_u
uint8_t * data_u
Definition: NGIAgoraVideoFrame.h:50
agora::rtc::IVideoFrame
Definition: NGIAgoraVideoFrame.h:148
agora::rtc::PaddedRawPixelBuffer::stride_v
int stride_v
Definition: NGIAgoraVideoFrame.h:53
agora::rtc::VideoFrameData::type
Type type
Definition: NGIAgoraVideoFrame.h:102
agora::rtc::VideoFrameData::width
int width
Definition: NGIAgoraVideoFrame.h:108
agora::rtc::VideoFrameData::texture
TextureInfo texture
Definition: NGIAgoraVideoFrame.h:104
agora::rtc::TextureInfo::frame_buffer_id
int frame_buffer_id
Definition: NGIAgoraVideoFrame.h:79
agora::rtc::TextureInfo::context_type
EglContextType context_type
Definition: NGIAgoraVideoFrame.h:75
agora::rtc::IVideoFrame::~IVideoFrame
~IVideoFrame()
Definition: NGIAgoraVideoFrame.h:192
agora::rtc::TextureInfo::texture_id
int texture_id
Definition: NGIAgoraVideoFrame.h:77
agora::rtc::TextureInfo::EglContextType
OPTIONAL_ENUM_CLASS EglContextType
Definition: NGIAgoraVideoFrame.h:69
agora::rtc::PaddedRawPixelBuffer::stride_y
int stride_y
Definition: NGIAgoraVideoFrame.h:49
agora::rtc::IVideoFrameMemoryPool::createVideoFrame
virtual agora::agora_refptr< IVideoFrame > createVideoFrame(const VideoFrameData &data, const VideoFrameMetaDataType *metatypes=NULL, int count=0)=0
agora::rtc::VideoFrameData::Type
OPTIONAL_ENUM_CLASS Type
Definition: NGIAgoraVideoFrame.h:94
agora::rtc::RawPixelBuffer::format
Format format
Definition: NGIAgoraVideoFrame.h:41
agora::rtc::IVideoFrame::getVideoFrameMetaData
virtual int getVideoFrameMetaData(VideoFrameMetaDataType type, void *data)=0
agora::rtc::TextureInfo::raw_data_size
int64_t raw_data_size
Definition: NGIAgoraVideoFrame.h:85
agora::rtc::AlphaChannel::data
uint8_t * data
Definition: NGIAgoraVideoFrame.h:138