agora-rte-sdk 3.7.8 → 3.8.0-alpha

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 (71) hide show
  1. package/lib/constant.d.ts +2 -1
  2. package/lib/constant.js +26 -0
  3. package/lib/core/engine/ap-detector.js +2 -4
  4. package/lib/core/engine/index.d.ts +3 -0
  5. package/lib/core/engine/index.js +10 -4
  6. package/lib/core/media/camera.d.ts +1 -1
  7. package/lib/core/media/camera.js +15 -15
  8. package/lib/core/media/index.d.ts +8 -8
  9. package/lib/core/media/index.js +16 -16
  10. package/lib/core/media/loopback.d.ts +1 -1
  11. package/lib/core/media/loopback.js +15 -15
  12. package/lib/core/media/microphone.d.ts +1 -1
  13. package/lib/core/media/microphone.js +15 -15
  14. package/lib/core/media/screen.d.ts +1 -1
  15. package/lib/core/media/screen.js +15 -15
  16. package/lib/core/processor/synchronizer/synchronizer-manager.d.ts +4 -0
  17. package/lib/core/processor/synchronizer/synchronizer-manager.js +41 -10
  18. package/lib/core/rtc/channel.d.ts +8 -1
  19. package/lib/core/rtc/publisher.d.ts +7 -0
  20. package/lib/core/rtc/type.d.ts +13 -0
  21. package/lib/core/scene/index.d.ts +4 -2
  22. package/lib/core/scene/index.js +29 -17
  23. package/lib/core/scene/local-user.d.ts +7 -6
  24. package/lib/core/scene/local-user.js +12 -7
  25. package/lib/core/scene/stream-player.d.ts +1 -1
  26. package/lib/core/scene/stream-player.js +2 -2
  27. package/lib/core/scene/type.d.ts +10 -0
  28. package/lib/imports.d.ts +4 -1
  29. package/lib/imports.js +22 -1
  30. package/lib/plugin/monitor/index.js +15 -15
  31. package/lib/plugin/restful-client/index.d.ts +4 -2
  32. package/lib/plugin/restful-client/index.js +14 -7
  33. package/lib/plugin/rtc/electron/capture-enhancement.js +16 -4
  34. package/lib/plugin/rtc/electron/channel.d.ts +4 -1
  35. package/lib/plugin/rtc/electron/channel.js +31 -4
  36. package/lib/plugin/rtc/electron/client.js +25 -9
  37. package/lib/plugin/rtc/electron/publish-pool.d.ts +8 -1
  38. package/lib/plugin/rtc/electron/publish-pool.js +47 -49
  39. package/lib/plugin/rtc/electron/publisher.d.ts +7 -0
  40. package/lib/plugin/rtc/electron/publisher.js +143 -26
  41. package/lib/plugin/rtc/electron/source-manager.d.ts +4 -0
  42. package/lib/plugin/rtc/electron/source-manager.js +85 -36
  43. package/lib/plugin/rtc/electron/source-state-control/loopback-state-control.js +3 -1
  44. package/lib/plugin/rtc/electron/type.d.ts +10 -1
  45. package/lib/plugin/rtc/electron/type.js +6 -1
  46. package/lib/plugin/rtc/web/channel.d.ts +3 -1
  47. package/lib/plugin/rtc/web/channel.js +25 -2
  48. package/lib/plugin/rtc/web/client.d.ts +5 -0
  49. package/lib/plugin/rtc/web/client.js +30 -7
  50. package/lib/plugin/rtc/web/device.d.ts +8 -4
  51. package/lib/plugin/rtc/web/device.js +52 -9
  52. package/lib/plugin/rtc/web/publish-pool.d.ts +7 -0
  53. package/lib/plugin/rtc/web/publish-pool.js +43 -43
  54. package/lib/plugin/rtc/web/publish.d.ts +11 -10
  55. package/lib/plugin/rtc/web/publish.js +43 -19
  56. package/lib/plugin/rtc/web/publisher.d.ts +14 -2
  57. package/lib/plugin/rtc/web/publisher.js +136 -6
  58. package/lib/plugin/rtc/web/source-manager.d.ts +4 -2
  59. package/lib/plugin/rtc/web/source-manager.js +52 -34
  60. package/lib/plugin/rtc/web/track-control/camera.d.ts +1 -0
  61. package/lib/plugin/rtc/web/track-control/camera.js +20 -3
  62. package/lib/plugin/rtc/web/track-control/microphone.d.ts +6 -3
  63. package/lib/plugin/rtc/web/track-control/microphone.js +209 -79
  64. package/lib/plugin/rtc/web/track-control/screen.js +19 -14
  65. package/lib/plugin/rtc/web/type.d.ts +10 -0
  66. package/lib/plugin/rtc/web/utils.d.ts +4 -0
  67. package/lib/plugin/rtc/web/utils.js +7 -2
  68. package/lib/plugin/rtm/client.js +5 -8
  69. package/lib/plugin/rtm/index.js +1 -1
  70. package/lib/type.d.ts +1 -1
  71. package/package.json +4 -4
