Esempio n. 1
0
 public void TerminateCall(LinphoneCall linphoneCall)
 {
     if (linphoneCall.IsExist() && LinphoneCore.IsNonZero())
     {
         CallModule.linphone_core_terminate_call(LinphoneCore, linphoneCall.LinphoneCallPtr);
     }
 }
Esempio n. 2
0
 public void PauseRecording(LinphoneCall linphoneCall)
 {
     if (linphoneCall.IsExist() && LinphoneCore.IsNonZero() && !string.IsNullOrWhiteSpace(linphoneCall.RecordFile))
     {
         GenericModules.linphone_call_stop_recording(linphoneCall.LinphoneCallPtr);
     }
 }
Esempio n. 3
0
 public void ResumeCall(LinphoneCall linphoneCall)
 {
     if (linphoneCall.IsExist() && LinphoneCore.IsNonZero())
     {
         CallModule.linphone_core_resume_call(LinphoneCore, linphoneCall.LinphoneCallPtr);
     }
 }
Esempio n. 4
0
 public void SetIncomingRingSound(string file)
 {
     if (LinphoneCore.IsNonZero())
     {
         MediaModule.linphone_core_set_ring(LinphoneCore, file);
     }
 }
Esempio n. 5
0
 public void HoldCall(LinphoneCall linphoneCall)
 {
     if (linphoneCall.IsExist() && LinphoneCore.IsNonZero())
     {
         CallModule.linphone_core_pause_call(LinphoneCore, linphoneCall.LinphoneCallPtr);
     }
 }
Esempio n. 6
0
        private bool IsAccountConfigured()
        {
            LinphoneCore        lc  = LinphoneManager.Instance.LinphoneCore;
            LinphoneProxyConfig cfg = lc.DefaultProxyConfig;

            return(cfg != null);
        }
Esempio n. 7
0
 public void SetRingbackSound(string file)
 {
     if (LinphoneCore.IsNonZero())
     {
         MediaModule.linphone_core_set_ringback(LinphoneCore, file);
     }
 }
Esempio n. 8
0
 public void OnRegistrationChanged(IntPtr lc, IntPtr cfg, LinphoneRegistrationState cstate, string message)
 {
     if (LinphoneCore.IsNonZero())
     {
         RegistrationStateChangedEvent?.Invoke(cstate);
     }
 }
Esempio n. 9
0
        public void MakeCallAndRecord(string uri, string filename, bool startRecordInstantly)
        {
            if (LinphoneCore.IsNonZero())
            {
                var callParams = CreateCallParameters();

                if (!string.IsNullOrWhiteSpace(filename))
                {
                    CallModule.linphone_call_params_set_record_file(callParams, filename);
                }

                IntPtr call = CallModule.linphone_core_invite_with_params(LinphoneCore, uri, callParams);

                if (call.IsZero())
                {
#if (DEBUG)
                    ErrorEvent?.Invoke(null, "Can't call!");
#endif
                    return;
                }

                CallModule.linphone_call_ref(call);
                if (startRecordInstantly)
                {
                    GenericModules.linphone_call_start_recording(call);
                }
            }
        }
Esempio n. 10
0
 public void RedirectCall(LinphoneCall linphoneCall, string redirect_uri)
 {
     if (linphoneCall.IsExist() && LinphoneCore.IsNonZero())
     {
         CallModule.linphone_call_redirect(LinphoneCore, linphoneCall.LinphoneCallPtr, redirect_uri);
     }
 }
Esempio n. 11
0
 public void SendDTMFs(LinphoneCall linphoneCall, string dtmfs)
 {
     if (linphoneCall.IsExist() && LinphoneCore.IsNonZero() && !string.IsNullOrWhiteSpace(dtmfs))
     {
         CallModule.linphone_call_send_dtmfs(linphoneCall.LinphoneCallPtr, dtmfs);
     }
 }
Esempio n. 12
0
 private void InitLinphoneCore()
 {
     //Globals.Instance.LinphoneCoreFactory.CreateLinphoneCore(listener);
     Globals.Instance.LinphoneCoreFactory.CreateLinphoneCore(this);
     lc = Globals.Instance.LinphoneCore;
     lc.NativeVideoWindowId = this.videoViewerPanel.Handle.ToInt64();
     listener.Lc = lc;
 }
Esempio n. 13
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);
     }
 }
