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
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
Definition: NGIAgoraVideoFrame.h:64
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:93
agora::media::base::ColorSpace
Definition: AgoraMediaBase.h:637
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:46
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:28
agora::rtc::IVideoFrame::fillVideoFrameData
virtual int fillVideoFrameData(const VideoFrameData &data)=0
agora::rtc::IVideoFrame
Definition: NGIAgoraVideoFrame.h:148