agora-electron-sdk 4.2.2-dev.7 → 4.2.3-dev.3

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 (36) hide show
  1. package/CHANGELOG.md +6 -1
  2. package/README.md +2 -2
  3. package/js/Private/AgoraBase.js +18 -2
  4. package/js/Private/AgoraMediaBase.js +4 -0
  5. package/js/Private/IAgoraMusicContentCenter.js +4 -0
  6. package/js/Private/IAgoraRtcEngine.js +15 -1
  7. package/js/Private/impl/IAgoraRtcEngineExImpl.js +20 -0
  8. package/js/Private/impl/IAgoraRtcEngineImpl.js +16 -0
  9. package/js/Private/internal/IrisApiEngine.js +74 -57
  10. package/js/Renderer/RendererManager.js +1 -1
  11. package/package.json +3 -3
  12. package/ts/Private/AgoraBase.ts +18 -2
  13. package/ts/Private/AgoraMediaBase.ts +8 -8
  14. package/ts/Private/IAgoraMusicContentCenter.ts +8 -0
  15. package/ts/Private/IAgoraRtcEngine.ts +31 -14
  16. package/ts/Private/IAgoraRtcEngineEx.ts +13 -5
  17. package/ts/Private/impl/IAgoraRtcEngineExImpl.ts +35 -1
  18. package/ts/Private/impl/IAgoraRtcEngineImpl.ts +21 -0
  19. package/ts/Private/internal/IrisApiEngine.ts +74 -59
  20. package/ts/Renderer/RendererManager.ts +1 -1
  21. package/types/Private/AgoraBase.d.ts +20 -4
  22. package/types/Private/AgoraBase.d.ts.map +1 -1
  23. package/types/Private/AgoraMediaBase.d.ts +9 -9
  24. package/types/Private/AgoraMediaBase.d.ts.map +1 -1
  25. package/types/Private/IAgoraMusicContentCenter.d.ts +9 -1
  26. package/types/Private/IAgoraMusicContentCenter.d.ts.map +1 -1
  27. package/types/Private/IAgoraRtcEngine.d.ts +29 -14
  28. package/types/Private/IAgoraRtcEngine.d.ts.map +1 -1
  29. package/types/Private/IAgoraRtcEngineEx.d.ts +8 -5
  30. package/types/Private/IAgoraRtcEngineEx.d.ts.map +1 -1
  31. package/types/Private/impl/IAgoraRtcEngineExImpl.d.ts +3 -1
  32. package/types/Private/impl/IAgoraRtcEngineExImpl.d.ts.map +1 -1
  33. package/types/Private/impl/IAgoraRtcEngineImpl.d.ts +3 -1
  34. package/types/Private/impl/IAgoraRtcEngineImpl.d.ts.map +1 -1
  35. package/types/Private/internal/IrisApiEngine.d.ts +2 -2
  36. package/types/Private/internal/IrisApiEngine.d.ts.map +1 -1
