agora-rte-sdk 3.8.0 → 3.8.1-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.
@@ -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;
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,31 @@ 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
+ return _type4.AgoraRteVideoSourceType.CAMERA;
601
+ }
602
+
580
603
  /**
581
604
  * Get all streams in scene, return as object
582
605
  * @returns {Record<string, AgoraRteMediaStreamInfo[]>} all streams in scene
583
606
  */
584
- )
585
607
  }, {
586
608
  key: "getStreams",
587
609
  value: function getStreams() {
@@ -1116,7 +1138,7 @@ var AgoraRteScene = exports.AgoraRteScene = /*#__PURE__*/function () {
1116
1138
  var _this7 = this;
1117
1139
  streams.forEach(/*#__PURE__*/function () {
1118
1140
  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;
1141
+ var streamToken, shouldPublishAudio, shouldPublishVideo, sourceType, _this7$_rtcMainChanne, _this7$rtcMainChannel, _this7$_rtcMainChanne2, _this7$rtcMainChannel2, observer;
1120
1142
  return _regenerator["default"].wrap(function (_context12) {
1121
1143
  while (1) switch (_context12.prev = _context12.next) {
1122
1144
  case 0:
@@ -1124,10 +1146,11 @@ var AgoraRteScene = exports.AgoraRteScene = /*#__PURE__*/function () {
1124
1146
  streamToken = _this7.localUser.getStreamTokenByStreamId(stream.streamId);
1125
1147
  shouldPublishAudio = stream.streamType === _type.AgoraRteMediaStreamType.BOTH || stream.streamType === _type.AgoraRteMediaStreamType.AUDIO;
1126
1148
  shouldPublishVideo = stream.streamType === _type.AgoraRteMediaStreamType.BOTH || stream.streamType === _type.AgoraRteMediaStreamType.VIDEO;
1149
+ sourceType = _this7.getLocalStreamSourceTypeFromStreamLabel(stream.streamId);
1127
1150
  if (shouldPublishVideo) {
1128
- (_this7$_rtcMainChanne = _this7._rtcMainChannelClient) === null || _this7$_rtcMainChanne === void 0 || _this7$_rtcMainChanne.publisher.publishLocalVideoStream(streamToken, stream.streamId, stream.videoSourceId, stream.videoSourceType);
1151
+ (_this7$_rtcMainChanne = _this7._rtcMainChannelClient) === null || _this7$_rtcMainChanne === void 0 || _this7$_rtcMainChanne.publisher.publishLocalVideoStream(streamToken, stream.streamId, stream.videoSourceId, sourceType);
1129
1152
  } else {
1130
- (_this7$rtcMainChannel = _this7.rtcMainChannelClient) === null || _this7$rtcMainChannel === void 0 || _this7$rtcMainChannel.publisher.unpublishLocalVideoStream(stream.streamId, stream.videoSourceType);
1153
+ (_this7$rtcMainChannel = _this7.rtcMainChannelClient) === null || _this7$rtcMainChannel === void 0 || _this7$rtcMainChannel.publisher.unpublishLocalVideoStream(stream.streamId, sourceType);
1131
1154
  }
1132
1155
  if (shouldPublishAudio) {
1133
1156
  (_this7$_rtcMainChanne2 = _this7._rtcMainChannelClient) === null || _this7$_rtcMainChanne2 === void 0 || _this7$_rtcMainChanne2.publisher.publishLocalAudioStream(streamToken, stream.streamId, stream.audioSourceId, stream.audioSourceType);
@@ -1145,7 +1168,7 @@ var AgoraRteScene = exports.AgoraRteScene = /*#__PURE__*/function () {
1145
1168
  }
1146
1169
  if (shouldPublishVideo) {
1147
1170
  var _this7$_rtcMainChanne4;
1148
- (_this7$_rtcMainChanne4 = _this7._rtcMainChannelClient) === null || _this7$_rtcMainChanne4 === void 0 || _this7$_rtcMainChanne4.publisher.publishLocalVideoStream(token, stream.streamId, stream.videoSourceId, stream.videoSourceType);
1171
+ (_this7$_rtcMainChanne4 = _this7._rtcMainChannelClient) === null || _this7$_rtcMainChanne4 === void 0 || _this7$_rtcMainChanne4.publisher.publishLocalVideoStream(token, stream.streamId, stream.videoSourceId, sourceType);
1149
1172
  }
1150
1173
  _this7.localUser.removeObserver(observer);
1151
1174
  }
@@ -1737,6 +1760,7 @@ var AgoraRteScene = exports.AgoraRteScene = /*#__PURE__*/function () {
1737
1760
  value: function _cleanup() {
1738
1761
  var _this$_stateSynchroni3;
1739
1762
  (_this$_stateSynchroni3 = this._stateSynchronizer) === null || _this$_stateSynchroni3 === void 0 || _this$_stateSynchroni3.stop();
1763
+ this._screenStreamLabelMap.clear();
1740
1764
  this._stopDeviceStateSync();
1741
1765
  this._localUser = undefined;
1742
1766
  this._streamPlayer = undefined;
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-alpha",
4
4
  "description": "SDK for building interactive scenarios",
5
5
  "author": "agora.io",
6
6
  "license": "ISC",
@@ -10,7 +10,6 @@
10
10
  "lib"
11
11
  ],
12
12
  "scripts": {
13
- "prepare": "husky",
14
13
  "build": "agora-tc-transpile",
15
14
  "test-browser": "agora-tc-test-karma-browser",
16
15
  "test-electron": "agora-tc-test-karma-electron"
@@ -28,7 +27,7 @@
28
27
  "@types/sinon": "^17.0.2",
29
28
  "@types/ua-parser-js": "^0.7.35",
30
29
  "agora-token": "^2.0.3",
31
- "agora-toolchain": "3.8.0",
30
+ "agora-toolchain": "3.8.1-alpha",
32
31
  "core-js": "^3.33.3",
33
32
  "electron": "22.3.27",
34
33
  "husky": "^9.0.11",
@@ -43,7 +42,7 @@
43
42
  "agora-extension-ai-denoiser": "^1.0.0",
44
43
  "agora-extension-beauty-effect": "^1.0.1-beta",
45
44
  "agora-extension-virtual-background": "^2.1.0",
46
- "agora-foundation": "3.8.0",
45
+ "agora-foundation": "3.8.1-alpha",
47
46
  "agora-rtc-sdk-ng": "4.23.3",
48
47
  "agora-rtm": "2.2.2-3",
49
48
  "await-to-js": "^3.0.0",