Update go2rtc and implement stream probe to only show 2 way talk when supported (#11407)

* Support two way talk validation

* Fix handling

* Use go2rtc stream info to infer audio output

* Update go2rtc

* Update bundle policy

* Formatting
This commit is contained in:
Nicolas Mowen
2024-05-17 07:30:22 -06:00
committed by GitHub
parent 07eef9b139
commit 97f5ba0145
10 changed files with 91 additions and 12 deletions

View File

@@ -21,7 +21,7 @@ import { TooltipProvider } from "@/components/ui/tooltip";
import { useResizeObserver } from "@/hooks/resize-observer";
import useKeyboardListener from "@/hooks/use-keyboard-listener";
import { CameraConfig } from "@/types/frigateConfig";
import { VideoResolutionType } from "@/types/live";
import { LiveStreamMetadata, VideoResolutionType } from "@/types/live";
import { CameraPtzInfo } from "@/types/ptz";
import { RecordingStartingPoint } from "@/types/record";
import React, {
@@ -83,6 +83,40 @@ export default function LiveCameraView({ camera }: LiveCameraViewProps) {
const [{ width: windowWidth, height: windowHeight }] =
useResizeObserver(window);
// supported features
const { data: cameraMetadata } = useSWR<LiveStreamMetadata>(
`go2rtc/streams/${camera.live.stream_name}`,
{
revalidateOnFocus: false,
},
);
const supports2WayTalk = useMemo(() => {
if (!window.isSecureContext || !cameraMetadata) {
return false;
}
return (
cameraMetadata.producers.find(
(prod) =>
prod.medias.find((media) => media.includes("audio, sendonly")) != undefined,
) != undefined
);
}, [cameraMetadata]);
const supportsAudioOutput = useMemo(() => {
if (!cameraMetadata) {
return false;
}
return (
cameraMetadata.producers.find(
(prod) =>
prod.medias.find((media) => media.includes("audio, recvonly")) != undefined,
) != undefined
);
}, [cameraMetadata])
// click overlay for ptzs
const [clickOverlay, setClickOverlay] = useState(false);
@@ -306,7 +340,7 @@ export default function LiveCameraView({ camera }: LiveCameraViewProps) {
}}
/>
)}
{window.isSecureContext && (
{supports2WayTalk && (
<CameraFeatureToggle
className="p-2 md:p-0"
variant={fullscreen ? "overlay" : "primary"}
@@ -316,14 +350,14 @@ export default function LiveCameraView({ camera }: LiveCameraViewProps) {
onClick={() => setMic(!mic)}
/>
)}
<CameraFeatureToggle
{supportsAudioOutput && <CameraFeatureToggle
className="p-2 md:p-0"
variant={fullscreen ? "overlay" : "primary"}
Icon={audio ? GiSpeaker : GiSpeakerOff}
isActive={audio}
title={`${audio ? "Disable" : "Enable"} Camera Audio`}
onClick={() => setAudio(!audio)}
/>
/>}
<FrigateCameraFeatures
camera={camera.name}
audioDetectEnabled={camera.audio.enabled_in_config}