Beispiel #1
1
        public void CallState(LinphoneCall call, LinphoneCallState state, string message)
        {
            WriteLog("CallState: {0} | {1}", state, message);
            switch (state)
            {
            case LinphoneCallState.IncomingReceived:
                this.UIThreadInvoke(() => AcceptCall(call, message));
                break;

            case LinphoneCallState.OutgoingRinging:
                this.UIThreadInvoke(() => WriteLog("Ringing"));
                break;

            case LinphoneCallState.Connected:
                this.UIThreadInvoke(() => WriteLog("Talking"));
                this.UIThreadInvoke(() => this.btnCall.Text = "Hangup");
                break;

            case LinphoneCallState.CallEnd:
                this.UIThreadInvoke(() => WriteLog("Call ended"));
                this.UIThreadInvoke(() => this.btnCall.Text = "Call");
                break;

            default:
                break;
            }
        }
Beispiel #2
0
 /// <summary>
 /// Called when the call changes its state to paused or resumed.
 /// </summary>
 public void PauseStateChanged(LinphoneCall call, bool isCallPaused, bool isCallPausedByRemote)
 {
     if (this.PauseListener != null)
     {
         this.PauseListener.PauseStateChanged(call, isCallPaused, isCallPausedByRemote);
     }
 }
Beispiel #3
0
 /// <summary>
 /// Called when the call is updated by the remote party.
 /// </summary>
 /// <param name="call">The call that has been updated</param>
 /// <param name="isVideoAdded">A boolean telling whether the remote party added video</param>
 public void CallUpdatedByRemote(LinphoneCall call, bool isVideoAdded)
 {
     if (this.CallUpdatedByRemoteListener != null)
     {
         this.CallUpdatedByRemoteListener.CallUpdatedByRemote(call, isVideoAdded);
     }
 }
Beispiel #4
0
        /// <summary>
        /// Method called when the page is displayed.
        /// Searches for a matching contact using the current call address or number and display information if found.
        /// </summary>
        protected override void OnNavigatedTo(NavigationEventArgs nee)
        {
            base.OnNavigatedTo(nee);
            this.ViewModel.MuteListener  = this;
            this.ViewModel.PauseListener = this;
            this.ViewModel.CallUpdatedByRemoteListener = this;
            LinphoneManager.Instance.CallStateChanged += CallStateChanged;
            AudioRoutingManager.GetDefault().AudioEndpointChanged += AudioEndpointChanged;

            if (NavigationContext.QueryString.ContainsKey("sip"))
            {
                String          calledNumber = NavigationContext.QueryString["sip"];
                LinphoneAddress address      = LinphoneManager.Instance.LinphoneCore.InterpretURL(calledNumber);
                calledNumber = String.Format("{0}@{1}", address.UserName, address.Domain);
                // While we dunno if the number matches a contact one, we consider it won't and we display the phone number as username
                Contact.Text = calledNumber;

                if (calledNumber != null && calledNumber.Length > 0)
                {
                    ContactManager cm = ContactManager.Instance;
                    cm.ContactFound += cm_ContactFound;
                    cm.FindContact(calledNumber);
                }
            }

            ApplicationSettingsManager settings = new ApplicationSettingsManager();

            settings.Load();

            // Callback CallStateChanged set too late when call is incoming, so trigger it manually
            if (LinphoneManager.Instance.LinphoneCore.CallsNb > 0)
            {
                LinphoneCall call = (LinphoneCall)LinphoneManager.Instance.LinphoneCore.Calls[0];
                if (call.State == LinphoneCallState.StreamsRunning)
                {
                    CallStateChanged(call, LinphoneCallState.StreamsRunning);
                    if (settings.VideoActiveWhenGoingToBackground)
                    {
                        LinphoneManager.Instance.LinphoneCore.VideoPolicy.AutomaticallyAccept = settings.VideoAutoAcceptWhenGoingToBackground;
                        LinphoneCallParams callParams = call.GetCurrentParamsCopy();
                        callParams.VideoEnabled = true;
                        LinphoneManager.Instance.LinphoneCore.UpdateCall(call, callParams);
                    }
                }
                else if (call.State == LinphoneCallState.UpdatedByRemote)
                {
                    // The call was updated by the remote party while we were in background
                    LinphoneManager.Instance.CallState(call, call.State, "call updated while in background");
                }
            }

            settings.VideoActiveWhenGoingToBackground = false;
            settings.Save();

            oneSecondTimer          = new DispatcherTimer();
            oneSecondTimer.Interval = TimeSpan.FromSeconds(1);
            oneSecondTimer.Tick    += timerTick;
            oneSecondTimer.Start();
        }
 public void CallState(LinphoneCall call, LinphoneCallState state, string message)
 {
     WriteLog("CallState: {0} | {1}", state, message);
     if (state == LinphoneCallState.IncomingReceived)
     {
         this.Lc.AcceptCall(call);
     }
 }
Beispiel #6
0
 public void CallState(LinphoneCall call, LinphoneCallState state, string message)
 {
     Console.WriteLine("CallState: {0} | {1}", state, message);
     if (state == LinphoneCallState.IncomingReceived)
     {
         this.Lc.AcceptCall(call);
     }
 }
Beispiel #7
0
 /// <summary>
 /// Pauses the current call if any and if it's running.
 /// </summary>
 public void PauseCurrentCall()
 {
     if (LinphoneCore.CallsNb > 0)
     {
         LinphoneCall call = LinphoneCore.CurrentCall;
         LinphoneCore.PauseCall(call);
     }
 }
Beispiel #8
0
        public LinphoneCall GetCurrentCall()
        {
            LinphoneCall call = LinphoneManager.Instance.LinphoneCore.CurrentCall;

            if (call == null)
            {
                if (LinphoneManager.Instance.LinphoneCore.CallsNb > 0)
                {
                    call = (LinphoneCall)LinphoneManager.Instance.LinphoneCore.Calls[0];
                }
            }
            return(call);
        }
Beispiel #9
0
 /// <summary>
 /// Called when user rotates the device
 /// </summary>
 public void OrientationChanged(object sender, Microsoft.Phone.Controls.OrientationChangedEventArgs e)
 {
     PageOrientation = e.Orientation;
     Logger.Msg("[InCall] OrientationChanged");
     if (IsVideoActive)
     {
         HideVideo();
         ShowVideo();
         LinphoneCall call = GetCurrentCall();
         if (call != null)
         {
             call.SendVFURequest();
         }
     }
 }
