tirtc-react-native 2.4.0-alpha.3 → 2.4.0-alpha.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. package/README.md +6 -6
  2. package/TiRtcReactNative.podspec +1 -1
  3. package/android/build.gradle +1 -1
  4. package/android/src/main/java/com/tange/ai/tirtc/reactnative/TiRtcModule.kt +146 -109
  5. package/android/src/main/java/com/tange/ai/tirtc/reactnative/TiRtcReactNativeCleanup.kt +23 -23
  6. package/android/src/main/java/com/tange/ai/tirtc/reactnative/TiRtcReactNativeEventBinder.kt +21 -24
  7. package/android/src/main/java/com/tange/ai/tirtc/reactnative/TiRtcReactNativeEventSink.kt +6 -10
  8. package/android/src/main/java/com/tange/ai/tirtc/reactnative/TiRtcReactNativeMaps.kt +5 -5
  9. package/android/src/main/java/com/tange/ai/tirtc/reactnative/TiRtcReactNativeRegistry.kt +11 -11
  10. package/android/src/main/java/com/tange/ai/tirtc/reactnative/{TiRtcReactNativeStoreSupport.kt → TiRtcReactNativeStorageSupport.kt} +9 -9
  11. package/android/src/main/java/com/tange/ai/tirtc/reactnative/TiRtcVideoOutputViewManager.kt +2 -2
  12. package/ios/TiRtcReactNative+Conn.mm +5 -5
  13. package/ios/TiRtcReactNative+Storage.mm +513 -0
  14. package/ios/TiRtcReactNative.mm +19 -19
  15. package/ios/TiRtcReactNativeEventBinder.h +8 -8
  16. package/ios/TiRtcReactNativeEventBinder.mm +31 -33
  17. package/ios/TiRtcReactNativeEventSink.h +3 -4
  18. package/ios/TiRtcReactNativeEventSink.mm +6 -10
  19. package/ios/TiRtcVideoOutputView.mm +4 -4
  20. package/lib/module/index.js +1 -1
  21. package/lib/module/index.js.map +1 -1
  22. package/lib/module/{store.js → storage.js} +184 -176
  23. package/lib/module/storage.js.map +1 -0
  24. package/lib/typescript/index.d.ts +2 -2
  25. package/lib/typescript/specs/NativeTiRtc.d.ts +42 -42
  26. package/lib/typescript/storage.d.ts +204 -0
  27. package/package.json +1 -1
  28. package/src/index.ts +44 -44
  29. package/src/specs/NativeTiRtc.ts +47 -47
  30. package/src/storage.ts +769 -0
  31. package/ios/TiRtcReactNative+Store.mm +0 -496
  32. package/lib/module/store.js.map +0 -1
  33. package/lib/typescript/store.d.ts +0 -202
  34. package/src/store.ts +0 -760
@@ -6,43 +6,46 @@ import { TiRtcLogging } from './logging';
6
6
  import { NativeTiRtc, NativeTiRtcVideoOutputView } from './native';
7
7
  import { clearNativeIdentity, readNativeIdentity, setNativeIdentity, subscribeNativeIdentity, } from './native_object_id';
8
8
  import { NativeMediaFileBase, recordingFailure } from './recording';
