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 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 };
90 Type type;
91 union {
92 TextureInfo texture; // Android (To be supported)
93 RawPixelBuffer pixels; // All platform
94 void* cvpixelbuffer; // iOS (To be supported)
95 };
96 int width;
97 int height;
98 int rotation;
99 agora::media::base::ColorSpace color_space;
100 int64_t timestamp_ms; // Capture time in milli-seconds
101 };
102
103 struct VideoFrameDataV2 : public VideoFrameData {
104 PaddedRawPixelBuffer padded_pixels; // All platform
105 };
106
107 OPTIONAL_ENUM_CLASS VideoFrameMetaDataType {
108 kAlphaChannel,
109 kScreenMetaInfo,
110 kVideoSourceType,
111 kFaceInfo,
112 kFaceCaptureInfo,
113 kGravityRotation,
114 // Add other types afterwards
115 };
116
117 OPTIONAL_ENUM_CLASS VideoFrameGravityRotation {
118 kGravityRotation_Unknown = -1,
119 kGravityRotation_0 = 0,
120 kGravityRotation_90 = 90,
121 kGravityRotation_180 = 180,
122 kGravityRotation_270 = 270
123 };
124
125 struct AlphaChannel {
126 uint8_t* data;
127 int size;
128 };
129
130 typedef int32_t VideoSourceType;
131
136 class IVideoFrame : public RefCountInterface {
137 public:
144 virtual int getVideoFrameData(VideoFrameData& data) const = 0;
145
155 virtual int fillVideoFrameData(const VideoFrameData& data) = 0;
156
166 virtual int getVideoFrameMetaData(VideoFrameMetaDataType type, void* data) = 0;
167
177 virtual int fillVideoFrameMetaData(VideoFrameMetaDataType type, const void* data) = 0;
178
179 protected:
180 ~IVideoFrame() {}
181 };
182
183 class IVideoFrameMemoryPool : public RefCountInterface {
184 public:
191 virtual agora::agora_refptr<IVideoFrame> createVideoFrame(
192 const VideoFrameData& data, const VideoFrameMetaDataType* metatypes = NULL, int count = 0) = 0;
193
194 protected:
195 virtual ~IVideoFrameMemoryPool() {}
196 };
197
198 } // namespace rtc
199 } // 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:125
agora::rtc::VideoFrameData
Definition: NGIAgoraVideoFrame.h:81
agora::media::base::ColorSpace
Definition: AgoraMediaBase.h:582
agora::rtc::IVideoFrame::getVideoFrameMetaData
virtual int getVideoFrameMetaData(VideoFrameMetaDataType type, void *data)=0
agora::rtc::IVideoFrameMemoryPool
Definition: NGIAgoraVideoFrame.h:183
agora::rtc::IVideoFrame::getVideoFrameData
virtual int getVideoFrameData(VideoFrameData &data) const =0
agora::rtc::PaddedRawPixelBuffer
Definition: NGIAgoraVideoFrame.h:68
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:103
agora::rtc::RawPixelBuffer
Definition: NGIAgoraVideoFrame.h:51
agora::rtc::IVideoFrame::fillVideoFrameData
virtual int fillVideoFrameData(const VideoFrameData &data)=0
agora::rtc::IVideoFrame
Definition: NGIAgoraVideoFrame.h:136