Beispiel #10
0
        /// <summary>
        /// Called when a call is finished.
        /// Goes back to the last page if possible, else displays Dialer.xaml.
        /// </summary>
        public void CallEnded(LinphoneCall call)
        {
            Debug.WriteLine("[CallListener] Call ended, can go back ? " + this.Page.NavigationService.CanGoBack);

            if (this.Page.NavigationService.CanGoBack)
            {
                this.Page.NavigationService.GoBack();
            }
            else
            {
                // Launch the Dialer and remove the incall view from the backstack
                this.Page.NavigationService.Navigate(new Uri("/Views/Dialer.xaml", UriKind.RelativeOrAbsolute));
                this.Page.NavigationService.RemoveBackEntry();
            }
        }
Beispiel #11
0
        /// <summary>
        /// Called when the call changes its state to paused or resumed.
        /// </summary>
        public void PauseStateChanged(LinphoneCall call, bool isCallPaused, bool isCallPausedByRemote)
        {
            buttons.pause.IsChecked           = isCallPaused || isCallPausedByRemote;
            buttons_landscape.pause.IsChecked = isCallPaused || isCallPausedByRemote;
            buttons.pauseImg.Source           = new BitmapImage(new Uri(isCallPaused || isCallPausedByRemote ? pauseOn : pauseOff, UriKind.RelativeOrAbsolute));
            buttons_landscape.pauseImg.Source = new BitmapImage(new Uri(isCallPaused || isCallPausedByRemote ? pauseOn : pauseOff, UriKind.RelativeOrAbsolute));

            if (!isCallPaused && !isCallPausedByRemote)
            {
                if (call.GetCurrentParamsCopy().VideoEnabled&& !((InCallModel)ViewModel).IsVideoActive)
                {
                    // Show video if it was not shown yet
                    ((InCallModel)ViewModel).IsVideoActive = true;
                    buttons.video.IsChecked           = true;
                    buttons_landscape.video.IsChecked = true;
                    buttons.videoImg.Source           = new BitmapImage(new Uri(videoOn, UriKind.RelativeOrAbsolute));
                    buttons_landscape.videoImg.Source = new BitmapImage(new Uri(videoOn, UriKind.RelativeOrAbsolute));
                    ButtonsFadeInVideoAnimation.Begin();
                    StartFadeTimer();
                }
                else if (!call.GetCurrentParamsCopy().VideoEnabled&& ((InCallModel)ViewModel).IsVideoActive)
                {
                    // Stop video if it is no longer active
                    ((InCallModel)ViewModel).IsVideoActive = false;
                    buttons.video.IsChecked           = false;
                    buttons_landscape.video.IsChecked = false;
                    buttons.videoImg.Source           = new BitmapImage(new Uri(videoOff, UriKind.RelativeOrAbsolute));
                    buttons_landscape.videoImg.Source = new BitmapImage(new Uri(videoOff, UriKind.RelativeOrAbsolute));
                    ButtonsFadeInAudioAnimation.Begin();
                    StopFadeTimer();
                }
                if (((InCallModel)ViewModel).IsVideoActive)
                {
                    ButtonsFadeOutAnimation.Begin();
                }
            }
            else
            {
                ((InCallModel)ViewModel).IsVideoActive = false;
                ((InCallModel)ViewModel).ShowButtonsAndPanel();
                ButtonsFadeInAudioAnimation.Begin();
                StopFadeTimer();
            }
        }
Beispiel #12
0
        /// <summary>
        /// Stops the current call if any.
        /// </summary>
        public void EndCurrentCall()
        {
            LinphoneCall call = LinphoneCore.CurrentCall;

            if (call != null)
            {
                LinphoneCore.TerminateCall(call);
            }
            else
            {
                foreach (LinphoneCall lCall in LinphoneCore.Calls)
                {
                    if (lCall.State == LinphoneCallState.Paused)
                    {
                        LinphoneCore.TerminateCall(lCall);
                    }
                }
            }
        }
Beispiel #13
0
 /// <summary>
 /// Enables disables video.
 /// </summary>
 /// <param name="enable">Wether to enable or disable video</param>
 /// <returns>true if the operation has been successful, false otherwise</returns>
 public bool EnableVideo(bool enable)
 {
     if (LinphoneCore.InCall)
     {
         LinphoneCall       call       = LinphoneCore.CurrentCall;
         LinphoneCallParams parameters = call.GetCurrentParamsCopy();
         if (enable != parameters.VideoEnabled)
         {
             parameters.VideoEnabled = enable;
             if (enable)
             {
                 // TODO: Handle bandwidth limitation
             }
             LinphoneCore.UpdateCall(call, parameters);
             return(true);
         }
     }
     return(false);
 }
Beispiel #14
0
        public void TerminateCall(Call call)
        {
            if (call == null)
            {
                throw new ArgumentNullException("call");
            }

            if (linphoneCore == IntPtr.Zero || !running)
            {
                if (ErrorEvent != null)
                {
                    ErrorEvent(call, "Cannot make or receive calls when Linphone Core is not working.");
                }
                return;
            }

            LinphoneCall linphonecall = (LinphoneCall)call;

            linphone_core_terminate_call(linphoneCore, linphonecall.LinphoneCallPtr);
        }
Beispiel #15
0
        public void SendDTMFs(Call call, string dtmfs)
        {
            if (call == null)
            {
                throw new ArgumentNullException("call");
            }

            if (linphoneCore == IntPtr.Zero || !running)
            {
                if (ErrorEvent != null)
                {
                    ErrorEvent(call, "Cannot make or receive calls when Linphone Core is not working.");
                }
                return;
            }

            LinphoneCall linphonecall = (LinphoneCall)call;

            linphone_call_send_dtmfs(linphonecall.LinphoneCallPtr, dtmfs);
        }
Beispiel #16
0
 /// <summary>
 /// Toggles the camera used for video capture.
 /// </summary>
 public void ToggleCameras()
 {
     if (NumberOfCameras >= 2)
     {
         String currentDevice = LinphoneCore.VideoDevice;
         if (currentDevice == frontCamera)
         {
             LinphoneCore.VideoDevice = backCamera;
         }
         else if (currentDevice == backCamera)
         {
             LinphoneCore.VideoDevice = frontCamera;
         }
         if (LinphoneCore.InCall)
         {
             LinphoneCall call = LinphoneCore.CurrentCall;
             LinphoneCore.UpdateCall(call, null);
         }
     }
 }
Beispiel #17
0
        public void ReceiveCall(Call call)
        {
            if (call == null)
            {
                throw new ArgumentNullException("call");
            }

            if (linphoneCore == IntPtr.Zero || !running)
            {
                if (ErrorEvent != null)
                {
                    ErrorEvent(call, "Cannot receive call when Linphone Core is not working.");
                }
                return;
            }

            LinphoneCall linphonecall = (LinphoneCall)call;

            linphone_call_params_set_record_file(callsDefaultParams, null);
            linphone_core_accept_call_with_params(linphoneCore, linphonecall.LinphoneCallPtr, callsDefaultParams);
        }