9
- export const TISTORE_ERROR_OK = 0;
10
- export const TISTORE_ERROR_INVALID_ARGUMENT = 6000;
11
- export const TISTORE_ERROR_NOT_INITIALIZED = 6001;
12
- export const TISTORE_ERROR_TOKEN_EXPIRED = 6014;
13
- export const TISTORE_ERROR_ALREADY_INITIALIZED = 6022;
14
- export const TISTORE_ERROR_PERMISSION_DENIED = 6024;
15
- export const TISTORE_ERROR_IN_USE = 6026;
16
- export const TISTORE_ERROR_NOT_STARTED = 6027;
17
- export const TISTORE_ERROR_NOT_BOUND = 6029;
18
- export const TISTORE_ERROR_NOT_CONFIGURED = 6030;
19
- export const TISTORE_ERROR_RESOURCE_EXHAUSTED = 6043;
20
- export const TISTORE_ERROR_FILE_WRITE_FAILED = 6046;
21
- export const TISTORE_ERROR_UNSUPPORTED_FORMAT = 6113;
22
- export const TISTORE_ERROR_IO_FAILED = 6114;
23
- export const TISTORE_ERROR_CANCELLED = 6115;
24
- export const TISTORE_ERROR_RANGE_TOO_LARGE = 6117;
25
- export const TISTORE_ERROR_NO_FRAME = 6118;
26
- export const TISTORE_ERROR_NO_RECORDABLE_MEDIA = 6119;
27
- export const TISTORE_ERROR_RECORDING_OVERRUN = 6120;
28
- export const TISTORE_ERROR_RECORDING_UNREADABLE = 6122;
29
- export const TISTORE_ERROR_STORE_UNAVAILABLE = 6123;
30
- export const TISTORE_ERROR_STOPPED = 6124;
31
- export const TiStoreReplaySpeed = {
9
+ export const TI_CLOUD_STORAGE_ERROR_OK = 0;
10
+ export const TI_CLOUD_STORAGE_ERROR_INVALID_ARGUMENT = 6000;
11
+ export const TI_CLOUD_STORAGE_ERROR_NOT_INITIALIZED = 6001;
12
+ export const TI_CLOUD_STORAGE_ERROR_TOKEN_EXPIRED = 6014;
13
+ export const TI_CLOUD_STORAGE_ERROR_ALREADY_INITIALIZED = 6022;
14
+ export const TI_CLOUD_STORAGE_ERROR_PERMISSION_DENIED = 6024;
15
+ export const TI_CLOUD_STORAGE_ERROR_IN_USE = 6026;
16
+ export const TI_CLOUD_STORAGE_ERROR_NOT_STARTED = 6027;
17
+ export const TI_CLOUD_STORAGE_ERROR_NOT_BOUND = 6029;
18
+ export const TI_CLOUD_STORAGE_ERROR_NOT_CONFIGURED = 6030;
19
+ export const TI_CLOUD_STORAGE_ERROR_RESOURCE_EXHAUSTED = 6043;
20
+ export const TI_CLOUD_STORAGE_ERROR_FILE_WRITE_FAILED = 6046;
21
+ export const TI_CLOUD_STORAGE_ERROR_UNSUPPORTED_FORMAT = 6113;
22
+ export const TI_CLOUD_STORAGE_ERROR_IO_FAILED = 6114;
23
+ export const TI_CLOUD_STORAGE_ERROR_CANCELLED = 6115;
24
+ export const TI_CLOUD_STORAGE_ERROR_RANGE_TOO_LARGE = 6117;
25
+ export const TI_CLOUD_STORAGE_ERROR_NO_FRAME = 6118;
26
+ export const TI_CLOUD_STORAGE_ERROR_NO_RECORDABLE_MEDIA = 6119;
27
+ export const TI_CLOUD_STORAGE_ERROR_RECORDING_OVERRUN = 6120;
28
+ export const TI_CLOUD_STORAGE_ERROR_RECORDING_UNREADABLE = 6122;
29
+ export const TI_CLOUD_STORAGE_ERROR_UNAVAILABLE = 6123;
30
+ export const TI_CLOUD_STORAGE_ERROR_STOPPED = 6124;
31
+ export const TiCloudStorageReplaySpeed = {
32
+ x0_125: 'x0_125',
33
+ x0_25: 'x0_25',
34
+ x0_5: 'x0_5',
32
35
  x1: 'x1',
33
36
  x2: 'x2',
34
37
  x4: 'x4',
35
38
  x8: 'x8',
36
39
  };
37
- const storeLogTag = 'TIRTC_REACT_NATIVE_STORE';
38
- function logStoreOutcome(operation, code, details = '') {
39
- const message = `[${operation}] outcome=${code === TISTORE_ERROR_OK ? 'ok' : 'failed'} error_code=${code}${details}`;
40
- if (code === TISTORE_ERROR_OK)
41
- TiRtcLogging.i(storeLogTag, message);
40
+ const tiCloudStorageLogTag = 'TIRTC_REACT_NATIVE_CLOUD_STORAGE';
41
+ function tiCloudStorageLogOutcome(operation, code, details = '') {
42
+ const message = `[${operation}] outcome=${code === TI_CLOUD_STORAGE_ERROR_OK ? 'ok' : 'failed'} error_code=${code}${details}`;
43
+ if (code === TI_CLOUD_STORAGE_ERROR_OK)
44
+ TiRtcLogging.i(tiCloudStorageLogTag, message);
42
45
  else
43
- TiRtcLogging.e(storeLogTag, message);
46
+ TiRtcLogging.e(tiCloudStorageLogTag, message);
44
47
  }
45
- export const TiStoreAudioOutputState = {
48
+ export const TiCloudStorageAudioOutputState = {
46
49
  idle: 'idle',
47
50
  buffering: 'buffering',
48
51
  playing: 'playing',
@@ -50,7 +53,7 @@ export const TiStoreAudioOutputState = {
50
53
  paused: 'paused',
51
54
  completed: 'completed',
52
55
  };
53
- export const TiStoreVideoOutputState = {
56
+ export const TiCloudStorageVideoOutputState = {
54
57
  idle: 'idle',
55
58
  buffering: 'buffering',
56
59
  rendering: 'rendering',
@@ -77,13 +80,19 @@ function validTime(value) {
77
80
  }
78
81
  function speedToNative(speed) {
79
82
  switch (speed) {
80
- case TiStoreReplaySpeed.x1:
83
+ case TiCloudStorageReplaySpeed.x0_125:
84
+ return 6;
85
+ case TiCloudStorageReplaySpeed.x0_25:
86
+ return 5;
87
+ case TiCloudStorageReplaySpeed.x0_5:
88
+ return 4;
89
+ case TiCloudStorageReplaySpeed.x1:
81
90
  return 0;
82
- case TiStoreReplaySpeed.x2:
91
+ case TiCloudStorageReplaySpeed.x2:
83
92
  return 1;
84
- case TiStoreReplaySpeed.x4:
93
+ case TiCloudStorageReplaySpeed.x4:
85
94
  return 2;
86
- case TiStoreReplaySpeed.x8:
95
+ case TiCloudStorageReplaySpeed.x8:
87
96
  return 3;
88
97
  default:
89
98
  return null;
@@ -91,69 +100,74 @@ function speedToNative(speed) {
91
100
  }
92
101
  function speedFromNative(speed) {
93
102
  switch (speed) {
103
+ case 6:
104
+ return TiCloudStorageReplaySpeed.x0_125;
105
+ case 5:
106
+ return TiCloudStorageReplaySpeed.x0_25;
107
+ case 4:
108
+ return TiCloudStorageReplaySpeed.x0_5;
94
109
  case 0:
95
- return TiStoreReplaySpeed.x1;
110
+ return TiCloudStorageReplaySpeed.x1;
96
111
  case 1:
97
- return TiStoreReplaySpeed.x2;
112
+ return TiCloudStorageReplaySpeed.x2;
98
113
  case 2:
99
- return TiStoreReplaySpeed.x4;
114
+ return TiCloudStorageReplaySpeed.x4;
100
115
  case 3:
101
- return TiStoreReplaySpeed.x8;
116
+ return TiCloudStorageReplaySpeed.x8;
102
117
  default:
103
118
  return null;
104
119
  }
105
120
  }
106
121
  function audioStateFromNative(state) {
107
122
  switch (state) {
108
- case TiStoreAudioOutputState.idle:
109
- case TiStoreAudioOutputState.buffering:
110
- case TiStoreAudioOutputState.playing:
111
- case TiStoreAudioOutputState.failed:
112
- case TiStoreAudioOutputState.paused:
113
- case TiStoreAudioOutputState.completed:
123
+ case TiCloudStorageAudioOutputState.idle:
124
+ case TiCloudStorageAudioOutputState.buffering:
125
+ case TiCloudStorageAudioOutputState.playing:
126
+ case TiCloudStorageAudioOutputState.failed:
127
+ case TiCloudStorageAudioOutputState.paused:
128
+ case TiCloudStorageAudioOutputState.completed:
114
129
  return state;
115
130
  default:
116
- return TiStoreAudioOutputState.failed;
131
+ return TiCloudStorageAudioOutputState.failed;
117
132
  }
118
133
  }
119
134
  function videoStateFromNative(state) {
120
135
  switch (state) {
121
- case TiStoreVideoOutputState.idle:
122
- case TiStoreVideoOutputState.buffering:
123
- case TiStoreVideoOutputState.rendering:
124
- case TiStoreVideoOutputState.failed:
125
- case TiStoreVideoOutputState.paused:
126
- case TiStoreVideoOutputState.completed:
136
+ case TiCloudStorageVideoOutputState.idle:
137
+ case TiCloudStorageVideoOutputState.buffering:
138
+ case TiCloudStorageVideoOutputState.rendering:
139
+ case TiCloudStorageVideoOutputState.failed:
140
+ case TiCloudStorageVideoOutputState.paused:
141
+ case TiCloudStorageVideoOutputState.completed:
127
142
  return state;
128
143
  default:
129
- return TiStoreVideoOutputState.failed;
144
+ return TiCloudStorageVideoOutputState.failed;
130
145
  }
131
146
  }
132
- export class TiStore {
147
+ export class TiCloudStorage {
133
148
  constructor(token) {
134
149
  this.token = token;
135
150
  this.identity = null;
136
151
  this.disposed = false;
137
- this.onTokenExpired = null;
138
152
  }
139
153
  static init(options) {
140
154
  if (!isPlainObject(options) || typeof options.appId !== 'string' || options.appId.length === 0) {
141
- logStoreOutcome('store_initialize', TISTORE_ERROR_INVALID_ARGUMENT);
142
- return Promise.resolve(TISTORE_ERROR_INVALID_ARGUMENT);
155
+ tiCloudStorageLogOutcome('cloud_storage_initialize', TI_CLOUD_STORAGE_ERROR_INVALID_ARGUMENT);
156
+ return Promise.resolve(TI_CLOUD_STORAGE_ERROR_INVALID_ARGUMENT);
143
157
  }
144
- return NativeTiRtc.storeInitialize({
158
+ return NativeTiRtc.tiCloudStorageInitialize({
145
159
  appId: options.appId,
146
160
  endpoint: options.endpoint ?? '',
147
161
  consoleLogEnabled: options.consoleLogEnabled ?? false,
148
162
  }).then((code) => {
149
- logStoreOutcome('store_initialize', code);
163
+ tiCloudStorageLogOutcome('cloud_storage_initialize', code);
150
164
  return code;
151
165
  });
152
166
  }
153
167
  static shutdown() {
154
- const nativeCode = NativeTiRtc.storeShutdown();
155
- const code = nativeCode === TISTORE_ERROR_NOT_INITIALIZED ? TISTORE_ERROR_OK : nativeCode;
156
- logStoreOutcome('store_shutdown', code);
168
+ const nativeCode = NativeTiRtc.tiCloudStorageShutdown();
169
+ const code = nativeCode === TI_CLOUD_STORAGE_ERROR_NOT_INITIALIZED ? TI_CLOUD_STORAGE_ERROR_OK : nativeCode;
170
+ tiCloudStorageLogOutcome('cloud_storage_shutdown', code);
157
171
  return code;
158
172
  }
159
173
  static errorToString(code) {
@@ -161,31 +175,31 @@ export class TiStore {
161
175
  }
162
176
  updateToken(token) {
163
177
  if (token.length === 0)
164
- return TISTORE_ERROR_INVALID_ARGUMENT;
178
+ return TI_CLOUD_STORAGE_ERROR_INVALID_ARGUMENT;
165
179
  const identity = this.ensureIdentity();
166
180
  if (typeof identity === 'number')
167
181
  return identity;
168
- const code = NativeTiRtc.storeUpdateToken(identity.objectId, token);
182
+ const code = NativeTiRtc.tiCloudStorageUpdateToken(identity.objectId, token);
169
183
  if (code === 0)
170
184
  this.token = token;
171
- logStoreOutcome('store_update_token', code);
185
+ tiCloudStorageLogOutcome('cloud_storage_update_token', code);
172
186
  return code;
173
187
  }
174
188
  listRecordings(startTimeMs, endTimeMs) {
175
189
  if (!validTime(startTimeMs) || !validTime(endTimeMs) || endTimeMs <= startTimeMs) {
176
190
  return Promise.resolve({
177
- code: TISTORE_ERROR_INVALID_ARGUMENT,
191
+ code: TI_CLOUD_STORAGE_ERROR_INVALID_ARGUMENT,
178
192
  recordings: [],
179
193
  });
180
194
  }
181
195
  const identity = this.ensureIdentity();
182
196
  if (typeof identity === 'number') {
183
- logStoreOutcome('recording_list', identity);
197
+ tiCloudStorageLogOutcome('recording_list', identity);
184
198
  return Promise.resolve({ code: identity, recordings: [] });
185
199
  }
186
- TiRtcLogging.i(storeLogTag, `[recording_list] outcome=started range_duration_ms=${endTimeMs - startTimeMs}`);
187
- return NativeTiRtc.storeListRecordings(identity.objectId, startTimeMs, endTimeMs).then((result) => {
188
- logStoreOutcome('recording_list', result.code, ` recording_count=${result.recordings.length}`);
200
+ TiRtcLogging.i(tiCloudStorageLogTag, `[recording_list] outcome=started range_duration_ms=${endTimeMs - startTimeMs}`);
201
+ return NativeTiRtc.tiCloudStorageListRecordings(identity.objectId, startTimeMs, endTimeMs).then((result) => {
202
+ tiCloudStorageLogOutcome('recording_list', result.code, ` recording_count=${result.recordings.length}`);
189
203
  return result;
190
204
  });
191
205
  }
@@ -194,21 +208,21 @@ export class TiStore {
194
208
  typeof endDate !== 'string' ||
195
209
  typeof timeZoneId !== 'string' ||
196
210
  timeZoneId.length === 0) {
197
- return Promise.resolve({ code: TISTORE_ERROR_INVALID_ARGUMENT, days: [] });
211
+ return Promise.resolve({ code: TI_CLOUD_STORAGE_ERROR_INVALID_ARGUMENT, days: [] });
198
212
  }
199
213
  const identity = this.ensureIdentity();
200
214
  if (typeof identity === 'number') {
201
- logStoreOutcome('recording_days_list', identity);
215
+ tiCloudStorageLogOutcome('recording_days_list', identity);
202
216
  return Promise.resolve({ code: identity, days: [] });
203
217
  }
204
- TiRtcLogging.i(storeLogTag, '[recording_days_list] outcome=started');
205
- return NativeTiRtc.storeListRecordingDays(identity.objectId, startDate, endDate, timeZoneId).then((result) => {
206
- logStoreOutcome('recording_days_list', result.code, ` day_count=${result.days.length}`);
218
+ TiRtcLogging.i(tiCloudStorageLogTag, '[recording_days_list] outcome=started');
219
+ return NativeTiRtc.tiCloudStorageListRecordingDays(identity.objectId, startDate, endDate, timeZoneId).then((result) => {
220
+ tiCloudStorageLogOutcome('recording_days_list', result.code, ` day_count=${result.days.length}`);
207
221
  return result;
208
222
  });
209
223
  }
210
224
  createReplay() {
211
- return new TiStoreReplay(this);
225
+ return new TiCloudStorageReplay(this);
212
226
  }
213
227
  exportRecording(options, onProgress) {
214
228
  if (!validTime(options.startTimeMs) ||
@@ -216,15 +230,15 @@ export class TiStore {
216
230
  options.endTimeMs <= options.startTimeMs ||
217
231
  !isUInt8(options.videoChannelId) ||
218
232
  (options.audioChannelId !== undefined && !isUInt8(options.audioChannelId))) {
219
- return recordingFailure(TISTORE_ERROR_INVALID_ARGUMENT);
233
+ return recordingFailure(TI_CLOUD_STORAGE_ERROR_INVALID_ARGUMENT);
220
234
  }
221
235
  const identity = this.ensureIdentity();
222
236
  if (typeof identity === 'number')
223
237
  return recordingFailure(identity);
224
- const result = NativeTiRtc.storeExportRecording(identity.objectId, options.startTimeMs, options.endTimeMs, options.videoChannelId, options.audioChannelId ?? null);
225
- logStoreOutcome('export_start', result.code, ` range_duration_ms=${options.endTimeMs - options.startTimeMs}`);
238
+ const result = NativeTiRtc.tiCloudStorageExportRecording(identity.objectId, options.startTimeMs, options.endTimeMs, options.videoChannelId, options.audioChannelId ?? null);
239
+ tiCloudStorageLogOutcome('export_start', result.code, ` range_duration_ms=${options.endTimeMs - options.startTimeMs}`);
226
240
  return result.code === 0 && result.taskId !== null
227
- ? success(new TiStoreExportTask(result.taskId, this, onProgress))
241
+ ? success(new TiCloudStorageExportTask(result.taskId, this, onProgress))
228
242
  : recordingFailure(result.code);
229
243
  }
230
244
  dispose() {
@@ -233,29 +247,27 @@ export class TiStore {
233
247
  if (this.identity === null) {
234
248
  this.disposed = true;
235
249
  this.token = '';
236
- this.onTokenExpired = null;
237
250
  return 0;
238
251
  }
239
252
  const identity = this.identity;
240
- const code = NativeTiRtc.storeDispose(identity.objectId);
253
+ const code = NativeTiRtc.tiCloudStorageDispose(identity.objectId);
241
254
  if (code === 0) {
242
255
  unregisterNativeEventHandler(identity);
243
256
  clearNativeIdentity(this);
244
257
  this.identity = null;
245
258
  this.disposed = true;
246
259
  this.token = '';
247
- this.onTokenExpired = null;
248
260
  }
249
261
  return code;
250
262
  }
251
263
  ensureIdentity() {
252
264
  if (this.disposed)
253
- return TISTORE_ERROR_NOT_INITIALIZED;
265
+ return TI_CLOUD_STORAGE_ERROR_NOT_INITIALIZED;
254
266
  if (this.identity !== null)
255
267
  return this.identity;
256
268
  if (this.token.length === 0)
257
- return TISTORE_ERROR_INVALID_ARGUMENT;
258
- const result = normalizeCreateResult(NativeTiRtc.storeCreate(this.token));
269
+ return TI_CLOUD_STORAGE_ERROR_INVALID_ARGUMENT;
270
+ const result = normalizeCreateResult(NativeTiRtc.tiCloudStorageCreate(this.token));
259
271
  if (result.code !== 0)
260
272
  return result.code;
261
273
  this.identity = {
@@ -263,19 +275,15 @@ export class TiStore {
263
275
  generation: result.generation,
264
276
  };
265
277
  setNativeIdentity(this, this.identity);
266
- registerNativeEventHandler(this.identity, (event) => {
267
- if (event.type === 'storeTokenExpired')
268
- this.onTokenExpired?.();
269
- });
270
278
  return this.identity;
271
279
  }
272
280
  }
273
- function nativeStoreIdentity(store) {
274
- return store.ensureIdentity();
281
+ function tiCloudStorageNativeIdentity(cloudStorage) {
282
+ return cloudStorage.ensureIdentity();
275
283
  }
276
- export class TiStoreReplay {
277
- constructor(store) {
278
- this.store = store;
284
+ export class TiCloudStorageReplay {
285
+ constructor(cloudStorage) {
286
+ this.cloudStorage = cloudStorage;
279
287
  this.identity = null;
280
288
  this.disposed = false;
281
289
  this.currentSpeed = 'x1';
@@ -286,7 +294,7 @@ export class TiStoreReplay {
286
294
  }
287
295
  get speed() {
288
296
  if (this.identity !== null) {
289
- const info = NativeTiRtc.storeReplayGetInfo(this.identity.objectId);
297
+ const info = NativeTiRtc.tiCloudStorageReplayGetInfo(this.identity.objectId);
290
298
  if (info.code === 0)
291
299
  this.currentSpeed = speedFromNative(info.speed) ?? this.currentSpeed;
292
300
  }
@@ -294,7 +302,7 @@ export class TiStoreReplay {
294
302
  }
295
303
  get currentTimeMs() {
296
304
  if (this.identity !== null) {
297
- const info = NativeTiRtc.storeReplayGetInfo(this.identity.objectId);
305
+ const info = NativeTiRtc.tiCloudStorageReplayGetInfo(this.identity.objectId);
298
306
  if (info.code === 0)
299
307
  this.currentTime = info.currentTimeMs;
300
308
  }
@@ -306,64 +314,64 @@ export class TiStoreReplay {
306
314
  endTimeMs <= startTimeMs ||
307
315
  (initialTimeMs !== undefined &&
308
316
  (!validTime(initialTimeMs) || initialTimeMs < startTimeMs || initialTimeMs >= endTimeMs)))
309
- return TISTORE_ERROR_INVALID_ARGUMENT;
317
+ return TI_CLOUD_STORAGE_ERROR_INVALID_ARGUMENT;
310
318
  const identity = this.ensureIdentity();
311
319
  const code = typeof identity === 'number'
312
320
  ? identity
313
- : NativeTiRtc.storeReplayPlay(identity.objectId, startTimeMs, endTimeMs, initialTimeMs ?? null);
314
- logStoreOutcome('replay_play', code, ` range_duration_ms=${endTimeMs - startTimeMs}`);
321
+ : NativeTiRtc.tiCloudStorageReplayPlay(identity.objectId, startTimeMs, endTimeMs, initialTimeMs ?? null);
322
+ tiCloudStorageLogOutcome('replay_play', code, ` range_duration_ms=${endTimeMs - startTimeMs}`);
315
323
  return code;
316
324
  }
317
325
  pause() {
318
- const code = this.command(NativeTiRtc.storeReplayPause);
319
- logStoreOutcome('replay_pause', code);
326
+ const code = this.command(NativeTiRtc.tiCloudStorageReplayPause);
327
+ tiCloudStorageLogOutcome('replay_pause', code);
320
328
  return code;
321
329
  }
322
330
  resume() {
323
- const code = this.command(NativeTiRtc.storeReplayResume);
324
- logStoreOutcome('replay_resume', code);
331
+ const code = this.command(NativeTiRtc.tiCloudStorageReplayResume);
332
+ tiCloudStorageLogOutcome('replay_resume', code);
325
333
  return code;
326
334
  }
327
335
  seek(timeMs) {
328
336
  if (!validTime(timeMs))
329
- return TISTORE_ERROR_INVALID_ARGUMENT;
337
+ return TI_CLOUD_STORAGE_ERROR_INVALID_ARGUMENT;
330
338
  const identity = this.ensureIdentity();
331
- const code = typeof identity === 'number' ? identity : NativeTiRtc.storeReplaySeek(identity.objectId, timeMs);
332
- logStoreOutcome('replay_seek', code);
339
+ const code = typeof identity === 'number' ? identity : NativeTiRtc.tiCloudStorageReplaySeek(identity.objectId, timeMs);
340
+ tiCloudStorageLogOutcome('replay_seek', code);
333
341
  return code;
334
342
  }
335
343
  setSpeed(speed) {
336
344
  const index = speedToNative(speed);
337
345
  if (index === null)
338
- return TISTORE_ERROR_INVALID_ARGUMENT;
346
+ return TI_CLOUD_STORAGE_ERROR_INVALID_ARGUMENT;
339
347
  const identity = this.ensureIdentity();
340
348
  if (typeof identity === 'number')
341
349
  return identity;
342
- const code = NativeTiRtc.storeReplaySetSpeed(identity.objectId, index);
350
+ const code = NativeTiRtc.tiCloudStorageReplaySetSpeed(identity.objectId, index);
343
351
  if (code === 0)
344
352
  this.currentSpeed = speed;
345
- logStoreOutcome('replay_speed', code, ` speed=${speed}`);
353
+ tiCloudStorageLogOutcome('replay_speed', code, ` speed=${speed}`);
346
354
  return code;
347
355
  }
348
356
  startRecording(options) {
349
357
  if (!isUInt8(options.videoChannelId) ||
350
358
  (options.audioChannelId !== undefined && !isUInt8(options.audioChannelId))) {
351
- return recordingFailure(TISTORE_ERROR_INVALID_ARGUMENT);
359
+ return recordingFailure(TI_CLOUD_STORAGE_ERROR_INVALID_ARGUMENT);
352
360
  }
353
361
  const identity = this.ensureIdentity();
354
362
  if (typeof identity === 'number')
355
363
  return recordingFailure(identity);
356
- const result = NativeTiRtc.storeReplayStartRecording(identity.objectId, options.videoChannelId, options.audioChannelId ?? null);
357
- logStoreOutcome('replay_recording_start', result.code);
364
+ const result = NativeTiRtc.tiCloudStorageReplayStartRecording(identity.objectId, options.videoChannelId, options.audioChannelId ?? null);
365
+ tiCloudStorageLogOutcome('replay_recording_start', result.code);
358
366
  return result.code === 0 && result.taskId !== null
359
- ? success(new TiStoreRecordingTask(result.taskId, this))
367
+ ? success(new TiCloudStorageRecordingTask(result.taskId, this))
360
368
  : recordingFailure(result.code);
361
369
  }
362
370
  stop() {
363
- const code = this.command(NativeTiRtc.storeReplayStop);
371
+ const code = this.command(NativeTiRtc.tiCloudStorageReplayStop);
364
372
  if (code === 0)
365
373
  this.currentTime = null;
366
- logStoreOutcome('replay_stop', code);
374
+ tiCloudStorageLogOutcome('replay_stop', code);
367
375
  return code;
368
376
  }
369
377
  dispose() {
@@ -377,7 +385,7 @@ export class TiStoreReplay {
377
385
  return 0;
378
386
  }
379
387
  const identity = this.identity;
380
- const code = NativeTiRtc.storeReplayDispose(identity.objectId);
388
+ const code = NativeTiRtc.tiCloudStorageReplayDispose(identity.objectId);
381
389
  if (code === 0) {
382
390
  unregisterNativeEventHandler(identity);
383
391
  clearNativeIdentity(this);
@@ -387,7 +395,7 @@ export class TiStoreReplay {
387
395
  this.onError = null;
388
396
  this.onCompleted = null;
389
397
  }
390
- logStoreOutcome('replay_dispose', code);
398
+ tiCloudStorageLogOutcome('replay_dispose', code);
391
399
  return code;
392
400
  }
393
401
  command(operation) {
@@ -396,13 +404,13 @@ export class TiStoreReplay {
396
404
  }
397
405
  ensureIdentity() {
398
406
  if (this.disposed)
399
- return TISTORE_ERROR_NOT_INITIALIZED;
407
+ return TI_CLOUD_STORAGE_ERROR_NOT_INITIALIZED;
400
408
  if (this.identity !== null)
401
409
  return this.identity;
402
- const store = nativeStoreIdentity(this.store);
403
- if (typeof store === 'number')
404
- return store;
405
- const result = normalizeCreateResult(NativeTiRtc.storeCreateReplay(store.objectId));
410
+ const cloudStorage = tiCloudStorageNativeIdentity(this.cloudStorage);
411
+ if (typeof cloudStorage === 'number')
412
+ return cloudStorage;
413
+ const result = normalizeCreateResult(NativeTiRtc.tiCloudStorageCreateReplay(cloudStorage.objectId));
406
414
  if (result.code !== 0)
407
415
  return result.code;
408
416
  this.identity = {
@@ -414,20 +422,20 @@ export class TiStoreReplay {
414
422
  return this.identity;
415
423
  }
416
424
  handleEvent(event) {
417
- if (event.type === 'storeReplayTimeChanged' && event.timestampMs !== undefined) {
425
+ if (event.type === 'tiCloudStorageReplayTimeChanged' && event.timestampMs !== undefined) {
418
426
  this.currentTime = event.timestampMs;
419
427
  this.onTimeChanged?.(event.timestampMs);
420
428
  }
421
- else if (event.type === 'storeReplayCompleted')
429
+ else if (event.type === 'tiCloudStorageReplayCompleted')
422
430
  this.onCompleted?.();
423
- else if (event.type === 'storeReplayError')
424
- this.onError?.(event.code ?? TISTORE_ERROR_STORE_UNAVAILABLE);
431
+ else if (event.type === 'tiCloudStorageReplayError')
432
+ this.onError?.(event.code ?? TI_CLOUD_STORAGE_ERROR_UNAVAILABLE);
425
433
  }
426
434
  }
427
435
  function nativeReplayIdentity(replay) {
428
436
  return replay.ensureIdentity();
429
437
  }
430
- class StoreOutputBase {
438
+ class TiCloudStorageOutputBase {
431
439
  constructor() {
432
440
  this.identity = null;
433
441
  this.disposed = false;
@@ -435,7 +443,7 @@ class StoreOutputBase {
435
443
  }
436
444
  ensureIdentity() {
437
445
  if (this.disposed)
438
- return TISTORE_ERROR_NOT_INITIALIZED;
446
+ return TI_CLOUD_STORAGE_ERROR_NOT_INITIALIZED;
439
447
  if (this.identity !== null)
440
448
  return this.identity;
441
449
  const result = normalizeCreateResult(this.create());
@@ -458,7 +466,7 @@ class StoreOutputBase {
458
466
  this.disposed = true;
459
467
  }
460
468
  }
461
- export class TiStoreAudioOutput extends StoreOutputBase {
469
+ export class TiCloudStorageAudioOutput extends TiCloudStorageOutputBase {
462
470
  constructor() {
463
471
  super(...arguments);
464
472
  this.currentState = 'idle';
@@ -466,65 +474,65 @@ export class TiStoreAudioOutput extends StoreOutputBase {
466
474
  this.onError = null;
467
475
  }
468
476
  create() {
469
- return NativeTiRtc.storeCreateAudioOutput();
477
+ return NativeTiRtc.tiCloudStorageCreateAudioOutput();
470
478
  }
471
479
  get state() {
472
480
  if (this.identity !== null)
473
- this.currentState = audioStateFromNative(NativeTiRtc.storeAudioOutputGetState(this.identity.objectId).state ?? this.currentState);
481
+ this.currentState = audioStateFromNative(NativeTiRtc.tiCloudStorageAudioOutputGetState(this.identity.objectId).state ?? this.currentState);
474
482
  return this.currentState;
475
483
  }
476
484
  attach(replay, channelId) {
477
485
  if (!isUInt8(channelId))
478
- return TISTORE_ERROR_INVALID_ARGUMENT;
486
+ return TI_CLOUD_STORAGE_ERROR_INVALID_ARGUMENT;
479
487
  const output = this.ensureIdentity();
480
488
  const replayId = nativeReplayIdentity(replay);
481
489
  if (typeof output === 'number')
482
490
  return output;
483
491
  if (typeof replayId === 'number')
484
492
  return replayId;
485
- const code = NativeTiRtc.storeAudioOutputAttach(output.objectId, replayId.objectId, channelId);
493
+ const code = NativeTiRtc.tiCloudStorageAudioOutputAttach(output.objectId, replayId.objectId, channelId);
486
494
  if (code === 0)
487
495
  this.bound = true;
488
- logStoreOutcome('audio_output_attach', code);
496
+ tiCloudStorageLogOutcome('audio_output_attach', code);
489
497
  return code;
490
498
  }
491
499
  setVolume(volumePercent) {
492
500
  if (!isFiniteSafeInteger(volumePercent) || volumePercent < 0 || volumePercent > 100)
493
- return TISTORE_ERROR_INVALID_ARGUMENT;
501
+ return TI_CLOUD_STORAGE_ERROR_INVALID_ARGUMENT;
494
502
  const output = this.ensureIdentity();
495
- return typeof output === 'number' ? output : NativeTiRtc.storeAudioOutputSetVolume(output.objectId, volumePercent);
503
+ return typeof output === 'number' ? output : NativeTiRtc.tiCloudStorageAudioOutputSetVolume(output.objectId, volumePercent);
496
504
  }
497
505
  detach() {
498
506
  if (this.identity === null)
499
507
  return 0;
500
- const code = NativeTiRtc.storeAudioOutputDetach(this.identity.objectId);
508
+ const code = NativeTiRtc.tiCloudStorageAudioOutputDetach(this.identity.objectId);
501
509
  if (code === 0) {
502
510
  this.bound = false;
503
- this.currentState = TiStoreAudioOutputState.idle;
511
+ this.currentState = TiCloudStorageAudioOutputState.idle;
504
512
  }
505
- logStoreOutcome('audio_output_detach', code);
513
+ tiCloudStorageLogOutcome('audio_output_detach', code);
506
514
  return code;
507
515
  }
508
516
  dispose() {
509
517
  if (this.disposed)
510
518
  return 0;
511
519
  if (this.bound)
512
- return TISTORE_ERROR_IN_USE;
520
+ return TI_CLOUD_STORAGE_ERROR_IN_USE;
513
521
  if (this.identity === null) {
514
522
  this.disposed = true;
515
- this.currentState = TiStoreAudioOutputState.idle;
523
+ this.currentState = TiCloudStorageAudioOutputState.idle;
516
524
  this.onStateChanged = null;
517
525
  this.onError = null;
518
526
  return 0;
519
527
  }
520
- const code = NativeTiRtc.storeAudioOutputDispose(this.identity.objectId);
528
+ const code = NativeTiRtc.tiCloudStorageAudioOutputDispose(this.identity.objectId);
521
529
  if (code === 0) {
522
530
  this.releaseIdentity();
523
- this.currentState = TiStoreAudioOutputState.idle;
531
+ this.currentState = TiCloudStorageAudioOutputState.idle;
524
532
  this.onStateChanged = null;
525
533
  this.onError = null;
526
534
  }
527
- logStoreOutcome('audio_output_dispose', code);
535
+ tiCloudStorageLogOutcome('audio_output_dispose', code);
528
536
  return code;
529
537
  }
530
538
  handleEvent(event) {
@@ -533,10 +541,10 @@ export class TiStoreAudioOutput extends StoreOutputBase {
533
541
  this.onStateChanged?.(this.currentState);
534
542
  }
535
543
  else if (event.type === 'audioOutputError')
536
- this.onError?.(event.code ?? TISTORE_ERROR_IO_FAILED);
544
+ this.onError?.(event.code ?? TI_CLOUD_STORAGE_ERROR_IO_FAILED);
537
545
  }
538
546
  }
539
- export class TiStoreVideoOutput extends StoreOutputBase {
547
+ export class TiCloudStorageVideoOutput extends TiCloudStorageOutputBase {
540
548
  constructor() {
541
549
  super(...arguments);
542
550
  this.currentState = 'idle';
@@ -544,41 +552,41 @@ export class TiStoreVideoOutput extends StoreOutputBase {
544
552
  this.onError = null;
545
553
  }
546
554
  create() {
547
- return NativeTiRtc.storeCreateVideoOutput();
555
+ return NativeTiRtc.tiCloudStorageCreateVideoOutput();
548
556
  }
549
557
  get state() {
550
558
  if (this.identity !== null)
551
- this.currentState = videoStateFromNative(NativeTiRtc.storeVideoOutputGetState(this.identity.objectId).state ?? this.currentState);
559
+ this.currentState = videoStateFromNative(NativeTiRtc.tiCloudStorageVideoOutputGetState(this.identity.objectId).state ?? this.currentState);
552
560
  return this.currentState;
553
561
  }
554
562
  view(props = {}) {
555
563
  this.ensureIdentity();
556
- return React.createElement(TiStoreVideoOutputView, {
564
+ return React.createElement(TiCloudStorageVideoOutputView, {
557
565
  ...props,
558
566
  output: this,
559
567
  });
560
568
  }
561
569
  attach(replay, channelId) {
562
570
  if (!isUInt8(channelId))
563
- return TISTORE_ERROR_INVALID_ARGUMENT;
571
+ return TI_CLOUD_STORAGE_ERROR_INVALID_ARGUMENT;
564
572
  const output = this.ensureIdentity();
565
573
  const replayId = nativeReplayIdentity(replay);
566
574
  if (typeof output === 'number')
567
575
  return output;
568
576
  if (typeof replayId === 'number')
569
577
  return replayId;
570
- const code = NativeTiRtc.storeVideoOutputAttach(output.objectId, replayId.objectId, channelId);
578
+ const code = NativeTiRtc.tiCloudStorageVideoOutputAttach(output.objectId, replayId.objectId, channelId);
571
579
  if (code === 0)
572
580
  this.bound = true;
573
- logStoreOutcome('video_output_attach', code);
581
+ tiCloudStorageLogOutcome('video_output_attach', code);
574
582
  return code;
575
583
  }
576
584
  async takeSnapshot() {
577
585
  const output = this.ensureIdentity();
578
586
  if (typeof output === 'number')
579
587
  return recordingFailure(output);
580
- const result = await NativeTiRtc.storeVideoOutputTakeSnapshot(output.objectId);
581
- logStoreOutcome('snapshot', result.code);
588
+ const result = await NativeTiRtc.tiCloudStorageVideoOutputTakeSnapshot(output.objectId);
589
+ tiCloudStorageLogOutcome('snapshot', result.code);
582
590
  return result.code === 0 && result.fileId !== null && result.filePath !== null
583
591
  ? success(new SnapshotFile(result.filePath, result.fileId))
584
592
  : recordingFailure(result.code);
@@ -586,34 +594,34 @@ export class TiStoreVideoOutput extends StoreOutputBase {
586
594
  detach() {
587
595
  if (this.identity === null)
588
596
  return 0;
589
- const code = NativeTiRtc.storeVideoOutputDetach(this.identity.objectId);
597
+ const code = NativeTiRtc.tiCloudStorageVideoOutputDetach(this.identity.objectId);
590
598
  if (code === 0) {
591
599
  this.bound = false;
592
- this.currentState = TiStoreVideoOutputState.idle;
600
+ this.currentState = TiCloudStorageVideoOutputState.idle;
593
601
  }
594
- logStoreOutcome('video_output_detach', code);
602
+ tiCloudStorageLogOutcome('video_output_detach', code);
595
603
  return code;
596
604
  }
597
605
  dispose() {
598
606
  if (this.disposed)
599
607
  return 0;
600
608
  if (this.bound)
601
- return TISTORE_ERROR_IN_USE;
609
+ return TI_CLOUD_STORAGE_ERROR_IN_USE;
602
610
  if (this.identity === null) {
603
611
  this.disposed = true;
604
- this.currentState = TiStoreVideoOutputState.idle;
612
+ this.currentState = TiCloudStorageVideoOutputState.idle;
605
613
  this.onStateChanged = null;
606
614
  this.onError = null;
607
615
  return 0;
608
616
  }
609
- const code = NativeTiRtc.storeVideoOutputDispose(this.identity.objectId);
617
+ const code = NativeTiRtc.tiCloudStorageVideoOutputDispose(this.identity.objectId);
610
618
  if (code === 0) {
611
619
  this.releaseIdentity();
612
- this.currentState = TiStoreVideoOutputState.idle;
620
+ this.currentState = TiCloudStorageVideoOutputState.idle;
613
621
  this.onStateChanged = null;
614
622
  this.onError = null;
615
623
  }
616
- logStoreOutcome('video_output_dispose', code);
624
+ tiCloudStorageLogOutcome('video_output_dispose', code);
617
625
  return code;
618
626
  }
619
627
  handleEvent(event) {
@@ -622,10 +630,10 @@ export class TiStoreVideoOutput extends StoreOutputBase {
622
630
  this.onStateChanged?.(this.currentState);
623
631
  }
624
632
  else if (event.type === 'videoOutputError')
625
- this.onError?.(event.code ?? TISTORE_ERROR_IO_FAILED);
633
+ this.onError?.(event.code ?? TI_CLOUD_STORAGE_ERROR_IO_FAILED);
626
634
  }
627
635
  }
628
- export function TiStoreVideoOutputView(props) {
636
+ export function TiCloudStorageVideoOutputView(props) {
629
637
  const { output, resizeMode = 'contain', ...viewProps } = props;
630
638
  const identity = useOwnerIdentity(output);
631
639
  return identity === null
@@ -642,7 +650,7 @@ function useOwnerIdentity(owner) {
642
650
  React.useEffect(() => subscribeNativeIdentity(owner, update), [owner]);
643
651
  return readNativeIdentity(owner);
644
652
  }
645
- export class TiStoreRecordingTask {
653
+ export class TiCloudStorageRecordingTask {
646
654
  constructor(taskId, owner) {
647
655
  this.taskId = taskId;
648
656
  this.owner = owner;
@@ -650,21 +658,21 @@ export class TiStoreRecordingTask {
650
658
  }
651
659
  stop() {
652
660
  void this.owner;
653
- return (this.stopPromise ?? (this.stopPromise = NativeTiRtc.storeRecordingTaskStop(this.taskId).then((result) => {
654
- logStoreOutcome('replay_recording_stop', result.code, ` duration_ms=${result.durationMs ?? 0}`);
661
+ return (this.stopPromise ?? (this.stopPromise = NativeTiRtc.tiCloudStorageRecordingTaskStop(this.taskId).then((result) => {
662
+ tiCloudStorageLogOutcome('replay_recording_stop', result.code, ` duration_ms=${result.durationMs ?? 0}`);
655
663
  return result.code === 0 && result.fileId !== null && result.filePath !== null && result.durationMs !== null
656
664
  ? success(new RecordingFile(result.filePath, result.durationMs, result.fileId))
657
665
  : recordingFailure(result.code);
658
666
  })));
659
667
  }
660
668
  }
661
- export class TiStoreExportTask {
669
+ export class TiCloudStorageExportTask {
662
670
  constructor(taskId, owner, onProgress) {
663
671
  this.taskId = taskId;
664
672
  this.owner = owner;
665
673
  this.onProgress = onProgress;
666
- this.resultPromise = NativeTiRtc.storeExportResult(taskId).then((result) => {
667
- logStoreOutcome('export_terminal', result.code, ` duration_ms=${result.durationMs ?? 0}`);
674
+ this.resultPromise = NativeTiRtc.tiCloudStorageExportResult(taskId).then((result) => {
675
+ tiCloudStorageLogOutcome('export_terminal', result.code, ` duration_ms=${result.durationMs ?? 0}`);
668
676
  return result.code === 0 && result.fileId !== null && result.filePath !== null && result.durationMs !== null
669
677
  ? success(new RecordingFile(result.filePath, result.durationMs, result.fileId))
670
678
  : recordingFailure(result.code);
@@ -672,7 +680,7 @@ export class TiStoreExportTask {
672
680
  if (onProgress !== undefined) {
673
681
  let lastProgress = -1;
674
682
  const timer = setInterval(() => {
675
- const progress = NativeTiRtc.storeExportProgress(taskId);
683
+ const progress = NativeTiRtc.tiCloudStorageExportProgress(taskId);
676
684
  if (progress !== lastProgress) {
677
685
  lastProgress = progress;
678
686
  onProgress(progress);
@@ -684,15 +692,15 @@ export class TiStoreExportTask {
684
692
  }
685
693
  get progress() {
686
694
  void this.owner;
687
- return NativeTiRtc.storeExportProgress(this.taskId);
695
+ return NativeTiRtc.tiCloudStorageExportProgress(this.taskId);
688
696
  }
689
697
  get result() {
690
698
  return this.resultPromise;
691
699
  }
692
700
  stop() {
693
- const code = NativeTiRtc.storeExportStop(this.taskId);
694
- logStoreOutcome('export_stop', code);
701
+ const code = NativeTiRtc.tiCloudStorageExportStop(this.taskId);
702
+ tiCloudStorageLogOutcome('export_stop', code);
695
703
  return this.resultPromise;
696
704
  }
697
705
  }
698
- //# sourceMappingURL=store.js.map
706
+ //# sourceMappingURL=storage.js.map