Esempio n. 14
0
 private void InitLinphoneCore()
 {
     //Globals.Instance.LinphoneCoreFactory.CreateLinphoneCore(listener);
     Globals.Instance.LinphoneCoreFactory.CreateLinphoneCore(this);
     lc = Globals.Instance.LinphoneCore;
     lc.NativeVideoWindowId = this.videoViewerPanel.Handle.ToInt64();
     listener.Lc            = lc;
 }
Esempio n. 15
0
 public void SendMessage(string to, string message)
 {
     if (LinphoneCore.IsNonZero())
     {
         IntPtr chat_room    = ChatModule.linphone_core_get_chat_room_from_uri(LinphoneCore, to);
         IntPtr chat_message = ChatModule.linphone_chat_room_create_message(chat_room, message);
         ChatModule.linphone_chat_room_send_chat_message(chat_room, chat_message);
     }
 }
Esempio n. 16
0
 /// <summary>
 /// Remove one or many entries from the calls' history.
 /// </summary>
 /// <param name="logsToRemove">A list of CallLog to remove from history</param>
 /// <returns>A list of CallLogs, without the removed entries</returns>
 public void RemoveCallLogs(IEnumerable <CallLog> logsToRemove)
 {
     // When removing log from history, it will be removed from logsToRemove list too.
     // Using foreach causing the app to crash on a InvalidOperationException, so we are using while
     for (int i = 0; i < logsToRemove.Count(); i++)
     {
         CallLog logToRemove = logsToRemove.ElementAt(i);
         LinphoneCore.RemoveCallLog(logToRemove.NativeLog as LinphoneCallLog);
     }
 }
Esempio n. 17
0
        public MainPage()
        {
            InitializeComponent();

            Listener = Factory.Instance.CreateCoreListener();
            Listener.OnRegistrationStateChanged = OnRegistration;
            Listener.OnCallStateChanged         = OnCall;
            Listener.OnCallStatsUpdated         = OnStats;
            LinphoneCore.AddListener(Listener);
        }
Esempio n. 18
0
 /// <summary>
 /// Resume the current call if any and if it's paused.
 /// </summary>
 public void ResumeCurrentCall()
 {
     foreach (LinphoneCall call in LinphoneCore.Calls)
     {
         if (call.State == LinphoneCallState.Paused)
         {
             LinphoneCore.ResumeCall(call);
         }
     }
 }
Esempio n. 19
0
        private bool IsRegisterEnabled()
        {
            LinphoneCore        lc  = LinphoneManager.Instance.LinphoneCore;
            LinphoneProxyConfig cfg = lc.DefaultProxyConfig;

            if (cfg != null)
            {
                return(cfg.RegisterEnabled);
            }
            return(true);
        }
Esempio n. 20
0
        public void ReceiveCall(LinphoneCall linphoneCall)
        {
            if (linphoneCall.IsExist() && LinphoneCore.IsNonZero())
            {
                CallModule.linphone_call_ref(linphoneCall.LinphoneCallPtr);

                IntPtr callParams = CreateCallParameters();

                CallModule.linphone_core_accept_call_with_params(LinphoneCore, linphoneCall.LinphoneCallPtr, callParams);
            }
        }
Esempio n. 21
0
        private void EnableRegister(bool enable)
        {
            LinphoneCore        lc  = LinphoneManager.Instance.LinphoneCore;
            LinphoneProxyConfig cfg = lc.DefaultProxyConfig;

            if (cfg != null)
            {
                cfg.Edit();
                cfg.RegisterEnabled = enable;
                cfg.Done();
            }
        }
Esempio n. 22
0
        public void ReceiveCallAndRecord(LinphoneCall linphoneCall, string filename, bool startRecordInstantly = true)
        {
            if (linphoneCall.IsExist() && LinphoneCore.IsNonZero())
            {
                CallModule.linphone_call_ref(linphoneCall.LinphoneCallPtr);
                IntPtr callParams = CreateCallParameters();

                CallModule.linphone_call_params_set_record_file(callParams, filename);

                CallModule.linphone_core_accept_call_with_params(LinphoneCore, linphoneCall.LinphoneCallPtr, callParams);

                if (startRecordInstantly)
                {
                    GenericModules.linphone_call_start_recording(linphoneCall.LinphoneCallPtr);
                }
            }
        }
