Skip to content
Merged
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": "screen sharing bug",
"type": "patch"
}
],
"packageName": "@coze/realtime-api",
"email": "[email protected]"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"changes": [
{
"packageName": "@coze/realtime-api",
"comment": "screen sharing bug",
"type": "patch"
}
],
"packageName": "@coze/realtime-api",
"email": "[email protected]"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"changes": [
{
"packageName": "@coze/realtime-api",
"comment": "Add check for video support before throwing device error",
"type": "patch"
}
],
"packageName": "@coze/realtime-api",
"email": "[email protected]"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"changes": [
{
"packageName": "@coze/realtime-api",
"comment": "Add check for video support before throwing device error",
"type": "patch"
}
],
"packageName": "@coze/realtime-api",
"email": "[email protected]"
}
11 changes: 8 additions & 3 deletions examples/realtime-console/src/pages/main/header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -283,9 +283,14 @@ const Header: React.FC<HeaderProps> = ({
clientRef.current?.setAudioOutputDevice(value);
};

const handleVideoInputDeviceChange = (value: string) => {
setVideoInputDeviceId(value);
clientRef.current?.setVideoInputDevice(value);
const handleVideoInputDeviceChange = async (value: string) => {
try {
setVideoInputDeviceId(value);
await clientRef.current?.setVideoInputDevice(value);
} catch (error) {
message.error(`Failed to set video input device: ${error}`);
console.error(error);
}
};

if (microphoneStatus === 'error') {
Expand Down
2 changes: 1 addition & 1 deletion packages/realtime-api/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@coze/realtime-api",
"version": "1.0.3-beta.6",
"version": "1.0.3-beta.7",
"description": "A powerful real-time communication SDK for voice interactions with Coze AI bots | 扣子官方实时通信 SDK,用于与 Coze AI bots 进行语音交互",
"keywords": [
"coze",
Expand Down
14 changes: 13 additions & 1 deletion packages/realtime-api/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import VERTC, {
type onUserLeaveEvent,
StreamIndex,
type UserMessageEvent,
VideoSourceType,
} from '@volcengine/rtc';

import { getAudioDevices, isScreenShareDevice } from './utils';
Expand Down Expand Up @@ -225,7 +226,12 @@ export class EngineClient extends RealtimeEventHandler {
this.engine.setLocalVideoPlayer(StreamIndex.STREAM_INDEX_MAIN);
}
if (isAutoCapture) {
this.engine.setVideoSourceType(
StreamIndex.STREAM_INDEX_SCREEN,
VideoSourceType.VIDEO_SOURCE_TYPE_INTERNAL,
);
await this.engine.startScreenCapture(this._videoConfig?.screenConfig);
await this.engine.publishScreen(MediaType.VIDEO);
}
this._streamIndex = StreamIndex.STREAM_INDEX_SCREEN;
} else {
Expand Down Expand Up @@ -255,7 +261,7 @@ export class EngineClient extends RealtimeEventHandler {
);
}

if (!devices.videoInputs.length) {
if (this._isSupportVideo && !devices.videoInputs.length) {
throw new RealtimeAPIError(
RealtimeError.DEVICE_ACCESS_ERROR,
'Failed to get video devices',
Expand Down Expand Up @@ -306,13 +312,19 @@ export class EngineClient extends RealtimeEventHandler {
if (this._streamIndex === StreamIndex.STREAM_INDEX_MAIN) {
await this.engine.startVideoCapture();
} else {
this.engine.setVideoSourceType(
StreamIndex.STREAM_INDEX_SCREEN,
VideoSourceType.VIDEO_SOURCE_TYPE_INTERNAL,
);
await this.engine.startScreenCapture(this._videoConfig?.screenConfig);
await this.engine.publishScreen(MediaType.VIDEO);
}
} else {
if (this._streamIndex === StreamIndex.STREAM_INDEX_MAIN) {
await this.engine.stopVideoCapture();
} else {
await this.engine.stopScreenCapture();
await this.engine.unpublishScreen(MediaType.VIDEO);
}
}
} catch (e) {
Expand Down
7 changes: 7 additions & 0 deletions packages/realtime-api/test/client.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ const mockEngine = {
registerExtension: vi.fn(),
startAudioPlaybackDeviceTest: vi.fn(),
stopAudioPlaybackDeviceTest: vi.fn(),
unpublishScreen: vi.fn(),
publishScreen: vi.fn(),
setVideoSourceType: vi.fn(),
};

// Mock VERTC
Expand All @@ -52,6 +55,9 @@ vi.mock('@volcengine/rtc', () => ({
MediaType: {
AUDIO: 'audio',
},
VideoSourceType: {
VIDEO_SOURCE_TYPE_INTERNAL: 'internal',
},
}));

// Mock RTCAIAnsExtension
Expand Down Expand Up @@ -311,6 +317,7 @@ describe('EngineClient', () => {
});

it('should throw error when no video devices available', async () => {
(client as any)._isSupportVideo = true;
(utils.getAudioDevices as Mock).mockResolvedValueOnce({
audioInputs: [{ deviceId: 'audio-in-1' }],
audioOutputs: [],
Expand Down
Loading