Beispiel #18
0
        private void LookupForContact(LinphoneCall call)
        {
            try
            {
                LinphoneAddress remoteAddress = call.RemoteAddress;
                if (remoteAddress.DisplayName.Length == 0)
                {
                    string sipAddress = String.Format("{0}@{1}", remoteAddress.UserName, remoteAddress.Domain);
                    Logger.Msg("[LinphoneManager] Display name null, looking for remote address in contact: " + sipAddress + "\r\n");

                    ContactManager.ContactFound += OnContactFound;
                    ContactManager.FindContact(sipAddress);
                }
                else
                {
                    Logger.Msg("[LinphoneManager] Display name found: " + call.RemoteAddress.DisplayName + "\r\n");
                }
            }
            catch
            {
                Logger.Warn("[LinphoneManager] Exception occured while looking for contact...\r\n");
            }
        }
Beispiel #19
0
        /// <summary>
        /// Method called when the page is leaved.
        /// </summary>
        protected override void OnNavigatedFrom(NavigationEventArgs nee)
        {
            if (((InCallModel)ViewModel).IsVideoActive)
            {
                LinphoneCall call = null;
                try
                {
                    call = (LinphoneCall)LinphoneManager.Instance.LinphoneCore.Calls[0];
                }
                catch (System.ArgumentOutOfRangeException) { }
                if (call != null)
                {
                    ApplicationSettingsManager settings = new ApplicationSettingsManager();
                    settings.Load();
                    settings.VideoActiveWhenGoingToBackground     = true;
                    settings.VideoAutoAcceptWhenGoingToBackground = LinphoneManager.Instance.LinphoneCore.VideoPolicy.AutomaticallyAccept;
                    settings.Save();
                    LinphoneManager.Instance.LinphoneCore.VideoPolicy.AutomaticallyAccept = false;
                    LinphoneCallParams callParams = call.GetCurrentParamsCopy();
                    callParams.VideoEnabled = false;
                    LinphoneManager.Instance.LinphoneCore.UpdateCall(call, callParams);
                }
            }

            oneSecondTimer.Stop();
            if (fadeTimer != null)
            {
                fadeTimer.Dispose();
                fadeTimer = null;
            }

            base.OnNavigatedFrom(nee);
            this.ViewModel.MuteListener  = null;
            this.ViewModel.PauseListener = null;
            LinphoneManager.Instance.CallStateChanged -= CallStateChanged;
            AudioRoutingManager.GetDefault().AudioEndpointChanged -= AudioEndpointChanged;
        }
Beispiel #20
0
 /// <summary>
 /// Called when the call is updated by the remote party.
 /// </summary>
 /// <param name="call">The call that has been updated</param>
 /// <param name="isVideoAdded">A boolean telling whether the remote party added video</param>
 public void CallUpdatedByRemote(LinphoneCall call, bool isVideoAdded)
 {
     if (isVideoAdded)
     {
         Guide.BeginShowMessageBox(AppResources.VideoActivationPopupCaption,
                                   AppResources.VideoActivationPopupContent,
                                   new List <String> {
             "Accept", "Dismiss"
         },
                                   0,
                                   MessageBoxIcon.Alert,
                                   asyncResult =>
         {
             int?res = Guide.EndShowMessageBox(asyncResult);
             LinphoneCallParams parameters = call.GetCurrentParamsCopy();
             if (res == 0)
             {
                 parameters.VideoEnabled = true;
             }
             LinphoneManager.Instance.LinphoneCore.AcceptCallUpdate(call, parameters);
         },
                                   null);
     }
 }
Beispiel #21
0
 public void CallStatsUpdated(LinphoneCall call, LinphoneCallStats stats)
 {
     Console.WriteLine("CallStatsUpdated: U:{0} | D:{1}", stats.UploadBandwidth, stats.DownloadBandwidth);
 }
Beispiel #22
0
 public void DTMFReceived(LinphoneCall call, char dtmf)
 {
     Console.WriteLine("DTMFReceived");
 }
 public void CallStatsUpdated(LinphoneCall call, LinphoneCallStats stats)
 {
     WriteLog("CallStatsUpdated: U:{0} | D:{1}", stats.UploadBandwidth, stats.DownloadBandwidth);
 }
Beispiel #24
0
 public void CallState(LinphoneCall call, LinphoneCallState state, string message)
 {
     WriteLog("CallState: {0} | {1}", state, message);
     switch (state)
     {
         case LinphoneCallState.IncomingReceived:
             this.UIThreadInvoke(() => AcceptCall(call, message));
             break;
         case LinphoneCallState.OutgoingRinging:
             this.UIThreadInvoke(() => WriteLog("Ringing"));
             break;
         case LinphoneCallState.Connected:                    
             this.UIThreadInvoke(() => WriteLog("Talking"));
             this.UIThreadInvoke(() => this.btnCall.Text = "Hangup");
             break;
         case LinphoneCallState.CallEnd:
             this.UIThreadInvoke(() => WriteLog("Call ended"));
             this.UIThreadInvoke(() => this.btnCall.Text = "Call" );
             break;
         default:
             break;
     }
 }
        /// <summary>
        /// Called when the call changes its state to paused or resumed.
        /// </summary>
        public void PauseStateChanged(LinphoneCall call, bool isCallPaused, bool isCallPausedByRemote)
        {
            buttons.pause.IsChecked = isCallPaused || isCallPausedByRemote;
            buttons_landscape.pause.IsChecked = isCallPaused || isCallPausedByRemote;
            buttons.pauseImg.Source = new BitmapImage(new Uri(isCallPaused || isCallPausedByRemote ? pauseOn : pauseOff, UriKind.RelativeOrAbsolute));
            buttons_landscape.pauseImg.Source = new BitmapImage(new Uri(isCallPaused || isCallPausedByRemote ? pauseOn : pauseOff, UriKind.RelativeOrAbsolute));

            if (!isCallPaused && !isCallPausedByRemote)
            {
                if (call.GetCurrentParamsCopy().VideoEnabled && !((InCallModel)ViewModel).IsVideoActive)
                {
                    // Show video if it was not shown yet
                    ((InCallModel)ViewModel).IsVideoActive = true;
                    buttons.video.IsChecked = true;
                    buttons_landscape.video.IsChecked = true;
                    buttons.videoImg.Source = new BitmapImage(new Uri(videoOn, UriKind.RelativeOrAbsolute));
                    buttons_landscape.videoImg.Source = new BitmapImage(new Uri(videoOn, UriKind.RelativeOrAbsolute));
                    ButtonsFadeInVideoAnimation.Begin();
                    StartFadeTimer();
                }
                else if (!call.GetCurrentParamsCopy().VideoEnabled && ((InCallModel)ViewModel).IsVideoActive)
                {
                    // Stop video if it is no longer active
                    ((InCallModel)ViewModel).IsVideoActive = false;
                    buttons.video.IsChecked = false;
                    buttons_landscape.video.IsChecked = false;
                    buttons.videoImg.Source = new BitmapImage(new Uri(videoOff, UriKind.RelativeOrAbsolute));
                    buttons_landscape.videoImg.Source = new BitmapImage(new Uri(videoOff, UriKind.RelativeOrAbsolute));
                    ButtonsFadeInAudioAnimation.Begin();
                    StopFadeTimer();
                }
                if (((InCallModel)ViewModel).IsVideoActive)
                {
                    ButtonsFadeOutAnimation.Begin();
                }
            }
            else
            {
                ((InCallModel)ViewModel).IsVideoActive = false;
                ((InCallModel)ViewModel).ShowButtonsAndPanel();
                ButtonsFadeInAudioAnimation.Begin();
                StopFadeTimer();
            }
        }