Esempio n. 23
0
        public void OnCallStateChanged(IntPtr lc, IntPtr call, LinphoneCallState callState, string message)
        {
            if (LinphoneCore.IsNonZero() && IsRunning)
            {
                var    newCallState = CallState.None;
                var    newCallType = CallType.None;
                string from, to, recordFile;

                from = to = recordFile = null;
                IntPtr callParams = CallModule.linphone_call_get_params(call);

                bool recordEnable = MarshalingExtensions.TryConvert(CallModule.linphone_call_params_get_record_file(callParams), out recordFile);

                newCallState = GetNewCallState(call, callState, ref newCallType, ref from, ref to, recordEnable);

                UpdateCallReferences(call, newCallState, newCallType, callState, from, to, recordFile);
            }
        }
Esempio n. 24
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);
                    }
                }
            }
        }
Esempio n. 25
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);
 }
Esempio n. 26
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);
         }
     }
 }
Esempio n. 27
0
        public bool AcceptCall()
        {
            bool result = false;
            var  call   = LinphoneCore.CurrentCall;

            if (call != null && (call.State == CallState.IncomingReceived || call.State == CallState.IncomingEarlyMedia))
            {
                LinphoneCore.AcceptCall(call);
                result = true;
            }
            else
            {
                try
                {
                    linphoneCore.AcceptCall(LastCall);
                }
                catch
                {
                }
            }
            return(result);
        }
Esempio n. 28
0
 private void LinphoneCoreIterate(ThreadPoolTimer timer)
 {
     while (true)
     {
         CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.High, () => LinphoneCore.Iterate());
     }
 }
Esempio n. 29
0
 /// <summary>
 /// Remove all calls' history from LinphoneCore.
 /// </summary>
 /// <returns>An empty list</returns>
 public void ClearCallLogs()
 {
     LinphoneCore.ClearCallLogs();
 }
Esempio n. 30
0
        static void Main(string[] args)
        {
            var listener = new LinphoneManager();

            Globals.Instance.LinphoneCoreFactory.CreateLinphoneCore(listener);
            LinphoneCore lc = Globals.Instance.LinphoneCore;

            listener.Lc = lc;

            var proxyCfg = new LinphoneProxyConfig();

            proxyCfg.SetIdentity("test 1000 <sip:[email protected]>");
            proxyCfg.ServerAddr      = "192.168.6.241";
            proxyCfg.RegisterEnabled = true;
            proxyCfg.Expires         = 60000;
            lc.ClearProxyConfigs();
            lc.AddProxyConfig(proxyCfg);
            lc.DefaultProxyConfig = proxyCfg;

            var authInfo = new LinphoneAuthInfo("1000", string.Empty, "12345", string.Empty, string.Empty, string.Empty);

            lc.AddAuthInfo(authInfo);

            lc.IterateEnabled = true;
            while (lc.DefaultProxyConfig.State != RegistrationState.RegistrationOk)
            {
                Console.WriteLine("Registering...");
                System.Threading.Thread.Sleep(1000);
                if (lc.DefaultProxyConfig.State == RegistrationState.RegistrationFailed)
                {
                    Console.WriteLine("Reason: {0}", lc.DefaultProxyConfig.Error);
                    lc.IterateEnabled = false;
                    Console.ReadKey();
                    return;
                }
            }
            Console.WriteLine("Registered");
            Console.ReadKey();

#if CALL
            Console.WriteLine("Calling to sip:[email protected] ...");

            var callParams = lc.CreateDefaultCallParameters();
            callParams.VideoEnabled = false;
            //var callAddr = Globals.Instance.LinphoneCoreFactory.CreateLinphoneAddress("sip:[email protected]");
            //var call = lc.InviteAddressWithParams(callAddr, callParams);
            var call = lc.InviteWithParams("sip:[email protected]", callParams);

            if (call.State != LinphoneCallState.Connected)
            {
                Console.WriteLine("Waiting accept call...");
                System.Threading.Thread.Sleep(2000);
            }
            Console.ReadKey();

            lc.TerminateAllCalls();
#endif
            // De-activate registering
            var defaultCfg = lc.DefaultProxyConfig;
            defaultCfg.Edit();
            defaultCfg.RegisterEnabled = false;
            defaultCfg.Done();
            while (lc.DefaultProxyConfig.State != RegistrationState.RegistrationCleared)
            {
                Console.WriteLine("UnRegistering...");
                System.Threading.Thread.Sleep(1000);
            }
            Console.WriteLine("UnRegistered");
            lc.IterateEnabled = false;
            Console.ReadKey();
        }
Esempio n. 31
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);
 }