agora-rte-sdk 2.8.21 → 2.8.30

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 (47) hide show
  1. package/dist/index.js +2 -2
  2. package/lib/core/decorator/handlers/log-handler.d.ts +2 -0
  3. package/lib/core/decorator/handlers/log-handler.js +34 -0
  4. package/lib/core/decorator/log/log-serializer.d.ts +7 -0
  5. package/lib/core/decorator/log/log-serializer.js +38 -0
  6. package/lib/core/decorator/utils.d.ts +2 -0
  7. package/lib/core/decorator/utils.js +19 -0
  8. package/lib/core/logger/index.d.ts +1 -0
  9. package/lib/core/logger/index.js +16 -0
  10. package/lib/core/logger/log.worker.js +4 -2
  11. package/lib/core/media/control.d.ts +11 -8
  12. package/lib/core/media/control.js +42 -32
  13. package/lib/core/media/player.d.ts +9 -0
  14. package/lib/core/media/player.js +36 -0
  15. package/lib/core/media/track.d.ts +8 -1
  16. package/lib/core/media/track.js +18 -0
  17. package/lib/core/media/type.d.ts +113 -0
  18. package/lib/core/media/type.js +31 -0
  19. package/lib/core/rtc/adapter/base.d.ts +5 -5
  20. package/lib/core/rtc/adapter/electron/device.d.ts +0 -1
  21. package/lib/core/rtc/adapter/electron/device.js +0 -5
  22. package/lib/core/rtc/adapter/electron/index.d.ts +5 -5
  23. package/lib/core/rtc/adapter/electron/index.js +18 -24
  24. package/lib/core/rtc/adapter/web/client.d.ts +7 -5
  25. package/lib/core/rtc/adapter/web/client.js +33 -28
  26. package/lib/core/rtc/adapter/web/device.d.ts +0 -1
  27. package/lib/core/rtc/adapter/web/device.js +0 -5
  28. package/lib/core/rtc/adapter/web/dispatcher.d.ts +61 -0
  29. package/lib/core/rtc/adapter/web/dispatcher.js +166 -0
  30. package/lib/core/rtc/adapter/web/index.d.ts +9 -5
  31. package/lib/core/rtc/adapter/web/index.js +25 -16
  32. package/lib/core/rtc/adapter/web/thread.d.ts +18 -11
  33. package/lib/core/rtc/adapter/web/thread.js +241 -133
  34. package/lib/core/rtc/index.d.ts +5 -4
  35. package/lib/core/rtc/index.js +12 -12
  36. package/lib/core/rtc/type.d.ts +0 -4
  37. package/lib/core/services/api.d.ts +4 -0
  38. package/lib/core/services/api.js +29 -0
  39. package/lib/core/utils/decorator.d.ts +2 -0
  40. package/lib/core/utils/decorator.js +65 -0
  41. package/lib/index.d.ts +3 -1
  42. package/lib/index.js +24 -17
  43. package/lib/scene/index.d.ts +1 -0
  44. package/lib/scene/index.js +23 -13
  45. package/lib/scene/state-sync.d.ts +21 -0
  46. package/lib/scene/state-sync.js +169 -0
  47. package/package.json +1 -1
@@ -5,7 +5,8 @@ import { AGEventEmitter } from '../../utils/events';
5
5
  import { AgoraRtcVideoCanvas } from '../canvas';
6
6
  import { AGRtcConnectionType } from '../channel';
7
7
  import { IBaseProcessor } from 'agora-rte-extension';
8
- import { AgoraRteMediaSourceState, AGRtcDeviceInfo, AGScreenShareDevice, AGScreenShareType, AGBeautyEffect, AGAudioRawDataConfig, AGSnapshotInfo, AGNetworkStats, AGRtcState, AGLowStreamParameter } from '../type';
8
+ import { AgoraRteMediaSourceState, AGRtcDeviceInfo, AGScreenShareDevice, AGScreenShareType, AGBeautyEffect, AGSnapshotInfo, AGNetworkStats, AGRtcState, AGLowStreamParameter } from '../type';
9
+ import { AgoraRteAudioRawDataConfig, AgoraRteAudioRawDataObserver, AgoraRteAudioRawDataPosition } from '../../media/type';
9
10
  export declare type LocalVideoTrackStateEvent = (state: AgoraRteMediaSourceState, type: AgoraRteVideoSourceType) => void;
10
11
  export declare type LocalAudioTrackStateEvent = (state: AgoraRteMediaSourceState, type: AgoraRteAudioSourceType) => void;
11
12
  export declare type LocalCameraDeviceListEvent = (addNewDevice: boolean, newDevices: AGRtcDeviceInfo[], allDevices: AGRtcDeviceInfo[]) => void;
@@ -25,7 +26,6 @@ export declare abstract class RtcAudioDeviceManagerBase extends AGEventEmitter {
25
26
  abstract onLocalAudioTrackStateChanged(cb: LocalAudioTrackStateEvent): number;
26
27
  abstract onLocalAudioVolume(cb: (volume: number) => void): number;
27
28
  abstract onLocalAudioPlaybackTestVolumeChanged(cb: LocalAudioPlaybackVolumeIndicatorEvent): number;
28
- abstract onAudioFrame(cb: (buffer: ArrayBuffer) => void): number;
29
29
  }
