Skip to content

Commit e78f864

Browse files
guoxianzhesda-robdependabot[bot]Nero-Hu
authored
feat: support native 4.3.1 (#1168)
* feat: support native 4.3.1 * chore: call unregisterEventHandler before release ep-555 * chore: bump to 0313 build * feat: bump example electron version to 22.0.0 * feat: allow unregister event handler by specific eventHandler * chore: optimize * chore: optimize * chore: optimize * chore: optimize * chore: optimize * chore: optimize * chore: optimize * [AUTO] Generate codes by terra (#1183) Co-authored-by: guoxianzhe <[email protected]> * chore: optimize * chore: startCameraCapture need pass format NMS-20523 * build(deps): bump tar from 6.1.14 to 6.2.1 in /example (#1181) * build(deps): bump express from 4.18.2 to 4.19.2 in /example (#1177) Bumps [express](https://github.com/expressjs/express) from 4.18.2 to 4.19.2. - [Release notes](https://github.com/expressjs/express/releases) - [Changelog](https://github.com/expressjs/express/blob/master/History.md) - [Commits](expressjs/express@4.18.2...4.19.2) --- updated-dependencies: - dependency-name: express dependency-type: indirect ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * build(deps): bump es5-ext from 0.10.62 to 0.10.64 in /example (#1162) Bumps [es5-ext](https://github.com/medikoo/es5-ext) from 0.10.62 to 0.10.64. - [Release notes](https://github.com/medikoo/es5-ext/releases) - [Changelog](https://github.com/medikoo/es5-ext/blob/main/CHANGELOG.md) - [Commits](medikoo/es5-ext@v0.10.62...v0.10.64) --- updated-dependencies: - dependency-name: es5-ext dependency-type: indirect ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: guoxianzhe <[email protected]> * build(deps): bump follow-redirects from 1.15.2 to 1.15.6 in /example (#1172) Bumps [follow-redirects](https://github.com/follow-redirects/follow-redirects) from 1.15.2 to 1.15.6. - [Release notes](https://github.com/follow-redirects/follow-redirects/releases) - [Commits](follow-redirects/follow-redirects@v1.15.2...v1.15.6) --- updated-dependencies: - dependency-name: follow-redirects dependency-type: indirect ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * build(deps): bump tar from 6.1.14 to 6.2.1 in /example Bumps [tar](https://github.com/isaacs/node-tar) from 6.1.14 to 6.2.1. - [Release notes](https://github.com/isaacs/node-tar/releases) - [Changelog](https://github.com/isaacs/node-tar/blob/main/CHANGELOG.md) - [Commits](isaacs/node-tar@v6.1.14...v6.2.1) --- updated-dependencies: - dependency-name: tar dependency-type: indirect ... Signed-off-by: dependabot[bot] <[email protected]> --------- Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: guoxianzhe <[email protected]> * [AUTO] Generate codes by terra (#1184) Co-authored-by: guoxianzhe <[email protected]> * [AUTO] Generate comments by iris-doc (#1185) Co-authored-by: Nero-Hu <[email protected]> * [AUTO] Generate codes by terra (#1187) Co-authored-by: guoxianzhe <[email protected]> * chore: optimize --------- Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: sda-rob <[email protected]> Co-authored-by: guoxianzhe <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Nero-Hu <[email protected]>
1 parent e65354e commit e78f864

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+1045
-550
lines changed

Diff for: .eslintignore

+1
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ build/
44
js/
55
types/
66
ts/Private/ti/
7+
native/

Diff for: .gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -241,4 +241,5 @@ js/
241241
docs/
242242
types/
243243
iris/
244+
native/
244245
appId.*

Diff for: CMakeLists.txt

+3-3
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,11 @@ file(GLOB TARGET_AGORA_NODE_EXT_FILE
6161
if (${CMAKE_SYSTEM_NAME} STREQUAL "Darwin")
6262
set(AGORA_IRIS_PROJECT_ARCH "MAC")
6363
set(AGORA_RTC_SDK_PATH
64-
${CMAKE_CURRENT_SOURCE_DIR}/iris/DCG/Agora_Native_SDK_for_Mac_FULL/libs
64+
${CMAKE_CURRENT_SOURCE_DIR}/native/Agora_Native_SDK_for_Mac_FULL/libs
6565
)
6666
# native rtc sdk library
6767
set(AGORA_RTC_SDK_LIBRARY
68-
${AGORA_RTC_SDK_PATH}/*.framework
68+
${AGORA_RTC_SDK_PATH}/*.xcframework/macos-arm64_x86_64/*.framework
6969
)
7070

7171
# iris sdk path
@@ -98,7 +98,7 @@ elseif (${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
9898

9999
# native rtc sdk path
100100
set(AGORA_RTC_SDK_PATH
101-
${CMAKE_CURRENT_SOURCE_DIR}/iris/DCG)
101+
${CMAKE_CURRENT_SOURCE_DIR}/native)
102102

103103
file(GLOB AGORA_RTC_SDK_LIBRARY
104104
${AGORA_RTC_SDK_PATH}/Agora_Native_SDK_for_Windows_FULL/sdk/${AGORA_RTC_PROJECT_ARCH}/*.dll

Diff for: example/package.json

+2-3
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@
7979
"agora-electron-sdk": "4.3.0",
8080
"antd": "^4.20.3",
8181
"download": "^8.0.0",
82-
"ffi-napi": "^4.0.3",
82+
"koffi": "^2.8.0",
8383
"react": "^18.1.0",
8484
"react-color": "^2.19.3",
8585
"react-dom": "^18.1.0",
@@ -94,13 +94,12 @@
9494
"@pmmmwh/react-refresh-webpack-plugin": "^0.5.6",
9595
"@teamsupercell/typings-for-css-modules-loader": "^2.5.1",
9696
"@types/download": "^8.0.2",
97-
"@types/ffi-napi": "^4.0.7",
9897
"@types/react": "^16.9.44",
9998
"@types/react-color": "^3.0.6",
10099
"@types/react-dom": "^18.0.3",
101100
"@types/react-router-dom": "^5.1.6",
102101
"@types/ref-napi": "^3.0.7",
103-
"electron": "18.2.3",
102+
"electron": "22.0.0",
104103
"electron-builder": "^23.1.0",
105104
"electron-webpack": "^2.8.2",
106105
"fork-ts-checker-webpack-plugin": "^4.1.2",

Diff for: example/src/renderer/examples/advanced/LocalVideoTranscoder/LocalVideoTranscoder.tsx

+8-1
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,14 @@ export default class LocalVideoTranscoder
163163
this.error('sourceType is invalid');
164164
return;
165165
}
166-
this.engine?.startCameraCapture(sourceType, { deviceId });
166+
this.engine?.startCameraCapture(sourceType, {
167+
deviceId,
168+
format: {
169+
width: 1920,
170+
height: 1080,
171+
fps: 60,
172+
},
173+
});
167174
};
168175

169176
stopCameraCapture = (deviceId: string) => {

Diff for: example/src/renderer/examples/advanced/ProcessVideoRawData/ProcessVideoRawData.tsx

+45-29
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,7 @@ import {
99
createAgoraRtcEngine,
1010
} from 'agora-electron-sdk';
1111
import download from 'download';
12-
import ffi, {
13-
LibraryObject,
14-
LibraryObjectDefinitionToLibraryDefinition,
15-
} from 'ffi-napi';
12+
import ffi, { IKoffiLib } from 'koffi';
1613
import React, { ReactElement } from 'react';
1714

1815
import {
@@ -33,12 +30,21 @@ if (process.platform === 'darwin') {
3330
}
3431
pluginName += postfix;
3532

36-
type PluginType = {
37-
EnablePlugin: ['bool', ['uint64']];
38-
DisablePlugin: ['bool', ['uint64']];
39-
CreateSamplePlugin: ['uint64', ['uint64']];
40-
DestroySamplePlugin: ['void', ['uint64']];
41-
CreateSampleAudioPlugin: ['uint64', ['uint64']];
33+
type FuncConfig = {
34+
returnType: string;
35+
paramTypes: string[];
36+
};
37+
38+
type PluginConfig = {
39+
[funcName: string]: FuncConfig;
40+
};
41+
42+
const pluginConfig: PluginConfig = {
43+
CreateSampleAudioPlugin: { returnType: 'uint64', paramTypes: ['uint64'] },
44+
CreateSamplePlugin: { returnType: 'uint64', paramTypes: ['uint64'] },
45+
DestroySamplePlugin: { returnType: 'void', paramTypes: ['uint64'] },
46+
DisablePlugin: { returnType: 'bool', paramTypes: ['uint64'] },
47+
EnablePlugin: { returnType: 'bool', paramTypes: ['uint64'] },
4248
};
4349

4450
interface State extends BaseVideoComponentState {
@@ -49,9 +55,16 @@ export default class ProcessVideoRawData
4955
extends BaseComponent<{}, State>
5056
implements IRtcEngineEventHandler
5157
{
52-
pluginLibrary?: LibraryObject<
53-
LibraryObjectDefinitionToLibraryDefinition<PluginType>
54-
>;
58+
nativeLib?: IKoffiLib;
59+
pluginLibrary: {
60+
[funcName: string]: Function;
61+
} = {
62+
CreateSampleAudioPlugin: () => {},
63+
CreateSamplePlugin: () => {},
64+
DestroySamplePlugin: () => {},
65+
DisablePlugin: () => {},
66+
EnablePlugin: () => {},
67+
};
5568
plugin?: string | number;
5669
pluginAudio?: string | number;
5770

@@ -137,21 +150,24 @@ export default class ProcessVideoRawData
137150
console.log(`download success`);
138151
}
139152

140-
const plugin: PluginType = {
141-
CreateSampleAudioPlugin: ['uint64', ['uint64']],
142-
CreateSamplePlugin: ['uint64', ['uint64']],
143-
DestroySamplePlugin: ['void', ['uint64']],
144-
DisablePlugin: ['bool', ['uint64']],
145-
EnablePlugin: ['bool', ['uint64']],
146-
};
147-
this.pluginLibrary ??= ffi.Library(dllPath, plugin);
153+
this.nativeLib ??= ffi.load(dllPath);
154+
155+
for (const [funcName, { returnType, paramTypes }] of Object.entries(
156+
pluginConfig
157+
)) {
158+
this.pluginLibrary[funcName] = this.nativeLib.func(
159+
funcName,
160+
returnType,
161+
paramTypes
162+
);
163+
}
148164

149165
const handle = this.engine?.getNativeHandle();
150166
if (handle !== undefined) {
151-
this.plugin = this.pluginLibrary.CreateSamplePlugin(handle);
152-
this.pluginLibrary.EnablePlugin(this.plugin);
153-
this.pluginAudio = this.pluginLibrary.CreateSampleAudioPlugin(handle);
154-
this.pluginLibrary.EnablePlugin(this.pluginAudio);
167+
this.plugin = this.pluginLibrary.CreateSamplePlugin?.(handle);
168+
this.pluginLibrary.EnablePlugin?.(this.plugin);
169+
this.pluginAudio = this.pluginLibrary.CreateSampleAudioPlugin?.(handle);
170+
this.pluginLibrary.EnablePlugin?.(this.pluginAudio);
155171
}
156172
this.setState({ enablePlugin: true });
157173
};
@@ -161,16 +177,16 @@ export default class ProcessVideoRawData
161177
*/
162178
disablePlugin = () => {
163179
if (this.plugin) {
164-
this.pluginLibrary?.DisablePlugin(this.plugin);
165-
this.pluginLibrary?.DestroySamplePlugin(this.plugin);
180+
this.pluginLibrary.DisablePlugin?.(this.plugin);
181+
this.pluginLibrary.DestroySamplePlugin?.(this.plugin);
166182
this.plugin = undefined;
167183
} else {
168184
this.error('plugin is invalid');
169185
}
170186

171187
if (this.pluginAudio) {
172-
this.pluginLibrary?.DisablePlugin(this.pluginAudio);
173-
this.pluginLibrary?.DestroySamplePlugin(this.pluginAudio);
188+
this.pluginLibrary.DisablePlugin?.(this.pluginAudio);
189+
this.pluginLibrary.DestroySamplePlugin?.(this.pluginAudio);
174190
this.pluginAudio = undefined;
175191
} else {
176192
this.error('pluginAudio is invalid');

Diff for: example/webpack.renderer.additions.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ module.exports = function (config) {
8181
// ...config.externals,
8282
'webpack',
8383
'agora-electron-sdk',
84-
'ffi-napi',
84+
'koffi',
8585
'ref-napi',
8686
];
8787
console.log('config', config.module.rules);

0 commit comments

Comments
 (0)