fix: pass audio/video URL params to EC for correct initial device state
- Camera no longer starts enabled when user disables it in prescreen - When PTT mode is enabled, call starts muted so PTT works immediately without requiring a manual mute first - CallControlState also updated to match the forced-off audio for PTT EC 0.16.x ignores io.element.device_mute for initial state at startup, so audio= and video= URL params are the only reliable way to set the initial device state before the call begins.
This commit is contained in:
@@ -45,15 +45,18 @@ export const createCallEmbed = (
|
|||||||
themeKind: ElementCallThemeKind,
|
themeKind: ElementCallThemeKind,
|
||||||
container: HTMLElement,
|
container: HTMLElement,
|
||||||
pref?: CallPreferences,
|
pref?: CallPreferences,
|
||||||
noiseSuppression = true
|
noiseSuppression = true,
|
||||||
|
forceAudioOff = false
|
||||||
): CallEmbed => {
|
): CallEmbed => {
|
||||||
const rtcSession = mx.matrixRTC.getRoomSession(room);
|
const rtcSession = mx.matrixRTC.getRoomSession(room);
|
||||||
const ongoing =
|
const ongoing =
|
||||||
MatrixRTCSession.sessionMembershipsForRoom(room, rtcSession.sessionDescription).length > 0;
|
MatrixRTCSession.sessionMembershipsForRoom(room, rtcSession.sessionDescription).length > 0;
|
||||||
|
|
||||||
const intent = CallEmbed.getIntent(dm, ongoing);
|
const intent = CallEmbed.getIntent(dm, ongoing);
|
||||||
const widget = CallEmbed.getWidget(mx, room, intent, themeKind, noiseSuppression);
|
const initialAudio = forceAudioOff ? false : (pref?.microphone ?? true);
|
||||||
const controlState = pref && new CallControlState(pref.microphone, pref.video, pref.sound);
|
const initialVideo = pref?.video ?? false;
|
||||||
|
const widget = CallEmbed.getWidget(mx, room, intent, themeKind, noiseSuppression, initialAudio, initialVideo);
|
||||||
|
const controlState = pref && new CallControlState(forceAudioOff ? false : pref.microphone, pref.video, pref.sound);
|
||||||
|
|
||||||
const embed = new CallEmbed(mx, room, widget, container, controlState);
|
const embed = new CallEmbed(mx, room, widget, container, controlState);
|
||||||
|
|
||||||
@@ -66,6 +69,7 @@ export const useCallStart = (dm = false) => {
|
|||||||
const setCallEmbed = useSetAtom(callEmbedAtom);
|
const setCallEmbed = useSetAtom(callEmbedAtom);
|
||||||
const callEmbedRef = useCallEmbedRef();
|
const callEmbedRef = useCallEmbedRef();
|
||||||
const [callNoiseSuppression] = useSetting(settingsAtom, 'callNoiseSuppression');
|
const [callNoiseSuppression] = useSetting(settingsAtom, 'callNoiseSuppression');
|
||||||
|
const [pttMode] = useSetting(settingsAtom, 'pttMode');
|
||||||
|
|
||||||
const startCall = useCallback(
|
const startCall = useCallback(
|
||||||
(room: Room, pref?: CallPreferences) => {
|
(room: Room, pref?: CallPreferences) => {
|
||||||
@@ -73,11 +77,11 @@ export const useCallStart = (dm = false) => {
|
|||||||
if (!container) {
|
if (!container) {
|
||||||
throw new Error('Failed to start call, No embed container element found!');
|
throw new Error('Failed to start call, No embed container element found!');
|
||||||
}
|
}
|
||||||
const callEmbed = createCallEmbed(mx, room, dm, theme.kind, container, pref, callNoiseSuppression ?? true);
|
const callEmbed = createCallEmbed(mx, room, dm, theme.kind, container, pref, callNoiseSuppression ?? true, !!pttMode);
|
||||||
|
|
||||||
setCallEmbed(callEmbed);
|
setCallEmbed(callEmbed);
|
||||||
},
|
},
|
||||||
[mx, dm, theme, setCallEmbed, callEmbedRef, callNoiseSuppression]
|
[mx, dm, theme, setCallEmbed, callEmbedRef, callNoiseSuppression, pttMode]
|
||||||
);
|
);
|
||||||
|
|
||||||
return startCall;
|
return startCall;
|
||||||
|
|||||||
@@ -60,7 +60,9 @@ export class CallEmbed {
|
|||||||
room: Room,
|
room: Room,
|
||||||
intent: ElementCallIntent,
|
intent: ElementCallIntent,
|
||||||
themeKind: ElementCallThemeKind,
|
themeKind: ElementCallThemeKind,
|
||||||
noiseSuppression = true
|
noiseSuppression = true,
|
||||||
|
initialAudio = true,
|
||||||
|
initialVideo = false
|
||||||
): Widget {
|
): Widget {
|
||||||
const userId = mx.getSafeUserId();
|
const userId = mx.getSafeUserId();
|
||||||
const deviceId = mx.getDeviceId() ?? '';
|
const deviceId = mx.getDeviceId() ?? '';
|
||||||
@@ -83,6 +85,8 @@ export class CallEmbed {
|
|||||||
lang: 'en-EN',
|
lang: 'en-EN',
|
||||||
theme: themeKind,
|
theme: themeKind,
|
||||||
noiseSuppression: noiseSuppression.toString(),
|
noiseSuppression: noiseSuppression.toString(),
|
||||||
|
audio: initialAudio.toString(),
|
||||||
|
video: initialVideo.toString(),
|
||||||
});
|
});
|
||||||
|
|
||||||
const widgetUrl = new URL(
|
const widgetUrl = new URL(
|
||||||
|
|||||||
Reference in New Issue
Block a user