30
30
  export declare abstract class RtcChannelAdapterBase extends AGEventEmitter {
31
31
  abstract join(token: string, streamUuid: string, connectionType: AGRtcConnectionType): Promise<void>;
@@ -79,9 +79,9 @@ export declare abstract class RtcAdapterBase extends AGEventEmitter {
79
79
  abstract onLocalScreenShareTrackStateChanged(cb: LocalVideoTrackStateEvent): number;
80
80
  abstract destroy(): number;
81
81
  abstract setBeautyEffectOptions(enable: boolean, options: AGBeautyEffect): number;
82
- abstract setAudioRawDataConfig(config: AGAudioRawDataConfig): number;
83
- abstract setAudioFrameCallback(): number;
84
- abstract stopAudioFrameCallback(): number;
82
+ abstract setAudioRawDataConfig(config: AgoraRteAudioRawDataConfig, position: AgoraRteAudioRawDataPosition): number;
83
+ abstract addAudioRawDataObserver(observer: AgoraRteAudioRawDataObserver, position: AgoraRteAudioRawDataPosition): number;
84
+ abstract removeAudioRawDataObserver(observer: AgoraRteAudioRawDataObserver, position: AgoraRteAudioRawDataPosition): number;
85
85
  static getRtcVersion(): string;
86
86
  abstract hasScreenSharePermission(): boolean;
87
87
  abstract takeSnapshot(channel: string, streamUuid: number, filePath: string): Promise<AGSnapshotInfo | void>;
@@ -35,5 +35,4 @@ export declare class RtcAudioDeviceManagerElectron extends RtcAudioDeviceManager
35
35
  private _emitRecordingListChanged;
36
36
  private _fetchPlaybackDeviceList;
37
37
  private _fetchRecordingDeviceList;
38
- onAudioFrame(cb: (buffer: ArrayBuffer) => void): number;
39
38
  }
@@ -268,11 +268,6 @@ var RtcAudioDeviceManagerElectron = /*#__PURE__*/function (_RtcAudioDeviceManage
268
268
  });
269
269
  this._emitRecordingListChanged(true, newDevices, this.microphoneList);
270
270
  }
271
- }, {
272
- key: "onAudioFrame",
273
- value: function onAudioFrame(cb) {
274
- return 0;
275
- }
276
271
  }]);
277
272
  return RtcAudioDeviceManagerElectron;
278
273
  }(_base.RtcAudioDeviceManagerBase);
@@ -3,13 +3,14 @@ import type AgoraRtcEngine from 'agora-electron-sdk/types/AgoraSdk';
3
3
  import { AgoraRteVideoSourceType } from '../../../media/track';
4
4
  import { AgoraRtcVideoCanvas } from '../../canvas';
5
5
  import { AGRtcConnectionType } from '../../channel';
6
- import { AGScreenShareDevice, AGScreenShareType, AGBeautyEffect, AGAudioRawDataConfig, AGSnapshotInfo, AGNetworkStats, AGRtcState, AGLowStreamParameter } from '../../type';
6
+ import { AGScreenShareDevice, AGScreenShareType, AGBeautyEffect, AGSnapshotInfo, AGNetworkStats, AGRtcState, AGLowStreamParameter } from '../../type';
7
7
  import { LocalVideoTrackStateEvent, LocalAudioTrackStateEvent, RtcAdapterBase, RtcAudioDeviceManagerBase, RtcChannelAdapterBase, RtcVideoDeviceManagerBase, LocalAudioPlaybackVolumeIndicatorEvent } from '../base';
8
8
  import { AgoraRteElectronCameraThread } from './thread';
9
9
  import { AgoraLatencyLevel } from '../../../../configs';
10
10
  import { AGChannelProfile } from '../../../../type';
11
11
  import { RemoteStreamType } from 'agora-rtc-sdk-ng';
12
12
  import { Logger } from '../../../logger';
