From 077247ae0a61cd2940bc0bd73cc55a5a4847a4f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A4=8F=E7=BE=8A=E7=BE=A4?= Date: Wed, 20 Mar 2024 10:32:38 +0800 Subject: [PATCH] update 4.3.1 to 2024.3.20 --- headers/rtc_4.3.1/include/AgoraBase.h | 30 + headers/rtc_4.3.1/include/IAgoraRtcEngine.h | 44 + .../custom_headers/CustomIAgoraRtmClient.h | 26 + .../custom_headers/CustomIAgoraRtmStorage.h | 34 + .../CustomIAgoraStreamChannel.h | 22 + headers/rtm_2.1.10/include/AgoraRtmBase.h | 1211 +++++++++++++++++ headers/rtm_2.1.10/include/IAgoraRtmClient.h | 843 ++++++++++++ headers/rtm_2.1.10/include/IAgoraRtmLock.h | 107 ++ .../rtm_2.1.10/include/IAgoraRtmPresence.h | 116 ++ headers/rtm_2.1.10/include/IAgoraRtmService.h | 715 ++++++++++ headers/rtm_2.1.10/include/IAgoraRtmStorage.h | 257 ++++ headers/rtm_2.1.10/include/IAgoraService.h | 965 +++++++++++++ .../rtm_2.1.10/include/IAgoraStreamChannel.h | 242 ++++ headers/rtm_2.1.10/shared_configs.yaml | 19 + 14 files changed, 4631 insertions(+) create mode 100644 headers/rtm_2.1.10/custom_headers/CustomIAgoraRtmClient.h create mode 100644 headers/rtm_2.1.10/custom_headers/CustomIAgoraRtmStorage.h create mode 100644 headers/rtm_2.1.10/custom_headers/CustomIAgoraStreamChannel.h create mode 100644 headers/rtm_2.1.10/include/AgoraRtmBase.h create mode 100644 headers/rtm_2.1.10/include/IAgoraRtmClient.h create mode 100644 headers/rtm_2.1.10/include/IAgoraRtmLock.h create mode 100644 headers/rtm_2.1.10/include/IAgoraRtmPresence.h create mode 100644 headers/rtm_2.1.10/include/IAgoraRtmService.h create mode 100644 headers/rtm_2.1.10/include/IAgoraRtmStorage.h create mode 100644 headers/rtm_2.1.10/include/IAgoraService.h create mode 100644 headers/rtm_2.1.10/include/IAgoraStreamChannel.h create mode 100644 headers/rtm_2.1.10/shared_configs.yaml diff --git a/headers/rtc_4.3.1/include/AgoraBase.h b/headers/rtc_4.3.1/include/AgoraBase.h index 708a747..831bd9e 100644 --- a/headers/rtc_4.3.1/include/AgoraBase.h +++ b/headers/rtc_4.3.1/include/AgoraBase.h @@ -1185,6 +1185,28 @@ enum VIDEO_CODEC_TYPE { VIDEO_CODEC_GENERIC_JPEG = 20, }; +/** + * Camera focal length type. + */ +enum CAMERA_FOCAL_LENGTH_TYPE { + /** + * By default, there are no wide-angle and ultra-wide-angle properties. + */ + CAMERA_FOCAL_LENGTH_DEFAULT = 0, + /** + * Lens with focal length from 24mm to 35mm. + */ + CAMERA_FOCAL_LENGTH_WIDE_ANGLE = 1, + /** + * Lens with focal length of less than 24mm. + */ + CAMERA_FOCAL_LENGTH_URLTRA_WIDE = 2, + /** + * Telephoto lens. + */ + CAMERA_FOCAL_LENGTH_TELEPHOTO = 3, +}; + /** * The CC (Congestion Control) mode options. */ @@ -1776,6 +1798,14 @@ struct CodecCapInfo { CodecCapInfo(): codecType(VIDEO_CODEC_NONE), codecCapMask(0) {} }; +/** FocalLengthInfo contains the IDs of the front and rear cameras, along with the wide-angle types. */ +struct FocalLengthInfo { + /** The camera direction. */ + int cameraDirection; + /** Camera focal segment type. */ + CAMERA_FOCAL_LENGTH_TYPE focalLengthType; +}; + /** * The definition of the VideoEncoderConfiguration struct. */ diff --git a/headers/rtc_4.3.1/include/IAgoraRtcEngine.h b/headers/rtc_4.3.1/include/IAgoraRtcEngine.h index dc9015f..8f4f708 100644 --- a/headers/rtc_4.3.1/include/IAgoraRtcEngine.h +++ b/headers/rtc_4.3.1/include/IAgoraRtcEngine.h @@ -798,6 +798,16 @@ struct CameraCapturerConfiguration { * The camera direction. */ CAMERA_DIRECTION cameraDirection; + + /*- CAMERA_FOCAL_LENGTH_TYPE.CAMERA_FOCAL_LENGTH_DEFAULT: + For iOS, if iPhone/iPad has 3 or 2 back camera, it means combination of triple (wide + ultra wide + telephoto) camera + or dual wide(wide + ultra wide) camera.In this situation, you can apply for ultra wide len by set smaller zoom fator + and bigger zoom fator for telephoto len.Otherwise, it always means wide back/front camera. + + - CAMERA_FOCAL_LENGTH_TYPE.CAMERA_FOCAL_LENGTH_WIDE_ANGLE:wide camera + - CAMERA_FOCAL_LENGTH_TYPE.CAMERA_FOCAL_LENGTH_URLTRA_WIDE:ultra wide camera + - CAMERA_FOCAL_LENGTH_TYPE.CAMERA_FOCAL_LENGTH_TELEPHOTO:telephoto camera*/ + CAMERA_FOCAL_LENGTH_TYPE cameraFocalLengthType; #else /** For windows. The device ID of the playback device. The maximum length is #MAX_DEVICE_ID_LENGTH. */ char deviceId[MAX_DEVICE_ID_LENGTH]; @@ -2135,6 +2145,25 @@ class IRtcEngineEventHandler { (void) vecDistance; (void) numFaces; } + +#if defined(__ANDROID__) + /** + * When the actual configuration is different from the preset configuration, the callback is triggered. + * + * @param direction Camera orientation, front or back. + * @param focalLengthType The focal length of the camera, wide Angle, super wide Angle or ordinary lens. + * @param width Camera acquisition width. + * @param height Camera acquisition width. + * @param frameRate Camera acquisition frameRate. + */ + virtual void onCameraCapturerConfigurationChanged(int direction, int focalLengthType, int width, int height, int frameRate) { + (void)direction; + (void)focalLengthType; + (void)width; + (void)height; + (void)frameRate; + } +#endif // __ANDROID__ #endif /** * Occurs when the video stops playing. @@ -7060,6 +7089,18 @@ class IRtcEngine : public agora::base::IEngineBase { * - < 0: Failure.. */ virtual int getAudioDeviceInfo(DeviceInfo& deviceInfo) = 0; + /** + * Query all focal attributes supported by the camera. + * + * @param focalLengthInfos The camera supports the collection of focal segments. + * + * @param size The camera supports the size of the focal segment set. + * + * @return + * - 0: Success. + * - < 0: Failure.. + */ + virtual int queryCameraFocalLengthCapability(agora::rtc::FocalLengthInfo* focalLengthInfos, int& size) = 0; #endif // __ANDROID__ @@ -7171,6 +7212,9 @@ class IRtcEngine : public agora::base::IEngineBase { * - < 0: Failure. */ virtual int queryScreenCaptureCapability() = 0; +#if defined(__APPLE__) && TARGET_OS_IOS + virtual int queryCameraFocalLengthCapability(agora::rtc::FocalLengthInfo* focalLengthInfo, int& size) = 0; +#endif #endif #if defined(_WIN32) || defined(__APPLE__) || defined(__ANDROID__) diff --git a/headers/rtm_2.1.10/custom_headers/CustomIAgoraRtmClient.h b/headers/rtm_2.1.10/custom_headers/CustomIAgoraRtmClient.h new file mode 100644 index 0000000..8a770c9 --- /dev/null +++ b/headers/rtm_2.1.10/custom_headers/CustomIAgoraRtmClient.h @@ -0,0 +1,26 @@ +#pragma once + +#include "IAgoraStreamChannel.h" +#include "IAgoraRtmStorage.h" +#include "IAgoraRtmPresence.h" +#include "IAgoraRtmLock.h" +#include "AgoraRtmBase.h" +#include "IAgoraRtmClient.h" + +namespace agora { +namespace rtm { +namespace ext { + +class IRtmClient { + // ----------------------------- 👇🏻new API👇🏻 ----------------------------- + + // IRtmClient + //virtual int publish(const char* channelName, const char* message, const size_t length, const PublishOptions& option, uint64_t& requestId) = 0; + virtual int publishWithBuffer(const char* channelName, const unsigned char* message, const size_t length, const PublishOptions& option, uint64_t& requestId) = 0; + + // ----------------------------- 👆🏻new API👆🏻 ----------------------------- +}; + +} // namespace ext +} // namespace rtm +} // namespace agora \ No newline at end of file diff --git a/headers/rtm_2.1.10/custom_headers/CustomIAgoraRtmStorage.h b/headers/rtm_2.1.10/custom_headers/CustomIAgoraRtmStorage.h new file mode 100644 index 0000000..250d30e --- /dev/null +++ b/headers/rtm_2.1.10/custom_headers/CustomIAgoraRtmStorage.h @@ -0,0 +1,34 @@ +#pragma once + +#include "AgoraRtmBase.h" +#include "IAgoraRtmStorage.h" + +namespace agora { +namespace rtm { +namespace ext { + +struct RtmMetadata { + // ----------------------------- 👇🏻new API👇🏻 ----------------------------- + /** + * The key of the metadata item. + */ + const int64_t majorRevision; + /** + * The value of the metadata item. + */ + const MetadataItem* metadataItems; + /** + * The User ID of the user who makes the latest update to the metadata item. + */ + const uint64_t metadataItemsSize; + + RtmMetadata() : majorRevision(-1), + metadataItems(NULL), + metadataItemsSize(NULL) {} + + // ----------------------------- 👆🏻new API👆🏻 ----------------------------- +}; + +} // namespace ext +} // namespace rtm +} // namespace agora diff --git a/headers/rtm_2.1.10/custom_headers/CustomIAgoraStreamChannel.h b/headers/rtm_2.1.10/custom_headers/CustomIAgoraStreamChannel.h new file mode 100644 index 0000000..f26b47d --- /dev/null +++ b/headers/rtm_2.1.10/custom_headers/CustomIAgoraStreamChannel.h @@ -0,0 +1,22 @@ +#pragma once + +#include "AgoraRtmBase.h" +#include "IAgoraStreamChannel.h" + +namespace agora { +namespace rtm { +namespace ext { + +class IStreamChannel { + // ----------------------------- 👇🏻new API👇🏻 ----------------------------- + + // IStreamChannel + //virtual int publishTopicMessage(const char* topic, const char* message, size_t length, const PublishOptions& option) = 0; + virtual int publishTopicMessageWithBuffer(const char* topic, const unsigned char* message, size_t length, const PublishOptions& option) = 0; + + // ----------------------------- 👆🏻new API👆🏻 ----------------------------- +}; + +} // namespace ext +} // namespace rtm +} // namespace agora \ No newline at end of file diff --git a/headers/rtm_2.1.10/include/AgoraRtmBase.h b/headers/rtm_2.1.10/include/AgoraRtmBase.h new file mode 100644 index 0000000..8ec74a7 --- /dev/null +++ b/headers/rtm_2.1.10/include/AgoraRtmBase.h @@ -0,0 +1,1211 @@ +// Copyright (c) 2022 Agora.io. All rights reserved + +// This program is confidential and proprietary to Agora.io. +// And may not be copied, reproduced, modified, disclosed to others, published +// or used, in whole or in part, without the express prior written permission +// of Agora.io. + +#pragma once // NOLINT(build/header_guard) + +#include +#include +#include +#include +#include +#include + +#if defined(_WIN32) + +#ifndef WIN32_LEAN_AND_MEAN +#define WIN32_LEAN_AND_MEAN +#endif // !WIN32_LEAN_AND_MEAN +#if defined(__aarch64__) +#include +#endif +#include + +#if defined(AGORARTC_EXPORT) +#define AGORA_API extern "C" __declspec(dllexport) +#else +#define AGORA_API extern "C" __declspec(dllimport) +#endif // AGORARTC_EXPORT + +#define AGORA_CALL __cdecl + +#define __deprecated + +#elif defined(__APPLE__) + +#include + +#define AGORA_API extern "C" __attribute__((visibility("default"))) +#define AGORA_CALL + +#elif defined(__ANDROID__) || defined(__linux__) + +#define AGORA_API extern "C" __attribute__((visibility("default"))) +#define AGORA_CALL + +#define __deprecated + +#else // !_WIN32 && !__APPLE__ && !(__ANDROID__ || __linux__) + +#define AGORA_API extern "C" +#define AGORA_CALL + +#define __deprecated + +#endif // _WIN32 + +#ifndef OPTIONAL_ENUM_SIZE_T +#if __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1800) +#define OPTIONAL_ENUM_SIZE_T enum : size_t +#else +#define OPTIONAL_ENUM_SIZE_T enum +#endif +#endif + +#ifndef OPTIONAL_NULLPTR +#if __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1800) +#define OPTIONAL_NULLPTR nullptr +#else +#define OPTIONAL_NULLPTR NULL +#endif +#endif + +namespace agora { +namespace rtm { +const uint32_t DEFAULT_LOG_SIZE_IN_KB = 1024; + +/** + * IP areas. + */ +enum RTM_AREA_CODE { + /** + * Mainland China. + */ + RTM_AREA_CODE_CN = 0x00000001, + /** + * North America. + */ + RTM_AREA_CODE_NA = 0x00000002, + /** + * Europe. + */ + RTM_AREA_CODE_EU = 0x00000004, + /** + * Asia, excluding Mainland China. + */ + RTM_AREA_CODE_AS = 0x00000008, + /** + * Japan. + */ + RTM_AREA_CODE_JP = 0x00000010, + /** + * India. + */ + RTM_AREA_CODE_IN = 0x00000020, + /** + * (Default) Global. + */ + RTM_AREA_CODE_GLOB = (0xFFFFFFFF) +}; + +/** + * The log level for rtm sdk. + */ +enum RTM_LOG_LEVEL { + /** + * 0x0000: No logging. + */ + RTM_LOG_LEVEL_NONE = 0x0000, + /** + * 0x0001: Informational messages. + */ + RTM_LOG_LEVEL_INFO = 0x0001, + /** + * 0x0002: Warnings. + */ + RTM_LOG_LEVEL_WARN = 0x0002, + /** + * 0x0004: Errors. + */ + RTM_LOG_LEVEL_ERROR = 0x0004, + /** + * 0x0008: Critical errors that may lead to program termination. + */ + RTM_LOG_LEVEL_FATAL = 0x0008, +}; + +/** + * The encryption mode. + */ +enum RTM_ENCRYPTION_MODE { + /** + * Disable message encryption. + */ + RTM_ENCRYPTION_MODE_NONE = 0, + /** + * 128-bit AES encryption, GCM mode. + */ + RTM_ENCRYPTION_MODE_AES_128_GCM = 1, + /** + * 256-bit AES encryption, GCM mode. + */ + RTM_ENCRYPTION_MODE_AES_256_GCM = 2, +}; + +/** + * The error codes of rtm client. + */ +enum RTM_ERROR_CODE { + /** + * 0: No error occurs. + */ + RTM_ERROR_OK = 0, + + /** + * -10001 ~ -11000 : reserved for generic error. + * -10001: The SDK is not initialized. + */ + RTM_ERROR_NOT_INITIALIZED = -10001, + /** + * -10002: The user didn't login the RTM system. + */ + RTM_ERROR_NOT_LOGIN = -10002, + /** + * -10003: The app ID is invalid. + */ + RTM_ERROR_INVALID_APP_ID = -10003, + /** + * -10004: The event handler is invalid. + */ + RTM_ERROR_INVALID_EVENT_HANDLER = -10004, + /** + * -10005: The token is invalid. + */ + RTM_ERROR_INVALID_TOKEN = -10005, + /** + * -10006: The user ID is invalid. + */ + RTM_ERROR_INVALID_USER_ID = -10006, + /** + * -10007: The service is not initialized. + */ + RTM_ERROR_INIT_SERVICE_FAILED = -10007, + /** + * -10008: The channel name is invalid. + */ + RTM_ERROR_INVALID_CHANNEL_NAME = -10008, + /** + * -10009: The token has expired. + */ + RTM_ERROR_TOKEN_EXPIRED = -10009, + /** + * -10010: There is no server resources now. + */ + RTM_ERROR_LOGIN_NO_SERVER_RESOURCES = -10010, + /** + * -10011: The login timeout. + */ + RTM_ERROR_LOGIN_TIMEOUT = -10011, + /** + * -10012: The login is rejected by server. + */ + RTM_ERROR_LOGIN_REJECTED = -10012, + /** + * -10013: The login is aborted due to unrecoverable error. + */ + RTM_ERROR_LOGIN_ABORTED = -10013, + /** + * -10014: The parameter is invalid. + */ + RTM_ERROR_INVALID_PARAMETER = -10014, + /** + * -10015: The login is not authorized. Happens user login the RTM system without granted from console. + */ + RTM_ERROR_LOGIN_NOT_AUTHORIZED = -10015, + /** + * -10016: Try to login or join with inconsistent app ID. + */ + RTM_ERROR_INCONSISTENT_APPID = -10016, + /** + * -10017: Already call same request. + */ + RTM_ERROR_DUPLICATE_OPERATION = -10017, + /** + * -10018: Already call destroy or release, this instance is forbidden to call any api, please create new instance. + */ + RTM_ERROR_INSTANCE_ALREADY_RELEASED = -10018, + /** + * -10019: The channel type is invalid. + */ + RTM_ERROR_INVALID_CHANNEL_TYPE = -10019, + /** + * -10020: The encryption parameter is invalid. + */ + RTM_ERROR_INVALID_ENCRYPTION_PARAMETER = -10020, + /** + * -10021: The operation is too frequent. + */ + RTM_ERROR_OPERATION_RATE_EXCEED_LIMITATION = -10021, + + /** + * -11001 ~ -12000 : reserved for channel error. + * -11001: The user has not joined the channel. + */ + RTM_ERROR_CHANNEL_NOT_JOINED = -11001, + /** + * -11002: The user has not subscribed the channel. + */ + RTM_ERROR_CHANNEL_NOT_SUBSCRIBED = -11002, + /** + * -11003: The topic member count exceeds the limit. + */ + RTM_ERROR_CHANNEL_EXCEED_TOPIC_USER_LIMITATION = -11003, + /** + * -11004: The channel is reused in RTC. + */ + RTM_ERROR_CHANNEL_IN_REUSE = -11004, + /** + * -11005: The channel instance count exceeds the limit. + */ + RTM_ERROR_CHANNEL_INSTANCE_EXCEED_LIMITATION = -11005, + /** + * -11006: The channel is in error state. + */ + RTM_ERROR_CHANNEL_IN_ERROR_STATE = -11006, + /** + * -11007: The channel join failed. + */ + RTM_ERROR_CHANNEL_JOIN_FAILED = -11007, + /** + * -11008: The topic name is invalid. + */ + RTM_ERROR_CHANNEL_INVALID_TOPIC_NAME = -11008, + /** + * -11009: The message is invalid. + */ + RTM_ERROR_CHANNEL_INVALID_MESSAGE = -11009, + /** + * -11010: The message length exceeds the limit. + */ + RTM_ERROR_CHANNEL_MESSAGE_LENGTH_EXCEED_LIMITATION = -11010, + /** + * -11011: The user list is invalid. + */ + RTM_ERROR_CHANNEL_INVALID_USER_LIST = -11011, + /** + * -11012: The stream channel is not available. + */ + RTM_ERROR_CHANNEL_NOT_AVAILABLE = -11012, + /** + * -11013: The topic is not subscribed. + */ + RTM_ERROR_CHANNEL_TOPIC_NOT_SUBSCRIBED = -11013, + /** + * -11014: The topic count exceeds the limit. + */ + RTM_ERROR_CHANNEL_EXCEED_TOPIC_LIMITATION = -11014, + /** + * -11015: Join topic failed. + */ + RTM_ERROR_CHANNEL_JOIN_TOPIC_FAILED = -11015, + /** + * -11016: The topic is not joined. + */ + RTM_ERROR_CHANNEL_TOPIC_NOT_JOINED = -11016, + /** + * -11017: The topic does not exist. + */ + RTM_ERROR_CHANNEL_TOPIC_NOT_EXIST = -11017, + /** + * -11018: The topic meta is invalid. + */ + RTM_ERROR_CHANNEL_INVALID_TOPIC_META = -11018, + /** + * -11019: Subscribe channel timeout. + */ + RTM_ERROR_CHANNEL_SUBSCRIBE_TIMEOUT = -11019, + /** + * -11020: Subscribe channel too frequent. + */ + RTM_ERROR_CHANNEL_SUBSCRIBE_TOO_FREQUENT = -11020, + /** + * -11021: Subscribe channel failed. + */ + RTM_ERROR_CHANNEL_SUBSCRIBE_FAILED = -11021, + /** + * -11022: Unsubscribe channel failed. + */ + RTM_ERROR_CHANNEL_UNSUBSCRIBE_FAILED = -11022, + /** + * -11023: Encrypt message failed. + */ + RTM_ERROR_CHANNEL_ENCRYPT_MESSAGE_FAILED = -11023, + /** + * -11024: Publish message failed. + */ + RTM_ERROR_CHANNEL_PUBLISH_MESSAGE_FAILED = -11024, + /** + * -11025: Publish message too frequent. + */ + RTM_ERROR_CHANNEL_PUBLISH_MESSAGE_TOO_FREQUENT = -11025, + /** + * -11026: Publish message timeout. + */ + RTM_ERROR_CHANNEL_PUBLISH_MESSAGE_TIMEOUT = -11026, + /** + * -11027: The connection state is invalid. + */ + RTM_ERROR_CHANNEL_NOT_CONNECTED = -11027, + /** + * -11028: Leave channel failed. + */ + RTM_ERROR_CHANNEL_LEAVE_FAILED = -11028, + /** + * -11029: The custom type length exceeds the limit. + */ + RTM_ERROR_CHANNEL_CUSTOM_TYPE_LENGTH_OVERFLOW = -11029, + /** + * -11030: The custom type is invalid. + */ + RTM_ERROR_CHANNEL_INVALID_CUSTOM_TYPE = -11030, + /** + * -11031: unsupported message type (in MacOS/iOS platform,message only support NSString and NSData) + */ + RTM_ERROR_CHANNEL_UNSUPPORTED_MESSAGE_TYPE = -11031, + /** + * -11032: The channel presence is not ready. + */ + RTM_ERROR_CHANNEL_PRESENCE_NOT_READY = -11032, + /** + * -11033: The destination user of publish message is offline. + */ + RTM_ERROR_CHANNEL_RECEIVER_OFFLINE = -11033, + + /** + * -12001 ~ -13000 : reserved for storage error. + * -12001: The storage operation failed. + */ + RTM_ERROR_STORAGE_OPERATION_FAILED = -12001, + /** + * -12002: The metadata item count exceeds the limit. + */ + RTM_ERROR_STORAGE_METADATA_ITEM_EXCEED_LIMITATION = -12002, + /** + * -12003: The metadata item is invalid. + */ + RTM_ERROR_STORAGE_INVALID_METADATA_ITEM = -12003, + /** + * -12004: The argument in storage operation is invalid. + */ + RTM_ERROR_STORAGE_INVALID_ARGUMENT = -12004, + /** + * -12005: The revision in storage operation is invalid. + */ + RTM_ERROR_STORAGE_INVALID_REVISION = -12005, + /** + * -12006: The metadata length exceeds the limit. + */ + RTM_ERROR_STORAGE_METADATA_LENGTH_OVERFLOW = -12006, + /** + * -12007: The lock name in storage operation is invalid. + */ + RTM_ERROR_STORAGE_INVALID_LOCK_NAME = -12007, + /** + * -12008: The lock in storage operation is not acquired. + */ + RTM_ERROR_STORAGE_LOCK_NOT_ACQUIRED = -12008, + /** + * -12009: The metadata key is invalid. + */ + RTM_ERROR_STORAGE_INVALID_KEY = -12009, + /** + * -12010: The metadata value is invalid. + */ + RTM_ERROR_STORAGE_INVALID_VALUE = -12010, + /** + * -12011: The metadata key length exceeds the limit. + */ + RTM_ERROR_STORAGE_KEY_LENGTH_OVERFLOW = -12011, + /** + * -12012: The metadata value length exceeds the limit. + */ + RTM_ERROR_STORAGE_VALUE_LENGTH_OVERFLOW = -12012, + /** + * -12013: The metadata key already exists. + */ + RTM_ERROR_STORAGE_DUPLICATE_KEY = -12013, + /** + * -12014: The revision in storage operation is outdated. + */ + RTM_ERROR_STORAGE_OUTDATED_REVISION = -12014, + /** + * -12015: The storage operation performed without subscribing. + */ + RTM_ERROR_STORAGE_NOT_SUBSCRIBE = -12015, + /** + * -12016: The metadata item is invalid. + */ + RTM_ERROR_STORAGE_INVALID_METADATA_INSTANCE = -12016, + /** + * -12017: The user count exceeds the limit when try to subscribe. + */ + RTM_ERROR_STORAGE_SUBSCRIBE_USER_EXCEED_LIMITATION = -12017, + /** + * -12018: The storage operation timeout. + */ + RTM_ERROR_STORAGE_OPERATION_TIMEOUT = -12018, + /** + * -12019: The storage service not available. + */ + RTM_ERROR_STORAGE_NOT_AVAILABLE = -12019, + + /** + * -13001 ~ -14000 : reserved for presence error. + * -13001: The user is not connected. + */ + RTM_ERROR_PRESENCE_NOT_CONNECTED = -13001, + /** + * -13002: The presence is not writable. + */ + RTM_ERROR_PRESENCE_NOT_WRITABLE = -13002, + /** + * -13003: The argument in presence operation is invalid. + */ + RTM_ERROR_PRESENCE_INVALID_ARGUMENT = -13003, + /** + * -13004: The cached presence state count exceeds the limit. + */ + RTM_ERROR_PRESENCE_CACHED_TOO_MANY_STATES = -13004, + /** + * -13005: The state count exceeds the limit. + */ + RTM_ERROR_PRESENCE_STATE_COUNT_OVERFLOW = -13005, + /** + * -13006: The state key is invalid. + */ + RTM_ERROR_PRESENCE_INVALID_STATE_KEY = -13006, + /** + * -13007: The state value is invalid. + */ + RTM_ERROR_PRESENCE_INVALID_STATE_VALUE = -13007, + /** + * -13008: The state key length exceeds the limit. + */ + RTM_ERROR_PRESENCE_STATE_KEY_SIZE_OVERFLOW = -13008, + /** + * -13009: The state value length exceeds the limit. + */ + RTM_ERROR_PRESENCE_STATE_VALUE_SIZE_OVERFLOW = -13009, + /** + * -13010: The state key already exists. + */ + RTM_ERROR_PRESENCE_STATE_DUPLICATE_KEY = -13010, + /** + * -13011: The user is not exist. + */ + RTM_ERROR_PRESENCE_USER_NOT_EXIST = -13011, + /** + * -13012: The presence operation timeout. + */ + RTM_ERROR_PRESENCE_OPERATION_TIMEOUT = -13012, + /** + * -13013: The presence operation failed. + */ + RTM_ERROR_PRESENCE_OPERATION_FAILED = -13013, + + /** + * -14001 ~ -15000 : reserved for lock error. + * -14001: The lock operation failed. + */ + RTM_ERROR_LOCK_OPERATION_FAILED = -14001, + /** + * -14002: The lock operation timeout. + */ + RTM_ERROR_LOCK_OPERATION_TIMEOUT = -14002, + /** + * -14003: The lock operation is performing. + */ + RTM_ERROR_LOCK_OPERATION_PERFORMING = -14003, + /** + * -14004: The lock already exists. + */ + RTM_ERROR_LOCK_ALREADY_EXIST = -14004, + /** + * -14005: The lock name is invalid. + */ + RTM_ERROR_LOCK_INVALID_NAME = -14005, + /** + * -14006: The lock is not acquired. + */ + RTM_ERROR_LOCK_NOT_ACQUIRED = -14006, + /** + * -14007: Acquire lock failed. + */ + RTM_ERROR_LOCK_ACQUIRE_FAILED = -14007, + /** + * -14008: The lock is not exist. + */ + RTM_ERROR_LOCK_NOT_EXIST = -14008, + /** + * -14009: The lock service is not available. + */ + RTM_ERROR_LOCK_NOT_AVAILABLE = -14009, +}; + +/** + * Connection states between rtm sdk and agora server. + */ +enum RTM_CONNECTION_STATE { + /** + * 1: The SDK is disconnected with server. + */ + RTM_CONNECTION_STATE_DISCONNECTED = 1, + /** + * 2: The SDK is connecting to the server. + */ + RTM_CONNECTION_STATE_CONNECTING = 2, + /** + * 3: The SDK is connected to the server and has joined a channel. You can now publish or subscribe to + * a track in the channel. + */ + RTM_CONNECTION_STATE_CONNECTED = 3, + /** + * 4: The SDK keeps rejoining the channel after being disconnected from the channel, probably because of + * network issues. + */ + RTM_CONNECTION_STATE_RECONNECTING = 4, + /** + * 5: The SDK fails to connect to the server or join the channel. + */ + RTM_CONNECTION_STATE_FAILED = 5, +}; + +/** + * Reasons for connection state change. + */ +enum RTM_CONNECTION_CHANGE_REASON { + /** + * 0: The SDK is connecting to the server. + */ + RTM_CONNECTION_CHANGED_CONNECTING = 0, + /** + * 1: The SDK has joined the channel successfully. + */ + RTM_CONNECTION_CHANGED_JOIN_SUCCESS = 1, + /** + * 2: The connection between the SDK and the server is interrupted. + */ + RTM_CONNECTION_CHANGED_INTERRUPTED = 2, + /** + * 3: The connection between the SDK and the server is banned by the server. + */ + RTM_CONNECTION_CHANGED_BANNED_BY_SERVER = 3, + /** + * 4: The SDK fails to join the channel for more than 20 minutes and stops reconnecting to the channel. + */ + RTM_CONNECTION_CHANGED_JOIN_FAILED = 4, + /** + * 5: The SDK has left the channel. + */ + RTM_CONNECTION_CHANGED_LEAVE_CHANNEL = 5, + /** + * 6: The connection fails because the App ID is not valid. + */ + RTM_CONNECTION_CHANGED_INVALID_APP_ID = 6, + /** + * 7: The connection fails because the channel name is not valid. + */ + RTM_CONNECTION_CHANGED_INVALID_CHANNEL_NAME = 7, + /** + * 8: The connection fails because the token is not valid. + */ + RTM_CONNECTION_CHANGED_INVALID_TOKEN = 8, + /** + * 9: The connection fails because the token has expired. + */ + RTM_CONNECTION_CHANGED_TOKEN_EXPIRED = 9, + /** + * 10: The connection is rejected by the server. + */ + RTM_CONNECTION_CHANGED_REJECTED_BY_SERVER = 10, + /** + * 11: The connection changes to reconnecting because the SDK has set a proxy server. + */ + RTM_CONNECTION_CHANGED_SETTING_PROXY_SERVER = 11, + /** + * 12: When the connection state changes because the app has renewed the token. + */ + RTM_CONNECTION_CHANGED_RENEW_TOKEN = 12, + /** + * 13: The IP Address of the app has changed. A change in the network type or IP/Port changes the IP + * address of the app. + */ + RTM_CONNECTION_CHANGED_CLIENT_IP_ADDRESS_CHANGED = 13, + /** + * 14: A timeout occurs for the keep-alive of the connection between the SDK and the server. + */ + RTM_CONNECTION_CHANGED_KEEP_ALIVE_TIMEOUT = 14, + /** + * 15: The SDK has rejoined the channel successfully. + */ + RTM_CONNECTION_CHANGED_REJOIN_SUCCESS = 15, + /** + * 16: The connection between the SDK and the server is lost. + */ + RTM_CONNECTION_CHANGED_LOST = 16, + /** + * 17: The change of connection state is caused by echo test. + */ + RTM_CONNECTION_CHANGED_ECHO_TEST = 17, + /** + * 18: The local IP Address is changed by user. + */ + RTM_CONNECTION_CHANGED_CLIENT_IP_ADDRESS_CHANGED_BY_USER = 18, + /** + * 19: The connection is failed due to join the same channel on another device with the same uid. + */ + RTM_CONNECTION_CHANGED_SAME_UID_LOGIN = 19, + /** + * 20: The connection is failed due to too many broadcasters in the channel. + */ + RTM_CONNECTION_CHANGED_TOO_MANY_BROADCASTERS = 20, + /** + * 21: The connection is failed due to license validation failure. + */ + RTM_CONNECTION_CHANGED_LICENSE_VALIDATION_FAILURE = 21, + /** + * 22: The connection is failed due to user vid not support stream channel. + */ + RTM_CONNECTION_CHANGED_STREAM_CHANNEL_NOT_AVAILABLE = 22, + /** + * 23: The connection is failed due to token and appid inconsistent. + */ + RTM_CONNECTION_CHANGED_INCONSISTENT_APPID = 23, + /** + * 10001: The connection of rtm edge service has been successfully established. + */ + RTM_CONNECTION_CHANGED_LOGIN_SUCCESS = 10001, + /** + * 10002: User log out Agora RTM system. + */ + RTM_CONNECTION_CHANGED_LOGOUT = 10002, + /** + * 10003: User log out Agora RTM system. + */ + RTM_CONNECTION_CHANGED_PRESENCE_NOT_READY = 10003, +}; + +/** + * RTM channel type. + */ +enum RTM_CHANNEL_TYPE { + /** + * 0: Unknown channel type. + */ + RTM_CHANNEL_TYPE_NONE = 0, + /** + * 1: Message channel. + */ + RTM_CHANNEL_TYPE_MESSAGE = 1, + /** + * 2: Stream channel. + */ + RTM_CHANNEL_TYPE_STREAM = 2, + /** + * 3: User. + */ + RTM_CHANNEL_TYPE_USER = 3, +}; + +/** + @brief Message type when user publish message to channel or topic + */ +enum RTM_MESSAGE_TYPE { + /** + 0: The binary message. + */ + RTM_MESSAGE_TYPE_BINARY = 0, + /** + 1: The ascii message. + */ + RTM_MESSAGE_TYPE_STRING = 1, +}; + +/** + @brief Storage type indicate the storage event was triggered by user or channel + */ +enum RTM_STORAGE_TYPE { + /** + 0: Unknown type. + */ + RTM_STORAGE_TYPE_NONE= 0, + /** + 1: The user storage event. + */ + RTM_STORAGE_TYPE_USER = 1, + /** + 2: The channel storage event. + */ + RTM_STORAGE_TYPE_CHANNEL = 2, +}; + +/** + * The storage event type, indicate storage operation + */ +enum RTM_STORAGE_EVENT_TYPE { + /** + 0: Unknown event type. + */ + RTM_STORAGE_EVENT_TYPE_NONE= 0, + /** + 1: Triggered when user subscribe user metadata state or join channel with options.withMetadata = true + */ + RTM_STORAGE_EVENT_TYPE_SNAPSHOT = 1, + /** + 2: Triggered when a remote user set metadata + */ + RTM_STORAGE_EVENT_TYPE_SET = 2, + /** + 3: Triggered when a remote user update metadata + */ + RTM_STORAGE_EVENT_TYPE_UPDATE = 3, + /** + 4: Triggered when a remote user remove metadata + */ + RTM_STORAGE_EVENT_TYPE_REMOVE = 4, +}; + +/** + * The lock event type, indicate lock operation + */ +enum RTM_LOCK_EVENT_TYPE { + /** + * 0: Unknown event type + */ + RTM_LOCK_EVENT_TYPE_NONE = 0, + /** + * 1: Triggered when user subscribe lock state + */ + RTM_LOCK_EVENT_TYPE_SNAPSHOT = 1, + /** + * 2: Triggered when a remote user set lock + */ + RTM_LOCK_EVENT_TYPE_LOCK_SET = 2, + /** + * 3: Triggered when a remote user remove lock + */ + RTM_LOCK_EVENT_TYPE_LOCK_REMOVED = 3, + /** + * 4: Triggered when a remote user acquired lock + */ + RTM_LOCK_EVENT_TYPE_LOCK_ACQUIRED = 4, + /** + * 5: Triggered when a remote user released lock + */ + RTM_LOCK_EVENT_TYPE_LOCK_RELEASED = 5, + /** + * 6: Triggered when user reconnect to rtm service, + * detect the lock has been acquired and released by others. + */ + RTM_LOCK_EVENT_TYPE_LOCK_EXPIRED = 6, +}; + +/** + * The proxy type + */ +enum RTM_PROXY_TYPE { + /** + * 0: Link without proxy + */ + RTM_PROXY_TYPE_NONE = 0, + /** + * 1: Link with http proxy + */ + RTM_PROXY_TYPE_HTTP = 1, +}; + +/** + @brief Topic event type + */ +enum RTM_TOPIC_EVENT_TYPE { + /** + * 0: Unknown event type + */ + RTM_TOPIC_EVENT_TYPE_NONE = 0, + /** + * 1: The topic snapshot of this channel + */ + RTM_TOPIC_EVENT_TYPE_SNAPSHOT = 1, + /** + * 2: Triggered when remote user join a topic + */ + RTM_TOPIC_EVENT_TYPE_REMOTE_JOIN_TOPIC = 2, + /** + * 3: Triggered when remote user leave a topic + */ + RTM_TOPIC_EVENT_TYPE_REMOTE_LEAVE_TOPIC = 3, +}; + +/** + @brief Presence event type + */ +enum RTM_PRESENCE_EVENT_TYPE { + /** + * 0: Unknown event type + */ + RTM_PRESENCE_EVENT_TYPE_NONE = 0, + /** + * 1: The presence snapshot of this channel + */ + RTM_PRESENCE_EVENT_TYPE_SNAPSHOT = 1, + /** + * 2: The presence event triggered in interval mode + */ + RTM_PRESENCE_EVENT_TYPE_INTERVAL = 2, + /** + * 3: Triggered when remote user join channel + */ + RTM_PRESENCE_EVENT_TYPE_REMOTE_JOIN_CHANNEL = 3, + /** + * 4: Triggered when remote user leave channel + */ + RTM_PRESENCE_EVENT_TYPE_REMOTE_LEAVE_CHANNEL = 4, + /** + * 5: Triggered when remote user's connection timeout + */ + RTM_PRESENCE_EVENT_TYPE_REMOTE_TIMEOUT = 5, + /** + * 6: Triggered when user changed state + */ + RTM_PRESENCE_EVENT_TYPE_REMOTE_STATE_CHANGED = 6, + /** + * 7: Triggered when user joined channel without presence service + */ + RTM_PRESENCE_EVENT_TYPE_ERROR_OUT_OF_SERVICE = 7, +}; + +/** + * Definition of LogConfiguration + */ +struct RtmLogConfig { + /** + * The log file path, default is NULL for default log path + */ + const char* filePath; + /** + * The log file size, KB , set 1024KB to use default log size + */ + uint32_t fileSizeInKB; + /** + * The log level, set LOG_LEVEL_INFO to use default log level + */ + RTM_LOG_LEVEL level; + + RtmLogConfig() : filePath(NULL), fileSizeInKB(DEFAULT_LOG_SIZE_IN_KB), level(RTM_LOG_LEVEL_INFO) {} +}; + +/** + * User list. + */ +struct UserList { + /** + * The list of users. + */ + const char** users; + /** + * The number of users. + */ + size_t userCount; + + UserList() : users(NULL), userCount(0) {} +}; + +/** + @brief Topic publisher information + */ +struct PublisherInfo { + /** + * The publisher user ID + */ + const char* publisherUserId; + /** + * The metadata of the publisher + */ + const char* publisherMeta; + + PublisherInfo() : publisherUserId(NULL), + publisherMeta(NULL) {} +}; + +/** + @brief Topic information + */ +struct TopicInfo { + /** + * The name of the topic + */ + const char* topic; + /** + * The publisher array + */ + PublisherInfo* publishers; + /** + * The count of publisher in current topic + */ + size_t publisherCount; + + TopicInfo() : topic(NULL), + publishers(NULL), + publisherCount(0) {} +}; + +/** + @brief User state property + */ +struct StateItem { + /** + * The key of the state item. + */ + const char* key; + /** + * The value of the state item. + */ + const char* value; + + StateItem() : key(NULL), value(NULL) {} +}; + +/** + * The information of a Lock. + */ +struct LockDetail { + /** + * The name of the lock. + */ + const char* lockName; + /** + * The owner of the lock. Only valid when user getLocks or receive LockEvent with RTM_LOCK_EVENT_TYPE_SNAPSHOT + */ + const char* owner; + /** + * The ttl of the lock. + */ + uint32_t ttl; + + LockDetail() : lockName(NULL), + owner(NULL), + ttl(0) {} +}; + +/** + * The states of user. + */ +struct UserState { + /** + * The user id. + */ + const char* userId; + /** + * The user states. + */ + const StateItem* states; + /** + * The count of user states. + */ + size_t statesCount; + + UserState() : userId(NULL), + states(NULL), + statesCount(0) {} +}; + +/** + * The subscribe option. + */ +struct SubscribeOptions { + /** + * Whether to subscribe channel with message + */ + bool withMessage; + /** + * Whether to subscribe channel with metadata + */ + bool withMetadata; + /** + * Whether to subscribe channel with user presence + */ + bool withPresence; + /** + * Whether to subscribe channel with lock + */ + bool withLock; + + SubscribeOptions() : withMessage(true), + withMetadata(false), + withPresence(true), + withLock(false) {} +}; + +/** + * The channel information. + */ +struct ChannelInfo { + /** + * The channel which the message was published + */ + const char* channelName; + /** + * Which channel type, RTM_CHANNEL_TYPE_STREAM or RTM_CHANNEL_TYPE_MESSAGE + */ + RTM_CHANNEL_TYPE channelType; +}; + +/** + * The option to query user presence. + */ +struct PresenceOptions { + /** + * Whether to display user id in query result + */ + bool includeUserId; + /** + * Whether to display user state in query result + */ + bool includeState; + /** + * The paging object used for pagination. + */ + const char* page; + + PresenceOptions() : includeUserId(true), + includeState(false), + page(NULL) {} +}; + +/** + * The option to query user presence. + */ +struct GetOnlineUsersOptions { + /** + * Whether to display user id in query result + */ + bool includeUserId; + /** + * Whether to display user state in query result + */ + bool includeState; + /** + * The paging object used for pagination. + */ + const char* page; + + GetOnlineUsersOptions() : includeUserId(true), + includeState(false), + page(NULL) {} +}; + +/** + @brief Publish message option + */ +struct PublishOptions { + /* + The channel type. + */ + RTM_CHANNEL_TYPE channelType; + /** + The message type. + */ + RTM_MESSAGE_TYPE messageType; + /** + The custom type of the message, up to 32 bytes for customize + */ + const char* customType; + + PublishOptions() : channelType(RTM_CHANNEL_TYPE_MESSAGE), messageType(RTM_MESSAGE_TYPE_BINARY), + customType(NULL) {} +}; + +/** + @brief topic message option + */ +struct TopicMessageOptions { + /** + The message type. + */ + RTM_MESSAGE_TYPE messageType; + /** + The time to calibrate data with media, + only valid when user join topic with syncWithMedia in stream channel + */ + uint64_t sendTs; + /** + The custom type of the message, up to 32 bytes for customize + */ + const char* customType; + + TopicMessageOptions() : messageType(RTM_MESSAGE_TYPE_BINARY), + sendTs(0), customType(NULL) {} +}; + +/** + @brief Proxy configuration + */ +struct RtmProxyConfig { + /** + The Proxy type. + */ + RTM_PROXY_TYPE proxyType; + /** + The Proxy server address. + */ + const char* server; + /** + The Proxy server port. + */ + uint16_t port; + /** + The Proxy user account. + */ + const char* account; + /** + The Proxy password. + */ + const char* password; + + RtmProxyConfig() : proxyType(RTM_PROXY_TYPE_NONE), + server(NULL), + port(0), + account(NULL), + password(NULL) {} +}; + +/** + @brief encryption configuration + */ +struct RtmEncryptionConfig { + /** + * The encryption mode. + */ + RTM_ENCRYPTION_MODE encryptionMode; + + /** + * The encryption key in the string format. + */ + const char* encryptionKey; + + /** + * The encryption salt. + */ + uint8_t encryptionSalt[32]; + + RtmEncryptionConfig() : encryptionMode(RTM_ENCRYPTION_MODE_NONE), + encryptionKey(NULL) { + memset(encryptionSalt, 0, sizeof(encryptionSalt)); + } +}; + +} // namespace rtm +} // namespace agora diff --git a/headers/rtm_2.1.10/include/IAgoraRtmClient.h b/headers/rtm_2.1.10/include/IAgoraRtmClient.h new file mode 100644 index 0000000..785ade5 --- /dev/null +++ b/headers/rtm_2.1.10/include/IAgoraRtmClient.h @@ -0,0 +1,843 @@ +// Copyright (c) 2022 Agora.io. All rights reserved + +// This program is confidential and proprietary to Agora.io. +// And may not be copied, reproduced, modified, disclosed to others, published +// or used, in whole or in part, without the express prior written permission +// of Agora.io. + +#pragma once // NOLINT(build/header_guard) + +#include "IAgoraStreamChannel.h" +#include "IAgoraRtmStorage.h" +#include "IAgoraRtmPresence.h" +#include "IAgoraRtmLock.h" +#include "AgoraRtmBase.h" + +#ifndef OPTIONAL_ENUM_CLASS +#if __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1800) +#define OPTIONAL_ENUM_CLASS enum class +#else +#define OPTIONAL_ENUM_CLASS enum +#endif +#endif + +namespace agora { +namespace rtm { + +class IRtmEventHandler; + +/** + * Configurations for RTM Client. + */ +struct RtmConfig { + /** + * The App ID of your project. + */ + const char* appId; + + /** + * The ID of the user. + */ + const char* userId; + + /** + * The region for connection. This advanced feature applies to scenarios that + * have regional restrictions. + * + * For the regions that Agora supports, see #AREA_CODE. + * + * After specifying the region, the SDK connects to the Agora servers within + * that region. + */ + RTM_AREA_CODE areaCode; + + /** + * Presence timeout in seconds, specify the timeout value when you lost connection between sdk + * and rtm service. + */ + uint32_t presenceTimeout; + + /** + * - For Android, it is the context of Activity or Application. + * - For Windows, it is the window handle of app. Once set, this parameter enables you to plug + * or unplug the video devices while they are powered. + */ + void* context; + + /** + * Whether to use String user IDs, if you are using RTC products with Int user IDs, + * set this value as 'false'. Otherwise errors might occur. + */ + bool useStringUserId; + + /** + * The callbacks handler + */ + IRtmEventHandler* eventHandler; + + /** + * The config for customer set log path, log size and log level. + */ + RtmLogConfig logConfig; + + /** + * The config for proxy setting + */ + RtmProxyConfig proxyConfig; + + /** + * The config for encryption setting + */ + RtmEncryptionConfig encryptionConfig; + + RtmConfig() : appId(NULL), + userId(NULL), + areaCode(RTM_AREA_CODE_GLOB), + presenceTimeout(300), + context(NULL), + useStringUserId(true), + eventHandler(NULL) {} +}; + +/** + * The IRtmEventHandler class. + * + * The SDK uses this class to send callback event notifications to the app, and the app inherits + * the methods in this class to retrieve these event notifications. + * + * All methods in this class have their default (empty) implementations, and the app can inherit + * only some of the required events instead of all. In the callback methods, the app should avoid + * time-consuming tasks or calling blocking APIs, otherwise the SDK may not work properly. + */ +class IRtmEventHandler { + public: + virtual ~IRtmEventHandler() {} + + struct MessageEvent { + /** + * Which channel type, RTM_CHANNEL_TYPE_STREAM or RTM_CHANNEL_TYPE_MESSAGE + */ + RTM_CHANNEL_TYPE channelType; + /** + * Message type + */ + RTM_MESSAGE_TYPE messageType; + /** + * The channel which the message was published + */ + const char* channelName; + /** + * If the channelType is RTM_CHANNEL_TYPE_STREAM, which topic the message came from. only for RTM_CHANNEL_TYPE_STREAM + */ + const char* channelTopic; + /** + * The payload + */ + const char* message; + /** + * The payload length + */ + size_t messageLength; + /** + * The publisher + */ + const char* publisher; + /** + * The custom type of the message + */ + const char* customType; + + MessageEvent() : channelType(RTM_CHANNEL_TYPE_NONE), + messageType(RTM_MESSAGE_TYPE_BINARY), + channelName(NULL), + channelTopic(NULL), + message(NULL), + messageLength(0), + publisher(NULL), + customType(NULL) {} + }; + + struct PresenceEvent { + + struct IntervalInfo { + /** + * Joined users during this interval + */ + UserList joinUserList; + /** + * Left users during this interval + */ + UserList leaveUserList; + /** + * Timeout users during this interval + */ + UserList timeoutUserList; + /** + * The user state changed during this interval + */ + UserState* userStateList; + /** + * The user count + */ + size_t userStateCount; + + IntervalInfo() : userStateList(NULL), + userStateCount(0) {} + }; + + struct SnapshotInfo { + /** + * The user state in this snapshot event + */ + UserState* userStateList; + /** + * The user count + */ + size_t userCount; + + SnapshotInfo() : userStateList(NULL), + userCount(0) {} + }; + + /** + * Indicate presence event type + */ + RTM_PRESENCE_EVENT_TYPE type; + /** + * Which channel type, RTM_CHANNEL_TYPE_STREAM or RTM_CHANNEL_TYPE_MESSAGE + */ + RTM_CHANNEL_TYPE channelType; + /** + * The channel which the presence event was triggered + */ + const char* channelName; + /** + * The user who triggered this event. + */ + const char* publisher; + /** + * The user states + */ + const StateItem* stateItems; + /** + * The states count + */ + size_t stateItemCount; + /** + * Only valid when in interval mode + */ + IntervalInfo interval; + /** + * Only valid when receive snapshot event + */ + SnapshotInfo snapshot; + + PresenceEvent() : type(RTM_PRESENCE_EVENT_TYPE_NONE), + channelType(RTM_CHANNEL_TYPE_NONE), + channelName(NULL), + publisher(NULL), + stateItems(NULL), + stateItemCount(0) {} + }; + + struct TopicEvent { + /** + * Indicate topic event type + */ + RTM_TOPIC_EVENT_TYPE type; + /** + * The channel which the topic event was triggered + */ + const char* channelName; + /** + * The user who triggered this event. + */ + const char* publisher; + /** + * Topic information array. + */ + const TopicInfo* topicInfos; + /** + * The count of topicInfos. + */ + size_t topicInfoCount; + + TopicEvent() : type(RTM_TOPIC_EVENT_TYPE_NONE), + channelName(NULL), + publisher(NULL), + topicInfos(NULL), + topicInfoCount(0) {} + }; + + struct LockEvent { + /** + * Which channel type, RTM_CHANNEL_TYPE_STREAM or RTM_CHANNEL_TYPE_MESSAGE + */ + RTM_CHANNEL_TYPE channelType; + /** + * Lock event type, indicate lock states + */ + RTM_LOCK_EVENT_TYPE eventType; + /** + * The channel which the lock event was triggered + */ + const char* channelName; + /** + * The detail information of locks + */ + const LockDetail* lockDetailList; + /** + * The count of locks + */ + size_t count; + + LockEvent() : channelType(RTM_CHANNEL_TYPE_NONE), + eventType(RTM_LOCK_EVENT_TYPE_NONE), + channelName(NULL), + lockDetailList(NULL), + count(0) {} + }; + + struct StorageEvent { + /** + * Which channel type, RTM_CHANNEL_TYPE_STREAM or RTM_CHANNEL_TYPE_MESSAGE + */ + RTM_CHANNEL_TYPE channelType; + /** + * Storage type, RTM_STORAGE_TYPE_USER or RTM_STORAGE_TYPE_CHANNEL + */ + RTM_STORAGE_TYPE storageType; + /** + * Indicate storage event type + */ + RTM_STORAGE_EVENT_TYPE eventType; + /** + * The target name of user or channel, depends on the RTM_STORAGE_TYPE + */ + const char* target; + /** + * The metadata information + */ + IMetadata* data; + + StorageEvent() : channelType(RTM_CHANNEL_TYPE_NONE), + storageType(RTM_STORAGE_TYPE_NONE), + eventType(RTM_STORAGE_EVENT_TYPE_NONE), + target(NULL), + data(NULL) {} + }; + + /** + * Occurs when receive a message. + * + * @param event details of message event. + */ + virtual void onMessageEvent(const MessageEvent& event) {} + + /** + * Occurs when remote user presence changed + * + * @param event details of presence event. + */ + virtual void onPresenceEvent(const PresenceEvent& event) {} + + /** + * Occurs when remote user join/leave topic or when user first join this channel, + * got snapshot of topics in this channel + * + * @param event details of topic event. + */ + virtual void onTopicEvent(const TopicEvent& event) {} + + /** + * Occurs when lock state changed + * + * @param event details of lock event. + */ + virtual void onLockEvent(const LockEvent& event) {} + + /** + * Occurs when receive storage event + * + * @param event details of storage event. + */ + virtual void onStorageEvent(const StorageEvent& event) {} + + /** + * Occurs when user join a stream channel. + * + * @param channelName The name of the channel. + * @param userId The id of the user. + * @param errorCode The error code. + */ + virtual void onJoinResult(const uint64_t requestId, const char* channelName, const char* userId, RTM_ERROR_CODE errorCode) {} + + /** + * Occurs when user leave a stream channel. + * + * @param channelName The name of the channel. + * @param userId The id of the user. + * @param errorCode The error code. + */ + virtual void onLeaveResult(const uint64_t requestId, const char* channelName, const char* userId, RTM_ERROR_CODE errorCode) {} + + /** + * Occurs when user join topic. + * + * @param channelName The name of the channel. + * @param userId The id of the user. + * @param topic The name of the topic. + * @param meta The meta of the topic. + * @param errorCode The error code. + */ + virtual void onJoinTopicResult(const uint64_t requestId, const char* channelName, const char* userId, const char* topic, const char* meta, RTM_ERROR_CODE errorCode) {} + + /** + * Occurs when user leave topic. + * + * @param channelName The name of the channel. + * @param userId The id of the user. + * @param topic The name of the topic. + * @param meta The meta of the topic. + * @param errorCode The error code. + */ + virtual void onLeaveTopicResult(const uint64_t requestId, const char* channelName, const char* userId, const char* topic, const char* meta, RTM_ERROR_CODE errorCode) {} + + /** + * Occurs when user subscribe topic. + * + * @param channelName The name of the channel. + * @param userId The id of the user. + * @param topic The name of the topic. + * @param succeedUsers The subscribed users. + * @param failedUser The failed to subscribe users. + * @param errorCode The error code. + */ + virtual void onSubscribeTopicResult(const uint64_t requestId, const char* channelName, const char* userId, const char* topic, UserList succeedUsers, UserList failedUsers, RTM_ERROR_CODE errorCode) {} + + /** + * Occurs when the connection state changes between rtm sdk and agora service. + * + * @param channelName The name of the channel. + * @param state The new connection state. + * @param reason The reason for the connection state change. + */ + virtual void onConnectionStateChanged(const char* channelName, RTM_CONNECTION_STATE state, RTM_CONNECTION_CHANGE_REASON reason) {} + + /** + * Occurs when token will expire in 30 seconds. + * + * @param channelName The name of the channel. + */ + virtual void onTokenPrivilegeWillExpire(const char* channelName) {} + + /** + * Occurs when subscribe a channel + * + * @param channelName The name of the channel. + * @param errorCode The error code. + */ + virtual void onSubscribeResult(const uint64_t requestId, const char* channelName, RTM_ERROR_CODE errorCode) {} + + /** + * Occurs when user publish message. + * + * @param requestId The related request id when user publish message + * @param errorCode The error code. + */ + virtual void onPublishResult(const uint64_t requestId, RTM_ERROR_CODE errorCode) {} + + /** + * Occurs when user login. + * + * @param errorCode The error code. + */ + virtual void onLoginResult(RTM_ERROR_CODE errorCode) {} + + /** + * Occurs when user setting the channel metadata + * + * @param requestId The related request id when user perform this operation + * @param channelName The name of the channel. + * @param channelType The type of the channel. + * @param errorCode The error code. + */ + virtual void onSetChannelMetadataResult( + const uint64_t requestId, const char* channelName, RTM_CHANNEL_TYPE channelType, RTM_ERROR_CODE errorCode) {} + + /** + * Occurs when user updating the channel metadata + * + * @param requestId The related request id when user perform this operation + * @param channelName The name of the channel. + * @param channelType The type of the channel. + * @param errorCode The error code. + */ + virtual void onUpdateChannelMetadataResult( + const uint64_t requestId, const char* channelName, RTM_CHANNEL_TYPE channelType, RTM_ERROR_CODE errorCode) {} + + /** + * Occurs when user removing the channel metadata + * + * @param requestId The related request id when user perform this operation + * @param channelName The name of the channel. + * @param channelType The type of the channel. + * @param errorCode The error code. + */ + virtual void onRemoveChannelMetadataResult( + const uint64_t requestId, const char* channelName, RTM_CHANNEL_TYPE channelType, RTM_ERROR_CODE errorCode) {} + + /** + * Occurs when user try to get the channel metadata + * + * @param requestId The related request id when user perform this operation + * @param channelName The name of the channel. + * @param channelType The type of the channel. + * @param data The result metadata of getting operation. + * @param errorCode The error code. + */ + virtual void onGetChannelMetadataResult( + const uint64_t requestId, const char* channelName, RTM_CHANNEL_TYPE channelType, const IMetadata& data, RTM_ERROR_CODE errorCode) {} + + /** + * Occurs when user setting the user metadata + * + * @param requestId The related request id when user perform this operation + * @param userId The id of the user. + * @param errorCode The error code. + */ + virtual void onSetUserMetadataResult( + const uint64_t requestId, const char* userId, RTM_ERROR_CODE errorCode) {} + + /** + * Occurs when user updating the user metadata + * + * @param requestId The related request id when user perform this operation + * @param userId The id of the user. + * @param errorCode The error code. + */ + virtual void onUpdateUserMetadataResult( + const uint64_t requestId, const char* userId, RTM_ERROR_CODE errorCode) {} + + /** + * Occurs when user removing the user metadata + * + * @param requestId The related request id when user perform this operation + * @param userId The id of the user. + * @param errorCode The error code. + */ + virtual void onRemoveUserMetadataResult( + const uint64_t requestId, const char* userId, RTM_ERROR_CODE errorCode) {} + + /** + * Occurs when user try to get the user metadata + * + * @param requestId The related request id when user perform this operation + * @param userId The id of the user. + * @param data The result metadata of getting operation. + * @param errorCode The error code. + */ + virtual void onGetUserMetadataResult( + const uint64_t requestId, const char* userId, const IMetadata& data, RTM_ERROR_CODE errorCode) {} + + /** + * Occurs when user subscribe a user metadata + * + * @param userId The id of the user. + * @param errorCode The error code. + */ + virtual void onSubscribeUserMetadataResult(const uint64_t requestId, const char* userId, RTM_ERROR_CODE errorCode) {} + + /** + * Occurs when user set a lock + * + * @param channelName The name of the channel. + * @param channelType The type of the channel. + * @param lockName The name of the lock. + * @param errorCode The error code. + */ + virtual void onSetLockResult(const uint64_t requestId, const char* channelName, RTM_CHANNEL_TYPE channelType, const char* lockName, RTM_ERROR_CODE errorCode) {} + + /** + * Occurs when user delete a lock + * + * @param channelName The name of the channel. + * @param channelType The type of the channel. + * @param lockName The name of the lock. + * @param errorCode The error code. + */ + virtual void onRemoveLockResult(const uint64_t requestId, const char* channelName, RTM_CHANNEL_TYPE channelType, const char* lockName, RTM_ERROR_CODE errorCode) {} + + /** + * Occurs when user release a lock + * + * @param channelName The name of the channel. + * @param channelType The type of the channel. + * @param lockName The name of the lock. + * @param errorCode The error code. + */ + virtual void onReleaseLockResult(const uint64_t requestId, const char* channelName, RTM_CHANNEL_TYPE channelType, const char* lockName, RTM_ERROR_CODE errorCode) {} + + /** + * Occurs when user acquire a lock + * + * @param channelName The name of the channel. + * @param channelType The type of the channel. + * @param lockName The name of the lock. + * @param errorCode The error code. + */ + virtual void onAcquireLockResult(const uint64_t requestId, const char* channelName, RTM_CHANNEL_TYPE channelType, const char* lockName, RTM_ERROR_CODE errorCode, const char* errorDetails) {} + + /** + * Occurs when user revoke a lock + * + * @param channelName The name of the channel. + * @param channelType The type of the channel. + * @param lockName The name of the lock. + * @param errorCode The error code. + */ + virtual void onRevokeLockResult(const uint64_t requestId, const char* channelName, RTM_CHANNEL_TYPE channelType, const char* lockName, RTM_ERROR_CODE errorCode) {} + + /** + * Occurs when user try to get locks from the channel + * + * @param channelName The name of the channel. + * @param channelType The type of the channel. + * @param lockDetailList The details of the locks. + * @param count The count of the locks. + * @param errorCode The error code. + */ + virtual void onGetLocksResult(const uint64_t requestId, const char* channelName, RTM_CHANNEL_TYPE channelType, const LockDetail* lockDetailList, const size_t count, RTM_ERROR_CODE errorCode) {} + + /** + * Occurs when query who joined this channel + * + * @param requestId The related request id when user perform this operation + * @param userStatesList The states the users. + * @param count The user count. + * @param errorCode The error code. + */ + virtual void onWhoNowResult(const uint64_t requestId, const UserState* userStateList, const size_t count, const char* nextPage, RTM_ERROR_CODE errorCode) {} + + /** + * Occurs when query who joined this channel + * + * @param requestId The related request id when user perform this operation + * @param userStatesList The states the users. + * @param count The user count. + * @param errorCode The error code. + */ + virtual void onGetOnlineUsersResult(const uint64_t requestId, const UserState* userStateList, const size_t count, const char* nextPage, RTM_ERROR_CODE errorCode) {} + + /** + * Occurs when query which channels the user joined + * + * @param requestId The related request id when user perform this operation + * @param channels The channel informations. + * @param count The channel count. + * @param errorCode The error code. + */ + virtual void onWhereNowResult(const uint64_t requestId, const ChannelInfo* channels, const size_t count, RTM_ERROR_CODE errorCode) {} + + /** + * Occurs when query which channels the user joined + * + * @param requestId The related request id when user perform this operation + * @param channels The channel informations. + * @param count The channel count. + * @param errorCode The error code. + */ + virtual void onGetUserChannelsResult(const uint64_t requestId, const ChannelInfo* channels, const size_t count, RTM_ERROR_CODE errorCode) {} + + /** + * Occurs when set user presence + * + * @param requestId The related request id when user perform this operation + * @param errorCode The error code. + */ + virtual void onPresenceSetStateResult(const uint64_t requestId, RTM_ERROR_CODE errorCode) {} + + /** + * Occurs when delete user presence + * + * @param requestId The related request id when user perform this operation + * @param errorCode The error code. + */ + virtual void onPresenceRemoveStateResult(const uint64_t requestId, RTM_ERROR_CODE errorCode) {} + + /** + * Occurs when get user presence + * + * @param requestId The related request id when user perform this operation + * @param states The user states + * @param errorCode The error code. + */ + virtual void onPresenceGetStateResult(const uint64_t requestId, const UserState& state, RTM_ERROR_CODE errorCode) {} +}; + +/** + * The IRtmClient class. + * + * This class provides the main methods that can be invoked by your app. + * + * IRtmClient is the basic interface class of the Agora RTM SDK. + * Creating an IRtmClient object and then calling the methods of + * this object enables you to use Agora RTM SDK's functionality. + */ +class IRtmClient { + public: + /** + * Initializes the rtm client instance. + * + * @param [in] config The configurations for RTM Client. + * @param [in] eventHandler . + * @return + * - 0: Success. + * - < 0: Failure. + */ + virtual int initialize(const RtmConfig& config) = 0; + + /** + * Release the rtm client instance. + * + * @return + * - 0: Success. + * - < 0: Failure. + */ + virtual int release() = 0; + + /** + * Login the Agora RTM service. The operation result will be notified by \ref agora::rtm::IRtmEventHandler::onLoginResult callback. + * + * @param [in] token Token used to login RTM service. + * @return + * - 0: Success. + * - < 0: Failure. + */ + virtual int login(const char* token) = 0; + + /** + * Logout the Agora RTM service. Be noticed that this method will break the rtm service including storage/lock/presence. + * + * @return + * - 0: Success. + * - < 0: Failure. + */ + virtual int logout() = 0; + + /** + * Get the storage instance. + * + * @return + * - return NULL if error occurred + */ + virtual IRtmStorage* getStorage() = 0; + + /** + * Get the lock instance. + * + * @return + * - return NULL if error occurred + */ + virtual IRtmLock* getLock() = 0; + + /** + * Get the presence instance. + * + * @return + * - return NULL if error occurred + */ + virtual IRtmPresence* getPresence() = 0; + + /** + * Renews the token. Once a token is enabled and used, it expires after a certain period of time. + * You should generate a new token on your server, call this method to renew it. + * + * @param [in] token Token used renew. + * - 0: Success. + * - < 0: Failure. + */ + virtual int renewToken(const char* token) = 0; + + /** + * Publish a message in the channel. + * + * @param [in] channelName The name of the channel. + * @param [in] message The content of the message. + * @param [in] length The length of the message. + * @param [in] option The option of the message. + * @param [out] requestId The related request id of this operation. + * @return + * - 0: Success. + * - < 0: Failure. + */ + virtual int publish(const char* channelName, const char* message, const size_t length, const PublishOptions& option, uint64_t& requestId) = 0; + + /** + * Subscribe a channel. + * + * @param [in] channelName The name of the channel. + * @param [in] options The options of subscribe the channel. + * @return + * - 0: Success. + * - < 0: Failure. + */ + virtual int subscribe(const char* channelName, const SubscribeOptions& options, uint64_t& requestId) = 0; + + /** + * Unsubscribe a channel. + * + * @param [in] channelName The name of the channel. + * @return + * - 0: Success. + * - < 0: Failure. + */ + virtual int unsubscribe(const char* channelName) = 0; + + /** + * Create a stream channel instance. + * + * @param [in] channelName The Name of the channel. + * @return + * - return NULL if error occurred + */ + virtual IStreamChannel* createStreamChannel(const char* channelName) = 0; + + /** + * Set parameters of the sdk or engine + * + * @param [in] parameters The parameters in json format + * @return + * - 0: Success. + * - < 0: Failure. + */ + virtual int setParameters(const char* parameters) = 0; + + protected: + virtual ~IRtmClient() {} +}; + +/** + * Creates the rtm client object and returns the pointer. + * + * @return Pointer of the rtm client object. + */ +AGORA_API IRtmClient* AGORA_CALL createAgoraRtmClient(); + +/** + * Convert error code to error string + * + * @param [in] errorCode Received error code + * @return The error reason + */ +AGORA_API const char* AGORA_CALL getErrorReason(int errorCode); + +/** + * Get the version info of the Agora RTM SDK. + * + * @return The version info of the Agora RTM SDK. + */ +AGORA_API const char* AGORA_CALL getVersion(); + +} // namespace rtm +} // namespace agora diff --git a/headers/rtm_2.1.10/include/IAgoraRtmLock.h b/headers/rtm_2.1.10/include/IAgoraRtmLock.h new file mode 100644 index 0000000..8a27de3 --- /dev/null +++ b/headers/rtm_2.1.10/include/IAgoraRtmLock.h @@ -0,0 +1,107 @@ +// Copyright (c) 2022 Agora.io. All rights reserved + +// This program is confidential and proprietary to Agora.io. +// And may not be copied, reproduced, modified, disclosed to others, published +// or used, in whole or in part, without the express prior written permission +// of Agora.io. + +#pragma once // NOLINT(build/header_guard) + +#include "AgoraRtmBase.h" + +namespace agora { +namespace rtm { + +/** + * The IRtmLock class. + * + * This class provides the rtm lock methods that can be invoked by your app. + */ +class IRtmLock { + public: + /** + * sets a lock + * + * @param [in] channelName The name of the channel. + * @param [in] channelType The type of the channel. + * @param [in] lockName The name of the lock. + * @param [in] ttl The lock ttl. + * @param [out] requestId The related request id of this operation. + * @return + * - 0: Success. + * - < 0: Failure. + */ + virtual int setLock(const char* channelName, RTM_CHANNEL_TYPE channelType, const char* lockName, uint32_t ttl, uint64_t& requestId) = 0; + + /** + * gets locks in the channel + * + * @param [in] channelName The name of the channel. + * @param [in] channelType The type of the channel. + * @param [out] requestId The related request id of this operation. + * @return + * - 0: Success. + * - < 0: Failure. + */ + virtual int getLocks(const char* channelName, RTM_CHANNEL_TYPE channelType, uint64_t& requestId) = 0; + + /** + * removes a lock + * + * @param [in] channelName The name of the channel. + * @param [in] channelType The type of the channel. + * @param [in] lockName The name of the lock. + * @param [out] requestId The related request id of this operation. + * @return + * - 0: Success. + * - < 0: Failure. + */ + virtual int removeLock(const char* channelName, RTM_CHANNEL_TYPE channelType, const char* lockName, uint64_t& requestId) = 0; + + /** + * acquires a lock + * + * @param [in] channelName The name of the channel. + * @param [in] channelType The type of the channel. + * @param [in] lockName The name of the lock. + * @param [in] retry Whether to automatically retry when acquires lock failed + * @param [out] requestId The related request id of this operation. + * @return + * - 0: Success. + * - < 0: Failure. + */ + virtual int acquireLock(const char* channelName, RTM_CHANNEL_TYPE channelType, const char* lockName, bool retry, uint64_t& requestId) = 0; + + /** + * releases a lock + * + * @param [in] channelName The name of the channel. + * @param [in] channelType The type of the channel. + * @param [in] lockName The name of the lock. + * @param [out] requestId The related request id of this operation. + * @return + * - 0: Success. + * - < 0: Failure. + */ + virtual int releaseLock(const char* channelName, RTM_CHANNEL_TYPE channelType, const char* lockName, uint64_t& requestId) = 0; + + /** + * disables a lock + * + * @param [in] channelName The name of the channel. + * @param [in] channelType The type of the channel. + * @param [in] lockName The name of the lock. + * @param [in] owner The lock owner. + * @param [out] requestId The related request id of this operation. + * @return + * - 0: Success. + * - < 0: Failure. + */ + virtual int revokeLock(const char* channelName, RTM_CHANNEL_TYPE channelType, const char* lockName, const char* owner, uint64_t& requestId) = 0; + + protected: + virtual ~IRtmLock() {} +}; + +} // namespace rtm +} // namespace agora diff --git a/headers/rtm_2.1.10/include/IAgoraRtmPresence.h b/headers/rtm_2.1.10/include/IAgoraRtmPresence.h new file mode 100644 index 0000000..0a8123a --- /dev/null +++ b/headers/rtm_2.1.10/include/IAgoraRtmPresence.h @@ -0,0 +1,116 @@ +// Copyright (c) 2022 Agora.io. All rights reserved + +// This program is confidential and proprietary to Agora.io. +// And may not be copied, reproduced, modified, disclosed to others, published +// or used, in whole or in part, without the express prior written permission +// of Agora.io. + +#pragma once // NOLINT(build/header_guard) + +#include "AgoraRtmBase.h" + +namespace agora { +namespace rtm { + +/** + * The IRtmPresence class. + * + * This class provides the rtm presence methods that can be invoked by your app. + */ +class IRtmPresence { + public: + /** + * To query who joined this channel + * + * @param [in] channelName The name of the channel. + * @param [in] channelType The type of the channel. + * @param [in] options The query option. + * @param [out] requestId The related request id of this operation. + * @return + * - 0: Success. + * - < 0: Failure. + */ + virtual int whoNow(const char* channelName, RTM_CHANNEL_TYPE channelType, const PresenceOptions& options, uint64_t& requestId) = 0; + + /** + * To query which channels the user joined + * + * @param [in] userId The id of the user. + * @param [out] requestId The related request id of this operation. + * @return + * - 0: Success. + * - < 0: Failure. + */ + virtual int whereNow(const char* userId, uint64_t& requestId) = 0; + + /** + * Set user state + * + * @param [in] channelName The name of the channel. + * @param [in] channelType The type of the channel. + * @param [in] items The states item of user. + * @param [in] count The count of states item. + * @param [out] requestId The related request id of this operation. + * @return + * - 0: Success. + * - < 0: Failure. + */ + virtual int setState(const char* channelName, RTM_CHANNEL_TYPE channelType, const StateItem* items, size_t count, uint64_t& requestId) = 0; + + /** + * Delete user state + * + * @param [in] channelName The name of the channel. + * @param [in] channelType The type of the channel. + * @param [in] keys The keys of state item. + * @param [in] count The count of keys. + * @param [out] requestId The related request id of this operation. + * @return + * - 0: Success. + * - < 0: Failure. + */ + virtual int removeState(const char* channelName, RTM_CHANNEL_TYPE channelType, const char** keys, size_t count, uint64_t& requestId) = 0; + + /** + * Get user state + * + * @param [in] channelName The name of the channel. + * @param [in] channelType The type of the channel. + * @param [in] userId The id of the user. + * @param [out] requestId The related request id of this operation. + * @return + * - 0: Success. + * - < 0: Failure. + */ + virtual int getState(const char* channelName, RTM_CHANNEL_TYPE channelType, const char* userId, uint64_t& requestId) = 0; + + /** + * To query who joined this channel + * + * @param [in] channelName The name of the channel. + * @param [in] channelType The type of the channel. + * @param [in] options The query option. + * @param [out] requestId The related request id of this operation. + * @return + * - 0: Success. + * - < 0: Failure. + */ + virtual int getOnlineUsers(const char* channelName, RTM_CHANNEL_TYPE channelType, const GetOnlineUsersOptions& options, uint64_t& requestId) = 0; + + /** + * To query which channels the user joined + * + * @param [in] userId The id of the user. + * @param [out] requestId The related request id of this operation. + * @return + * - 0: Success. + * - < 0: Failure. + */ + virtual int getUserChannels(const char* userId, uint64_t& requestId) = 0; + + protected: + virtual ~IRtmPresence() {} +}; + +} // namespace rtm +} // namespace agora diff --git a/headers/rtm_2.1.10/include/IAgoraRtmService.h b/headers/rtm_2.1.10/include/IAgoraRtmService.h new file mode 100644 index 0000000..1e4b3f0 --- /dev/null +++ b/headers/rtm_2.1.10/include/IAgoraRtmService.h @@ -0,0 +1,715 @@ +// +// Agora Rtm SDK +// +// Created by junhao Wang in 2018-05. +// Copyright (c) 2018 Agora IO. All rights reserved. +// +#pragma once + +#include + +namespace agora { + +namespace rtm { + +enum PEER_MESSAGE_STATE { + PEER_MESSAGE_INIT = 0, + PEER_MESSAGE_FAILURE = 1, + PEER_MESSAGE_PEER_UNREACHABLE = 2, + PEER_MESSAGE_RECEIVED_BY_PEER = 3, + PEER_MESSAGE_SENT_TIMEOUT = 4, +}; +/** + * The login error code. + */ +enum LOGIN_ERR_CODE { + /** + * 0: Login succeeds. No error occurs. + */ + LOGIN_ERR_OK = 0, + /** + * 1: Login fails for reasons unknown. + */ + LOGIN_ERR_UNKNOWN = 1, + /** + * 2: The server rejects the login, either because the user has already logged in, or because + * the RTM service is not initialized. + */ + LOGIN_ERR_REJECTED = 2, // ALREADY LOGIN OR NOT INITIALIZED, SERVER REJECT + /** + * 3: Invalid login arguments. + */ + LOGIN_ERR_INVALID_ARGUMENT = 3, + /** + * 4: The App ID is invalid. + */ + LOGIN_ERR_INVALID_APP_ID = 4, + /** + * 5: The token is invalid. + */ + LOGIN_ERR_INVALID_TOKEN = 5, + /** + * 6: The login is rejected because the token has expired. + */ + LOGIN_ERR_TOKEN_EXPIRED = 6, + /** + * 7: Authentication of the RTMP token fails. + */ + LOGIN_ERR_NOT_AUTHORIZED = 7, + /** + * 8: The login times out. The current timeout is set as six seconds. + */ + LOGIN_ERR_TIMEOUT = 8, +}; +/** + * The logout error code. + */ +enum LOGOUT_ERR_CODE { + /** + * 0: Logout succeeds. No error occurs. + */ + LOGOUT_ERR_OK = 0, + /** + * 1: Logout fails. + */ + LOGOUT_ERR_REJECTED = 1, +}; +/** + * The connection state. + */ +enum CONNECTION_STATE { + /** + * 1: The SDK has logged in the RTM service. + */ + CONNECTION_STATE_CONNECTED = 1, + /** + * 2: The initial state. The SDK is disconnected from the RTM service. + */ + CONNECTION_STATE_DISCONNECTED = 2, + /** + * 3: The SDK gives up logging in the RTM service, mainly because another instance has logged in the RTM + * service with the same user ID. + * + * Call the logout() method before calling login to log in the RTM service again. + */ + CONNECTION_STATE_ABORTED = 3, +}; + +/** + * The state of the channel message. + */ +enum CHANNEL_MESSAGE_STATE { + /** + * 1: The channel message is received by the server. + */ + CHANNEL_MESSAGE_RECEIVED_BY_SERVER = 1, + /** + * 3: The SDK has not received a response from the server in five seconds. The current timeout is set as + * five seconds. + */ + CHANNEL_MESSAGE_SENT_TIMEOUT = 3, +}; +/** + * The join channel error. + */ +enum JOIN_CHANNEL_ERR { + /** + 0: The method call succeeds, or the user joins the channel successfully. + */ + JOIN_CHANNEL_ERR_OK = 0, + + /** + 1: Common failure. The user fails to join the channel. + */ + JOIN_CHANNEL_ERR_FAILURE = 1, + + /** + 2: **RESERVED FOR FUTURE USE** + */ + JOIN_CHANNEL_ERR_REJECTED = 2, // Usually occurs when the user is already in the channel + + /** + 3: The user fails to join the channel because the argument is invalid. + */ + JOIN_CHANNEL_ERR_INVALID_ARGUMENT = 3, + + /** + 4: A timeout occurs when joining the channel. The current timeout is set as five seconds. Possible reasons: The user is in the \ref agora::rtm::CONNECTION_STATE_ABORTED "CONNECTION_STATE_ABORTED" state. + */ + JOIN_CHANNEL_TIMEOUT = 4, + + /** + 5: The number of the RTM channels you are in exceeds the limit of 20. + */ + JOIN_CHANNEL_ERR_EXCEED_LIMIT = 5, + + /** + 6: The user is joining or has joined the channel. + */ + JOIN_CHANNEL_ERR_ALREADY_JOINED = 6, + + /** + 7: The method call frequency exceeds 50 queries every three seconds. + */ + JOIN_CHANNEL_ERR_TOO_OFTEN = 7, + + /** + 8: The frequency of joining the same channel exceeds two times every five seconds. + */ + JOIN_CHANNEL_ERR_JOIN_SAME_CHANNEL_TOO_OFTEN = 8, + + /** + 101: \ref agora::rtm::IRtmService "IRtmService" is not initialized. + */ + JOIN_CHANNEL_ERR_NOT_INITIALIZED = 101, + + /** + 102: The user does not call the \ref agora::rtm::IRtmService::login "login" method, or the method call of \ref agora::rtm::IRtmService::login "login" does not succeed before joining the channel. + */ + JOIN_CHANNEL_ERR_USER_NOT_LOGGED_IN = 102, +}; +/** + @brief Error codes related to leaving a channel. + */ +enum LEAVE_CHANNEL_ERR { + + /** + 0: The method call succeeds, or the user leaves the channel successfully. + */ + LEAVE_CHANNEL_ERR_OK = 0, + + /** + 1: Common failure. The user fails to leave the channel. + */ + LEAVE_CHANNEL_ERR_FAILURE = 1, + + /** + 2: **RESERVED FOR FUTURE USE** + */ + LEAVE_CHANNEL_ERR_REJECTED = 2, + + /** + 3: The user is not in the channel. + */ + LEAVE_CHANNEL_ERR_NOT_IN_CHANNEL = 3, + + /** + 101: \ref agora::rtm::IRtmService "IRtmService" is not initialized. + */ + LEAVE_CHANNEL_ERR_NOT_INITIALIZED = 101, + + /** + 102: The user does not call the \ref agora::rtm::IRtmService::login "login" method, or the method call of \ref agora::rtm::IRtmService::login "login" does not succeed before calling the \ref agora::rtm::IChannel::leave "leave" method. + */ + LEAVE_CHANNEL_ERR_USER_NOT_LOGGED_IN = 102, +}; + +/** + * The reason for a user to leave the channel. + */ +enum LEAVE_CHANNEL_REASON { + /** + * 1: The user quits the channel. + */ + LEAVE_CHANNEL_REASON_QUIT = 1, + /** + * 2: The user is kicked off the channel. + */ + LEAVE_CHANNEL_REASON_KICKED = 2, +}; +/** + @brief Error codes related to sending a channel message. + */ +enum CHANNEL_MESSAGE_ERR_CODE { + + /** + 0: The method call succeeds, or the server receives the channel message. + */ + CHANNEL_MESSAGE_ERR_OK = 0, + + /** + 1: Common failure. The user fails to send the channel message. + */ + CHANNEL_MESSAGE_ERR_FAILURE = 1, + + /** + 2: The SDK does not receive a response from the server in 10 seconds. The current timeout is set as 10 seconds. Possible reasons: The user is in the \ref agora::rtm::CONNECTION_STATE_ABORTED "CONNECTION_STATE_ABORTED" state. + */ + CHANNEL_MESSAGE_ERR_SENT_TIMEOUT = 2, + + /** + 3: The method call frequency exceeds the limit of (RTM SDK for Windows C++) 180 calls every three seconds or (RTM SDK for Linux C++) 1500 calls every three seconds, with channel and peer messages taken together.. + */ + CHANNEL_MESSAGE_ERR_TOO_OFTEN = 3, + + /** + 4: The message is null or exceeds 32 KB in length. + */ + CHANNEL_MESSAGE_ERR_INVALID_MESSAGE = 4, + + /** + 101: \ref agora::rtm::IRtmService "IRtmService" is not initialized. + */ + CHANNEL_MESSAGE_ERR_NOT_INITIALIZED = 101, + + /** + 102: The user does not call the \ref agora::rtm::IRtmService::login "login" method, or the method call of \ref agora::rtm::IRtmService::login "login" does not succeed before sending out a channel message. + */ + CHANNEL_MESSAGE_ERR_USER_NOT_LOGGED_IN = 102, +}; + +/** + * The response code. + */ +enum RESPONSE_CODE { + /** + * 1: The response + */ + RESPONSE_CODE_SUCCESS = 1, + RESPONSE_CODE_FAILURE = 2, +}; +/** + * The message type. + */ +enum MESSAGE_TYPE { + /** + * 0: The message type is undefined. + */ + MESSAGE_TYPE_UNDEFINED = 0, + /** + * 1: A text message. + */ + MESSAGE_TYPE_TEXT = 1, + /** + * 2: A raw message in binary, for example, audio data, or video data. + */ + MESSAGE_TYPE_BINARY = 2, + /** + * 4: A converge message. + */ + MESSAGE_TYPE_CONVERGE = 4, +}; +/** + * The IMessage class. + */ +class IMessage { + public: + /** + * Creates an IMessage instance. + * + * The created IMessage instance can be either for a channel message or for a peer-to-peer message. + * + * You can set the content of the text message later using the setText() method. + * @return + * - An empty text IMessage instance, if the method call succeeds. + */ + static IMessage *createMessage(); + virtual ~IMessage() {} + /** + * Gets the ID of the message. + * @return The ID of the current IMessage instance. + */ + virtual int64_t getMessageId() const = 0; + /** + * Gets the message type. + * @return + * - 0: Success. + * - < 0: Failure. + */ + virtual int getMessageType() const = 0; + /** + * Sets the content of the text message, or the text description of the raw message. + * @param str The content of the text message, or the text description of the raw message. The maximum length + * is 32 KB. + */ + virtual void setText(const char *str) = 0; + /** + * Gets the content of the text messsage, or the text description of the raw message. + * @return + * - The content of the text message or the text description of the raw message. + */ + virtual const char *getText() const = 0; + /** + * Get pointer of custom raw message + * @return + * - The content of binary raw message + */ + virtual const unsigned char *getRawMessageData() const = 0; + /** + * Get length of custom raw message + * @return + * - The length of binary raw message in bytes + */ + virtual int getRawMessageLength() const = 0; + /** + * Set message type + */ + virtual void setMessageType(int32_t type) = 0; + /** + * Set raw binary message + */ + virtual void setRawMessage(const uint8_t* data, int length) = 0; + /** + * Releases the IMessage instance. + */ + virtual void release() = 0; +}; + +/** + * The IChannelMember class. + */ +class IChannelMember { + public: + virtual ~IChannelMember() {} + /** + * Gets the ID of the channel member. + * @return The ID of the channel member. + */ + virtual const char *getMemberId() const = 0; + /** + * Gets the ID of the channel. + * @return The ID of the channel. + */ + virtual const char *getChannelId() const = 0; + /** + * Releases the IChannelMember class. + */ + virtual void release() = 0; +}; +/** + * The IChannelAttributes class. + */ +class IChannelAttributes { + public: + /** + * Creates an IChannelAttributes instance. + * @return + * - An IChannelAttributes instance, if the method call succeeds. + */ + static IChannelAttributes *createChannelAttributes(); + /** + * Adds an attribute to a specified channel. + * + * @param key The pointer to the attribute key. + * @param value The pointer to the attribute value. + * @return + * - 0: Success. + * - < 0: Failure. + */ + virtual int addAttribute(const char *key, const char *value) = 0; + /** + * Removes an attribute from the channel. + * @param key The pointer to the attribute key. + * @return + * - 0: Success. + * - < 0: Failure. + */ + virtual int removeAttribute(const char *key) = 0; + /** + * Gets the size of the attributes. + * @return + * - 0: Success. + * - < 0: Failure. + */ + virtual int getAttributesSize() const = 0; + /** + * Gets the channel attributes. + * @param size The size of the channel attributes. + * @param key The pointer to the key of each channel attribute. + * @param value The pointer to the value of each channel attribute. + */ + virtual void getAttributes(int size, char **key, + char **value) const = 0; // todo: discussion, how to traveral + /** + * Gets the value of a channel attribute using the attribute key. + * @param key The pointer to the key of the channel attribute that you want to get. + */ + virtual const char *getAttributeValue(const char *key) const = 0; + /** + * Releases the IChannelAttributes instance. + * @param + * - 0: Success. + * - < 0: Failure. + */ + virtual int release() = 0; +}; +/** + * The IChannelEventHandler class. + */ +class IChannelEventHandler { + public: + virtual ~IChannelEventHandler() {} + /** + * Occurs when the local user successfully joins a channel. + */ + virtual void onJoinSuccess() {} + /** + * Occurs when the local user fails to join a channel. + * @param errorCode The error code: #JOIN_CHANNEL_ERR. + */ + virtual void onJoinFailure(JOIN_CHANNEL_ERR errorCode) {} + /** + * Occurs when the local user leaves a channel. + * @param errorCode The error code. See #LEAVE_CHANNEL_ERR. + */ + virtual void onLeave(LEAVE_CHANNEL_ERR errorCode) {} + /** + * Occurs when the local user receives a channel message. + * @param message The pointer to the messsage: IMessage. + */ + virtual void onMessageReceived(const char *userId, const IMessage *message) {} + /** + * Reports the state of the message sent by the local user. + * @param messageId ID of the message. + * @param state The state of the message: #CHANNEL_MESSAGE_STATE. + */ + virtual void onSendMessageState(int64_t messageId, CHANNEL_MESSAGE_STATE state) {} + /** + Returns the result of the \ref agora::rtm::IChannel::sendMessage "sendMessage" method call. + + @param messageId The ID of the sent channel message. + @param state The error codes. See #CHANNEL_MESSAGE_ERR_CODE. + */ + virtual void onSendMessageResult(long long messageId, CHANNEL_MESSAGE_ERR_CODE state) {} + /** + * Occurs when another member joins the channel. + * @param member The pointer to the member who joins the channel: IChannelMember. + */ + virtual void onMemberJoined(IChannelMember *member) {} + /** + * Occurs when the other member leaves the channel. + * @param member The pointer to the member who leaves the channel: IChannelMember. + */ + virtual void onMemberLeft(IChannelMember *member) {} + /** + * Reports all the members in the channel. + * @param members The pointer to each member in the channel: IChannelMember. + * @param userCount The number of users in the channel. + */ + virtual void onMembersGotten(IChannelMember **members, int userCount) {} + /** + * Occurs when the channel attributes are updated. + * @param attributes The pointer to the current channel attributes: IChannelAttributes. + */ + virtual void onAttributesUpdated(const IChannelAttributes *attributes) {} + /** + * Occurs when the local user calls updateAttributes(). + * @param requestId ID of the current attribute update request. + * @param resCode The response code: #RESPONSE_CODE. + */ + virtual void onUpdateAttributesResponse(int64_t requestId, RESPONSE_CODE resCode) {} + /** + * Occurs when the channel attributes are deleted. + * @param attributes The pointer to the channel attributes that you want to remove: IChannelAttributes. + */ + virtual void onAttributesDeleted(const IChannelAttributes *attributes) {} + /** + * Occurs when the local user calls deleteAttributes(). + * @param requestId ID of the current attribute delete request. + * @param resCode The response code: #RESPONSE_CODE. + */ + virtual void onDeleteAttributesResponse(int64_t requestId, RESPONSE_CODE resCode) {} +}; +/** + * The IChannel class. + */ +class IChannel { + public: + /** + * Sets an event handler for IChannel. + * @param eventHandler The pointer to the event handler of IChannel: IChannelEventHandler. + */ + virtual void setEventHandler(IChannelEventHandler *eventHandler) = 0; + /** + * Joins the current channel. + * + * A successful method call triggers either onJoinSuccess() or onJoinFailure() on the local client, to report + * the state of joining the channel. + * @return + * - 0: Success. + * - < 0: Failure. + */ + virtual int join() = 0; + /** + * Leaves the current channel. + * + * After the local user successfully leaves the channel, the SDK triggers the onLeave() on the local client. + * @return + * - 0: Success. + * - < 0: Failure. + */ + virtual int leave() = 0; + /** + * Sends a channel message. + * + * After you successfully send a channel message, all members in the channel receive the message in the + * onMessageReceived() callback. + * @param message The pointer to the channel message that you want to send: IMessage. + * @return + * - 0: Success. + * - < 0: Failure. + */ + virtual int sendMessage(const IMessage *message) = 0; + /** + * Updates the channel attributes. + * + * A successful method call triggers the onUpdateAttributesResponse() callback on the local client. + * @param attributes The pointer to the channel attributes that you want to update: IChannelAttributes. + * @param requestId ID of the current update request. + * @return + * - 0: Success. + * - < 0: Failure. + */ + virtual int updateAttributes(IChannelAttributes *attributes, int64_t &requestId) = 0; + /** + * Removes the channel attributes. + * + * A successful method call triggers the onDeleteAttributesResponse() callback on the local client. + * @param attributes The pointer to the channel attributes that you want to remove: IChannelAttributes. + * @param requestId ID of the current delete request. + * @return + * - 0: Success. + * - < 0: Failure. + */ + virtual int deleteAttributes(IChannelAttributes *attributes, int64_t &requestId) = 0; + /** + * Gets the current request ID. + * @return + * - The pointer to the request ID, if the method call succeeds. + * - An empty pointer NULL, if the method call fails. + */ + virtual const char *getId() const = 0; + + // sync_call + /** + * Releases the IChannel instance. + * + * This is a synchronous method call, which means that the SDK reports the result of this method call + * after the IChannel instance is successfully released. + * @return + * - 0: Success. + * - < 0: Failure. + */ + virtual int release() = 0; +}; +/** + * The IRtmServiceEventHandler class. + */ +class IRtmServiceEventHandler { + public: + virtual ~IRtmServiceEventHandler() {} + + /** + * Occurs when the user successfully logs in the RTM service. + */ + virtual void onLoginSuccess() {} + /** + * Occurs when the user fails to log in the RTM service. + * @param errorCode The reason for the login failure: #LOGIN_ERR_CODE. + */ + virtual void onLoginFailure(LOGIN_ERR_CODE errorCode) {} + /** + * Occurs when the user successfully logs out of the RTM service. + */ + virtual void onLogout() {} + /** + * Occurs when the connection state of the local user has changed. + * @param state The current connection state: #CONNECTION_STATE. + */ + virtual void onConnectionStateChanged(CONNECTION_STATE state) {} + /** + * Reports the state of sending a message. + * @param messageId ID of the message. + * @param state The current state of the message: #PEER_MESSAGE_STATE. + */ + virtual void onSendMessageState(int64_t messageId, PEER_MESSAGE_STATE state) {} + /** + * Occurs when the local user receives a message from a remote user. + * @param peerId ID of the remote user that sends the message. + * @param message The pointer to the message: IMessage. + */ + virtual void onMessageReceivedFromPeer(const char *peerId, const IMessage *message) {} +}; +/** + * The IRtmService class. + */ +class IRtmService { + public: + virtual ~IRtmService() {} + /** + * Creates and gets an IRtmService instance. + * @param appId The pointer to the app ID. + * @param eventHandler The pointer to the IRtmServiceEventHandler object. + * @param eventSpace The connection specific ID, used during report to argus. + * @return + * - 0: Success. + * - < 0: Failure. + */ + virtual int initialize(const char *appId, IRtmServiceEventHandler *eventHandler) = 0; + /** + * Releases the IRtmServiceEventHandler object. + * @param eventHandler The pointer to the IRtmServiceEventHandler object. + */ + virtual void unregisterObserver(IRtmServiceEventHandler *eventHandler) = 0; + /** + * Releases the IRtmService instance. + * @param sync Determines whether to report the result of this method call synchronously. + * - true: Report the result of this method call after the IRtmService instance is released. + * - false: (Default) Report the result of this method call immediately, even when the IRtmService is not + * released. + * @return + * - 0: Success. + * - < 0: Failure. + */ + virtual int release(bool sync = false) = 0; + /** + * Logs in the RTM service. + * + * @note + * - If you login with the same user ID from a different instance, your previous login will be kicked. + * - The call frequency limit of this method is 2 queries per second. + * @param token The token used to log in the RTM service. + * @param userId ID of the user logging in the RTM service. + * @return + * - 0: Success. + * - < 0: Failure. + */ + virtual int login(const char *token, const char *userId) = 0; + /** + * Logs out of the RTM service. + * @return + * - 0: Success. + * - < 0: Failure. + */ + virtual int logout() = 0; + /** + * Sends a peer message to a specified remote user. + * + * @param peerId The pointer to the ID of the remote user. + * @param message The pointer to message: IMessage. + * @return + * - 0: Success. + * - < 0: Failure. + */ + virtual int sendMessageToPeer(const char *peerId, const IMessage *message) = 0; + /** + * Creates an RTM channel. + * + * @param channelId The unique channel name for an RTM session. Supported character scopes are: + * - All lowercase English letters: a to z. + * - All uppercase English letters: A to Z. + * - All numeric characters: 0 to 9. + * - The space character. + * - Punctuation characters and other symbols, including: "!", "#", "$", "%", "&", "(", ")", "+", "-", ":", ";", "<", "=", + * ".", ">", "?", "@", "[", "]", "^", "_", " {", "}", "|", "~", "," + * + * @param eventHandler The pointer to IChannelEventHandler. + * @return + * - The pointer to an IChannel instance, if the method call succeeds. + * - An empty pointer NULL, if the method call fails. + */ + virtual IChannel *createChannel(const char *channelId, IChannelEventHandler *eventHandler) = 0; +}; + +} // namespace rtm +} // namespace agora diff --git a/headers/rtm_2.1.10/include/IAgoraRtmStorage.h b/headers/rtm_2.1.10/include/IAgoraRtmStorage.h new file mode 100644 index 0000000..f34646e --- /dev/null +++ b/headers/rtm_2.1.10/include/IAgoraRtmStorage.h @@ -0,0 +1,257 @@ +// Copyright (c) 2022 Agora.io. All rights reserved + +// This program is confidential and proprietary to Agora.io. +// And may not be copied, reproduced, modified, disclosed to others, published +// or used, in whole or in part, without the express prior written permission +// of Agora.io. + +#pragma once // NOLINT(build/header_guard) + +#include "AgoraRtmBase.h" + +namespace agora { +namespace rtm { + +/** + * Metadata options. + */ +struct MetadataOptions { + /** + * Indicates whether or not to notify server update the modify timestamp of metadata + */ + bool recordTs; + /** + * Indicates whether or not to notify server update the modify user id of metadata + */ + bool recordUserId; + + MetadataOptions() + : recordTs(false), + recordUserId(false) {} +}; + +struct MetadataItem { + public: + /** + * The key of the metadata item. + */ + const char* key; + /** + * The value of the metadata item. + */ + const char* value; + /** + * The User ID of the user who makes the latest update to the metadata item. + */ + const char* authorUserId; + /** + * The revision of the metadata item. + */ + int64_t revision; + /** + * The Timestamp when the metadata item was last updated. + */ + int64_t updateTs; + + MetadataItem() + : key(NULL), + value(NULL), + authorUserId(NULL), + revision(-1), + updateTs(0) {} + + MetadataItem(const char* key, const char* value, int64_t revision = -1) + : key(key), + value(value), + authorUserId(NULL), + revision(revision), + updateTs(0) {} +}; + +class IMetadata { + public: + /** + * Set the major revision of metadata. + * + * @param [in] revision The major revision of the metadata. + */ + virtual void setMajorRevision(const int64_t revision) = 0; + /** + * Get the major revision of metadata. + * + * @return the major revision of metadata. + */ + virtual int64_t getMajorRevision() const = 0; + /** + * Add or revise a metadataItem to current metadata. + */ + virtual void setMetadataItem(const MetadataItem& item) = 0; + /** + * Get the metadataItem array of current metadata. + * + * @param [out] items The address of the metadataItem array. + * @param [out] size The size the metadataItem array. + */ + virtual void getMetadataItems(const MetadataItem** items, size_t* size) const = 0; + /** + * Clear the metadataItem array & reset major revision + */ + virtual void clearMetadata() = 0; + /** + * Release the metadata instance. + */ + virtual void release() = 0; + protected: + virtual ~IMetadata() {} +}; + +class IRtmStorage { + public: + /** Creates the metadata object and returns the pointer. + * @return Pointer of the metadata object. + */ + virtual IMetadata* createMetadata() = 0; + + /** + * Set the metadata of a specified channel. + * + * @param [in] channelName The name of the channel. + * @param [in] channelType Which channel type, RTM_CHANNEL_TYPE_STREAM or RTM_CHANNEL_TYPE_MESSAGE. + * @param [in] data Metadata data. + * @param [in] options The options of operate metadata. + * @param [in] lock lock for operate channel metadata. + * @param [out] requestId The unique ID of this request. + * + * @return + * - 0: Success. + * - < 0: Failure. + */ + virtual int setChannelMetadata( + const char* channelName, RTM_CHANNEL_TYPE channelType, const IMetadata* data, const MetadataOptions& options, const char* lockName, uint64_t& requestId) = 0; + /** + * Update the metadata of a specified channel. + * + * @param [in] channelName The channel Name of the specified channel. + * @param [in] channelType Which channel type, RTM_CHANNEL_TYPE_STREAM or RTM_CHANNEL_TYPE_MESSAGE. + * @param [in] data Metadata data. + * @param [in] options The options of operate metadata. + * @param [in] lock lock for operate channel metadata. + * @param [out] requestId The unique ID of this request. + * + * @return + * - 0: Success. + * - < 0: Failure. + */ + virtual int updateChannelMetadata( + const char* channelName, RTM_CHANNEL_TYPE channelType, const IMetadata* data, const MetadataOptions& options, const char* lockName, uint64_t& requestId) = 0; + /** + * Remove the metadata of a specified channel. + * + * @param [in] channelName The channel Name of the specified channel. + * @param [in] channelType Which channel type, RTM_CHANNEL_TYPE_STREAM or RTM_CHANNEL_TYPE_MESSAGE. + * @param [in] data Metadata data. + * @param [in] options The options of operate metadata. + * @param [in] lock lock for operate channel metadata. + * @param [out] requestId The unique ID of this request. + * + * @return + * - 0: Success. + * - < 0: Failure. + */ + virtual int removeChannelMetadata( + const char* channelName, RTM_CHANNEL_TYPE channelType, const IMetadata* data, const MetadataOptions& options, const char* lockName, uint64_t& requestId) = 0; + /** + * Get the metadata of a specified channel. + * + * @param [in] channelName The channel Name of the specified channel. + * @param [in] channelType Which channel type, RTM_CHANNEL_TYPE_STREAM or RTM_CHANNEL_TYPE_MESSAGE. + * @param requestId The unique ID of this request. + * + * @return + * - 0: Success. + * - < 0: Failure. + */ + virtual int getChannelMetadata( + const char* channelName, RTM_CHANNEL_TYPE channelType, uint64_t& requestId) = 0; + + /** + * Set the metadata of a specified user. + * + * @param [in] userId The user ID of the specified user. + * @param [in] data Metadata data. + * @param [in] options The options of operate metadata. + * @param [out] requestId The unique ID of this request. + * + * @return + * - 0: Success. + * - < 0: Failure. + */ + virtual int setUserMetadata( + const char* userId, const IMetadata* data, const MetadataOptions& options, uint64_t& requestId) = 0; + /** + * Update the metadata of a specified user. + * + * @param [in] userId The user ID of the specified user. + * @param [in] data Metadata data. + * @param [in] options The options of operate metadata. + * @param [out] requestId The unique ID of this request. + * + * @return + * - 0: Success. + * - < 0: Failure. + */ + virtual int updateUserMetadata( + const char* userId, const IMetadata* data, const MetadataOptions& options, uint64_t& requestId) = 0; + /** + * Remove the metadata of a specified user. + * + * @param [in] userId The user ID of the specified user. + * @param [in] data Metadata data. + * @param [in] options The options of operate metadata. + * @param [out] requestId The unique ID of this request. + * + * @return + * - 0: Success. + * - < 0: Failure. + */ + virtual int removeUserMetadata( + const char* userId, const IMetadata* data, const MetadataOptions& options, uint64_t& requestId) = 0; + /** + * Get the metadata of a specified user. + * + * @param [in] userId The user ID of the specified user. + * @param [out] requestId The unique ID of this request. + * + * @return + * - 0: Success. + * - < 0: Failure. + */ + virtual int getUserMetadata(const char* userId, uint64_t& requestId) = 0; + + /** + * Subscribe the metadata update event of a specified user. + * + * @param [in] userId The user ID of the specified user. + * + * @return + * - 0: Success. + * - < 0: Failure. + */ + virtual int subscribeUserMetadata(const char* userId, uint64_t& requestId) = 0; + /** + * unsubscribe the metadata update event of a specified user. + * + * @param [in] userId The user ID of the specified user. + * + * @return + * - 0: Success. + * - < 0: Failure. + */ + virtual int unsubscribeUserMetadata(const char* userId) = 0; + + protected: + virtual ~IRtmStorage() {} +}; + +} // namespace rtm +} // namespace agora diff --git a/headers/rtm_2.1.10/include/IAgoraService.h b/headers/rtm_2.1.10/include/IAgoraService.h new file mode 100644 index 0000000..ac2ec4a --- /dev/null +++ b/headers/rtm_2.1.10/include/IAgoraService.h @@ -0,0 +1,965 @@ +// Agora SDK +// +// Copyright (c) 2018 Agora.io. All rights reserved. +// + +#pragma once // NOLINT(build/header_guard) + +#include "IAgoraLog.h" +#include "AgoraBase.h" +#include "AgoraOptional.h" + +namespace agora { +class ILocalDataChannel; +class IRemoteDataChannel; +struct DataChannelConfig; + +namespace rtc { +class IRtcConnection; +class IRtmpConnection; +class ILocalUser; +class IMediaDeviceManager; +class INGAudioDeviceManager; +struct TConnectionInfo; +struct RtcConnectionConfiguration; +struct RtmpConnectionConfiguration; +class ILocalAudioTrack; +class IMediaPlayerSource; +class IMediaStreamingSource; +class ICameraCapturer; +class IScreenCapturer; +class IScreenCapturer2; +class IAudioPcmDataSender; +class IAudioEncodedFrameSender; +class IVideoFrameSender; +class IVideoEncodedImageSender; +class IVideoSourceNode; +class IVideoMixerSource; +class IVideoFrameTransceiver; +class ILocalVideoTrack; +class IMediaNodeFactory; +class IRecordingDeviceSource; +class IRemoteAudioMixerSource; +class IRtmpStreamingService; +class IMediaPacketSender; +class IMediaRelayService; +class IAudioDeviceManager; +class IAudioDeviceManagerObserver; + +class IMediaExtensionObserver; +class IExtensionProvider; +class IFileUploaderService; +/** + * The audio encoder configuration. + */ +struct AudioEncoderConfiguration { + /** + * The audio profile: #AUDIO_PROFILE_TYPE + */ + AUDIO_PROFILE_TYPE audioProfile; + + AudioEncoderConfiguration() : audioProfile(AUDIO_PROFILE_DEFAULT) {} +}; + +} // namespace rtc + +namespace rtm { +class IRtmService; +} + +namespace base { +class IServiceObserver; + +/** + * The global configurations for \ref agora::base::IAgoraService "AgoraService". + * + * Set these configurations when calling \ref agora::base::IAgoraService::initialize "initialize". + */ +struct AgoraServiceConfiguration { + /** + * Whether to enable the audio processing module. + * - `true`: (Default) Enable the audio processing module. + * - `false`: Disable the audio processing module. If you disable the audio processing module, you cannot create audio tracks. + */ + bool enableAudioProcessor; + /** + * Whether to enable the audio device module. The function of the audio device module is to manage audio devices, + * such as recording and playing audio. + * - `true`: (Default) Enable the audio device module. Audio recording and playback is available. + * - `false`: Disable the audio device module. Audio recording and playback is unavailable. + * + * @note + * If you set `enableAudioDevice` as `false` and set `enableAudioProcessor` as `true`, you cannot use audio devices, + * but you can push PCM audio data. + */ + bool enableAudioDevice; + /** + * Whether to enable video. + * - `true`: Enable video. + * - `false`: (Default) Disable video. + */ + bool enableVideo; + /** + * The user context. + * - For Windows, it is the handle of the window that loads the video. Specify this value to support plugging or unplugging the video devices while the host is powered on. + * - For Android, it is the context of activity. + */ + void* context; + /** + * The App ID of your project. + */ + const char* appId; + + /** + * The supported area code, default is AREA_CODE_GLOB + */ + unsigned int areaCode; + + /** The channel profile. For details, see \ref agora::CHANNEL_PROFILE_TYPE "CHANNEL_PROFILE_TYPE". The default channel profile is `CHANNEL_PROFILE_LIVE_BROADCASTING`. + */ + agora::CHANNEL_PROFILE_TYPE channelProfile; + + /** + * The license used for verification when connectting channel. Charge according to the license + */ + const char* license; + + /** + * The audio scenario. See \ref agora::rtc::AUDIO_SCENARIO_TYPE "AUDIO_SCENARIO_TYPE". The default value is `AUDIO_SCENARIO_DEFAULT`. + */ + rtc::AUDIO_SCENARIO_TYPE audioScenario; + /** + * The config for custumer set log path, log size and log level. + */ + commons::LogConfig logConfig; + /** + * Whether to enable string uid. + */ + bool useStringUid; + /** + * The service observer. + */ + IServiceObserver* serviceObserver; + + /** + * Thread priority for SDK common threads + */ + Optional threadPriority; + /** + * Whether use egl context in current thread as sdk‘s root egl context + * which shared by all egl related modules. eg. camera capture, video renderer. + * @note + * This property applies to Android only. + */ + bool useExternalEglContext; + + /** + * Determines whether to enable domain limit. + * - `true`: only connect to servers that already parsed by DNS + * - `false`: (Default) connect to servers with no limit + */ + bool domainLimit; + + AgoraServiceConfiguration() : enableAudioProcessor(true), + enableAudioDevice(true), + enableVideo(false), + context(NULL), + appId(NULL), + areaCode(rtc::AREA_CODE_GLOB), + channelProfile(agora::CHANNEL_PROFILE_LIVE_BROADCASTING), + license(NULL), + audioScenario(rtc::AUDIO_SCENARIO_DEFAULT), + useStringUid(false), + serviceObserver(NULL), + useExternalEglContext(false), + domainLimit(false){} +}; +/** + * The audio session configurations. + * + * Set these configurations when calling \ref agora::base::IAgoraService::setAudioSessionConfiguration "setAudioSessionConfiguration". + */ +struct AudioSessionConfiguration { + /** + * Whether to enable audio input (recording) and audio output (playback): + * - `true`: Enable audio recording and playback. + * - `false`: Disable audio recording and playback, which prevents audio input + * and output. + * + * @note + * - For the recording function to work, the user must grant permission for audio recording. + * - By default, the audio of your app is nonmixable, which means + * activating audio sessions in your app interrupts other nonmixable audio sessions. + * Set `allowMixWithOthers` as `true` to allow audio mixing. + */ + Optional playbackAndRecord; + /** + * Whether to enable chat mode: + * - `true`: Enable chat mode. This mode is for apps that are engaged in two-way + * real-time communication, such as a voice or video chat. + * - `false`: Disable chat mode. + * + * For a video chat, set this member as `true` and set the audio route to the speaker. + */ + Optional chatMode; + /** + * Whether the audio defaults to the built-in speaker: + * - `true`: The audio defaults to the built-in speaker. + * - `false`: The audio does not default to the built-in speaker. + * + * @note + * This member is available only when `playbackAndRecord` is set as `true`. + */ + Optional defaultToSpeaker; + /** + * Whether to temporarily change the current audio route to the built-in speaker: + * - `true`: Set the current audio route to the built-in speaker. + * - `false`: Do not set the current audio route to the built-in speaker. + * + * @note + * This member is available only when the `playbackAndRecord` member is set as `true`. + */ + Optional overrideSpeaker; + /** + * Whether to mix the audio from this session with the audio from active audio sessions in other apps. + * - `true`: Mix the audio sessions. + * - `false`: Do not mix the audio session. + * + * @note + * This member is available only when the `playbackAndRecord` member is set as `true`. + */ + Optional allowMixWithOthers; + /** + * Whether to duck the audio from this session with the audio from active audio sessions in other apps. + * - `true`: Duck the audio sessions. + * - `false`: Do not duck the audio session. + * + * @note + * This member is available only when the `playbackAndRecord` member is set as `true`. + */ + Optional allowDuckOthers; + /** + * Whether to allow Bluetooth handsfree devices to appear as available audio input + * devices: + * - `true`: Allow Bluetooth handsfree devices to appear as available audio input routes. + * - `false`: Do not allow Bluetooth handsfree devices to appear as available audio input + * routes. + * + * @note + * This member is available only when the `playbackAndRecord` member is set as `true`. + */ + Optional allowBluetooth; + /** + * Whether to allow the audio from this session to be routed to Bluetooth + * devices that support the Advanced Audio Distribution Profile (A2DP). + * - `true`: Allow the audio from this session to be routed to Bluetooth devices that + * support the Advanced Audio Distribution Profile (A2DP). + * - `false`: Do not allow the audio from this session to be routed to Bluetooth devices that + * support the Advanced Audio Distribution Profile (A2DP). + * + * @note + * This member is available only when the `playbackAndRecord` member is set as `true`. + */ + Optional allowBluetoothA2DP; + /** + * The expected audio sample rate (kHz) of this session. + * + * The value range is [8,48]. The actual sample rate may differ based on the audio sampling + * device in use. + */ + Optional sampleRate; + /** + * The expected input and output buffer duration (ms) of this session. + * + * The value range is [0,93]. The actual I/O buffer duration might be lower + * than the set value based on the hardware in use. + */ + Optional ioBufferDuration; + /** + * The expected number of input audio channels of this session. + */ + Optional inputNumberOfChannels; + /** + * The expected number of output audio channels of this session. + */ + Optional outputNumberOfChannels; + + void SetAll(const AudioSessionConfiguration& change) { + SetFrom(&playbackAndRecord, change.playbackAndRecord); + SetFrom(&chatMode, change.chatMode); + SetFrom(&defaultToSpeaker, change.defaultToSpeaker); + SetFrom(&overrideSpeaker, change.overrideSpeaker); + SetFrom(&allowMixWithOthers, change.allowMixWithOthers); + SetFrom(&allowDuckOthers, change.allowDuckOthers); + SetFrom(&allowBluetooth, change.allowBluetooth); + SetFrom(&allowBluetoothA2DP, change.allowBluetoothA2DP); + SetFrom(&sampleRate, change.sampleRate); + SetFrom(&ioBufferDuration, change.ioBufferDuration); + SetFrom(&inputNumberOfChannels, change.inputNumberOfChannels); + SetFrom(&outputNumberOfChannels, change.outputNumberOfChannels); + } + + bool operator==(const AudioSessionConfiguration& o) const { + return playbackAndRecord == o.playbackAndRecord && chatMode == o.chatMode && + defaultToSpeaker == o.defaultToSpeaker && overrideSpeaker == o.overrideSpeaker && + allowMixWithOthers == o.allowMixWithOthers && allowDuckOthers == o.allowDuckOthers && + allowBluetooth == o.allowBluetooth && allowBluetoothA2DP == o.allowBluetoothA2DP && sampleRate == o.sampleRate && + ioBufferDuration == o.ioBufferDuration && + inputNumberOfChannels == o.inputNumberOfChannels && + outputNumberOfChannels == o.outputNumberOfChannels; + } + bool operator!=(const AudioSessionConfiguration& o) const { return !(*this == o); } + + private: + template + static void SetFrom(Optional* s, const Optional& o) { + if (o) { + *s = o; + } + } +}; +/** + * The audio mixing mode. + */ +enum TMixMode { + /** + * Mix all the local audio tracks in the channel. + */ + MIX_ENABLED, + /** + * Do not mix the local audio tracks in the channel. + */ + MIX_DISABLED, +}; + +/** + * The IServiceObserver class. + */ +class IServiceObserver { +public: + virtual ~IServiceObserver() {} + + /** + * Reports the permission error. + * @param permission {@link PERMISSION} + */ + virtual void onPermissionError(agora::rtc::PERMISSION_TYPE permissionType) {} + /** + * Reports the audio device error. + * @param error {@link ERROR_CODE_TYPE} + */ + virtual void onAudioDeviceError(ERROR_CODE_TYPE error, const char* description) {} +}; + +/** + * The IAgoraService class. + * + * `IAgoraService` is the entry point of Agora low-level APIs. Use this interface to + * create access points to Agora interfaces, including RTC connections and media tracks. + * + * You can create an `IAgoraService` object by calling \ref agora::base::IAgoraService::createAgoraService "createAgoraService". + * + * You can configure the `IAgoraService` object for different user scenarios on the global level by using `AgoraServiceConfiguration`. + */ +class IAgoraService { + public: + /** + * Initializes the \ref agora::base::IAgoraService "AgoraService" object. + * + * @param config The configuration of the initialization. For details, see \ref agora::base::AgoraServiceConfiguration "AgoraServiceConfiguration". + * @return + * - 0: Success. + * - < 0: Failure. + * - `ERR_INVALID_ARGUMENT`, if `context` in `AgoraServiceConfiguration` is not provided for + * Android. + * - `ERR_INIT_NET_ENGINE`, if the network engine cannot be initialized. On Windows, the error occurs mostly because the connection to the local port is disabled by the firewall. In this case, turn off the firewall and then turn it on again. + */ + virtual int initialize(const AgoraServiceConfiguration& config) = 0; + + /** + * Flush log & cache before exit + */ + virtual void atExit() = 0; + + /** + * Releases the \ref agora::base::IAgoraService "AgoraService" object. + * + * @return + * - 0: Success. + * - < 0: Failure. + */ + virtual int release() = 0; + + /** + * Configures the preset audio scenario. + * + * @param scenario The preset audio scenario: \ref agora::rtc::AUDIO_SCENARIO_TYPE + * "AUDIO_SCENARIO_TYPE". + * @return + * - 0: Success. + * - < 0: Failure. + */ + virtual int setAudioSessionPreset(agora::rtc::AUDIO_SCENARIO_TYPE scenario) = 0; + + /** + * Customizes the audio session configuration. + * + * @param config The reference to the audio session configuration: \ref agora::base::AudioSessionConfiguration "AudioSessionConfiguration". + * @return + * - 0: Success. + * - < 0: Failure. + */ + virtual int setAudioSessionConfiguration(const AudioSessionConfiguration& config) = 0; + + /** + * Gets the audio session configuration. + * + * @param [out] config The pointer to the audio session configuration: \ref agora::base::AudioSessionConfiguration "AudioSessionConfiguration". + * @return + * - 0: Success. + * - < 0: Failure. + */ + virtual int getAudioSessionConfiguration(AudioSessionConfiguration* config) = 0; + + /** + * Sets the path and size of the SDK log files. + * + * The SDK records all the log data during the SDK runtime in two log files, + * each with a default size of 512 KB. If you set `fileSize` as 1024 KB, + * the SDK outputs log files with a maximum size of 2 MB. If the total size + * of the log files exceeds the set value, the new output log + * overwrites the old output log. + * + * @note + * To ensure that the output log is complete, call this method immediately after calling + * \ref agora::base::IAgoraService::initialize "initialize". + * + * @param filePath The pointer to the log file. Ensure that the directory of the log file exists and is writable. + * @param fileSize The size of the SDK log file size (KB). + * @return + * - 0: Success. + * - < 0: Failure. + */ + virtual int setLogFile(const char* filePath, unsigned int fileSize) = 0; + /** + * Sets the SDK log output filter. + * + * The log level follows the sequence of OFF, CRITICAL, ERROR, WARNING, INFO, and DEBUG. + * + * Select a level to output the logs in and above the selected level. + * For example, if you set the log level to WARNING, you can see the logs in the levels of CRITICAL, ERROR, and WARNING. + * + * @param filters The log output filter. + * - `LOG_LEVEL_NONE (0x0000)`: Do not output any log file. + * - `LOG_LEVEL_INFO (0x0001)`: (Recommended) Output log files of the INFO level. + * - `LOG_LEVEL_WARN (0x0002)`: Output log files of the WARN level. + * - `LOG_LEVEL_ERROR (0x0004)`: Output log files of the ERROR level. + * - `LOG_LEVEL_FATAL (0x0008)`: Output log files of the FATAL level. + * @return + * - 0: Success. + * - < 0: Failure. + */ + virtual int setLogFilter(unsigned int filters) = 0; + + /** + * Creates an \ref agora::rtc::IRtcConnection "RtcConnection" object and returns the pointer. + * + * @param cfg The reference to the RTC connection configuration: \ref agora::rtc::RtcConnectionConfiguration "RtcConnectionConfiguration". + * @return + * - The pointer to \ref rtc::IRtcConnection "IRtcConnection": Success. + * - A null pointer: Failure. + */ + virtual agora_refptr createRtcConnection( + const rtc::RtcConnectionConfiguration& cfg) = 0; + + virtual agora_refptr createRtmpConnection( + const rtc::RtmpConnectionConfiguration& cfg) = 0; + + /** + * Creates a local audio track object and returns the pointer. + * + * By default, the audio track is created from the selected audio input device, such as + * the built-in microphone on a mobile device. + * + * @return + * - The pointer to \ref rtc::ILocalAudioTrack "ILocalAudioTrack": Success. + * - A null pointer: Failure. + * - `INVALID_STATE`, if `enableAudioProcessor` in \ref agora::base::AgoraServiceConfiguration "AgoraServiceConfiguration" is set as `false`. + */ + virtual agora_refptr createLocalAudioTrack() = 0; + + /** + * Creates a local audio track object with a PCM data sender and returns the pointer. + * + * Once created, this track can be used to send PCM audio data. + * + * @param audioSource The pointer to the PCM audio data sender: \ref agora::rtc::IAudioPcmDataSender "IAudioPcmDataSender". + * @return + * - The pointer to \ref rtc::ILocalAudioTrack "ILocalAudioTrack": Success. + * - A null pointer: Failure. + * - `INVALID_STATE`, if `enableAudioProcessor` in \ref agora::base::AgoraServiceConfiguration "AgoraServiceConfiguration" is set as `false`. + */ + virtual agora_refptr createCustomAudioTrack( + agora_refptr audioSource) = 0; + + /** + * Creates a local audio track object with a PCM data sender and returns the pointer. + * The source is not intended to be mixed with other source. + * + * Once created, this track can be used to send PCM audio data. + * + * @param audioSource The pointer to the PCM audio data sender: \ref agora::rtc::IAudioPcmDataSender "IAudioPcmDataSender". + * @return + * - The pointer to \ref rtc::ILocalAudioTrack "ILocalAudioTrack": Success. + * - A null pointer: Failure. + * - `INVALID_STATE`, if `enableAudioProcessor` in \ref agora::base::AgoraServiceConfiguration "AgoraServiceConfiguration" is set as `false`. + */ + virtual agora_refptr createDirectCustomAudioTrack( + agora_refptr audioSource) = 0; + + /** + * Creates a local audio track object with a PCM data sender and returns the pointer. + * + * Once created, this track can be used to send PCM audio data. + * + * @param audioSource The pointer to the PCM audio data sender: \ref agora::rtc::IAudioPcmDataSender "IAudioPcmDataSender". + * @param enableAec Whether enable audio echo cancellation for PCM audio data. + * @return + * - The pointer to \ref rtc::ILocalAudioTrack "ILocalAudioTrack": Success. + * - A null pointer: Failure. + * - `INVALID_STATE`, if `enableAudioProcessor` in \ref agora::base::AgoraServiceConfiguration "AgoraServiceConfiguration" is set as `false`. + */ + virtual agora_refptr createCustomAudioTrack( + agora_refptr audioSource, bool enableAec) = 0; + + /** + * Creates a local audio track object with two PCM data sender and returns the pointer. + * + * Once created, this track can be used to send PCM audio data with echo cancellation. + * + * @param audioSource The pointer to the recording PCM audio data sender: \ref agora::rtc::IAudioPcmDataSender "IAudioPcmDataSender". + * @param audioReverseSource The pointer to the playout PCM audio data sender: \ref agora::rtc::IAudioPcmDataSender "IAudioPcmDataSender". + * @param audioSourceDelay The delay of recording pcm data when do echo cancellation. + * @return + * - The pointer to \ref rtc::ILocalAudioTrack "ILocalAudioTrack": Success. + * - A null pointer: Failure. + * - `INVALID_STATE`, if `enableAudioProcessor` in \ref agora::base::AgoraServiceConfiguration "AgoraServiceConfiguration" is set as `false`. + */ + virtual agora_refptr createCustomAudioTrack(agora_refptr audioSource, + agora_refptr audioReverseSource, + int audioSourceDelay) = 0; + + /** + * Creates a local audio track object with a audio mixer source and returns the pointer. + * + * Once created, this track can be used to send PCM audio data. + * + * @param audioSource The pointer to the audio mixer source : \ref agora::rtc::IRemoteAudioMixerSource "IRemoteAudioMixerSource". + * @return + * - The pointer to \ref rtc::ILocalAudioTrack "ILocalAudioTrack", if the method call succeeds. + * - A null pointer, if the method call fails. + * - `INVALID_STATE`, if `enableAudioProcessor` in `AgoraServiceConfiguration` is set as `false`. + */ + virtual agora_refptr createCustomAudioTrack( + agora_refptr audioSource) = 0; + + /** + * Creates a local audio track object with an encoded audio frame sender and returns the pointer. + * + * Once created, this track can be used to send encoded audio frames, such as Opus frames. + * + * @param audioSource The pointer to the encoded audio frame sender: \ref agora::rtc::IAudioEncodedFrameSender "IAudioEncoderFrameSender". + * @param mixMode The mixing mode of the encoded audio in the channel: #TMixMode. + * @return + * - The pointer to \ref rtc::ILocalAudioTrack "ILocalAudioTrack": Success. + * - A null pointer: Failure. + * - `INVALID_STATE`, if `enableAudioProcessor` is set as `false` in \ref agora::base::AgoraServiceConfiguration "AgoraServiceConfiguration". + */ + virtual agora_refptr createCustomAudioTrack( + agora_refptr audioSource, TMixMode mixMode) = 0; +/// @cond (!Linux) + /** + * Creates a local audio track object with a media packet sender and returns the pointer. + * + * Once created, this track can be used to send audio packets, such as customized UDP/RTP packets. + * + * @param source The pointer to the media packet sender: \ref agora::rtc::IMediaPacketSender "IMediaPacketSender". + * @return + * - The pointer to \ref rtc::ILocalAudioTrack "ILocalAudioTrack": Success. + * - A null pointer: Failure. + * - `INVALID_STATE`, if `enableAudioProcessor` is set as `false` in \ref agora::base::AgoraServiceConfiguration "AgoraServiceConfiguration". + */ + virtual agora_refptr createCustomAudioTrack( + agora_refptr source) = 0; + /// @endcond + /** + * Creates a local audio track object with an IMediaPlayerSource object and returns the pointer. + * + * Once created, this track can be used to send PCM audio data decoded from a media player. + * + * @param audioSource The pointer to the player source. See \ref agora::rtc::IMediaPlayerSource "IMediaPlayerSource". + * @return + * - The pointer to \ref rtc::ILocalAudioTrack "ILocalAudioTrack": Success. + * - A null pointer: Failure. + * - `INVALID_STATE`, if `enableAudioProcessor` is set as `false` in \ref agora::base::AgoraServiceConfiguration "AgoraServiceConfiguration". + */ + virtual agora_refptr createMediaPlayerAudioTrack( + agora_refptr audioSource) = 0; + + /** + * Creates a local audio track object with an IMediaStreamingSource object and returns the pointer. + * + * Once created, this track can be used to send encoded audio data which demuxed from a media streaming. + * + * @param streamingSource The pointer to the streaming source. See \ref agora::rtc::IMediaStreamingSource "IMediaStreamingSource". + * @return + * - The pointer to \ref rtc::ILocalAudioTrack "ILocalAudioTrack": Success. + * - A null pointer: Failure. + * - `INVALID_STATE`, if `enableAudioProcessor` is set as `false` in \ref agora::base::AgoraServiceConfiguration "AgoraServiceConfiguration". + */ + virtual agora_refptr createMediaStreamingAudioTrack( + agora_refptr streamingSource) = 0; + + /** + * Creates a local audio track object with the recording device source and returns the pointer. + * + * Once created, this track can be used to send audio data got from a recording device. + * @param audioSource The pointer to the recording device source. See \ref agora::rtc::IRecordingDeviceSource "IRecordingDeviceSource". + * @param enableAec Whether enable audio echo cancellation for loopback recording. If loopback + * recording device is a virtual sound card, it should be false, or it should be true. + * @return + * - The pointer to \ref rtc::ILocalAudioTrack "ILocalAudioTrack": Success. + * - A null pointer: Failure. + */ + virtual agora_refptr createRecordingDeviceAudioTrack( + agora_refptr audioSource, bool enableAec) = 0; + + /** + * Creates an audio device manager object and returns the pointer. + * + * @return + * - The pointer to \ref rtc::INGAudioDeviceManager "INGAudioDeviceManager": Success. + * - A null pointer: Failure. + */ + virtual agora_refptr createAudioDeviceManager() = 0; + + /** + * Creates a media node factory object and returns the pointer. + * + * @return + * - The pointer to \ref rtc::IMediaNodeFactory "IMediaNodeFactory": Success. + * - A null pointer: Failure. + */ + virtual agora_refptr createMediaNodeFactory() = 0; + + /** + * Creates a local video track object with a camera capturer and returns the pointer. + * + * Once created, this track can be used to send video data captured by the camera. + * + * @param videoSource The pointer to the camera capturer: \ref agora::rtc::ICameraCapturer "ICameraCapturer". + * + * @return + * - The pointer to \ref rtc::ILocalVideoTrack "ILocalVideoTrack": Success. + * - A null pointer: Failure. + */ + virtual agora_refptr createCameraVideoTrack( + agora_refptr videoSource, const char* id = OPTIONAL_NULLPTR) = 0; + + /** + * Creates a local video track object with a screen capturer and returns the pointer. + * + * Once created, this track can be used to send video data for screen sharing. + * + * @param videoSource The pointer to the screen capturer: \ref agora::rtc::IScreenCapturer "IScreenCapturer". + * @return + * - The pointer to \ref rtc::ILocalVideoTrack "ILocalVideoTrack": Success. + * - A null pointer: Failure. + */ + virtual agora_refptr createScreenVideoTrack( + agora_refptr videoSource, const char* id = OPTIONAL_NULLPTR) = 0; + + /** + * Creates a local video track object with a video mixer and returns the pointer. + * + * Once created, this track can be used to send video data processed by the video mixer. + * + * @param videoSource The pointer to the video mixer. See \ref agora::rtc::IVideoMixerSource "IVideoMixerSource". + * + * @return + * - The pointer to \ref rtc::ILocalVideoTrack "ILocalVideoTrack": Success. + * - A null pointer: Failure. + */ + virtual agora_refptr createMixedVideoTrack(agora_refptr videoSource, + const char* id = OPTIONAL_NULLPTR) = 0; + + /** + * Creates a local video track object with a video frame transceiver and returns the pointer. + * + * Once created, this track can be used to send video data processed by the transceiver. + * + * @param transceiver The pointer to the video transceiver. See \ref agora::rtc::IVideoFrameTransceiver "IVideoFrameTransceiver". + * + * @return + * - The pointer to \ref rtc::ILocalVideoTrack "ILocalVideoTrack": Success. + * - A null pointer: Failure. + */ + virtual agora_refptr createTranscodedVideoTrack(agora_refptr transceiver, + const char* id = OPTIONAL_NULLPTR) = 0; + +/// @cond (!RTSA) + /** + * Creates a local video track object with a customized video source and returns the pointer. + * + * Once created, this track can be used to send video data from a customized source. + * + * @param videoSource The pointer to the customized video frame sender: \ref agora::rtc::IVideoFrameSender "IVideoFrameSender". + * @return + * - The pointer to \ref rtc::ILocalVideoTrack "ILocalVideoTrack": Success. + * - A null pointer: Failure. + */ + virtual agora_refptr createCustomVideoTrack( + agora_refptr videoSource, const char* id = OPTIONAL_NULLPTR) = 0; +/// @endcond + + /** + * Creates a local video track object with an encoded video image sender and returns the pointer. + * + * Once created, this track can be used to send encoded video images, such as H.264 or VP8 frames. + * + * @param videoSource The pointer to the encoded video frame sender. See \ref agora::rtc::IVideoEncodedImageSender "IVideoEncodedImageSender". + * @param options The configuration for creating video encoded image track. + * + * @return + * - The pointer to \ref rtc::ILocalVideoTrack "ILocalVideoTrack": Success. + * - A null pointer: Failure. + */ + virtual agora_refptr createCustomVideoTrack( + agora_refptr videoSource, + const rtc::SenderOptions& options, + const char* id = OPTIONAL_NULLPTR) = 0; + +#if defined(__ANDROID__) || (defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE) + /** + * Creates a local video track object with a screen capture source extension and returns the pointer. + * + * Once created, this track can be used to work with the screen capture extension. + * + * @param screen The pointer to the screen capture source. + * + * @return + * - The pointer to \ref rtc::ILocalVideoTrack "ILocalVideoTrack": Success. + * - A null pointer: Failure. + */ + virtual agora_refptr createScreenCaptureVideoTrack( + agora_refptr screen) = 0; + +/** + * Creates a local audio track object with a screen capture source extension and returns the pointer. + * + * Once created, this track can be used to work with the screen capture extension. + * + * @param screen The pointer to the screen capture source. + * + * @return + * - The pointer to \ref rtc::ILocalAudioTrack "ILocalAudioTrack": Success. + * - A null pointer: Failure. + */ + virtual agora_refptr createScreenCaptureAudioTrack( + agora_refptr screen) = 0; +#else + /** + * Creates a local video track object with a screen capture source extension and returns the pointer. + * + * Once created, this track can be used to work with the screen capture extension. + * + * @param screen The pointer to the screen capture source. + * + * @return + * - The pointer to \ref rtc::ILocalVideoTrack "ILocalVideoTrack": Success. + * - A null pointer: Failure. + */ + virtual agora_refptr createScreenCaptureVideoTrack( + agora_refptr screen, const char* id = OPTIONAL_NULLPTR) = 0; +#endif + +/// @cond (!Linux) + /** + * Creates a local video track object with a media packet sender and returns the pointer. + * + * Once created, this track can be used to send video packets, such as customized UDP/RTP packets. + * + * @param source The pointer to the media packet sender: \ref agora::rtc::IMediaPacketSender "IMediaPacketSender". + * @return + * - The pointer to \ref rtc::ILocalVideoTrack "ILocalVideoTrack": Success. + * - A null pointer: Failure. + */ + virtual agora_refptr createCustomVideoTrack( + agora_refptr source, const char* id = OPTIONAL_NULLPTR) = 0; +/// @endcond + /** + * Creates a local video track object with an IMediaPlayerSource object and returns the pointer. + * + * Once created, this track can be used to send YUV frames decoded from a player. + * + * @param videoSource The pointer to the player source. See \ref agora::rtc::IMediaPlayerSource "IMediaPlayerSource". + * @return + * - The pointer to \ref rtc::ILocalAudioTrack "ILocalAudioTrack": Success. + * - A null pointer: Failure. + */ + virtual agora_refptr createMediaPlayerVideoTrack( + agora_refptr videoSource, const char* id = OPTIONAL_NULLPTR) = 0; + + /** + * Creates a local video track object with an IMediaStreamingSource object and returns the pointer. + * + * Once created, this track can be used to send H264 frames which demuxed from a streaming. + * + * @param streamingSource The pointer to the player source. See \ref agora::rtc::IMediaStreamingSource "IMediaStreamingSource". + * @return + * - The pointer to \ref rtc::ILocalAudioTrack "ILocalAudioTrack": Success. + * - A null pointer: Failure. + */ + virtual agora_refptr createMediaStreamingVideoTrack( + agora_refptr streamingSource, const char* id = OPTIONAL_NULLPTR) = 0; + + + /** + * Creates an RTMP streaming service object and returns the pointer. + * + * @param rtcConnection The pointer to \ref rtc::IRtcConnection "IRtcConnection". + * @param appId The App ID of the live streaming service. + * @return + * - The pointer to \ref rtc::IRtmpStreamingService "IRtmpStreamingService": Success. + * - A null pointer: Failure. + */ + virtual agora_refptr createRtmpStreamingService( + agora_refptr rtcConnection, const char* appId) = 0; + + /** + * Creates an Media Relay service object and returns the pointer. + * + * @param rtcConnection The pointer to \ref rtc::IRtcConnection "IRtcConnection". + * @param appId The App ID of the media relay service. + * @return + * - The pointer to \ref rtc::IMediaRelayService "IMediaRelayService", if the method call + * succeeds. + * - A null pointer, if the method call fails. + */ + virtual agora_refptr createMediaRelayService( + agora_refptr rtcConnection, const char* appId) = 0; + + /** + * Creates an file upload object and returns the pointer. + * + * @param rtcConnection The pointer to \ref rtc::IRtcConnection "IRtcConnection". + * @param appId The App ID of the media relay service. + * @return + * - The pointer to \ref rtc::IFileUploaderService "IFileUploaderService", if the method call + * succeeds. + * - A null pointer, if the method call fails. + */ + virtual agora_refptr createFileUploadService( + agora_refptr rtcConnection, const char* appId) = 0; + + /** + * Creates an RTM servive object and returns the pointer. + * + * @return + * - The pointer to \ref rtm::IRtmService "IRtmService": Success. + * - A null pointer: Failure. + */ + virtual rtm::IRtmService* createRtmService() = 0; + + virtual int addExtensionObserver(agora::agora_refptr observer) = 0; + + virtual int removeExtensionObserver(agora::agora_refptr observer) = 0; + + /** + * Creates an audio device manager and returns the pointer. + * + * @return + * - The pointer to \ref rtc::IAudioDeviceManager "IAudioDeviceManager": Success. + * - A null pointer: Failure. + */ + virtual agora_refptr createAudioDeviceManagerComponent( + rtc::IAudioDeviceManagerObserver *observer) = 0; + + /** + * Creates an data channel and returns the pointer. + * + * @return + * - The pointer to \ref rtc::ILocalDataChannel "ILocalDataChannel": Success. + * - A null pointer: Failure. + */ + virtual agora_refptr createLocalDataChannel(const DataChannelConfig& config) = 0; + + /** + * @brief Get the ID of the registered extension + * + * @param provider_name The pointer to provider name string (null-terminated) + * @param extension_name The pointer to extension name string (null-terminated) + * @return + * - Pointer to the extension id string (null-terminated). The pointer will be valid during service's lifetime + */ + virtual const char* getExtensionId(const char* provider_name, const char* extension_name) = 0; + +#if defined (_WIN32) || defined(__linux__) || defined(__ANDROID__) + /** + * @brief load the dynamic library of the extension + * + * @param path path of the extension library + * @param unload_after_use unload the library when engine release + * @return int + */ + virtual int loadExtensionProvider(const char* path, bool unload_after_use = false) = 0; +#endif + /** + * Enable extension. + * If the extension is enabled, the track loads the extension automatically. + * + * @param provider_name name for provider, e.g. agora.io. + * @param extension_name name for extension, e.g. agora.beauty. + * @param track_id id for the track, OPTIONAL_NULLPTR means effective on all tracks + * @param auto_enable_on_track if the extension is automatically open on track. + * + * @return + * - 0: Success. + * - < 0: Failure. + */ + virtual int enableExtension( + const char* provider_name, const char* extension_name, const char* track_id = NULL, + bool auto_enable_on_track = false) = 0; + /** + * Disable extension. + * + * @param provider_name name for provider, e.g. agora.io. + * @param extension_name name for extension, e.g. agora.beauty. + * @param track_id id for the track, OPTIONAL_NULLPTR means effective on all tracks + * + * @return + * - 0: Success. + * - < 0: Failure. + */ + virtual int disableExtension( + const char* provider_name, const char* extension_name, const char* track_id = NULL) = 0; + + protected: + virtual ~IAgoraService() {} +}; + +} // namespace base +} // namespace agora + +/** \addtogroup createAgoraService + @{ + */ +/** + * Creates an \ref agora::base::IAgoraService "IAgoraService" object and returns the pointer. + * + * @return + * - The pointer to \ref agora::base::IAgoraService "IAgoraService": Success. + * - A null pointer: Failure. + */ +AGORA_API agora::base::IAgoraService* AGORA_CALL createAgoraService(); +/** @} */ diff --git a/headers/rtm_2.1.10/include/IAgoraStreamChannel.h b/headers/rtm_2.1.10/include/IAgoraStreamChannel.h new file mode 100644 index 0000000..8c3b9e7 --- /dev/null +++ b/headers/rtm_2.1.10/include/IAgoraStreamChannel.h @@ -0,0 +1,242 @@ +// Copyright (c) 2022 Agora.io. All rights reserved + +// This program is confidential and proprietary to Agora.io. +// And may not be copied, reproduced, modified, disclosed to others, published +// or used, in whole or in part, without the express prior written permission +// of Agora.io. + +#pragma once // NOLINT(build/header_guard) + +#include "AgoraRtmBase.h" + +namespace agora { +namespace rtm { +/** + * The qos of rtm message. + */ +enum RTM_MESSAGE_QOS { + /** + * Will not ensure that messages arrive in order. + */ + RTM_MESSAGE_QOS_UNORDERED = 0, + /** + * Will ensure that messages arrive in order. + */ + RTM_MESSAGE_QOS_ORDERED = 1, +}; + +/** + * The priority of rtm message. + */ +enum RTM_MESSAGE_PRIORITY { + /** + * The highest priority + */ + RTM_MESSAGE_PRIORITY_HIGHEST = 0, + /** + * The high priority + */ + RTM_MESSAGE_PRIORITY_HIGH = 1, + /** + * The normal priority (Default) + */ + RTM_MESSAGE_PRIORITY_NORMAL = 4, + /** + * The low priority + */ + RTM_MESSAGE_PRIORITY_LOW = 8, +}; + +/** + * Join channel options. + */ +struct JoinChannelOptions { + /** + * Token used to join channel. + */ + const char* token; + /** + * Whether to subscribe channel metadata information + */ + bool withMetadata; + /** + * Whether to subscribe channel with user presence + */ + bool withPresence; + /** + * Whether to subscribe channel with lock + */ + bool withLock; + + JoinChannelOptions() : token(NULL), withMetadata(false), withPresence(true), withLock(false) {} +}; + +/** + * Join topic options. + */ +struct JoinTopicOptions { + /** + * The qos of rtm message. + */ + RTM_MESSAGE_QOS qos; + + /** + * The priority of rtm message. + */ + RTM_MESSAGE_PRIORITY priority; + + /** + * The metaData of topic. + */ + const char* meta; + + /** + * The rtm data will sync with media + */ + bool syncWithMedia; + + JoinTopicOptions() : qos(RTM_MESSAGE_QOS_UNORDERED), + priority(RTM_MESSAGE_PRIORITY_NORMAL), + meta(NULL) {} +}; + +/** + * Topic options. + */ +struct TopicOptions { + /** + * The list of users to subscribe. + */ + const char** users; + /** + * The number of users. + */ + size_t userCount; + + TopicOptions() : users(NULL), userCount(0) {} +}; + +/** + * The IStreamChannel class. + * + * This class provides the stream channel methods that can be invoked by your app. + */ +class IStreamChannel { + public: + /** + * Join the channel. + * + * @param [in] options join channel options. + * @return + * - 0: Success. + * - < 0: Failure. + */ + virtual int join(const JoinChannelOptions& options, uint64_t& requestId) = 0; + + /** + * Renews the token. Once a token is enabled and used, it expires after a certain period of time. + * You should generate a new token on your server, call this method to renew it. + * + * @param [in] token Token used renew. + * - 0: Success. + * - < 0: Failure. + */ + virtual int renewToken(const char* token) = 0; + + /** + * Leave the channel. + * + * @return + * - 0: Success. + * - < 0: Failure. + */ + virtual int leave(uint64_t& requestId) = 0; + + /** + * Return the channel name of this stream channel. + * + * @return The channel name. + */ + virtual const char* getChannelName() = 0; + + /** + * Join a topic. + * + * @param [in] topic The name of the topic. + * @param [in] options The options of the topic. + * @return + * - 0: Success. + * - < 0: Failure. + */ + virtual int joinTopic(const char* topic, const JoinTopicOptions& options, uint64_t& requestId) = 0; + + /** + * Publish a message in the topic. + * + * @param [in] topic The name of the topic. + * @param [in] message The content of the message. + * @param [in] length The length of the message. + * @param [in] option The option of the message. + * @return + * - 0: Success. + * - < 0: Failure. + */ + virtual int publishTopicMessage(const char* topic, const char* message, size_t length, const TopicMessageOptions& option) = 0; + + /** + * Leave the topic. + * + * @param [in] topic The name of the topic. + * @return + * - 0: Success. + * - < 0: Failure. + */ + virtual int leaveTopic(const char* topic, uint64_t& requestId) = 0; + + /** + * Subscribe a topic. + * + * @param [in] topic The name of the topic. + * @param [in] options The options of subscribe the topic. + * @return + * - 0: Success. + * - < 0: Failure. + */ + virtual int subscribeTopic(const char* topic, const TopicOptions& options, uint64_t& requestId) = 0; + + /** + * Unsubscribe a topic. + * + * @param [in] topic The name of the topic. + * @return + * - 0: Success. + * - < 0: Failure. + */ + virtual int unsubscribeTopic(const char* topic, const TopicOptions& options) = 0; + + /** + * Get subscribed user list + * + * @param [in] topic The name of the topic. + * @param [out] users The list of subscribed users. + * @return + * - 0: Success. + * - < 0: Failure. + */ + virtual int getSubscribedUserList(const char* topic, UserList* users) = 0; + + /** + * Release the stream channel instance. + * + * @return + * - 0: Success. + * - < 0: Failure. + */ + virtual int release() = 0; + + protected: + virtual ~IStreamChannel() {} +}; + +} // namespace rtm +} // namespace agora diff --git a/headers/rtm_2.1.10/shared_configs.yaml b/headers/rtm_2.1.10/shared_configs.yaml new file mode 100644 index 0000000..dcaf647 --- /dev/null +++ b/headers/rtm_2.1.10/shared_configs.yaml @@ -0,0 +1,19 @@ +include_header_dirs: + - include + - ../system + - /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include + +visit_headers: + - include/AgoraRtmBase.h + - include/IAgoraRtmClient.h + - include/IAgoraRtmLock.h + - include/IAgoraRtmPresence.h + - include/IAgoraRtmService.h + - include/IAgoraRtmStorage.h + # - include/IAgoraService.h + - include/IAgoraStreamChannel.h + +custom_headers: + - custom_headers/CustomIAgoraRtmClient.h + - custom_headers/CustomIAgoraStreamChannel.h + - custom_headers/CustomIAgoraRtmStorage.h \ No newline at end of file