Agora Server Gateway SDK C++ API Reference
NGIAgoraLocalUser.h
Go to the documentation of this file.
1//
2// Agora SDK
3//
4// Created by Zheng Ender in 2018-01.
5// Copyright (c) 2018 Agora.io. All rights reserved.
6//
7
8#pragma once // NOLINT(build/header_guard)
9
10#include <cstring>
11
12#include "AgoraBase.h"
13#include "AgoraOptional.h"
14
15namespace agora {
16namespace media {
18}
19
20namespace rtc {
21class IAudioEngineWrapper;
22
23class ILocalUserObserver;
24class ILocalVideoTrack;
25class IRemoteVideoTrack;
26class IVideoFrameObserver2;
27
28struct AudioEncoderConfiguration;
29struct VideoEncoderConfiguration;
30
31class ILocalAudioTrack;
32struct RemoteAudioTrackStats;
33class IRemoteAudioTrack;
34struct LocalVideoTrackStats;
35struct RemoteVideoTrackStats;
36class IVideoSinkBase;
49 public:
51
54 struct ANAStats {
60 agora::Optional<uint32_t> bitrate_action_counter;
66 agora::Optional<uint32_t> channel_action_counter;
72 agora::Optional<uint32_t> dtx_action_counter;
78 agora::Optional<uint32_t> fec_action_counter;
85 agora::Optional<uint32_t> frame_length_increase_counter;
92 agora::Optional<uint32_t> frame_length_decrease_counter;
98 agora::Optional<float> uplink_packet_loss_fraction;
99 };
100
104 struct AudioProcessingStats {
113 agora::Optional<double> echo_return_loss;
114 //
125 agora::Optional<double> echo_return_loss_enhancement;
130 agora::Optional<double> divergent_filter_fraction;
131
144 agora::Optional<int32_t> delay_median_ms;
148 agora::Optional<int32_t> delay_standard_deviation_ms;
149
153 agora::Optional<double> residual_echo_likelihood;
157 agora::Optional<double> residual_echo_likelihood_recent_max;
158
164 };
166 public:
167 virtual ~ILocalUser() {}
168
186 virtual void setUserRole(rtc::CLIENT_ROLE_TYPE role, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
187
194
196 virtual void setAudienceLatencyLevel(AUDIENCE_LATENCY_LEVEL_TYPE level) = 0;
197
198 virtual AUDIENCE_LATENCY_LEVEL_TYPE getAudienceLatencyLevel() = 0;
200
211 virtual int setAudioEncoderConfiguration(const rtc::AudioEncoderConfiguration& config, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
212
225 virtual int publishAudio(agora_refptr<ILocalAudioTrack> audioTrack, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
226
236 virtual int unpublishAudio(agora_refptr<ILocalAudioTrack> audioTrack, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
237
247 virtual int publishVideo(agora_refptr<ILocalVideoTrack> videoTrack, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
248
258 virtual int unpublishVideo(agora_refptr<ILocalVideoTrack> videoTrack, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
259
270 virtual int subscribeAudio(user_id_t userId, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
271
282 virtual int subscribeAllAudio(aosl_ref_t ares = AOSL_REF_INVALID) = 0;
283
294 virtual int unsubscribeAudio(user_id_t userId, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
295
307 virtual int unsubscribeAllAudio(aosl_ref_t ares = AOSL_REF_INVALID) = 0;
308
326 virtual int setPlaybackAudioFrameParameters(size_t numberOfChannels,
327 uint32_t sampleRateHz,
329 int samplesPerCall = 0,
330 aosl_ref_t ares = AOSL_REF_INVALID) = 0;
348 virtual int setRecordingAudioFrameParameters(size_t numberOfChannels,
349 uint32_t sampleRateHz,
351 int samplesPerCall = 0,
352 aosl_ref_t ares = AOSL_REF_INVALID) = 0;
368 virtual int setMixedAudioFrameParameters(size_t numberOfChannels,
369 uint32_t sampleRateHz,
370 int samplesPerCall = 0,
371 aosl_ref_t ares = AOSL_REF_INVALID) = 0;
372
388 virtual int setPlaybackAudioFrameBeforeMixingParameters(size_t numberOfChannels,
389 uint32_t sampleRateHz,
390 aosl_ref_t ares = AOSL_REF_INVALID) = 0;
391
409 virtual int registerAudioFrameObserver(agora::media::IAudioFrameObserverBase * observer, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
418 virtual int unregisterAudioFrameObserver(agora::media::IAudioFrameObserverBase * observer) = 0;
419
433 virtual int registerVideoEncodedFrameObserver(agora::media::IVideoEncodedFrameObserver* observer, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
441 virtual int unregisterVideoEncodedFrameObserver(agora::media::IVideoEncodedFrameObserver* observer) = 0;
442
464
478 virtual int subscribeVideo(user_id_t userId,
479 const rtc::VideoSubscriptionOptions &subscriptionOptions,
480 aosl_ref_t ares = AOSL_REF_INVALID) = 0;
481
493 virtual int subscribeAllVideo(const rtc::VideoSubscriptionOptions &subscriptionOptions, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
494
505 virtual int unsubscribeVideo(user_id_t userId, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
506
518 virtual int unsubscribeAllVideo(aosl_ref_t ares = AOSL_REF_INVALID) = 0;
519
533 ILocalUserObserver* observer,
534 void(*safeDeleter)(ILocalUserObserver*) = NULL,
535 aosl_ref_t ares = AOSL_REF_INVALID) = 0;
536
546
558 virtual int sendIntraRequest(user_id_t userId, aosl_ref_t ares = AOSL_REF_INVALID) = 0;
559};
560
569
573 unsigned int volume;
574
575 /*
576 * The activity status of remote users
577 */
578 unsigned int vad;
579
584
586};
587
592 public:
594
601 virtual void onAudioTrackPublishSuccess(agora_refptr<ILocalAudioTrack> audioTrack) = 0;
602
604
610 virtual void onAudioTrackPublicationFailure(agora_refptr<ILocalAudioTrack> audioTrack,
611 ERROR_CODE_TYPE error) = 0;
613
620 virtual void onLocalAudioTrackStateChanged(agora_refptr<rtc::ILocalAudioTrack> audioTrack,
622 LOCAL_AUDIO_STREAM_ERROR errorCode) = 0;
628 virtual void onLocalAudioTrackStatistics(const LocalAudioStats& stats) = 0;
635 virtual void onRemoteAudioTrackStatistics(agora_refptr<rtc::IRemoteAudioTrack> audioTrack, const RemoteAudioTrackStats& stats) = 0;
646 agora_refptr<rtc::IRemoteAudioTrack> audioTrack) = 0;
647
658 agora_refptr<rtc::IRemoteAudioTrack> audioTrack,
659 REMOTE_AUDIO_STATE state,
661 int elapsed) = 0;
662
668 virtual void onVideoTrackPublishSuccess(agora_refptr<ILocalVideoTrack> videoTrack) = 0;
669
671
677 virtual void onVideoTrackPublicationFailure(agora_refptr<ILocalVideoTrack> videoTrack,
678 ERROR_CODE_TYPE error) = 0;
680
691 virtual void onLocalVideoTrackStateChanged(agora_refptr<rtc::ILocalVideoTrack> videoTrack,
693 LOCAL_VIDEO_STREAM_ERROR errorCode) = 0;
694
701 virtual void onLocalVideoTrackStatistics(agora_refptr<rtc::ILocalVideoTrack> videoTrack,
702 const LocalVideoTrackStats& stats) = 0;
703
715 agora_refptr<rtc::IRemoteVideoTrack> videoTrack) = 0;
716
727 agora_refptr<rtc::IRemoteVideoTrack> videoTrack,
728 REMOTE_VIDEO_STATE state,
730 int elapsed) = 0;
731
740 virtual void onFirstRemoteVideoFrameRendered(user_id_t userId, int width,
741 int height, int elapsed) = 0;
742
743
750 virtual void onRemoteVideoTrackStatistics(agora_refptr<rtc::IRemoteVideoTrack> videoTrack,
751 const RemoteVideoTrackStats& stats) = 0;
753
782 virtual void onAudioVolumeIndication(const AudioVolumeInformation* speakers, unsigned int speakerNumber,
783 int totalVolume) = 0;
784
797 virtual void onActiveSpeaker(user_id_t userId) = 0;
799
808 virtual void onAudioSubscribeStateChanged(const char* channel, user_id_t userId, STREAM_SUBSCRIBE_STATE oldState, STREAM_SUBSCRIBE_STATE newState, int elapseSinceLastState) = 0;
809
819 virtual void onVideoSubscribeStateChanged(const char* channel, user_id_t userId, STREAM_SUBSCRIBE_STATE oldState, STREAM_SUBSCRIBE_STATE newState, int elapseSinceLastState) = 0;
820
829 virtual void onAudioPublishStateChanged(const char* channel, STREAM_PUBLISH_STATE oldState, STREAM_PUBLISH_STATE newState, int elapseSinceLastState) = 0;
830
839 virtual void onVideoPublishStateChanged(const char* channel, STREAM_PUBLISH_STATE oldState, STREAM_PUBLISH_STATE newState, int elapseSinceLastState) = 0;
840
846 virtual void onFirstRemoteAudioFrame(user_id_t userId, int elapsed) = 0;
847
854 virtual void onFirstRemoteAudioDecoded(user_id_t userId, int elapsed) = 0;
856
865 virtual void onFirstRemoteVideoFrame(user_id_t userId, int width, int height, int elapsed) = 0;
867
875 virtual void onFirstRemoteVideoDecoded(user_id_t userId, int width, int height, int elapsed) = 0;
876
894
897 USER_MEDIA_INFO_ENABLE_LOCAL_VIDEO = 8,
899 };
900
909 virtual void onUserInfoUpdated(user_id_t userId, USER_MEDIA_INFO msg, bool val) {
910 (void)userId;
911 (void)msg;
912 (void)val;
913 }
914
921 virtual void onIntraRequestReceived() {}
922
935 virtual void onStreamMessage(user_id_t userId, int streamId, const char* data, size_t length) {}
956
957 };
958
964 virtual void onUserStateChanged(user_id_t userId, uint32_t state){}
965};
966
968 public:
978 virtual void onFrame(const char* channelId, user_id_t remoteUid, const media::base::VideoFrame* frame) = 0;
979
981};
982
983} // namespace rtc
984} // namespace agora
Definition: AgoraMediaBase.h:765
Definition: AgoraOptional.h:413
Definition: NGIAgoraLocalUser.h:48
virtual int subscribeAllVideo(const rtc::VideoSubscriptionOptions &subscriptionOptions, aosl_ref_t ares=AOSL_REF_INVALID)=0
virtual int setPlaybackAudioFrameParameters(size_t numberOfChannels, uint32_t sampleRateHz, RAW_AUDIO_FRAME_OP_MODE_TYPE mode=RAW_AUDIO_FRAME_OP_MODE_READ_ONLY, int samplesPerCall=0, aosl_ref_t ares=AOSL_REF_INVALID)=0
virtual int unsubscribeAllAudio(aosl_ref_t ares=AOSL_REF_INVALID)=0
virtual int registerVideoFrameObserver(IVideoFrameObserver2 *observer)=0
virtual int sendIntraRequest(user_id_t userId, aosl_ref_t ares=AOSL_REF_INVALID)=0
virtual int unsubscribeAudio(user_id_t userId, aosl_ref_t ares=AOSL_REF_INVALID)=0
virtual void setUserRole(rtc::CLIENT_ROLE_TYPE role, aosl_ref_t ares=AOSL_REF_INVALID)=0
virtual int registerLocalUserObserver(ILocalUserObserver *observer, void(*safeDeleter)(ILocalUserObserver *)=NULL, aosl_ref_t ares=AOSL_REF_INVALID)=0
virtual int publishVideo(agora_refptr< ILocalVideoTrack > videoTrack, aosl_ref_t ares=AOSL_REF_INVALID)=0
virtual int setAudioEncoderConfiguration(const rtc::AudioEncoderConfiguration &config, aosl_ref_t ares=AOSL_REF_INVALID)=0
virtual int publishAudio(agora_refptr< ILocalAudioTrack > audioTrack, aosl_ref_t ares=AOSL_REF_INVALID)=0
virtual int unsubscribeVideo(user_id_t userId, aosl_ref_t ares=AOSL_REF_INVALID)=0
virtual int subscribeAllAudio(aosl_ref_t ares=AOSL_REF_INVALID)=0
virtual CLIENT_ROLE_TYPE getUserRole()=0
virtual int setPlaybackAudioFrameBeforeMixingParameters(size_t numberOfChannels, uint32_t sampleRateHz, aosl_ref_t ares=AOSL_REF_INVALID)=0
virtual int unregisterLocalUserObserver(ILocalUserObserver *observer)=0
virtual int subscribeAudio(user_id_t userId, aosl_ref_t ares=AOSL_REF_INVALID)=0
virtual ~ILocalUser()
Definition: NGIAgoraLocalUser.h:167
virtual int subscribeVideo(user_id_t userId, const rtc::VideoSubscriptionOptions &subscriptionOptions, aosl_ref_t ares=AOSL_REF_INVALID)=0
virtual int unregisterAudioFrameObserver(agora::media::IAudioFrameObserverBase *observer)=0
virtual int registerAudioFrameObserver(agora::media::IAudioFrameObserverBase *observer, aosl_ref_t ares=AOSL_REF_INVALID)=0
virtual int unregisterVideoFrameObserver(IVideoFrameObserver2 *observer)=0
virtual int unpublishVideo(agora_refptr< ILocalVideoTrack > videoTrack, aosl_ref_t ares=AOSL_REF_INVALID)=0
virtual int registerVideoEncodedFrameObserver(agora::media::IVideoEncodedFrameObserver *observer, aosl_ref_t ares=AOSL_REF_INVALID)=0
virtual int unpublishAudio(agora_refptr< ILocalAudioTrack > audioTrack, aosl_ref_t ares=AOSL_REF_INVALID)=0
virtual int setRecordingAudioFrameParameters(size_t numberOfChannels, uint32_t sampleRateHz, RAW_AUDIO_FRAME_OP_MODE_TYPE mode=RAW_AUDIO_FRAME_OP_MODE_READ_ONLY, int samplesPerCall=0, aosl_ref_t ares=AOSL_REF_INVALID)=0
virtual int unregisterVideoEncodedFrameObserver(agora::media::IVideoEncodedFrameObserver *observer)=0
virtual int unsubscribeAllVideo(aosl_ref_t ares=AOSL_REF_INVALID)=0
virtual int setMixedAudioFrameParameters(size_t numberOfChannels, uint32_t sampleRateHz, int samplesPerCall=0, aosl_ref_t ares=AOSL_REF_INVALID)=0
Definition: NGIAgoraLocalUser.h:591
virtual void onVideoPublishStateChanged(const char *channel, STREAM_PUBLISH_STATE oldState, STREAM_PUBLISH_STATE newState, int elapseSinceLastState)=0
virtual ~ILocalUserObserver()
Definition: NGIAgoraLocalUser.h:593
virtual void onAudioSubscribeStateChanged(const char *channel, user_id_t userId, STREAM_SUBSCRIBE_STATE oldState, STREAM_SUBSCRIBE_STATE newState, int elapseSinceLastState)=0
virtual void onStreamMessage(user_id_t userId, int streamId, const char *data, size_t length)
Definition: NGIAgoraLocalUser.h:935
virtual void onLocalVideoTrackStatistics(agora_refptr< rtc::ILocalVideoTrack > videoTrack, const LocalVideoTrackStats &stats)=0
virtual void onAudioTrackPublishSuccess(agora_refptr< ILocalAudioTrack > audioTrack)=0
virtual void onAudioPublishStateChanged(const char *channel, STREAM_PUBLISH_STATE oldState, STREAM_PUBLISH_STATE newState, int elapseSinceLastState)=0
virtual void onVideoSubscribeStateChanged(const char *channel, user_id_t userId, STREAM_SUBSCRIBE_STATE oldState, STREAM_SUBSCRIBE_STATE newState, int elapseSinceLastState)=0
virtual void onUserInfoUpdated(user_id_t userId, USER_MEDIA_INFO msg, bool val)
Definition: NGIAgoraLocalUser.h:909
virtual void onLocalAudioTrackStatistics(const LocalAudioStats &stats)=0
virtual void onUserVideoTrackSubscribed(user_id_t userId, VideoTrackInfo trackInfo, agora_refptr< rtc::IRemoteVideoTrack > videoTrack)=0
virtual void onUserVideoTrackStateChanged(user_id_t userId, agora_refptr< rtc::IRemoteVideoTrack > videoTrack, REMOTE_VIDEO_STATE state, REMOTE_VIDEO_STATE_REASON reason, int elapsed)=0
virtual void onFirstRemoteAudioDecoded(user_id_t userId, int elapsed)=0
virtual void onVideoTrackPublishSuccess(agora_refptr< ILocalVideoTrack > videoTrack)=0
virtual void onRemoteAudioTrackStatistics(agora_refptr< rtc::IRemoteAudioTrack > audioTrack, const RemoteAudioTrackStats &stats)=0
virtual void onFirstRemoteVideoFrameRendered(user_id_t userId, int width, int height, int elapsed)=0
virtual void onUserAudioTrackSubscribed(user_id_t userId, agora_refptr< rtc::IRemoteAudioTrack > audioTrack)=0
virtual void onUserStateChanged(user_id_t userId, uint32_t state)
Definition: NGIAgoraLocalUser.h:964
virtual void onFirstRemoteAudioFrame(user_id_t userId, int elapsed)=0
virtual void onIntraRequestReceived()
Definition: NGIAgoraLocalUser.h:921
virtual void onFirstRemoteVideoDecoded(user_id_t userId, int width, int height, int elapsed)=0
REMOTE_USER_STATE
Definition: NGIAgoraLocalUser.h:939
@ PEER_STATE_ENABLE_VIDEO
Definition: NGIAgoraLocalUser.h:951
@ PEER_STATE_MUTE_AUDIO
Definition: NGIAgoraLocalUser.h:943
@ PEER_STATE_ENABLE_LOCAL_VIDEO
Definition: NGIAgoraLocalUser.h:955
@ PEER_STATE_MUTE_VIDEO
Definition: NGIAgoraLocalUser.h:947
virtual void onRemoteVideoTrackStatistics(agora_refptr< rtc::IRemoteVideoTrack > videoTrack, const RemoteVideoTrackStats &stats)=0
virtual void onLocalAudioTrackStateChanged(agora_refptr< rtc::ILocalAudioTrack > audioTrack, LOCAL_AUDIO_STREAM_STATE state, LOCAL_AUDIO_STREAM_ERROR errorCode)=0
virtual void onLocalVideoTrackStateChanged(agora_refptr< rtc::ILocalVideoTrack > videoTrack, LOCAL_VIDEO_STREAM_STATE state, LOCAL_VIDEO_STREAM_ERROR errorCode)=0
virtual void onUserAudioTrackStateChanged(user_id_t userId, agora_refptr< rtc::IRemoteAudioTrack > audioTrack, REMOTE_AUDIO_STATE state, REMOTE_AUDIO_STATE_REASON reason, int elapsed)=0
USER_MEDIA_INFO
Definition: NGIAgoraLocalUser.h:880
@ USER_MEDIA_INFO_MUTE_VIDEO
Definition: NGIAgoraLocalUser.h:888
@ USER_MEDIA_INFO_ENABLE_VIDEO
Definition: NGIAgoraLocalUser.h:892
@ USER_MEDIA_INFO_MUTE_AUDIO
Definition: NGIAgoraLocalUser.h:884
Definition: NGIAgoraLocalUser.h:967
virtual ~IVideoFrameObserver2()
Definition: NGIAgoraLocalUser.h:980
virtual void onFrame(const char *channelId, user_id_t remoteUid, const media::base::VideoFrame *frame)=0
LOCAL_AUDIO_STREAM_STATE
Definition: AgoraBase.h:2735
LOCAL_AUDIO_STREAM_ERROR
Definition: AgoraBase.h:2758
CLIENT_ROLE_TYPE
Definition: AgoraBase.h:2414
REMOTE_AUDIO_STATE_REASON
Definition: AgoraBase.h:2878
STREAM_PUBLISH_STATE
Definition: AgoraBase.h:4882
LOCAL_VIDEO_STREAM_STATE
Definition: AgoraBase.h:2789
REMOTE_VIDEO_STATE
Definition: AgoraBase.h:2919
REMOTE_AUDIO_STATE
Definition: AgoraBase.h:2843
STREAM_SUBSCRIBE_STATE
Definition: AgoraBase.h:4859
LOCAL_VIDEO_STREAM_ERROR
Definition: AgoraBase.h:2812
REMOTE_VIDEO_STATE_REASON
Definition: AgoraBase.h:2948
RAW_AUDIO_FRAME_OP_MODE_TYPE
Definition: AgoraMediaBase.h:56
@ RAW_AUDIO_FRAME_OP_MODE_READ_ONLY
Definition: AgoraMediaBase.h:61
Definition: AgoraBase.h:86
const char * user_id_t
Definition: AgoraBase.h:1198
Definition: IAgoraService.h:33
Definition: NGIAgoraLocalUser.h:564
unsigned int vad
Definition: NGIAgoraLocalUser.h:578
unsigned int volume
Definition: NGIAgoraLocalUser.h:573
AudioVolumeInformation()
Definition: NGIAgoraLocalUser.h:585
user_id_t userId
Definition: NGIAgoraLocalUser.h:568
double voicePitch
Definition: NGIAgoraLocalUser.h:583
Definition: AgoraBase.h:3254
Definition: NGIAgoraVideoTrack.h:192
Definition: NGIAgoraAudioTrack.h:325
Definition: NGIAgoraVideoTrack.h:393
Definition: AgoraBase.h:1851
Definition: AgoraBase.h:3015