import { Call as SdkCall , RemoteParticipant as SdkRemoteParticipant , RemoteVideoStream as SdkRemoteVideoStream , LocalVideoStream as SdkLocalVideoStream , IncomingCall as SdkIncomingCall , VideoStreamRendererView } from '@azure/communication-calling' ; import { toFlatCommunicationIdentifier } from '@internal/acs-ui-common' ; import { CallState , RemoteParticipantState as DeclarativeRemoteParticipant , RemoteVideoStreamState as DeclarativeRemoteVideoStream , LocalVideoStreamState as DeclarativeLocalVideoStream , IncomingCallState as DeclarativeIncomingCall , VideoStreamRendererViewState as DeclarativeVideoStreamRendererView } from './CallClientState' ; private export function convertSdkLocalStreamToDeclarativeLocalStream ( stream ) { return { source : stream . source , mediaStreamType : stream . mediaStreamType , view : undefined } ; } private export function convertSdkRemoteStreamToDeclarativeRemoteStream ( stream ) { return { id : stream . id , mediaStreamType : stream . mediaStreamType , isAvailable : stream . isAvailable , view : undefined } ; } private export function convertSdkParticipantToDeclarativeParticipant ( participant ) { const declarativeVideoStreams = { } ; for ( const videoStream of participant . videoStreams ) { declarativeVideoStreams [ videoStream . id ] = convertSdkRemoteStreamToDeclarativeRemoteStream ( videoStream ) ; } return { identifier : participant . identifier , displayName : participant . displayName , state : participant . state , callEndReason : participant . callEndReason , videoStreams : declarativeVideoStreams , isMuted : participant . isMuted , isSpeaking : participant . isSpeaking } ; } private export function convertSdkCallToDeclarativeCall ( call ) { const declarativeRemoteParticipants = { } ; call . remoteParticipants . forEach ( ( participant ) => { declarativeRemoteParticipants [ toFlatCommunicationIdentifier ( participant . identifier ) ] = convertSdkParticipantToDeclarativeParticipant ( participant ) ; } ) ; return { id : call . id , callerInfo : call . callerInfo , state : call . state , callEndReason : call . callEndReason , diagnostics : { network : { latest : { } } , media : { latest : { } } } , direction : call . direction , isMuted : call . isMuted , isScreenSharingOn : call . isScreenSharingOn , localVideoStreams : call . localVideoStreams . map ( convertSdkLocalStreamToDeclarativeLocalStream ) , remoteParticipants : declarativeRemoteParticipants , remoteParticipantsEnded : { } , recording : { isRecordingActive : false } , transcription : { isTranscriptionActive : false } , screenShareRemoteParticipant : undefined , startTime : new Date ( ) , endTime : undefined } ; } private export function convertSdkIncomingCallToDeclarativeIncomingCall ( call ) { return { id : call . id , callerInfo : call . callerInfo , startTime : new Date ( ) , endTime : undefined } ; } private export function convertFromSDKToDeclarativeVideoStreamRendererView ( view ) { return { scalingMode : view . scalingMode , isMirrored : view . isMirrored , target : view . target } ; }