Beispiel #26
0
        void OnCallStateChanged(IntPtr lc, IntPtr call, LinphoneCallState cstate, string message)
        {
            if (linphoneCore == IntPtr.Zero || !running) return;
            #if (TRACE)
            Console.WriteLine("OnCallStateChanged: {0}", cstate);
            #endif

            Call.CallState newstate = Call.CallState.None;
            Call.CallType newtype = Call.CallType.None;
            string from = "";
            string to = "";
            IntPtr addressStringPtr;

            // detecting direction, state and source-destination data by state
            switch (cstate) {
                case LinphoneCallState.LinphoneCallIncomingReceived:
                case LinphoneCallState.LinphoneCallIncomingEarlyMedia:
                    newstate = Call.CallState.Loading;
                    newtype = Call.CallType.Incoming;
                    addressStringPtr = linphone_call_get_remote_address_as_string(call);
                    if (addressStringPtr != IntPtr.Zero) from = Marshal.PtrToStringAnsi(addressStringPtr);
                    to = identity;
                    break;

                case LinphoneCallState.LinphoneCallConnected:
                case LinphoneCallState.LinphoneCallStreamsRunning:
                case LinphoneCallState.LinphoneCallPausedByRemote:
                case LinphoneCallState.LinphoneCallUpdatedByRemote:
                    newstate = Call.CallState.Active;
                    break;

                case LinphoneCallState.LinphoneCallOutgoingInit:
                case LinphoneCallState.LinphoneCallOutgoingProgress:
                case LinphoneCallState.LinphoneCallOutgoingRinging:
                case LinphoneCallState.LinphoneCallOutgoingEarlyMedia:
                    newstate = Call.CallState.Loading;
                    newtype = Call.CallType.Outcoming;
                    addressStringPtr = linphone_call_get_remote_address_as_string(call);
                    if (addressStringPtr != IntPtr.Zero) to = Marshal.PtrToStringAnsi(addressStringPtr);
                    from = this.identity;
                    break;

                case LinphoneCallState.LinphoneCallError:
                    newstate = Call.CallState.Error;
                    break;

                case LinphoneCallState.LinphoneCallReleased:
                case LinphoneCallState.LinphoneCallEnd:
                    newstate = Call.CallState.Completed;
                    if (linphone_call_params_get_record_file (callsDefaultParams) != IntPtr.Zero)
                        linphone_call_stop_recording (call);
                    break;

                default:
                    break;
            }

            LinphoneCall existCall = FindCall (call);

            if (existCall == null) {
                existCall = new LinphoneCall ();
                existCall.SetCallState (newstate);
                existCall.SetCallType (newtype);
                existCall.SetFrom (from);
                existCall.SetTo (to);
                existCall.LinphoneCallPtr = call;

                calls.Add (existCall);

                if ((CallStateChangedEvent != null))
                    CallStateChangedEvent (existCall);
            } else {
                if (existCall.GetState () != newstate) {
                    existCall.SetCallState (newstate);
                    CallStateChangedEvent (existCall);
                }
            }
        }
 /// <summary>
 /// Called when the call is updated by the remote party.
 /// </summary>
 /// <param name="call">The call that has been updated</param>
 /// <param name="isVideoAdded">A boolean telling whether the remote party added video</param>
 public void CallUpdatedByRemote(LinphoneCall call, bool isVideoAdded)
 {
     if (this.CallUpdatedByRemoteListener != null)
         this.CallUpdatedByRemoteListener.CallUpdatedByRemote(call, isVideoAdded);
 }
