changes made to reflect main
This commit is contained in:
parent
137afb1831
commit
88554107fc
|
|
@ -11,6 +11,7 @@ import { DEFAULT_ASPECT_RATIO } from '@dailyjs/shared/constants';
|
||||||
import { useParticipants } from '@dailyjs/shared/contexts/ParticipantsProvider';
|
import { useParticipants } from '@dailyjs/shared/contexts/ParticipantsProvider';
|
||||||
import { useTracks } from '@dailyjs/shared/contexts/TracksProvider';
|
import { useTracks } from '@dailyjs/shared/contexts/TracksProvider';
|
||||||
import { useActiveSpeaker } from '@dailyjs/shared/hooks/useActiveSpeaker';
|
import { useActiveSpeaker } from '@dailyjs/shared/hooks/useActiveSpeaker';
|
||||||
|
import { useCamSubscriptions } from '@dailyjs/shared/hooks/useCamSubscriptions';
|
||||||
import usePreferredLayer from '@dailyjs/shared/hooks/usePreferredLayer';
|
import usePreferredLayer from '@dailyjs/shared/hooks/usePreferredLayer';
|
||||||
import { ReactComponent as IconArrow } from '@dailyjs/shared/icons/raquo-md.svg';
|
import { ReactComponent as IconArrow } from '@dailyjs/shared/icons/raquo-md.svg';
|
||||||
import sortByKey from '@dailyjs/shared/lib/sortByKey';
|
import sortByKey from '@dailyjs/shared/lib/sortByKey';
|
||||||
|
|
@ -30,8 +31,6 @@ export const PaginatedVideoGrid = () => {
|
||||||
} = useParticipants();
|
} = useParticipants();
|
||||||
const activeSpeakerId = useActiveSpeaker();
|
const activeSpeakerId = useActiveSpeaker();
|
||||||
|
|
||||||
const { updateCamSubscriptions } = useTracks();
|
|
||||||
|
|
||||||
// Memoized participant count (does not include screen shares)
|
// Memoized participant count (does not include screen shares)
|
||||||
const displayableParticipantCount = useMemo(
|
const displayableParticipantCount = useMemo(
|
||||||
() => participantCount,
|
() => participantCount,
|
||||||
|
|
@ -178,23 +177,10 @@ export const PaginatedVideoGrid = () => {
|
||||||
};
|
};
|
||||||
}, [page, pageSize, participants, visibleParticipants]);
|
}, [page, pageSize, participants, visibleParticipants]);
|
||||||
|
|
||||||
// Update subscriptions when array of subscribed or paused participants mutates
|
useCamSubscriptions(
|
||||||
const debouncedUpdate = useCallback(
|
|
||||||
(subIds, pausedIds) =>
|
|
||||||
debounce(() => updateCamSubscriptions(subIds, pausedIds), 90),
|
|
||||||
[updateCamSubscriptions]
|
|
||||||
);
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
debouncedUpdate(
|
|
||||||
camSubscriptions?.subscribedIds,
|
|
||||||
camSubscriptions?.pausedIds
|
|
||||||
);
|
|
||||||
}, [
|
|
||||||
camSubscriptions?.subscribedIds,
|
camSubscriptions?.subscribedIds,
|
||||||
camSubscriptions?.pausedIds,
|
camSubscriptions?.pausedIds
|
||||||
debouncedUpdate,
|
);
|
||||||
]);
|
|
||||||
|
|
||||||
// Set bandwidth layer based on amount of visible participants
|
// Set bandwidth layer based on amount of visible participants
|
||||||
usePreferredLayer(visibleParticipants);
|
usePreferredLayer(visibleParticipants);
|
||||||
|
|
|
||||||
|
|
@ -5,12 +5,11 @@ import Modal from '@dailyjs/shared/components/Modal';
|
||||||
import Well from '@dailyjs/shared/components/Well';
|
import Well from '@dailyjs/shared/components/Well';
|
||||||
import { useCallState } from '@dailyjs/shared/contexts/CallProvider';
|
import { useCallState } from '@dailyjs/shared/contexts/CallProvider';
|
||||||
import { useUIState } from '@dailyjs/shared/contexts/UIStateProvider';
|
import { useUIState } from '@dailyjs/shared/contexts/UIStateProvider';
|
||||||
import { enable } from 'debug';
|
|
||||||
import {
|
import {
|
||||||
RECORDING_COUNTDOWN_1,
|
RECORDING_COUNTDOWN_1,
|
||||||
RECORDING_COUNTDOWN_2,
|
RECORDING_COUNTDOWN_2,
|
||||||
RECORDING_COUNTDOWN_3,
|
RECORDING_COUNTDOWN_3,
|
||||||
RECORDING_ERROR,
|
|
||||||
RECORDING_IDLE,
|
RECORDING_IDLE,
|
||||||
RECORDING_RECORDING,
|
RECORDING_RECORDING,
|
||||||
RECORDING_SAVED,
|
RECORDING_SAVED,
|
||||||
|
|
|
||||||
|
|
@ -61,11 +61,14 @@ export const TracksProvider = ({ children }) => {
|
||||||
isLocalId(id) ||
|
isLocalId(id) ||
|
||||||
isScreenId(id) ||
|
isScreenId(id) ||
|
||||||
rtcpeers.getCurrentType() !== 'sfu'
|
rtcpeers.getCurrentType() !== 'sfu'
|
||||||
)
|
) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!rtcpeers.soup.implementationIsAcceptingCalls) {
|
if (!rtcpeers.soup.implementationIsAcceptingCalls) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const consumer = rtcpeers.soup?.findConsumerForTrack(id, 'cam-video');
|
const consumer = rtcpeers.soup?.findConsumerForTrack(id, 'cam-video');
|
||||||
if (!consumer) {
|
if (!consumer) {
|
||||||
rtcpeers.soup.setResumeOnSubscribeForTrack(id, 'cam-video', false);
|
rtcpeers.soup.setResumeOnSubscribeForTrack(id, 'cam-video', false);
|
||||||
|
|
@ -169,16 +172,6 @@ export const TracksProvider = ({ children }) => {
|
||||||
return { ...u, [id]: result };
|
return { ...u, [id]: result };
|
||||||
}, {});
|
}, {});
|
||||||
|
|
||||||
// Fast resume already subscribed videos
|
|
||||||
ids
|
|
||||||
.filter((id) => !pausedIds.includes(id))
|
|
||||||
.forEach((id) => {
|
|
||||||
const p = callObject.participants()?.[id];
|
|
||||||
if (p?.tracks?.video?.subscribed) {
|
|
||||||
resumeVideoTrack(id);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
callObject.updateParticipants(updates);
|
callObject.updateParticipants(updates);
|
||||||
},
|
},
|
||||||
[
|
[
|
||||||
|
|
@ -227,6 +220,7 @@ export const TracksProvider = ({ children }) => {
|
||||||
trackStoppedQueue.push([participant, track]);
|
trackStoppedQueue.push([participant, track]);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleParticipantLeft = ({ participant }) => {
|
const handleParticipantLeft = ({ participant }) => {
|
||||||
dispatch({
|
dispatch({
|
||||||
type: REMOVE_TRACKS,
|
type: REMOVE_TRACKS,
|
||||||
|
|
@ -256,11 +250,9 @@ export const TracksProvider = ({ children }) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rtcpeers?.getCurrentType?.() === 'peer-to-peer') {
|
if (rtcpeers?.getCurrentType?.() === 'peer-to-peer') {
|
||||||
result.setSubscribedTracks = {
|
result.setSubscribedTracks = true;
|
||||||
...result.setSubscribedTracks,
|
|
||||||
video: true,
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return { [id]: result };
|
return { [id]: result };
|
||||||
}, {});
|
}, {});
|
||||||
callObject.updateParticipants(updates);
|
callObject.updateParticipants(updates);
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,24 @@
|
||||||
|
import { useDeepCompareEffect } from 'use-deep-compare';
|
||||||
|
import { useTracks } from '../contexts/TracksProvider';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates cam subscriptions based on passed ids and pausedIds.
|
||||||
|
* @param ids Participant ids which should be subscribed to.
|
||||||
|
* @param pausedIds Participant ids which should be subscribed, but paused.
|
||||||
|
* @param delay Throttle in milliseconds. Default: 50
|
||||||
|
*/
|
||||||
|
export const useCamSubscriptions = (ids, pausedIds = [], throttle = 50) => {
|
||||||
|
const { updateCamSubscriptions } = useTracks();
|
||||||
|
|
||||||
|
useDeepCompareEffect(() => {
|
||||||
|
if (!ids || !pausedIds) return false;
|
||||||
|
const timeout = setTimeout(() => {
|
||||||
|
updateCamSubscriptions(ids, pausedIds);
|
||||||
|
}, throttle);
|
||||||
|
return () => {
|
||||||
|
clearTimeout(timeout);
|
||||||
|
};
|
||||||
|
}, [ids, pausedIds, throttle, updateCamSubscriptions]);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default useCamSubscriptions;
|
||||||
Loading…
Reference in New Issue