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

Allow Element Call to be started without audio / video interface #924

Merged
merged 14 commits into from
Mar 2, 2023
Merged
Show file tree
Hide file tree
Changes from 6 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 package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
"i18next-browser-languagedetector": "^6.1.8",
"i18next-http-backend": "^1.4.4",
"lodash": "^4.17.21",
"matrix-js-sdk": "github:matrix-org/matrix-js-sdk#64197bf4db6486d77708125d7fb2e8d7fe001f14",
"matrix-js-sdk": "github:matrix-org/matrix-js-sdk#c57aadb320164f1eea8f728c99fc54260745604b",
"matrix-widget-api": "^1.0.0",
"mermaid": "^8.13.8",
"normalize.css": "^8.0.1",
Expand Down
8 changes: 8 additions & 0 deletions src/config/ConfigOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,14 @@ export interface ConfigOptions {
server_name: string;
};
};

/**
* Allow to join a group calls without audio and video.
* TEMPORARY: Is a feature that's not proved and experimental
*/
features?: {
feature_group_calls_without_video_and_audio: boolean;
};
}

// Overrides members from ConfigOptions that are always provided by the
Expand Down
18 changes: 11 additions & 7 deletions src/matrix-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,14 @@ export async function initClient(
indexedDB = window.indexedDB;
} catch (e) {}

const storeOpts = {} as ICreateClientOpts;
const baseOpts = {
fallbackICEServerAllowed: fallbackICEServerAllowed,
isVoipWithNoMediaAllowed:
Config.get().features?.feature_group_calls_without_video_and_audio,
} as ICreateClientOpts;

