Revert "adapt v2 livekit-client"

This reverts commit 8ff05bb95f.
This commit is contained in:
fkwp
2024-04-23 10:07:56 +02:00
parent 8ff05bb95f
commit 4f33c55287
4 changed files with 36 additions and 78 deletions

View File

@@ -61,9 +61,7 @@ async function doConnect(
// doesn't publish it until you unmute. We want to publish it from the start so we're
// always capturing audio: it helps keep bluetooth headsets in the right mode and
// mobile browsers to know we're doing a call.
if (
livekitRoom!.localParticipant.getTrackPublication(Track.Source.Microphone)
) {
if (livekitRoom!.localParticipant.getTrack(Track.Source.Microphone)) {
logger.warn(
"Pre-creating audio track but participant already appears to have an microphone track: this shouldn't happen!",
);
@@ -92,9 +90,7 @@ async function doConnect(
if (!audioEnabled) await preCreatedAudioTrack?.mute();
// check again having awaited for the track to create
if (
livekitRoom!.localParticipant.getTrackPublication(Track.Source.Microphone)
) {
if (livekitRoom!.localParticipant.getTrack(Track.Source.Microphone)) {
logger.warn(
"Pre-created audio track but participant already appears to have an microphone track: this shouldn't happen!",
);
@@ -178,7 +174,7 @@ export function useECConnectionState(
const doFocusSwitch = useCallback(async (): Promise<void> => {
const screenshareTracks: MediaStreamTrack[] = [];
for (const t of livekitRoom!.localParticipant.videoTrackPublications.values()) {
for (const t of livekitRoom!.localParticipant.videoTracks.values()) {
if (t.track && t.source == Track.Source.ScreenShare) {
const newTrack = t.track.mediaStreamTrack.clone();
newTrack.enabled = true;

View File

@@ -293,7 +293,7 @@ export function useLiveKit(
room.options.audioCaptureDefaults?.deviceId === "default"
) {
const activeMicTrack = Array.from(
room.localParticipant.audioTrackPublications.values(),
room.localParticipant.audioTracks.values(),
).find((d) => d.source === Track.Source.Microphone)?.track;
const defaultDevice = device.available.find(
@@ -315,7 +315,7 @@ export function useLiveKit(
// Note that room.switchActiveDevice() won't work: Livekit will ignore it because
// the deviceId hasn't changed (was & still is default).
room.localParticipant
.getTrackPublication(Track.Source.Microphone)
.getTrack(Track.Source.Microphone)
?.audioTrack?.restartTrack();
}
} else {