Beispiel #28
0
 private void AcceptCall(LinphoneCall call, string message)
 {
     this.lc.AcceptCall(call);
 }
        /// <summary>
        /// Called when a call is finished.
        /// Goes back to the last page if possible, else displays Dialer.xaml.
        /// </summary>
        public void CallEnded(LinphoneCall call)
        {
            Debug.WriteLine("[CallListener] Call ended, can go back ? " + this.Page.NavigationService.CanGoBack);

            if (this.Page.NavigationService.CanGoBack)
            {
                this.Page.NavigationService.GoBack();
            }
            else
            {
                // Launch the Dialer and remove the incall view from the backstack
                this.Page.NavigationService.Navigate(new Uri("/Views/Dialer.xaml", UriKind.RelativeOrAbsolute));
                this.Page.NavigationService.RemoveBackEntry();
            }
        }
 /// <summary>
 /// Called when the call changes its state to paused or resumed.
 /// </summary>
 public void PauseStateChanged(LinphoneCall call, bool isCallPaused, bool isCallPausedByRemote)
 {
     if (this.PauseListener != null)
         this.PauseListener.PauseStateChanged(call, isCallPaused, isCallPausedByRemote);
 }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="call"></param>
        /// <param name="state"></param>
        public void CallStateChanged(LinphoneCall call, LinphoneCallState state)
        {
            Logger.Dbg("[InCall] Call state changed: " + state.ToString());
            if (state == LinphoneCallState.StreamsRunning || state == LinphoneCallState.Connected)
            {
                buttons.pause.IsEnabled = true;
                buttons.microphone.IsEnabled = true;
                buttons_landscape.pause.IsEnabled = true;
                buttons_landscape.microphone.IsEnabled = true;
                buttons.pauseImg.Opacity = BUTTON_ENABLED_OPACITY;
                buttons.microImg.Opacity = BUTTON_ENABLED_OPACITY;
                buttons_landscape.pauseImg.Opacity = BUTTON_ENABLED_OPACITY;
                buttons_landscape.microImg.Opacity = BUTTON_ENABLED_OPACITY;

                bool isVideoAvailable = LinphoneManager.Instance.IsVideoAvailable;
                buttons.video.IsEnabled = isVideoAvailable;
                buttons_landscape.video.IsEnabled = isVideoAvailable;
                buttons.videoImg.Opacity = isVideoAvailable ? BUTTON_ENABLED_OPACITY : BUTTON_DISABLED_OPACITY;
                buttons_landscape.videoImg.Opacity = isVideoAvailable ? BUTTON_ENABLED_OPACITY : BUTTON_DISABLED_OPACITY;
                buttons.camera.IsEnabled = isVideoAvailable;
                buttons_landscape.camera.IsEnabled = isVideoAvailable;
                buttons.cameraImg.Opacity = isVideoAvailable ? BUTTON_ENABLED_OPACITY : BUTTON_DISABLED_OPACITY;
                buttons_landscape.cameraImg.Opacity = isVideoAvailable ? BUTTON_ENABLED_OPACITY : BUTTON_DISABLED_OPACITY;

                bool isVideoEnabled = call.GetCurrentParamsCopy().VideoEnabled;
                buttons.video.IsChecked = isVideoEnabled;
                buttons_landscape.video.IsChecked = isVideoEnabled;
            }
            else if (state == LinphoneCallState.PausedByRemote)
            {
                buttons.pause.IsEnabled = false;
                buttons.microphone.IsEnabled = false;
                buttons.video.IsEnabled = false;
                buttons.camera.IsEnabled = false;
                buttons.pauseImg.Opacity = BUTTON_DISABLED_OPACITY;
                buttons.microImg.Opacity = BUTTON_DISABLED_OPACITY;
                buttons.videoImg.Opacity = BUTTON_DISABLED_OPACITY;
                buttons.cameraImg.Opacity = BUTTON_DISABLED_OPACITY;
                buttons_landscape.pause.IsEnabled = false;
                buttons_landscape.microphone.IsEnabled = false;
                buttons_landscape.video.IsEnabled = false;
                buttons_landscape.camera.IsEnabled = false;
                buttons_landscape.pauseImg.Opacity = BUTTON_DISABLED_OPACITY;
                buttons_landscape.microImg.Opacity = BUTTON_DISABLED_OPACITY;
                buttons_landscape.videoImg.Opacity = BUTTON_DISABLED_OPACITY;
                buttons_landscape.cameraImg.Opacity = BUTTON_DISABLED_OPACITY;
            }
            else if (state == LinphoneCallState.Paused)
            {
                buttons.microphone.IsEnabled = false;
                buttons.video.IsEnabled = false;
                buttons.camera.IsEnabled = false;
                buttons.microImg.Opacity = BUTTON_DISABLED_OPACITY;
                buttons.videoImg.Opacity = BUTTON_DISABLED_OPACITY;
                buttons.cameraImg.Opacity = BUTTON_DISABLED_OPACITY;
                buttons_landscape.microphone.IsEnabled = false;
                buttons_landscape.video.IsEnabled = false;
                buttons_landscape.camera.IsEnabled = false;
                buttons_landscape.microImg.Opacity = BUTTON_DISABLED_OPACITY;
                buttons_landscape.videoImg.Opacity = BUTTON_DISABLED_OPACITY;
                buttons_landscape.cameraImg.Opacity = BUTTON_DISABLED_OPACITY;
            }
            else if (state == LinphoneCallState.Error || state == LinphoneCallState.CallEnd)
            {
                oneSecondTimer.Stop();
            }

            AudioEndpointChanged(null, null);
        }
 public void DTMFReceived(LinphoneCall call, char dtmf)
 {
     Console.WriteLine("DTMFReceived");
 }
        private void LookupForContact(LinphoneCall call)
        {
            try
            {
                LinphoneAddress remoteAddress = call.RemoteAddress;
                if (remoteAddress.DisplayName.Length == 0)
                {
                    string sipAddress = String.Format("{0}@{1}", remoteAddress.UserName, remoteAddress.Domain);
                    Logger.Msg("[LinphoneManager] Display name null, looking for remote address in contact: " + sipAddress + "\r\n");

                    ContactManager.ContactFound += OnContactFound;
                    ContactManager.FindContact(sipAddress);
                }
                else
                {
                    Logger.Msg("[LinphoneManager] Display name found: " + call.RemoteAddress.DisplayName + "\r\n");
                }
            }
            catch 
            {
                Logger.Warn("[LinphoneManager] Exception occured while looking for contact...\r\n");
            }
        }
 public void CallEncryptionChanged(LinphoneCall call, bool encrypted, string authenticationToken)
 {
     WriteLog("CallEncryptionChanged");
 }
