agora-electron-sdk 4.2.2-dev.4 → 4.2.2-dev.6

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 (64) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/js/Private/AgoraBase.js +121 -51
  3. package/js/Private/AgoraMediaBase.js +9 -7
  4. package/js/Private/IAgoraRtcEngine.js +11 -11
  5. package/js/Private/IAgoraRtcEngineEx.js +1 -1
  6. package/js/Private/IAgoraSpatialAudio.js +2 -2
  7. package/js/Private/impl/IAgoraMediaEngineImpl.js +12 -6
  8. package/js/Private/impl/IAgoraRtcEngineImpl.js +7 -7
  9. package/js/Private/internal/MusicContentCenterInternal.js +3 -0
  10. package/js/Private/internal/RtcEngineExInternal.js +24 -7
  11. package/js/Private/ti/IAgoraRtcEngine-ti.js +2 -2
  12. package/js/Renderer/WebGLRenderer/index.js +19 -19
  13. package/js/Renderer/YUVCanvasRenderer/index.js +1 -1
  14. package/package.json +3 -3
  15. package/scripts/zipBuild.js +3 -1
  16. package/ts/Private/AgoraBase.ts +278 -131
  17. package/ts/Private/AgoraMediaBase.ts +52 -34
  18. package/ts/Private/AgoraMediaPlayerTypes.ts +8 -5
  19. package/ts/Private/IAgoraLog.ts +7 -3
  20. package/ts/Private/IAgoraMediaEngine.ts +73 -31
  21. package/ts/Private/IAgoraMediaPlayer.ts +126 -64
  22. package/ts/Private/IAgoraMediaPlayerSource.ts +3 -1
  23. package/ts/Private/IAgoraRtcEngine.ts +1307 -519
  24. package/ts/Private/IAgoraRtcEngineEx.ts +227 -94
  25. package/ts/Private/IAgoraSpatialAudio.ts +70 -35
  26. package/ts/Private/IAudioDeviceManager.ts +61 -31
  27. package/ts/Private/impl/IAgoraMediaEngineImpl.ts +12 -6
  28. package/ts/Private/impl/IAgoraRtcEngineImpl.ts +9 -11
  29. package/ts/Private/internal/MusicContentCenterInternal.ts +4 -0
  30. package/ts/Private/internal/RtcEngineExInternal.ts +36 -14
  31. package/ts/Private/ti/IAgoraRtcEngine-ti.ts +2 -2
  32. package/ts/Renderer/WebGLRenderer/index.ts +26 -21
  33. package/ts/Renderer/YUVCanvasRenderer/index.ts +1 -1
  34. package/types/Private/AgoraBase.d.ts +278 -131
  35. package/types/Private/AgoraBase.d.ts.map +1 -1
  36. package/types/Private/AgoraMediaBase.d.ts +52 -34
  37. package/types/Private/AgoraMediaBase.d.ts.map +1 -1
  38. package/types/Private/AgoraMediaPlayerTypes.d.ts +8 -5
  39. package/types/Private/AgoraMediaPlayerTypes.d.ts.map +1 -1
  40. package/types/Private/IAgoraLog.d.ts +7 -3
  41. package/types/Private/IAgoraLog.d.ts.map +1 -1
  42. package/types/Private/IAgoraMediaEngine.d.ts +73 -31
  43. package/types/Private/IAgoraMediaEngine.d.ts.map +1 -1
  44. package/types/Private/IAgoraMediaPlayer.d.ts +126 -64
  45. package/types/Private/IAgoraMediaPlayer.d.ts.map +1 -1
  46. package/types/Private/IAgoraMediaPlayerSource.d.ts +3 -1
  47. package/types/Private/IAgoraMediaPlayerSource.d.ts.map +1 -1
  48. package/types/Private/IAgoraRtcEngine.d.ts +1308 -519
  49. package/types/Private/IAgoraRtcEngine.d.ts.map +1 -1
  50. package/types/Private/IAgoraRtcEngineEx.d.ts +227 -94
  51. package/types/Private/IAgoraRtcEngineEx.d.ts.map +1 -1
  52. package/types/Private/IAgoraSpatialAudio.d.ts +70 -35
  53. package/types/Private/IAgoraSpatialAudio.d.ts.map +1 -1
  54. package/types/Private/IAudioDeviceManager.d.ts +61 -31
  55. package/types/Private/IAudioDeviceManager.d.ts.map +1 -1
  56. package/types/Private/impl/IAgoraMediaEngineImpl.d.ts +2 -2
  57. package/types/Private/impl/IAgoraMediaEngineImpl.d.ts.map +1 -1
  58. package/types/Private/impl/IAgoraRtcEngineImpl.d.ts +5 -5
  59. package/types/Private/impl/IAgoraRtcEngineImpl.d.ts.map +1 -1
  60. package/types/Private/internal/MusicContentCenterInternal.d.ts +1 -0
  61. package/types/Private/internal/MusicContentCenterInternal.d.ts.map +1 -1
  62. package/types/Private/internal/RtcEngineExInternal.d.ts.map +1 -1
  63. package/types/Renderer/WebGLRenderer/index.d.ts +1 -1
  64. package/types/Renderer/WebGLRenderer/index.d.ts.map +1 -1
