post merge
This commit is contained in:
@@ -10,7 +10,6 @@ import {
|
|||||||
ParticipantEvent,
|
ParticipantEvent,
|
||||||
type LocalParticipant,
|
type LocalParticipant,
|
||||||
type ScreenShareCaptureOptions,
|
type ScreenShareCaptureOptions,
|
||||||
ConnectionState,
|
|
||||||
RoomEvent,
|
RoomEvent,
|
||||||
MediaDeviceFailure,
|
MediaDeviceFailure,
|
||||||
} from "livekit-client";
|
} from "livekit-client";
|
||||||
@@ -329,11 +328,10 @@ export const createLocalMembership$ = ({
|
|||||||
// Based on `connectRequested$` we start publishing tracks. (once they are there!)
|
// Based on `connectRequested$` we start publishing tracks. (once they are there!)
|
||||||
scope.reconcile(
|
scope.reconcile(
|
||||||
scope.behavior(
|
scope.behavior(
|
||||||
combineLatest([publisher$, tracks$, joinAndPublishRequested$]),
|
combineLatest([publisher$, joinAndPublishRequested$]),
|
||||||
),
|
),
|
||||||
async ([publisher, tracks, shouldJoinAndPublish]) => {
|
async ([publisher, shouldJoinAndPublish]) => {
|
||||||
if (shouldJoinAndPublish === publisher?.publishing$.value) return;
|
if (shouldJoinAndPublish) {
|
||||||
if (tracks.length !== 0 && shouldJoinAndPublish) {
|
|
||||||
try {
|
try {
|
||||||
await publisher?.startPublishing();
|
await publisher?.startPublishing();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@@ -341,7 +339,7 @@ export const createLocalMembership$ = ({
|
|||||||
error instanceof Error ? error.message : String(error);
|
error instanceof Error ? error.message : String(error);
|
||||||
setPublishError(new FailToStartLivekitConnection(message));
|
setPublishError(new FailToStartLivekitConnection(message));
|
||||||
}
|
}
|
||||||
} else if (tracks.length !== 0 && !shouldJoinAndPublish) {
|
} else {
|
||||||
try {
|
try {
|
||||||
await publisher?.stopPublishing();
|
await publisher?.stopPublishing();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@@ -391,15 +389,6 @@ export const createLocalMembership$ = ({
|
|||||||
combineLatest([
|
combineLatest([
|
||||||
localConnectionState$,
|
localConnectionState$,
|
||||||
localTransport$,
|
localTransport$,
|
||||||
// tracks$.pipe(
|
|
||||||
// tap((t) => {
|
|
||||||
// logger.info("tracks$: ", t);
|
|
||||||
// }),
|
|
||||||
// ),
|
|
||||||
// publishing$,
|
|
||||||
connectRequested$,
|
|
||||||
tracks$,
|
|
||||||
publishing$,
|
|
||||||
joinAndPublishRequested$,
|
joinAndPublishRequested$,
|
||||||
from(trackStartRequested.promise).pipe(
|
from(trackStartRequested.promise).pipe(
|
||||||
map(() => true),
|
map(() => true),
|
||||||
@@ -410,16 +399,17 @@ export const createLocalMembership$ = ({
|
|||||||
([
|
([
|
||||||
localConnectionState,
|
localConnectionState,
|
||||||
localTransport,
|
localTransport,
|
||||||
tracks,
|
// tracks,
|
||||||
publishing,
|
// publishing,
|
||||||
shouldPublish,
|
shouldPublish,
|
||||||
shouldStartTracks,
|
shouldStartTracks,
|
||||||
]) => {
|
]) => {
|
||||||
if (!localTransport) return null;
|
if (!localTransport) return null;
|
||||||
const hasTracks = tracks.length > 0;
|
// const hasTracks = tracks.length > 0;
|
||||||
let trackState: TrackState = TrackState.WaitingForUser;
|
// let trackState: TrackState = TrackState.WaitingForUser;
|
||||||
if (hasTracks && shouldStartTracks) trackState = TrackState.Ready;
|
// if (hasTracks && shouldStartTracks) trackState = TrackState.Ready;
|
||||||
if (!hasTracks && shouldStartTracks) trackState = TrackState.Creating;
|
// if (!hasTracks && shouldStartTracks) trackState = TrackState.Creating;
|
||||||
|
const trackState: TrackState = shouldStartTracks ? TrackState.Ready : TrackState.WaitingForUser;
|
||||||
|
|
||||||
if (
|
if (
|
||||||
localConnectionState !== ConnectionState.LivekitConnected ||
|
localConnectionState !== ConnectionState.LivekitConnected ||
|
||||||
@@ -430,7 +420,7 @@ export const createLocalMembership$ = ({
|
|||||||
tracks: trackState,
|
tracks: trackState,
|
||||||
};
|
};
|
||||||
if (!shouldPublish) return PublishState.WaitingForUser;
|
if (!shouldPublish) return PublishState.WaitingForUser;
|
||||||
if (!publishing) return PublishState.Starting;
|
// if (!publishing) return PublishState.Starting;
|
||||||
return PublishState.Publishing;
|
return PublishState.Publishing;
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
@@ -660,7 +650,6 @@ export const createLocalMembership$ = ({
|
|||||||
requestJoinAndPublish,
|
requestJoinAndPublish,
|
||||||
requestDisconnect,
|
requestDisconnect,
|
||||||
localMemberState$,
|
localMemberState$,
|
||||||
tracks$,
|
|
||||||
participant$,
|
participant$,
|
||||||
reconnecting$,
|
reconnecting$,
|
||||||
disconnected$: scope.behavior(
|
disconnected$: scope.behavior(
|
||||||
|
|||||||
Reference in New Issue
Block a user