Skip to content

Commit

Permalink
Merge branch 'main' into dev/alpha-1
Browse files Browse the repository at this point in the history
# Conflicts:
#	package.json
#	ts/Private/AgoraBase.ts
#	ts/Private/AgoraMediaBase.ts
#	ts/Private/IAgoraRtcEngine.ts
#	ts/Private/IAgoraRtcEngineEx.ts
  • Loading branch information
guoxianzhe committed Dec 16, 2024
2 parents 2631051 + 9a24f58 commit 3370db3
Show file tree
Hide file tree
Showing 15 changed files with 367 additions and 2,186 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@


# [4.5.0](https://github.com/AgoraIO-Extensions/Electron-SDK/compare/v4.4.0...v4.5.0) (2024-12-10)


### Features

* support 4.5.0 ([#1228](https://github.com/AgoraIO-Extensions/Electron-SDK/issues/1228)) ([d1a6d9c](https://github.com/AgoraIO-Extensions/Electron-SDK/commit/d1a6d9cc2aa361e7b96ad158debe791f4accc6a7)), closes [#1224](https://github.com/AgoraIO-Extensions/Electron-SDK/issues/1224)

# [4.4.0](https://github.com/AgoraIO-Extensions/Electron-SDK/compare/v4.3.2...v4.4.0) (2024-08-29)


Expand Down
2 changes: 1 addition & 1 deletion example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
]
},
"dependencies": {
"agora-electron-sdk": "4.4.0",
"agora-electron-sdk": "4.5.0",
"antd": "^4.20.3",
"download": "^8.0.0",
"koffi": "2.8.11",
Expand Down
161 changes: 161 additions & 0 deletions example/src/renderer/examples/advanced/AgoraALD/AgoraALD.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
import fs from 'fs';
import os from 'os';
import path from 'path';

import {
ChannelProfileType,
ClientRoleType,
IRtcEngineEventHandler,
createAgoraRtcEngine,
} from 'agora-electron-sdk';
import download from 'download';

import React, { ReactElement } from 'react';

import {
BaseAudioComponentState,
BaseComponent,
} from '../../../components/BaseComponent';
import { AgoraButton, AgoraDivider, AgoraSwitch } from '../../../components/ui';
import Config from '../../../config/agora.config';
import { askMediaAccess } from '../../../utils/permissions';

interface State extends BaseAudioComponentState {
loopbackRecording: boolean;
}

export default class AgoraALD
extends BaseComponent<{}, State>
implements IRtcEngineEventHandler
{
protected createState(): State {
return {
appId: Config.appId,
enableVideo: false,
channelId: Config.channelId,
token: Config.token,
uid: Config.uid,
joinChannelSuccess: false,
loopbackRecording: false,
remoteUsers: [],
};
}

/**
* Step 1: initRtcEngine
*/
protected async initRtcEngine() {
const { appId } = this.state;
if (!appId) {
this.error(`appId is invalid`);
}

this.engine = createAgoraRtcEngine();
this.engine.initialize({
appId,
logConfig: { filePath: Config.logFilePath },
// Should use ChannelProfileLiveBroadcasting on most of cases
channelProfile: ChannelProfileType.ChannelProfileLiveBroadcasting,
});
this.engine.registerEventHandler(this);

// Need granted the microphone permission
await askMediaAccess(['microphone']);

// Only need to enable audio on this case
this.engine.enableAudio();

const url = `https://github.com/AgoraIO-Extensions/Electron-SDK/releases/download/v4.2.6-build.9-rc.1/AgoraALD.zip`;
const dllPath = path.resolve(os.tmpdir(), 'AgoraALD.driver');
if (fs.existsSync(dllPath)) {
fs.rmSync(dllPath, { recursive: true, force: true });
}
console.log(`start downloading plugin ${url} to ${dllPath}`);
await download(encodeURI(url), os.tmpdir(), { extract: true });
console.log(`download success`);
}

/**
* Step 2: joinChannel
*/
protected joinChannel() {
const { channelId, token, uid } = this.state;
if (!channelId) {
this.error('channelId is invalid');
return;
}
if (uid < 0) {
this.error('uid is invalid');
return;
}

// start joining channel
// 1. Users can only see each other after they join the
// same channel successfully using the same app id.
// 2. If app certificate is turned on at dashboard, token is needed
// when joining channel. The channel name and uid used to calculate
// the token has to match the ones used for channel join
this.engine?.joinChannel(token, channelId, uid, {
// Make myself as the broadcaster to send stream to remote
clientRoleType: ClientRoleType.ClientRoleBroadcaster,
});
}

/**
* Step 4: leaveChannel
*/
protected leaveChannel() {
this.engine?.leaveChannel();
}

/**
* Step 5: releaseRtcEngine
*/
protected releaseRtcEngine() {
this.engine?.unregisterEventHandler(this);
this.engine?.release();
}

_setupAgoraALD = () => {
this.engine?.setParameters(
JSON.stringify({
'che.audio.mac.loopback.custom_install_path': path.resolve(
os.tmpdir(),
'AgoraALD.driver'
),
})
);
// to enable AgoraALD, you need to enable loopback recording first and then disable it immediately.
this.engine?.enableLoopbackRecording(true, 'AgoraALD');
this.engine?.enableLoopbackRecording(false, 'AgoraALD');
};

_enableLoopbackRecording = (enabled: boolean) => {
this.engine?.enableLoopbackRecording(enabled);
};

protected renderConfiguration(): ReactElement | undefined {
const { loopbackRecording } = this.state;
return (
<>
<AgoraSwitch
title={'loopbackRecording'}
value={loopbackRecording}
onValueChange={(value) => {
this.setState({ loopbackRecording: value });
this.engine?.enableLoopbackRecording(value);
}}
/>
<AgoraDivider />
</>
);
}

protected renderAction(): ReactElement | undefined {
return (
<>
<AgoraButton title={`setup AgoraALD`} onPress={this._setupAgoraALD} />
</>
);
}
}
5 changes: 5 additions & 0 deletions example/src/renderer/examples/advanced/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import AgoraALD from './AgoraALD/AgoraALD';
import AudioMixing from './AudioMixing/AudioMixing';
import AudioSpectrum from './AudioSpectrum/AudioSpectrum';
import BeautyEffect from './BeautyEffect/BeautyEffect';
Expand Down Expand Up @@ -32,6 +33,10 @@ import VoiceChanger from './VoiceChanger/VoiceChanger';
const Advanced = {
title: 'Advanced',
data: [
{
name: 'AgoraALD',
component: AgoraALD,
},
{
name: 'AudioMixing',
component: AudioMixing,
Expand Down
Loading

0 comments on commit 3370db3

Please sign in to comment.