Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(realtime-api): feat: add getRtcEngine method to expose RTC engine #83

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"changes": [
{
"packageName": "@coze/realtime-api",
"comment": "feat: add getRtcEngine method to expose RTC engine instance",
"type": "minor"
}
],
"packageName": "@coze/realtime-api",
"email": "[email protected]"
}
4 changes: 3 additions & 1 deletion packages/realtime-api/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,9 @@ const operations = {
disconnect: () => client.disconnect(),
interrupt: () => client.interrupt(),
toggleMicrophone: (enabled: boolean) => client.setAudioEnable(enabled),
checkConnection: () => client.isConnected
checkConnection: () => client.isConnected,
// get rtc engine instance, for detail visit https://www.volcengine.com/docs/6348/104478#rtcengine
getRtcEngine: () => client.getRtcEngine(),
};

// Event Handling
Expand Down
4 changes: 3 additions & 1 deletion packages/realtime-api/README.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,9 @@ const operations = {
disconnect: () => client.disconnect(),
interrupt: () => client.interrupt(),
toggleMicrophone: (enabled: boolean) => client.setAudioEnable(enabled),
checkConnection: () => client.isConnected
checkConnection: () => client.isConnected,
// 获取 RTC 引擎实例,详情请访问 https://www.volcengine.com/docs/6348/104478#rtcengine
getRtcEngine: () => client.getRtcEngine(),
};

// 事件处理
Expand Down
4 changes: 4 additions & 0 deletions packages/realtime-api/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -421,4 +421,8 @@ export class EngineClient extends RealtimeEventHandler {
throw e;
}
}

getRtcEngine() {
return this.engine;
}
}
15 changes: 14 additions & 1 deletion packages/realtime-api/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import { type ScreenConfig, type AudioPropertiesConfig } from '@volcengine/rtc';
import {
type ScreenConfig,
type AudioPropertiesConfig,
type IRTCEngine,
} from '@volcengine/rtc';
import { CozeAPI, type CreateRoomData, type GetToken } from '@coze/api';

import * as RealtimeUtils from './utils';
Expand Down Expand Up @@ -309,6 +313,15 @@ class RealtimeClient extends RealtimeEventHandler {
await this._client?.setVideoInputDevice(deviceId);
this.dispatch(EventNames.VIDEO_INPUT_DEVICE_CHANGED, { deviceId });
}

/**
* en: Get the RTC engine instance, for detail visit https://www.volcengine.com/docs/6348/104481
*
* zh: 获取 RTC 引擎实例,详情请访问 https://www.volcengine.com/docs/6348/104481
*/
getRtcEngine(): IRTCEngine | undefined {
return this._client?.getRtcEngine();
}
}

export {
Expand Down
Loading