Beispiel #35
0
        /// <summary>
        /// Callback for LinphoneCoreListener
        /// </summary>
        public void CallState(LinphoneCall call, LinphoneCallState state, string message)
        {
            if (BaseModel.UIDispatcher == null)
            {
                return;
            }
            if (state == LinphoneCallState.OutgoingProgress)
            {
                BaseModel.UIDispatcher.BeginInvoke(() =>
                {
                    Logger.Msg("[LinphoneManager] Outgoing progress\r\n");
                    LookupForContact(call);

                    if (CallListener != null && LinphoneCore.CallsNb > 0)
                    {
                        string sipAddress = call.RemoteAddress.AsStringUriOnly();
                        CallListener.NewCallStarted(sipAddress);
                    }
                });
            }
            else if (state == LinphoneCallState.IncomingReceived)
            {
                BaseModel.UIDispatcher.BeginInvoke(() =>
                {
                    Logger.Msg("[LinphoneManager] Incoming received\r\n");
                    if (false) //TODO: Find a proper way to let the user choose between the two.
                    {
                        BaseModel.CurrentPage.NavigationService.Navigate(new Uri("/Views/IncomingCall.xaml?sip=" + Utils.ReplacePlusInUri(call.RemoteAddress.AsStringUriOnly()), UriKind.RelativeOrAbsolute));
                        //Remove the current page from the back stack to avoid duplicating him after
                        BaseModel.CurrentPage.NavigationService.RemoveBackEntry();
                    }

                    LookupForContact(call);
                });
            }
            else if (state == LinphoneCallState.Connected)
            {
                BaseModel.UIDispatcher.BeginInvoke(() =>
                {
                    Logger.Msg("[LinphoneManager] Connected\r\n");
                    if (CallListener != null)
                    {
                        string sipAddress = call.RemoteAddress.AsStringUriOnly();
                        CallListener.NewCallStarted(sipAddress);
                    }
                });
            }
            else if (state == LinphoneCallState.CallEnd || state == LinphoneCallState.Error)
            {
                BaseModel.UIDispatcher.BeginInvoke(() =>
                {
                    Logger.Msg(String.Format("[LinphoneManager] Call ended: {0}\r\n", message));
                    if (CallListener != null)
                    {
                        CallListener.CallEnded(call);
                    }
                    string text;
                    switch (call.Reason)
                    {
                    case Reason.LinphoneReasonNone:
                    case Reason.LinphoneReasonNotAnswered:
                        break;

                    case Reason.LinphoneReasonDeclined:
                        if (call.Direction == CallDirection.Outgoing)
                        {
                            text = ResourceManager.GetString("CallErrorDeclined", CultureInfo.CurrentCulture);
                            ShowCallError(text.Replace("#address#", call.RemoteAddress.UserName));
                        }
                        break;

                    case Reason.LinphoneReasonNotFound:
                        text = ResourceManager.GetString("CallErrorNotFound", CultureInfo.CurrentCulture);
                        ShowCallError(text.Replace("#address#", call.RemoteAddress.UserName));
                        break;

                    case Reason.LinphoneReasonBusy:
                        text = ResourceManager.GetString("CallErrorBusy", CultureInfo.CurrentCulture);
                        ShowCallError(text.Replace("#address#", call.RemoteAddress.UserName));
                        break;

                    case Reason.LinphoneReasonNotAcceptable:
                        ShowCallError(ResourceManager.GetString("CallErrorNotAcceptable", CultureInfo.CurrentCulture));
                        break;

                    case Reason.LinphoneReasonIOError:
                        ShowCallError(ResourceManager.GetString("CallErrorIOError", CultureInfo.CurrentCulture));
                        break;

                    default:
                        ShowCallError(ResourceManager.GetString("CallErrorUnknown", CultureInfo.CurrentCulture));
                        break;
                    }
                });
            }
            else if (state == LinphoneCallState.Paused || state == LinphoneCallState.PausedByRemote)
            {
                BaseModel.UIDispatcher.BeginInvoke(() =>
                {
                    Logger.Msg("[LinphoneManager] Call paused\r\n");
                    bool pausedByRemote = state == LinphoneCallState.PausedByRemote;
                    if (CallListener != null)
                    {
                        CallListener.PauseStateChanged(call, !pausedByRemote, pausedByRemote);
                    }
                });
            }
            else if (state == LinphoneCallState.StreamsRunning)
            {
                BaseModel.UIDispatcher.BeginInvoke(() =>
                {
                    Logger.Msg("[LinphoneManager] Call running\r\n");
                    if (CallListener != null)
                    {
                        CallListener.PauseStateChanged(call, false, false);
                    }
                });
            }
            else if (state == LinphoneCallState.Released)
            {
                BaseModel.UIDispatcher.BeginInvoke(() =>
                {
                    Logger.Msg("[LinphoneManager] Call released\r\n");
                });
            }
            else if (state == LinphoneCallState.UpdatedByRemote)
            {
                BaseModel.UIDispatcher.BeginInvoke(() =>
                {
                    Boolean videoAdded = false;
                    VideoPolicy policy = LinphoneManager.Instance.LinphoneCore.VideoPolicy;
                    LinphoneCallParams remoteParams = call.RemoteParams;
                    LinphoneCallParams localParams  = call.GetCurrentParamsCopy();
                    if (remoteParams.VideoEnabled && !localParams.VideoEnabled && !LinphoneManager.Instance.LinphoneCore.InConference)
                    {
                        if (policy.AutomaticallyAccept)
                        {
                            localParams.VideoEnabled = true;
                            LinphoneManager.Instance.LinphoneCore.AcceptCallUpdate(call, localParams);
                        }
                        else
                        {
                            videoAdded = true;
                        }
                    }
                    else
                    {
                        LinphoneManager.Instance.LinphoneCore.AcceptCallUpdate(call, localParams);
                    }

                    if (CallListener != null)
                    {
                        CallListener.CallUpdatedByRemote(call, videoAdded);
                    }
                });
            }

            BaseModel.UIDispatcher.BeginInvoke(() =>
            {
                if (CallStateChanged != null)
                {
                    CallStateChanged(call, state);
                }
            });
        }
Beispiel #36
0
 /// <summary>
 /// Start a new call to a sip address.
 /// </summary>
 /// <param name="sipAddress">SIP address to call</param>
 public void NewOutgoingCall(String sipAddress)
 {
     LinphoneCall LCall = LinphoneCore.Invite(sipAddress);
 }
 /// <summary>
 /// Callback for LinphoneCoreListener
 /// </summary>
 public void DTMFReceived(LinphoneCall call, Char dtmf)
 {
 }
 /// <summary>
 /// Called when the call is updated by the remote party.
 /// </summary>
 /// <param name="call">The call that has been updated</param>
 /// <param name="isVideoAdded">A boolean telling whether the remote party added video</param>
 public void CallUpdatedByRemote(LinphoneCall call, bool isVideoAdded)
 {
     if (isVideoAdded)
     {
         Guide.BeginShowMessageBox(AppResources.VideoActivationPopupCaption,
             AppResources.VideoActivationPopupContent,
             new List<String> { "Accept", "Dismiss" },
             0,
             MessageBoxIcon.Alert,
             asyncResult =>
             {
                 int? res = Guide.EndShowMessageBox(asyncResult);
                 LinphoneCallParams parameters = call.GetCurrentParamsCopy();
                 if (res == 0)
                 {
                     parameters.VideoEnabled = true;
                 }
                 LinphoneManager.Instance.LinphoneCore.AcceptCallUpdate(call, parameters);
             },
             null);
     }
 }
 /// <summary>
 /// Callback for LinphoneCoreListener
 /// </summary>
 public void CallStatsUpdated(LinphoneCall call, LinphoneCallStats stats)
 {
 }
