Agora RTC Objective-C API Reference  Refactor
AgoraMetaServiceKit.h
Go to the documentation of this file.
1 //
2 // AgoraMetaKit.h
3 // AgoraRtcKit
4 //
5 // Created by dingyusong on 12/4/22.
6 // Copyright (c) 2022 Agora. All rights reserved.
7 //
8 
9 #ifndef AgoraMetaKit_h
10 #define AgoraMetaKit_h
11 
12 #include "AgoraObjects.h"
13 #import <Foundation/Foundation.h>
14 #include <objc/objc.h>
15 #include <objc/NSObjCRuntime.h>
16 #import "AgoraRtcEngineKit.h"
17 
18 
21 typedef NS_ENUM(NSUInteger, AgoraMetaConnectionStateType){
22  /* The SDK is disconnected from the state meta server. */
24  /* The SDK is connecting to the state meta server. */
26  /* The SDK is connected to the state meta server. */
28  /* The SDK is reconnecting to the state meta server. */
30  /* The SDK is reconnected to the state meta server. */
32 };
33 
36 typedef NS_ENUM(NSUInteger, AgoraMetaConnectionChangedReasonType) {
37  /* The connection state is changed. */
39 };
40 
41 typedef NS_ENUM(NSUInteger, AgoraMetaDownloadStateType) {
46 };
47 
48 typedef NS_ENUM(NSUInteger, AgoraMetaErrorType) {
54 };
55 
56 typedef NS_ENUM(NSUInteger, AgoraMetaBundleType) {
61 };
62 
63 typedef NS_ENUM(NSUInteger, AgoraMetaSceneBroadcastMode) {
66 };
67 
68 typedef NS_ENUM(NSUInteger, AgoraMetaStateSyncMode) {
71 };
72 
73 // meta bundle model information bound to meta scene information
74 __attribute__((visibility("default"))) @interface AgoraMetaBundleInfo : NSObject
75 @property (nonatomic, assign) NSInteger bundleId;
76 @property (nonatomic, assign) NSInteger sceneId;
77 @property (nonatomic, assign) AgoraMetaBundleType bundleType;
78 @property (nonatomic, copy) NSString * _Nonnull bundleCode;
79 @property (nonatomic, copy) NSString * _Nonnull bundleName;
80 @property (nonatomic, copy) NSString * _Nonnull desc;
81 // local path of bundle model path
82 @property (nonatomic, copy) NSString * _Nonnull bundlePath;
83 // local path of bundle thumbnail
84 @property (nonatomic, copy) NSString * _Nonnull thumbnailPath;
85 @property (nonatomic, copy) NSString * _Nonnull assets;
86 @property (nonatomic, copy) NSString * _Nullable extraInfo;
87 @property (nonatomic, assign) NSInteger bundleSize;
88 @end
89 
90 // meta scene information retrieved by getScenes interface
91 __attribute__((visibility("default"))) @interface AgoraMetaSceneInfo : NSObject
92 @property (nonatomic, assign) NSInteger sceneId;
93 @property (nonatomic, copy) NSString * _Nonnull sceneName;
94 // local path of scene thumbnail
95 @property (nonatomic, copy) NSString * _Nonnull thumbnailPath;
96 @property (nonatomic, copy) NSString * _Nonnull scenePath;
97 @property (nonatomic, copy) NSString * _Nonnull parentScenePath;
98 @property (nonatomic, copy) NSString * _Nonnull desc;
99 @property (nonatomic, copy) NSString * _Nonnull sceneConfig;
100 @property (nonatomic, copy) NSString * _Nullable extraInfo;
101 @property (nonatomic, copy) NSString * _Nonnull sceneVersion;
102 @property (nonatomic, copy) NSString * _Nonnull sceneLocalVersion;
103 @property (nonatomic, assign) NSInteger totalSize;
104 // avatar information bound to scene
105 @property (nonatomic, strong) NSArray<AgoraMetaBundleInfo *> * _Nonnull bundles;
106 @end
107 
108 __attribute__((visibility("default"))) @interface AgoraMetaUserInfo : NSObject
109 @property (nonatomic, copy) NSString * _Nonnull userId;
110 @property (nonatomic, copy) NSString * _Nonnull userName;
111 @property (nonatomic, copy) NSString * _Nonnull userIconUrl;
112 @end
113 
114 __attribute__((visibility("default"))) @interface AgoraMetaPositionInfo : NSObject
115 @property (nonatomic, copy) NSArray * _Nonnull position;
116 @property (nonatomic, copy) NSArray * _Nonnull forward;
117 @property (nonatomic, copy) NSArray * _Nonnull right;
118 @property (nonatomic, copy) NSArray * _Nonnull up;
119 @end
120 
121 @class AgoraMetaServiceKit;
122 @class AgoraMetaScene;
123 @protocol AgoraMetaEventDelegate <NSObject>
124 - (void)onCreateSceneResult:(AgoraMetaScene *_Nullable)scene errorCode:(NSInteger)errorCode;
125 - (void)onConnectionStateChanged:(NSString *_Nullable)roomName state:(AgoraMetaConnectionStateType)state reason:(AgoraMetaConnectionChangedReasonType)reason;
126 - (void)onTokenWillExpire;
127 - (void)onGetSceneAssetsInfoResult:(NSMutableArray * _Nonnull)sceneInfos errorCode:(NSInteger)errorCode;
128 - (void)onDownloadSceneAssetsProgress:(NSInteger)sceneId progress:(NSInteger)progress state:(AgoraMetaDownloadStateType)state;
129 @end
130 
131 @protocol AgoraMetaSceneEventDelegate<NSObject>
132 - (void)metaScene:(AgoraMetaScene *_Nonnull)scene onReleasedScene:(NSInteger)errorCode;
133 - (void)metaScene:(AgoraMetaScene *_Nonnull)scene onEnterSceneResult:(NSInteger)errorCode;
134 - (void)metaScene:(AgoraMetaScene *_Nonnull)scene onLeaveSceneResult:(NSInteger)errorCode;
135 - (void)metaScene:(AgoraMetaScene *_Nonnull)scene onSceneMessageReceived:(NSData * _Nonnull)message;
136 - (void)metaScene:(AgoraMetaScene *_Nonnull)scene onUserPositionChanged:(NSString * _Nonnull)uid posInfo:(AgoraMetaPositionInfo * _Nonnull)posInfo;
137 #if (!(TARGET_OS_IPHONE) && (TARGET_OS_MAC))
138 - (void)metaScene:(AgoraMetaScene *_Nonnull)scene onSceneVideoFrameCaptured:(AgoraOutputVideoFrame * _Nullable)videoFrame view:(NSView * _Nonnull)view;
139 #else
140 - (void)metaScene:(AgoraMetaScene *_Nonnull)scene onSceneVideoFrameCaptured:(AgoraOutputVideoFrame * _Nullable)videoFrame view:(UIView * _Nonnull)view;
141 #endif
142 - (void)metaScene:(AgoraMetaScene *_Nonnull)scene onRecvMessageFromUser:(NSString * _Nonnull)userId message:(NSData * _Nonnull)message;
143 - (void)metaScene:(AgoraMetaScene *_Nonnull)scene onRecvBroadcastMessage:(NSData * _Nonnull)message;
144 #if (!(TARGET_OS_IPHONE) && (TARGET_OS_MAC))
145 - (void)metaScene:(AgoraMetaScene *_Nonnull)scene onAddSceneViewResult:(NSView * _Nonnull)view errorCode:(NSInteger)errorCode;
146 #else
147 - (void)metaScene:(AgoraMetaScene *_Nonnull)scene onAddSceneViewResult:(UIView * _Nonnull)view errorCode:(NSInteger)errorCode;
148 #endif
149 #if (!(TARGET_OS_IPHONE) && (TARGET_OS_MAC))
150 - (void)metaScene:(AgoraMetaScene *_Nonnull)scene onRemoveSceneViewResult:(NSView * _Nonnull)view errorCode:(NSInteger)errorCode;
151 #else
152 - (void)metaScene:(AgoraMetaScene *_Nonnull)scene onRemoveSceneViewResult:(UIView * _Nonnull)view errorCode:(NSInteger)errorCode;
153 #endif
154 @end
155 
156 __attribute__((visibility("default"))) @interface AgoraMetaAvatarModelInfo : NSObject
157 @property (nonatomic, copy) NSString * _Nonnull bundleCode;
158 @property (nonatomic,assign) BOOL localVisible;
159 @property (nonatomic,assign) BOOL remoteVisible;
160 @property (nonatomic,assign) BOOL syncPosition;
161 @end
162 
163 __attribute__((visibility("default"))) @interface AgoraMetaServiceConfig : NSObject
164 @property (nonatomic, copy) NSString * _Nonnull appId;
165 @property (nonatomic, copy) NSString * _Nonnull rtmToken;
166 @property (nonatomic, copy) NSString * _Nonnull rtcToken;
167 @property (nonatomic, copy) NSString * _Nonnull userId;
168 @property (nonatomic, weak) id<AgoraMetaEventDelegate> _Nullable delegate;
169 @property (nonatomic, copy) NSString * _Nonnull localDownloadPath;
170 @property (nonatomic, assign) AgoraRtcEngineKit* _Nullable rtcEngine;
171 @end
172 
173 __attribute__((visibility("default"))) @interface AgoraMetaSceneConfig : NSObject
174 @property (nonatomic, assign) AgoraMetaStateSyncMode syncMode;
175 @property (nonatomic, weak) id<AgoraMetaSceneEventDelegate> _Nullable delegate;
176 @property (nonatomic, assign) BOOL enableFaceCapture;
177 @property (nonatomic, copy) NSString * _Nonnull faceCaptureAppId;
178 @property (nonatomic, copy) NSString * _Nonnull faceCaptureCertificate;
179 @end
180 
181 __attribute__((visibility("default"))) @interface AgoraMetaEnterSceneConfig : NSObject
182 @property (nonatomic, copy) NSString * _Nonnull roomName;
183 #if (!(TARGET_OS_IPHONE) && (TARGET_OS_MAC))
184 @property (nonatomic, strong) NSView * _Nonnull sceneView;
185 #else
186 @property (nonatomic, strong) UIView * _Nonnull sceneView;
187 #endif
188 @property (nonatomic, assign) NSInteger sceneId;
189 @property (nonatomic, copy) NSString * _Nullable scenePath;
190 @property (nonatomic, strong) NSData * _Nullable extraInfo;
191 @end
192 
193 __attribute__((visibility("default"))) @interface AgoraMetaSceneDisplayConfig : NSObject
194 @property (nonatomic, assign) NSInteger width;
195 @property (nonatomic, assign) NSInteger height;
196 @property (nonatomic, strong) NSData * _Nullable extraInfo;
197 @end
198 
199 __attribute__((visibility("default"))) @interface AgoraMetaLocalUserAvatar : NSObject
200 - (NSInteger)setUserInfo:(AgoraMetaUserInfo *_Nullable)userInfo;
201 - (AgoraMetaUserInfo *_Nullable)getUserInfo;
202 - (NSInteger)setModelInfo:(AgoraMetaAvatarModelInfo *_Nullable)modelInfo;
204 - (NSInteger)setExtraInfo:(NSData *_Nullable)customInfo;
205 - (NSData *_Nullable)getExtraInfo;
206 - (NSInteger)applyInfo;
207 @end
208 
209 __attribute__((visibility("default"))) @interface AgoraMetaScene : NSObject
210 - (NSInteger)destroy;
212 #if (!(TARGET_OS_IPHONE) && (TARGET_OS_MAC))
213 - (NSView *_Nullable)createRenderView:(CGRect)frame;
214 #else
215 - (UIView *_Nullable)createRenderView:(CGRect)frame;
216 #endif
217 - (NSInteger)enterScene:(AgoraMetaEnterSceneConfig *_Nonnull)config;
218 - (NSInteger)leaveScene;
219 
220 - (NSInteger)sendSceneMessage:(NSData *_Nonnull)message;
221 - (NSInteger)setSceneParameters:(NSString *_Nonnull)jsonParam;
222 - (NSInteger)enableVideoDisplay:(NSString *_Nonnull)displayId enable:(BOOL)enable;
223 - (NSInteger)pushVideoFrameToDisplay:(NSString *_Nonnull)displayId frame:(AgoraVideoFrame *_Nullable)frame;
224 #if (!(TARGET_OS_IPHONE) && (TARGET_OS_MAC))
225 - (NSInteger)enableSceneVideoCapture:(NSView *_Nonnull)view enable:(BOOL)enable;
226 - (NSInteger)addSceneView:(NSView *_Nonnull)view sceneDisplayConfig:(AgoraMetaSceneDisplayConfig *_Nullable)config;
227 - (NSInteger)removeSceneView:(NSView *_Nonnull)view;
228 #else
229 - (NSInteger)enableSceneVideoCapture:(UIView *_Nonnull)view enable:(BOOL)enable;
230 - (NSInteger)addSceneView:(UIView *_Nonnull)view sceneDisplayConfig:(AgoraMetaSceneDisplayConfig *_Nullable)config;
231 - (NSInteger)removeSceneView:(UIView *_Nonnull)view;
232 
233 - (NSInteger)enableFaceCapture:(BOOL)enable;
234 #endif
235 
236 - (void)enableMainQueueDispatch:(BOOL)enabled NS_SWIFT_NAME(enableMainQueueDispatch(_:));
237 @end
238 
239 __attribute__((visibility("default"))) @interface AgoraMetaServiceKit : NSObject
240 + (instancetype _Nonnull)sharedMetaServiceWithConfig:(AgoraMetaServiceConfig* _Nonnull)config NS_SWIFT_NAME(sharedMetaServiceWithConfig(_:));
241 + (void)destroy NS_SWIFT_NAME(destroy());
242 
243 - (NSInteger)renewToken:(NSString *_Nonnull)token;
244 
245 - (NSString *_Nullable)getLauncherVersion;
246 - (NSInteger)getSceneAssetsInfo;
247 - (NSInteger)isSceneAssetsDownloaded:(NSInteger)sceneId;
248 - (NSInteger)downloadSceneAssets:(NSInteger)sceneId;
249 - (NSInteger)cancelDownloadSceneAssets:(NSInteger)sceneId;
250 - (NSInteger)cleanSceneAssets:(NSInteger)sceneId;
251 
252 - (NSInteger)createScene:(AgoraMetaSceneConfig *_Nonnull)config;
253 @end
254 
255 #endif /*AgoraMeta_h*/
256 
AgoraMetaPositionInfo
Definition: AgoraMetaServiceKit.h:115
AgoraMetaBundleInfo::bundleId
NSInteger bundleId
Definition: AgoraMetaServiceKit.h:75
AgoraRtcEngineKit
Definition: AgoraRtcEngineKit.h:47
AgoraMetaServiceKit
Definition: AgoraMetaServiceKit.h:240
AgoraMetaStateSyncModeNormal
@ AgoraMetaStateSyncModeNormal
Definition: AgoraMetaServiceKit.h:70
AgoraMetaDownloadStateTypeIdle
@ AgoraMetaDownloadStateTypeIdle
Definition: AgoraMetaServiceKit.h:42
-[AgoraMetaLocalUserAvatar getModelInfo]
AgoraMetaAvatarModelInfo *_Nullable getModelInfo()
AgoraMetaUserInfo
Definition: AgoraMetaServiceKit.h:109
AgoraMetaBundleTypeAssetManifest
@ AgoraMetaBundleTypeAssetManifest
Definition: AgoraMetaServiceKit.h:59
AgoraMetaSceneBroadcastMode
AgoraMetaSceneBroadcastMode
Definition: AgoraMetaServiceKit.h:63
AgoraMetaBundleInfo::bundleCode
NSString *_Nonnull bundleCode
Definition: AgoraMetaServiceKit.h:78
AgoraMetaSceneInfo
Definition: AgoraMetaServiceKit.h:92
AgoraMetaDownloadStateType
AgoraMetaDownloadStateType
Definition: AgoraMetaServiceKit.h:41
AgoraOutputVideoFrame
Definition: AgoraObjects.h:2169
AgoraMetaSceneEventDelegate-p
Definition: AgoraMetaServiceKit.h:131
AgoraMetaConnectionStateTypeConnected
@ AgoraMetaConnectionStateTypeConnected
Definition: AgoraMetaServiceKit.h:27
AgoraMetaErrorTypeSceneLoadFailed
@ AgoraMetaErrorTypeSceneLoadFailed
Definition: AgoraMetaServiceKit.h:51
-[AgoraMetaScene leaveScene]
NSInteger leaveScene()
AgoraMetaConnectionChangedReasonTypeDefault
@ AgoraMetaConnectionChangedReasonTypeDefault
Definition: AgoraMetaServiceKit.h:38
-[AgoraMetaServiceKit getLauncherVersion]
NSString *_Nullable getLauncherVersion()
AgoraMetaBundleTypeOther
@ AgoraMetaBundleTypeOther
Definition: AgoraMetaServiceKit.h:60
AgoraVideoFrame
Definition: AgoraObjects.h:1783
AgoraMetaConnectionStateType
AgoraMetaConnectionStateType
Definition: AgoraMetaServiceKit.h:21
AgoraMetaConnectionStateTypeConnecting
@ AgoraMetaConnectionStateTypeConnecting
Definition: AgoraMetaServiceKit.h:25
AgoraMetaSceneBroadcastModeNone
@ AgoraMetaSceneBroadcastModeNone
Definition: AgoraMetaServiceKit.h:64
AgoraMetaBundleInfo::bundlePath
NSString *_Nonnull bundlePath
Definition: AgoraMetaServiceKit.h:82
+[AgoraMetaServiceKit destroy]
void destroy()
AgoraMetaBundleTypeAvatar
@ AgoraMetaBundleTypeAvatar
Definition: AgoraMetaServiceKit.h:58
-[AgoraMetaLocalUserAvatar getUserInfo]
AgoraMetaUserInfo *_Nullable getUserInfo()
AgoraMetaAvatarModelInfo
Definition: AgoraMetaServiceKit.h:157
AgoraMetaSceneConfig
Definition: AgoraMetaServiceKit.h:174
AgoraMetaEnterSceneConfig
Definition: AgoraMetaServiceKit.h:182
AgoraMetaConnectionStateTypeDisconnected
@ AgoraMetaConnectionStateTypeDisconnected
Definition: AgoraMetaServiceKit.h:23
AgoraMetaBundleType
AgoraMetaBundleType
Definition: AgoraMetaServiceKit.h:56
AgoraRtcEngineKit.h
AgoraMetaConnectionChangedReasonType
AgoraMetaConnectionChangedReasonType
Definition: AgoraMetaServiceKit.h:36
AgoraMetaStateSyncMode
AgoraMetaStateSyncMode
Definition: AgoraMetaServiceKit.h:68
AgoraMetaConnectionStateTypeAborted
@ AgoraMetaConnectionStateTypeAborted
Definition: AgoraMetaServiceKit.h:31
-[AgoraMetaLocalUserAvatar getExtraInfo]
NSData *_Nullable getExtraInfo()
AgoraMetaBundleInfo::desc
NSString *_Nonnull desc
Definition: AgoraMetaServiceKit.h:80
-[AgoraMetaScene destroy]
NSInteger destroy()
AgoraMetaErrorTypeOK
@ AgoraMetaErrorTypeOK
Definition: AgoraMetaServiceKit.h:49
AgoraMetaSceneDisplayConfig
Definition: AgoraMetaServiceKit.h:194
-[AgoraMetaScene getLocalUserAvatar]
AgoraMetaLocalUserAvatar *_Nullable getLocalUserAvatar()
-[AgoraMetaServiceKit getSceneAssetsInfo]
NSInteger getSceneAssetsInfo()
AgoraMetaServiceConfig
Definition: AgoraMetaServiceKit.h:164
AgoraMetaBundleTypeScene
@ AgoraMetaBundleTypeScene
Definition: AgoraMetaServiceKit.h:57
AgoraObjects.h
AgoraMetaLocalUserAvatar
Definition: AgoraMetaServiceKit.h:200
AgoraMetaDownloadStateTypeDownloading
@ AgoraMetaDownloadStateTypeDownloading
Definition: AgoraMetaServiceKit.h:43
AgoraMetaSceneBroadcastModeAudience
@ AgoraMetaSceneBroadcastModeAudience
Definition: AgoraMetaServiceKit.h:65
AgoraMetaDownloadStateTypeDownloaded
@ AgoraMetaDownloadStateTypeDownloaded
Definition: AgoraMetaServiceKit.h:44
AgoraMetaBundleInfo::bundleName
NSString *_Nonnull bundleName
Definition: AgoraMetaServiceKit.h:79
AgoraMetaBundleInfo::extraInfo
NSString *_Nullable extraInfo
Definition: AgoraMetaServiceKit.h:86
AgoraMetaConnectionStateTypeReconnecting
@ AgoraMetaConnectionStateTypeReconnecting
Definition: AgoraMetaServiceKit.h:29
AgoraMetaBundleInfo::sceneId
NSInteger sceneId
Definition: AgoraMetaServiceKit.h:76
AgoraMetaErrorTypeJoinRoomFailed
@ AgoraMetaErrorTypeJoinRoomFailed
Definition: AgoraMetaServiceKit.h:52
AgoraMetaStateSyncModeNone
@ AgoraMetaStateSyncModeNone
Definition: AgoraMetaServiceKit.h:69
AgoraMetaBundleInfo::thumbnailPath
NSString *_Nonnull thumbnailPath
Definition: AgoraMetaServiceKit.h:84
AgoraMetaDownloadStateTypeFailed
@ AgoraMetaDownloadStateTypeFailed
Definition: AgoraMetaServiceKit.h:45
AgoraMetaScene
Definition: AgoraMetaServiceKit.h:210
AgoraMetaErrorTypeEngineLoadFailed
@ AgoraMetaErrorTypeEngineLoadFailed
Definition: AgoraMetaServiceKit.h:50
AgoraMetaBundleInfo::assets
NSString *_Nonnull assets
Definition: AgoraMetaServiceKit.h:85
AgoraMetaEventDelegate-p
Definition: AgoraMetaServiceKit.h:123
-[AgoraMetaLocalUserAvatar applyInfo]
NSInteger applyInfo()
AgoraMetaBundleInfo
Definition: AgoraMetaServiceKit.h:75
AgoraMetaErrorTypeSceneUnloadFailed
@ AgoraMetaErrorTypeSceneUnloadFailed
Definition: AgoraMetaServiceKit.h:53
AgoraMetaErrorType
AgoraMetaErrorType
Definition: AgoraMetaServiceKit.h:48
-[AgoraMetaEventDelegate-p onTokenWillExpire]
void onTokenWillExpire()
AgoraMetaBundleInfo::bundleType
AgoraMetaBundleType bundleType
Definition: AgoraMetaServiceKit.h:77
AgoraMetaBundleInfo::bundleSize
NSInteger bundleSize
Definition: AgoraMetaServiceKit.h:87