@@ -1022,7 +1022,7 @@ export class AdvancedAudioOptions {
1022
1022
  */
1023
1023
  export class ImageTrackOptions {
1024
1024
  /**
1025
- * The URL of the image that you want to use to replace the video feeds. The image must be in PNG format. This method supports adding an image from the local absolute or relative file path.
1025
+ * The image URL. Supported formats of images include JPEG, JPG, PNG and GIF. This method supports adding an image from the local absolute or relative file path.
1026
1026
  */
1027
1027
  imageUrl?: string;
1028
1028
  /**
@@ -1217,6 +1217,20 @@ export enum ProxyType {
1217
1217
  HttpsProxyType = 6,
1218
1218
  }
1219
1219
 
1220
+ /**
1221
+ * @ignore
1222
+ */
1223
+ export enum FeatureType {
1224
+ /**
1225
+ * @ignore
1226
+ */
1227
+ VideoVirtualBackground = 1,
1228
+ /**
1229
+ * @ignore
1230
+ */
1231
+ VideoBeautyEffect = 2,
1232
+ }
1233
+
1220
1234
  /**
1221
1235
  * The options for leaving a channel.
1222
1236
  */
@@ -1267,7 +1281,7 @@ export interface IRtcEngineEventHandler {
1267
1281
  *
1268
1282
  * @param channel The channel name.
1269
1283
  * @param uid The user ID.
1270
- * @param proxyType The proxy type connected. See CloudProxyType.
1284
+ * @param proxyType The proxy type connected. See ProxyType.
1271
1285
  * @param localProxyIp Reserved for future use.
1272
1286
  * @param elapsed The time elapsed (ms) from the user calling joinChannel until this callback is triggered.
1273
1287
  */
@@ -2899,7 +2913,7 @@ export abstract class IRtcEngine {
2899
2913
  * @param token The token generated on your server for authentication. When the token for preloading channels expires, you can update the token based on the number of channels you preload.
2900
2914
  * When preloading one channel, calling this method to pass in the new token.
2901
2915
  * When preloading more than one channels:
2902
- * If you use a wildcard token for all preloaded channels, call updatePreloadChannelToken to update the token.
2916
+ * If you use a wildcard token for all preloaded channels, call updatePreloadChannelToken to update the token. When generating a wildcard token, ensure the user ID is not set as 0.
2903
2917
  * If you use different tokens to preload different channels, call this method to pass in your user ID, channel name and the new token.
2904
2918
  * @param channelId The channel name that you want to preload. This parameter signifies the channel in which users engage in real-time audio and video interaction. Under the premise of the same App ID, users who fill in the same channel ID enter the same channel for audio and video interaction. The string length must be less than 64 bytes. Supported characters (89 characters in total):
2905
2919
  * All lowercase English letters: a to z.
@@ -2933,7 +2947,7 @@ export abstract class IRtcEngine {
2933
2947
  * @param token The token generated on your server for authentication. When the token for preloading channels expires, you can update the token based on the number of channels you preload.
2934
2948
  * When preloading one channel, calling this method to pass in the new token.
2935
2949
  * When preloading more than one channels:
2936
- * If you use a wildcard token for all preloaded channels, call updatePreloadChannelToken to update the token.
2950
+ * If you use a wildcard token for all preloaded channels, call updatePreloadChannelToken to update the token. When generating a wildcard token, ensure the user ID is not set as 0.
2937
2951
  * If you use different tokens to preload different channels, call this method to pass in your user ID, channel name and the new token.
2938
2952
  * @param channelId The channel name that you want to preload. This parameter signifies the channel in which users engage in real-time audio and video interaction. Under the premise of the same App ID, users who fill in the same channel ID enter the same channel for audio and video interaction. The string length must be less than 64 bytes. Supported characters (89 characters in total):
2939
2953
  * All lowercase English letters: a to z.
@@ -2985,7 +2999,7 @@ export abstract class IRtcEngine {
2985
2999
  * This method allows users to join only one channel at a time.
2986
3000
  * Ensure that the app ID you use to generate the token is the same app ID that you pass in the initialize method; otherwise, you may fail to join the channel by token.
2987
3001
  *
2988
- * @param token The token generated on your server for authentication.
3002
+ * @param token The token generated on your server for authentication. If you need to join different channels at the same time or switch between channels, Agora recommends using a wildcard token so that you don't need to apply for a new token every time joining a channel.
2989
3003
  * @param channelId The channel name. This parameter signifies the channel in which users engage in real-time audio and video interaction. Under the premise of the same App ID, users who fill in the same channel ID enter the same channel for audio and video interaction. The string length must be less than 64 bytes. Supported characters:
2990
3004
  * All lowercase English letters: a to z.
2991
3005
  * All uppercase English letters: A to Z.
@@ -3060,7 +3074,7 @@ export abstract class IRtcEngine {
3060
3074
  /**
3061
3075
  * Sets the channel profile.
3062
3076
  *
3063
- * After initializing the SDK, the default channel profile is the live streaming profile. You can call this method to set the usage scenario of the channel. For example, it prioritizes smoothness and low latency for a video call, and prioritizes video quality for the interactive live video streaming.
3077
+ * After initializing the SDK, the default channel profile is the live streaming profile. You can call this method to set the channel profile. The Agora SDK differentiates channel profiles and applies optimization algorithms accordingly. For example, it prioritizes smoothness and low latency for a video call and prioritizes video quality for interactive live video streaming.
3064
3078
  * To ensure the quality of real-time communication, Agora recommends that all users in a channel use the same channel profile.
3065
3079
  * This method must be called and set before joinChannel, and cannot be set again after joining the channel.
3066
3080
  * The default video encoding bitrate are different in different channel profiles. See setVideoEncoderConfiguration.
@@ -3081,7 +3095,7 @@ export abstract class IRtcEngine {
3081
3095
  * In the interactive live streaming profile, the SDK sets the user role as audience by default. You can call this method to set the user role as host. You can call this method either before or after joining a channel. If you call this method to set the user's role as the host before joining the channel and set the local video property through the setupLocalVideo method, the local video preview is automatically enabled when the user joins the channel. If you call this method to switch the user role after joining a channel, the SDK automatically does the following:
3082
3096
  * Calls muteLocalAudioStream and muteLocalVideoStream to change the publishing state.
3083
3097
  * Triggers onClientRoleChanged on the local client.
3084
- * Triggers onUserJoined or onUserOffline on the remote client. This method applies to the interactive live streaming profile (the profile parameter of setChannelProfile is ChannelProfileLiveBroadcasting) only.
3098
+ * Triggers onUserJoined or onUserOffline on the remote client. This method applies to the interactive live streaming profile (the profile parameter of setChannelProfile is set as ChannelProfileLiveBroadcasting) only.
3085
3099
  *
3086
3100
  * @param role The user role in the interactive live streaming. See ClientRoleType.
3087
3101
  * @param options The detailed options of a user, including the user level. See ClientRoleOptions.
@@ -4744,7 +4758,7 @@ export abstract class IRtcEngine {
4744
4758
  *
4745
4759
  * The SDK enables the low-quality video stream auto mode on the sender side by default (it does not actively sending low-quality video streams). The host identity receiver can initiate a low-quality video stream application at the receiving end by calling setRemoteVideoStreamType. After receiving the application, the sending end automatically switches to the low-quality video stream mode.
4746
4760
  * If you want to modify this behavior, you can call this method and modify the mode to DisableSimulcastStream (never send low-quality video streams) or EnableSimulcastStream (always send low-quality video streams).
4747
- * If you want to restore the default behavior after making changes, you can call this method again with mode set to AutoSimulcastStream. The difference and connection between this method and is as follows:
4761
+ * If you want to restore the default behavior after making changes, you can call this method again with mode set to AutoSimulcastStream. The difference and connection between this method and enableDualStreamMode is as follows:
4748
4762
  * When calling this method and setting mode to DisableSimulcastStream, it has the same effect as calling and setting enabled to false.
4749
4763
  * When calling this method and setting mode to EnableSimulcastStream, it has the same effect as calling and setting enabled to true.
4750
4764
  * Both methods can be called before and after joining a channel. If both methods are used, the settings in the method called later takes precedence.
@@ -5642,8 +5656,7 @@ export abstract class IRtcEngine {
5642
5656
  /**
5643
5657
  * Starts pushing media streams to a CDN without transcoding.
5644
5658
  *
5645
- * Ensure that you enable the Media Push service before using this function. See Enable Media Push.
5646
- * Call this method after joining a channel.
5659
+ * Call this method after joining a channel.
5647
5660
  * Only hosts in the LIVE_BROADCASTING profile can call this method.
5648
5661
  * If you want to retry pushing streams after a failed push, make sure to call stopRtmpStream first, then call this method to retry pushing streams; otherwise, the SDK returns the same error code as the last failed push. Agora recommends that you use the server-side Media Push function. You can call this method to push an audio or video stream to the specified CDN address. This method can push media streams to only one CDN address at a time, so if you need to push streams to multiple addresses, call this method multiple times. After you call this method, the SDK triggers the onRtmpStreamingStateChanged callback on the local client to report the state of the streaming.
5649
5662
  *
@@ -5661,8 +5674,7 @@ export abstract class IRtcEngine {
5661
5674
  /**
5662
5675
  * Starts Media Push and sets the transcoding configuration.
5663
5676
  *
5664
- * Agora recommends that you use the server-side Media Push function. You can call this method to push a live audio-and-video stream to the specified CDN address and set the transcoding configuration. This method can push media streams to only one CDN address at a time, so if you need to push streams to multiple addresses, call this method multiple times. After you call this method, the SDK triggers the onRtmpStreamingStateChanged callback on the local client to report the state of the streaming.
5665
- * Ensure that you enable the Media Push service before using this function. See Enable Media Push.
5677
+ * Agora recommends that you use the server-side Media Push function. You can call this method to push a live audio-and-video stream to the specified CDN address and set the transcoding configuration. This method can push media streams to only one CDN address at a time, so if you need to push streams to multiple addresses, call this method multiple times. Under one Agora project, the maximum number of concurrent tasks to push media streams is 200 by default. If you need a higher quota, contact. After you call this method, the SDK triggers the onRtmpStreamingStateChanged callback on the local client to report the state of the streaming.
5666
5678
  * Call this method after joining a channel.
5667
5679
  * Only hosts in the LIVE_BROADCASTING profile can call this method.
5668
5680
  * If you want to retry pushing streams after a failed push, make sure to call stopRtmpStream first, then call this method to retry pushing streams; otherwise, the SDK returns the same error code as the last failed push.
@@ -6119,7 +6131,7 @@ export abstract class IRtcEngine {
6119
6131
  * The local client: onLocalUserRegistered, onJoinChannelSuccess and onConnectionStateChanged callbacks.
6120
6132
  * The remote client: The onUserJoined callback, if the user is in the COMMUNICATION profile, and the onUserInfoUpdated callback if the user is a host in the LIVE_BROADCASTING profile. Once a user joins the channel, the user subscribes to the audio and video streams of all the other users in the channel by default, giving rise to usage and billing calculation. To stop subscribing to a specified stream or all remote streams, call the corresponding mute methods. To ensure smooth communication, use the same parameter type to identify the user. For example, if a user joins the channel with a user ID, then ensure all the other users use the user ID too. The same applies to the user account. If a user joins the channel with the Agora Web SDK, ensure that the ID of the user is set to the same parameter type.
6121
6133
  *
6122
- * @param token The token generated on your server for authentication.
6134
+ * @param token The token generated on your server for authentication. If you need to join different channels at the same time or switch between channels, Agora recommends using a wildcard token so that you don't need to apply for a new token every time joining a channel.
6123
6135
  * @param channelId The channel name. This parameter signifies the channel in which users engage in real-time audio and video interaction. Under the premise of the same App ID, users who fill in the same channel ID enter the same channel for audio and video interaction. The string length must be less than 64 bytes. Supported characters:
6124
6136
  * All lowercase English letters: a to z.
6125
6137
  * All uppercase English letters: A to Z.
@@ -6159,7 +6171,7 @@ export abstract class IRtcEngine {
6159
6171
  * The local client: onLocalUserRegistered, onJoinChannelSuccess and onConnectionStateChanged callbacks.
6160
6172
  * The remote client: The onUserJoined callback, if the user is in the COMMUNICATION profile, and the onUserInfoUpdated callback if the user is a host in the LIVE_BROADCASTING profile. Once a user joins the channel, the user subscribes to the audio and video streams of all the other users in the channel by default, giving rise to usage and billing calculation. To stop subscribing to a specified stream or all remote streams, call the corresponding mute methods. To ensure smooth communication, use the same parameter type to identify the user. For example, if a user joins the channel with a user ID, then ensure all the other users use the user ID too. The same applies to the user account. If a user joins the channel with the Agora Web SDK, ensure that the ID of the user is set to the same parameter type.
6161
6173
  *
6162
- * @param token The token generated on your server for authentication.
6174
+ * @param token The token generated on your server for authentication. If you need to join different channels at the same time or switch between channels, Agora recommends using a wildcard token so that you don't need to apply for a new token every time joining a channel.
6163
6175
  * @param channelId The channel name. This parameter signifies the channel in which users engage in real-time audio and video interaction. Under the premise of the same App ID, users who fill in the same channel ID enter the same channel for audio and video interaction. The string length must be less than 64 bytes. Supported characters:
6164
6176
  * All lowercase English letters: a to z.
6165
6177
  * All uppercase English letters: A to Z.
@@ -6598,6 +6610,11 @@ export abstract class IRtcEngine {
6598
6610
  */
6599
6611
  abstract getNtpWallTimeInMs(): number;
6600
6612
 
6613
+ /**
6614
+ * @ignore
6615
+ */
6616
+ abstract isFeatureAvailableOnDevice(type: FeatureType): boolean;
6617
+
6601
6618
  /**
6602
6619
  * Gets the IAudioDeviceManager object to manage audio devices.
6603
6620
  *
@@ -16,7 +16,7 @@ import {
16
16
  VideoSubscriptionOptions,
17
17
  WatermarkOptions,
18
18
  } from './AgoraBase';
19
- import { RenderModeType } from './AgoraMediaBase';
19
+ import { ContentInspectConfig, RenderModeType } from './AgoraMediaBase';
20
20
  import {
21
21
  ChannelMediaOptions,
22
22
  IRtcEngine,
@@ -52,7 +52,7 @@ export abstract class IRtcEngineEx extends IRtcEngine {
52
52
  * If you want to join the same channel from different devices, ensure that the user IDs are different for all devices.
53
53
  * Ensure that the app ID you use to generate the token is the same as the app ID used when creating the IRtcEngine instance.
54
54
  *
55
- * @param token The token generated on your server for authentication.
55
+ * @param token The token generated on your server for authentication. If you need to join different channels at the same time or switch between channels, Agora recommends using a wildcard token so that you don't need to apply for a new token every time joining a channel.
56
56
  * @param connection The connection information. See RtcConnection.
57
57
  * @param options The channel media options. See ChannelMediaOptions.
58
58
  *
@@ -78,7 +78,7 @@ export abstract class IRtcEngineEx extends IRtcEngine {
78
78
  *
79
79
  * This method lets the user leave the channel, for example, by hanging up or exiting the call. After calling joinChannelEx to join the channel, this method must be called to end the call before starting the next call. This method can be called whether or not a call is currently in progress. This method releases all resources related to the session. This method call is asynchronous. When this method returns, it does not necessarily mean that the user has left the channel. After you leave the channel, the SDK triggers the onLeaveChannel callback. After actually leaving the channel, the local user triggers the onLeaveChannel callback; after the user in the communication scenario and the host in the live streaming scenario leave the channel, the remote user triggers the onUserOffline callback.
80
80
  * If you call release immediately after calling this method, the SDK does not trigger the onLeaveChannel callback.
81
- * Calling leaveChannel will leave the channels joined by calling joinChannel and joinChannelEx.
81
+ * If you want to leave the channels that you joined by calling joinChannel and joinChannelEx, call the leaveChannel method.
82
82
  *
83
83
  * @param connection The connection information. See RtcConnection.
84
84
  * @param options The options for leaving the channel. See LeaveChannelOptions. This parameter only supports the stopMicrophoneRecording member in the LeaveChannelOptions settings; setting other members does not take effect.
@@ -641,8 +641,7 @@ export abstract class IRtcEngineEx extends IRtcEngine {
641
641
  /**
642
642
  * Starts pushing media streams to a CDN without transcoding.
643
643
  *
644
- * Ensure that you enable the Media Push service before using this function. See Enable Media Push.
645
- * Call this method after joining a channel.
644
+ * Call this method after joining a channel.
646
645
  * Only hosts in the LIVE_BROADCASTING profile can call this method.
647
646
  * If you want to retry pushing streams after a failed push, make sure to call stopRtmpStream first, then call this method to retry pushing streams; otherwise, the SDK returns the same error code as the last failed push. Agora recommends that you use the server-side Media Push function. You can call this method to push an audio or video stream to the specified CDN address. This method can push media streams to only one CDN address at a time, so if you need to push streams to multiple addresses, call this method multiple times. After you call this method, the SDK triggers the onRtmpStreamingStateChanged callback on the local client to report the state of the streaming.
648
647
  *
@@ -918,6 +917,15 @@ export abstract class IRtcEngineEx extends IRtcEngine {
918
917
  filePath: string
919
918
  ): number;
920
919
 
920
+ /**
921
+ * @ignore
922
+ */
923
+ abstract enableContentInspectEx(
924
+ enabled: boolean,
925
+ config: ContentInspectConfig,
926
+ connection: RtcConnection
927
+ ): number;
928
+
921
929
  /**
922
930
  * Enables tracing the video frame rendering process.
923
931
  *
@@ -15,7 +15,7 @@ import {
15
15
  VideoSubscriptionOptions,
16
16
  WatermarkOptions,
17
17
  } from '../AgoraBase';
18
- import { RenderModeType } from '../AgoraMediaBase';
18
+ import { ContentInspectConfig, RenderModeType } from '../AgoraMediaBase';
19
19
  import {
20
20
  ChannelMediaOptions,
21
21
  LeaveChannelOptions,
@@ -1494,6 +1494,40 @@ export class IRtcEngineExImpl extends IRtcEngineImpl implements IRtcEngineEx {
1494
1494
  return 'RtcEngineEx_takeSnapshotEx';
1495
1495
  }
1496
1496
 
1497
+ enableContentInspectEx(
1498
+ enabled: boolean,
1499
+ config: ContentInspectConfig,
1500
+ connection: RtcConnection
1501
+ ): number {
1502
+ const apiType = this.getApiTypeFromEnableContentInspectEx(
1503
+ enabled,
1504
+ config,
1505
+ connection
1506
+ );
1507
+ const jsonParams = {
1508
+ enabled: enabled,
1509
+ config: config,
1510
+ connection: connection,
1511
+ toJSON: () => {
1512
+ return {
1513
+ enabled: enabled,
1514
+ config: config,
1515
+ connection: connection,
1516
+ };
1517
+ },
1518
+ };
1519
+ const jsonResults = callIrisApi.call(this, apiType, jsonParams);
1520
+ return jsonResults.result;
1521
+ }
1522
+
1523
+ protected getApiTypeFromEnableContentInspectEx(
1524
+ enabled: boolean,
1525
+ config: ContentInspectConfig,
1526
+ connection: RtcConnection
1527
+ ): string {
1528
+ return 'RtcEngineEx_enableContentInspectEx';
1529
+ }
1530
+
1497
1531
  startMediaRenderingTracingEx(connection: RtcConnection): number {
1498
1532
  const apiType = this.getApiTypeFromStartMediaRenderingTracingEx(connection);
1499
1533
  const jsonParams = {
@@ -74,6 +74,7 @@ import {
74
74
  ChannelMediaOptions,
75
75
  CloudProxyType,
76
76
  DirectCdnStreamingMediaOptions,
77
+ FeatureType,
77
78
  IDirectCdnStreamingEventHandler,
78
79
  IMetadataObserver,
79
80
  IRtcEngine,
@@ -6707,6 +6708,26 @@ export class IRtcEngineImpl implements IRtcEngine {
6707
6708
  return 'RtcEngine_getNtpWallTimeInMs';
6708
6709
  }
6709
6710
 
6711
+ isFeatureAvailableOnDevice(type: FeatureType): boolean {
6712
+ const apiType = this.getApiTypeFromIsFeatureAvailableOnDevice(type);
6713
+ const jsonParams = {
6714
+ type: type,
6715
+ toJSON: () => {
6716
+ return {
6717
+ type: type,
6718
+ };
6719
+ },
6720
+ };
6721
+ const jsonResults = callIrisApi.call(this, apiType, jsonParams);
6722
+ return jsonResults.result;
6723
+ }
6724
+
6725
+ protected getApiTypeFromIsFeatureAvailableOnDevice(
6726
+ type: FeatureType
6727
+ ): string {
6728
+ return 'RtcEngine_isFeatureAvailableOnDevice';
6729
+ }
6730
+
6710
6731
  getAudioDeviceManager(): IAudioDeviceManager {
6711
6732
  const apiType = this.getApiTypeFromGetAudioDeviceManager();
6712
6733
  const jsonParams = {};
@@ -92,7 +92,11 @@ export type EventProcessor<T extends ProcessorType> = {
92
92
  type: (data: any) => EVENT_TYPE;
93
93
  func: Function[];
94
94
  preprocess?: (event: string, data: any, buffers: Uint8Array[]) => void;
95
- handlers: (data: any) => (T | undefined)[] | undefined;
95
+ handlers: (
96
+ event: string,
97
+ data: any,
98
+ buffers: Uint8Array[]
99
+ ) => (T | undefined)[] | undefined;
96
100
  };
97
101
 
98
102
  export enum EVENT_TYPE {
@@ -151,7 +155,8 @@ export const EVENT_PROCESSORS: EventProcessors = {
151
155
  data.audioFrame.buffer = buffers[0];
152
156
  }
153
157
  },
154
- handlers: () => MediaEngineInternal._audio_frame_observers,
158
+ handlers: (event: string, data: any) =>
159
+ MediaEngineInternal._audio_frame_observers,
155
160
  },
156
161
  IVideoFrameObserver: {
157
162
  suffix: 'VideoFrameObserver_',
@@ -170,14 +175,15 @@ export const EVENT_PROCESSORS: EventProcessors = {
170
175
  data.videoFrame.alphaBuffer = buffers[4];
171
176
  }
172
177
  },
173
- handlers: () => MediaEngineInternal._video_frame_observers,
178
+ handlers: (event: string, data: any) =>
179
+ MediaEngineInternal._video_frame_observers,
174
180
  },
175
181
  IAudioSpectrumObserver: {
176
182
  suffix: 'AudioSpectrumObserver_',
177
183
  type: (data: any) =>
178
184
  data.playerId === 0 ? EVENT_TYPE.IRtcEngine : EVENT_TYPE.IMediaPlayer,
179
185
  func: [processIAudioSpectrumObserver],
180
- handlers: (data: any) =>
186
+ handlers: (event: string, data: any) =>
181
187
  data.playerId === 0
182
188
  ? RtcEngineExInternal._audio_spectrum_observers
183
189
  : MediaPlayerInternal._audio_spectrum_observers.get(data.playerId),
@@ -201,7 +207,8 @@ export const EVENT_PROCESSORS: EventProcessors = {
201
207
  break;
202
208
  }
203
209
  },
204
- handlers: () => RtcEngineExInternal._audio_encoded_frame_observers,
210
+ handlers: (event: string, data: any) =>
211
+ RtcEngineExInternal._audio_encoded_frame_observers,
205
212
  },
206
213
  IVideoEncodedFrameObserver: {
207
214
  suffix: 'VideoEncodedFrameObserver_',
@@ -220,13 +227,14 @@ export const EVENT_PROCESSORS: EventProcessors = {
220
227
  break;
221
228
  }
222
229
  },
223
- handlers: () => MediaEngineInternal._video_encoded_frame_observers,
230
+ handlers: (event: string, data: any) =>
231
+ MediaEngineInternal._video_encoded_frame_observers,
224
232
  },
225
233
  IMediaPlayerSourceObserver: {
226
234
  suffix: 'MediaPlayerSourceObserver_',
227
235
  type: () => EVENT_TYPE.IMediaPlayer,
228
236
  func: [processIMediaPlayerSourceObserver],
229
- handlers: (data: any) =>
237
+ handlers: (event: string, data: any) =>
230
238
  MediaPlayerInternal._source_observers.get(data.playerId),
231
239
  },
232
240
  IAudioPcmFrameSink: {
@@ -242,7 +250,7 @@ export const EVENT_PROCESSORS: EventProcessors = {
242
250
  data.frame.data_ = Array.from(buffers[0] ?? []);
243
251
  }
244
252
  },
245
- handlers: (data: any) =>
253
+ handlers: (event: string, data: any) =>
246
254
  MediaPlayerInternal._audio_frame_observers.get(data.playerId),
247
255
  },
248
256
  IMediaPlayerVideoFrameObserver: {
@@ -262,14 +270,14 @@ export const EVENT_PROCESSORS: EventProcessors = {
262
270
  data.frame.alphaBuffer = buffers[4];
263
271
  }
264
272
  },
265
- handlers: (data: any) =>
273
+ handlers: (event: string, data: any) =>
266
274
  MediaPlayerInternal._video_frame_observers.get(data.playerId),
267
275
  },
268
276
  IMediaRecorderObserver: {
269
277
  suffix: 'MediaRecorderObserver_',
270
278
  type: () => EVENT_TYPE.IMediaRecorder,
271
279
  func: [processIMediaRecorderObserver],
272
- handlers: (data: any) => [
280
+ handlers: (event: string, data: any) => [
273
281
  MediaRecorderInternal._observers.get(data.nativeHandle),
274
282
  ],
275
283
  },
@@ -290,13 +298,15 @@ export const EVENT_PROCESSORS: EventProcessors = {
290
298
  break;
291
299
  }
292
300
  },
293
- handlers: () => RtcEngineExInternal._metadata_observer,
301
+ handlers: (event: string, data: any) =>
302
+ RtcEngineExInternal._metadata_observer,
294
303
  },
295
304
  IDirectCdnStreamingEventHandler: {
296
305
  suffix: 'DirectCdnStreamingEventHandler_',
297
306
  type: () => EVENT_TYPE.IRtcEngine,
298
307
  func: [processIDirectCdnStreamingEventHandler],
299
- handlers: () => RtcEngineExInternal._direct_cdn_streaming_event_handler,
308
+ handlers: (event: string, data: any) =>
309
+ RtcEngineExInternal._direct_cdn_streaming_event_handler,
300
310
  },
301
311
  IRtcEngineEventHandler: {
302
312
  suffix: 'RtcEngineEventHandler_',
@@ -314,7 +324,12 @@ export const EVENT_PROCESSORS: EventProcessors = {
314
324
  break;
315
325
  }
316
326
  },
317
- handlers: () => RtcEngineExInternal._event_handlers,
327
+ handlers: (event: string, data: any) => {
328
+ if (event === 'onLocalVideoStats' && 'connection' in data) {
329
+ return undefined;
330
+ }
331
+ return RtcEngineExInternal._event_handlers;
332
+ },
318
333
  },
319
334
  IMusicContentCenterEventHandler: {
320
335
  suffix: 'MusicContentCenterEventHandler_',
@@ -333,73 +348,64 @@ export const EVENT_PROCESSORS: EventProcessors = {
333
348
  }
334
349
  }
335
350
  },
336
- handlers: () => MusicContentCenterInternal._event_handlers,
351
+ handlers: (event: string, data: any) =>
352
+ MusicContentCenterInternal._event_handlers,
337
353
  },
338
354
  };
339
355
 
340
- // some events are not needed, so ignore them
341
- function isIgnoredEvent(event: string, data: any) {
342
- if (event === 'onLocalVideoStats' && 'connection' in data) {
343
- return true;
344
- } else {
345
- return false;
346
- }
347
- }
348
-
349
356
  function handleEvent(...[event, data, buffers]: any) {
350
357
  if (isDebuggable()) {
351
358
  console.info('onEvent', event, data, buffers);
352
359
  }
353
360
 
354
- let _data: any;
355
- try {
356
- _data = JSON.parse(data) ?? {};
357
- } catch (e) {
358
- _data = {};
359
- }
360
-
361
361
  let _event: string = event;
362
- let processor: EventProcessor<any> = EVENT_PROCESSORS.IRtcEngineEventHandler;
363
-
364
- Object.values(EVENT_PROCESSORS).some((it) => {
365
- const p = it as EventProcessor<any>;
366
- if (
367
- _event.startsWith(p.suffix) &&
368
- processor.handlers(_data) !== undefined
369
- ) {
370
- processor = p;
371
- const reg = new RegExp(`^${processor.suffix}`, 'g');
372
- _event = _event.replace(reg, '');
373
- return true;
374
- }
375
- return false;
362
+ let processor: EventProcessor<any> | undefined = Object.values(
363
+ EVENT_PROCESSORS
364
+ ).find((it) => {
365
+ return _event.startsWith(it.suffix);
376
366
  });
377
367
 
368
+ if (processor === undefined) {
369
+ return;
370
+ }
371
+
372
+ // allow replace preprocess to undefined for avoid call more than once
373
+ processor = { ...processor };
374
+
375
+ const reg = new RegExp(`^${processor.suffix}`, 'g');
376
+ _event = _event.replace(reg, '');
378
377
  if (_event.endsWith('Ex')) {
379
378
  _event = _event.replace(/Ex$/g, '');
380
379
  }
381
380
 
382
- if (isIgnoredEvent(_event, _data)) {
383
- return false;
381
+ let _data: any;
382
+ try {
383
+ _data = JSON.parse(data) ?? {};
384
+ } catch (e) {
385
+ _data = {};
384
386
  }
387
+
385
388
  const _buffers: Uint8Array[] = buffers;
386
- if (processor.preprocess) {
387
- processor.preprocess(_event, _data, _buffers);
388
- }
389
389
 
390
390
  if (processor.handlers) {
391
- processor.handlers(_data)?.map((value) => {
392
- if (value) {
393
- processor.func.map((it) => {
394
- it(value, _event, _data);
395
- });
391
+ const handlers = processor.handlers(_event, _data, _buffers);
392
+ if (handlers !== undefined) {
393
+ if (processor.preprocess) {
394
+ processor.preprocess(_event, _data, _buffers);
395
+ // call preprocess only once
396
+ processor.preprocess = undefined;
396
397
  }
397
- });
398
+ handlers.map((value) => {
399
+ if (value) {
400
+ processor!.func.map((it) => {
401
+ it(value, _event, _data);
402
+ });
403
+ }
404
+ });
405
+ }
398
406
  }
399
407
 
400
- emitEvent(_event, processor, _data);
401
-
402
- return true;
408
+ emitEvent(_event, processor, _data, _buffers);
403
409
  }
404
410
 
405
411
  /**
@@ -540,7 +546,16 @@ export function callIrisApi(funcName: string, params: any): any {
540
546
  export function emitEvent<EventType extends keyof T, T extends ProcessorType>(
541
547
  eventType: EventType,
542
548
  eventProcessor: EventProcessor<T>,
543
- data: any
549
+ data: any,
550
+ buffers?: Uint8Array[]
544
551
  ): void {
552
+ if (DeviceEventEmitter.listenerCount(eventType as string) === 0) {
553
+ return;
554
+ }
555
+ if (eventProcessor.preprocess) {
556
+ eventProcessor.preprocess(eventType as string, data, buffers ?? []);
557
+ // call preprocess only once
558
+ eventProcessor.preprocess = undefined;
559
+ }
545
560
  DeviceEventEmitter.emit(eventType as string, eventProcessor, data);
546
561
  }
@@ -376,7 +376,7 @@ export class RendererManager extends IRendererManager {
376
376
  break;
377
377
  }
378
378
  if (finalResult.ret !== 0) {
379
- logWarn('GetVideoFrame ret is', finalResult.ret, rendererItem);
379
+ logDebug('GetVideoFrame ret is', finalResult.ret, rendererItem);
380
380
  return;
381
381
  }
382
382
  if (!finalResult.isNewFrame) {
@@ -434,7 +434,11 @@ export declare enum ErrorCodeType {
434
434
  /**
435
435
  * 1501: Permission to access the camera is not granted. Check whether permission to access the camera permission is granted.
436
436
  */
437
- ErrVdmCameraNotAuthorized = 1501
437
+ ErrVdmCameraNotAuthorized = 1501,
438
+ /**
439
+ * @ignore
440
+ */
441
+ ErrAdmApplicationLoopback = 2007
438
442
  }
439
443
  /**
440
444
  * @ignore
@@ -2027,7 +2031,15 @@ export declare enum LocalVideoStreamError {
2027
2031
  /**
2028
2032
  * @ignore
2029
2033
  */
2030
- LocalVideoStreamErrorScreenCaptureWindowRecoverFromMinimized = 25
2034
+ LocalVideoStreamErrorScreenCaptureWindowHidden = 25,
2035
+ /**
2036
+ * @ignore
2037
+ */
2038
+ LocalVideoStreamErrorScreenCaptureWindowRecoverFromHidden = 26,
2039
+ /**
2040
+ * @ignore
2041
+ */
2042
+ LocalVideoStreamErrorScreenCaptureWindowRecoverFromMinimized = 27
2031
2043
  }
2032
2044
  /**
2033
2045
  * Remote audio states.
@@ -3011,7 +3023,7 @@ export declare enum ConnectionChangedReasonType {
3011
3023
  */
3012
3024
  ConnectionChangedClientIpAddressChanged = 13,
3013
3025
  /**
3014
- * 14: Timeout for the keep-alive of the connection between the SDK and the Agora edge server. The connection state changes to .
3026
+ * 14: Timeout for the keep-alive of the connection between the SDK and the Agora edge server. The SDK tries to reconnect to the server automatically.
3015
3027
  */
3016
3028
  ConnectionChangedKeepAliveTimeout = 14,
3017
3029
  /**
@@ -3150,7 +3162,11 @@ export declare enum NetworkType {
3150
3162
  /**
3151
3163
  * 5: The network type is mobile 4G.
3152
3164
  */
3153
- NetworkTypeMobile4g = 5
3165
+ NetworkTypeMobile4g = 5,
3166
+ /**
3167
+ * @ignore
3168
+ */
3169
+ NetworkTypeMobile5g = 6
3154
3170
  }
3155
3171
  /**
3156
3172
  * Setting mode of the view.