Search in sources :

Example 1 with ICallState

use of com.fanap.podchat.call.audio_call.ICallState 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)

Aggregations

PodCallBuilder (com.fanap.podcall.PodCallBuilder)1 CameraUnavailableException (com.fanap.podcall.error.CameraUnavailableException)1 MicrophoneUnavailableException (com.fanap.podcall.error.MicrophoneUnavailableException)1 KafkaConfig (com.fanap.podcall.kafka.KafkaConfig)1 CallPartner (com.fanap.podcall.model.CallPartner)1 ICallState (com.fanap.podchat.call.audio_call.ICallState)1 ClientDTO (com.fanap.podchat.call.model.ClientDTO)1 CallClientErrorsRequest (com.fanap.podchat.call.request_model.CallClientErrorsRequest)1 PodChatException (com.fanap.podchat.util.PodChatException)1