import { StreamCallProvider } from '@stream-io/video-react-bindings'; import React, { type PropsWithChildren, useEffect } from 'react'; import { Call } from '@stream-io/video-client'; import { canAddPushWSSubscriptionsRef } from '../../utils/push/internal/utils'; import { useAndroidKeepCallAliveEffect } from '../../hooks/useAndroidKeepCallAliveEffect'; import { useScreenShareAudioMixing } from '../../hooks/useScreenShareAudioMixing'; import { AppStateListener } from './AppStateListener'; import { DeviceStats } from './DeviceStats'; import { AudioInterruptionTracer } from './AudioInterruptionTracer'; import { AudioSessionDiagnosticsTracer } from './AudioSessionDiagnosticsTracer'; import { pushUnsubscriptionCallbacks } from '../../utils/push/internal/constants'; import { useCallingExpWithCallingStateEffect } from '../../hooks/push/useCallingExpWithCallingStateEffect'; // const PIP_CHANGE_EVENT = 'StreamVideoReactNative_PIP_CHANGE_EVENT'; // const isAndroid8OrAbove = Platform.OS === 'android' && Platform.Version >= 26; export type StreamCallProps = { /** * Stream Call instance propagated to the component's children as a part of StreamCallContext. * Children can access it with useCall() hook. */ call: Call; }; /** * StreamCall is a wrapper component that orchestrates the call life cycle logic and * provides the call object to the children components. * @param PropsWithChildren * * @category Client State */ export const StreamCall = ({ call, children, }: PropsWithChildren) => { return ( {children} ); }; /** * This is a renderless component to keep the call alive on Android device using useAndroidKeepCallAliveEffect. * useAndroidKeepCallAliveEffect needs to called inside a child of StreamCallProvider. */ const AndroidKeepCallAlive = () => { useAndroidKeepCallAliveEffect(); return null; }; /** * This is a renderless component to sync state between stream call and CallKit/Telecom. * useCallingExpWithCallingStateEffect needs to called inside a child of StreamCallProvider. */ const CallingExpWithCallingState = () => { useCallingExpWithCallingStateEffect(); return null; }; /** * This is a renderless component to manage screen share audio mixing lifecycle. * It starts/stops native audio mixing based on screen share status and audio preference. */ const ScreenShareAudioMixer = () => { useScreenShareAudioMixing(); return null; }; /** * This is a renderless component to clear all push ws event subscriptions * and set whether push ws subscriptions can be added or not. */ const ClearPushWSSubscriptions = () => { useEffect(() => { // clear all the push ws event subscriptions pushUnsubscriptionCallbacks.forEach((cbArray) => cbArray.forEach((cb) => cb()), ); pushUnsubscriptionCallbacks.clear(); canAddPushWSSubscriptionsRef.current = false; return () => { canAddPushWSSubscriptionsRef.current = true; }; }, []); return null; };