From 7945ca606fbf49194dd227950422d341b1bacc4f Mon Sep 17 00:00:00 2001 From: Chukwuebuka Nwankwo Date: Thu, 12 Sep 2024 19:23:59 +0000 Subject: [PATCH] Change files --- ...on-react-c5b508a6-370f-414d-9663-905d1ef3f69b.json | 9 +++++++++ .../calling-stateful-client/src/CallClientState.ts | 2 +- packages/calling-stateful-client/src/CallContext.ts | 11 +++++------ packages/calling-stateful-client/src/Converter.ts | 2 +- .../calling-stateful-client/src/StreamUtils.test.ts | 2 +- .../src/TogetherModeSubscriber.ts | 8 ++++---- .../review/beta/communication-react.api.md | 2 +- .../src/composites/CallComposite/MockCallAdapter.ts | 2 +- .../CallWithChatComposite/adapter/TestUtils.ts | 2 +- 9 files changed, 24 insertions(+), 16 deletions(-) create mode 100644 change-beta/@azure-communication-react-c5b508a6-370f-414d-9663-905d1ef3f69b.json diff --git a/change-beta/@azure-communication-react-c5b508a6-370f-414d-9663-905d1ef3f69b.json b/change-beta/@azure-communication-react-c5b508a6-370f-414d-9663-905d1ef3f69b.json new file mode 100644 index 0000000000..8ebd6c6f78 --- /dev/null +++ b/change-beta/@azure-communication-react-c5b508a6-370f-414d-9663-905d1ef3f69b.json @@ -0,0 +1,9 @@ +{ + "type": "prerelease", + "area": "feature", + "workstream": "Together Mode", + "comment": "This PR contains implementation of together mode client state changes and the event listener for together mode stream updates", + "packageName": "@azure/communication-react", + "email": "nwankwojustin93@gmail.com", + "dependentChangeType": "patch" +} diff --git a/packages/calling-stateful-client/src/CallClientState.ts b/packages/calling-stateful-client/src/CallClientState.ts index 107470993b..2c5f251d3a 100644 --- a/packages/calling-stateful-client/src/CallClientState.ts +++ b/packages/calling-stateful-client/src/CallClientState.ts @@ -284,7 +284,7 @@ export interface TogetherModeCallFeatureState { /** * Proxy of {@link @azure/communication-calling#TogetherModeCallFeature.togetherModeStream}. */ - stream?: TogetherModeStreamState; + stream: TogetherModeStreamState[]; } /* @conditional-compile-remove(together-mode) */ diff --git a/packages/calling-stateful-client/src/CallContext.ts b/packages/calling-stateful-client/src/CallContext.ts index bf3a97a413..1ce6c9c909 100644 --- a/packages/calling-stateful-client/src/CallContext.ts +++ b/packages/calling-stateful-client/src/CallContext.ts @@ -8,7 +8,6 @@ import { DominantSpeakersInfo, ParticipantRole, ScalingMode, - TogetherModeVideoStream, VideoDeviceInfo } from '@azure/communication-calling'; import { RaisedHand } from '@azure/communication-calling'; @@ -26,6 +25,8 @@ import { TeamsCaptionsInfo } from '@azure/communication-calling'; import { CaptionsKind, CaptionsInfo as AcsCaptionsInfo } from '@azure/communication-calling'; /* @conditional-compile-remove(unsupported-browser) */ import { EnvironmentInfo } from '@azure/communication-calling'; +/* @conditional-compile-remove(together-mode) */ +import { TogetherModeVideoStream } from '@azure/communication-calling'; import { AzureLogger, createClientLogger, getLogLevel } from '@azure/logger'; import { EventEmitter } from 'events'; import { enableMapSet, enablePatches, Patch, produce } from 'immer'; @@ -456,7 +457,7 @@ export class CallContext { } /* @conditional-compile-remove(together-mode) */ - public setTogetherModeVideoStream(callId: string, addedStream: TogetherModeVideoStream): void { + public setTogetherModeVideoStream(callId: string, addedStream: TogetherModeVideoStream[]): void { this.modifyState((draft: CallClientState) => { const call = draft.calls[this._callIdHistory.latestCallId(callId)]; if (call) { @@ -466,13 +467,11 @@ export class CallContext { } /* @conditional-compile-remove(together-mode) */ - public removeTogetherModeVideoStream(callId: string, removedStream: TogetherModeVideoStream): void { + public removeTogetherModeVideoStream(callId: string, removedStream: TogetherModeVideoStream[]): void { this.modifyState((draft: CallClientState) => { const call = draft.calls[this._callIdHistory.latestCallId(callId)]; if (call) { - if (call.togetherMode.stream && call.togetherMode.stream?.id === removedStream.id) { - call.togetherMode = { stream: undefined }; - } + call.togetherMode = { stream: [] }; } }); } diff --git a/packages/calling-stateful-client/src/Converter.ts b/packages/calling-stateful-client/src/Converter.ts index debe22b6bf..7244082c44 100644 --- a/packages/calling-stateful-client/src/Converter.ts +++ b/packages/calling-stateful-client/src/Converter.ts @@ -163,7 +163,7 @@ export function convertSdkCallToDeclarativeCall(call: CallCommon): CallState { pptLive: { isActive: false }, raiseHand: { raisedHands: [] }, /* @conditional-compile-remove(together-mode) */ - togetherMode: { stream: undefined }, + togetherMode: { stream: [] }, localParticipantReaction: undefined, transcription: { isTranscriptionActive: false }, screenShareRemoteParticipant: undefined, diff --git a/packages/calling-stateful-client/src/StreamUtils.test.ts b/packages/calling-stateful-client/src/StreamUtils.test.ts index 5b194d2e05..95662c0418 100644 --- a/packages/calling-stateful-client/src/StreamUtils.test.ts +++ b/packages/calling-stateful-client/src/StreamUtils.test.ts @@ -90,7 +90,7 @@ function createMockCall(mockCallId: string): CallState { localRecording: { isLocalRecordingActive: false }, raiseHand: { raisedHands: [] }, /* @conditional-compile-remove(together-mode) */ - togetherMode: { stream: undefined }, + togetherMode: { stream: [] }, localParticipantReaction: undefined, transcription: { isTranscriptionActive: false }, screenShareRemoteParticipant: undefined, diff --git a/packages/calling-stateful-client/src/TogetherModeSubscriber.ts b/packages/calling-stateful-client/src/TogetherModeSubscriber.ts index cbedf86457..0bde8905de 100644 --- a/packages/calling-stateful-client/src/TogetherModeSubscriber.ts +++ b/packages/calling-stateful-client/src/TogetherModeSubscriber.ts @@ -32,11 +32,11 @@ export class TogetherModeSubscriber { added: TogetherModeVideoStream[]; removed: TogetherModeVideoStream[]; }): void => { - for (const addedTogetherModeStream of args.added) { - this._context.setTogetherModeVideoStream(this._callIdRef.callId, addedTogetherModeStream); + if (args.added) { + this._context.setTogetherModeVideoStream(this._callIdRef.callId, args.added); } - for (const removedTogetherModeStream of args.removed) { - this._context.removeTogetherModeVideoStream(this._callIdRef.callId, removedTogetherModeStream); + if (args.removed) { + this._context.removeTogetherModeVideoStream(this._callIdRef.callId, args.removed); } }; } diff --git a/packages/communication-react/review/beta/communication-react.api.md b/packages/communication-react/review/beta/communication-react.api.md index ee17e28851..a9f0ea3bf3 100644 --- a/packages/communication-react/review/beta/communication-react.api.md +++ b/packages/communication-react/review/beta/communication-react.api.md @@ -4865,7 +4865,7 @@ export const toFlatCommunicationIdentifier: (identifier: CommunicationIdentifier // @alpha export interface TogetherModeCallFeature { - stream?: TogetherModeStreamState; + stream: TogetherModeStreamState[]; } // @alpha diff --git a/packages/react-composites/src/composites/CallComposite/MockCallAdapter.ts b/packages/react-composites/src/composites/CallComposite/MockCallAdapter.ts index 2e37d9f5e0..bdb4a3bfc6 100644 --- a/packages/react-composites/src/composites/CallComposite/MockCallAdapter.ts +++ b/packages/react-composites/src/composites/CallComposite/MockCallAdapter.ts @@ -261,7 +261,7 @@ const createDefaultCallAdapterState = (role?: ParticipantRole): CallAdapterState remoteParticipantsEnded: {}, raiseHand: { raisedHands: [] }, /* @conditional-compile-remove(together-mode) */ - togetherMode: { stream: undefined }, + togetherMode: { stream: [] }, pptLive: { isActive: false }, localParticipantReaction: undefined, role, diff --git a/packages/react-composites/src/composites/CallWithChatComposite/adapter/TestUtils.ts b/packages/react-composites/src/composites/CallWithChatComposite/adapter/TestUtils.ts index f39dd57f66..4eef39f30e 100644 --- a/packages/react-composites/src/composites/CallWithChatComposite/adapter/TestUtils.ts +++ b/packages/react-composites/src/composites/CallWithChatComposite/adapter/TestUtils.ts @@ -244,7 +244,7 @@ function createMockCall(mockCallId: string): CallState { dominantSpeakers: undefined, raiseHand: { raisedHands: [] }, /* @conditional-compile-remove(together-mode) */ - togetherMode: { stream: undefined }, + togetherMode: { stream: [] }, pptLive: { isActive: false }, localParticipantReaction: undefined, captionsFeature: {