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

fix(flat-services): share screen not working on windows #1785

Merged
merged 1 commit into from
Nov 21, 2022
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
Expand Up @@ -50,7 +50,8 @@ export const ScreenList = observer<ScreenListProps>(function ShareScreen({
return (
<div className="screen-list">
{screenInfo.map(info => {
const key = `${info.type}-${info.screenId}`;
const id = typeof info.screenId === "number" ? info.screenId : info.screenId.id;
const key = `${info.type}-${id}`;
const isActive = activeInfo === key;

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,11 @@ export abstract class IServiceShareScreen {
// Only used in electron.
export interface IServiceShareScreenInfo {
type: "display" | "window";
screenId: number;
screenId: number | { id: number };
name: string;
image: Uint8Array;
width: number;
height: number;
}

function doesNotSupportError(type: string): Error {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@ import {
IServiceShareScreenParams,
} from "@netless/flat-services";
import type AgoraRtcEngine from "agora-electron-sdk";
import type { DisplayInfo, WindowInfo } from "agora-electron-sdk/types/Api/native_type";
import type {
DisplayInfo,
ScreenSymbol,
WindowInfo,
} from "agora-electron-sdk/types/Api/native_type";

import { SideEffectManager } from "side-effect-manager";
import { combine, Val } from "value-enhancer";
Expand Down Expand Up @@ -120,16 +124,20 @@ export class AgoraRTCElectronShareScreen extends IServiceShareScreen {
if ("displayId" in info) {
return {
type: "display",
screenId: info.displayId.id,
screenId: info.displayId,
name: "Desktop",
image: info.image,
width: info.width,
height: info.height,
};
} else {
return {
type: "window",
screenId: info.windowId,
name: `${info.ownerName} - ${info.name}`,
image: info.image,
width: info.width,
height: info.height,
};
}
};
Expand Down Expand Up @@ -179,17 +187,18 @@ export class AgoraRTCElectronShareScreen extends IServiceShareScreen {
this._pTogglingShareScreen = new Promise<void>(resolve => {
this.client.once("videoSourceJoinedSuccess", () => {
this.client.videoSourceSetVideoProfile(43, false);
const { width, height } = screenInfo;
if (screenInfo.type === "display") {
this.client.videoSourceStartScreenCaptureByScreen(
{ id: screenInfo.screenId },
rect,
videoSourceParams,
screenInfo.screenId as ScreenSymbol,
{ ...rect, width, height },
{ ...videoSourceParams, width, height },
);
} else {
this.client.videoSourceStartScreenCaptureByWindow(
screenInfo.screenId,
rect,
videoSourceParams,
screenInfo.screenId as number,
{ ...rect, width, height },
{ ...videoSourceParams, width, height },
);
}
resolve();
Expand Down