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
2 changes: 1 addition & 1 deletion desktop/renderer-app/src/pages/BigClassPage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ export const BigClassPage = observer<BigClassPageProps>(function BigClassPage()
></ChatPanel>
}
isShow={isRealtimeSideOpen}
isVideoOn={true}
isVideoOn={classRoomStore.isJoinedRTC}
videoSlot={
<div className="big-class-realtime-rtc-box">
<RTCAvatar
Expand Down
2 changes: 1 addition & 1 deletion desktop/renderer-app/src/pages/OneToOnePage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ export const OneToOnePage = observer<OneToOnePageProps>(function OneToOnePage()
></ChatPanel>
}
isShow={isRealtimeSideOpen}
isVideoOn={true}
isVideoOn={classRoomStore.isJoinedRTC}
videoSlot={
<div className="one-to-one-rtc-avatar-container">
<RTCAvatar
Expand Down
32 changes: 17 additions & 15 deletions desktop/renderer-app/src/pages/SmallClassPage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -244,21 +244,23 @@ export const SmallClassPage = observer<SmallClassPageProps>(function SmallClassP
className="small-class-realtime-avatars-wrap"
style={{ maxWidth: `${whiteboardStore.smallClassAvatarWrapMaxWidth}px` }}
>
<div className="small-class-realtime-avatars">
<RTCAvatar
avatarUser={classRoomStore.users.creator}
isAvatarUserCreator={true}
isCreator={true}
rtcAvatar={
classRoomStore.users.creator &&
classRoomStore.rtc.getAvatar(classRoomStore.users.creator.rtcUID)
}
small={true}
updateDeviceState={classRoomStore.updateDeviceState}
userUUID={classRoomStore.userUUID}
/>
{classRoomStore.users.joiners.map(renderAvatar)}
</div>
{classRoomStore.isJoinedRTC && (
<div className="small-class-realtime-avatars">
<RTCAvatar
avatarUser={classRoomStore.users.creator}
isAvatarUserCreator={true}
isCreator={classRoomStore.isCreator}
rtcAvatar={
classRoomStore.users.creator &&
classRoomStore.rtc.getAvatar(classRoomStore.users.creator.rtcUID)
}
small={true}
updateDeviceState={classRoomStore.updateDeviceState}
userUUID={classRoomStore.userUUID}
/>
{classRoomStore.users.joiners.map(renderAvatar)}
</div>
)}
</div>
);
}
Expand Down
7 changes: 7 additions & 0 deletions desktop/renderer-app/src/stores/class-room-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ export class ClassRoomStore {
public isRecording = false;
/** is RTC on, for UI */
public isCalling = false;
public isJoinedRTC = false;
/** is user login on other device */
public isRemoteLogin = false;

Expand Down Expand Up @@ -308,6 +309,7 @@ export class ClassRoomStore {
shareScreenUID: globalStore.rtcShareScreen?.uid || -1,
shareScreenToken: globalStore.rtcShareScreen?.token || "",
});
this.updateIsJoinedRTC(true);
} catch (e) {
console.error(e);
this.updateCalling(false);
Expand Down Expand Up @@ -338,6 +340,7 @@ export class ClassRoomStore {

try {
this.rtc.leaveRoom();
this.updateIsJoinedRTC(false);
} catch (e) {
console.error(e);
this.updateCalling(true);
Expand Down Expand Up @@ -1068,6 +1071,10 @@ export class ClassRoomStore {
this.isCalling = isCalling;
});

private updateIsJoinedRTC = action("updateIsJoinedRTC", (isJoinedRTC: boolean): void => {
this.isJoinedRTC = isJoinedRTC;
});

private updateBanStatus = (isBan: boolean): void => {
this.isBan = isBan;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export const VideoAvatar: React.FC<VideoAvatarProps> = ({
}) => {
const isCameraCtrlDisable =
avatarUser.userUUID !== userUUID && (!isCreator || !avatarUser.camera);
console.log(avatarUser.userUUID, userUUID, isCreator, avatarUser.camera);

const isMicCtrlDisable = avatarUser.userUUID !== userUUID && (!isCreator || !avatarUser.mic);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
position: relative;
overflow: hidden;
user-select: none;
background: #000;

&::after {
content: '';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,10 @@ export class FlatRTCAgoraElectron extends FlatRTC<
this.shareScreen.setParams(null);
}

public getAvatar(uid?: FlatRTCAgoraElectronUIDType): FlatRTCAvatar {
public getAvatar(uid?: FlatRTCAgoraElectronUIDType): FlatRTCAvatar | undefined {
if (!this.isJoinedRoom) {
return;
}
if (!uid || this.uid === uid) {
return this.localAvatar;
}
Expand Down
30 changes: 18 additions & 12 deletions services/rtc/flat-rtc-agora-web/src/flat-rtc-agora-web.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,10 @@ export class FlatRTCAgoraWeb extends FlatRTC<FlatRTCAgoraWebUIDType> {
this.shareScreen.setParams(null);
}

public getAvatar(uid?: FlatRTCAgoraWebUIDType): FlatRTCAvatar {
public getAvatar(uid?: FlatRTCAgoraWebUIDType): FlatRTCAvatar | undefined {
if (!this.isJoinedRoom) {
return;
}
if (!uid || this.uid === uid) {
return this.localAvatar;
}
Expand All @@ -187,7 +190,8 @@ export class FlatRTCAgoraWeb extends FlatRTC<FlatRTCAgoraWebUIDType> {
}
let remoteAvatar = this._remoteAvatars.get(uid);
if (!remoteAvatar) {
remoteAvatar = new RTCRemoteAvatar();
const rtcRemoteUser = this.client?.remoteUsers.find(user => user.uid === uid);
remoteAvatar = new RTCRemoteAvatar({ rtcRemoteUser });
this._remoteAvatars.set(uid, remoteAvatar);
}
return remoteAvatar;
Expand Down Expand Up @@ -361,16 +365,18 @@ export class FlatRTCAgoraWeb extends FlatRTC<FlatRTCAgoraWebUIDType> {
console.error(e);
}

const uid = user.uid as FlatRTCAgoraWebUIDType;
if (uid === this.shareScreenUID) {
this.shareScreen.setRemoteUser(null);
return;
}

const avatar = this._remoteAvatars.get(uid);
if (avatar) {
avatar.destroy();
this._remoteAvatars.delete(uid);
if (!user.videoTrack && !user.audioTrack) {
const uid = user.uid as FlatRTCAgoraWebUIDType;
if (uid === this.shareScreenUID) {
this.shareScreen.setRemoteUser(null);
return;
}

const avatar = this._remoteAvatars.get(uid);
if (avatar) {
avatar.destroy();
this._remoteAvatars.delete(uid);
}
}
};
client.on("user-unpublished", handler);
Expand Down
2 changes: 1 addition & 1 deletion services/rtc/flat-rtc/src/rtc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export abstract class FlatRTC<
public abstract setRole(role: FlatRTCRole): void;

/** @returns local avatar if uid is not provided, throws error if uid == shareScreenUID */
public abstract getAvatar(uid?: TUid): FlatRTCAvatar;
public abstract getAvatar(uid?: TUid): FlatRTCAvatar | undefined;
public abstract getVolumeLevel(uid?: TUid): number;

public abstract setCameraID(deviceId: string): Promise<void>;
Expand Down
2 changes: 0 additions & 2 deletions web/flat-web/src/components/RTCAvatar/AvatarCanvas.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ export const AvatarCanvas = observer<

const [canvasEl, setCanvasEl] = useState<HTMLDivElement | null>(null);

useEffect(() => () => rtcAvatar?.destroy(), [rtcAvatar]);

const getVolumeLevel = useCallback((): number => {
return rtcAvatar?.getVolumeLevel() || 0;
}, [rtcAvatar]);
Expand Down
2 changes: 1 addition & 1 deletion web/flat-web/src/pages/BigClassPage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ export const BigClassPage = observer<BigClassPageProps>(function BigClassPage()
></ChatPanel>
}
isShow={isRealtimeSideOpen}
isVideoOn={true}
isVideoOn={classRoomStore.isJoinedRTC}
videoSlot={
<div className="big-class-realtime-rtc-box">
<RTCAvatar
Expand Down
2 changes: 1 addition & 1 deletion web/flat-web/src/pages/OneToOnePage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ export const OneToOnePage = observer<OneToOnePageProps>(function OneToOnePage()
></ChatPanel>
}
isShow={isRealtimeSideOpen}
isVideoOn={true}
isVideoOn={classRoomStore.isJoinedRTC}
videoSlot={
<div className="one-to-one-rtc-avatar-container">
<RTCAvatar
Expand Down
32 changes: 17 additions & 15 deletions web/flat-web/src/pages/SmallClassPage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -196,21 +196,23 @@ export const SmallClassPage = observer<SmallClassPageProps>(function SmallClassP
className="small-class-realtime-avatars-wrap"
style={{ maxWidth: `${whiteboardStore.smallClassAvatarWrapMaxWidth}px` }}
>
<div className="small-class-realtime-avatars">
<RTCAvatar
avatarUser={classRoomStore.users.creator}
isAvatarUserCreator={true}
isCreator={true}
rtcAvatar={
classRoomStore.users.creator &&
classRoomStore.rtc.getAvatar(classRoomStore.users.creator.rtcUID)
}
small={true}
updateDeviceState={classRoomStore.updateDeviceState}
userUUID={classRoomStore.userUUID}
/>
{classRoomStore.users.joiners.map(renderAvatar)}
</div>
{classRoomStore.isJoinedRTC && (
<div className="small-class-realtime-avatars">
<RTCAvatar
avatarUser={classRoomStore.users.creator}
isAvatarUserCreator={true}
isCreator={classRoomStore.isCreator}
rtcAvatar={
classRoomStore.users.creator &&
classRoomStore.rtc.getAvatar(classRoomStore.users.creator.rtcUID)
}
small={true}
updateDeviceState={classRoomStore.updateDeviceState}
userUUID={classRoomStore.userUUID}
/>
{classRoomStore.users.joiners.map(renderAvatar)}
</div>
)}
</div>
);
}
Expand Down
10 changes: 9 additions & 1 deletion web/flat-web/src/stores/class-room-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,10 @@ export class ClassRoomStore {
public isBan = false;
/** is Cloud Recording on */
public isRecording = false;
/** is RTC on */
/** is RTC UI on */
public isCalling = false;
/** is RTC joined room */
public isJoinedRTC = false;
/** is user login on other device */
public isRemoteLogin = false;

Expand Down Expand Up @@ -265,6 +267,7 @@ export class ClassRoomStore {
shareScreenUID: globalStore.rtcShareScreen?.uid || -1,
shareScreenToken: globalStore.rtcShareScreen?.token || "",
});
this.updateIsJoinedRTC(true);
} catch (e) {
console.error(e);
this.updateCalling(false);
Expand All @@ -281,6 +284,7 @@ export class ClassRoomStore {
}

this.updateCalling(false);
this.updateIsJoinedRTC(false);
};

public toggleCloudStoragePanel = (visible: boolean): void => {
Expand Down Expand Up @@ -1029,6 +1033,10 @@ export class ClassRoomStore {
this.isCalling = isCalling;
});

private updateIsJoinedRTC = action("updateIsJoinedRTC", (isJoinedRTC: boolean): void => {
this.isJoinedRTC = isJoinedRTC;
});

private updateBanStatus = (isBan: boolean): void => {
this.isBan = isBan;
};
Expand Down