Beispiel #40
0
        // TODO: Add OnCallStateChanged and OnChatMessageStateChanged.
        void OnCallStateChanged(IntPtr lc, IntPtr call, LinphoneCallState cstate, string message)
        {
            if (linphoneCore == IntPtr.Zero || !running)
            {
                return;
            }
            #if (TRACE)
            Console.WriteLine("OnCallStateChanged: {0}", cstate);
            #endif

            Call.State    newstate  = Call.State.Idle;
            Call.CallType newtype   = Call.CallType.None;
            string        from      = "";
            string        to        = "";
            string        peer_name = nameFromAddress(linphone_call_get_remote_address(call));
            IntPtr        addressStringPtr;

            // detecting direction, state and source-destination data by state
            switch (cstate)
            {
            case LinphoneCallState.LinphoneCallIncomingReceived:
                newstate         = Call.State.IncomingRinging;
                newtype          = Call.CallType.Incoming;
                addressStringPtr = linphone_call_get_remote_address_as_string(call);
                if (addressStringPtr != IntPtr.Zero)
                {
                    from = Marshal.PtrToStringAnsi(addressStringPtr);
                    to   = this.identity;
                }
                break;

            case LinphoneCallState.LinphoneCallIncomingEarlyMedia:
                newstate         = Call.State.IncomingEarlyMedia;
                newtype          = Call.CallType.Incoming;
                addressStringPtr = linphone_call_get_remote_address_as_string(call);
                if (addressStringPtr != IntPtr.Zero)
                {
                    from = Marshal.PtrToStringAnsi(addressStringPtr);
                    to   = this.identity;
                }
                break;

            case LinphoneCallState.LinphoneCallConnected:
                newstate = Call.State.Connected;
                break;

            case LinphoneCallState.LinphoneCallStreamsRunning:
                newstate = Call.State.StreamsRunning;
                break;

            case LinphoneCallState.LinphoneCallPausedByRemote:
                newstate = Call.State.PausedByRemote;
                break;

            case LinphoneCallState.LinphoneCallUpdatedByRemote:
                newstate = Call.State.UpdatedByRemote;
                break;

            case LinphoneCallState.LinphoneCallOutgoingInit:
                newstate         = Call.State.OutgoingStart;
                addressStringPtr = linphone_call_get_remote_address_as_string(call);
                if (addressStringPtr != IntPtr.Zero)
                {
                    from = this.identity;
                    to   = Marshal.PtrToStringAnsi(addressStringPtr);
                }
                break;

            case LinphoneCallState.LinphoneCallOutgoingProgress:
                newstate = Call.State.InProgress;
                break;

            case LinphoneCallState.LinphoneCallOutgoingRinging:
                newstate = Call.State.OutgoingRinging;
                break;

            case LinphoneCallState.LinphoneCallOutgoingEarlyMedia:
                newstate         = Call.State.OutgoingEarlyMedia;
                newtype          = Call.CallType.Outcoming;
                addressStringPtr = linphone_call_get_remote_address_as_string(call);
                if (addressStringPtr != IntPtr.Zero)
                {
                    from = this.identity;
                    to   = Marshal.PtrToStringAnsi(addressStringPtr);
                }
                break;

            case LinphoneCallState.LinphoneCallError:
                newstate = Call.State.Error;
                break;

            case LinphoneCallState.LinphoneCallReleased:
                newstate = Call.State.Released;

                break;

            case LinphoneCallState.LinphoneCallEnd:
                newstate = Call.State.Ended;
                //hangupCall(call);
                if (linphone_call_params_get_record_file(calls_default_params) != IntPtr.Zero)
                {
                    linphone_call_stop_recording(call);
                }
                break;

            default:
                break;
            }

            //Change the calls state or create a new call if it doesn't exist yet
            LinphoneCall existCall = FindCall(call);
            if (existCall == null)
            {
                existCall           = new LinphoneCall();
                existCall.state     = newstate;
                existCall.call_type = newtype;
                existCall.from      = from;
                existCall.to        = to;
                existCall.ptr       = call;
                existCall.peer_name = peer_name;

                calls.Add(existCall);

                if ((CallStateChangedEvent != null))
                {
                    CallStateChangedEvent(existCall);
                }
            }
            else
            {
                if (existCall.state != newstate)
                {
                    existCall.state = newstate;
                    CallStateChangedEvent(existCall);
                }
            }
        }
        /// <summary>
        /// Callback for LinphoneCoreListener
        /// </summary>
        public void CallState(LinphoneCall call, LinphoneCallState state, string message)
        {
            if (BaseModel.UIDispatcher == null) return;
            if (state == LinphoneCallState.OutgoingProgress)
            {
                BaseModel.UIDispatcher.BeginInvoke(() =>
                {
                    Logger.Msg("[LinphoneManager] Outgoing progress\r\n");
                    LookupForContact(call);

                    if (CallListener != null && LinphoneCore.CallsNb > 0)
                    {
                        string sipAddress = call.RemoteAddress.AsStringUriOnly();
                        CallListener.NewCallStarted(sipAddress);
                    }
                });
            }
            else if (state == LinphoneCallState.IncomingReceived)
            {
                BaseModel.UIDispatcher.BeginInvoke(() =>
                {
                    Logger.Msg("[LinphoneManager] Incoming received\r\n"); 
                    if (false) //TODO: Find a proper way to let the user choose between the two.
                    {
                        BaseModel.CurrentPage.NavigationService.Navigate(new Uri("/Views/IncomingCall.xaml?sip=" + Utils.ReplacePlusInUri(call.RemoteAddress.AsStringUriOnly()), UriKind.RelativeOrAbsolute));
                        //Remove the current page from the back stack to avoid duplicating him after
                        BaseModel.CurrentPage.NavigationService.RemoveBackEntry();
                    }

                    LookupForContact(call);
                });
            }
            else if (state == LinphoneCallState.Connected)
            {
                BaseModel.UIDispatcher.BeginInvoke(() =>
                {
                    Logger.Msg("[LinphoneManager] Connected\r\n");
                    if (CallListener != null)
                    {
                        string sipAddress = call.RemoteAddress.AsStringUriOnly();
                        CallListener.NewCallStarted(sipAddress);
                    }
                });
            }
            else if (state == LinphoneCallState.CallEnd || state == LinphoneCallState.Error)
            {
                BaseModel.UIDispatcher.BeginInvoke(() =>
                {
                    Logger.Msg(String.Format("[LinphoneManager] Call ended: {0}\r\n", message));
                    if (CallListener != null)
                        CallListener.CallEnded(call);
                    string text;
                    switch (call.Reason)
                    {
                        case Reason.LinphoneReasonNone:
                        case Reason.LinphoneReasonNotAnswered:
                            break;
                        case Reason.LinphoneReasonDeclined:
                            if (call.Direction == CallDirection.Outgoing)
                            {
                                text = ResourceManager.GetString("CallErrorDeclined", CultureInfo.CurrentCulture);
                                ShowCallError(text.Replace("#address#", call.RemoteAddress.UserName));
                            }
                            break;
                        case Reason.LinphoneReasonNotFound:
                            text = ResourceManager.GetString("CallErrorNotFound", CultureInfo.CurrentCulture);
                            ShowCallError(text.Replace("#address#", call.RemoteAddress.UserName));
                            break;
                        case Reason.LinphoneReasonBusy:
                            text = ResourceManager.GetString("CallErrorBusy", CultureInfo.CurrentCulture);
                            ShowCallError(text.Replace("#address#", call.RemoteAddress.UserName));
                            break;
                        case Reason.LinphoneReasonNotAcceptable:
                            ShowCallError(ResourceManager.GetString("CallErrorNotAcceptable", CultureInfo.CurrentCulture));
                            break;
                        case Reason.LinphoneReasonIOError:
                            ShowCallError(ResourceManager.GetString("CallErrorIOError", CultureInfo.CurrentCulture));
                            break;
                        default:
                            ShowCallError(ResourceManager.GetString("CallErrorUnknown", CultureInfo.CurrentCulture));
                            break;
                    }
                });
            }
            else if (state == LinphoneCallState.Paused || state == LinphoneCallState.PausedByRemote)
            {
                BaseModel.UIDispatcher.BeginInvoke(() =>
                {
                    Logger.Msg("[LinphoneManager] Call paused\r\n");
                    bool pausedByRemote = state == LinphoneCallState.PausedByRemote;
                    if (CallListener != null)
                        CallListener.PauseStateChanged(call, !pausedByRemote, pausedByRemote);
                });
            }
            else if (state == LinphoneCallState.StreamsRunning)
            {
                BaseModel.UIDispatcher.BeginInvoke(() =>
                {
                    Logger.Msg("[LinphoneManager] Call running\r\n");
                    if (CallListener != null)
                        CallListener.PauseStateChanged(call, false, false);
                });
            }
            else if (state == LinphoneCallState.Released)
            {
                BaseModel.UIDispatcher.BeginInvoke(() =>
                {
                    Logger.Msg("[LinphoneManager] Call released\r\n");
                });
            }
            else if (state == LinphoneCallState.UpdatedByRemote)
            {
                BaseModel.UIDispatcher.BeginInvoke(() =>
                {
                    Boolean videoAdded = false;
                    VideoPolicy policy = LinphoneManager.Instance.LinphoneCore.VideoPolicy;
                    LinphoneCallParams remoteParams = call.RemoteParams;
                    LinphoneCallParams localParams = call.GetCurrentParamsCopy();
                    if (remoteParams.VideoEnabled && !localParams.VideoEnabled && !LinphoneManager.Instance.LinphoneCore.InConference)
                    {
                        if (policy.AutomaticallyAccept)
                        {
                            localParams.VideoEnabled = true;
                            LinphoneManager.Instance.LinphoneCore.AcceptCallUpdate(call, localParams);
                        }
                        else
                        {
                            videoAdded = true;
                        }
                    }
                    else
                    {
                        LinphoneManager.Instance.LinphoneCore.AcceptCallUpdate(call, localParams);
                    }

                    if (CallListener != null)
                        CallListener.CallUpdatedByRemote(call, videoAdded);
                });
            }

            BaseModel.UIDispatcher.BeginInvoke(() =>
            {
                if (CallStateChanged != null)
                {
                    CallStateChanged(call, state);
                }
            });
        }
 /// <summary>
 /// Callback for LinphoneCoreListener
 /// </summary>
 public void CallState(LinphoneCall call, LinphoneCallState state, string message)
 {
 }
        /// <summary>
        /// Callback for LinphoneCoreListener
        /// </summary>
        public void CallStatsUpdated(LinphoneCall call, LinphoneCallStats stats)
        {

        }
 /// <summary>
 /// Callback for LinphoneCoreListener
 /// </summary>
 public void CallEncryptionChanged(LinphoneCall call, bool encrypted, string authenticationToken)
 {
 }
        /// <summary>
        /// Callback for LinphoneCoreListener
        /// </summary>
        public void DTMFReceived(LinphoneCall call, Char dtmf)
        {

        }
