diff --git a/src/components/UserVideo/index.tsx b/src/components/UserVideo/index.tsx index c26b1b4..066f6cc 100644 --- a/src/components/UserVideo/index.tsx +++ b/src/components/UserVideo/index.tsx @@ -5,6 +5,7 @@ import { agora } from '@/utils/package/agora'; import { Button, Empty, Select, message } from 'antd'; import { useEffect, useState } from "react"; import { useLocation } from 'react-router'; +import { VideoStreamType } from 'agora-electron-sdk'; const UserVideo: React.FC = () => { const { state } = useLocation(); const [from, setFrom] = useState({ @@ -65,6 +66,7 @@ const UserVideo: React.FC = () => { view: document.getElementById(`video-${item.screenShareId}`), channelId: state.channelId + 'a', }) + await agora.setRemoteVideoStreamType(item.uid, VideoStreamType.VideoStreamLow, false) }) }, [userList]) // 监听缓存变化 diff --git a/src/page/Meeting/index.tsx b/src/page/Meeting/index.tsx index 55a1cdf..66dda21 100644 --- a/src/page/Meeting/index.tsx +++ b/src/page/Meeting/index.tsx @@ -251,9 +251,9 @@ const Meeting: React.FC = () => { useEffect(() => { roomUserList.forEach(async (item: any) => { if (item.uid === currentVideoId) { - await agora.setRemoteVideoStreamType(item.uid, VideoStreamType.VideoStreamHigh) + await agora.setRemoteVideoStreamType(item.uid, VideoStreamType.VideoStreamHigh, true) } else { - await agora.setRemoteVideoStreamType(item.uid, VideoStreamType.VideoStreamLow) + await agora.setRemoteVideoStreamType(item.uid, VideoStreamType.VideoStreamLow, true) } }); }, [currentVideoId, roomUserList]); diff --git a/src/utils/package/agora.ts b/src/utils/package/agora.ts index 96cfaec..c1cf77a 100644 --- a/src/utils/package/agora.ts +++ b/src/utils/package/agora.ts @@ -211,7 +211,7 @@ export const agora = { joinChannel: async () => { await rtcEngine.enableAudioVolumeIndication(100, 1, true) await rtcEngine.joinChannel(option.token, option.channelId, option.uid); - await rtcEngine.setDualStreamMode( + await rtcEngine.setDualStreamModeEx( SimulcastStreamMode.EnableSimulcastStream, { dimensions: { @@ -219,7 +219,8 @@ export const agora = { height: 180 }, framerate: 5, - } + }, + { channelId: option.channelId, localUid: Number(option.uid) } ); }, // 更新频道配置 @@ -234,10 +235,11 @@ export const agora = { }) }, // 设置接收大小流 - setRemoteVideoStreamType: async (uid: number, type: VideoStreamType) => { - await rtcEngine.setRemoteVideoStreamType( + setRemoteVideoStreamType: async (uid: number, type: VideoStreamType, bool: boolean) => { + await rtcEngine.setRemoteVideoStreamTypeEx( Number(uid), type, + bool ? { channelId: option.channelId, localUid: Number(option.uid) } : { channelId: option.channelId + 'a', localUid: Number('1' + option.screenShareId) } ) }, // 共享屏幕单独用户 @@ -271,6 +273,17 @@ export const agora = { publishScreenTrack: false,//设置是否发布屏幕采集的视频 } ); + await rtcEngine.setDualStreamModeEx( + SimulcastStreamMode.EnableSimulcastStream, + { + dimensions: { + width: 320, + height: 180 + }, + framerate: 5, + }, + { channelId: option.channelId + 'a', localUid: Number('1' + option.screenShareId) } + ); }, // 退出第二个房间 allLeaveChannelEx: async () => { @@ -303,7 +316,6 @@ export const agora = { }, // 摄像头采集 startCameraCapture: async (bool: boolean = false) => { - console.log(bool); await rtcEngine.startCameraCapture(VideoSourceType.VideoSourceCamera, { format: { width: bool ? 160 : 1280,