Agora Java API Reference for Android

NGIAgoraMediaNode.h
1 #pragma once
2 #include "AgoraRefPtr.h"
3 #include "AgoraBase.h"
4 #include "IAgoraLog.h"
5 #include "NGIAgoraVideoFrame.h"
6 #include "AgoraExtensionVersion.h"
7 #include <api/aosl_ref.h>
8
9 #ifndef OPTIONAL_PROCESSRESULT_SPECIFIER
10 #if __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1800)
11 #define OPTIONAL_PROCESSRESULT_SPECIFIER ProcessResult::
12 #else
13 #define OPTIONAL_PROCESSRESULT_SPECIFIER
14 #endif
15 #endif
16
17 namespace webrtc {
18 struct AudioFrameHandleInfo;
19 } // namespace webrtc
20
21 namespace agora {
22 namespace rtc {
27 class IAudioFilterBase : public RefCountInterface {
28 public:
29 // Return false if filter decide to drop the frame.
30 // Implementation should not change samples_per_channel_/sample_rate_hz_/num_channels_
31 // Implementation should just adapt data of audio frame.
40 virtual bool adaptAudioFrame(const media::base::AudioPcmFrame& inAudioFrame,
41 media::base::AudioPcmFrame& adaptedFrame) = 0;
42
50 virtual int getPreferredSampleRate() = 0;
51
60 virtual int getPreferredChannelNumbers() = 0;
61
62 protected:
63 ~IAudioFilterBase() {}
64 };
65
70 class IVideoFilterBase : public RefCountInterface {
71 public:
82 virtual bool adaptVideoFrame(const media::base::VideoFrame& capturedFrame,
83 media::base::VideoFrame& adaptedFrame) = 0;
84 };
85
86 // TODO(Bob): private inherit?
94 class IVideoFilter : public IVideoFilterBase {
95 public:
103 virtual void setEnabled(bool enable) {}
110 virtual bool isEnabled() { return true; }
121 virtual int setProperty(const char* key, const void* buf, size_t buf_size) { return -1; }
132 virtual int getProperty(const char* key, void* buf, size_t buf_size) { return -1; }
140 virtual bool onDataStreamWillStart() { return true; }
145 virtual void onDataStreamWillStop() { }
153 virtual bool isExternal() { return true; }
161 virtual bool isExtensionFilter() { return false; }
162 };
163
167 class IVideoSinkBase : public RefCountInterface {
168 public:
179 virtual int setProperty(const char* key, const void* buf, int buf_size) { return -1; }
190 virtual int getProperty(const char* key, void* buf, int buf_size) { return -1; }
195 virtual int onFrame(const media::base::VideoFrame& videoFrame) = 0;
200 virtual bool isExternalSink() { return true; }
208 virtual bool onDataStreamWillStart() { return true; }
213 virtual void onDataStreamWillStop() { }
220 virtual bool applyMirror() { return false; }
227 virtual bool applyRotation() { return false; }
228 };
229
230 class IMediaExtensionObserver : public RefCountInterface {
231 public:
232 virtual ~IMediaExtensionObserver() {}
233 virtual void onEventWithContext(const ExtensionContext& context, const char* key, const char* json_value) {}
234 virtual void onExtensionStoppedWithContext(const ExtensionContext& context) {}
235 virtual void onExtensionStartedWithContext(const ExtensionContext& context) {}
236 virtual void onExtensionErrorWithContext(const ExtensionContext& context, int error, const char* message) {}
237 };
238
244 class IAudioPcmDataSender : public RefCountInterface {
245 public:
259 virtual int sendAudioPcmData(
260 const void* audio_data, uint32_t capture_timestamp, int64_t presentation_ms,
261 const size_t samples_per_channel, // for 10ms Data, number_of_samples * 100 = sample_rate
262 const agora::rtc::BYTES_PER_SAMPLE bytes_per_sample, // 2
263 const size_t number_of_channels,
264 const uint32_t sample_rate, aosl_ref_t ares = AOSL_REF_INVALID) = 0; // sample_rate > 8000)
265
266 protected:
267 ~IAudioPcmDataSender() {}
268 };
269
277 class IAudioEncodedFrameSender : public RefCountInterface {
278 public:
291 virtual bool sendEncodedAudioFrame(const uint8_t* payload_data, size_t payload_size,
292 const EncodedAudioFrameInfo& audioFrameInfo, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
293
294 protected:
295 ~IAudioEncodedFrameSender() {}
296 };
297
298 class IAudioEncodedFrameReceiver {
299 public:
308 virtual bool onEncodedAudioFrameReceived (
309 const uint8_t *packet, size_t length, const media::base::AudioEncodedFrameInfo& info) = 0;
310
311 virtual ~IAudioEncodedFrameReceiver() {}
312 };
313
318 class IMediaPacketReceiver {
319 public:
328 virtual bool onMediaPacketReceived(
329 const uint8_t *packet, size_t length, const agora::media::base::PacketOptions& options) = 0;
330
331 virtual ~IMediaPacketReceiver() {}
332 };
333
340 class IMediaControlPacketReceiver {
341 public:
349 virtual bool onMediaControlPacketReceived(uid_t uid, const uint8_t *packet, size_t length) = 0;
350
351 virtual ~IMediaControlPacketReceiver() {}
352 };
353
361 class IMediaPacketSender : public RefCountInterface {
362 public:
374 virtual int sendMediaPacket(const uint8_t *packet, size_t length,
375 const media::base::PacketOptions &options, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
376 protected:
377 ~IMediaPacketSender() {}
378 };
379
387 class IMediaControlPacketSender {
388 public:
401 virtual int sendPeerMediaControlPacket(media::base::user_id_t userId,
402 const uint8_t *packet,
403 size_t length, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
404
415 virtual int sendBroadcastMediaControlPacket(const uint8_t *packet, size_t length, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
416
417 virtual ~IMediaControlPacketSender() {}
418 };
419
424 class IAudioSinkBase : public RefCountInterface {
425 public:
433 virtual bool onAudioFrame(const media::base::AudioPcmFrame& audioFrame) = 0;
434
435 protected:
436 ~IAudioSinkBase() {}
437 };
438
446 class IVideoFrameSender : public RefCountInterface {
447 public:
457 virtual int sendVideoFrame(const media::base::ExternalVideoFrame& videoFrame, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
458
459 protected:
460 ~IVideoFrameSender() {}
461 };
462
470 class IVideoEncodedImageSender : public RefCountInterface {
471 public:
483 virtual bool sendEncodedVideoImage(const uint8_t* imageBuffer, size_t length,
484 const EncodedVideoFrameInfo& videoEncodedFrameInfo, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
485
486 protected:
487 ~IVideoEncodedImageSender() {}
488 };
489
493 class IVideoBeautyFilter : public IVideoFilter {
494 public:
498 struct BeautyOptions {
502 enum LIGHTENING_CONTRAST_LEVEL {
506 LIGHTENING_CONTRAST_LOW = 0,
510 LIGHTENING_CONTRAST_NORMAL,
514 LIGHTENING_CONTRAST_HIGH
515 };
516
521 LIGHTENING_CONTRAST_LEVEL lighteningContrastLevel;
522
526 float lighteningLevel;
527
532 float smoothnessLevel;
533
538 float rednessLevel;
539
540 BeautyOptions(LIGHTENING_CONTRAST_LEVEL contrastLevel, float lightening, float smoothness,
541 float redness)
542 : lighteningContrastLevel(contrastLevel),
543 lighteningLevel(lightening),
544 smoothnessLevel(smoothness),
545 rednessLevel(redness) {}
546
547 BeautyOptions()
548 : lighteningContrastLevel(LIGHTENING_CONTRAST_NORMAL),
549 lighteningLevel(0),
550 smoothnessLevel(0),
551 rednessLevel(0) {}
552 };
563 virtual int setBeautyEffectOptions(bool enabled, BeautyOptions options) = 0;
564 };
565
569 class IVideoRenderer : public IVideoSinkBase {
570 public:
578 virtual int setRenderMode(media::base::RENDER_MODE_TYPE renderMode, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
587 virtual int setRenderMode(void* view, media::base::RENDER_MODE_TYPE renderMode, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
597 virtual int setMirror(bool mirror, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
608 virtual int setMirror(void* view, bool mirror, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
616 virtual int setView(void* view, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
625 virtual int addView(void* view, const Rectangle& cropArea, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
632 virtual int unsetView(aosl_ref_t ares = AOSL_REF_INVALID) = 0;
639 virtual int removeView(void* view) = 0;
640 };
641
642 static const int kDeviceIdSize = 128;
643
644 class IVideoTrack;
648 class IVideoFrameTransceiver : public RefCountInterface {
649 public:
650 virtual int getTranscodingDelayMs() = 0;
651 virtual int addVideoTrack(agora_refptr<IVideoTrack> track, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
652 virtual int removeVideoTrack(agora_refptr<IVideoTrack> track, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
653 };
654 }
655 }
agora::media::base::VideoFrame
Configurations of the video frame.
Definition: AgoraMediaBase.h:1024
agora::rtc::IMediaPacketSender::sendMediaPacket
virtual int sendMediaPacket(const uint8_t *packet, size_t length, const media::base::PacketOptions &options, aosl_ref_t ares=AOSL_REF_INVALID)=0
agora::rtc::IVideoSinkBase::onDataStreamWillStart
virtual bool onDataStreamWillStart()
Definition: NGIAgoraMediaNode.h:208
agora::rtc::IMediaControlPacketReceiver
Definition: NGIAgoraMediaNode.h:340
agora::rtc::IVideoRenderer::unsetView
virtual int unsetView(aosl_ref_t ares=AOSL_REF_INVALID)=0
agora::rtc::IVideoFilter::onDataStreamWillStop
virtual void onDataStreamWillStop()
Definition: NGIAgoraMediaNode.h:145
agora::rtc::IAudioEncodedFrameReceiver::onEncodedAudioFrameReceived
virtual bool onEncodedAudioFrameReceived(const uint8_t *packet, size_t length, const media::base::AudioEncodedFrameInfo &info)=0
agora::rtc::IVideoSinkBase::applyRotation
virtual bool applyRotation()
Definition: NGIAgoraMediaNode.h:227
agora::rtc::IVideoBeautyFilter
Definition: NGIAgoraMediaNode.h:493
agora::rtc::IAudioFilterBase
Definition: NGIAgoraMediaNode.h:27
agora::rtc::IVideoFilterBase::adaptVideoFrame
virtual bool adaptVideoFrame(const media::base::VideoFrame &capturedFrame, media::base::VideoFrame &adaptedFrame)=0
agora::rtc::IVideoTrack
Definition: NGIAgoraVideoTrack.h:101
agora::agora_refptr
Definition: AgoraRefPtr.h:44
agora::rtc::IVideoFrameTransceiver
Definition: NGIAgoraMediaNode.h:648
agora::rtc::IAudioFilterBase::adaptAudioFrame
virtual bool adaptAudioFrame(const media::base::AudioPcmFrame &inAudioFrame, media::base::AudioPcmFrame &adaptedFrame)=0
agora::rtc::IVideoRenderer::setRenderMode
virtual int setRenderMode(void *view, media::base::RENDER_MODE_TYPE renderMode, aosl_ref_t ares=AOSL_REF_INVALID)=0
agora::rtc::IVideoFilter::setProperty
virtual int setProperty(const char *key, const void *buf, size_t buf_size)
Definition: NGIAgoraMediaNode.h:121
agora::rtc::IVideoFilter::isExtensionFilter
virtual bool isExtensionFilter()
Definition: NGIAgoraMediaNode.h:161
agora::rtc::Rectangle
The location of the target area relative to the screen or window. If you do not set this parameter,...
Definition: AgoraBase.h:2342
agora::rtc::IVideoSinkBase
Definition: NGIAgoraMediaNode.h:167
agora::rtc::IVideoSinkBase::applyMirror
virtual bool applyMirror()
Definition: NGIAgoraMediaNode.h:220
agora::rtc::EncodedVideoFrameInfo
Information about externally encoded video frames.
Definition: AgoraBase.h:1735
agora::rtc::IVideoFilter::onDataStreamWillStart
virtual bool onDataStreamWillStart()
Definition: NGIAgoraMediaNode.h:140
agora::rtc::EncodedAudioFrameInfo
Audio information after encoding.
Definition: AgoraBase.h:1567
agora::rtc::IMediaControlPacketSender::sendBroadcastMediaControlPacket
virtual int sendBroadcastMediaControlPacket(const uint8_t *packet, size_t length, aosl_ref_t ares=AOSL_REF_INVALID)=0
agora::rtc::IAudioPcmDataSender
Definition: NGIAgoraMediaNode.h:244
agora::rtc::IVideoRenderer::removeView
virtual int removeView(void *view)=0
agora::rtc::IMediaControlPacketReceiver::onMediaControlPacketReceived
virtual bool onMediaControlPacketReceived(uid_t uid, const uint8_t *packet, size_t length)=0
agora::rtc::IAudioPcmDataSender::sendAudioPcmData
virtual int sendAudioPcmData(const void *audio_data, uint32_t capture_timestamp, int64_t presentation_ms, const size_t samples_per_channel, const agora::rtc::BYTES_PER_SAMPLE bytes_per_sample, const size_t number_of_channels, const uint32_t sample_rate, aosl_ref_t ares=AOSL_REF_INVALID)=0
agora::rtc::ExtensionContext
The context information of the extension.
Definition: AgoraMediaBase.h:41
agora::rtc::IVideoEncodedImageSender
Definition: NGIAgoraMediaNode.h:470
agora::rtc::IAudioEncodedFrameSender::sendEncodedAudioFrame
virtual bool sendEncodedAudioFrame(const uint8_t *payload_data, size_t payload_size, const EncodedAudioFrameInfo &audioFrameInfo, aosl_ref_t ares=AOSL_REF_INVALID)=0
agora::rtc::IVideoRenderer::setRenderMode
virtual int setRenderMode(media::base::RENDER_MODE_TYPE renderMode, aosl_ref_t ares=AOSL_REF_INVALID)=0
agora::rtc::IMediaPacketSender
Definition: NGIAgoraMediaNode.h:361
agora::media::base::ExternalVideoFrame
The external video frame.
Definition: AgoraMediaBase.h:825
agora::rtc::IAudioFilterBase::getPreferredSampleRate
virtual int getPreferredSampleRate()=0
agora::rtc::IVideoSinkBase::setProperty
virtual int setProperty(const char *key, const void *buf, int buf_size)
Definition: NGIAgoraMediaNode.h:179
agora::rtc::IVideoSinkBase::onDataStreamWillStop
virtual void onDataStreamWillStop()
Definition: NGIAgoraMediaNode.h:213
agora::rtc::IAudioEncodedFrameReceiver
Definition: NGIAgoraMediaNode.h:298
agora::rtc::IVideoBeautyFilter::BeautyOptions::LIGHTENING_CONTRAST_HIGH
@ LIGHTENING_CONTRAST_HIGH
Definition: NGIAgoraMediaNode.h:514
agora::rtc::IAudioEncodedFrameSender
Definition: NGIAgoraMediaNode.h:277
agora::media::base::PacketOptions
Definition: AgoraMediaBase.h:358
agora::rtc::IAudioFilterBase::getPreferredChannelNumbers
virtual int getPreferredChannelNumbers()=0
agora::rtc::IVideoSinkBase::onFrame
virtual int onFrame(const media::base::VideoFrame &videoFrame)=0
agora::rtc::IVideoFilterBase
Definition: NGIAgoraMediaNode.h:70
agora::rtc::IVideoRenderer::setMirror
virtual int setMirror(bool mirror, aosl_ref_t ares=AOSL_REF_INVALID)=0
agora::rtc::IVideoFrameSender::sendVideoFrame
virtual int sendVideoFrame(const media::base::ExternalVideoFrame &videoFrame, aosl_ref_t ares=AOSL_REF_INVALID)=0
agora::rtc::IVideoRenderer::addView
virtual int addView(void *view, const Rectangle &cropArea, aosl_ref_t ares=AOSL_REF_INVALID)=0
agora::rtc::IMediaPacketReceiver
Definition: NGIAgoraMediaNode.h:318
agora::rtc::IVideoBeautyFilter::BeautyOptions::LIGHTENING_CONTRAST_LEVEL
LIGHTENING_CONTRAST_LEVEL
Definition: NGIAgoraMediaNode.h:502
agora::rtc::IVideoRenderer
Definition: NGIAgoraMediaNode.h:569
agora::rtc::IVideoEncodedImageSender::sendEncodedVideoImage
virtual bool sendEncodedVideoImage(const uint8_t *imageBuffer, size_t length, const EncodedVideoFrameInfo &videoEncodedFrameInfo, aosl_ref_t ares=AOSL_REF_INVALID)=0
agora::rtc::IMediaControlPacketSender::sendPeerMediaControlPacket
virtual int sendPeerMediaControlPacket(media::base::user_id_t userId, const uint8_t *packet, size_t length, aosl_ref_t ares=AOSL_REF_INVALID)=0
agora::rtc::IVideoRenderer::setMirror
virtual int setMirror(void *view, bool mirror, aosl_ref_t ares=AOSL_REF_INVALID)=0
agora::rtc::IVideoBeautyFilter::BeautyOptions::rednessLevel
float rednessLevel
Definition: NGIAgoraMediaNode.h:538
agora::rtc::IVideoBeautyFilter::BeautyOptions::LIGHTENING_CONTRAST_LOW
@ LIGHTENING_CONTRAST_LOW
Definition: NGIAgoraMediaNode.h:506
agora::rtc::IAudioSinkBase
Definition: NGIAgoraMediaNode.h:424
agora::rtc::IAudioSinkBase::onAudioFrame
virtual bool onAudioFrame(const media::base::AudioPcmFrame &audioFrame)=0
agora::rtc::IVideoFrameSender
Definition: NGIAgoraMediaNode.h:446
agora::RefCountInterface
Definition: AgoraRefPtr.h:31
agora::rtc::IVideoFilter::getProperty
virtual int getProperty(const char *key, void *buf, size_t buf_size)
Definition: NGIAgoraMediaNode.h:132
agora::rtc::IMediaPacketReceiver::onMediaPacketReceived
virtual bool onMediaPacketReceived(const uint8_t *packet, size_t length, const agora::media::base::PacketOptions &options)=0
agora::rtc::IVideoFilter::isEnabled
virtual bool isEnabled()
Definition: NGIAgoraMediaNode.h:110
agora::rtc::IVideoFilter::setEnabled
virtual void setEnabled(bool enable)
Definition: NGIAgoraMediaNode.h:103
agora::rtc::IVideoBeautyFilter::BeautyOptions::smoothnessLevel
float smoothnessLevel
Definition: NGIAgoraMediaNode.h:532
agora::media::base::AudioEncodedFrameInfo
Definition: AgoraMediaBase.h:372
agora::rtc::IVideoBeautyFilter::setBeautyEffectOptions
virtual int setBeautyEffectOptions(bool enabled, BeautyOptions options)=0
agora::rtc::IVideoBeautyFilter::BeautyOptions::lighteningLevel
float lighteningLevel
Definition: NGIAgoraMediaNode.h:526
agora::rtc::IVideoFilter::isExternal
virtual bool isExternal()
Definition: NGIAgoraMediaNode.h:153
agora::rtc::IMediaControlPacketSender
Definition: NGIAgoraMediaNode.h:387
agora::rtc::IVideoBeautyFilter::BeautyOptions::lighteningContrastLevel
LIGHTENING_CONTRAST_LEVEL lighteningContrastLevel
Definition: NGIAgoraMediaNode.h:521
agora::rtc::IVideoBeautyFilter::BeautyOptions::LIGHTENING_CONTRAST_NORMAL
@ LIGHTENING_CONTRAST_NORMAL
Definition: NGIAgoraMediaNode.h:510
agora::media::base::AudioPcmFrame
The parameters of the audio frame in PCM format.
Definition: AgoraMediaBase.h:387
agora::rtc::IVideoRenderer::setView
virtual int setView(void *view, aosl_ref_t ares=AOSL_REF_INVALID)=0
agora::rtc::IMediaExtensionObserver
Definition: NGIAgoraMediaNode.h:230
agora::rtc::IVideoFilter
Definition: NGIAgoraMediaNode.h:94
agora::rtc::IVideoSinkBase::isExternalSink
virtual bool isExternalSink()
Definition: NGIAgoraMediaNode.h:200
agora::rtc::IVideoBeautyFilter::BeautyOptions
Definition: NGIAgoraMediaNode.h:498
agora::rtc::IVideoSinkBase::getProperty
virtual int getProperty(const char *key, void *buf, int buf_size)
Definition: NGIAgoraMediaNode.h:190