@@ -63,15 +63,13 @@ var AgoraRteSynchronizerManager = exports.AgoraRteSynchronizerManager = /*#__PUR
63
63
  }, {
64
64
  key: "release",
65
65
  value: function release() {
66
- if (this._worker) {
67
- this._worker.terminate();
68
- this._worker = undefined;
69
- }
66
+ this.cleanupWorker();
70
67
  }
71
68
  }, {
72
69
  key: "initWorker",
73
70
  value: function initWorker() {
74
71
  try {
72
+ console.log('initWorker');
75
73
  // 创建worker实例
76
74
  this._worker = (0, _imports.getAgoraRteSynchronizerWorker)();
77
75
  this._worker.addEventListener('message', this.handleWorkerMessage.bind(this));
@@ -155,7 +153,42 @@ var AgoraRteSynchronizerManager = exports.AgoraRteSynchronizerManager = /*#__PUR
155
153
  }, {
156
154
  key: "handleWorkerError",
157
155
  value: function handleWorkerError(error) {
158
- this.logger.error("Worker error: ".concat(error.message), error);
156
+ // 如果worker正在终止或已经切换到主线程,不处理错误
157
+ if (this._useMainThread) {
158
+ this.logger.debug('Worker error ignored - worker is terminating or already using main thread');
159
+ return;
160
+ }
161
+
162
+ // 在测试环境中,ErrorEvent的属性可能为undefined,需要提供默认值
163
+ var errorMessage = error.message || 'Unknown worker error';
164
+ var errorDetails = {
165
+ message: error.message,
166
+ filename: error.filename,
167
+ lineno: error.lineno,
168
+ colno: error.colno,
169
+ isTrusted: error.isTrusted
170
+ };
171
+ this.logger.error("Worker error: ".concat(errorMessage), errorDetails);
172
+ if (!error.message && !error.filename) {
173
+ this.cleanupWorker();
174
+ this.fallbackToMainThread();
175
+ }
176
+ }
177
+
178
+ /**
179
+ * 清理worker资源
180
+ */
181
+ }, {
182
+ key: "cleanupWorker",
183
+ value: function cleanupWorker() {
184
+ if (this._worker) {
185
+ this._worker.removeEventListener('message', this.handleWorkerMessage.bind(this));
186
+ this._worker.removeEventListener('error', this.handleWorkerError.bind(this));
187
+
188
+ // 终止worker
189
+ this._worker.terminate();
190
+ this._worker = undefined;
191
+ }
159
192
  }
160
193
  }, {
161
194
  key: "handleTaskReady",
@@ -377,15 +410,13 @@ var AgoraRteSynchronizerManager = exports.AgoraRteSynchronizerManager = /*#__PUR
377
410
  value: function destroy() {
378
411
  // 清理队列
379
412
  this._messageQueue = [];
380
- if (this._worker) {
381
- this._worker.terminate();
382
- this._worker = undefined;
383
- }
413
+ this.cleanupWorker();
384
414
  if (this._fallbackSynchronizer) {
385
415
  this._fallbackSynchronizer.destroy();
386
416
  this._fallbackSynchronizer = undefined;
387
417
  }
388
418
  this._isReady = false;
419
+ this._useMainThread = false;
389
420
  }
390
421
  }, {
391
422
  key: "postMessage",
@@ -394,7 +425,7 @@ var AgoraRteSynchronizerManager = exports.AgoraRteSynchronizerManager = /*#__PUR
394
425
  // 使用回退同步器
395
426
  this.handleMainThreadMessage(message);
396
427
  } else if (this._worker && this._isReady) {
397
- this.logger.debug('Sending message to worker:', message.type);
428
+ this.logger.debug('Sending message to worker:', message.type, '_sceneId', this._sceneId);
398
429
  this._worker.postMessage(message);
399
430
  } else {
400
431
  // worker not ready, queue message
@@ -55,6 +55,13 @@ export declare abstract class AgoraRtcChannelClient {
55
55
  * @returns The result of the operation.
56
56
  */
57
57
  abstract setVideoEncoderConfig(config: AgoraRtcVideoEncoderConfiguration, streamType: AgoraRtcVideoStreamType, streamId: string): number;
58
+ /**
59
+ * Sets the dual stream mode for a local stream.
60
+ * @param streamId The ID of the stream.
61
+ * @param enable Whether to enable dual stream mode.
62
+ * @returns The result of the operation.
63
+ */
64
+ abstract setDualStreamMode(streamId: string, enable: boolean): number;
58
65
  /**
59
66
  * Starts rendering a remote video stream on a canvas.
60
67
  * @param streamId The ID of the stream.
@@ -64,7 +71,7 @@ export declare abstract class AgoraRtcChannelClient {
64
71
  * @param isMirror Whether to mirror the video.
65
72
  * @returns The result of the operation.
66
73
  */
67
- abstract startRenderRemoteVideoStream(streamId: string, view: AgoraRteRenderView, streamType: AgoraRtcVideoStreamType, renderMode: AgoraRtcRenderMode, isMirror: boolean): number;
74
+ abstract startRenderRemoteVideoStream(streamId: string, view: AgoraRteRenderView, renderMode: AgoraRtcRenderMode, isMirror: boolean): number;
68
75
  /**
69
76
  * Starts rendering a remote video stream on all canvases.
70
77
  * @param streamId The ID of the stream.
@@ -52,6 +52,13 @@ export declare abstract class AgoraRtcChannelPublisher {
52
52
  * @returns number
53
53
  */
54
54
  abstract setVideoEncoderConfig(config: AgoraRtcVideoEncoderConfiguration, streamType: AgoraRtcVideoStreamType, streamId: string): number;
55
+ /**
56
+ * set dual stream mode
57
+ * @param streamId The ID of the stream.
58
+ * @param enable Whether to enable dual stream mode.
59
+ * @returns The result of the operation.
60
+ */
61
+ abstract setDualStreamMode(streamId: string, enable: boolean): number;
55
62
  /**
56
63
  * set screen scenario.
57
64
  * @param type The type of the scenario.
@@ -98,6 +98,8 @@ export declare enum AgoraRtcCameraPosition {
98
98
  export type AgoraRtcDeviceInfo = {
99
99
  deviceId: string;
100
100
  deviceName: string;
101
+ vendorId?: string;
102
+ productId?: string;
101
103
  };
102
104
  export type AgoraRtcDisplayInfo = {
103
105
  id: string;
@@ -348,6 +350,7 @@ export type AgoraRtcChannelClientObserver = {
348
350
  onRemoteAudioStatsUpdated?(channelId: string, streamId: string, stats: AgoraRtcRemoteAudioStats): void;
349
351
  onFirstRemoteVideoFrameRendered?(channelId: string, streamId: string): void;
350
352
  onConnectionStateUpdated?(channelId: string, state: AgoraRtcConnectionState): void;
353
+ onStreamMessageReceived?(sceneId: string, data: AgoraRtcStreamMessage): void;
351
354
  } & AgoraRtcPlayAudioRawDataObserver;
352
355
  export declare enum AgoraRtcRegion {
353
356
  AREA_GLOBAL = "AREA_GLOBAL",
@@ -376,6 +379,7 @@ export type AgoraRtcConnection = {
376
379
  localUid: number;
377
380
  };
378
381
  export type AgoraRtcStreamPublishPoolObserver = {
382
+ onConnectionSetVideoEncoderConfig?(item: AgoraRtcStreamPublishPoolItem): void;
379
383
  onConnectionJoinChannel?(item: AgoraRtcStreamPublishPoolItem): void;
380
384
  onUpdateChannelOptions?(item: AgoraRtcStreamPublishPoolItem): void;
381
385
  onConnectionLeaveChannel?(item: AgoraRtcStreamPublishPoolItem): void;
@@ -470,3 +474,12 @@ export interface AgoraRtcDiffList {
470
474
  export interface AgoraRtcChannelPublisherObserver {
471
475
  onLocalVideoStatsUpdated?(stats: AgoraRtcLocalVideoStats): void;
472
476
  }
477
+ export type AgoraRtcStreamMessage = {
478
+ streamId: string;
479
+ payload: Uint8Array;
480
+ };
481
+ export type AgoraRtcDefaultCameraStreamConfig = {
482
+ dimensions: AgoraRtcDimensions;
483
+ frameRate: number;
484
+ bitrate: number;
485
+ };
@@ -30,10 +30,12 @@ export declare class AgoraRteScene {
30
30
  onNetworkQualityUpdated: (sceneId: string, event: import("./type").AgoraRteNetworkQualityEvent) => void;
31
31
  onNetworkStatsUpdated: (sceneId: string, networkStats: import("../rtc/type").AgoraRtcNetworkStats) => void;
32
32
  onFirstRemoteVideoFrameRendered(sceneId: string, streamId: string): void;
33
+ onStreamMessageReceived: (sceneId: string, data: import("./type").AgoraRteStreamMessage) => void;
33
34
  }>>;
34
35
  private _sceneId;
35
36
  private _sceneInfo?;
36
37
  private _localUser?;
38
+ private _messageUserId;
37
39
  private _apiService;
38
40
  private _rtmClient;
39
41
  private _rtmChannelClient?;
@@ -41,7 +43,8 @@ export declare class AgoraRteScene {
41
43
  private _apDetector;
42
44
  private _rtcMainChannelClient?;
43
45
  private _stateSynchronizer?;
44
- private _messageSynchronizer;
46
+ private _messageSynchronizer?;
47
+ private _messageHandlerObservers?;
45
48
  private _streamPlayer?;
46
49
  private _timestampGap;
47
50
  private _totalUserCount;
@@ -53,7 +56,6 @@ export declare class AgoraRteScene {
53
56
  private _localScreenCaptureStateMap;
54
57
  private _localLoopbackStateMap;
55
58
  private _deviceStateSyncTimer?;
56
- private _messageHandlerObservers;
57
59
  private _deviceSyncMutex;
58
60
  private _connectionState;
59
61
  private _rtmObserver;
@@ -155,14 +155,8 @@ var AgoraRteScene = exports.AgoraRteScene = /*#__PURE__*/function () {
155
155
  this._rtcClient = options.rtcClient;
156
156
  this._apDetector = options.apDetector;
157
157
  this._apiService = options.apiService;
158
+ this._messageUserId = options.userId;
158
159
  this._handleConnectionStateUpdated = this._handleConnectionStateUpdated.bind(this);
159
- this._messageSynchronizer = new _messageHandler.AgoraRteMessageHandle({
160
- sceneId: this.sceneId,
161
- apiService: this._apiService,
162
- rtmClient: this._rtmClient,
163
- userId: options.userId
164
- });
165
- this._messageHandlerObservers = this._getChannelMessageEventListeners();
166
160
  this._rtcClient.sourceManager.getCameraList().then(function (deviceList) {
167
161
  deviceList.forEach(function (_ref) {
168
162
  var deviceId = _ref.deviceId;
@@ -217,6 +211,9 @@ var AgoraRteScene = exports.AgoraRteScene = /*#__PURE__*/function () {
217
211
  }, {
218
212
  key: "dataStore",
219
213
  get: function get() {
214
+ if (!this._messageSynchronizer) {
215
+ throw (0, _error2.generateRteClientError)(_error2.AgoraRteModuleErrorCode.SCENE, _error2.AgoraRteErrorCode.NOT_JOINED_ROOM, 'message synchronizer not exist, please join scene first', new Error('message synchronizer not exist, please join scene first'));
216
+ }
220
217
  return this._messageSynchronizer.dataStore;
221
218
  }
222
219
  }, {
@@ -280,11 +277,19 @@ var AgoraRteScene = exports.AgoraRteScene = /*#__PURE__*/function () {
280
277
  function () {
281
278
  var _join = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee2(options) {
282
279
  var _this3 = this;
283
- var rteError, _rteError, isJoinStopped, handleJoinAborted, _yield$to, _yield$to2, error;
280
+ var messageSynchronizer, rteError, _rteError, isJoinStopped, handleJoinAborted, _yield$to, _yield$to2, error;
284
281
  return _regenerator["default"].wrap(function (_context2) {
285
282
  while (1) switch (_context2.prev = _context2.next) {
286
283
  case 0:
287
284
  this._joinState = JOIN_STATE.JOINING;
285
+ messageSynchronizer = new _messageHandler.AgoraRteMessageHandle({
286
+ sceneId: this.sceneId,
287
+ apiService: this._apiService,
288
+ rtmClient: this._rtmClient,
289
+ userId: this._messageUserId
290
+ });
291
+ this._messageSynchronizer = messageSynchronizer;
292
+ this._messageHandlerObservers = this._getChannelMessageEventListeners();
288
293
  if (!this._joinSuccess) {
289
294
  _context2.next = 1;
290
295
  break;
@@ -384,9 +389,9 @@ var AgoraRteScene = exports.AgoraRteScene = /*#__PURE__*/function () {
384
389
  _this3._streamPlayer = new _streamPlayer.AgoraRteStreamPlayer(rtcChannelClient);
385
390
  _this3._localUser = new _localUser.AgoraRteLocalUser(localUser.userUuid, rtcChannelClient, _this3.sceneId, _this3.apiService);
386
391
  _this3._stateSynchronizer = new _stateSync.AgoraRteConnectionSynchronizer(sysConfig.onlineStateEnsureDelay || DEFAULT_ONLINE_STATE_ENSURE_DELAY, localUser.userUuid, _this3.sceneId, _this3.apiService);
387
- _this3._messageSynchronizer.setUserId(localUser.userUuid);
388
- _this3._messageSynchronizer.setRtmChannelClient(_this3._rtmChannelClient);
389
- _this3._messageSynchronizer.syncSnapshot(_struct.AgoraRteSyncSnapshotData.fromData(_objectSpread({
392
+ messageSynchronizer.setUserId(localUser.userUuid);
393
+ messageSynchronizer.setRtmChannelClient(_this3._rtmChannelClient);
394
+ messageSynchronizer.syncSnapshot(_struct.AgoraRteSyncSnapshotData.fromData(_objectSpread({
390
395
  users: [localUser].concat((0, _toConsumableArray2["default"])(remoteUsers))
391
396
  }, room)), room.sequence, localUser.sequence);
392
397
  _this3._startDeviceStateSync();
@@ -938,6 +943,9 @@ var AgoraRteScene = exports.AgoraRteScene = /*#__PURE__*/function () {
938
943
  this._rtcMainChannelClient.addObserver({
939
944
  onConnectionStateUpdated: function onConnectionStateUpdated(channelId, state) {
940
945
  _this6._handleConnectionStateUpdated(state, options.streamUuid, options.token);
946
+ },
947
+ onStreamMessageReceived: function onStreamMessageReceived(sceneId, data) {
948
+ _this6.observable.notifyObservers('onStreamMessageReceived', sceneId, data);
941
949
  }
942
950
  });
943
951
  _context0.next = 3;
@@ -1126,9 +1134,9 @@ var AgoraRteScene = exports.AgoraRteScene = /*#__PURE__*/function () {
1126
1134
  } else {
1127
1135
  (_this7$rtcMainChannel2 = _this7.rtcMainChannelClient) === null || _this7$rtcMainChannel2 === void 0 || _this7$rtcMainChannel2.publisher.unpublishLocalAudioStream(stream.streamId, stream.audioSourceType);
1128
1136
  }
1129
- if (!streamToken && (stream.videoSourceType === _type2.AgoraRtcVideoSourceType.SCREEN || stream.audioSourceType === _type2.AgoraRtcAudioSourceType.LOOPBACK)) {
1137
+ if (!streamToken) {
1130
1138
  observer = {
1131
- onShareStreamTokenUpdated: function onShareStreamTokenUpdated(streamId, token) {
1139
+ onStreamTokenUpdated: function onStreamTokenUpdated(streamId, token) {
1132
1140
  _this7.logger.info("republish stream after token updated streamId: ".concat(streamId));
1133
1141
  if (streamId === stream.streamId) {
1134
1142
  if (shouldPublishAudio) {
@@ -1142,7 +1150,7 @@ var AgoraRteScene = exports.AgoraRteScene = /*#__PURE__*/function () {
1142
1150
  _this7.localUser.removeObserver(observer);
1143
1151
  }
1144
1152
  },
1145
- onShareStreamTokenRemoved: function onShareStreamTokenRemoved() {
1153
+ onStreamTokenRemoved: function onStreamTokenRemoved() {
1146
1154
  _this7.localUser.removeObserver(observer);
1147
1155
  }
1148
1156
  };
@@ -1728,13 +1736,17 @@ var AgoraRteScene = exports.AgoraRteScene = /*#__PURE__*/function () {
1728
1736
  key: "_cleanup",
1729
1737
  value: function _cleanup() {
1730
1738
  var _this$_stateSynchroni3;
1731
- this._messageSynchronizer.removeObserver(this._messageHandlerObservers);
1732
- this._messageSynchronizer.stop();
1733
1739
  (_this$_stateSynchroni3 = this._stateSynchronizer) === null || _this$_stateSynchroni3 === void 0 || _this$_stateSynchroni3.stop();
1734
1740
  this._stopDeviceStateSync();
1735
1741
  this._localUser = undefined;
1736
1742
  this._streamPlayer = undefined;
1737
- this._messageSynchronizer.release();
1743
+ if (this._messageSynchronizer) {
1744
+ if (this._messageHandlerObservers) {
1745
+ this._messageSynchronizer.removeObserver(this._messageHandlerObservers);
1746
+ }
1747
+ this._messageSynchronizer.stop();
1748
+ this._messageSynchronizer.release();
1749
+ }
1738
1750
  try {
1739
1751
  return Promise.all([this._leaveRTCChannel(), this._leaveRTMChannel()]);
1740
1752
  } finally {
@@ -6,8 +6,8 @@ import { AgoraObservable } from '../../imports';
6
6
  import { AgoraRtcVideoStreamType } from '../rtc/type';
7
7
  import { AgoraRtcChannelClient } from '../rtc';
8
8
  export type AgoraRteLocalUserObserver = Partial<{
9
- onShareStreamTokenUpdated: (streamId: string, token: string) => void;
10
- onShareStreamTokenRemoved: () => void;
9
+ onStreamTokenUpdated: (streamId: string, token: string) => void;
10
+ onStreamTokenRemoved: () => void;
11
11
  }>;
12
12
  export declare class AgoraRteLocalUser {
13
13
  private _rtcChannelClient;
@@ -17,8 +17,8 @@ export declare class AgoraRteLocalUser {
17
17
  private readonly _streamIdTokenMap;
18
18
  private readonly _userId;
19
19
  protected readonly observable: AgoraObservable<Partial<{
20
- onShareStreamTokenUpdated: (streamId: string, token: string) => void;
21
- onShareStreamTokenRemoved: () => void;
20
+ onStreamTokenUpdated: (streamId: string, token: string) => void;
21
+ onStreamTokenRemoved: () => void;
22
22
  }>>;
23
23
  constructor(userId: string, _rtcChannelClient: AgoraRtcChannelClient, _fromSceneId: string, _apiService: AgoraRteServiceApi);
24
24
  /**
@@ -99,8 +99,9 @@ export declare class AgoraRteLocalUser {
99
99
  * @returns The result of the operation.
100
100
  */
101
101
  setVideoEncoderConfig(config: AgoraRteVideoEncoderConfig, streamType: AgoraRtcVideoStreamType, streamId: string): void;
102
- prepareToPublishScreenStream(streamId: string, token: string): void;
103
- removePreparePublishScreenStream(streamId: string): void;
102
+ setDualStreamMode(streamId: string, enable: boolean): number;
103
+ prepareToPublishStream(streamId: string, token: string): void;
104
+ removePreparePublishStream(streamId: string): void;
104
105
  setScreenScenario(type: AgoraRteScreenScenarioType): void;
105
106
  getStreamTokenByStreamId(streamId: string): any;
106
107
  addObserver(observer: AgoraRteLocalUserObserver): void;
@@ -407,16 +407,21 @@ var AgoraRteLocalUser = exports.AgoraRteLocalUser = /*#__PURE__*/function () {
407
407
  this._rtcChannelClient.setVideoEncoderConfig(config, streamType, streamId);
408
408
  }
409
409
  }, {
410
- key: "prepareToPublishScreenStream",
411
- value: function prepareToPublishScreenStream(streamId, token) {
410
+ key: "setDualStreamMode",
411
+ value: function setDualStreamMode(streamId, enable) {
412
+ return this._rtcChannelClient.setDualStreamMode(streamId, enable);
413
+ }
414
+ }, {
415
+ key: "prepareToPublishStream",
416
+ value: function prepareToPublishStream(streamId, token) {
412
417
  this._streamIdTokenMap.set(streamId, token);
413
- this.observable.notifyObservers('onShareStreamTokenUpdated', streamId, token);
418
+ this.observable.notifyObservers('onStreamTokenUpdated', streamId, token);
414
419
  }
415
420
  }, {
416
- key: "removePreparePublishScreenStream",
417
- value: function removePreparePublishScreenStream(streamId) {
421
+ key: "removePreparePublishStream",
422
+ value: function removePreparePublishStream(streamId) {
418
423
  this._streamIdTokenMap["delete"](streamId);
419
- this.observable.notifyObservers('onShareStreamTokenRemoved');
424
+ this.observable.notifyObservers('onStreamTokenRemoved');
420
425
  }
421
426
  }, {
422
427
  key: "setScreenScenario",
@@ -441,7 +446,7 @@ var AgoraRteLocalUser = exports.AgoraRteLocalUser = /*#__PURE__*/function () {
441
446
  }]);
442
447
  }();
443
448
  _AgoraRteLocalUser = AgoraRteLocalUser;
444
- var _applyDecs$e = _applyDecs(_AgoraRteLocalUser, [[_imports.trace, 2, "sendSceneMessage"], [_imports.trace, 2, "updateSceneProperties"], [_imports.trace, 2, "deleteSceneProperties"], [_imports.trace, 2, "updateUserProperties"], [_imports.trace, 2, "deleteUserProperties"], [_imports.trace, 2, "addLocalStreams"], [_imports.trace, 2, "bindLocalStreams"], [_imports.trace, 2, "removeStreams"], [_imports.trace, 2, "updatePublishPrivilegeOfStreams"], [_imports.trace, 2, "setVideoEncoderConfig"], [_imports.trace, 2, "prepareToPublishScreenStream"], [_imports.trace, 2, "removePreparePublishScreenStream"], [_imports.trace, 2, "setScreenScenario"]], []).e;
449
+ var _applyDecs$e = _applyDecs(_AgoraRteLocalUser, [[_imports.trace, 2, "sendSceneMessage"], [_imports.trace, 2, "updateSceneProperties"], [_imports.trace, 2, "deleteSceneProperties"], [_imports.trace, 2, "updateUserProperties"], [_imports.trace, 2, "deleteUserProperties"], [_imports.trace, 2, "addLocalStreams"], [_imports.trace, 2, "bindLocalStreams"], [_imports.trace, 2, "removeStreams"], [_imports.trace, 2, "updatePublishPrivilegeOfStreams"], [_imports.trace, 2, "setVideoEncoderConfig"], [_imports.trace, 2, "setDualStreamMode"], [_imports.trace, 2, "prepareToPublishStream"], [_imports.trace, 2, "removePreparePublishStream"], [_imports.trace, 2, "setScreenScenario"]], []).e;
445
450
  var _applyDecs$e2 = (0, _slicedToArray2["default"])(_applyDecs$e, 1);
446
451
  _initProto = _applyDecs$e2[0];
447
452
  _applyDecs$e;
@@ -29,7 +29,7 @@ export declare class AgoraRteStreamPlayer {
29
29
  * @param isMirror
30
30
  * @param view
31
31
  */
32
- startRenderRemoteVideoStream(streamId: string, streamType: AgoraRteVideoStreamType, renderMode: AgoraRteVideoRenderMode, isMirror: boolean, view: AgoraRteRenderView): void;
32
+ startRenderRemoteVideoStream(streamId: string, renderMode: AgoraRteVideoRenderMode, isMirror: boolean, view: AgoraRteRenderView): void;
33
33
  /**
34
34
  * Stop rendering the video of the remote user on the canvas.
35
35
  * @param streamId
@@ -107,8 +107,8 @@ var AgoraRteStreamPlayer = exports.AgoraRteStreamPlayer = /*#__PURE__*/function
107
107
  */
108
108
  }, {
109
109
  key: "startRenderRemoteVideoStream",
110
- value: function startRenderRemoteVideoStream(streamId, streamType, renderMode, isMirror, view) {
111
- this._rtcChannel.startRenderRemoteVideoStream(streamId, view, streamType, renderMode, isMirror);
110
+ value: function startRenderRemoteVideoStream(streamId, renderMode, isMirror, view) {
111
+ this._rtcChannel.startRenderRemoteVideoStream(streamId, view, renderMode, isMirror);
112
112
  }
113
113
  /**
114
114
  * Stop rendering the video of the remote user on the canvas.
@@ -337,6 +337,12 @@ export type AgoraRteSceneObserver = Partial<{
337
337
  * @param dimensions The dimensions of the first video frame.
338
338
  */
339
339
  onFirstRemoteVideoFrameRendered(sceneId: string, streamId: string): void;
340
+ /**
341
+ * Triggered when the stream message is received.
342
+ * @param sceneId The scene ID.
343
+ * @param data The stream message.
344
+ */
345
+ onStreamMessageReceived: (sceneId: string, data: AgoraRteStreamMessage) => void;
340
346
  }>;
341
347
  export type AgoraRteMediaStreamCreateConfig = {
342
348
  streamName: string;
@@ -429,3 +435,7 @@ export type ControlledPromise = {
429
435
  resolve: (value?: any) => void;
430
436
  reject: (reason?: any) => void;
431
437
  };
438
+ export type AgoraRteStreamMessage = {
439
+ streamId: string;
440
+ payload: Uint8Array;
441
+ };
package/lib/imports.d.ts CHANGED
@@ -11,6 +11,7 @@ export { isTrueValue } from 'agora-foundation/lib/utilities/value-check';
11
11
  export { readAsArrayBuffer } from 'agora-foundation/lib/utilities/file-reader';
12
12
  export { zipDir } from 'agora-foundation/lib/utilities/zip';
13
13
  export { retryAttempt } from 'agora-foundation/lib/utilities/async-retry';
14
+ export { generateLogObserver } from 'agora-foundation/lib/utilities/logger';
14
15
  export { AgoraScheduler } from 'agora-foundation/lib/schedule';
15
16
  export type { Task } from 'agora-foundation/lib/schedule';
16
17
  export { AgoraUploadScheduler } from 'agora-foundation/lib/upload';
@@ -24,7 +25,8 @@ import padEnd from 'lodash/padEnd';
24
25
  import keyBy from 'lodash/keyBy';
25
26
  import filter from 'lodash/filter';
26
27
  import isEqual from 'lodash/isEqual';
27
- export { get, toLower, padStart, cloneDeep, padEnd, keyBy, filter, isEqual };
28
+ import { isEmpty } from 'lodash';
29
+ export { get, toLower, padStart, cloneDeep, padEnd, keyBy, filter, isEqual, isEmpty };
28
30
  import Immutable from 'immutable';
29
31
  export { Immutable };
30
32
  import to from 'await-to-js';
@@ -36,3 +38,4 @@ export { createLogger } from 'agora-foundation/lib/logger';
36
38
  export { AgoraRteEngine } from './core/engine';
37
39
  export { fetch } from './core/utilities/fetch';
38
40
  export { type AgoraRteSynchronizerWorker, getAgoraRteSynchronizerWorker, } from './plugin/synchronizer-worker';
41
+ export { AgoraRequestScheduler } from 'agora-foundation/lib/restful-scheduler/scheduler';
package/lib/imports.js CHANGED
@@ -11,6 +11,12 @@ Object.defineProperty(exports, "AgoraObservable", {
11
11
  return _observable.AgoraObservable;
12
12
  }
13
13
  });
14
+ Object.defineProperty(exports, "AgoraRequestScheduler", {
15
+ enumerable: true,
16
+ get: function get() {
17
+ return _scheduler.AgoraRequestScheduler;
18
+ }
19
+ });
14
20
  Object.defineProperty(exports, "AgoraRestfulClientImpl", {
15
21
  enumerable: true,
16
22
  get: function get() {
@@ -89,6 +95,12 @@ Object.defineProperty(exports, "filter", {
89
95
  return _filter["default"];
90
96
  }
91
97
  });
98
+ Object.defineProperty(exports, "generateLogObserver", {
99
+ enumerable: true,
100
+ get: function get() {
101
+ return _logger2.generateLogObserver;
102
+ }
103
+ });
92
104
  Object.defineProperty(exports, "get", {
93
105
  enumerable: true,
94
106
  get: function get() {
@@ -125,6 +137,12 @@ Object.defineProperty(exports, "isElectron", {
125
137
  return _env.isElectron;
126
138
  }
127
139
  });
140
+ Object.defineProperty(exports, "isEmpty", {
141
+ enumerable: true,
142
+ get: function get() {
143
+ return _lodash.isEmpty;
144
+ }
145
+ });
128
146
  Object.defineProperty(exports, "isEqual", {
129
147
  enumerable: true,
130
148
  get: function get() {
@@ -238,6 +256,7 @@ var _valueCheck = require("agora-foundation/lib/utilities/value-check");
238
256
  var _fileReader = require("agora-foundation/lib/utilities/file-reader");
239
257
  var _zip = require("agora-foundation/lib/utilities/zip");
240
258
  var _asyncRetry = require("agora-foundation/lib/utilities/async-retry");
259
+ var _logger2 = require("agora-foundation/lib/utilities/logger");
241
260
  var _schedule = require("agora-foundation/lib/schedule");
242
261
  var _upload = require("agora-foundation/lib/upload");
243
262
  var _agoraError = require("agora-foundation/lib/utilities/agora-error");
@@ -249,10 +268,12 @@ var _padEnd = _interopRequireDefault(require("lodash/padEnd"));
249
268
  var _keyBy = _interopRequireDefault(require("lodash/keyBy"));
250
269
  var _filter = _interopRequireDefault(require("lodash/filter"));
251
270
  var _isEqual = _interopRequireDefault(require("lodash/isEqual"));
271
+ var _lodash = require("lodash");
252
272
  var _immutable = _interopRequireDefault(require("immutable"));
253
273
  var _awaitToJs = _interopRequireDefault(require("await-to-js"));
254
274
  var _restfulClient = require("./plugin/restful-client");
255
275
  var _hijack = require("agora-foundation/lib/logger/hijack");
256
276
  var _engine = require("./core/engine");
257
277
  var _fetch = require("./core/utilities/fetch");
258
- var _synchronizerWorker = require("./plugin/synchronizer-worker");
278
+ var _synchronizerWorker = require("./plugin/synchronizer-worker");
279
+ var _scheduler = require("agora-foundation/lib/restful-scheduler/scheduler");
@@ -129,7 +129,7 @@ var AgoraRteMonitorImpl = exports.AgoraRteMonitorImpl = /*#__PURE__*/function ()
129
129
  _context2.prev = 1;
130
130
  _this2.logger.info("start uploading logs, task: ".concat(taskId));
131
131
  if ((0, _imports.isElectron)()) {
132
- _context2.next = 4;
132
+ _context2.next = 3;
133
133
  break;
134
134
  }
135
135
  logManager = (0, _imports.getLogManager)();
@@ -144,18 +144,18 @@ var AgoraRteMonitorImpl = exports.AgoraRteMonitorImpl = /*#__PURE__*/function ()
144
144
  meta: meta
145
145
  });
146
146
  _this2.logger.info("add log upload task, task: ".concat(taskId, ", size: ").concat(consoleLogs.size, " bytes"));
147
- _context2.next = 3;
148
- return logManager.flush();
149
- case 3:
150
- _this2.logger.info("flush logs from db, task: ".concat(taskId));
151
- _context2.next = 6;
147
+
148
+ // await logManager.flush();
149
+
150
+ // this.logger.info(`flush logs from db, task: ${taskId}`);
151
+ _context2.next = 5;
152
152
  break;
153
- case 4:
153
+ case 3:
154
154
  path = window.require('path');
155
155
  logBasePath = path.resolve(window.require('@electron/remote').app.getPath('logs'), 'logs');
156
- _context2.next = 5;
156
+ _context2.next = 4;
157
157
  return (0, _imports.zipDir)(logBasePath, checkPrefix);
158
- case 5:
158
+ case 4:
159
159
  logs = _context2.sent;
160
160
  if (logs) {
161
161
  _this2.logger.info("compress logs, task: ".concat(taskId, ", path: ").concat(logBasePath, ", size: ").concat(logs.size, " bytes"));
@@ -168,18 +168,18 @@ var AgoraRteMonitorImpl = exports.AgoraRteMonitorImpl = /*#__PURE__*/function ()
168
168
  } else {
169
169
  _this2.logger.info("no logs to upload, task: ".concat(taskId));
170
170
  }
171
- case 6:
172
- _context2.next = 8;
171
+ case 5:
172
+ _context2.next = 7;
173
173
  break;
174
- case 7:
175
- _context2.prev = 7;
174
+ case 6:
175
+ _context2.prev = 6;
176
176
  _t = _context2["catch"](1);
177
177
  _this2.logger.error("failed to upload sdk logs, task: ".concat(taskId), _t);
178
- case 8:
178
+ case 7:
179
179
  case "end":
180
180
  return _context2.stop();
181
181
  }
182
- }, _callee2, null, [[1, 7]]);
182
+ }, _callee2, null, [[1, 6]]);
183
183
  }))));
184
184
  case 1:
185
185
  case "end":
@@ -1,17 +1,19 @@
1
1
  import { AgoraDomainHolder } from '../../core/services/domain-holder';
2
2
  import { AgoraFetchParams, AgoraHttpAuthHeadersProvider } from '../../core/services/type';
3
+ import { AgoraRequestScheduler } from '../../imports';
3
4
  export declare class AgoraRestfulClientImpl {
4
5
  private _authHeadersProvider;
5
6
  private _domainHolder;
7
+ private _requestScheduler;
6
8
  private _pathPrefix?;
7
9
  private _retryInterval;
8
10
  private _requestTimeout;
9
11
  private _defaultRetryTimes;
10
- constructor(_authHeadersProvider: AgoraHttpAuthHeadersProvider, _domainHolder: AgoraDomainHolder);
12
+ constructor(_authHeadersProvider: AgoraHttpAuthHeadersProvider, _domainHolder: AgoraDomainHolder, _requestScheduler: AgoraRequestScheduler);
11
13
  cloneWithUserCredential(userId: string, token: string): AgoraRestfulClientImpl;
12
14
  get host(): string;
13
15
  setPathPrefix(pathPrefix: string): void;
14
- fetch(params: AgoraFetchParams): Promise<void>;
16
+ fetch(params: AgoraFetchParams): Promise<unknown>;
15
17
  private _sendRequest;
16
18
  private _dispatchRequest;
17
19
  /**