use of com.fanap.podchat.call.model.ClientDTO in project pod-chat-android-sdk by FanapSoft.
the class Chat method startVideoCall.
private void startVideoCall(ChatResponse<StartedCallModel> info) {
if (podVideoCall != null) {
KafkaConfig kafkaConfig = new KafkaConfig.Builder(info.getResult().getChatDataDTO().getBrokerAddress()).setSsl(info.getResult().getCert_file()).build();
podVideoCall.setKafkaConfig(kafkaConfig);
ClientDTO localClient = info.getResult().getClientDTO();
String sendVideoTopic = localClient.getTopicSendVideo();
String sendAudioTopic = localClient.getTopicSendAudio();
CallPartner.Builder lCallPartnerBuilder = new CallPartner.Builder();
lCallPartnerBuilder.setPartnerType(PartnerType.LOCAL);
lCallPartnerBuilder.setName(info.getResult().getClientDTO().getSendKey() + "" + sendVideoTopic);
if (localClient.getVideo()) {
visibleView(localPartnerView);
localPartnerView.setPartnerId(CoreConfig.userId);
localPartnerView.setPartnerName("You");
lCallPartnerBuilder.setVideoTopic(sendVideoTopic);
lCallPartnerBuilder.setVideoView(localPartnerView);
}
lCallPartnerBuilder.setAudioTopic(sendAudioTopic);
podVideoCall.addPartner(lCallPartnerBuilder.build());
if (Util.isNotNullOrEmpty(info.getResult().getOtherClientDtoList())) {
prepareRemotePartnersByClientDTOList(info);
} else {
captureError(new PodChatException("Util.isNotNullOrEmpty(info.getResult().getOtherClientDtoList()) == false", ChatConstant.ERROR_CODE_INVALID_DATA));
}
try {
podVideoCall.startCall();
} catch (MicrophoneUnavailableException e) {
captureError(new PodChatException(e.getMessage(), ChatConstant.ERROR_CODE_MICROPHONE_NOT_AVAILABLE, info.getUniqueId()));
sendClientCallErrors(new CallClientErrorsRequest.Builder(info.getSubjectId(), ChatConstant.ERROR_CODE_MICROPHONE_NOT_AVAILABLE).build());
} catch (CameraUnavailableException e) {
captureError(new PodChatException(e.getMessage(), ChatConstant.ERROR_CODE_CAMERA_NOT_AVAILABLE, info.getUniqueId()));
sendClientCallErrors(new CallClientErrorsRequest.Builder(info.getSubjectId(), ChatConstant.ERROR_CODE_CAMERA_NOT_AVAILABLE).build());
}
if (callServiceManager != null)
callServiceManager.startCallService(info, new ICallState() {
@Override
public void onInfoEvent(String info) {
}
@Override
public void onErrorEvent(String cause) {
}
@Override
public void onEndCallRequested() {
endCall();
endCall(CallAsyncRequestsManager.createEndCallRequest(info.getSubjectId()));
listenerManager.callOnEndCallRequestFromNotification();
}
});
}
}
use of com.fanap.podchat.call.model.ClientDTO in project pod-chat-android-sdk by FanapSoft.
the class CallAsyncRequestsManager method handleOnCallConnectReceived.
public static ChatResponse<CallReconnectResult> handleOnCallConnectReceived(ChatMessage chatMessage) {
ChatResponse<CallReconnectResult> response = null;
try {
response = new ChatResponse<>();
response.setUniqueId(chatMessage.getUniqueId());
response.setSubjectId(chatMessage.getSubjectId());
ClientDTO clientDTO = App.getGson().fromJson(chatMessage.getContent(), ClientDTO.class);
CallReconnectResult result = new CallReconnectResult();
result.setCallId(chatMessage.getSubjectId());
result.setClientId(clientDTO.getClientId());
response.setResult(result);
} catch (Exception e) {
Log.wtf(TAG, e);
}
return response;
}
use of com.fanap.podchat.call.model.ClientDTO in project pod-chat-android-sdk by FanapSoft.
the class CallAsyncRequestsManager method handleOnCallReconnectReceived.
public static ChatResponse<CallReconnectResult> handleOnCallReconnectReceived(ChatMessage chatMessage) {
ChatResponse<CallReconnectResult> response = null;
try {
response = new ChatResponse<>();
response.setUniqueId(chatMessage.getUniqueId());
response.setSubjectId(chatMessage.getSubjectId());
ClientDTO clientDTO = App.getGson().fromJson(chatMessage.getContent(), ClientDTO.class);
CallReconnectResult result = new CallReconnectResult();
result.setCallId(chatMessage.getSubjectId());
result.setClientId(clientDTO.getClientId());
response.setResult(result);
} catch (Exception e) {
Log.wtf(TAG, e);
}
return response;
}
use of com.fanap.podchat.call.model.ClientDTO in project pod-chat-android-sdk by FanapSoft.
the class CallAsyncRequestsManager method fillResult.
public static ChatResponse<CallStartResult> fillResult(ChatResponse<StartedCallModel> callResponse) {
ChatResponse<CallStartResult> response = new ChatResponse<>();
ArrayList<CallParticipantVO> callPartners = new ArrayList<>();
if (Util.isNotNullOrEmpty(callResponse.getResult().getOtherClientDtoList())) {
for (ClientDTO client : callResponse.getResult().getOtherClientDtoList()) {
if (!client.getUserId().equals(CoreConfig.userId)) {
CallParticipantVO partner = new CallParticipantVO();
partner.setUserId(client.getUserId());
partner.setMute(client.getMute());
partner.setVideo(client.getVideo());
callPartners.add(partner);
}
}
}
CallStartResult result = new CallStartResult(callResponse.getResult().getCallName(), callResponse.getResult().getCallImage(), callPartners);
response.setResult(result);
response.setSubjectId(callResponse.getSubjectId());
response.setUniqueId(callResponse.getUniqueId());
return response;
}
use of com.fanap.podchat.call.model.ClientDTO in project pod-chat-android-sdk by FanapSoft.
the class Chat method prepareRemotePartnersByClientDTOList.
private void prepareRemotePartnersByClientDTOList(ChatResponse<StartedCallModel> info) {
boolean hasScreenSharer = CallAsyncRequestsManager.checkIsAnyScreenSharing(info);
boolean isCallRecording = CallAsyncRequestsManager.checkIsCallIsRecording(info);
for (ClientDTO client : info.getResult().getOtherClientDtoList()) {
if (client.getUserId() == 0)
continue;
if (!client.getUserId().equals(CoreConfig.userId)) {
CallPartner.Builder rPartnerBuilder = new CallPartner.Builder();
rPartnerBuilder.setId(client.getUserId());
rPartnerBuilder.setPartnerType(PartnerType.REMOTE).setName("" + client.getUserId());
rPartnerBuilder.setVideoTopic(client.getTopicSendVideo());
rPartnerBuilder.setHasVideo(Util.isNotNullOrEmpty(client.getTopicSendVideo()));
rPartnerBuilder.setVideoOn(client.getVideo());
if (client.getVideo() && hasRemotePartnerView()) {
CallPartnerView view = assignCallPartnerView(client.getUserId());
if (view != null) {
visibleView(view);
rPartnerBuilder.setVideoView(view);
} else {
rPartnerBuilder.setVideoOn(false);
}
}
rPartnerBuilder.setAudioTopic(client.getTopicSendAudio());
rPartnerBuilder.setHasAudio(Util.isNotNullOrEmpty(client.getTopicSendAudio()));
rPartnerBuilder.setAudioOn(!client.getMute());
CallPartner rPartner = rPartnerBuilder.build();
podVideoCall.addPartner(rPartner);
}
}
if (hasScreenSharer) {
ChatResponse<ScreenShareResult> sc = CallAsyncRequestsManager.handleOnScreenIsSharing(info);
addScreenSharer(sc);
}
if (isCallRecording) {
ChatResponse<Participant> response = CallAsyncRequestsManager.handleCallIsRecordingCallResponse(info);
if (CoreConfig.userId.equals(response.getResult().getId())) {
removeCallback(info.getUniqueId());
listenerManager.callOnCallRecordStarted(response);
} else {
listenerManager.callOnCallParticipantStartRecording(response);
}
}
}
Aggregations