@@ -458,7 +458,7 @@ export class RtcEngineExInternal extends IRtcEngineExImpl {
458
458
  channelId: string,
459
459
  userAccount: string
460
460
  ): string {
461
- return 'RtcEngine_preloadChannelWithUserAccount2';
461
+ return 'RtcEngine_preloadChannel2';
462
462
  }
463
463
 
464
464
  override getAudioDeviceManager(): IAudioDeviceManager {
@@ -533,27 +533,49 @@ export class RtcEngineExInternal extends IRtcEngineExImpl {
533
533
  iconSize: Size,
534
534
  includeScreen: boolean
535
535
  ): ScreenCaptureSourceInfo[] {
536
- return super
537
- .getScreenCaptureSources(thumbSize, iconSize, includeScreen)
538
- .map((value: any) => {
539
- if (value.thumbImage.buffer == 0) {
540
- value.thumbImage.buffer = undefined;
536
+ const apiType = this.getApiTypeFromGetScreenCaptureSources(
537
+ thumbSize,
538
+ iconSize,
539
+ includeScreen
540
+ );
541
+ const jsonParams = {
542
+ thumbSize: thumbSize,
543
+ iconSize: iconSize,
544
+ includeScreen: includeScreen,
545
+ toJSON: () => {
546
+ return {
547
+ thumbSize: thumbSize,
548
+ iconSize: iconSize,
549
+ includeScreen: includeScreen,
550
+ };
551
+ },
552
+ };
553
+ const { result, sources } = callIrisApi.call(this, apiType, jsonParams);
554
+ const screenCaptureSources = result.map(
555
+ (value: ScreenCaptureSourceInfo) => {
556
+ if (!value.thumbImage?.buffer || !value.thumbImage?.length) {
557
+ value.thumbImage!.buffer = undefined;
541
558
  } else {
542
- value.thumbImage.buffer = AgoraEnv.AgoraElectronBridge.GetBuffer(
543
- value.thumbImage.buffer,
544
- value.thumbImage?.length
559
+ value.thumbImage!.buffer = AgoraEnv.AgoraElectronBridge.GetBuffer(
560
+ value.thumbImage!.buffer as unknown as number,
561
+ value.thumbImage.length!
545
562
  );
546
563
  }
547
- if (value.iconImage.buffer == 0) {
548
- value.iconImage.buffer = undefined;
564
+ if (!value.iconImage?.buffer || !value.iconImage?.length) {
565
+ value.iconImage!.buffer = undefined;
549
566
  } else {
550
567
  value.iconImage.buffer = AgoraEnv.AgoraElectronBridge.GetBuffer(
551
- value.iconImage.buffer,
552
- value.iconImage.length
568
+ value.iconImage!.buffer as unknown as number,
569
+ value.iconImage.length!
553
570
  );
554
571
  }
555
572
  return value;
556
- });
573
+ }
574
+ );
575
+ callIrisApi.call(this, 'RtcEngine_releaseScreenCaptureSources', {
576
+ sources,
577
+ });
578
+ return screenCaptureSources;
557
579
  }
558
580
 
559
581
  override setupLocalVideo(canvas: VideoCanvas): number {
@@ -25,7 +25,7 @@ export const IRtcEngineEventHandler = t.iface([], {
25
25
  "onDownlinkNetworkInfoUpdated": t.opt(t.func("void", t.param("info", "DownlinkNetworkInfo"))),
26
26
  "onLastmileQuality": t.opt(t.func("void", t.param("quality", "QualityType"))),
27
27
  "onFirstLocalVideoFrame": t.opt(t.func("void", t.param("source", "VideoSourceType"), t.param("width", "number"), t.param("height", "number"), t.param("elapsed", "number"))),
28
- "onFirstLocalVideoFramePublished": t.opt(t.func("void", t.param("connection", "RtcConnection"), t.param("elapsed", "number"))),
28
+ "onFirstLocalVideoFramePublished": t.opt(t.func("void", t.param("source", "VideoSourceType"), t.param("elapsed", "number"))),
29
29
  "onFirstRemoteVideoDecoded": t.opt(t.func("void", t.param("connection", "RtcConnection"), t.param("remoteUid", "number"), t.param("width", "number"), t.param("height", "number"), t.param("elapsed", "number"))),
30
30
  "onVideoSizeChanged": t.opt(t.func("void", t.param("connection", "RtcConnection"), t.param("sourceType", "VideoSourceType"), t.param("uid", "number"), t.param("width", "number"), t.param("height", "number"), t.param("rotation", "number"))),
31
31
  "onLocalVideoStateChanged": t.opt(t.func("void", t.param("source", "VideoSourceType"), t.param("state", "LocalVideoStreamState"), t.param("error", "LocalVideoStreamError"))),
@@ -40,7 +40,7 @@ export const IRtcEngineEventHandler = t.iface([], {
40
40
  "onUserEnableLocalVideo": t.opt(t.func("void", t.param("connection", "RtcConnection"), t.param("remoteUid", "number"), t.param("enabled", "boolean"))),
41
41
  "onLocalAudioStats": t.opt(t.func("void", t.param("connection", "RtcConnection"), t.param("stats", "LocalAudioStats"))),
42
42
  "onRemoteAudioStats": t.opt(t.func("void", t.param("connection", "RtcConnection"), t.param("stats", "RemoteAudioStats"))),
43
- "onLocalVideoStats": t.opt(t.func("void", t.param("connection", "RtcConnection"), t.param("stats", "LocalVideoStats"))),
43
+ "onLocalVideoStats": t.opt(t.func("void", t.param("source", "VideoSourceType"), t.param("stats", "LocalVideoStats"))),
44
44
  "onRemoteVideoStats": t.opt(t.func("void", t.param("connection", "RtcConnection"), t.param("stats", "RemoteVideoStats"))),
45
45
  "onCameraReady": t.opt(t.func("void")),
46
46
  "onCameraFocusAreaChanged": t.opt(t.func("void", t.param("x", "number"), t.param("y", "number"), t.param("width", "number"), t.param("height", "number"))),
@@ -46,7 +46,6 @@ const yuvShaderSource =
46
46
 
47
47
  export class GlRenderer extends IRenderer {
48
48
  gl: WebGL2RenderingContext | undefined | null;
49
- handleContextLost: any;
50
49
  program: any;
51
50
  positionLocation: any;
52
51
  texCoordLocation: any;
@@ -127,6 +126,12 @@ export class GlRenderer extends IRenderer {
127
126
  logWarn('webgl renderer unbind happen some error', e);
128
127
  }
129
128
 
129
+ this.canvas &&
130
+ this.canvas.removeEventListener(
131
+ 'webglcontextlost',
132
+ this.handleContextLost,
133
+ false
134
+ );
130
135
  this.canvas = undefined;
131
136
  this.container = undefined;
132
137
  this.parentElement = undefined;
@@ -448,6 +453,25 @@ export class GlRenderer extends IRenderer {
448
453
  }
449
454
  }
450
455
 
456
+ private handleContextLost = () => {
457
+ try {
458
+ this.canvas &&
459
+ this.canvas.removeEventListener(
460
+ 'webglcontextlost',
461
+ this.handleContextLost,
462
+ false
463
+ );
464
+ } catch (error) {
465
+ logWarn('webglcontextlost error', error);
466
+ } finally {
467
+ this.gl = undefined;
468
+ this.failInitRenderCB &&
469
+ this.failInitRenderCB({
470
+ error: 'Browser not support! No WebGL detected.',
471
+ });
472
+ }
473
+ };
474
+
451
475
  private initCanvas(
452
476
  view: HTMLElement,
453
477
  width: number,
@@ -487,28 +511,9 @@ export class GlRenderer extends IRenderer {
487
511
  preserveDrawingBuffer: true,
488
512
  });
489
513
  // context list after toggle resolution on electron 12.0.6
490
- let handleContextLost = () => {
491
- try {
492
- this.gl = null;
493
- this.canvas &&
494
- this.canvas.removeEventListener(
495
- 'webglcontextlost',
496
- handleContextLost,
497
- false
498
- );
499
- } catch (error) {
500
- logWarn('webglcontextlost error', error);
501
- } finally {
502
- this.gl = undefined;
503
- this.failInitRenderCB &&
504
- this.failInitRenderCB({
505
- error: 'Browser not support! No WebGL detected.',
506
- });
507
- }
508
- };
509
514
  this.canvas.addEventListener(
510
515
  'webglcontextlost',
511
- handleContextLost,
516
+ this.handleContextLost,
512
517
  false
513
518
  );
514
519
  } catch (e) {
@@ -153,7 +153,7 @@ export class YUVCanvasRenderer extends IRenderer {
153
153
  this.canvas.style.transform = `scale(${scale.toString()})`;
154
154
 
155
155
  if (transformItems.length > 0) {
156
- this.canvas.style.transform = `${transformItems.join(' ')}`;
156
+ this.canvas.style.transform += ` ${transformItems.join(' ')}`;
157
157
  }
158
158
  }
159
159
  }