Agora C++ API Reference for All Platforms
Loading...
Searching...
No Matches
AgoraExtensions.h
1#pragma once
2#include "NGIAgoraMediaNode.h"
3
4namespace agora {
5namespace rtc {
13 public:
20 virtual void setEnabled(bool enable) = 0;
27 virtual bool isEnabled() const = 0;
38 virtual int setProperty(const char* key, const void* buf, int buf_size) = 0;
49 virtual int getProperty(const char* key, void* buf, int buf_size) const = 0;
57 virtual const char * getName() const = 0;
58
67 virtual int getPreferredSampleRate() { return 0; };
68
77 virtual int getPreferredChannelNumbers() { return 0; };
78
79 protected:
81};
82
84public:
85 class Control : public RefCountInterface {
86 public:
92 virtual int postEvent(const char* key, const char* value) = 0;
99 virtual void printLog(commons::LOG_LEVEL level, const char* format, ...) = 0;
100 };
101public:
107};
108
115 public:
117 kSync, // Indicates that video frame data will be exchanged via "adaptVideoFrame"
118 kAsync, // Indicates that video frame data will be exchanged via "pendVideoFrame" & "deliverVideoFrame"
119 };
120
122 kSuccess, // Video frame data is successfully processed
123 kBypass, // Video frame data should bypass the current filter and flow to its successsors
124 kDrop, // Video Frame data should be discarded
125 };
126
134 class Control : public RefCountInterface {
135 public:
153 virtual int postEvent(const char* key, const char* value) = 0;
160 virtual void printLog(commons::LOG_LEVEL level, const char* format, ...) = 0;
166 virtual void disableMe(int error, const char* msg) = 0;
167 };
168
176 virtual void getProcessMode(ProcessMode& mode, bool& independent_thread) = 0;
177
185 virtual int start(agora::agora_refptr<Control> control) = 0;
191 virtual int stop() = 0;
208 return OPTIONAL_PROCESSRESULT_SPECIFIER kBypass;
209 }
210
216 return OPTIONAL_PROCESSRESULT_SPECIFIER kBypass;
217 }
218 /* Occurs each time needs to get rotation apply.
219 *
220 * @return Determines whether to rotate.
221 * - true: need to rotate.
222 * - false: no rotate.
223 */
224 virtual bool getRotationApplied() { return false; }
225
226 // NOTE: The following two interfaces should never be overriden!
227 virtual bool isExtensionFilter() { return true; }
228 virtual bool adaptVideoFrame(
229 const media::base::VideoFrame& capturedFrame,
230 media::base::VideoFrame& adaptedFrame) {
231 return -ERR_NOT_SUPPORTED;
232 }
233};
234
236};
237
239 public:
241 kSuccess, // Video frame data is successfully processed
242 kBypass, // Video frame data should bypass the current filter and flow to its successsors
243 kDrop, // Video Frame data should be discarded
244 };
245
246 class Control : public RefCountInterface {
247 public:
253 virtual int postEvent(const char* key, const char* value) = 0;
260 virtual void printLog(commons::LOG_LEVEL level, const char* format, ...) = 0;
266 virtual void disableMe(int error, const char* msg) = 0;
272 virtual void ReportCounter(int32_t counter_id, int32_t value) = 0;
277 virtual int GetStats(int32_t counter_id) = 0;
278 };
279
280 virtual int start(agora::agora_refptr<Control> control) = 0;
281
282 virtual int stop() = 0;
283
284 virtual int setProperty(const char* key, const void* buf, size_t buf_size) { return -1; }
291 virtual ProcessResult convertAudioFrameToFaceInfo(const agora::media::base::AudioPcmFrame& inAudioFrame, char* outFaceInfo) {
292 return kBypass;
293 }
294};
295
297 public:
298 // Structure to hold settings for the video encoder.
300 uint32_t framerate = 0; // The frame rate of the video in frames per second (fps).
301 uint32_t bitrate_kbps = 0; // The bitrate of the video in kilobits per second (kbps).
302 uint32_t key_frame_interval = 0; // The interval between key frames in seconds (time between I-frames).
303 };
304 // Structure to hold settings for the video decoder.
306 media::base::VIDEO_PIXEL_FORMAT prefer_data_format; // The preferred pixel format for the decoded video.
307 };
308
309 uint16_t width = 0; // The width of the video frame in pixels.
310 uint16_t height = 0; // The height of the video frame in pixels.
311 VideoEncoderSettings encoder_settings; // An instance of VideoEncoderSettings to configure the encoder.
312 VideoDecoderSettings decoder_settings; // An instance of VideoDecoderSettings to configure the decoder.
313};
314
316public:
317 size_t length = 0; // The length of the encoded image data (in bytes).
318 uint8_t* buffer = nullptr; // Pointer to the buffer holding the encoded image data (raw bytes).
319 VIDEO_FRAME_TYPE frame_type = VIDEO_FRAME_TYPE_DELTA_FRAME; // The type of the video frame (e.g., key frame, delta frame).
320 uint32_t pts_ms = 0; // Presentation timestamp (PTS) in milliseconds, indicating when the frame should be displayed.
321 uint32_t dts_ms = 0; // Decoding timestamp (DTS) in milliseconds, indicating when the frame should be decoded.
322 uint32_t width = 0; // The width of the video frame in pixels.
323 uint32_t height = 0; // The height of the video frame in pixels.
324};
325
327 public:
328 // Destructor for the IExtensionDecoderCallback class.
335 virtual void onDecodedFrame(agora_refptr<IVideoFrame> frame, const char* extended_info_json) = 0;
342 virtual void printLog(commons::LOG_LEVEL level, const char* format, ...) = 0;
343};
344
346 public:
347 // Destructor for the IExtensionEncoderCallback class.
354 virtual void onEncodedImage(const ExtensionEncodedImage* img, const char* extended_info_json) = 0;
361 virtual void printLog(commons::LOG_LEVEL level, const char* format, ...) = 0;
362};
363
365 public:
373 virtual int initVideoEncoder(ExtensionVideoCodecSettings codec_settings) = 0;
390 virtual int encode(agora_refptr<IVideoFrame> frame, VIDEO_FRAME_TYPE frame_type) = 0;
397 virtual int32_t releaseVideoEncoder() = 0;
406 virtual int32_t setRates(uint32_t bitrate_kbps, uint32_t framerate) = 0;
412 virtual void querySupportCodecDataFormat(media::base::VIDEO_PIXEL_FORMAT* data_format, int& size) = 0;
423 virtual int setAdvancedCodecProperty(const char* key, const char* json_value) = 0;
434 virtual int getAdvancedCodecProperty(const char* key, char* json_value, int& length) const = 0;
435};
436
438 public:
446 virtual int initVideoDecoder(const ExtensionVideoCodecSettings& codec_settings) = 0;
454 virtual int decode(const ExtensionEncodedImage& data) = 0;
469 virtual int32_t releaseVideoDecoder() = 0;
475 virtual void querySupportCodecDataFormat(media::base::VIDEO_PIXEL_FORMAT* data_format, int& size) = 0;
476
487 virtual int setAdvancedCodecProperty(const char* key, const char* json_value) = 0;
498 virtual int getAdvancedCodecProperty(const char* key, char* json_value, int& length) const = 0;
499};
500}
501}
Definition AgoraRefPtr.h:31
Definition AgoraRefPtr.h:44
Definition AgoraExtensions.h:315
size_t length
Definition AgoraExtensions.h:317
uint32_t width
Definition AgoraExtensions.h:322
uint32_t height
Definition AgoraExtensions.h:323
uint8_t * buffer
Definition AgoraExtensions.h:318
uint32_t dts_ms
Definition AgoraExtensions.h:321
uint32_t pts_ms
Definition AgoraExtensions.h:320
VIDEO_FRAME_TYPE frame_type
Definition AgoraExtensions.h:319
Definition AgoraExtensions.h:296
uint16_t width
Definition AgoraExtensions.h:309
uint16_t height
Definition AgoraExtensions.h:310
VideoEncoderSettings encoder_settings
Definition AgoraExtensions.h:311
VideoDecoderSettings decoder_settings
Definition AgoraExtensions.h:312
Definition NGIAgoraMediaNode.h:27
Definition AgoraExtensions.h:12
virtual void setEnabled(bool enable)=0
virtual const char * getName() const =0
virtual int getPreferredSampleRate()
Definition AgoraExtensions.h:67
virtual int setProperty(const char *key, const void *buf, int buf_size)=0
virtual bool isEnabled() const =0
virtual int getPreferredChannelNumbers()
Definition AgoraExtensions.h:77
virtual int getProperty(const char *key, void *buf, int buf_size) const =0
~IAudioFilter()
Definition AgoraExtensions.h:80
Definition AgoraExtensions.h:85
virtual int postEvent(const char *key, const char *value)=0
Post an event and notify the end users.
virtual void printLog(commons::LOG_LEVEL level, const char *format,...)=0
print log to the SDK.
Definition AgoraExtensions.h:83
virtual void setExtensionControl(agora::agora_refptr< IAudioFilterV2::Control > control)=0
AgoraSDK set IAudioFilterV2::Control to filter.
Definition AgoraExtensions.h:326
virtual void onDecodedFrame(agora_refptr< IVideoFrame > frame, const char *extended_info_json)=0
virtual void printLog(commons::LOG_LEVEL level, const char *format,...)=0
virtual ~IExtensionDecoderCallback()
Definition AgoraExtensions.h:329
Definition AgoraExtensions.h:345
virtual ~IExtensionEncoderCallback()
Definition AgoraExtensions.h:348
virtual void printLog(commons::LOG_LEVEL level, const char *format,...)=0
virtual void onEncodedImage(const ExtensionEncodedImage *img, const char *extended_info_json)=0
Definition AgoraExtensions.h:437
virtual int getAdvancedCodecProperty(const char *key, char *json_value, int &length) const =0
virtual int32_t releaseVideoDecoder()=0
virtual int initVideoDecoder(const ExtensionVideoCodecSettings &codec_settings)=0
virtual int setAdvancedCodecProperty(const char *key, const char *json_value)=0
virtual int decode(const ExtensionEncodedImage &data)=0
virtual int32_t registerDecoderCallback(IExtensionDecoderCallback *callback)=0
virtual void querySupportCodecDataFormat(media::base::VIDEO_PIXEL_FORMAT *data_format, int &size)=0
Definition AgoraExtensions.h:364
virtual int32_t releaseVideoEncoder()=0
virtual int encode(agora_refptr< IVideoFrame > frame, VIDEO_FRAME_TYPE frame_type)=0
virtual void querySupportCodecDataFormat(media::base::VIDEO_PIXEL_FORMAT *data_format, int &size)=0
virtual int initVideoEncoder(ExtensionVideoCodecSettings codec_settings)=0
virtual int32_t registerEncoderCallback(IExtensionEncoderCallback *callback)=0
virtual int getAdvancedCodecProperty(const char *key, char *json_value, int &length) const =0
virtual int setAdvancedCodecProperty(const char *key, const char *json_value)=0
virtual int32_t setRates(uint32_t bitrate_kbps, uint32_t framerate)=0
Definition AgoraExtensions.h:134
virtual void disableMe(int error, const char *msg)=0
Ask SDK to disable the current filter if a fatal error is detected.
virtual void printLog(commons::LOG_LEVEL level, const char *format,...)=0
print log to the SDK.
virtual agora::agora_refptr< IVideoFrameMemoryPool > getMemoryPool()=0
Filter can invoke this function to get the IVideoFrameMemoryPool object if a new IVideoFrame data obj...
virtual ProcessResult deliverVideoFrame(agora::agora_refptr< IVideoFrame > frame)=0
Filter can invoke this function to deliver the processed frame to SDK if the Process Mode is designat...
virtual int postEvent(const char *key, const char *value)=0
Post an event and notify the end users.
Definition AgoraExtensions.h:114
virtual bool adaptVideoFrame(const media::base::VideoFrame &capturedFrame, media::base::VideoFrame &adaptedFrame)
Definition AgoraExtensions.h:228
virtual void getVideoFormatWanted(VideoFrameData::Type &type, RawPixelBuffer::Format &format)=0
SDK will invoke this API every time before sending data to the filter. Filter can desigante the type ...
virtual bool isExtensionFilter()
Definition AgoraExtensions.h:227
virtual ProcessResult adaptVideoFrame(agora::agora_refptr< IVideoFrame > in, agora::agora_refptr< IVideoFrame > &out)
SDK will invoke this API to send video frame to the filter if process mode is "Sync".
Definition AgoraExtensions.h:215
virtual ProcessResult pendVideoFrame(agora::agora_refptr< IVideoFrame > frame)
SDK will invoke this API to send video frame to the filter if process mode is "Async"....
Definition AgoraExtensions.h:207
ProcessMode
Definition AgoraExtensions.h:116
@ kAsync
Definition AgoraExtensions.h:118
@ kSync
Definition AgoraExtensions.h:117
virtual int stop()=0
SDK will invoke this API when the data stream is about to stop. Filter can perform cleanup jobs in th...
virtual int start(agora::agora_refptr< Control > control)=0
SDK will invoke this API before feeding video frame data to the filter. Filter can perform its initia...
virtual bool getRotationApplied()
Definition AgoraExtensions.h:224
ProcessResult
Definition AgoraExtensions.h:121
@ kSuccess
Definition AgoraExtensions.h:122
@ kDrop
Definition AgoraExtensions.h:124
@ kBypass
Definition AgoraExtensions.h:123
virtual void getProcessMode(ProcessMode &mode, bool &independent_thread)=0
SDK will invoke this API first to get the filter's requested process mode ProcessMode.
Definition AgoraExtensions.h:235
Definition AgoraExtensions.h:246
virtual void disableMe(int error, const char *msg)=0
Ask SDK to disable the current filter if a fatal error is detected.
virtual void ReportCounter(int32_t counter_id, int32_t value)=0
report counter to the SDK.
virtual int postEvent(const char *key, const char *value)=0
Post an event and notify the end users.
virtual void printLog(commons::LOG_LEVEL level, const char *format,...)=0
print log to the SDK.
virtual int GetStats(int32_t counter_id)=0
get stats to the SDK.
Definition AgoraExtensions.h:238
virtual ProcessResult convertAudioFrameToFaceInfo(const agora::media::base::AudioPcmFrame &inAudioFrame, char *outFaceInfo)
Definition AgoraExtensions.h:291
virtual int start(agora::agora_refptr< Control > control)=0
ProcessResult
Definition AgoraExtensions.h:240
@ kDrop
Definition AgoraExtensions.h:243
@ kSuccess
Definition AgoraExtensions.h:241
@ kBypass
Definition AgoraExtensions.h:242
virtual int setProperty(const char *key, const void *buf, size_t buf_size)
Definition AgoraExtensions.h:284
Definition NGIAgoraMediaNode.h:94
Definition NGIAgoraMediaNode.h:167
OPTIONAL_ENUM_CLASS LOG_LEVEL
Definition IAgoraLog.h:33
VIDEO_PIXEL_FORMAT
Definition AgoraMediaBase.h:464
VIDEO_FRAME_TYPE
Definition AgoraBase.h:1051
@ VIDEO_FRAME_TYPE_DELTA_FRAME
Definition AgoraBase.h:1057
Definition AgoraAtomicOps.h:21
@ ERR_NOT_SUPPORTED
Definition AgoraBase.h:481
Definition video_node_i.h:28
Definition AgoraMediaBase.h:351
Definition AgoraMediaBase.h:963
media::base::VIDEO_PIXEL_FORMAT prefer_data_format
Definition AgoraExtensions.h:306
uint32_t framerate
Definition AgoraExtensions.h:300
uint32_t bitrate_kbps
Definition AgoraExtensions.h:301
uint32_t key_frame_interval
Definition AgoraExtensions.h:302
OPTIONAL_ENUM_CLASS Format
Definition NGIAgoraVideoFrame.h:29
OPTIONAL_ENUM_CLASS Type
Definition NGIAgoraVideoFrame.h:94