Skip to content

Commit

Permalink
feat: support native 4.3.1 (#1168)
Browse files Browse the repository at this point in the history
* 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]>
  • Loading branch information
5 people authored May 8, 2024
1 parent e65354e commit e78f864
Show file tree
Hide file tree
Showing 43 changed files with 1,045 additions and 550 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ build/
js/
types/
ts/Private/ti/
native/
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -241,4 +241,5 @@ js/
docs/
types/
iris/
native/
appId.*
6 changes: 3 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,11 @@ file(GLOB TARGET_AGORA_NODE_EXT_FILE
if (${CMAKE_SYSTEM_NAME} STREQUAL "Darwin")
set(AGORA_IRIS_PROJECT_ARCH "MAC")
set(AGORA_RTC_SDK_PATH
${CMAKE_CURRENT_SOURCE_DIR}/iris/DCG/Agora_Native_SDK_for_Mac_FULL/libs
${CMAKE_CURRENT_SOURCE_DIR}/native/Agora_Native_SDK_for_Mac_FULL/libs
)
# native rtc sdk library
set(AGORA_RTC_SDK_LIBRARY
${AGORA_RTC_SDK_PATH}/*.framework
${AGORA_RTC_SDK_PATH}/*.xcframework/macos-arm64_x86_64/*.framework
)

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

# native rtc sdk path
set(AGORA_RTC_SDK_PATH
${CMAKE_CURRENT_SOURCE_DIR}/iris/DCG)
${CMAKE_CURRENT_SOURCE_DIR}/native)

file(GLOB AGORA_RTC_SDK_LIBRARY
${AGORA_RTC_SDK_PATH}/Agora_Native_SDK_for_Windows_FULL/sdk/${AGORA_RTC_PROJECT_ARCH}/*.dll
Expand Down
5 changes: 2 additions & 3 deletions example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
"agora-electron-sdk": "4.3.0",
"antd": "^4.20.3",
"download": "^8.0.0",
"ffi-napi": "^4.0.3",
"koffi": "^2.8.0",
"react": "^18.1.0",
"react-color": "^2.19.3",
"react-dom": "^18.1.0",
Expand All @@ -94,13 +94,12 @@
"@pmmmwh/react-refresh-webpack-plugin": "^0.5.6",
"@teamsupercell/typings-for-css-modules-loader": "^2.5.1",
"@types/download": "^8.0.2",
"@types/ffi-napi": "^4.0.7",
"@types/react": "^16.9.44",
"@types/react-color": "^3.0.6",
"@types/react-dom": "^18.0.3",
"@types/react-router-dom": "^5.1.6",
"@types/ref-napi": "^3.0.7",
"electron": "18.2.3",
"electron": "22.0.0",
"electron-builder": "^23.1.0",
"electron-webpack": "^2.8.2",
"fork-ts-checker-webpack-plugin": "^4.1.2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,14 @@ export default class LocalVideoTranscoder
this.error('sourceType is invalid');
return;
}
this.engine?.startCameraCapture(sourceType, { deviceId });
this.engine?.startCameraCapture(sourceType, {
deviceId,
format: {
width: 1920,
height: 1080,
fps: 60,
},
});
};

stopCameraCapture = (deviceId: string) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,7 @@ import {
createAgoraRtcEngine,
} from 'agora-electron-sdk';
import download from 'download';
import ffi, {
LibraryObject,
LibraryObjectDefinitionToLibraryDefinition,
} from 'ffi-napi';
import ffi, { IKoffiLib } from 'koffi';
import React, { ReactElement } from 'react';

import {
Expand All @@ -33,12 +30,21 @@ if (process.platform === 'darwin') {
}
pluginName += postfix;

type PluginType = {
EnablePlugin: ['bool', ['uint64']];
DisablePlugin: ['bool', ['uint64']];
CreateSamplePlugin: ['uint64', ['uint64']];
DestroySamplePlugin: ['void', ['uint64']];
CreateSampleAudioPlugin: ['uint64', ['uint64']];
type FuncConfig = {
returnType: string;
paramTypes: string[];
};

type PluginConfig = {
[funcName: string]: FuncConfig;
};

const pluginConfig: PluginConfig = {
CreateSampleAudioPlugin: { returnType: 'uint64', paramTypes: ['uint64'] },
CreateSamplePlugin: { returnType: 'uint64', paramTypes: ['uint64'] },
DestroySamplePlugin: { returnType: 'void', paramTypes: ['uint64'] },
DisablePlugin: { returnType: 'bool', paramTypes: ['uint64'] },
EnablePlugin: { returnType: 'bool', paramTypes: ['uint64'] },
};

interface State extends BaseVideoComponentState {
Expand All @@ -49,9 +55,16 @@ export default class ProcessVideoRawData
extends BaseComponent<{}, State>
implements IRtcEngineEventHandler
{
pluginLibrary?: LibraryObject<
LibraryObjectDefinitionToLibraryDefinition<PluginType>
>;
nativeLib?: IKoffiLib;
pluginLibrary: {
[funcName: string]: Function;
} = {
CreateSampleAudioPlugin: () => {},
CreateSamplePlugin: () => {},
DestroySamplePlugin: () => {},
DisablePlugin: () => {},
EnablePlugin: () => {},
};
plugin?: string | number;
pluginAudio?: string | number;

Expand Down Expand Up @@ -137,21 +150,24 @@ export default class ProcessVideoRawData
console.log(`download success`);
}

const plugin: PluginType = {
CreateSampleAudioPlugin: ['uint64', ['uint64']],
CreateSamplePlugin: ['uint64', ['uint64']],
DestroySamplePlugin: ['void', ['uint64']],
DisablePlugin: ['bool', ['uint64']],
EnablePlugin: ['bool', ['uint64']],
};
this.pluginLibrary ??= ffi.Library(dllPath, plugin);
this.nativeLib ??= ffi.load(dllPath);

for (const [funcName, { returnType, paramTypes }] of Object.entries(
pluginConfig
)) {
this.pluginLibrary[funcName] = this.nativeLib.func(
funcName,
returnType,
paramTypes
);
}

const handle = this.engine?.getNativeHandle();
if (handle !== undefined) {
this.plugin = this.pluginLibrary.CreateSamplePlugin(handle);
this.pluginLibrary.EnablePlugin(this.plugin);
this.pluginAudio = this.pluginLibrary.CreateSampleAudioPlugin(handle);
this.pluginLibrary.EnablePlugin(this.pluginAudio);
this.plugin = this.pluginLibrary.CreateSamplePlugin?.(handle);
this.pluginLibrary.EnablePlugin?.(this.plugin);
this.pluginAudio = this.pluginLibrary.CreateSampleAudioPlugin?.(handle);
this.pluginLibrary.EnablePlugin?.(this.pluginAudio);
}
this.setState({ enablePlugin: true });
};
Expand All @@ -161,16 +177,16 @@ export default class ProcessVideoRawData
*/
disablePlugin = () => {
if (this.plugin) {
this.pluginLibrary?.DisablePlugin(this.plugin);
this.pluginLibrary?.DestroySamplePlugin(this.plugin);
this.pluginLibrary.DisablePlugin?.(this.plugin);
this.pluginLibrary.DestroySamplePlugin?.(this.plugin);
this.plugin = undefined;
} else {
this.error('plugin is invalid');
}

if (this.pluginAudio) {
this.pluginLibrary?.DisablePlugin(this.pluginAudio);
this.pluginLibrary?.DestroySamplePlugin(this.pluginAudio);
this.pluginLibrary.DisablePlugin?.(this.pluginAudio);
this.pluginLibrary.DestroySamplePlugin?.(this.pluginAudio);
this.pluginAudio = undefined;
} else {
this.error('pluginAudio is invalid');
Expand Down
2 changes: 1 addition & 1 deletion example/webpack.renderer.additions.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ module.exports = function (config) {
// ...config.externals,
'webpack',
'agora-electron-sdk',
'ffi-napi',
'koffi',
'ref-napi',
];
console.log('config', config.module.rules);
Expand Down
Loading

0 comments on commit e78f864

Please sign in to comment.