Skip to content

Commit

Permalink
Force to allow calls without video and audio in embedded mode (#1134)
Browse files Browse the repository at this point in the history
* force to allow calls without video and audio in embedded mode
  • Loading branch information
Enrico Schwendig authored Jun 29, 2023
1 parent 8c2229b commit ec810cd
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/UrlParams.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@ export interface UrlParams {
* user's homeserver doesn't provide any.
*/
allowIceFallback: boolean;
/**
* Whether the app is allowed screen share only mode
*/
allowVoipWithNoMedia: boolean;
}

/**
Expand Down Expand Up @@ -141,6 +145,7 @@ export const getUrlParams = (
fontScale: Number.isNaN(fontScale) ? null : fontScale,
analyticsID: getParam("analyticsID"),
allowIceFallback: hasParam("allowIceFallback"),
allowVoipWithNoMedia: hasParam("allowVoipWithNoMedia"),
};
};

Expand Down
12 changes: 11 additions & 1 deletion src/room/GroupCallView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,17 @@ export function GroupCallView({
// Get the available devices so we can match the selected device
// to its ID. This involves getting a media stream (see docs on
// the function) so we only do it once and re-use the result.
const devices = await getNamedDevices();
//
// But we only want to preload the devices if we get audio or video devices included in the widget request!
// By default, the device list is null!
let devices: MediaDeviceInfo[] | null = null;

const { audioInput, videoInput } = ev.detail
.data as unknown as JoinCallData;

if (audioInput !== null) {
// we load the devices because w have an audio device in the widget request
devices = await getNamedDevices();
const deviceId = await findDeviceByName(
audioInput,
"audioinput",
Expand All @@ -124,6 +129,11 @@ export function GroupCallView({
}

if (videoInput !== null) {
// we only need to load the devices once time
if (devices === null) {
// we load the devices because w have a video device in the widget request
devices = await getNamedDevices();
}
const deviceId = await findDeviceByName(
videoInput,
"videoinput",
Expand Down
2 changes: 2 additions & 0 deletions src/widget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ export const widget: WidgetHelpers | null = (() => {
baseUrl,
e2eEnabled,
allowIceFallback,
allowVoipWithNoMedia,
} = getUrlParams();
if (!roomId) throw new Error("Room ID must be supplied");
if (!userId) throw new Error("User ID must be supplied");
Expand Down Expand Up @@ -156,6 +157,7 @@ export const widget: WidgetHelpers | null = (() => {
timelineSupport: true,
useE2eForGroupCall: e2eEnabled,
fallbackICEServerAllowed: allowIceFallback,
isVoipWithNoMediaAllowed: allowVoipWithNoMedia,
}
);
const clientPromise = client.startClient().then(() => client);
Expand Down

0 comments on commit ec810cd

Please sign in to comment.