From 1be4218ec94a7dd824a58d42c6a2312c6c7df68f Mon Sep 17 00:00:00 2001 From: Half-Shot Date: Tue, 16 Sep 2025 15:16:57 +0100 Subject: [PATCH] Add media hints for notification events. --- src/UrlParams.ts | 30 +++++++++++++++++++++++++++++- src/rtcSessionHelpers.ts | 6 +++++- 2 files changed, 34 insertions(+), 2 deletions(-) diff --git a/src/UrlParams.ts b/src/UrlParams.ts index f5369765..c8aaf7e6 100644 --- a/src/UrlParams.ts +++ b/src/UrlParams.ts @@ -8,7 +8,10 @@ Please see LICENSE in the repository root for full details. import { useMemo } from "react"; import { useLocation } from "react-router-dom"; import { logger } from "matrix-js-sdk/lib/logger"; -import { type RTCNotificationType } from "matrix-js-sdk/lib/matrixrtc"; +import { + RTCMediaHint, + type RTCNotificationType, +} from "matrix-js-sdk/lib/matrixrtc"; import { pickBy } from "lodash-es"; import { Config } from "./config/Config"; @@ -26,7 +29,9 @@ export enum UserIntent { StartNewCall = "start_call", JoinExistingCall = "join_existing", StartNewCallDM = "start_call_dm", + StartNewCallDMVoice = "start_call_dm_voice", JoinExistingCallDM = "join_existing_dm", + JoinExistingCallDMVoice = "join_existing_dm_voice", Unknown = "unknown", } @@ -227,6 +232,8 @@ export interface UrlConfiguration { * - auto-dismiss the call widget once the notification lifetime expires on the receivers side. */ waitForCallPickup: boolean; + + mediaHint?: RTCMediaHint; } // If you need to add a new flag to this interface, prefer a name that describes @@ -365,12 +372,14 @@ export const getUrlParams = ( intentPreset = { ...inAppDefault, skipLobby: true, + mediaHint: "video", }; break; case UserIntent.JoinExistingCall: intentPreset = { ...inAppDefault, skipLobby: false, + mediaHint: "video", }; break; case UserIntent.StartNewCallDM: @@ -379,6 +388,16 @@ export const getUrlParams = ( skipLobby: true, autoLeaveWhenOthersLeft: true, waitForCallPickup: true, + mediaHint: "video", + }; + break; + case UserIntent.StartNewCallDMVoice: + intentPreset = { + ...inAppDefault, + skipLobby: true, + autoLeaveWhenOthersLeft: true, + waitForCallPickup: true, + mediaHint: "audio", }; break; case UserIntent.JoinExistingCallDM: @@ -386,6 +405,15 @@ export const getUrlParams = ( ...inAppDefault, skipLobby: true, autoLeaveWhenOthersLeft: true, + mediaHint: "video", + }; + break; + case UserIntent.JoinExistingCallDMVoice: + intentPreset = { + ...inAppDefault, + skipLobby: true, + autoLeaveWhenOthersLeft: true, + mediaHint: "audio", }; break; // Non widget usecase defaults diff --git a/src/rtcSessionHelpers.ts b/src/rtcSessionHelpers.ts index 73f58cea..3c9b759d 100644 --- a/src/rtcSessionHelpers.ts +++ b/src/rtcSessionHelpers.ts @@ -120,11 +120,15 @@ export async function enterRTCSession( const { features, matrix_rtc_session: matrixRtcSessionConfig } = Config.get(); const useDeviceSessionMemberEvents = features?.feature_use_device_session_member_events; + const { sendNotificationType: notificationType, mediaHint } = getUrlParams(); rtcSession.joinRoomSession( await makePreferredLivekitFoci(rtcSession, livekitAlias), makeActiveFocus(), { - notificationType: getUrlParams().sendNotificationType, + notification: notificationType && { + type: notificationType, + hint: mediaHint, + }, useNewMembershipManager, manageMediaKeys: encryptMedia, ...(useDeviceSessionMemberEvents !== undefined && {