Agora Java API Reference for Android
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  int frame_buffer_id;
45  float transform_matrix[16];
46 };
47 
53  OPTIONAL_ENUM_CLASS Format {
54  kUnknown,
55  kI420,
56  kI422,
57  kNV21,
58  kNV12,
59  kI010,
60  kRGBA,
61  kARGB,
62  kBGRA,
63  kABGR
64  };
65  Format format;
66  uint8_t* data;
67  int size;
68 };
69 
71  RawPixelBuffer::Format format;
72  uint8_t* data;
73  int size;
74  int stride;
75  int width;
76  int height;
77  uint8_t* data_y;
78  int stride_y;
79  uint8_t* data_u;
80  int stride_u;
81  uint8_t* data_v;
82  int stride_v;
84  : data(NULL), size(0), stride(0), width(0), height(0), data_y(NULL), stride_y(0),
85  data_u(NULL), stride_u(0), data_v(NULL), stride_v(0) {}
86 };
87 
93  OPTIONAL_ENUM_CLASS Type {
94  kRawPixels, // Raw pixels in memory
95  kTexture, // Deprecated Android: GL_TEXTURE_2D/GL_TEXTURE_OES
96  kCVPixelBuffer, // iOS: CVPixelBufferRef
97  kPaddedRawPixels, // Raw pixels with paddings
98  kTextureOES,// Android: GL_TEXTURE_OES
99  kTexture2D, // Android: GL_TEXTURE_2D
100  kDoubleBuffer, //Android: double buffer
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 
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 
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 
196  public:
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
Definition: NGIAgoraVideoFrame.h:29
agora::agora_refptr
Definition: AgoraRefPtr.h:44
agora::rtc::IVideoFrameMemoryPool::createVideoFrame
virtual agora::agora_refptr< IVideoFrame > createVideoFrame(const VideoFrameData &data, const VideoFrameMetaDataType *metatypes=NULL, int count=0)=0
agora::rtc::AlphaChannel
Definition: NGIAgoraVideoFrame.h:137
agora::rtc::VideoFrameData
Definition: NGIAgoraVideoFrame.h:92
agora::media::base::ColorSpace
Definition: AgoraMediaBase.h:638
agora::rtc::IVideoFrame::getVideoFrameMetaData
virtual int getVideoFrameMetaData(VideoFrameMetaDataType type, void *data)=0
agora::rtc::IVideoFrameMemoryPool
Definition: NGIAgoraVideoFrame.h:195
agora::rtc::IVideoFrame::getVideoFrameData
virtual int getVideoFrameData(VideoFrameData &data) const =0
agora::rtc::PaddedRawPixelBuffer
Definition: NGIAgoraVideoFrame.h:70
agora::rtc::IVideoFrame::fillVideoFrameMetaData
virtual int fillVideoFrameMetaData(VideoFrameMetaDataType type, const void *data)=0
agora::RefCountInterface
Definition: AgoraRefPtr.h:31
agora::rtc::VideoFrameDataV2
Definition: NGIAgoraVideoFrame.h:115
agora::rtc::RawPixelBuffer
Definition: NGIAgoraVideoFrame.h:52
agora::rtc::IVideoFrame::fillVideoFrameData
virtual int fillVideoFrameData(const VideoFrameData &data)=0
agora::rtc::IVideoFrame
Definition: NGIAgoraVideoFrame.h:148