Agora RTC Objective-C API Reference Refactor

AgoraMetachatKit.h
Go to the documentation of this file.
1 //
2 // AgoraMetachatKit.h
3 // AgoraRtcKit
4 //
5 // Created by dingyusong on 12/4/22.
6 // Copyright (c) 2022 Agora. All rights reserved.
7 //
8
9 #ifndef AgoraMetachatKit_h
10 #define AgoraMetachatKit_h
11
12 #import <Foundation/Foundation.h>
13 #import "AgoraRtcEngineKit.h"
14 #import "AgoraMetaViewProtocol.h"
15
16
19 typedef NS_ENUM(NSUInteger, AgoraMetachatConnectionStateType){
20 /* The SDK is disconnected from the state metachat server. */
21 AgoraMetachatConnectionStateTypeDisconnected = 1,
22 /* The SDK is connecting to the state metachat server. */
23 AgoraMetachatConnectionStateTypeConnecting,
24 /* The SDK is connected to the state metachat server. */
25 AgoraMetachatConnectionStateTypeConnected,
26 /* The SDK is reconnecting to the state metachat server. */
27 AgoraMetachatConnectionStateTypeReconnecting,
28 /* The SDK is reconnected to the state metachat server. */
29 AgoraMetachatConnectionStateTypeAborted
30 };
31
34 typedef NS_ENUM(NSUInteger, AgoraMetachatConnectionChangedReasonType) {
35 /* The connection state is changed. */
36 AgoraMetachatConnectionChangedReasonTypeDefault = 0,
37 };
38
39 typedef NS_ENUM(NSUInteger, AgoraMetachatDownloadStateType) {
40 AgoraMetachatDownloadStateTypeIdle = 0,
41 AgoraMetachatDownloadStateTypeDownloading = 1,
42 AgoraMetachatDownloadStateTypeDownloaded = 2,
43 AgoraMetachatDownloadStateTypeFailed = 3,
44 };
45
46 typedef NS_ENUM(NSUInteger, AgoraMetachatErrorType) {
47 AgoraMetachatErrorTypeOK = 0,
48 AgoraMetachatErrorTypeEngineLoadFailed,
49 AgoraMetachatErrorTypeSceneLoadFailed,
50 AgoraMetachatErrorTypeJoinRoomFailed,
51 AgoraMetachatErrorTypeSceneUnloadFailed,
52 };
53
54 typedef NS_ENUM(NSUInteger, AgoraMetachatVenderType) {
55 AgoraMetachatVenderTypeUnity = 0,
56 };
57
58 typedef NS_ENUM(NSUInteger, AgoraMetachatBundleType) {
59 AgoraMetachatBundleTypeScene = 1,
60 AgoraMetachatBundleTypeAvatar = 2,
61 AgoraMetachatBundleTypeAssetManifest = 3,
62 AgoraMetachatBundleTypeOther = 100,
63 };
64
65 // metachat bundle model information bound to metachat scene information
66 __attribute__((visibility("default"))) @interface AgoraMetachatBundleInfo : NSObject
67 @property (nonatomic, assign) NSInteger bundleId;
68 @property (nonatomic, assign) NSInteger sceneId;
69 @property (nonatomic, assign) AgoraMetachatBundleType bundleType;
70 @property (nonatomic, copy) NSString * _Nonnull bundleCode;
71 @property (nonatomic, copy) NSString * _Nonnull bundleName;
72 @property (nonatomic, copy) NSString * _Nonnull desc;
73 // local path of bundle model path
74 @property (nonatomic, copy) NSString * _Nonnull bundlePath;
75 // local path of bundle thumbnail
76 @property (nonatomic, copy) NSString * _Nonnull thumbnailPath;
77 @property (nonatomic, copy) NSString * _Nonnull assets;
78 @property (nonatomic, copy) NSString * _Nullable extraInfo;
79 @property (nonatomic, assign) NSInteger bundleSize;
80 @end
81
82 // metachat scene information retrieved by getScenes interface
83 __attribute__((visibility("default"))) @interface AgoraMetachatSceneInfo : NSObject
84 @property (nonatomic, assign) NSInteger sceneId;
85 @property (nonatomic, copy) NSString * _Nonnull sceneName;
86 // local path of scene thumbnail
87 @property (nonatomic, copy) NSString * _Nonnull thumbnailPath;
88 @property (nonatomic, copy) NSString * _Nonnull scenePath;
89 @property (nonatomic, copy) NSString * _Nonnull parentScenePath;
90 @property (nonatomic, copy) NSString * _Nonnull desc;
91 @property (nonatomic, copy) NSString * _Nonnull sceneConfig;
92 @property (nonatomic, copy) NSString * _Nullable extraInfo;
93 @property (nonatomic, copy) NSString * _Nonnull sceneVersion;
94 @property (nonatomic, copy) NSString * _Nonnull sceneLocalVersion;
95 @property (nonatomic, assign) NSInteger totalSize;
96 // avatar information bound to scene
97 @property (nonatomic, strong) NSArray<AgoraMetachatBundleInfo *> * _Nonnull bundles;
98 @end
99
100 __attribute__((visibility("default"))) @interface AgoraMetachatUserInfo : NSObject
101 @property (nonatomic, copy) NSString * _Nonnull userId;
102 @property (nonatomic, copy) NSString * _Nonnull userName;
103 @property (nonatomic, copy) NSString * _Nonnull userIconUrl;
104 @property (nonatomic, strong) NSData * _Nullable extraCustomInfo;
105 @end
106
107 __attribute__((visibility("default"))) @interface AgoraMetachatPositionInfo : NSObject
108 @property (nonatomic, copy) NSArray * _Nonnull position;
109 @property (nonatomic, copy) NSArray * _Nonnull forward;
110 @property (nonatomic, copy) NSArray * _Nonnull right;
111 @property (nonatomic, copy) NSArray * _Nonnull up;
112 @end
113
114 @class AgoraMetachatKit;
115 @class AgoraMetachatScene;
116 @protocol AgoraMetachatEventDelegate <NSObject>
117 - (void)onCreateSceneResult:(AgoraMetachatScene *_Nullable)scene errorCode:(NSInteger)errorCode;
118 - (void)onConnectionStateChanged:(AgoraMetachatConnectionStateType)state reason:(AgoraMetachatConnectionChangedReasonType)reason;
119 - (void)onRequestToken;
120 - (void)onGetSceneInfosResult:(NSMutableArray * _Nonnull)sceneInfos errorCode:(NSInteger)errorCode;
121 - (void)onDownloadSceneProgress:(NSInteger)sceneId progress:(NSInteger)progress state:(AgoraMetachatDownloadStateType)state;
122 @end
123
124 @protocol AgoraMetachatSceneEventDelegate<NSObject>
125 - (void)metachatScene:(AgoraMetachatScene *_Nonnull)scene onReleasedScene:(NSInteger)errorCode;
126 - (void)metachatScene:(AgoraMetachatScene *_Nonnull)scene onEnterSceneResult:(NSInteger)errorCode;
127 - (void)metachatScene:(AgoraMetachatScene *_Nonnull)scene onLeaveSceneResult:(NSInteger)errorCode;
128 - (void)metachatScene:(AgoraMetachatScene *_Nonnull)scene onRecvMessageFromScene:(NSData * _Nonnull)message;
129 - (void)metachatScene:(AgoraMetachatScene *_Nonnull)scene onUserPositionChanged:(NSString * _Nonnull)uid posInfo:(AgoraMetachatPositionInfo * _Nonnull)posInfo;
130 - (void)metachatScene:(AgoraMetachatScene *_Nonnull)scene onEnumerateVideoDisplaysResult:(NSMutableArray * _Nonnull)displayIds;
131 @end
132
133 __attribute__((visibility("default"))) @interface AgoraMetachatAvatarModelInfo : NSObject
134 @property (nonatomic, copy) NSString * _Nonnull bundleCode;
135 @property (nonatomic,assign) BOOL localVisible;
136 @property (nonatomic,assign) BOOL remoteVisible;
137 @property (nonatomic,assign) BOOL syncPosition;
138 @property (nonatomic, strong) NSData * _Nullable extraCustomInfo;
139 @end
140
141 __attribute__((visibility("default"))) @interface AgoraMetachatDressInfo : NSObject
142 @property (nonatomic, strong) NSData * _Nullable extraCustomInfo;
143 @end
144
145 __attribute__((visibility("default"))) @interface AgoraMetachatFaceInfo : NSObject
146 @property (nonatomic, strong) NSData * _Nullable extraCustomInfo;
147 @end
148
149 __attribute__((visibility("default"))) @interface AgoraMetachatConfig : NSObject
150 @property (nonatomic, copy) NSString * _Nonnull appId;
151 @property (nonatomic, copy) NSString * _Nonnull rtmToken;
152 @property (nonatomic, copy) NSString * _Nonnull userId;
153 @property (nonatomic, weak) id<AgoraMetachatEventDelegate> _Nullable delegate;
154 @property (nonatomic, copy) NSString * _Nonnull localDownloadPath;
155 @property (nonatomic, assign) AgoraRtcEngineKit* _Nullable rtcEngine;
156 @end
157
158 __attribute__((visibility("default"))) @interface AgoraMetachatSceneConfig : NSObject
159 @property (nonatomic, weak) id<AgoraMetachatSceneEventDelegate> _Nullable delegate;
160 @end
161
162 __attribute__((visibility("default"))) @interface AgoraMetachatEnterSceneConfig : NSObject
163 @property (nonatomic, copy) NSString * _Nonnull roomName;
164 #if (!(TARGET_OS_IPHONE) && (TARGET_OS_MAC))
165 @property (nonatomic, strong) NSView * _Nonnull sceneView;
166 #else
167 @property (nonatomic, strong) UIView * _Nonnull sceneView;
168 #endif
169 @property (nonatomic, assign) NSInteger sceneId;
170 @property (nonatomic, strong) NSData * _Nullable extraCustomInfo;
171 @end
172
173 __attribute__((visibility("default"))) @interface AgoraMetachatLocalUserAvatar : NSObject
174 - (NSInteger)setUserInfo:(AgoraMetachatUserInfo *_Nullable)userInfo;
175 - (AgoraMetachatUserInfo *_Nullable)getUserInfo;
176 - (NSInteger)setModelInfo:(AgoraMetachatAvatarModelInfo *_Nullable)modelInfo;
177 - (AgoraMetachatAvatarModelInfo *_Nullable)getModelInfo;
178 - (NSInteger)setDressInfo:(AgoraMetachatDressInfo *_Nullable)dressInfo;
179 - (AgoraMetachatDressInfo *_Nullable)getDressInfo;
180 - (NSInteger)setFaceInfo:(AgoraMetachatFaceInfo *_Nullable)faceInfo;
181 - (AgoraMetachatFaceInfo *_Nullable)getFaceInfo;
182 - (NSInteger)setExtraCustomInfo:(NSData *_Nullable)customInfo;
183 - (NSData *_Nullable)getExtraCustomInfo;
184 - (NSInteger)applyInfo;
185 @end
186
187 __attribute__((visibility("default"))) @interface AgoraMetachatScene : NSObject
188 - (NSInteger)destroy;
189 - (AgoraMetachatLocalUserAvatar *_Nullable)getLocalUserAvatar;
190 #if (!(TARGET_OS_IPHONE) && (TARGET_OS_MAC))
191 - (NSView<AgoraMetaViewProtocol> *_Nullable)createRenderView:(AgoraMetachatVenderType)venderType region:(CGRect)region;
192 #else
193 - (UIView<AgoraMetaViewProtocol> *_Nullable)createRenderView:(AgoraMetachatVenderType)venderType region:(CGRect)region;
194 #endif
195 - (NSInteger)enterScene:(AgoraMetachatEnterSceneConfig *_Nonnull)config;
196 - (NSInteger)leaveScene;
197
198 - (NSInteger)sendMessageToScene:(NSData *_Nonnull)message;
199 - (NSInteger)setSceneParameters:(NSString *_Nonnull)jsonParam;
200 - (NSInteger)enableUserPositionNotification:(BOOL)enable;
201 - (NSInteger)enumerateVideoDisplays;
202 - (NSInteger)enableVideoDisplay:(NSString *_Nonnull)displayId enable:(BOOL)enable;
203 - (NSInteger)pushVideoFrameToDisplay:(NSString *_Nonnull)displayId frame:(AgoraVideoFrame *_Nullable)frame;
204
205 - (void)enableMainQueueDispatch:(BOOL)enabled NS_SWIFT_NAME(enableMainQueueDispatch(_:));
206 @end
207
208 __attribute__((visibility("default"))) @interface AgoraMetachatKit : NSObject
209 + (instancetype _Nonnull)sharedMetachatWithConfig:(AgoraMetachatConfig* _Nonnull)config NS_SWIFT_NAME(sharedMetachatWithConfig(_:));
210 + (void)destroy NS_SWIFT_NAME(destroy());
211
212 - (NSInteger)renewToken:(NSString *_Nonnull)token;
213
214 - (NSString *_Nullable)getLauncherVersion;
215 - (NSInteger)getSceneInfos;
216 - (NSInteger)isSceneDownloaded:(NSInteger)sceneId;
217 - (NSInteger)downloadScene:(NSInteger)sceneId;
218 - (NSInteger)cancelDownloadScene:(NSInteger)sceneId;
219 - (NSInteger)cleanScene:(NSInteger)sceneId;
220
221 - (NSInteger)createScene:(AgoraMetachatSceneConfig *_Nonnull)config;
222 @end
223
224 #endif /*AgoraMetachat_h*/
225
-[AgoraMetachatKit getSceneInfos]
NSInteger getSceneInfos()
AgoraMetachatDownloadStateTypeIdle
@ AgoraMetachatDownloadStateTypeIdle
Definition: AgoraMetachatKit.h:40
AgoraRtcEngineKit
Definition: AgoraRtcEngineKit.h:1813
AgoraMetachatEventDelegate-p
Definition: AgoraMetachatKit.h:116
-[AgoraMetachatLocalUserAvatar getUserInfo]
AgoraMetachatUserInfo *_Nullable getUserInfo()
AgoraMetachatBundleInfo::bundlePath
NSString *_Nonnull bundlePath
Definition: AgoraMetachatKit.h:74
-[AgoraMetachatScene leaveScene]
NSInteger leaveScene()
AgoraMetachatAvatarModelInfo
Definition: AgoraMetachatKit.h:134
-[AgoraMetachatLocalUserAvatar getDressInfo]
AgoraMetachatDressInfo *_Nullable getDressInfo()
AgoraMetachatConnectionStateTypeConnecting
@ AgoraMetachatConnectionStateTypeConnecting
Definition: AgoraMetachatKit.h:23
AgoraMetachatVenderType
AgoraMetachatVenderType
Definition: AgoraMetachatKit.h:54
AgoraMetachatBundleInfo::assets
NSString *_Nonnull assets
Definition: AgoraMetachatKit.h:77
AgoraMetachatBundleInfo::desc
NSString *_Nonnull desc
Definition: AgoraMetachatKit.h:72
-[AgoraMetachatScene destroy]
NSInteger destroy()
AgoraMetachatEnterSceneConfig
Definition: AgoraMetachatKit.h:163
AgoraMetachatBundleInfo::bundleCode
NSString *_Nonnull bundleCode
Definition: AgoraMetachatKit.h:70
-[AgoraMetachatScene getLocalUserAvatar]
AgoraMetachatLocalUserAvatar *_Nullable getLocalUserAvatar()
AgoraMetachatErrorTypeEngineLoadFailed
@ AgoraMetachatErrorTypeEngineLoadFailed
Definition: AgoraMetachatKit.h:48
AgoraMetachatBundleInfo::bundleName
NSString *_Nonnull bundleName
Definition: AgoraMetachatKit.h:71
AgoraVideoFrame
Definition: AgoraObjects.h:1734
-[AgoraMetachatScene enumerateVideoDisplays]
NSInteger enumerateVideoDisplays()
AgoraMetachatSceneConfig
Definition: AgoraMetachatKit.h:159
AgoraMetachatBundleInfo::bundleId
NSInteger bundleId
Definition: AgoraMetachatKit.h:67
AgoraMetachatSceneInfo
Definition: AgoraMetachatKit.h:84
AgoraMetaViewProtocol.h
AgoraMetachatFaceInfo
Definition: AgoraMetachatKit.h:146
AgoraMetaViewProtocol-p
Definition: AgoraMetaViewProtocol.h:11
AgoraMetachatBundleInfo::bundleType
AgoraMetachatBundleType bundleType
Definition: AgoraMetachatKit.h:69
AgoraMetachatPositionInfo
Definition: AgoraMetachatKit.h:108
AgoraMetachatBundleInfo::bundleSize
NSInteger bundleSize
Definition: AgoraMetachatKit.h:79
AgoraMetachatErrorTypeJoinRoomFailed
@ AgoraMetachatErrorTypeJoinRoomFailed
Definition: AgoraMetachatKit.h:50
AgoraMetachatErrorType
AgoraMetachatErrorType
Definition: AgoraMetachatKit.h:46
AgoraRtcEngineKit.h
AgoraMetachatConnectionChangedReasonTypeDefault
@ AgoraMetachatConnectionChangedReasonTypeDefault
Definition: AgoraMetachatKit.h:36
AgoraMetachatDressInfo
Definition: AgoraMetachatKit.h:142
AgoraMetachatUserInfo
Definition: AgoraMetachatKit.h:101
-[AgoraMetachatKit getLauncherVersion]
NSString *_Nullable getLauncherVersion()
AgoraMetachatConnectionChangedReasonType
AgoraMetachatConnectionChangedReasonType
Definition: AgoraMetachatKit.h:34
AgoraMetachatConnectionStateTypeReconnecting
@ AgoraMetachatConnectionStateTypeReconnecting
Definition: AgoraMetachatKit.h:27
AgoraMetachatDownloadStateType
AgoraMetachatDownloadStateType
Definition: AgoraMetachatKit.h:39
AgoraMetachatErrorTypeSceneUnloadFailed
@ AgoraMetachatErrorTypeSceneUnloadFailed
Definition: AgoraMetachatKit.h:51
AgoraMetachatDownloadStateTypeDownloading
@ AgoraMetachatDownloadStateTypeDownloading
Definition: AgoraMetachatKit.h:41
AgoraMetachatErrorTypeSceneLoadFailed
@ AgoraMetachatErrorTypeSceneLoadFailed
Definition: AgoraMetachatKit.h:49
-[AgoraMetachatLocalUserAvatar applyInfo]
NSInteger applyInfo()
AgoraMetachatBundleInfo::sceneId
NSInteger sceneId
Definition: AgoraMetachatKit.h:68
AgoraMetachatBundleInfo::extraInfo
NSString *_Nullable extraInfo
Definition: AgoraMetachatKit.h:78
AgoraMetachatConnectionStateType
AgoraMetachatConnectionStateType
Definition: AgoraMetachatKit.h:19
AgoraMetachatBundleTypeScene
@ AgoraMetachatBundleTypeScene
Definition: AgoraMetachatKit.h:59
AgoraMetachatBundleType
AgoraMetachatBundleType
Definition: AgoraMetachatKit.h:58
AgoraMetachatErrorTypeOK
@ AgoraMetachatErrorTypeOK
Definition: AgoraMetachatKit.h:47
+[AgoraMetachatKit destroy]
void destroy()
AgoraMetachatBundleTypeOther
@ AgoraMetachatBundleTypeOther
Definition: AgoraMetachatKit.h:62
AgoraMetachatConfig
Definition: AgoraMetachatKit.h:150
AgoraMetachatBundleInfo
Definition: AgoraMetachatKit.h:67
AgoraMetachatConnectionStateTypeAborted
@ AgoraMetachatConnectionStateTypeAborted
Definition: AgoraMetachatKit.h:29
AgoraMetachatKit
Definition: AgoraMetachatKit.h:209
AgoraMetachatLocalUserAvatar
Definition: AgoraMetachatKit.h:174
AgoraMetachatBundleInfo::thumbnailPath
NSString *_Nonnull thumbnailPath
Definition: AgoraMetachatKit.h:76
AgoraMetachatSceneEventDelegate-p
Definition: AgoraMetachatKit.h:124
AgoraMetachatConnectionStateTypeDisconnected
@ AgoraMetachatConnectionStateTypeDisconnected
Definition: AgoraMetachatKit.h:21
-[AgoraMetachatLocalUserAvatar getExtraCustomInfo]
NSData *_Nullable getExtraCustomInfo()
AgoraMetachatDownloadStateTypeDownloaded
@ AgoraMetachatDownloadStateTypeDownloaded
Definition: AgoraMetachatKit.h:42
AgoraMetachatDownloadStateTypeFailed
@ AgoraMetachatDownloadStateTypeFailed
Definition: AgoraMetachatKit.h:43
-[AgoraMetachatLocalUserAvatar getModelInfo]
AgoraMetachatAvatarModelInfo *_Nullable getModelInfo()
AgoraMetachatVenderTypeUnity
@ AgoraMetachatVenderTypeUnity
Definition: AgoraMetachatKit.h:55
AgoraMetachatBundleTypeAssetManifest
@ AgoraMetachatBundleTypeAssetManifest
Definition: AgoraMetachatKit.h:61
AgoraMetachatBundleTypeAvatar
@ AgoraMetachatBundleTypeAvatar
Definition: AgoraMetachatKit.h:60
-[AgoraMetachatEventDelegate-p onRequestToken]
void onRequestToken()
-[AgoraMetachatLocalUserAvatar getFaceInfo]
AgoraMetachatFaceInfo *_Nullable getFaceInfo()
AgoraMetachatConnectionStateTypeConnected
@ AgoraMetachatConnectionStateTypeConnected
Definition: AgoraMetachatKit.h:25
AgoraMetachatScene
Definition: AgoraMetachatKit.h:188