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
337
371 virtual int createDataStream(int* streamId, bool reliable, bool ordered, bool sync) = 0;
372
399 virtual int sendStreamMessage(int streamId, const char* data, size_t length) = 0;
400
418 virtual int enableEncryption(bool enabled, const EncryptionConfig& config) = 0;
419
431 virtual int getUserInfoByUserAccount(const char* userAccount, rtc::UserInfo* userInfo) = 0;
443 virtual int getUserInfoByUid(uid_t uid, rtc::UserInfo* userInfo) = 0;
444};
445
450 public:
452
459 virtual void onConnected(const TConnectionInfo& connectionInfo, CONNECTION_CHANGED_REASON_TYPE reason) = 0;
460
467 virtual void onDisconnected(const TConnectionInfo& connectionInfo, CONNECTION_CHANGED_REASON_TYPE reason) = 0;
468
475 virtual void onConnecting(const TConnectionInfo& connectionInfo, CONNECTION_CHANGED_REASON_TYPE reason) = 0;
476
483 virtual void onReconnecting(const TConnectionInfo& connectionInfo, CONNECTION_CHANGED_REASON_TYPE reason) = 0;
484
485 // This should be deleted. onConnected is enough.
486 virtual void onReconnected(const TConnectionInfo& connectionInfo, CONNECTION_CHANGED_REASON_TYPE reason) = 0;
487
493 virtual void onConnectionLost(const TConnectionInfo& connectionInfo) = 0;
494
502 virtual void onLastmileQuality(const QUALITY_TYPE quality) = 0;
503
511 virtual void onLastmileProbeResult(const LastmileProbeResult& result) = 0;
512
523 virtual void onTokenPrivilegeWillExpire(const char* token) = 0;
524
530 virtual void onTokenPrivilegeDidExpire() = 0;
531
538 virtual void onConnectionFailure(const TConnectionInfo& connectionInfo,
540
548 virtual void onUserJoined(user_id_t userId) = 0;
549
558 virtual void onUserLeft(user_id_t userId, USER_OFFLINE_REASON_TYPE reason) = 0;
559
567 virtual void onTransportStats(const RtcStats& stats) = 0;
568
576 (void)oldRole;
577 (void)newRole;
578 }
579
583 virtual void onChangeRoleFailure() {}
584
595 virtual void onUserNetworkQuality(user_id_t userId, QUALITY_TYPE txQuality,
596 QUALITY_TYPE rxQuality) {
597 (void)userId;
598 (void)txQuality;
599 (void)rxQuality;
600 }
601
606 (void)type;
607 }
608
617 virtual void onApiCallExecuted(int err, const char* api, const char* result) {
618 (void)err;
619 (void)api;
620 (void)result;
621 }
623
624 virtual void onContentInspectResult(media::CONTENT_INSPECT_RESULT result) { (void)result; }
637 virtual void onSnapshotTaken(const char* channel, uid_t uid, const char* filePath, int width, int height, int errCode) {
638 (void)channel;
639 (void)uid;
640 (void)filePath;
641 (void)width;
642 (void)height;
643 (void)errCode;
644 }
650 virtual void onWarning(WARN_CODE_TYPE warning, const char* msg) {
651 (void)warning;
652 (void)msg;
653 }
655
664 virtual void onError(ERROR_CODE_TYPE error, const char* msg) {
665 (void)error;
666 (void)msg;
667 }
668
698 virtual void onChannelMediaRelayStateChanged(int state, int code) = 0;
700
705 virtual void onLocalUserRegistered(uid_t uid, const char* userAccount) {
706 (void)uid;
707 (void)userAccount;
708 }
709
711 virtual void onUserAccountUpdated(uid_t uid, const char* userAccount){
712 (void)uid;
713 (void)userAccount;
714 }
715
725 virtual void onStreamMessageError(user_id_t userId, int streamId, int code, int missed,
726 int cached) {
727 (void)userId;
728 (void)streamId;
729 (void)code;
730 (void)missed;
731 (void)cached;
732 }
734
738 virtual void onEncryptionError(ENCRYPTION_ERROR_TYPE errorType) {
739 (void)errorType;
740 }
742
748 virtual void onUploadLogResult(const char* requestId, bool success, UPLOAD_ERROR_REASON reason) {
749 (void)requestId;
750 (void)success;
751 (void)reason;
752 }
754};
755
757 public:
758 virtual ~INetworkObserver() {}
759
760 public:
770 (void)info;
771 }
772
781 (void)info;
782 }
783};
784
785} // namespace rtc
786} // namespace agora
Definition: IAgoraParameter.h:226
Definition: NGIAgoraLocalUser.h:48
Definition: NGIAgoraRtcConnection.h:756
virtual void onDownlinkNetworkInfoUpdated(const DownlinkNetworkInfo &info)
Definition: NGIAgoraRtcConnection.h:780
virtual void onUplinkNetworkInfoUpdated(const UplinkNetworkInfo &info)
Definition: NGIAgoraRtcConnection.h:769
virtual ~INetworkObserver()
Definition: NGIAgoraRtcConnection.h:758
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:449
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:605
virtual void onConnected(const TConnectionInfo &connectionInfo, CONNECTION_CHANGED_REASON_TYPE reason)=0
virtual void onEncryptionError(ENCRYPTION_ERROR_TYPE errorType)
Definition: NGIAgoraRtcConnection.h:738
virtual void onLastmileQuality(const QUALITY_TYPE quality)=0
virtual void onChangeRoleSuccess(CLIENT_ROLE_TYPE oldRole, CLIENT_ROLE_TYPE newRole)
Definition: NGIAgoraRtcConnection.h:575
virtual void onTokenPrivilegeWillExpire(const char *token)=0
virtual void onConnectionFailure(const TConnectionInfo &connectionInfo, CONNECTION_CHANGED_REASON_TYPE reason)=0
virtual void onError(ERROR_CODE_TYPE error, const char *msg)
Definition: NGIAgoraRtcConnection.h:664
virtual ~IRtcConnectionObserver()
Definition: NGIAgoraRtcConnection.h:451
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:617
virtual void onUserNetworkQuality(user_id_t userId, QUALITY_TYPE txQuality, QUALITY_TYPE rxQuality)
Definition: NGIAgoraRtcConnection.h:595
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:583
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:3528
ENCRYPTION_ERROR_TYPE
Definition: AgoraBase.h:4811
CLIENT_ROLE_TYPE
Definition: AgoraBase.h:2414
@ CLIENT_ROLE_AUDIENCE
Definition: AgoraBase.h:2422
CONNECTION_STATE_TYPE
Definition: AgoraBase.h:3395
@ CONNECTION_STATE_DISCONNECTED
Definition: AgoraBase.h:3399
USER_OFFLINE_REASON_TYPE
Definition: AgoraBase.h:1236
NETWORK_TYPE
Definition: AgoraBase.h:3612
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:4759
Definition: AgoraBase.h:3424
Definition: AgoraBase.h:3501
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:4905