if (indexedDB && localStorage) {
storeOpts.store = new IndexedDBStore({
baseOpts.store = new IndexedDBStore({
indexedDB: window.indexedDB,
localStorage,
dbName: SYNC_STORE_NAME,
Expand All @@ -107,7 +111,7 @@ export async function initClient(
: () => new IndexedDBWorker(),
});
} else if (localStorage) {
storeOpts.store = new MemoryStore({ localStorage });
baseOpts.store = new MemoryStore({ localStorage });
}

// Check whether we have crypto data store. If we are restoring a session
Expand Down Expand Up @@ -139,14 +143,14 @@ export async function initClient(
}

if (indexedDB) {
storeOpts.cryptoStore = new IndexedDBCryptoStore(
baseOpts.cryptoStore = new IndexedDBCryptoStore(
indexedDB,
CRYPTO_STORE_NAME
);
} else if (localStorage) {
storeOpts.cryptoStore = new LocalStorageCryptoStore(localStorage);
baseOpts.cryptoStore = new LocalStorageCryptoStore(localStorage);
} else {
storeOpts.cryptoStore = new MemoryCryptoStore();
baseOpts.cryptoStore = new MemoryCryptoStore();
}

// XXX: we read from the URL params in RoomPage too:
Expand All @@ -160,7 +164,7 @@ export async function initClient(
}

const client = createClient({
...storeOpts,
...baseOpts,
...clientOptions,
useAuthorizationHeader: true,
// Use a relatively low timeout for API calls: this is a realtime app
Expand Down
3 changes: 3 additions & 0 deletions src/room/GroupCallView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ export function GroupCallView({
screenshareFeeds,
participants,
unencryptedEventsFromUsers,
initCallWithoutVideoAndAudio,
} = useGroupCall(groupCall);

const { t } = useTranslation();
Expand Down Expand Up @@ -262,6 +263,7 @@ export function GroupCallView({
roomIdOrAlias={roomIdOrAlias}
unencryptedEventsFromUsers={unencryptedEventsFromUsers}
hideHeader={hideHeader}
isOnlyScreenshare={initCallWithoutVideoAndAudio}
/>
);
}
Expand Down Expand Up @@ -300,6 +302,7 @@ export function GroupCallView({
roomIdOrAlias={roomIdOrAlias}
isEmbedded={isEmbedded}
hideHeader={hideHeader}
isOnlyScreenShare={initCallWithoutVideoAndAudio}
/>
);
}
Expand Down
41 changes: 23 additions & 18 deletions src/room/InCallView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ interface Props {
roomIdOrAlias: string;
unencryptedEventsFromUsers: Set<string>;
hideHeader: boolean;
isOnlyScreenshare: boolean;
}

export function InCallView({
Expand All @@ -122,6 +123,7 @@ export function InCallView({
roomIdOrAlias,
unencryptedEventsFromUsers,
hideHeader,
isOnlyScreenshare,
}: Props) {
const { t } = useTranslation();
usePreventScroll();
Expand Down Expand Up @@ -372,26 +374,27 @@ export function InCallView({

if (noControls) {
footer = null;
} else if (reducedControls) {
footer = (
<div className={styles.footer}>
<MicButton muted={microphoneMuted} onPress={toggleMicrophoneMuted} />
<VideoButton muted={localVideoMuted} onPress={toggleLocalVideoMuted} />
<HangupButton onPress={onLeave} />
</div>
);
} else {
footer = (
<div className={styles.footer}>
<MicButton muted={microphoneMuted} onPress={toggleMicrophoneMuted} />
const buttons: JSX.Element[] = [];

if (!isOnlyScreenshare) {
buttons.push(
<MicButton muted={microphoneMuted} onPress={toggleMicrophoneMuted} />,
<VideoButton muted={localVideoMuted} onPress={toggleLocalVideoMuted} />
{canScreenshare && !hideScreensharing && !isSafari && (
);
}

if (!reducedControls) {
if (canScreenshare && !hideScreensharing && !isSafari) {
buttons.push(
<ScreenshareButton
enabled={isScreensharing}
onPress={toggleScreensharing}
/>
)}
{!maximisedParticipant && (
);
}
if (!maximisedParticipant) {
buttons.push(
<OverflowMenu
inCall
roomIdOrAlias={roomIdOrAlias}
Expand All @@ -400,10 +403,12 @@ export function InCallView({
feedbackModalState={feedbackModalState}
feedbackModalProps={feedbackModalProps}
/>
)}
<HangupButton onPress={onLeave} />
</div>
);
);
}
}

buttons.push(<HangupButton onPress={onLeave} />);
footer = <div className={styles.footer}>{buttons}</div>;
}

return (
Expand Down
2 changes: 2 additions & 0 deletions src/room/LobbyView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ interface Props {
roomIdOrAlias: string;
isEmbedded: boolean;
hideHeader: boolean;
isOnlyScreenShare: boolean;
}
export function LobbyView({
client,
Expand All @@ -66,6 +67,7 @@ export function LobbyView({
roomIdOrAlias,
isEmbedded,
hideHeader,
isOnlyScreenShare,
}: Props) {
const { t } = useTranslation();
const { stream } = useCallFeed(localCallFeed);
Expand Down
4 changes: 4 additions & 0 deletions src/room/useGroupCall.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ export interface UseGroupCallReturnType {
participants: Map<RoomMember, Map<string, ParticipantInfo>>;
hasLocalParticipant: boolean;
unencryptedEventsFromUsers: Set<string>;
initCallWithoutVideoAndAudio: boolean;
}

interface State {
Expand Down Expand Up @@ -146,6 +147,8 @@ export function useGroupCall(groupCall: GroupCall): UseGroupCallReturnType {
hasLocalParticipant: false,
});

const initCallWithoutVideoAndAudio = groupCall.initCallWithoutVideoAndAudio;

const [unencryptedEventsFromUsers, addUnencryptedEventUser] = useReducer(
(state: Set<string>, newVal: string) => {
return new Set(state).add(newVal);
Expand Down Expand Up @@ -525,5 +528,6 @@ export function useGroupCall(groupCall: GroupCall): UseGroupCallReturnType {
participants,
hasLocalParticipant,
unencryptedEventsFromUsers,
initCallWithoutVideoAndAudio,
};
}
16 changes: 8 additions & 8 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1821,10 +1821,10 @@
resolved "https://registry.yarnpkg.com/@juggle/resize-observer/-/resize-observer-3.3.1.tgz#b50a781709c81e10701004214340f25475a171a0"
integrity sha512-zMM9Ds+SawiUkakS7y94Ymqx+S0ORzpG3frZirN3l+UlXUmSUR7hF4wxCVqW+ei94JzV5kt0uXBcoOEAuiydrw==

"@matrix-org/matrix-sdk-crypto-js@^0.1.0-alpha.2":
version "0.1.0-alpha.2"
resolved "https://registry.yarnpkg.com/@matrix-org/matrix-sdk-crypto-js/-/matrix-sdk-crypto-js-0.1.0-alpha.2.tgz#a09d0fea858e817da971a3c9f904632ef7b49eb6"
integrity sha512-oVkBCh9YP7H9i4gAoQbZzswniczfo/aIptNa4dxRi4Ff9lSvUCFv6Hvzi7C+90c0/PWZLXjIDTIAWZYmwyd2fA==
"@matrix-org/matrix-sdk-crypto-js@^0.1.0-alpha.3":
version "0.1.0-alpha.4"
resolved "https://registry.yarnpkg.com/@matrix-org/matrix-sdk-crypto-js/-/matrix-sdk-crypto-js-0.1.0-alpha.4.tgz#1b20294e0354c3dcc9c7dc810d883198a4042f04"
integrity sha512-mdaDKrw3P5ZVCpq0ioW0pV6ihviDEbS8ZH36kpt9stLKHwwDSopPogE6CkQhi0B1jn1yBUtOYi32mBV/zcOR7g==

"@matrix-org/olm@https://gitlab.matrix.org/api/v4/projects/27/packages/npm/@matrix-org/olm/-/@matrix-org/olm-3.2.14.tgz":
version "3.2.14"
Expand Down Expand Up @@ -10362,12 +10362,12 @@ [email protected]:
resolved "https://registry.yarnpkg.com/matrix-events-sdk/-/matrix-events-sdk-0.0.1.tgz#c8c38911e2cb29023b0bbac8d6f32e0de2c957dd"
integrity sha512-1QEOsXO+bhyCroIe2/A5OwaxHvBm7EsSQ46DEDn8RBIfQwN5HWBpFvyWWR4QY0KHPPnnJdI99wgRiAl7Ad5qaA==

"matrix-js-sdk@github:matrix-org/matrix-js-sdk#64197bf4db6486d77708125d7fb2e8d7fe001f14":
version "23.1.1"
resolved "https://codeload.github.com/matrix-org/matrix-js-sdk/tar.gz/64197bf4db6486d77708125d7fb2e8d7fe001f14"
"matrix-js-sdk@github:matrix-org/matrix-js-sdk#c57aadb320164f1eea8f728c99fc54260745604b":
version "23.3.0"
resolved "https://codeload.github.com/matrix-org/matrix-js-sdk/tar.gz/c57aadb320164f1eea8f728c99fc54260745604b"
dependencies:
"@babel/runtime" "^7.12.5"
"@matrix-org/matrix-sdk-crypto-js" "^0.1.0-alpha.2"
"@matrix-org/matrix-sdk-crypto-js" "^0.1.0-alpha.3"
another-json "^0.2.0"
bs58 "^5.0.0"
content-type "^1.0.4"
Expand Down