in AzureCommunicationUI/sdk/AzureCommunicationUICalling/Sources/Service/Calling/AzureCommunicationCalling/CallingSDKEventsHandler.swift [236:285]
func onStateChanged(call: Call) {
callIdSubject.send(call.id)
let currentStatus = call.state.toCallingStatus()
let internalError = call.callEndReason.toCompositeInternalError(wasCallConnected())
if internalError != nil {
let code = call.callEndReason.code
let subcode = call.callEndReason.subcode
logger.error("Receive vaildate CallEndReason:\(code), subcode:\(subcode)")
}
if currentStatus == .connected {
self.captionsFeature = call.feature(Features.captions)
self.captionsFeature?.getCaptions {(value, error) in
if let error = error {
self.logger.error("Can not get the captions with error:\(error)")
} else {
if value?.type == CaptionsType.communicationCaptions {
// communication captions
self.communicationCaptions = value as? CommunicationCaptions
self.communicationCaptions?.delegate = self.communicationCaptionsHandler
self.captionsSupportedSpokenLanguages.send(self.communicationCaptions?
.supportedSpokenLanguages ?? [])
self.captionsTypeChanged.send(.communication)
}
if value?.type == CaptionsType.teamsCaptions {
// teams captions
self.teamsCaptions = value as? TeamsCaptions
self.teamsCaptions?.delegate = self.teamsCaptionsHandler
self.captionsSupportedSpokenLanguages.send(self.teamsCaptions?.supportedSpokenLanguages ?? [])
self.captionsSupportedCaptionLanguages.send(self.teamsCaptions?.supportedCaptionLanguages ?? [])
self.captionsTypeChanged.send(.teams)
}
}
}
}
let callInfoModel = CallInfoModel(status: currentStatus,
internalError: internalError,
callEndReasonCode: Int(call.callEndReason.code),
callEndReasonSubCode: Int(call.callEndReason.subcode))
logger.debug( "callInfoModel \(callInfoModel.status)")
logger.debug( "remoteParticipants \(call.remoteParticipants.count)")
callInfoSubject.send(callInfoModel)
if currentStatus == .connected || currentStatus == .connecting {
addRemoteParticipants(call.remoteParticipants)
}
if currentStatus == .disconnected {
call.delegate = nil
}
self.previousCallingStatus = currentStatus
}