agora-rte-sdk 3.8.0 → 3.8.1-beta

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.
@@ -32,6 +32,7 @@ export declare abstract class AgoraRtcCanvasTagPool {
32
32
  abstract getTagWithCanvasId(canvasAddress: AgoraRteRenderView): AgoraRtcCanvasTag | undefined;
33
33
  abstract addTagWithCanvasId(canvasAddress: AgoraRteRenderView, sourceId: string, canvas: AgoraRtcVideoCanvas, isLocal: boolean, connection?: AgoraRtcConnection): void;
34
34
  abstract ifNeedStopRenderCanvas(canvasAddress: AgoraRteRenderView): void;
35
+ abstract ifNeedStopLocalRenderCanvas(canvasAddress: AgoraRteRenderView): void;
35
36
  abstract stopRenderOnAllCanvasWithSourceId(sourceId: string): void;
36
37
  /**
37
38
  * 获取画布标签池
@@ -5,13 +5,13 @@ import { AgoraRteStreamPlayer } from './stream-player';
5
5
  import { AgoraRteLocalUser } from './local-user';
6
6
  import { AgoraRteServiceApi } from '../services/api';
7
7
  import { AgoraObservable, AgoraRteError } from '../../imports';
8
- import { AgoraRtcMediaSourceState, AgoraRtcScreenCaptureType } from '../rtc/type';
8
+ import { AgoraRtcMediaSourceState, AgoraRtcScreenCaptureType, AgoraRtcVideoSourceType } from '../rtc/type';
9
9
  export declare class AgoraRteScene {
10
10
  protected logger: import("agora-foundation/lib/logger/type").Logger;
11
11
  protected readonly observable: AgoraObservable<Partial<{
12
12
  onJoinSceneSuccess(sceneId: string, localUser: AgoraRteLocalUser, streamPlayer: AgoraRteStreamPlayer): void;
13
13
  onJoinSceneFailure(sceneId: string, error: AgoraRteError): void;
14
- onSceneMessageReceived(sceneId: string, message: import("../..").AgoraRteMessage): void;
14
+ onSceneMessageReceived(sceneId: string, message: import("../../type").AgoraRteMessage): void;
15
15
  onScenePropertiesUpdated(sceneId: string, event: import("./type").AgoraRteScenePropertiesUpdatedEvent): void;
16
16
  onScenePropertiesDeleted(sceneId: string, event: import("./type").AgoraRteScenePropertiesDeletedEvent): void;
17
17
  onUserPropertiesUpdated(sceneId: string, event: AgoraRteUserPropertiesUpdatedEvent): void;
@@ -45,6 +45,7 @@ export declare class AgoraRteScene {
45
45
  private _stateSynchronizer?;
46
46
  private _messageSynchronizer?;
47
47
  private _messageHandlerObservers?;
48
+ private _screenStreamLabelMap;
48
49
  private _streamPlayer?;
49
50
  private _timestampGap;
50
51
  private _totalUserCount;
@@ -122,6 +123,9 @@ export declare class AgoraRteScene {
122
123
  *
123
124
  */
124
125
  fetchUserList(params: AgoraRteUserPageParams): Promise<AgoraRteUserPageResponse>;
126
+ addLocalStreamLabels(streamId: string, labels: Map<string, any>): void;
127
+ removeLocalStreamLabel(streamId: string): void;
128
+ getLocalStreamSourceTypeFromStreamLabel(streamId: string): AgoraRtcVideoSourceType.CAMERA | AgoraRtcVideoSourceType.SCREEN | undefined;
125
129
  /**
126
130
  * Get all streams in scene, return as object
127
131
  * @returns {Record<string, AgoraRteMediaStreamInfo[]>} all streams in scene
@@ -88,6 +88,7 @@ var _error2 = require("../utilities/error");
88
88
  var _type2 = require("../rtc/type");
89
89
  var _client = require("../services/client");
90
90
  var _type3 = require("../rtm/type");
91
+ var _type4 = require("../../type");
91
92
  var _AgoraRteScene;
92
93
  var _initProto;
93
94
  function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
@@ -115,6 +116,8 @@ var AgoraRteScene = exports.AgoraRteScene = /*#__PURE__*/function () {
115
116
  prefix: 'AgoraRteScene'
116
117
  })));
