Search in sources :

Example 1 with ClientDTO

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();
                }
            });
    }
}
Also used : CallClientErrorsRequest(com.fanap.podchat.call.request_model.CallClientErrorsRequest) PodChatException(com.fanap.podchat.util.PodChatException) MicrophoneUnavailableException(com.fanap.podcall.error.MicrophoneUnavailableException) PodCallBuilder(com.fanap.podcall.PodCallBuilder) ClientDTO(com.fanap.podchat.call.model.ClientDTO) CameraUnavailableException(com.fanap.podcall.error.CameraUnavailableException) ICallState(com.fanap.podchat.call.audio_call.ICallState) CallPartner(com.fanap.podcall.model.CallPartner) KafkaConfig(com.fanap.podcall.kafka.KafkaConfig)

Example 2 with ClientDTO

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;
}
Also used : ClientDTO(com.fanap.podchat.call.model.ClientDTO) SendClientDTO(com.fanap.podchat.call.model.SendClientDTO) PodChatException(com.fanap.podchat.util.PodChatException) JsonSyntaxException(com.google.gson.JsonSyntaxException) CallReconnectResult(com.fanap.podchat.call.result_model.CallReconnectResult)

Example 3 with ClientDTO

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;
}
Also used : ClientDTO(com.fanap.podchat.call.model.ClientDTO) SendClientDTO(com.fanap.podchat.call.model.SendClientDTO) PodChatException(com.fanap.podchat.util.PodChatException) JsonSyntaxException(com.google.gson.JsonSyntaxException) CallReconnectResult(com.fanap.podchat.call.result_model.CallReconnectResult)

Example 4 with ClientDTO

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;
}
Also used : CallStartResult(com.fanap.podchat.call.result_model.CallStartResult) CallParticipantVO(com.fanap.podchat.call.model.CallParticipantVO) ChatResponse(com.fanap.podchat.model.ChatResponse) ClientDTO(com.fanap.podchat.call.model.ClientDTO) SendClientDTO(com.fanap.podchat.call.model.SendClientDTO) ArrayList(java.util.ArrayList)

Example 5 with ClientDTO

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);
        }
    }
}
Also used : ScreenShareResult(com.fanap.podchat.call.request_model.screen_share.ScreenShareResult) Participant(com.fanap.podchat.mainmodel.Participant) ClientDTO(com.fanap.podchat.call.model.ClientDTO) PodCallBuilder(com.fanap.podcall.PodCallBuilder) CallPartner(com.fanap.podcall.model.CallPartner) CallPartnerView(com.fanap.podcall.view.CallPartnerView)

Aggregations

ClientDTO (com.fanap.podchat.call.model.ClientDTO)5 SendClientDTO (com.fanap.podchat.call.model.SendClientDTO)3 PodChatException (com.fanap.podchat.util.PodChatException)3 PodCallBuilder (com.fanap.podcall.PodCallBuilder)2 CallPartner (com.fanap.podcall.model.CallPartner)2 CallReconnectResult (com.fanap.podchat.call.result_model.CallReconnectResult)2 JsonSyntaxException (com.google.gson.JsonSyntaxException)2 CameraUnavailableException (com.fanap.podcall.error.CameraUnavailableException)1 MicrophoneUnavailableException (com.fanap.podcall.error.MicrophoneUnavailableException)1 KafkaConfig (com.fanap.podcall.kafka.KafkaConfig)1 CallPartnerView (com.fanap.podcall.view.CallPartnerView)1 ICallState (com.fanap.podchat.call.audio_call.ICallState)1 CallParticipantVO (com.fanap.podchat.call.model.CallParticipantVO)1 CallClientErrorsRequest (com.fanap.podchat.call.request_model.CallClientErrorsRequest)1 ScreenShareResult (com.fanap.podchat.call.request_model.screen_share.ScreenShareResult)1 CallStartResult (com.fanap.podchat.call.result_model.CallStartResult)1 Participant (com.fanap.podchat.mainmodel.Participant)1 ChatResponse (com.fanap.podchat.model.ChatResponse)1 ArrayList (java.util.ArrayList)1