13
+ import { AgoraRteAudioRawDataConfig, AgoraRteAudioRawDataObserver, AgoraRteAudioRawDataPosition } from '../../../media/type';
13
14
  declare global {
14
15
  interface Window {
15
16
  main_pid: string;
@@ -71,12 +72,11 @@ export declare class RtcAdapterElectron extends RtcAdapterBase {
71
72
  onLocalAudioTrackStateChanged(cb: LocalAudioTrackStateEvent): number;
72
73
  onLocalAudioVolume(cb: (volume: number) => void): number;
73
74
  onLocalScreenShareTrackStateChanged(cb: LocalVideoTrackStateEvent): number;
74
- onAudioFrame(cb: (buffer: ArrayBuffer) => void): number;
75
75
  setBeautyEffectOptions(enable: boolean, options: AGBeautyEffect): number;
76
- setAudioFrameCallback(): number;
77
- stopAudioFrameCallback(): number;
78
- setAudioRawDataConfig(config: AGAudioRawDataConfig): number;
79
76
  hasScreenSharePermission(): boolean;
77
+ setAudioRawDataConfig(config: AgoraRteAudioRawDataConfig, position: AgoraRteAudioRawDataPosition): number;
78
+ addAudioRawDataObserver(observer: AgoraRteAudioRawDataObserver): number;
79
+ removeAudioRawDataObserver(observer: AgoraRteAudioRawDataObserver): number;
80
80
  takeSnapshot(channel: string, streamUuid: number, filePath: string): Promise<AGSnapshotInfo>;
81
81
  getCurrentFrameData(_channelName: string, _streamUuid: string, _isLocal: boolean): ImageData;
82
82
  addCameraProcessors(_processors: unknown[]): number;
@@ -385,35 +385,11 @@ var RtcAdapterElectron = (_dec = _log.Log.attach({
385
385
  this._screenEventBus.on(_control.AgoraMediaControlEventType.trackStateChanged, cb);
386
386
  return 0;
387
387
  }
388
- }, {
389
- key: "onAudioFrame",
390
- value: function onAudioFrame(cb) {
391
- this.logger.warn("electron platform does not support this for now");
392
- return 0;
393
- }
394
388
  }, {
395
389
  key: "setBeautyEffectOptions",
396
390
  value: function setBeautyEffectOptions(enable, options) {
397
391
  return this.rtcEngine.setBeautyEffectOptions(enable, options);
398
392
  }
399
- }, {
400
- key: "setAudioFrameCallback",
401
- value: function setAudioFrameCallback() {
402
- this.logger.warn("electron platform does not support this for now");
403
- return 0;
404
- }
405
- }, {
406
- key: "stopAudioFrameCallback",
407
- value: function stopAudioFrameCallback() {
408
- this.logger.warn("electron platform does not support this for now");
409
- return 0;
410
- }
411
- }, {
412
- key: "setAudioRawDataConfig",
413
- value: function setAudioRawDataConfig(config) {
414
- this.logger.warn("electron platform does not support this for now");
415
- return 0;
416
- }
417
393
  }, {
418
394
  key: "hasScreenSharePermission",
419
395
  value: function hasScreenSharePermission() {
@@ -423,6 +399,24 @@ var RtcAdapterElectron = (_dec = _log.Log.attach({
423
399
  }
424
400
  return true;
425
401
  }
402
+ }, {
403
+ key: "setAudioRawDataConfig",
404
+ value: function setAudioRawDataConfig(config, position) {
405
+ this.logger.warn("electron platform does not support setAudioRawDataConfig for now");
406
+ return 1;
407
+ }
408
+ }, {
409
+ key: "addAudioRawDataObserver",
410
+ value: function addAudioRawDataObserver(observer) {
411
+ this.logger.warn("electron platform does not support addAudioRawDataObserver for now");
412
+ return 1;
413
+ }
414
+ }, {
415
+ key: "removeAudioRawDataObserver",
416
+ value: function removeAudioRawDataObserver(observer) {
417
+ this.logger.warn("electron platform does not support removeAudioRawDataObserver for now");
418
+ return 1;
419
+ }
426
420
  }, {
427
421
  key: "takeSnapshot",
428
422
  value: function takeSnapshot(channel, streamUuid, filePath) {
@@ -7,19 +7,21 @@ import { AGLowStreamParameter, AGRtcState } from '../../type';
7
7
  import { AGRtcConnectionType } from '../../channel';
8
8
  import { AgoraLatencyLevel } from '../../../../configs';
9
9
  import { Logger } from '../../../logger';
10
+ import { AGAudioRawDataDispatcher } from './dispatcher';
10
11
  export declare class AgoraRteWebClientBase extends AGEventEmitter {
11
12
  logger: Logger;
12
13
  protected _client: IAgoraRTCClient;
13
14
  private _base;
14
15
  get base(): RtcAdapterWeb;
15
16
  private readonly configs;
16
- private _connectionState;
17
17
  protected readonly channelName: string;
18
- readonly connectionType: AGRtcConnectionType;
18
+ protected readonly connectionType: AGRtcConnectionType;
19
+ protected readonly _audioRawDataDispatcher: AGAudioRawDataDispatcher;
20
+ private _connectionState;
19
21
  private _networkStats;
20
22
  private _recentLocalPacketStats;
21
23
  private _recentRemotePacketStats;
22
- constructor(channelName: string, configs: RtcAdapterWebConfig, base: RtcAdapterBase, connectionType: AGRtcConnectionType);
24
+ constructor(channelName: string, configs: RtcAdapterWebConfig, base: RtcAdapterBase, connectionType: AGRtcConnectionType, audioRawDataDispatcher: AGAudioRawDataDispatcher);
23
25
  private _setPrivateParameter;
24
26
  private _getRecentPacketLoss;
25
27
  get ready(): boolean;
@@ -41,7 +43,7 @@ export declare class AgoraRteWebClientMain extends AgoraRteWebClientBase {
41
43
  private _subscribeVideoThreads;
42
44
  private _subscribeAudioThreads;
43
45
  videoSubscribeThread(streamUuid: string): AgoraRteSubscribeThread | undefined;
44
- constructor(channelName: string, configs: RtcAdapterWebConfig, base: RtcAdapterBase, connectionType: AGRtcConnectionType);
46
+ constructor(channelName: string, configs: RtcAdapterWebConfig, base: RtcAdapterBase, connectionType: AGRtcConnectionType, audioRawDataDispatcher: AGAudioRawDataDispatcher);
45
47
  get remoteRtcUsers(): Map<string, IAgoraRTCRemoteUser>;
46
48
  private _notifyStreamVolumes;
47
49
  private _notifySubscribeThreads;
@@ -59,7 +61,7 @@ export declare class AgoraRteWebClientMain extends AgoraRteWebClientBase {
59
61
  }
60
62
  export declare class AgoraRteWebClientSub extends AgoraRteWebClientBase {
61
63
  private _publishThread;
62
- constructor(channelName: string, configs: RtcAdapterWebConfig, base: RtcAdapterBase, connectionType: AGRtcConnectionType);
64
+ constructor(channelName: string, configs: RtcAdapterWebConfig, base: RtcAdapterBase, connectionType: AGRtcConnectionType, audioRawDataDispatcher: AGAudioRawDataDispatcher);
63
65
  muteLocalVideo(mute: boolean): number;
64
66
  muteLocalAudio(mute: boolean): number;
65
67
  muteLocalScreenShare(mute: boolean): number;
@@ -85,7 +85,7 @@ var AgoraRteWebClientBase = (_dec = _log.Log.attach({
85
85
  }), _dec(_class = /*#__PURE__*/function (_AGEventEmitter) {
86
86
  (0, _inherits2["default"])(AgoraRteWebClientBase, _AGEventEmitter);
87
87
  var _super = _createSuper(AgoraRteWebClientBase);
88
- function AgoraRteWebClientBase(channelName, configs, base, connectionType) {
88
+ function AgoraRteWebClientBase(channelName, configs, base, connectionType, audioRawDataDispatcher) {
89
89
  var _ref;
90
90
  var _this;
91
91
  (0, _classCallCheck2["default"])(this, AgoraRteWebClientBase);
@@ -94,9 +94,10 @@ var AgoraRteWebClientBase = (_dec = _log.Log.attach({
94
94
  _this._client = void 0;
95
95
  _this._base = void 0;
96
96
  _this.configs = void 0;
97
- _this._connectionState = _type.AGRtcState.Idle;
98
97
  _this.channelName = void 0;
99
98
  _this.connectionType = void 0;
99
+ _this._audioRawDataDispatcher = void 0;
100
+ _this._connectionState = _type.AGRtcState.Idle;
100
101
  _this._networkStats = new _stats.RtcNetworkQualityWeb();
101
102
  _this._recentLocalPacketStats = [];
102
103
  _this._recentRemotePacketStats = [];
@@ -104,6 +105,7 @@ var AgoraRteWebClientBase = (_dec = _log.Log.attach({
104
105
  _this.configs = configs;
105
106
  _this._base = base;
106
107
  _this.connectionType = connectionType;
108
+ _this._audioRawDataDispatcher = audioRawDataDispatcher;
107
109
  _agoraRtcSdkNg["default"].setArea({
108
110
  areaCode: [_this._rtcRegion()]
109
111
  });
@@ -341,10 +343,10 @@ exports.AgoraRteWebClientBase = AgoraRteWebClientBase;
341
343
  var AgoraRteWebClientMain = (_class3 = /*#__PURE__*/function (_AgoraRteWebClientBas) {
342
344
  (0, _inherits2["default"])(AgoraRteWebClientMain, _AgoraRteWebClientBas);
343
345
  var _super2 = _createSuper(AgoraRteWebClientMain);
344
- function AgoraRteWebClientMain(channelName, configs, base, connectionType) {
346
+ function AgoraRteWebClientMain(channelName, configs, base, connectionType, audioRawDataDispatcher) {
345
347
  var _this2;
346
348
  (0, _classCallCheck2["default"])(this, AgoraRteWebClientMain);
347
- _this2 = _super2.call(this, channelName, configs, base, connectionType);
349
+ _this2 = _super2.call(this, channelName, configs, base, connectionType, audioRawDataDispatcher);
348
350
  _this2._remoteRtcUsers = new Map();
349
351
  _this2._muteRemoteVideo = new Map();
350
352
  _this2._muteRemoteAudio = new Map();
@@ -353,7 +355,6 @@ var AgoraRteWebClientMain = (_class3 = /*#__PURE__*/function (_AgoraRteWebClient
353
355
  _this2._subscribeVideoThreads = new Map();
354
356
  _this2._subscribeAudioThreads = new Map();
355
357
  _this2._publishThread = new _thread2.AgoraRtePublishThreadMain(_this2._client, configs);
356
-
357
358
  //publish thread needs to wait till join channel
358
359
  _this2._publishThread.runnable = false;
359
360
  var throttledVolumeIndicator = (0, _lodash.throttle)(_this2._notifyStreamVolumes, 500);
@@ -366,7 +367,7 @@ var AgoraRteWebClientMain = (_class3 = /*#__PURE__*/function (_AgoraRteWebClient
366
367
  muteMap: _this2._muteRemoteVideo,
367
368
  mediaType: 'video',
368
369
  canvasMap: _this2.base.remoteCanvas
369
- });
370
+ }, audioRawDataDispatcher);
370
371
  _this2._subscribeVideoThreads.set(streamUuid, thread);
371
372
  thread.runnable = _this2.ready;
372
373
  } else {
@@ -374,7 +375,7 @@ var AgoraRteWebClientMain = (_class3 = /*#__PURE__*/function (_AgoraRteWebClient
374
375
  channelName: _this2.channelName,
375
376
  muteMap: _this2._muteRemoteAudio,
376
377
  mediaType: 'audio'
377
- });
378
+ }, audioRawDataDispatcher);
378
379
  _thread.on('audio-volume-indication', function (volume) {
379
380
  _this2._audioVolumes.set(streamUuid, volume);
380
381
  throttledVolumeIndicator();
@@ -387,34 +388,36 @@ var AgoraRteWebClientMain = (_class3 = /*#__PURE__*/function (_AgoraRteWebClient
387
388
  _this2._client.on('user-unpublished', function (user) {
388
389
  if (!user.hasAudio && !user.hasVideo) {
389
390
  // if user has no video/audio, take him out
390
- var userId = "".concat(user.uid);
391
- _this2._remoteRtcUsers["delete"](userId);
392
- var videoThread = _this2._subscribeVideoThreads.get(userId);
393
- var audioThread = _this2._subscribeAudioThreads.get(userId);
391
+ var streamUuid = "".concat(user.uid);
392
+ _this2._remoteRtcUsers["delete"](streamUuid);
393
+ var videoThread = _this2._subscribeVideoThreads.get(streamUuid);
394
+ var audioThread = _this2._subscribeAudioThreads.get(streamUuid);
394
395
  if (videoThread) {
395
396
  videoThread.stop();
396
- _this2._subscribeVideoThreads["delete"](userId);
397
+ _this2._subscribeVideoThreads["delete"](streamUuid);
397
398
  }
398
399
  if (audioThread) {
400
+ audioRawDataDispatcher.dispatch('AudioTrackUnsubscribed', audioThread.streamUuid, channelName);
399
401
  audioThread.stop();
400
- _this2._audioVolumes["delete"](userId);
401
- _this2._subscribeAudioThreads["delete"](userId);
402
+ _this2._audioVolumes["delete"](streamUuid);
403
+ _this2._subscribeAudioThreads["delete"](streamUuid);
402
404
  }
403
405
  }
404
406
  });
405
407
  _this2._client.on('user-left', function (user) {
406
- var userId = "".concat(user.uid);
407
- _this2._remoteRtcUsers["delete"](userId);
408
- var videoThread = _this2._subscribeVideoThreads.get(userId);
409
- var audioThread = _this2._subscribeAudioThreads.get(userId);
408
+ var streamUuid = "".concat(user.uid);
409
+ _this2._remoteRtcUsers["delete"](streamUuid);
410
+ var videoThread = _this2._subscribeVideoThreads.get(streamUuid);
411
+ var audioThread = _this2._subscribeAudioThreads.get(streamUuid);
410
412
  if (videoThread) {
411
413
  videoThread.stop();
412
- _this2._subscribeVideoThreads["delete"](userId);
414
+ _this2._subscribeVideoThreads["delete"](streamUuid);
413
415
  }
414
416
  if (audioThread) {
417
+ audioRawDataDispatcher.dispatch('AudioTrackUnsubscribed', streamUuid, channelName);
415
418
  audioThread.stop();
416
- _this2._audioVolumes["delete"](userId);
417
- _this2._subscribeAudioThreads["delete"](userId);
419
+ _this2._audioVolumes["delete"](streamUuid);
420
+ _this2._subscribeAudioThreads["delete"](streamUuid);
418
421
  }
419
422
  });
420
423
  return _this2;
@@ -611,6 +614,7 @@ var AgoraRteWebClientMain = (_class3 = /*#__PURE__*/function (_AgoraRteWebClient
611
614
  key: "leave",
612
615
  value: function () {
613
616
  var _leave2 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
617
+ var _this4 = this;
614
618
  return _regeneratorRuntime().wrap(function _callee4$(_context4) {
615
619
  while (1) {
616
620
  switch (_context4.prev = _context4.next) {
@@ -625,6 +629,7 @@ var AgoraRteWebClientMain = (_class3 = /*#__PURE__*/function (_AgoraRteWebClient
625
629
  });
626
630
  this._subscribeVideoThreads.clear();
627
631
  this._subscribeAudioThreads.forEach(function (thread) {
632
+ _this4._audioRawDataDispatcher.dispatch('AudioTrackUnsubscribed', thread.streamUuid, _this4.channelName);
628
633
  thread.stop();
629
634
  });
630
635
  this._subscribeAudioThreads.clear();
@@ -648,16 +653,16 @@ exports.AgoraRteWebClientMain = AgoraRteWebClientMain;
648
653
  var AgoraRteWebClientSub = /*#__PURE__*/function (_AgoraRteWebClientBas2) {
649
654
  (0, _inherits2["default"])(AgoraRteWebClientSub, _AgoraRteWebClientBas2);
650
655
  var _super3 = _createSuper(AgoraRteWebClientSub);
651
- function AgoraRteWebClientSub(channelName, configs, base, connectionType) {
652
- var _this4;
656
+ function AgoraRteWebClientSub(channelName, configs, base, connectionType, audioRawDataDispatcher) {
657
+ var _this5;
653
658
  (0, _classCallCheck2["default"])(this, AgoraRteWebClientSub);
654
- _this4 = _super3.call(this, channelName, configs, base, connectionType);
655
- _this4._publishThread = void 0;
656
- _this4._publishThread = new _thread2.AgoraRtePublishThreadSub(_this4._client, configs);
659
+ _this5 = _super3.call(this, channelName, configs, base, connectionType, audioRawDataDispatcher);
660
+ _this5._publishThread = void 0;
661
+ _this5._publishThread = new _thread2.AgoraRtePublishThreadSub(_this5._client, configs);
657
662
 
658
663
  //publish thread needs to wait till join channel
659
- _this4._publishThread.runnable = false;
660
- return _this4;
664
+ _this5._publishThread.runnable = false;
665
+ return _this5;
661
666
  }
662
667
  (0, _createClass2["default"])(AgoraRteWebClientSub, [{
663
668
  key: "muteLocalVideo",
@@ -22,7 +22,6 @@ export declare class RtcAudioDeviceManagerWeb extends RtcAudioDeviceManagerBase
22
22
  private _playbackDeviceIds;
23
23
  constructor(adapter: RtcAdapterWeb, noDevicePermission?: boolean);
24
24
  onLocalAudioPlaybackTestVolumeChanged(cb: LocalAudioPlaybackVolumeIndicatorEvent): number;
25
- onAudioFrame(cb: (buffer: ArrayBuffer) => void): number;
26
25
  onLocalAudioTrackStateChanged(cb: LocalAudioTrackStateEvent): number;
27
26
  onLocalAudioVolume(cb: (volume: number) => void): number;
28
27
  onLocalRecordingDeviceListChanged(cb: (addNewDevice: boolean, newDevices: AGRtcDeviceInfo[], allDevices: AGRtcDeviceInfo[]) => void): number;
@@ -214,11 +214,6 @@ var RtcAudioDeviceManagerWeb = /*#__PURE__*/function (_RtcAudioDeviceManage) {
214
214
  value: function onLocalAudioPlaybackTestVolumeChanged(cb) {
215
215
  return this.adapter.onLocalAudioPlaybackTestVolumeChanged(cb);
216
216
  }
217
- }, {
218
- key: "onAudioFrame",
219
- value: function onAudioFrame(cb) {
220
- return this.adapter.onAudioFrame(cb);
221
- }
222
217
  }, {
223
218
  key: "onLocalAudioTrackStateChanged",
224
219
  value: function onLocalAudioTrackStateChanged(cb) {
@@ -0,0 +1,61 @@
1
+ import { ILocalAudioTrack, IRemoteAudioTrack } from 'agora-rtc-sdk-ng';
2
+ import { Logger } from '../../../logger';
3
+ import { AgoraRteAudioRawDataConfig, AgoraRteAudioRawDataObserver, AgoraRteAudioRawDataPosition, AgoraRteAudioRawData } from '../../../media/type';
4
+ declare type CallbackRawDataRecorded = (rawData: AgoraRteAudioRawData) => void;
5
+ declare type CallbackRawDataBeforeMixed = (rawData: AgoraRteAudioRawData, streamUuid: string, channelName: string) => void;
6
+ declare type CallbackObserverChanged = (position: AgoraRteAudioRawDataPosition) => void;
7
+ declare type CallbackMicrophoneTrackCreated = (track: ILocalAudioTrack) => void;
8
+ declare type CallbackAudioTrackSubscribed = (track: IRemoteAudioTrack, streamUuid: string, channelName: string) => void;
9
+ declare type CallbackMicrophoneTrackDestroyed = () => void;
10
+ declare type CallbackAudioTrackUnsubscribed = (streamUuid: string, channelName: string) => void;
11
+ declare type CallbackStart = () => void;
12
+ declare type CallbackStop = () => void;
13
+ export declare class AGAudioRawDataDispatcher {
14
+ logger: Logger;
15
+ private static DEFAULT_FRAME_SIZE;
16
+ private _microphoneTrackRawDataObservers;
17
+ private _audioTrackRawDataObservers;
18
+ private _eventBus;
19
+ private _configs;
20
+ private _state;
21
+ setConfig(config: AgoraRteAudioRawDataConfig, position: AgoraRteAudioRawDataPosition): void;
22
+ get isStarted(): boolean;
23
+ get microphoneTrackRawDataConfig(): AgoraRteAudioRawDataConfig;
24
+ get audioTrackRawDataConfig(): AgoraRteAudioRawDataConfig;
25
+ get hasMicrophoneRawDataObservers(): boolean;
26
+ get hasAudioTrackRawDataObservers(): boolean;
27
+ private _callbackAudioRawRecorded;
28
+ private _callbackAudioRawBeforeMixed;
29
+ start(): void;
30
+ stop(): void;
31
+ dispatch(event: 'AudioRawDataRecored', ...params: Parameters<CallbackRawDataRecorded>): void;
32
+ dispatch(event: 'AudioRawDataBeforeMixed', ...params: Parameters<CallbackRawDataBeforeMixed>): void;
33
+ dispatch(event: 'ObserverChanged', ...params: Parameters<CallbackObserverChanged>): void;
34
+ dispatch(event: 'MicrophoneTrackCreated', ...params: Parameters<CallbackMicrophoneTrackCreated>): void;
35
+ dispatch(event: 'AudioTrackSubscribed', ...params: Parameters<CallbackAudioTrackSubscribed>): void;
36
+ dispatch(event: 'MicrophoneTrackDestroyed', ...params: Parameters<CallbackMicrophoneTrackDestroyed>): void;
37
+ dispatch(event: 'AudioTrackUnsubscribed', ...params: Parameters<CallbackAudioTrackUnsubscribed>): void;
38
+ dispatch(event: 'Start', ...params: Parameters<CallbackStart>): void;
39
+ dispatch(event: 'Stop', ...params: Parameters<CallbackStop>): void;
40
+ register(event: 'AudioRawDataRecored', callback: CallbackRawDataRecorded): void;
41
+ register(event: 'AudioRawDataBeforeMixed', callback: CallbackRawDataBeforeMixed): void;
42
+ register(event: 'ObserverChanged', callback: CallbackObserverChanged): void;
43
+ register(event: 'MicrophoneTrackCreated', callback: CallbackMicrophoneTrackCreated): void;
44
+ register(event: 'AudioTrackSubscribed', callback: CallbackAudioTrackSubscribed): void;
45
+ register(event: 'MicrophoneTrackDestroyed', callback: CallbackMicrophoneTrackDestroyed): void;
46
+ register(event: 'AudioTrackUnsubscribed', callback: CallbackAudioTrackUnsubscribed): void;
47
+ register(event: 'Start', callback: CallbackStart): void;
48
+ register(event: 'Stop', callback: CallbackStop): void;
49
+ unregister(event: 'AudioRawDataRecored', callback: CallbackRawDataRecorded): void;
50
+ unregister(event: 'AudioRawDataBeforeMixed', callback: CallbackRawDataBeforeMixed): void;
51
+ unregister(event: 'ObserverChanged', callback: CallbackObserverChanged): void;
52
+ unregister(event: 'MicrophoneTrackCreated', callback: CallbackMicrophoneTrackCreated): void;
53
+ unregister(event: 'AudioTrackSubscribed', callback: CallbackAudioTrackSubscribed): void;
54
+ unregister(event: 'MicrophoneTrackDestroyed', callback: CallbackMicrophoneTrackDestroyed): void;
55
+ unregister(event: 'AudioTrackUnsubscribed', callback: CallbackAudioTrackUnsubscribed): void;
56
+ unregister(event: 'Start', callback: CallbackStart): void;
57
+ unregister(event: 'Stop', callback: CallbackStop): void;
58
+ addAudioRawDataObserver(observer: AgoraRteAudioRawDataObserver, position: AgoraRteAudioRawDataPosition): void;
59
+ removeAudioRawDataObserver(observer: AgoraRteAudioRawDataObserver, position: AgoraRteAudioRawDataPosition): void;
60
+ }
61
+ export {};
@@ -0,0 +1,166 @@
1
+ "use strict";
2
+
3
+ require("core-js/modules/es.object.define-property.js");
4
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.AGAudioRawDataDispatcher = void 0;
9
+ require("core-js/modules/es.array.iterator.js");
10
+ require("core-js/modules/es.object.to-string.js");
11
+ require("core-js/modules/es.set.js");
12
+ require("core-js/modules/es.string.iterator.js");
13
+ require("core-js/modules/esnext.set.add-all.js");
14
+ require("core-js/modules/esnext.set.delete-all.js");
15
+ require("core-js/modules/esnext.set.difference.js");
16
+ require("core-js/modules/esnext.set.every.js");
17
+ require("core-js/modules/esnext.set.filter.js");
18
+ require("core-js/modules/esnext.set.find.js");
19
+ require("core-js/modules/esnext.set.intersection.js");
20
+ require("core-js/modules/esnext.set.is-disjoint-from.js");
21
+ require("core-js/modules/esnext.set.is-subset-of.js");
22
+ require("core-js/modules/esnext.set.is-superset-of.js");
23
+ require("core-js/modules/esnext.set.join.js");
24
+ require("core-js/modules/esnext.set.map.js");
25
+ require("core-js/modules/esnext.set.reduce.js");
26
+ require("core-js/modules/esnext.set.some.js");
27
+ require("core-js/modules/esnext.set.symmetric-difference.js");
28
+ require("core-js/modules/esnext.set.union.js");
29
+ require("core-js/modules/web.dom-collections.iterator.js");
30
+ require("core-js/modules/es.array.for-each.js");
31
+ require("core-js/modules/web.dom-collections.for-each.js");
32
+ require("core-js/modules/es.array.concat.js");
33
+ require("core-js/modules/es.object.get-own-property-descriptor.js");
34
+ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
35
+ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
36
+ var _applyDecoratedDescriptor2 = _interopRequireDefault(require("@babel/runtime/helpers/applyDecoratedDescriptor"));
37
+ var _events = require("../../../utils/events");
38
+ var _decorator = require("../../../decorator");
39
+ var _type = require("../../../media/type");
40
+ var _dec, _dec2, _dec3, _dec4, _class, _class2, _class3;
41
+ var AGAudioRawDataDispatcher = (_dec = _decorator.Log.attach({
42
+ proxyMethods: false
43
+ }), _dec2 = _decorator.Log.trace, _dec3 = _decorator.Log.trace, _dec4 = _decorator.Log.trace, _dec(_class = (_class2 = (_class3 = /*#__PURE__*/function () {
44
+ function AGAudioRawDataDispatcher() {
45
+ (0, _classCallCheck2["default"])(this, AGAudioRawDataDispatcher);
46
+ this.logger = void 0;
47
+ this._microphoneTrackRawDataObservers = new Set();
48
+ this._audioTrackRawDataObservers = new Set();
49
+ this._eventBus = new _events.AGEventEmitter();
50
+ this._configs = {};
51
+ this._state = 0;
52
+ }
53
+ (0, _createClass2["default"])(AGAudioRawDataDispatcher, [{
54
+ key: "setConfig",
55
+ value: function setConfig(config, position) {
56
+ this._configs[position] = config;
57
+ }
58
+ }, {
59
+ key: "isStarted",
60
+ get: function get() {
61
+ return this._state === 1;
62
+ }
63
+ }, {
64
+ key: "microphoneTrackRawDataConfig",
65
+ get: function get() {
66
+ var _this$_configs$AgoraR;
67
+ return (_this$_configs$AgoraR = this._configs[_type.AgoraRteAudioRawDataPosition.record]) !== null && _this$_configs$AgoraR !== void 0 ? _this$_configs$AgoraR : {
68
+ frameSize: AGAudioRawDataDispatcher.DEFAULT_FRAME_SIZE
69
+ };
70
+ }
71
+ }, {
72
+ key: "audioTrackRawDataConfig",
73
+ get: function get() {
74
+ var _this$_configs$AgoraR2;
75
+ return (_this$_configs$AgoraR2 = this._configs[_type.AgoraRteAudioRawDataPosition.beforeMixed]) !== null && _this$_configs$AgoraR2 !== void 0 ? _this$_configs$AgoraR2 : {
76
+ frameSize: AGAudioRawDataDispatcher.DEFAULT_FRAME_SIZE
77
+ };
78
+ }
79
+ }, {
80
+ key: "hasMicrophoneRawDataObservers",
81
+ get: function get() {
82
+ return !!this._microphoneTrackRawDataObservers.size;
83
+ }
84
+ }, {
85
+ key: "hasAudioTrackRawDataObservers",
86
+ get: function get() {
87
+ return !!this._audioTrackRawDataObservers.size;
88
+ }
89
+ }, {
90
+ key: "_callbackAudioRawRecorded",
91
+ value: function _callbackAudioRawRecorded(rawData) {
92
+ this._microphoneTrackRawDataObservers.forEach(function (observer) {
93
+ observer(rawData);
94
+ });
95
+ }
96
+ }, {
97
+ key: "_callbackAudioRawBeforeMixed",
98
+ value: function _callbackAudioRawBeforeMixed(rawData, channelName, streamUuid) {
99
+ this._audioTrackRawDataObservers.forEach(function (observer) {
100
+ observer(rawData, channelName, streamUuid);
101
+ });
102
+ }
103
+ }, {
104
+ key: "start",
105
+ value: function start() {
106
+ this._state = 1;
107
+ this.register('AudioRawDataBeforeMixed', this._callbackAudioRawBeforeMixed);
108
+ this.register('AudioRawDataRecored', this._callbackAudioRawRecorded);
109
+ this.dispatch('Start');
110
+ }
111
+ }, {
112
+ key: "stop",
113
+ value: function stop() {
114
+ this._state = 0;
115
+ this.unregister('AudioRawDataBeforeMixed', this._callbackAudioRawBeforeMixed);
116
+ this.unregister('AudioRawDataRecored', this._callbackAudioRawRecorded);
117
+ this.dispatch('Stop');
118
+ }
119
+ }, {
120
+ key: "dispatch",
121
+ value: function dispatch(event) {
122
+ if (this.isStarted) {
123
+ var _this$_eventBus;
124
+ for (var _len = arguments.length, params = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
125
+ params[_key - 1] = arguments[_key];
126
+ }
127
+ this.logger.debug("event: ".concat(event, ", params:"), params);
128
+ (_this$_eventBus = this._eventBus).emit.apply(_this$_eventBus, [event].concat(params));
129
+ }
130
+ }
131
+ }, {
132
+ key: "register",
133
+ value: function register(event, callback) {
134
+ this._eventBus.on(event, callback);
135
+ }
136
+ }, {
137
+ key: "unregister",
138
+ value: function unregister(event, callback) {
139
+ this._eventBus.off(event, callback);
140
+ }
141
+ }, {
142
+ key: "addAudioRawDataObserver",
143
+ value: function addAudioRawDataObserver(observer, position) {
144
+ if (position === _type.AgoraRteAudioRawDataPosition.record) {
145
+ this._microphoneTrackRawDataObservers.add(observer.onAudioRawDataRecored);
146
+ }
147
+ if (position === _type.AgoraRteAudioRawDataPosition.beforeMixed) {
148
+ this._audioTrackRawDataObservers.add(observer.onAudioRawDataBeforeMixed);
149
+ }
150
+ this.dispatch('ObserverChanged', position);
151
+ }
152
+ }, {
153
+ key: "removeAudioRawDataObserver",
154
+ value: function removeAudioRawDataObserver(observer, position) {
155
+ if (position === _type.AgoraRteAudioRawDataPosition.record) {
156
+ this._microphoneTrackRawDataObservers["delete"](observer.onAudioRawDataRecored);
157
+ }
158
+ if (position === _type.AgoraRteAudioRawDataPosition.beforeMixed) {
159
+ this._audioTrackRawDataObservers["delete"](observer.onAudioRawDataBeforeMixed);
160
+ }
161
+ this.dispatch('ObserverChanged', position);
162
+ }
163
+ }]);
164
+ return AGAudioRawDataDispatcher;
165
+ }(), _class3.DEFAULT_FRAME_SIZE = 1024, _class3), ((0, _applyDecoratedDescriptor2["default"])(_class2.prototype, "setConfig", [_dec2], Object.getOwnPropertyDescriptor(_class2.prototype, "setConfig"), _class2.prototype), (0, _applyDecoratedDescriptor2["default"])(_class2.prototype, "_callbackAudioRawRecorded", [_decorator.bound], Object.getOwnPropertyDescriptor(_class2.prototype, "_callbackAudioRawRecorded"), _class2.prototype), (0, _applyDecoratedDescriptor2["default"])(_class2.prototype, "_callbackAudioRawBeforeMixed", [_decorator.bound], Object.getOwnPropertyDescriptor(_class2.prototype, "_callbackAudioRawBeforeMixed"), _class2.prototype), (0, _applyDecoratedDescriptor2["default"])(_class2.prototype, "start", [_dec3], Object.getOwnPropertyDescriptor(_class2.prototype, "start"), _class2.prototype), (0, _applyDecoratedDescriptor2["default"])(_class2.prototype, "stop", [_dec4], Object.getOwnPropertyDescriptor(_class2.prototype, "stop"), _class2.prototype)), _class2)) || _class);
166
+ exports.AGAudioRawDataDispatcher = AGAudioRawDataDispatcher;
@@ -6,11 +6,13 @@ import { AgoraRtcVideoCanvas } from '../../canvas';
6
6
  import { AgoraRteVideoSourceType } from '../../../media/track';
7
7
  import { AgoraRteWebClientMain, AgoraRteWebClientSub } from './client';
8
8
  import { AGRtcConnectionType } from '../../channel';
9
- import { AGScreenShareDevice, AGAudioRawDataConfig, AGNetworkStats, AGRtcState, AGLowStreamParameter, AGBeautyEffect } from '../../type';
9
+ import { AGScreenShareDevice, AGNetworkStats, AGRtcState, AGLowStreamParameter, AGBeautyEffect } from '../../type';
10
10
  import { AgoraLatencyLevel } from '../../../../configs';
11
11
  import { AGChannelProfile } from '../../../../type';
12
12
  import { IBaseProcessor } from 'agora-rte-extension';
13
13
  import { Logger } from '../../../logger';
14
+ import { AGAudioRawDataDispatcher } from './dispatcher';
15
+ import { AgoraRteAudioRawDataConfig, AgoraRteAudioRawDataObserver, AgoraRteAudioRawDataPosition } from '../../../media/type';
14
16
  export interface RtcAdapterWebConfig {
15
17
  codec: SDK_CODEC;
16
18
  mode: SDK_MODE;
@@ -21,11 +23,12 @@ export declare class RtcAdapterWeb extends RtcAdapterBase {
21
23
  private _channels;
22
24
  private _vdm;
23
25
  private _adm;
26
+ private _audioRawDataDispatcher;
27
+ private _audioPlayer;
24
28
  readonly cameraThread: AgoraRteCameraThread;
25
29
  readonly micThread: AgoraRteMicrophoneThread;
26
30
  readonly screenThread: AgoraRteScreenShareThread;
27
31
  readonly remoteCanvas: Map<string, AgoraRtcVideoCanvas>;
28
- private _audioPlayer;
29
32
  static defaultConfigs: RtcAdapterWebConfig;
30
33
  private _configs?;
31
34
  get configs(): {
@@ -62,11 +65,12 @@ export declare class RtcAdapterWeb extends RtcAdapterBase {
62
65
  onLocalAudioTrackStateChanged(cb: LocalAudioTrackStateEvent): number;
63
66
  onLocalScreenShareTrackStateChanged(cb: LocalVideoTrackStateEvent): number;
64
67
  onLocalAudioVolume(cb: (volume: number) => void): number;
65
- onAudioFrame(cb: (buffer: ArrayBuffer) => void): number;
66
68
  setBeautyEffectOptions(enable: boolean, options: AGBeautyEffect): number;
67
69
  setAudioFrameCallback(): number;
68
70
  stopAudioFrameCallback(): number;
69
- setAudioRawDataConfig(config: AGAudioRawDataConfig): number;
71
+ addAudioRawDataObserver(observer: AgoraRteAudioRawDataObserver, position: AgoraRteAudioRawDataPosition): number;
72
+ removeAudioRawDataObserver(observer: AgoraRteAudioRawDataObserver, position: AgoraRteAudioRawDataPosition): number;
73
+ setAudioRawDataConfig(config: AgoraRteAudioRawDataConfig, position: AgoraRteAudioRawDataPosition): number;
70
74
  hasScreenSharePermission(): boolean;
71
75
  takeSnapshot(_channel: string, _streamUuid: number, _filePath: string): Promise<never>;
72
76
  getCurrentFrameData(channelName: string, streamUuid: string, isLocal: boolean): ImageData;
@@ -83,7 +87,7 @@ export declare class RtcChannelAdapterWeb extends RtcChannelAdapterBase {
83
87
  readonly main: AgoraRteWebClientMain;
84
88
  readonly sub: AgoraRteWebClientSub;
85
89
  channelName: string;
86
- constructor(channelName: string, configs: RtcAdapterWebConfig, base: RtcAdapterBase);
90
+ constructor(channelName: string, configs: RtcAdapterWebConfig, base: RtcAdapterBase, audioRawDataDispatcher: AGAudioRawDataDispatcher);
87
91
  getSessionId(): any;
88
92
  private client;
89
93
  setLatencyLevel(level: AgoraLatencyLevel): void;