Beispiel #46
0
 public void CallEncryptionChanged(LinphoneCall call, bool encrypted, string authenticationToken)
 {
     Console.WriteLine("CallEncryptionChanged");
 }
 public void DTMFReceived(LinphoneCall call, char dtmf)
 {
     WriteLog("DTMFReceived");
 }
Beispiel #48
0
        void OnCallStateChanged(IntPtr lc, IntPtr call, LinphoneCallState cstate, string message)
        {
            if (linphoneCore == IntPtr.Zero || !running)
            {
                return;
            }
            #if (TRACE)
            Console.WriteLine("OnCallStateChanged: {0}", cstate);
            #endif

            Call.CallState newstate = Call.CallState.None;
            Call.CallType  newtype  = Call.CallType.None;
            string         from     = "";
            string         to       = "";
            IntPtr         addressStringPtr;

            // detecting direction, state and source-destination data by state
            switch (cstate)
            {
            case LinphoneCallState.LinphoneCallIncomingReceived:
            case LinphoneCallState.LinphoneCallIncomingEarlyMedia:
                newstate         = Call.CallState.Loading;
                newtype          = Call.CallType.Incoming;
                addressStringPtr = linphone_call_get_remote_address_as_string(call);
                if (addressStringPtr != IntPtr.Zero)
                {
                    from = Marshal.PtrToStringAnsi(addressStringPtr);
                }
                to = identity;
                break;

            case LinphoneCallState.LinphoneCallConnected:
            case LinphoneCallState.LinphoneCallStreamsRunning:
            case LinphoneCallState.LinphoneCallPausedByRemote:
            case LinphoneCallState.LinphoneCallUpdatedByRemote:
                newstate = Call.CallState.Active;
                break;

            case LinphoneCallState.LinphoneCallOutgoingInit:
            case LinphoneCallState.LinphoneCallOutgoingProgress:
            case LinphoneCallState.LinphoneCallOutgoingRinging:
            case LinphoneCallState.LinphoneCallOutgoingEarlyMedia:
                newstate         = Call.CallState.Loading;
                newtype          = Call.CallType.Outcoming;
                addressStringPtr = linphone_call_get_remote_address_as_string(call);
                if (addressStringPtr != IntPtr.Zero)
                {
                    to = Marshal.PtrToStringAnsi(addressStringPtr);
                }
                from = this.identity;
                break;

            case LinphoneCallState.LinphoneCallError:
                newstate = Call.CallState.Error;
                break;

            case LinphoneCallState.LinphoneCallReleased:
            case LinphoneCallState.LinphoneCallEnd:
                newstate = Call.CallState.Completed;
                if (linphone_call_params_get_record_file(callsDefaultParams) != IntPtr.Zero)
                {
                    linphone_call_stop_recording(call);
                }
                break;

            default:
                break;
            }

            LinphoneCall existCall = FindCall(call);

            if (existCall == null)
            {
                existCall = new LinphoneCall();
                existCall.SetCallState(newstate);
                existCall.SetCallType(newtype);
                existCall.SetFrom(from);
                existCall.SetTo(to);
                existCall.LinphoneCallPtr = call;

                calls.Add(existCall);

                if ((CallStateChangedEvent != null))
                {
                    CallStateChangedEvent(existCall);
                }
            }
            else
            {
                if (existCall.GetState() != newstate)
                {
                    existCall.SetCallState(newstate);
                    CallStateChangedEvent(existCall);
                }
            }
        }
 /// <summary>
 /// Callback for LinphoneCoreListener
 /// </summary>
 public void CallState(LinphoneCall call, LinphoneCallState state, string message)
 {
 }