117
118
  (0, _defineProperty2["default"])(this, "observable", new _imports.AgoraObservable());
119
+ // key is streamId, value is label
120
+ (0, _defineProperty2["default"])(this, "_screenStreamLabelMap", new Map());
118
121
  (0, _defineProperty2["default"])(this, "_timestampGap", 0);
119
122
  (0, _defineProperty2["default"])(this, "_totalUserCount", 0);
120
123
  (0, _defineProperty2["default"])(this, "_joinSuccess", false);
@@ -576,12 +579,34 @@ var AgoraRteScene = exports.AgoraRteScene = /*#__PURE__*/function () {
576
579
  return _fetchUserList.apply(this, arguments);
577
580
  }
578
581
  return fetchUserList;
579
- }()
582
+ }())
583
+ }, {
584
+ key: "addLocalStreamLabels",
585
+ value: function addLocalStreamLabels(streamId, labels) {
586
+ this._screenStreamLabelMap.set(streamId, labels);
587
+ }
588
+ }, {
589
+ key: "removeLocalStreamLabel",
590
+ value: function removeLocalStreamLabel(streamId) {
591
+ this._screenStreamLabelMap["delete"](streamId);
592
+ }
593
+ }, {
594
+ key: "getLocalStreamSourceTypeFromStreamLabel",
595
+ value: function getLocalStreamSourceTypeFromStreamLabel(streamId) {
596
+ var label = this._screenStreamLabelMap.get(streamId);
597
+ if ((label === null || label === void 0 ? void 0 : label.get('localSourceType')) === 'screen') {
598
+ return _type4.AgoraRteVideoSourceType.SCREEN;
599
+ }
600
+ if ((label === null || label === void 0 ? void 0 : label.get('localSourceType')) === 'camera') {
601
+ return _type4.AgoraRteVideoSourceType.CAMERA;
602
+ }
603
+ return undefined;
604
+ }
605
+
580
606
  /**
581
607
  * Get all streams in scene, return as object
582
608
  * @returns {Record<string, AgoraRteMediaStreamInfo[]>} all streams in scene
583
609
  */
584
- )
585
610
  }, {
586
611
  key: "getStreams",
587
612
  value: function getStreams() {
@@ -1116,7 +1141,7 @@ var AgoraRteScene = exports.AgoraRteScene = /*#__PURE__*/function () {
1116
1141
  var _this7 = this;
1117
1142
  streams.forEach(/*#__PURE__*/function () {
1118
1143
  var _ref9 = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee12(stream) {
1119
- var streamToken, shouldPublishAudio, shouldPublishVideo, _this7$_rtcMainChanne, _this7$rtcMainChannel, _this7$_rtcMainChanne2, _this7$rtcMainChannel2, observer;
1144
+ var streamToken, shouldPublishAudio, shouldPublishVideo, localLabelSourceType, sourceType, _this7$_rtcMainChanne, _this7$rtcMainChannel, _this7$_rtcMainChanne2, _this7$rtcMainChannel2, observer;
1120
1145
  return _regenerator["default"].wrap(function (_context12) {
1121
1146
  while (1) switch (_context12.prev = _context12.next) {
1122
1147
  case 0:
@@ -1124,10 +1149,12 @@ var AgoraRteScene = exports.AgoraRteScene = /*#__PURE__*/function () {
1124
1149
  streamToken = _this7.localUser.getStreamTokenByStreamId(stream.streamId);
1125
1150
  shouldPublishAudio = stream.streamType === _type.AgoraRteMediaStreamType.BOTH || stream.streamType === _type.AgoraRteMediaStreamType.AUDIO;
1126
1151
  shouldPublishVideo = stream.streamType === _type.AgoraRteMediaStreamType.BOTH || stream.streamType === _type.AgoraRteMediaStreamType.VIDEO;
1152
+ localLabelSourceType = _this7.getLocalStreamSourceTypeFromStreamLabel(stream.streamId);
1153
+ sourceType = localLabelSourceType !== null && localLabelSourceType !== void 0 ? localLabelSourceType : stream.videoSourceType;
1127
1154
  if (shouldPublishVideo) {
1128
- (_this7$_rtcMainChanne = _this7._rtcMainChannelClient) === null || _this7$_rtcMainChanne === void 0 || _this7$_rtcMainChanne.publisher.publishLocalVideoStream(streamToken, stream.streamId, stream.videoSourceId, stream.videoSourceType);
1155
+ (_this7$_rtcMainChanne = _this7._rtcMainChannelClient) === null || _this7$_rtcMainChanne === void 0 || _this7$_rtcMainChanne.publisher.publishLocalVideoStream(streamToken, stream.streamId, stream.videoSourceId, sourceType);
1129
1156
  } else {
1130
- (_this7$rtcMainChannel = _this7.rtcMainChannelClient) === null || _this7$rtcMainChannel === void 0 || _this7$rtcMainChannel.publisher.unpublishLocalVideoStream(stream.streamId, stream.videoSourceType);
1157
+ (_this7$rtcMainChannel = _this7.rtcMainChannelClient) === null || _this7$rtcMainChannel === void 0 || _this7$rtcMainChannel.publisher.unpublishLocalVideoStream(stream.streamId, sourceType);
1131
1158
  }
1132
1159
  if (shouldPublishAudio) {
1133
1160
  (_this7$_rtcMainChanne2 = _this7._rtcMainChannelClient) === null || _this7$_rtcMainChanne2 === void 0 || _this7$_rtcMainChanne2.publisher.publishLocalAudioStream(streamToken, stream.streamId, stream.audioSourceId, stream.audioSourceType);
@@ -1145,7 +1172,7 @@ var AgoraRteScene = exports.AgoraRteScene = /*#__PURE__*/function () {
1145
1172
  }
1146
1173
  if (shouldPublishVideo) {
1147
1174
  var _this7$_rtcMainChanne4;
1148
- (_this7$_rtcMainChanne4 = _this7._rtcMainChannelClient) === null || _this7$_rtcMainChanne4 === void 0 || _this7$_rtcMainChanne4.publisher.publishLocalVideoStream(token, stream.streamId, stream.videoSourceId, stream.videoSourceType);
1175
+ (_this7$_rtcMainChanne4 = _this7._rtcMainChannelClient) === null || _this7$_rtcMainChanne4 === void 0 || _this7$_rtcMainChanne4.publisher.publishLocalVideoStream(token, stream.streamId, stream.videoSourceId, sourceType);
1149
1176
  }
1150
1177
  _this7.localUser.removeObserver(observer);
1151
1178
  }
@@ -1737,6 +1764,7 @@ var AgoraRteScene = exports.AgoraRteScene = /*#__PURE__*/function () {
1737
1764
  value: function _cleanup() {
1738
1765
  var _this$_stateSynchroni3;
1739
1766
  (_this$_stateSynchroni3 = this._stateSynchronizer) === null || _this$_stateSynchroni3 === void 0 || _this$_stateSynchroni3.stop();
1767
+ this._screenStreamLabelMap.clear();
1740
1768
  this._stopDeviceStateSync();
1741
1769
  this._localUser = undefined;
1742
1770
  this._streamPlayer = undefined;
@@ -39,6 +39,7 @@ export declare class AgoraRtcCanvasTagPoolImpl extends AgoraRtcCanvasTagPool {
39
39
  * @param rtcEngine - RTC引擎实例
40
40
  */
41
41
  ifNeedStopRenderCanvas(canvasAddress: AgoraRteRenderView): void;
42
+ ifNeedStopLocalRenderCanvas(canvasAddress: AgoraRteRenderView): void;
42
43
  /**
43
44
  * 停止所有指定源ID的画布渲染
44
45
  * @param sourceId - 源ID
@@ -3,8 +3,6 @@
3
3
  require("core-js/modules/es.symbol.js");
4
4
  require("core-js/modules/es.symbol.description.js");
5
5
  require("core-js/modules/es.symbol.to-primitive.js");
6
- require("core-js/modules/es.error.cause.js");
7
- require("core-js/modules/es.error.to-string.js");
8
6
  require("core-js/modules/es.array.is-array.js");
9
7
  require("core-js/modules/es.array.push.js");
10
8
  require("core-js/modules/es.date.to-primitive.js");
@@ -24,6 +22,8 @@ Object.defineProperty(exports, "__esModule", {
24
22
  value: true
25
23
  });
26
24
  exports.AgoraRtcCanvasTagPoolImpl = void 0;
25
+ require("core-js/modules/es.error.cause.js");
26
+ require("core-js/modules/es.error.to-string.js");
27
27
  require("core-js/modules/es.array.filter.js");
28
28
  require("core-js/modules/es.array.for-each.js");
29
29
  require("core-js/modules/es.array.from.js");
@@ -146,6 +146,30 @@ var AgoraRtcCanvasTagPoolImpl = exports.AgoraRtcCanvasTagPoolImpl = /*#__PURE__*
146
146
  }
147
147
  }
148
148
 
149
+ // 新增了这个方法,用于停止本地渲染,
150
+ // 有部分客户在停止摄像头预览时,会传入远程画布地址
151
+ // 导致远端也停止渲染,所以需要新增这个方法来停止本地渲染。
152
+ }, {
153
+ key: "ifNeedStopLocalRenderCanvas",
154
+ value: function ifNeedStopLocalRenderCanvas(canvasAddress) {
155
+ var canvasTag = this._canvasTagPool.get(canvasAddress);
156
+ if (!canvasTag) {
157
+ return;
158
+ }
159
+ if (!canvasTag.isLocal) {
160
+ this.logger.error('Remote canvas should not be stopped');
161
+ throw new Error('Remote canvas should not be stopped');
162
+ }
163
+ try {
164
+ if (!canvasTag.connection) {
165
+ this._stopLocalRender(canvasTag);
166
+ this._cleanupCanvas(canvasAddress);
167
+ }
168
+ } catch (error) {
169
+ this.logger.error('Error stopping render canvas:', error);
170
+ }
171
+ }
172
+
149
173
  /**
150
174
  * 停止所有指定源ID的画布渲染
151
175
  * @param sourceId - 源ID
@@ -360,7 +384,7 @@ var AgoraRtcCanvasTagPoolImpl = exports.AgoraRtcCanvasTagPoolImpl = /*#__PURE__*
360
384
  }]);
361
385
  }(_canvas.AgoraRtcCanvasTagPool);
362
386
  _AgoraRtcCanvasTagPoolImpl = AgoraRtcCanvasTagPoolImpl;
363
- var _applyDecs$e = _applyDecs(_AgoraRtcCanvasTagPoolImpl, [[_imports.trace, 2, "release"], [_imports.trace, 2, "addTagWithCanvasId"], [_imports.trace, 2, "ifNeedStopRenderCanvas"], [_imports.trace, 2, "stopRenderOnAllCanvasWithSourceId"], [_imports.trace, 2, "_isLastLocalCanvas"]], [], 0, void 0, _canvas.AgoraRtcCanvasTagPool).e;
387
+ var _applyDecs$e = _applyDecs(_AgoraRtcCanvasTagPoolImpl, [[_imports.trace, 2, "release"], [_imports.trace, 2, "addTagWithCanvasId"], [_imports.trace, 2, "ifNeedStopRenderCanvas"], [_imports.trace, 2, "ifNeedStopLocalRenderCanvas"], [_imports.trace, 2, "stopRenderOnAllCanvasWithSourceId"], [_imports.trace, 2, "_isLastLocalCanvas"]], [], 0, void 0, _canvas.AgoraRtcCanvasTagPool).e;
364
388
  var _applyDecs$e2 = (0, _slicedToArray2["default"])(_applyDecs$e, 1);
365
389
  _initProto = _applyDecs$e2[0];
366
390
  _applyDecs$e;
@@ -382,7 +382,7 @@ var AgoraRtcClientImpl = exports.AgoraRtcClientImpl = /*#__PURE__*/function (_Ag
382
382
  }, {
383
383
  key: "stopRenderCameraPreview",
384
384
  value: function stopRenderCameraPreview(deviceId, view) {
385
- this.canvasTagPool.ifNeedStopRenderCanvas(view);
385
+ this.canvasTagPool.ifNeedStopLocalRenderCanvas(view);
386
386
  this.canvasHelper.unbind(view);
387
387
  return 0;
388
388
  }
@@ -84,7 +84,7 @@ var CameraStateControlImpl = exports.CameraStateControlImpl = /*#__PURE__*/funct
84
84
  //@internal
85
85
  (0, _defineProperty2["default"])(_this, "_cameraSourceIndexMapping", (_initProto(_this), new Map()));
86
86
  //@internal
87
- (0, _defineProperty2["default"])(_this, "_availableCameraSourceIndex", initAvailableCameraSourceIndex);
87
+ (0, _defineProperty2["default"])(_this, "_availableCameraSourceIndex", [].concat(initAvailableCameraSourceIndex));
88
88
  return _this;
89
89
  }
90
90
  (0, _inherits2["default"])(CameraStateControlImpl, _SourceStateControlIm);
@@ -97,7 +97,7 @@ var CameraStateControlImpl = exports.CameraStateControlImpl = /*#__PURE__*/funct
97
97
  key: "release",
98
98
  value: function release() {
99
99
  this._cameraSourceIndexMapping.clear();
100
- this._availableCameraSourceIndex = initAvailableCameraSourceIndex;
100
+ this._availableCameraSourceIndex = [].concat(initAvailableCameraSourceIndex);
101
101
  _superPropGet(CameraStateControlImpl, "release", this, 3)([]);
102
102
  }
103
103
  }, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agora-rte-sdk",
3
- "version": "3.8.0",
3
+ "version": "3.8.1-beta",
4
4
  "description": "SDK for building interactive scenarios",
5
5
  "author": "agora.io",
6
6
  "license": "ISC",
@@ -28,7 +28,7 @@
28
28
  "@types/sinon": "^17.0.2",
29
29
  "@types/ua-parser-js": "^0.7.35",
30
30
  "agora-token": "^2.0.3",
31
- "agora-toolchain": "3.8.0",
31
+ "agora-toolchain": "3.8.1-beta",
32
32
  "core-js": "^3.33.3",
33
33
  "electron": "22.3.27",
34
34
  "husky": "^9.0.11",
@@ -43,7 +43,7 @@
43
43
  "agora-extension-ai-denoiser": "^1.0.0",
44
44
  "agora-extension-beauty-effect": "^1.0.1-beta",
45
45
  "agora-extension-virtual-background": "^2.1.0",
46
- "agora-foundation": "3.8.0",
46
+ "agora-foundation": "3.8.1-beta",
47
47
  "agora-rtc-sdk-ng": "4.23.3",
48
48
  "agora-rtm": "2.2.2-3",
49
49
  "await-to-js": "^3.0.0",