-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* chore: optimize * build(deps): bump express from 4.19.2 to 4.21.0 in /example (#1224) Bumps [express](https://github.com/expressjs/express) from 4.19.2 to 4.21.0. - [Release notes](https://github.com/expressjs/express/releases) - [Changelog](https://github.com/expressjs/express/blob/4.21.0/History.md) - [Commits](expressjs/express@4.19.2...4.21.0) --- 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> * chore: config terra and iris to 4.5.0 * [AUTO] Generate codes by terra (#1226) Co-authored-by: guoxianzhe <[email protected]> * [AUTO] Generate codes by terra (#1227) Co-authored-by: guoxianzhe <[email protected]> * chore: optimize * chore: migrate abr feature * chore: adjust string length limit * chore: optimize * chore: fix NMS-23504 * chore: remove encodedVideoFrame case * [AUTO] Generate codes by terra (#1238) Co-authored-by: guoxianzhe <[email protected]> * chore: bump to 4.5.0-dev.10 * chore: bump native to 4.5.0-dev.12 * chore: remove useless * chore: pick agoraald * chore: optimize * chore: bump iris to 4.5.0-build.1 * [AUTO] Generate codes by terra (#1245) Co-authored-by: guoxianzhe <[email protected]> --------- Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: sda-rob <[email protected]> Co-authored-by: guoxianzhe <[email protected]>
- Loading branch information
1 parent
082cb50
commit d1a6d9c
Showing
33 changed files
with
2,001 additions
and
2,544 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
161 changes: 161 additions & 0 deletions
161
example/src/renderer/examples/advanced/AgoraALD/AgoraALD.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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} /> | ||
</> | ||
); | ||
} | ||
} |
Oops, something went wrong.