Skip to content

Commit

Permalink
Merge pull request #156 from whereby/thomas/fix-screenshare-stream-bug
Browse files Browse the repository at this point in the history
Fix screenshare stream bug
  • Loading branch information
thyal authored Dec 4, 2023
2 parents 97824c9 + 0042ebe commit 83da34d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/lib/RoomParticipant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export interface RemoteParticipant {
isAudioEnabled: boolean;
isVideoEnabled: boolean;
isLocalParticipant: boolean;
stream: MediaStream | null;
stream: (MediaStream & { inboundId?: string }) | null;
streams: Stream[];
newJoiner: boolean;
presentationStream: (MediaStream & { inboundId?: string }) | null;
Expand Down
9 changes: 5 additions & 4 deletions src/lib/core/redux/slices/remoteParticipants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ function removeClient(state: RemoteParticipantState, participantId: string) {

function addStreamId(state: RemoteParticipantState, participantId: string, streamId: string) {
const { participant } = findParticipant(state, participantId);

if (!participant || participant.streams.find((s) => s.id === streamId)) {
console.warn(`No participant ${participantId} or stream ${streamId} already exists`);
return state;
Expand Down Expand Up @@ -142,13 +143,13 @@ function addStream(state: RemoteParticipantState, payload: RtcStreamAddedPayload
return state;
}

const remoteParticipantStream =
remoteParticipant.streams.find((s) => s.id === streamId) || remoteParticipant.streams[0];
const remoteParticipantStream = remoteParticipant.streams.find((s) => s.id === streamId);

if (
(remoteParticipant.stream && remoteParticipant.stream.id === streamId) ||
(remoteParticipant.stream &&
(remoteParticipant.stream.id === streamId || remoteParticipant.stream.inboundId === streamId)) ||
(!remoteParticipant.stream && streamType === "webcam") ||
(!remoteParticipant.stream && !streamType && remoteParticipant.streams.indexOf(remoteParticipantStream) < 1)
(!remoteParticipant.stream && !streamType && !remoteParticipantStream)
) {
return updateParticipant(state, clientId, { stream });
}
Expand Down

0 comments on commit 83da34d

Please sign in to comment.