Merge branch 'main' into hide-invite

This commit is contained in:
Robin Townsend 2022-10-14 10:51:41 -04:00
commit 684defdc19
3 changed files with 26 additions and 18 deletions

View file

@ -29,6 +29,8 @@ export interface UrlParams {
preload: boolean; preload: boolean;
// Whether to hide the room header when in a call // Whether to hide the room header when in a call
hideHeader: boolean; hideHeader: boolean;
// Whether to hide the screen-sharing button
hideScreensharing: boolean;
// Whether to start a walkie-talkie call instead of a video call // Whether to start a walkie-talkie call instead of a video call
isPtt: boolean; isPtt: boolean;
// Whether to use end-to-end encryption // Whether to use end-to-end encryption
@ -84,6 +86,7 @@ export const getUrlParams = (
isEmbedded: hasParam("embed"), isEmbedded: hasParam("embed"),
preload: hasParam("preload"), preload: hasParam("preload"),
hideHeader: hasParam("hideHeader"), hideHeader: hasParam("hideHeader"),
hideScreensharing: hasParam("hideScreensharing"),
isPtt: hasParam("ptt"), isPtt: hasParam("ptt"),
e2eEnabled: getParam("enableE2e") !== "false", // Defaults to true e2eEnabled: getParam("enableE2e") !== "false", // Defaults to true
userId: getParam("userId"), userId: getParam("userId"),

View file

@ -59,6 +59,7 @@ import { AudioContainer } from "../video-grid/AudioContainer";
import { useAudioOutputDevice } from "../video-grid/useAudioOutputDevice"; import { useAudioOutputDevice } from "../video-grid/useAudioOutputDevice";
import { widget, ElementWidgetActions } from "../widget"; import { widget, ElementWidgetActions } from "../widget";
import { useJoinRule } from "./useJoinRule"; import { useJoinRule } from "./useJoinRule";
import { useUrlParams } from "../UrlParams";
const canScreenshare = "getDisplayMedia" in (navigator.mediaDevices ?? {}); const canScreenshare = "getDisplayMedia" in (navigator.mediaDevices ?? {});
// There is currently a bug in Safari our our code with cloning and sending MediaStreams // There is currently a bug in Safari our our code with cloning and sending MediaStreams
@ -145,6 +146,8 @@ export function InCallView({
useAudioOutputDevice(audioRef, audioOutput); useAudioOutputDevice(audioRef, audioOutput);
const { hideScreensharing } = useUrlParams();
useEffect(() => { useEffect(() => {
widget?.api.transport.send( widget?.api.transport.send(
layout === "freedom" layout === "freedom"
@ -333,12 +336,15 @@ export function InCallView({
<div className={styles.footer}> <div className={styles.footer}>
<MicButton muted={microphoneMuted} onPress={toggleMicrophoneMuted} /> <MicButton muted={microphoneMuted} onPress={toggleMicrophoneMuted} />
<VideoButton muted={localVideoMuted} onPress={toggleLocalVideoMuted} /> <VideoButton muted={localVideoMuted} onPress={toggleLocalVideoMuted} />
{canScreenshare && !isSafari && !reducedControls && ( {canScreenshare &&
<ScreenshareButton !hideScreensharing &&
enabled={isScreensharing} !isSafari &&
onPress={toggleScreensharing} !reducedControls && (
/> <ScreenshareButton
)} enabled={isScreensharing}
onPress={toggleScreensharing}
/>
)}
{!reducedControls && ( {!reducedControls && (
<OverflowMenu <OverflowMenu
inCall inCall

View file

@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
import React, { useEffect, useRef } from "react"; import React, { FC, useEffect, useRef } from "react";
import { Participant } from "../room/InCallView"; import { Participant } from "../room/InCallView";
import { useCallFeed } from "./useCallFeed"; import { useCallFeed } from "./useCallFeed";
@ -29,19 +29,22 @@ interface AudioForParticipantProps {
audioDestination: AudioNode; audioDestination: AudioNode;
} }
export function AudioForParticipant({ export const AudioForParticipant: FC<AudioForParticipantProps> = ({
item, item,
audioContext, audioContext,
audioDestination, audioDestination,
}: AudioForParticipantProps): JSX.Element { }) => {
const { stream, localVolume, audioMuted } = useCallFeed(item.callFeed); const { stream, localVolume } = useCallFeed(item.callFeed);
const [audioTrackCount] = useMediaStreamTrackCount(stream); const [audioTrackCount] = useMediaStreamTrackCount(stream);
const gainNodeRef = useRef<GainNode>(); const gainNodeRef = useRef<GainNode>();
const sourceRef = useRef<MediaStreamAudioSourceNode>(); const sourceRef = useRef<MediaStreamAudioSourceNode>();
useEffect(() => { useEffect(() => {
if (!item.isLocal && audioContext && !audioMuted && audioTrackCount > 0) { // We don't compare the audioMuted flag of useCallFeed here, since unmuting
// depends on to-device messages which may lag behind the audio actually
// starting to flow over the network
if (!item.isLocal && audioContext && audioTrackCount > 0) {
if (!gainNodeRef.current) { if (!gainNodeRef.current) {
gainNodeRef.current = new GainNode(audioContext, { gainNodeRef.current = new GainNode(audioContext, {
gain: localVolume, gain: localVolume,
@ -68,12 +71,11 @@ export function AudioForParticipant({
audioDestination, audioDestination,
stream, stream,
localVolume, localVolume,
audioMuted,
audioTrackCount, audioTrackCount,
]); ]);
return null; return null;
} };
interface AudioContainerProps { interface AudioContainerProps {
items: Participant[]; items: Participant[];
@ -81,10 +83,7 @@ interface AudioContainerProps {
audioDestination: AudioNode; audioDestination: AudioNode;
} }
export function AudioContainer({ export const AudioContainer: FC<AudioContainerProps> = ({ items, ...rest }) => {
items,
...rest
}: AudioContainerProps): JSX.Element {
return ( return (
<> <>
{items {items
@ -94,4 +93,4 @@ export function AudioContainer({
))} ))}
</> </>
); );
} };