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
416 virtual int enableEncryption(bool enabled, const EncryptionConfig& config) = 0;
417
429 virtual int getUserInfoByUserAccount(const char* userAccount, rtc::UserInfo* userInfo) = 0;
441 virtual int getUserInfoByUid(uid_t uid, rtc::UserInfo* userInfo) = 0;
442};
443
448 public:
450
457 virtual void onConnected(const TConnectionInfo& connectionInfo, CONNECTION_CHANGED_REASON_TYPE reason) = 0;
458
465 virtual void onDisconnected(const TConnectionInfo& connectionInfo, CONNECTION_CHANGED_REASON_TYPE reason) = 0;
466
473 virtual void onConnecting(const TConnectionInfo& connectionInfo, CONNECTION_CHANGED_REASON_TYPE reason) = 0;
474
481 virtual void onReconnecting(const TConnectionInfo& connectionInfo, CONNECTION_CHANGED_REASON_TYPE reason) = 0;
482
483 // This should be deleted. onConnected is enough.
484 virtual void onReconnected(const TConnectionInfo& connectionInfo, CONNECTION_CHANGED_REASON_TYPE reason) = 0;
485
491 virtual void onConnectionLost(const TConnectionInfo& connectionInfo) = 0;
492
500 virtual void onLastmileQuality(const QUALITY_TYPE quality) = 0;
501
509 virtual void onLastmileProbeResult(const LastmileProbeResult& result) = 0;
510
521 virtual void onTokenPrivilegeWillExpire(const char* token) = 0;
522
528 virtual void onTokenPrivilegeDidExpire() = 0;
529
536 virtual void onConnectionFailure(const TConnectionInfo& connectionInfo,
538
546 virtual void onUserJoined(user_id_t userId) = 0;
547
556 virtual void onUserLeft(user_id_t userId, USER_OFFLINE_REASON_TYPE reason) = 0;
557
565 virtual void onTransportStats(const RtcStats& stats) = 0;
566
574 (void)oldRole;
575 (void)newRole;
576 }
577
581 virtual void onChangeRoleFailure() {}
582
593 virtual void onUserNetworkQuality(user_id_t userId, QUALITY_TYPE txQuality,
594 QUALITY_TYPE rxQuality) {
595 (void)userId;
596 (void)txQuality;
597 (void)rxQuality;
598 }
599
604 (void)type;
605 }
606
615 virtual void onApiCallExecuted(int err, const char* api, const char* result) {
616 (void)err;
617 (void)api;
618 (void)result;
619 }
621
622 virtual void onContentInspectResult(media::CONTENT_INSPECT_RESULT result) { (void)result; }
635 virtual void onSnapshotTaken(const char* channel, uid_t uid, const char* filePath, int width, int height, int errCode) {
636 (void)channel;
637 (void)uid;
638 (void)filePath;
639 (void)width;
640 (void)height;
641 (void)errCode;
642 }
648 virtual void onError(ERROR_CODE_TYPE error, const char* msg) {
649 (void)error;
650 (void)msg;
651 }
652
658 virtual void onWarning(WARN_CODE_TYPE warning, const char* msg) {
659 (void)warning;
660 (void)msg;
661 }
663
692 virtual void onChannelMediaRelayStateChanged(int state, int code) = 0;
694
699 virtual void onLocalUserRegistered(uid_t uid, const char* userAccount) {
700 (void)uid;
701 (void)userAccount;
702 }
703
705 virtual void onUserAccountUpdated(uid_t uid, const char* userAccount){
706 (void)uid;
707 (void)userAccount;
708 }
709
719 virtual void onStreamMessageError(user_id_t userId, int streamId, int code, int missed,
720 int cached) {
721 (void)userId;
722 (void)streamId;
723 (void)code;
724 (void)missed;
725 (void)cached;
726 }
728
732 virtual void onEncryptionError(ENCRYPTION_ERROR_TYPE errorType) {
733 (void)errorType;
734 }
736
742 virtual void onUploadLogResult(const char* requestId, bool success, UPLOAD_ERROR_REASON reason) {
743 (void)requestId;
744 (void)success;
745 (void)reason;
746 }
748};
749
751 public:
752 virtual ~INetworkObserver() {}
753
754 public:
764 (void)info;
765 }
766
775 (void)info;
776 }
777};
778
779} // namespace rtc
780} // namespace agora
Definition: IAgoraParameter.h:226
Definition: NGIAgoraLocalUser.h:48
Definition: NGIAgoraRtcConnection.h:750
virtual void onDownlinkNetworkInfoUpdated(const DownlinkNetworkInfo &info)
Definition: NGIAgoraRtcConnection.h:774
virtual void onUplinkNetworkInfoUpdated(const UplinkNetworkInfo &info)
Definition: NGIAgoraRtcConnection.h:763
virtual ~INetworkObserver()
Definition: NGIAgoraRtcConnection.h:752
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:447
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:603
virtual void onConnected(const TConnectionInfo &connectionInfo, CONNECTION_CHANGED_REASON_TYPE reason)=0
virtual void onEncryptionError(ENCRYPTION_ERROR_TYPE errorType)
Definition: NGIAgoraRtcConnection.h:732
virtual void onLastmileQuality(const QUALITY_TYPE quality)=0
virtual void onChangeRoleSuccess(CLIENT_ROLE_TYPE oldRole, CLIENT_ROLE_TYPE newRole)
Definition: NGIAgoraRtcConnection.h:573
virtual void onTokenPrivilegeWillExpire(const char *token)=0
virtual void onConnectionFailure(const TConnectionInfo &connectionInfo, CONNECTION_CHANGED_REASON_TYPE reason)=0
virtual ~IRtcConnectionObserver()
Definition: NGIAgoraRtcConnection.h:449
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:615
virtual void onUserNetworkQuality(user_id_t userId, QUALITY_TYPE txQuality, QUALITY_TYPE rxQuality)
Definition: NGIAgoraRtcConnection.h:593
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:581
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