Agora C++ API Reference for All Platforms

Loading...
Searching...
No Matches
NGIAgoraVideoFrame.h
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 int64_t fence_object;
44 float transform_matrix[16];
45};
46
51 struct RawPixelBuffer {
52 OPTIONAL_ENUM_CLASS Format {
53 kUnknown,
54 kI420,
55 kI422,
56 kNV21,
57 kNV12,
58 kI010,
59 kRGBA,
60 kARGB,
61 kBGRA
62 };
63 Format format;
64 uint8_t* data;
65 int size;
66};
67
68 struct PaddedRawPixelBuffer {
69 RawPixelBuffer::Format format;
70 uint8_t* data;
71 int size;
72 int stride;
73 PaddedRawPixelBuffer()
74 : data(NULL), size(0), stride(0) {}
75};
76
81 struct VideoFrameData {
82 OPTIONAL_ENUM_CLASS Type {
83 kRawPixels, // Raw pixels in memory
84 kTexture, // Deprecated Android: GL_TEXTURE_2D/GL_TEXTURE_OES
85 kCVPixelBuffer, // iOS: CVPixelBufferRef
86 kPaddedRawPixels, // Raw pixels with paddings
87 kTextureOES,// Android: GL_TEXTURE_OES
88 kTexture2D, // Android: GL_TEXTURE_2D
89 kDoubleBuffer, //Android: double buffer
90 };
91 Type type;
92 union {
93 TextureInfo texture; // Android (To be supported)
94 RawPixelBuffer pixels; // All platform
95 void* cvpixelbuffer; // iOS (To be supported)
96 };
97 int width;
98 int height;
99 int rotation;
100 agora::media::base::ColorSpace color_space;
101 int64_t timestamp_ms; // Capture time in milli-seconds
102};
103
104 struct VideoFrameDataV2 : public VideoFrameData {
105 PaddedRawPixelBuffer padded_pixels; // All platform
106};
107
108OPTIONAL_ENUM_CLASS VideoFrameMetaDataType {
109 kAlphaChannel,
110 kScreenMetaInfo,
111 kVideoSourceType,
112 kFaceInfo,
113 kFaceCaptureInfo,
114 kGravityRotation,
115 // Add other types afterwards
116};
117
118OPTIONAL_ENUM_CLASS VideoFrameGravityRotation {
119 kGravityRotation_Unknown = -1,
120 kGravityRotation_0 = 0,
121 kGravityRotation_90 = 90,
122 kGravityRotation_180 = 180,
123 kGravityRotation_270 = 270
124};
125
126 struct AlphaChannel {
127 uint8_t* data;
128 int size;
129};
130
131 typedef int32_t VideoSourceType;
132
137 class IVideoFrame : public RefCountInterface {
138 public:
145 virtual int getVideoFrameData(VideoFrameData& data) const = 0;
146
156 virtual int fillVideoFrameData(const VideoFrameData& data) = 0;
157
167 virtual int getVideoFrameMetaData(VideoFrameMetaDataType type, void* data) = 0;
168
178 virtual int fillVideoFrameMetaData(VideoFrameMetaDataType type, const void* data) = 0;
179
180 protected:
181 ~IVideoFrame() {}
182};
183
184 class IVideoFrameMemoryPool : public RefCountInterface {
185 public:
192 virtual agora::agora_refptr<IVideoFrame> createVideoFrame(
193 const VideoFrameData& data, const VideoFrameMetaDataType* metatypes = NULL, int count = 0) = 0;
194
195 protected:
196 virtual ~IVideoFrameMemoryPool() {}
197};
198
199} // namespace rtc
200} // namespace agora
agora::RefCountInterface
Definition AgoraRefPtr.h:31
agora::agora_refptr
Definition AgoraRefPtr.h:44
agora::rtc::IVideoFrame
Definition NGIAgoraVideoFrame.h:137
agora::rtc::IVideoFrame::getVideoFrameMetaData
virtual int getVideoFrameMetaData(VideoFrameMetaDataType type, void *data)=0
agora::rtc::IVideoFrame::~IVideoFrame
~IVideoFrame()
Definition NGIAgoraVideoFrame.h:181
agora::rtc::IVideoFrame::fillVideoFrameData
virtual int fillVideoFrameData(const VideoFrameData &data)=0
agora::rtc::IVideoFrame::getVideoFrameData
virtual int getVideoFrameData(VideoFrameData &data) const =0
agora::rtc::IVideoFrame::fillVideoFrameMetaData
virtual int fillVideoFrameMetaData(VideoFrameMetaDataType type, const void *data)=0
agora::rtc::IVideoFrameMemoryPool
Definition NGIAgoraVideoFrame.h:184
agora::rtc::IVideoFrameMemoryPool::~IVideoFrameMemoryPool
virtual ~IVideoFrameMemoryPool()
Definition NGIAgoraVideoFrame.h:196
agora::rtc::IVideoFrameMemoryPool::createVideoFrame
virtual agora::agora_refptr< IVideoFrame > createVideoFrame(const VideoFrameData &data, const VideoFrameMetaDataType *metatypes=NULL, int count=0)=0
agora::rtc
Definition AgoraExtensionVersion.h:12
agora::rtc::VideoFrameMetaDataType
OPTIONAL_ENUM_CLASS VideoFrameMetaDataType
Definition NGIAgoraVideoFrame.h:108
agora::rtc::VideoSourceType
int32_t VideoSourceType
Definition NGIAgoraVideoFrame.h:131
agora::rtc::VideoFrameGravityRotation
OPTIONAL_ENUM_CLASS VideoFrameGravityRotation
Definition NGIAgoraVideoFrame.h:118
agora
Definition AgoraAtomicOps.h:21
agora::media::base::ColorSpace
Definition AgoraMediaBase.h:582
agora::rtc::AlphaChannel
Definition NGIAgoraVideoFrame.h:126
agora::rtc::AlphaChannel::size
int size
Definition NGIAgoraVideoFrame.h:128
agora::rtc::AlphaChannel::data
uint8_t * data
Definition NGIAgoraVideoFrame.h:127
agora::rtc::PaddedRawPixelBuffer
Definition NGIAgoraVideoFrame.h:68
agora::rtc::PaddedRawPixelBuffer::size
int size
Definition NGIAgoraVideoFrame.h:71
agora::rtc::PaddedRawPixelBuffer::data
uint8_t * data
Definition NGIAgoraVideoFrame.h:70
agora::rtc::PaddedRawPixelBuffer::stride
int stride
Definition NGIAgoraVideoFrame.h:72
agora::rtc::PaddedRawPixelBuffer::format
RawPixelBuffer::Format format
Definition NGIAgoraVideoFrame.h:69
agora::rtc::PaddedRawPixelBuffer::PaddedRawPixelBuffer
PaddedRawPixelBuffer()
Definition NGIAgoraVideoFrame.h:73
agora::rtc::RawPixelBuffer
Definition NGIAgoraVideoFrame.h:51
agora::rtc::RawPixelBuffer::format
Format format
Definition NGIAgoraVideoFrame.h:63
agora::rtc::RawPixelBuffer::Format
OPTIONAL_ENUM_CLASS Format
Definition NGIAgoraVideoFrame.h:52
agora::rtc::RawPixelBuffer::size
int size
Definition NGIAgoraVideoFrame.h:65
agora::rtc::RawPixelBuffer::data
uint8_t * data
Definition NGIAgoraVideoFrame.h:64
agora::rtc::TextureInfo
Definition NGIAgoraVideoFrame.h:29
agora::rtc::TextureInfo::TextureType
OPTIONAL_ENUM_CLASS TextureType
Definition NGIAgoraVideoFrame.h:30
agora::rtc::TextureInfo::texture_id
int texture_id
Definition NGIAgoraVideoFrame.h:42
agora::rtc::TextureInfo::fence_object
int64_t fence_object
Definition NGIAgoraVideoFrame.h:43
agora::rtc::TextureInfo::EglContextType
OPTIONAL_ENUM_CLASS EglContextType
Definition NGIAgoraVideoFrame.h:34
agora::rtc::TextureInfo::shared_context
void * shared_context
Definition NGIAgoraVideoFrame.h:41
agora::rtc::TextureInfo::context_type
EglContextType context_type
Definition NGIAgoraVideoFrame.h:40
agora::rtc::TextureInfo::texture_type
TextureType texture_type
Definition NGIAgoraVideoFrame.h:39
agora::rtc::TextureInfo::transform_matrix
float transform_matrix[16]
Definition NGIAgoraVideoFrame.h:44
agora::rtc::VideoFrameData
Definition NGIAgoraVideoFrame.h:81
agora::rtc::VideoFrameData::texture
TextureInfo texture
Definition NGIAgoraVideoFrame.h:93
agora::rtc::VideoFrameData::width
int width
Definition NGIAgoraVideoFrame.h:97
agora::rtc::VideoFrameData::rotation
int rotation
Definition NGIAgoraVideoFrame.h:99
agora::rtc::VideoFrameData::color_space
agora::media::base::ColorSpace color_space
Definition NGIAgoraVideoFrame.h:100
agora::rtc::VideoFrameData::pixels
RawPixelBuffer pixels
Definition NGIAgoraVideoFrame.h:94
agora::rtc::VideoFrameData::timestamp_ms
int64_t timestamp_ms
Definition NGIAgoraVideoFrame.h:101
agora::rtc::VideoFrameData::cvpixelbuffer
void * cvpixelbuffer
Definition NGIAgoraVideoFrame.h:95
agora::rtc::VideoFrameData::Type
OPTIONAL_ENUM_CLASS Type
Definition NGIAgoraVideoFrame.h:82
agora::rtc::VideoFrameData::height
int height
Definition NGIAgoraVideoFrame.h:98
agora::rtc::VideoFrameData::type
Type type
Definition NGIAgoraVideoFrame.h:91
agora::rtc::VideoFrameDataV2
Definition NGIAgoraVideoFrame.h:104
agora::rtc::VideoFrameDataV2::padded_pixels
PaddedRawPixelBuffer padded_pixels
Definition NGIAgoraVideoFrame.h:105