Agora Server Gateway SDK C++ API Reference
NGIAgoraRtcConnection.h
Go to the documentation of this file.
1//
2// Agora SDK
3//
4// Created by Sting Feng in 2018-01.
5// Copyright (c) 2018 Agora.io. All rights reserved.
6//
7
8#pragma once // NOLINT(build/header_guard)
9
10#include "AgoraBase.h"
11
12namespace agora {
13namespace rtc {
14class IAudioEncodedFrameSender;
15class IRtcConnectionObserver;
16class INetworkObserver;
17class IRtcConnection;
18class IVideoEncodedImageSender;
19class ILocalUser;
20
42
45 uid_t internalUid;
48};
49
93
98
103
105 : autoSubscribeAudio(true),
106 autoSubscribeVideo(true),
108 maxSendBitrate(-1),
109 minPort(0),
110 maxPort(0),
114 videoRecvMediaPacket(false) {}
115};
116
127class IRtcConnection : public RefCountInterface {
128 protected:
130
131 public:
159 virtual int connect(const char* token, const char* channelId, user_id_t userId) = 0;
160
172 virtual int disconnect() = 0;
173
201 virtual int startLastmileProbeTest(const LastmileProbeConfig& config) = 0;
202
209 virtual int stopLastmileProbeTest() = 0;
210
221 virtual int renewToken(const char* token) = 0;
222
231
239 virtual ILocalUser* getLocalUser() = 0;
240
253 virtual int getRemoteUsers(UserList& users) = 0;
254
265 virtual int getUserInfo(user_id_t userId, agora::UserInfo& userInfo) = 0;
266
275 virtual int registerObserver(IRtcConnectionObserver* observer, void(*safeDeleter)(IRtcConnectionObserver*) = NULL) = 0;
276
286 virtual int unregisterObserver(IRtcConnectionObserver* observer) = 0;
287
296 virtual int registerNetworkObserver(INetworkObserver* observer, void(*safeDeleter)(INetworkObserver*) = NULL) = 0;
297
307 virtual int unregisterNetworkObserver(INetworkObserver* observer) = 0;
308
316 virtual conn_id_t getConnId() = 0;
317
326
335
369 virtual int createDataStream(int* streamId, bool reliable, bool ordered, bool sync) = 0;
370
397 virtual int sendStreamMessage(int streamId, const char* data, size_t length) = 0;
398
417 virtual int enableEncryption(bool enabled, const EncryptionConfig& config) = 0;
418
430 virtual int getUserInfoByUserAccount(const char* userAccount, rtc::UserInfo* userInfo) = 0;
442 virtual int getUserInfoByUid(uid_t uid, rtc::UserInfo* userInfo) = 0;
443};
444
449 public:
451
458 virtual void onConnected(const TConnectionInfo& connectionInfo, CONNECTION_CHANGED_REASON_TYPE reason) = 0;
459
466 virtual void onDisconnected(const TConnectionInfo& connectionInfo, CONNECTION_CHANGED_REASON_TYPE reason) = 0;
467
474 virtual void onConnecting(const TConnectionInfo& connectionInfo, CONNECTION_CHANGED_REASON_TYPE reason) = 0;
475
482 virtual void onReconnecting(const TConnectionInfo& connectionInfo, CONNECTION_CHANGED_REASON_TYPE reason) = 0;
483
484 // This should be deleted. onConnected is enough.
485 virtual void onReconnected(const TConnectionInfo& connectionInfo, CONNECTION_CHANGED_REASON_TYPE reason) = 0;
486
492 virtual void onConnectionLost(const TConnectionInfo& connectionInfo) = 0;
493
501 virtual void onLastmileQuality(const QUALITY_TYPE quality) = 0;
502
510 virtual void onLastmileProbeResult(const LastmileProbeResult& result) = 0;
511
522 virtual void onTokenPrivilegeWillExpire(const char* token) = 0;
523
529 virtual void onTokenPrivilegeDidExpire() = 0;
530
537 virtual void onConnectionFailure(const TConnectionInfo& connectionInfo,
539
547 virtual void onUserJoined(user_id_t userId) = 0;
548
557 virtual void onUserLeft(user_id_t userId, USER_OFFLINE_REASON_TYPE reason) = 0;
558
566 virtual void onTransportStats(const RtcStats& stats) = 0;
567
575 (void)oldRole;
576 (void)newRole;
577 }
578
582 virtual void onChangeRoleFailure() {}
583
594 virtual void onUserNetworkQuality(user_id_t userId, QUALITY_TYPE txQuality,
595 QUALITY_TYPE rxQuality) {
596 (void)userId;
597 (void)txQuality;
598 (void)rxQuality;
599 }
600
605 (void)type;
606 }
607
616 virtual void onApiCallExecuted(int err, const char* api, const char* result) {
617 (void)err;
618 (void)api;
619 (void)result;
620 }
622
623 virtual void onContentInspectResult(media::CONTENT_INSPECT_RESULT result) { (void)result; }
636 virtual void onSnapshotTaken(const char* channel, uid_t uid, const char* filePath, int width, int height, int errCode) {
637 (void)channel;
638 (void)uid;
639 (void)filePath;
640 (void)width;
641 (void)height;
642 (void)errCode;
643 }
649 virtual void onError(ERROR_CODE_TYPE error, const char* msg) {
650 (void)error;
651 (void)msg;
652 }
653
659 virtual void onWarning(WARN_CODE_TYPE warning, const char* msg) {
660 (void)warning;
661 (void)msg;
662 }
664
693 virtual void onChannelMediaRelayStateChanged(int state, int code) = 0;
695
700 virtual void onLocalUserRegistered(uid_t uid, const char* userAccount) {
701 (void)uid;
702 (void)userAccount;
703 }
704
706 virtual void onUserAccountUpdated(uid_t uid, const char* userAccount){
707 (void)uid;
708 (void)userAccount;
709 }
710
720 virtual void onStreamMessageError(user_id_t userId, int streamId, int code, int missed,
721 int cached) {
722 (void)userId;
723 (void)streamId;
724 (void)code;
725 (void)missed;
726 (void)cached;
727 }
729
733 virtual void onEncryptionError(ENCRYPTION_ERROR_TYPE errorType) {
734 (void)errorType;
735 }
737
743 virtual void onUploadLogResult(const char* requestId, bool success, UPLOAD_ERROR_REASON reason) {
744 (void)requestId;
745 (void)success;
746 (void)reason;
747 }
749};
750
752 public:
753 virtual ~INetworkObserver() {}
754
755 public:
765 (void)info;
766 }
767
776 (void)info;
777 }
778};
779
780} // namespace rtc
781} // namespace agora
Definition: IAgoraParameter.h:226
Definition: NGIAgoraLocalUser.h:48
Definition: NGIAgoraRtcConnection.h:751
virtual void onDownlinkNetworkInfoUpdated(const DownlinkNetworkInfo &info)
Definition: NGIAgoraRtcConnection.h:775
virtual void onUplinkNetworkInfoUpdated(const UplinkNetworkInfo &info)
Definition: NGIAgoraRtcConnection.h:764
virtual ~INetworkObserver()
Definition: NGIAgoraRtcConnection.h:753
Definition: NGIAgoraRtcConnection.h:127
virtual int connect(const char *token, const char *channelId, user_id_t userId)=0
virtual int sendStreamMessage(int streamId, const char *data, size_t length)=0
virtual int stopLastmileProbeTest()=0
virtual conn_id_t getConnId()=0
virtual int createDataStream(int *streamId, bool reliable, bool ordered, bool sync)=0
virtual int unregisterNetworkObserver(INetworkObserver *observer)=0
~IRtcConnection()
Definition: NGIAgoraRtcConnection.h:129
virtual int renewToken(const char *token)=0
virtual int getUserInfoByUid(uid_t uid, rtc::UserInfo *userInfo)=0
virtual ILocalUser * getLocalUser()=0
virtual int registerNetworkObserver(INetworkObserver *observer, void(*safeDeleter)(INetworkObserver *)=NULL)=0
virtual int disconnect()=0
virtual RtcStats getTransportStats()=0
virtual int getUserInfoByUserAccount(const char *userAccount, rtc::UserInfo *userInfo)=0
virtual TConnectionInfo getConnectionInfo()=0
virtual int startLastmileProbeTest(const LastmileProbeConfig &config)=0
virtual int registerObserver(IRtcConnectionObserver *observer, void(*safeDeleter)(IRtcConnectionObserver *)=NULL)=0
virtual int getRemoteUsers(UserList &users)=0
virtual int getUserInfo(user_id_t userId, agora::UserInfo &userInfo)=0
virtual int unregisterObserver(IRtcConnectionObserver *observer)=0
virtual int enableEncryption(bool enabled, const EncryptionConfig &config)=0
virtual agora::base::IAgoraParameter * getAgoraParameter()=0
Definition: NGIAgoraRtcConnection.h:448
virtual void onChannelMediaRelayStateChanged(int state, int code)=0
virtual void onUserLeft(user_id_t userId, USER_OFFLINE_REASON_TYPE reason)=0
virtual void onConnectionLost(const TConnectionInfo &connectionInfo)=0
virtual void onNetworkTypeChanged(NETWORK_TYPE type)
Definition: NGIAgoraRtcConnection.h:604
virtual void onConnected(const TConnectionInfo &connectionInfo, CONNECTION_CHANGED_REASON_TYPE reason)=0
virtual void onEncryptionError(ENCRYPTION_ERROR_TYPE errorType)
Definition: NGIAgoraRtcConnection.h:733
virtual void onLastmileQuality(const QUALITY_TYPE quality)=0
virtual void onChangeRoleSuccess(CLIENT_ROLE_TYPE oldRole, CLIENT_ROLE_TYPE newRole)
Definition: NGIAgoraRtcConnection.h:574
virtual void onTokenPrivilegeWillExpire(const char *token)=0
virtual void onConnectionFailure(const TConnectionInfo &connectionInfo, CONNECTION_CHANGED_REASON_TYPE reason)=0
virtual ~IRtcConnectionObserver()
Definition: NGIAgoraRtcConnection.h:450
virtual void onReconnecting(const TConnectionInfo &connectionInfo, CONNECTION_CHANGED_REASON_TYPE reason)=0
virtual void onLastmileProbeResult(const LastmileProbeResult &result)=0
virtual void onTransportStats(const RtcStats &stats)=0
virtual void onApiCallExecuted(int err, const char *api, const char *result)
Definition: NGIAgoraRtcConnection.h:616
virtual void onUserNetworkQuality(user_id_t userId, QUALITY_TYPE txQuality, QUALITY_TYPE rxQuality)
Definition: NGIAgoraRtcConnection.h:594
virtual void onReconnected(const TConnectionInfo &connectionInfo, CONNECTION_CHANGED_REASON_TYPE reason)=0
virtual void onTokenPrivilegeDidExpire()=0
virtual void onUserJoined(user_id_t userId)=0
virtual void onDisconnected(const TConnectionInfo &connectionInfo, CONNECTION_CHANGED_REASON_TYPE reason)=0
virtual void onChangeRoleFailure()
Definition: NGIAgoraRtcConnection.h:582
virtual void onConnecting(const TConnectionInfo &connectionInfo, CONNECTION_CHANGED_REASON_TYPE reason)=0
Definition: AgoraBase.h:269
Definition: AgoraBase.h:179
CONNECTION_CHANGED_REASON_TYPE
Definition: AgoraBase.h:3524
ENCRYPTION_ERROR_TYPE
Definition: AgoraBase.h:4807
CLIENT_ROLE_TYPE
Definition: AgoraBase.h:2414
@ CLIENT_ROLE_AUDIENCE
Definition: AgoraBase.h:2422
CONNECTION_STATE_TYPE
Definition: AgoraBase.h:3391
@ CONNECTION_STATE_DISCONNECTED
Definition: AgoraBase.h:3395
USER_OFFLINE_REASON_TYPE
Definition: AgoraBase.h:1236
NETWORK_TYPE
Definition: AgoraBase.h:3608
unsigned int uid_t
Definition: AgoraMediaBase.h:25
unsigned int conn_id_t
Definition: AgoraMediaBase.h:27
QUALITY_TYPE
Definition: AgoraBase.h:1274
Definition: AgoraBase.h:86
const char * user_id_t
Definition: AgoraBase.h:1198
CHANNEL_PROFILE_TYPE
Definition: AgoraBase.h:306
@ CHANNEL_PROFILE_LIVE_BROADCASTING
Definition: AgoraBase.h:318
Definition: AgoraBase.h:1205
Definition: AgoraBase.h:4755
Definition: AgoraBase.h:3420
Definition: AgoraBase.h:3497
Definition: NGIAgoraRtcConnection.h:55
bool autoSubscribeAudio
Definition: NGIAgoraRtcConnection.h:61
bool audioRecvMediaPacket
Definition: NGIAgoraRtcConnection.h:97
RtcConnectionConfiguration()
Definition: NGIAgoraRtcConnection.h:104
CLIENT_ROLE_TYPE clientRoleType
Definition: NGIAgoraRtcConnection.h:89
int maxSendBitrate
Definition: NGIAgoraRtcConnection.h:77
int maxPort
Definition: NGIAgoraRtcConnection.h:85
CHANNEL_PROFILE_TYPE channelProfile
Definition: NGIAgoraRtcConnection.h:92
int minPort
Definition: NGIAgoraRtcConnection.h:81
bool videoRecvMediaPacket
Definition: NGIAgoraRtcConnection.h:102
bool enableAudioRecordingOrPlayout
Definition: NGIAgoraRtcConnection.h:73
bool autoSubscribeVideo
Definition: NGIAgoraRtcConnection.h:67
Definition: AgoraBase.h:2173
Definition: NGIAgoraRtcConnection.h:24
TConnectionInfo()
Definition: NGIAgoraRtcConnection.h:47
conn_id_t id
Definition: NGIAgoraRtcConnection.h:28
util::AString localUserId
Definition: NGIAgoraRtcConnection.h:40
CONNECTION_STATE_TYPE state
Definition: NGIAgoraRtcConnection.h:36
util::AString channelId
Definition: NGIAgoraRtcConnection.h:32
Definition: AgoraBase.h:4901