forked from Github/frigate
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:
@@ -40,6 +40,7 @@ export default function WebRtcPlayer({
|
||||
}
|
||||
|
||||
const pc = new RTCPeerConnection({
|
||||
bundlePolicy: "max-bundle",
|
||||
iceServers: [{ urls: "stun:stun.l.google.com:19302" }],
|
||||
});
|
||||
|
||||
|
||||
@@ -3,3 +3,30 @@ export type VideoResolutionType = {
|
||||
width: number;
|
||||
height: number;
|
||||
};
|
||||
|
||||
type LiveProducerMetadata = {
|
||||
type: string;
|
||||
url: string;
|
||||
remote_addr: string;
|
||||
user_agent: string;
|
||||
sdp: string;
|
||||
medias: string[];
|
||||
receivers: string[];
|
||||
recv: number;
|
||||
};
|
||||
|
||||
type LiveConsumerMetadata = {
|
||||
type: string;
|
||||
url: string;
|
||||
remote_addr: string;
|
||||
user_agent: string;
|
||||
sdp: string;
|
||||
medias: string[];
|
||||
senders: string[];
|
||||
send: number;
|
||||
};
|
||||
|
||||
export type LiveStreamMetadata = {
|
||||
producers: LiveProducerMetadata[];
|
||||
consumers: LiveConsumerMetadata[];
|
||||
};
|
||||
|
||||
@@ -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}
|
||||
|
||||
Reference in New Issue
Block a user