private void EVSdkWrapper_EventCallPeerConnected(ManagedEVSdk.Structs.EVCallInfoCli callInfo)
 {
     log.Info("EventCallPeerConnected");
     CallInfo                   = callInfo;
     ConferenceNumber           = callInfo.conference_number;
     CurrentContentStreamStatus = ContentStreamStatus.Idle;
     CurrentCallStatus          = CallStatus.Connected;
     log.Info("EventCallPeerConnected end");
 }
 private void EVSdkWrapper_EventCallConnected(ManagedEVSdk.Structs.EVCallInfoCli callInfo)
 {
     log.Info("EventCallConnected");
     CallInfo                   = callInfo;
     ConferenceNumber           = callInfo.conference_number;
     CurrentContentStreamStatus = ContentStreamStatus.Idle;
     if (ManagedEVSdk.Structs.EV_SVC_CALL_TYPE_CLI.EV_SVC_CALL_P2P == callInfo.svcCallType)
     {
         CurrentCallStatus = CallStatus.P2pOutgoing;
     }
     else
     {
         CurrentCallStatus = CallStatus.Connected;
     }
     log.Info("EventCallConnected end");
 }
        private void EVSdkWrapper_EventCallEnd(ManagedEVSdk.Structs.EVCallInfoCli callInfo)
        {
            log.Info("EventCallEnd.");
            if (
                null != callInfo.err &&
                callInfo.err.type == ManagedEVSdk.ErrorInfo.EV_ERROR_TYPE_CLI.EV_ERROR_TYPE_CALL &&
                callInfo.err.code == (int)ManagedEVSdk.ErrorInfo.EV_CALL_ERROR_CLI.EV_CALL_INVALID_PASSWORD
                )
            {
                log.Info("password empty!");
                App.Current.Dispatcher.InvokeAsync(() =>
                {
                    InputConfPasswordPromptDialog passwordDialog = new InputConfPasswordPromptDialog();
                    passwordDialog.Owner = VideoPeopleWindow.Instance;

                    bool?result = passwordDialog.ShowDialog();
                    if (null != result && result.Value)
                    {
                        if (JoinConfTypeEnum.Direct == _joinConfType)
                        {
                            //JoinConference(_conferenceServer, _conferencePort, ConferenceNumber, _conferenceDisplayName, passwordDialog.ConfPassword);
                        }
                        else if (JoinConfTypeEnum.Location == _joinConfType)
                        {
                            JoinConferenceWithLocation(_conferenceServer, _conferencePort, ConferenceNumber, _conferenceDisplayName, passwordDialog.ConfPassword);
                        }
                        else
                        {
                            JoinConference(ConferenceNumber, _conferenceDisplayName, passwordDialog.ConfPassword);
                        }
                    }
                    else
                    {
                        CurrentCallStatus = CallStatus.Ended;
                        if (LoginStatus.AnonymousLoggedIn == LoginManager.Instance.CurrentLoginStatus)
                        {
                            LoginManager.Instance.CurrentLoginStatus = LoginStatus.NotLogin;
                        }
                    }
                });
            }
            else
            {
                if (
                    LoginStatus.LoggedIn == LoginManager.Instance.CurrentLoginStatus &&
                    ManagedEVSdk.ErrorInfo.EV_ERROR_TYPE_CLI.EV_ERROR_TYPE_SDK == callInfo.err.type &&
                    ((int)ManagedEVSdk.ErrorInfo.EV_ERROR_CLI.EV_CALL_TIMEOUT == callInfo.err.code || (int)ManagedEVSdk.ErrorInfo.EV_ERROR_CLI.EV_CALL_DECLINED == callInfo.err.code)
                    )
                {
                    if ((int)ManagedEVSdk.ErrorInfo.EV_ERROR_CLI.EV_CALL_TIMEOUT == callInfo.err.code)
                    {
                        log.Info("EventCallEnd, error code is EV_CALL_TIMEOUT, set TimeoutSelfCancelled");
                        CurrentCallStatus = CallStatus.TimeoutSelfCancelled;
                    }
                    else if ((int)ManagedEVSdk.ErrorInfo.EV_ERROR_CLI.EV_CALL_DECLINED == callInfo.err.code)
                    {
                        log.Info("EventCallEnd, error code is EV_CALL_DECLINED, set PeerDeclined");
                        CurrentCallStatus = CallStatus.PeerDeclined;
                    }
                }
                else
                {
                    CurrentCallStatus = CallStatus.Ended;
                    if (LoginStatus.AnonymousLoggedIn == LoginManager.Instance.CurrentLoginStatus)
                    {
                        LoginManager.Instance.CurrentLoginStatus = LoginStatus.NotLogin;
                    }
                }
            }

            log.InfoFormat("EventCallEnd end.");
        }
        // incoming call: EventJoinConferenceIndication[P2pIncoming | ConfIncoming] -- {(JoinConference[Dialing] -- EventCallConnected[Connected]) or (DeclineIncommingCall[Idle]) or (EventJoinConferenceIndication[PeerCancelled]) or (EventJoinConferenceIndication[TimeoutSelfCancelled])}
        private void EVSdkWrapper_EventJoinConferenceIndication(ManagedEVSdk.Structs.EVCallInfoCli callInfo)
        {
            log.InfoFormat("EventJoinConferenceIndication, svcCallAction: {0}", callInfo.svcCallAction);

            if (
                CallStatus.Idle != CurrentCallStatus &&
                CallStatus.Ended != CurrentCallStatus &&
                CallStatus.P2pIncoming != CurrentCallStatus &&
                CallStatus.ConfIncoming != CurrentCallStatus
                )
            {
                log.InfoFormat("Received EventJoinConferenceIndication, but CurrentCallStatus is invalid: {0}", CurrentCallStatus);
                return;
            }

            CallInfo = callInfo;

            if (ManagedEVSdk.Structs.EV_SVC_CALL_ACTION_CLI.EV_SVC_INCOMING_CALL_RING == callInfo.svcCallAction)
            {
                if (ManagedEVSdk.Structs.EV_SVC_CALL_TYPE_CLI.EV_SVC_CALL_P2P == callInfo.svcCallType)
                {
                    log.Info("P2pIncoming, set IsP2pCall to true");
                    IsP2pCall = true;
                }

                if (Utils.GetAutoAnswer())
                {
                    log.Info("Auto answer the dial in conf, EventJoinConferenceIndication end");
                    JoinConference(CallInfo.conference_number, LoginManager.Instance.DisplayName, CallInfo.password, ManagedEVSdk.Structs.EV_SVC_CALL_TYPE_CLI.EV_SVC_CALL_CONF);
                    return;
                }

                if (ManagedEVSdk.Structs.EV_SVC_CALL_TYPE_CLI.EV_SVC_CALL_P2P == callInfo.svcCallType)
                {
                    CurrentCallStatus = CallStatus.P2pIncoming;
                }
                else
                {
                    CurrentCallStatus = CallStatus.ConfIncoming;
                }
            }
            else if (ManagedEVSdk.Structs.EV_SVC_CALL_ACTION_CLI.EV_SVC_INCOMING_CALL_CANCEL == callInfo.svcCallAction)
            {
                if (CallStatus.P2pIncoming == CurrentCallStatus || CallStatus.ConfIncoming == CurrentCallStatus)
                {
                    if (ManagedEVSdk.ErrorInfo.EV_ERROR_TYPE_CLI.EV_ERROR_TYPE_SDK == callInfo.err.type && (int)ManagedEVSdk.ErrorInfo.EV_ERROR_CLI.EV_CALL_TIMEOUT == callInfo.err.code)
                    {
                        log.Info("Call timeout, terminate the call");
                        CurrentCallStatus = CallStatus.TimeoutSelfCancelled;
                    }
                    else
                    {
                        CurrentCallStatus = CallStatus.PeerCancelled;
                    }
                }
                else
                {
                    log.InfoFormat("Recevied EV_SVC_INCOMING_CALL_CANCEL, but CurrentCallStatus is: {0}", CurrentCallStatus);
                }
            }
            else
            {
                log.Info("Received unhandling action");
            }

            log.Info("EventJoinConferenceIndication end");
        }