Ejemplo n.º 1
0
 private void PhoneLineStateChanged(object sender, VoIPEventArgs <PhoneLineState> e)
 {
     _log.Debug("Line state changed to " + e.Item.ToString());
     if (e.Item == PhoneLineState.RegistrationSucceeded)
     {
         _log.Info("Line Registered");
         Dial();
     }
     else if (e.Item == PhoneLineState.UnregSucceeded)
     {
         _log.Info("Line Unregistered");
         _phoneLine = null;
         _softPhone = null;
         _complete  = true;
         lock (_sync)
         {
             Monitor.Pulse(_sync);
         }
     }
     else if (e.Item == PhoneLineState.RegistrationFailed)
     {
         _log.Info("Registration failed. Try again");
         Register();
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Initializes the base softphone engine.
        /// </summary>
        internal void InitSoftphone(bool useFixIP)
        {
            // if the softphone is already created, then close it
            if (softPhone != null)
            {
                // unregister the phone lines, because if the local IP address changed, the existing registrations will not work
                foreach (var line in PhoneLines)
                {
                    if (line.LineState == PhoneLineState.RegistrationSucceeded || line.LineState == PhoneLineState.NoRegNeeded)
                    {
                        softPhone.UnregisterPhoneLine(line);
                    }
                }

                softPhone.IncomingCall -= (SoftPhone_IncomingCall);
                softPhone.Close();
            }

            // create new softphone
            if (LocalIP == null || !useFixIP)
            {
                softPhone = SoftPhoneFactory.CreateSoftPhone(MinPort, MaxPort, 5060);
            }
            else
            {
                softPhone = SoftPhoneFactory.CreateSoftPhone(LocalIP, MinPort, MaxPort, 5060);
            }

            softPhone.IncomingCall += (SoftPhone_IncomingCall);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Inicializa la información de los controles que se usarán para el teléfono
        /// </summary>
        void InitializeSoftphone()
        {
            try
            {
                UsuarioLinea ln = new UsuarioLinea().ObtenerLinea(int.Parse(AUsuarioData.sIdusuario));

                _softPhone = SoftPhoneFactory.CreateSoftPhone(SoftPhoneFactory.GetLocalIP(), 5700, 5750);
                SIPAccount sa = new SIPAccount(true, ln.sDisplayName, ln.sUserName, ln.sRegisterName, ln.sRegisterPassword, ln.sDomainHost, ln.iDomainPort);

                _phoneLine = _softPhone.CreatePhoneLine(sa);
                _phoneLine.RegistrationStateChanged += _phoneLine_RegistrationStateChanged;

                _softPhone.IncomingCall += _softPhone_IncomingCall;
                _softPhone.RegisterPhoneLine(_phoneLine);

                _incomingCall = false;

                ConnectMedia();
            }
            catch (Exception ex)
            {
                InvokeGUIThread(() => {
                    txtDisplay.Text = ex.Message;
                });
            }
        }
 public OzekiLiveStream()
 {
     softPhone = SoftPhoneFactory.CreateSoftPhone(SoftPhoneFactory.GetLocalIP(), 5700, 5750);
     softPhone.IncomingCall += SoftPhone_IncomingCall;
     conferenceRoom          = new ConferenceRoom();
     conferenceRoom.StartConferencing();
 }
		/// <summary>
		///It initializes a softphone object with a SIP BPX, and it is for requisiting a SIP account that is nedded for a SIP PBX service. It registers this SIP
		///account to the SIP PBX through an ’IphoneLine’ object which represents the telephoneline. 
		///If the telephone registration is successful we have a call ready softphone. In this example the softphone can be reached by dialing the number 891.
		/// </summary>
		private void InitializeSoftPhone()
		{
			try
			{
				softPhone = SoftPhoneFactory.CreateSoftPhone(SoftPhoneFactory.GetLocalIP(), 5700, 5750, 5700);
				softPhone.IncomingCall += new EventHandler<VoIPEventArgs<IPhoneCall>>(softPhone_IncomingCall); // arama geldiğinde çalışan fonksiyon.
				phoneLine = softPhone.CreatePhoneLine(new SIPAccount(true, "7134", "7134", "7134", "123456", "sip.kobikom.com", 5060), new NatConfiguration(NatTraversalMethod.None));
				//phoneLine = softPhone.CreatePhoneLine(new SIPAccount(true, "oz875", "oz875", "oz875", "oz875", "192.168.112.100", 5060), new NatConfiguration(NatTraversalMethod.None));
				phoneLine.PhoneLineStateChanged += new EventHandler<VoIPEventArgs<PhoneLineState>>(phoneLine_PhoneLineInformation);

				softPhone.RegisterPhoneLine(phoneLine);
			}
			catch (Exception ex)
			{
				MessageBox.Show(String.Format("You didn't give your local IP adress, so the program won't run properly.\n {0}", ex.Message), string.Empty, MessageBoxButtons.OK,
				MessageBoxIcon.Error);

				var sb = new StringBuilder();
				sb.AppendLine("Some error happened.");
				sb.AppendLine();
				sb.AppendLine("Exception:");
				sb.AppendLine(ex.Message);
				sb.AppendLine();
				if (ex.InnerException != null)
				{
					sb.AppendLine("Inner Exception:");
					sb.AppendLine(ex.InnerException.Message);
					sb.AppendLine();
				}
				sb.AppendLine("StackTrace:");
				sb.AppendLine(ex.StackTrace);

				MessageBox.Show(sb.ToString());
			}
		}
Ejemplo n.º 6
0
        /// <summary>
        /// Contructor.
        /// </summary>
        public SoftPhoneUtils()
        {
            try
            {
                if (LicenseManager.Instance.LicenseType.ToString().Equals("Expired") || LicenseManager.Instance.LicenseType.ToString().Equals("Trial"))
                {
                    var userName = "******";
                    var key      = "UDoyMDMzLTEyLTI1LFVQOjIwMzMtMDEtMDEsTUNDOjUwMCxNUEw6NTAwLE1TTEM6NTAwLE1GQzo1MDAsRzcyOTp0cnVlLE1XUEM6NTAwLE1JUEM6NTAwfHFQZDBhQnhlaEFGaTlNMmV4cXZxaHUyVE5rMWh2S0FzaUZlVlowbFFseTZWZ3JKbmFMTXh3ZVV2elBGcEliTFpwNHZtZDArZlZwc2VkRGpjQWdKR3ZnPT0=";
                    LicenseManager.Instance.SetLicense(userName, key);
                }
            }
            catch (Exception e)
            {
                log.Error(e);
            }

            //Crear instancia softPhone. Rango 5000-10000
            softphone = SoftPhoneFactory.CreateSoftPhone(softPhoneRangeMin, softPhoneRangeMax);

            softphone.EnableCodec(0);
            softphone.EnableCodec(8);//PCMU(G711U)=> 0, PCMA(G711A)=> 8
            log.Info(softphone.Codecs);

            mediaSender = new PhoneCallAudioSender();
            connector   = new MediaConnector();
        }
Ejemplo n.º 7
0
        public void Run()
        {
            _log.Info("Starting server");

            try
            {
                _config = new Config("config.txt");
            }
            catch (FileNotFoundException)
            {
                _log.Fatal("Configuration file not found");
                return;
            }

            _softPhone = SoftPhoneFactory.CreateSoftPhone(SoftPhoneFactory.GetLocalIP(), _config.GetIntValue("sip.min"), _config.GetIntValue("sip.max"), _config.GetIntValue("sip.port"));
            _phoneLine = _softPhone.CreatePhoneLine(new SIPAccount(true, _config.GetStringValue("sip.displayname"), _config.GetStringValue("sip.username"), _config.GetStringValue("sip.username"), _config.GetStringValue("sip.password"), _config.GetStringValue("sip.host")), new NatConfiguration(_config.GetStringValue("externalip"), true));
            _phoneLine.PhoneLineStateChanged += phoneLine_PhoneLineStateChanged;
            _softPhone.RegisterPhoneLine(_phoneLine);
            _softPhone.IncomingCall += softPhone_IncomingCall;

            // Wait 3 seconds and check if the line is registered. If not, shut down.
            System.Threading.Thread.Sleep(3000);
            if (_phoneLine.LineState != PhoneLineState.RegistrationSucceeded)
            {
                _log.Error(String.Format("Phone Line is not registered. State is {0}. Exiting.", _phoneLine.LineState.ToString()));
                return;
            }

            lock (_sync)
                System.Threading.Monitor.Wait(_sync);
        }
Ejemplo n.º 8
0
        private void InitializeSoftPhone()
        {
            try
            {
                var userAgent = "MyFirstSoftPhone-3-example";
                _softPhone = SoftPhoneFactory.CreateSoftPhone(SoftPhoneFactory.GetLocalIP(), 5700, 5750, userAgent);
                InvokeGUIThread(() => { lb_Log.Items.Add("Softphone created!"); });

                _softPhone.IncomingCall += softPhone_inComingCall;

                SIPAccount sa = new SIPAccount(true, "100", "100", "100", "123456", "192.168.1.6", 5060);
                InvokeGUIThread(() => { lb_Log.Items.Add("SIP account created!"); });

                _phoneLine = _softPhone.CreatePhoneLine(sa);
                _phoneLine.RegistrationStateChanged += phoneLine_PhoneLineInformation;
                InvokeGUIThread(() => { lb_Log.Items.Add("Phoneline created."); });
                _softPhone.RegisterPhoneLine(_phoneLine);

                tb_Display.Text       = string.Empty;
                lbl_NumberToDial.Text = sa.RegisterName;

                _inComingCall = false;
                _reDialNumber = string.Empty;
                _localHeld    = false;

                ConnectMedia();
            }
            catch (Exception ex)
            {
                InvokeGUIThread(() => { lb_Log.Items.Add("Local IP error! " + ex); });
            }
        }
Ejemplo n.º 9
0
        public void InitializeSoftPhone()
        {
            try
            {
                var userAgent = "MyFirstSoftPhone-3-example";
                _message   = new List <string>();
                _softPhone = SoftPhoneFactory.CreateSoftPhone(SoftPhoneFactory.GetLocalIP(), 5700, 5750, userAgent);
                _message.Add("Softphone created!");
                //InvokeGUIThread(() => { lb_Log.Items.Add("Softphone created!"); });

                _softPhone.IncomingCall += softPhone_inComingCall;

                SIPAccount sa = new SIPAccount(true, "2001", "2001", "2001", "2001", "172.16.1.17");
                _message.Add("SIP account created!");
                //InvokeGUIThread(() => { lb_Log.Items.Add("SIP account created!"); });

                _phoneLine = _softPhone.CreatePhoneLine(sa);
                _phoneLine.RegistrationStateChanged += phoneLine_PhoneLineInformation;
                _message.Add("Phoneline created.");
                //InvokeGUIThread(() => { lb_Log.Items.Add("Phoneline created."); });
                _softPhone.RegisterPhoneLine(_phoneLine);

                _registerName = sa.RegisterName;

                _inComingCall = false;
                _reDialNumber = string.Empty;
                //_localHeld = false;

                ConnectMedia();
            }
            catch (Exception ex)
            {
                _message.Add(ex.ToString());
            }
        }
Ejemplo n.º 10
0
        private void InitializeSoftPhone()
        {
            try
            {
                softPhone = SoftPhoneFactory.CreateSoftPhone(SoftPhoneFactory.GetLocalIP(), 5700, 5750);
                InvokeGUIThread(() => { lb_Log.Items.Add("Softphone created!"); });

                softPhone.IncomingCall += new EventHandler <VoIPEventArgs <IPhoneCall> >(softPhone_inComingCall);

                SIPAccount sa = new SIPAccount(true, "1000", "1000", "1000", "1000", "192.168.115.103", 5060);
                InvokeGUIThread(() => { lb_Log.Items.Add("SIP account created!"); });

                phoneLine = softPhone.CreatePhoneLine(sa);
                phoneLine.RegistrationStateChanged += phoneLine_PhoneLineInformation;
                InvokeGUIThread(() => { lb_Log.Items.Add("Phoneline created."); });
                softPhone.RegisterPhoneLine(phoneLine);

                tb_Display.Text       = string.Empty;
                lbl_NumberToDial.Text = sa.RegisterName;

                inComingCall = false;
                reDialNumber = string.Empty;
                localHeld    = false;

                ConnectMedia();
            }
            catch (Exception ex)
            {
                InvokeGUIThread(() => { lb_Log.Items.Add("Local IP error!"); });
            }
        }
 public void OzekiInitialization()
 {
     softphone     = SoftPhoneFactory.CreateSoftPhone(5000, 10000);
     microphone    = Microphone.GetDefaultDevice();
     speaker       = Speaker.GetDefaultDevice();
     mediaSender   = new PhoneCallAudioSender();
     mediaReceiver = new PhoneCallAudioReceiver();
     connector     = new MediaConnector();
 }
Ejemplo n.º 12
0
        public void OzekiInitialization()
        {
            softphone = SoftPhoneFactory.CreateSoftPhone(5000, 10000);
            var config = new DirectIPPhoneLineConfig(local_ip, 5060);

            phoneLine = softphone.CreateDirectIPPhoneLine(config);
            phoneLine.RegistrationStateChanged += line_RegStateChanged;
            softphone.IncomingCall             += softphone_IncomingCall;
            softphone.RegisterPhoneLine(phoneLine);
        }
Ejemplo n.º 13
0
        /// <summary>
        /// Default constructor, initalizes the softphone with deafult parameters.
        /// </summary>
        public Softphone()
        {
            _softphone = SoftPhoneFactory.CreateSoftPhone(5000, 10000);

            _microphone    = Microphone.GetDefaultDevice();
            _speaker       = Speaker.GetDefaultDevice();
            _connector     = new MediaConnector();
            _mediaSender   = new PhoneCallAudioSender();
            _mediaReceiver = new PhoneCallAudioReceiver();
        }
Ejemplo n.º 14
0
        void Form_Load(object sender, EventArgs e)
        {
            _txtFromAlias.Text     = "alice";
            _txtToAlias.Text       = "bob";
            _chkPeerToPeer.Checked = false;
            _chkPeerToPeer_CheckedChanged(null, null);

            _softPhone = SoftPhoneFactory.CreateSoftPhone(SipUtil.ParseIpEndPoint(this.MainForm.Configuration.BindIpEndPoint));
            _softPhone.IncomingCall += _softPhone_IncomingCall;
            _softPhone.Start();
        }
Ejemplo n.º 15
0
 static void OzekiInit()
 {
     //softphone = SoftPhoneFactory.CreateSoftPhone(6000, 6200);
     softphone = SoftPhoneFactory.CreateSoftPhone(5000, 10000);
     //Console.WriteLine("OZEKI: CreatedSoftPhone");
     microphone    = Microphone.GetDefaultDevice();
     speaker       = Speaker.GetDefaultDevice();
     mediaSender   = new PhoneCallAudioSender();
     mediaReceiver = new PhoneCallAudioReceiver();
     connector     = new MediaConnector();
 }
Ejemplo n.º 16
0
        public PhoneForm()
        {
            InitializeComponent();
            softphone = SoftPhoneFactory.CreateSoftPhone(5000, 10000);

            microphone    = Microphone.GetDefaultDevice();
            speaker       = Speaker.GetDefaultDevice();
            mediaSender   = new PhoneCallAudioSender();
            mediaReceiver = new PhoneCallAudioReceiver();
            connector     = new MediaConnector();
        }
Ejemplo n.º 17
0
        public Softphone()
        {
            softphone     = SoftPhoneFactory.CreateSoftPhone(5000, 10000);
            microphone    = Microphone.GetDefaultDevice();
            speaker       = Speaker.GetDefaultDevice();
            connector     = new MediaConnector();
            mediaSender   = new PhoneCallAudioSender();
            mediaReceiver = new PhoneCallAudioReceiver();

            incomingCall = false;
        }
        public OutGoingCallEngine(string dialedNumber, ISoftPhone softPhone, IPhoneLine phoneLine)
        {
            _connector = new MediaConnector();
            _videoSender = new PhoneCallVideoSender();
            _audioSender = new PhoneCallAudioSender();

            var dial = new DialParameters(dialedNumber) { CallType = CallType.AudioVideo };
            Call = softPhone.CreateCallObject(phoneLine, dial);
            Call.CallStateChanged += _call_CallStateChanged;        

            _videoSender.AttachToCall(Call);
            _audioSender.AttachToCall(Call);
        }
Ejemplo n.º 19
0
        /// <summary>
        /// Initializes the softphone logic
        /// Subscribes change events to get notifications.
        /// Register info event
        /// Incoming call event
        /// </summary>
        private void InitializeSoftPhone()
        {
            try
            {
                var    displayName      = txtDisplayName.Text;
                string userName         = txtUsername.Text;
                string authenticationId = userName;
                string password         = txtPassword.Text;
                string domain           = txtDomain.Text;
                int    port             = int.Parse(txtPort.Text);
                var    userAgent        = "Snowday";
                _softPhone = SoftPhoneFactory.CreateSoftPhone(
                    SoftPhoneFactory.GetLocalIP(),
                    7000, 9000, userAgent);

                InvokeGUIThread(() => {
                    lb_Log.Items.Add("Softphone created!");
                });

                _softPhone.IncomingCall += softPhone_inComingCall;

                SIPAccount account_S = new SIPAccount(true,
                                                      displayName,
                                                      userName,
                                                      authenticationId,
                                                      password,
                                                      domain,
                                                      port);
                InvokeGUIThread(() => {
                    lb_Log.Items.Add("SIP account created!");
                });

                _phoneLine = _softPhone.CreatePhoneLine(account_S);
                _phoneLine.RegistrationStateChanged += phoneLine_PhoneLineInformation;
                InvokeGUIThread(() => {
                    lb_Log.Items.Add("Phoneline created.");
                });
                _softPhone.RegisterPhoneLine(_phoneLine);

                _inComingCall = false;

                ConnectMedia();
            }
            catch (Exception ex)
            {
                InvokeGUIThread(() => {
                    lb_Log.Items.Add("Local IP error! " + ex);
                });
            }
        }
Ejemplo n.º 20
0
        protected override void Given()
        {
            _aliceEndPoint = TestConstants.LocalEndPoint1;
            _bobEndPoint   = TestConstants.LocalEndPoint2;

            _phoneAlice = SoftPhoneFactory.CreateSoftPhone(_aliceEndPoint);
            _phoneAlice.IncomingCall += _phoneAlice_IncomingCall;
            _phoneAlice.Start();

            _phoneBob = SoftPhoneFactory.CreateSoftPhone(_bobEndPoint);
            _phoneBob.IncomingCall += _phoneBob_IncomingCall;
            _phoneBob.Start();

            GivenOverride();
        }
Ejemplo n.º 21
0
        protected override void Given()
        {
            _aliceEndPoint = TestConstants.LocalEndPoint1;
            _bobEndPoint = TestConstants.LocalEndPoint2;

            _phoneAlice = SoftPhoneFactory.CreateSoftPhone(_aliceEndPoint);
            _phoneAlice.IncomingCall += _phoneAlice_IncomingCall;
            _phoneAlice.Start();

            _phoneBob = SoftPhoneFactory.CreateSoftPhone(_bobEndPoint);
            _phoneBob.IncomingCall += _phoneBob_IncomingCall;
            _phoneBob.Start();

            GivenOverride();
        }
Ejemplo n.º 22
0
        /// <summary>
        ///It initializes a softphone object with a SIP PBX, and it is for requisiting a SIP account that is nedded for a SIP PBX service. It registers this SIP
        ///account to the SIP PBX through an ’IphoneLine’ object which represents the telephoneline.
        ///If the telephone registration is successful we have a call ready softphone. In this example the softphone can be reached by dialing the registername.
        /// </summary>
        /// <param name="registerName">The SIP ID what will registered into your PBX</param>
        /// <param name="domainHost">The address of your PBX</param>
        private void InitializeSoftPhone(string registerName, string domainHost)
        {
            try
            {
                softPhone = SoftPhoneFactory.CreateSoftPhone(5700, 5800);
                softPhone.IncomingCall += softPhone_IncomingCall;
                phoneLine = softPhone.CreatePhoneLine(new SIPAccount(true, registerName, registerName, registerName, registerName, domainHost, 5060));
                phoneLine.RegistrationStateChanged += phoneLine_PhoneLineInformation;

                softPhone.RegisterPhoneLine(phoneLine);
            }
            catch (Exception ex)
            {
                Console.WriteLine("You didn't give your local IP adress, so the program won't run properly.\n {0}", ex.Message);
            }
        }
Ejemplo n.º 23
0
        public bool MakeCall(Dictionary <string, string> pingData)
        {
            _log.Info("Beginning MakeCall");
            _pingData = pingData;

            // Ensure the specified audio file is in the manifest
            Assembly assembly       = Assembly.GetExecutingAssembly();
            string   resourceName   = String.Format("Netopia.VOIPTester.Client.Resources.{0}", _config.GetStringValue("tonefile"));
            Stream   resourceStream = assembly.GetManifestResourceStream(resourceName);

            // Console.WriteLine(String.Join("\n", assembly.GetManifestResourceNames()));
            if (resourceStream == null)
            {
                _log.Fatal(String.Format("Can't find embedded audio file {0}", resourceName));
                return(false);
            }

            // Create the SIP client and register to the server
            _softPhone = SoftPhoneFactory.CreateSoftPhone(SoftPhoneFactory.GetLocalIP(), _config.GetIntValue("sip.min"), _config.GetIntValue("sip.max"), _config.GetIntValue("sip.port"));
            _phoneLine = _softPhone.CreatePhoneLine(new SIPAccount(true, _config.GetStringValue("sip.displayname"), _config.GetStringValue("sip.username"), _config.GetStringValue("sip.username"), _config.GetStringValue("sip.password"), _config.GetStringValue("sip.host")), new NatConfiguration(_config.GetStringValue("externalip"), true));
            _phoneLine.PhoneLineStateChanged += PhoneLineStateChanged;
            _wavPlayback          = new WaveStreamPlayback(resourceStream);
            _wavPlayback.Stopped += StreamingStopped;
            _connector.Connect(_wavPlayback, _callSender);

            // Register the SIP connection
            Register();

            // Wait 3 seconds and check if the line is registered. If not, shut down.
            System.Threading.Thread.Sleep(3000);
            if (_phoneLine.LineState != PhoneLineState.RegistrationSucceeded)
            {
                _log.Error(String.Format("Phone Line is not registered. State is {0}. Exiting.", _phoneLine.LineState.ToString()));
                return(false);
            }


            lock (_sync)
            {
                // Wait for the defined MAX_CALL_LENGTH
                Monitor.Wait(_sync, MAX_CALL_LENGTH * 1000);
            }
            _log.Info("Completed call");

            return(_complete);
        }
Ejemplo n.º 24
0
Archivo: App.cs Proyecto: Nedvid/BlaBla
        //OZEKI
        void Ozeki()
        {
            softphone = SoftPhoneFactory.CreateSoftPhone(6000, 6200);

            microphone    = Microphone.GetDefaultDevice();
            speaker       = Speaker.GetDefaultDevice();
            mediaSender   = new PhoneCallAudioSender();
            mediaReceiver = new PhoneCallAudioReceiver();
            connector     = new MediaConnector();

            var config = new DirectIPPhoneLineConfig(local_ip, 5060);

            phoneLine = softphone.CreateDirectIPPhoneLine(config);
            phoneLine.RegistrationStateChanged += line_RegStateChanged;
            softphone.IncomingCall             += softphone_IncomingCall;
            softphone.RegisterPhoneLine(phoneLine);
        }
Ejemplo n.º 25
0
        /// <summary>
        /// Default constructor, initalizes the softphone with deafult parameters.
        /// </summary>
        public SoftPhone()
        {
            //you can specify the User-Agent of the softphone
            string userAgent = "ORX SoftPhone";

            _softphone     = SoftPhoneFactory.CreateSoftPhone(5000, 10000, userAgent);
            _microphone    = Microphone.GetDefaultDevice();
            _speaker       = Speaker.GetDefaultDevice();
            _connector     = new MediaConnector();
            _mediaSender   = new PhoneCallAudioSender();
            _mediaReceiver = new PhoneCallAudioReceiver();

            _incomingCall = false;

            MediaHandlers = new MediaHandlers();
            InitMedia();
        }
Ejemplo n.º 26
0
        public OutGoingCallEngine(string dialedNumber, ISoftPhone softPhone, IPhoneLine phoneLine)
        {
            _connector   = new MediaConnector();
            _videoSender = new PhoneCallVideoSender();
            _audioSender = new PhoneCallAudioSender();

            var dial = new DialParameters(dialedNumber)
            {
                CallType = CallType.AudioVideo
            };

            Call = softPhone.CreateCallObject(phoneLine, dial);
            Call.CallStateChanged += _call_CallStateChanged;

            _videoSender.AttachToCall(Call);
            _audioSender.AttachToCall(Call);
        }
Ejemplo n.º 27
0
        /// <summary>
        /// Initializes the softphone logic
        /// Subscribes change events to get notifications.
        /// Register info event
        /// Incoming call event
        /// </summary>
        private void InitializeSoftPhone()
        {
            try
            {
                var devices = Devices.EnumerateAudioEndPoints(DataFlow.All,
                                                              NAudio.CoreAudioApi.DeviceState.Active);
                arrayDevices = devices.ToArray();
                string userAgent = "Snow";
                _softPhone = SoftPhoneFactory.CreateSoftPhone(
                    SoftPhoneFactory.GetLocalIP(),
                    7000, 9000, userAgent);

                InvokeGUIThread(() =>
                {
                    lb_Log.Items.Add("Softphone created!");
                });

                _softPhone.IncomingCall += softPhone_inComingCall;


                InvokeGUIThread(() =>
                {
                    lb_Log.Items.Add("SIP account created!");
                });
                _phoneLine = _softPhone.CreatePhoneLine(accountSipInfo);

                _phoneLine.RegistrationStateChanged += phoneLine_PhoneLineInformation;
                InvokeGUIThread(() =>
                {
                    lb_Log.Items.Add("Phoneline created.");
                });
                _softPhone.RegisterPhoneLine(_phoneLine);

                _inComingCall = false;

                ConnectMedia();
            }
            catch (Exception ex)
            {
                InvokeGUIThread(() =>
                {
                    lb_Log.Items.Add("Local IP error! " + ex);
                });
            }
        }
Ejemplo n.º 28
0
        public RealPhone(string number, string password, string ip, int port)
        {
            if (File.Exists("license.txt"))
            {
                string[] licenseInfo = File.ReadAllLines("license.txt");
                var      uid         = licenseInfo.Length > 0 ? licenseInfo[0] : "";
                var      pwd         = licenseInfo.Length > 1 ? licenseInfo[1] : "";
                //http://geekwolke.com/2016/10/04/ozeki-voip-sip-sdk-license-code-free-download/
                Ozeki.VoIP.SDK.Protection.LicenseManager.Instance.SetLicense(uid, pwd);
            }
            softPhone = SoftPhoneFactory.CreateSoftPhone(15000, 15500);
            softPhone.IncomingCall += softPhone_IncomingCall;
            phoneLine = softPhone.CreatePhoneLine(new SIPAccount(true, number, number, number, password, ip, port));
            phoneLine.RegistrationStateChanged += phoneLine_PhoneLineStateChanged;

            softPhone.RegisterPhoneLine(phoneLine);

            ConnectMedia();
        }
        ISoftPhone softphone; // softphone object

        #endregion Fields

        #region Methods

        public string Get(string id)
        {
            Regex regexObj = new Regex(@"[^\d]");
            id2 = regexObj.Replace(id, "");
            softphone = SoftPhoneFactory.CreateSoftPhone(5000, 10000);
            var registrationRequired = true;
            var userName = "******";
            var displayName = "730";
            var authenticationId = "730";
            var registerPassword = "";
            var domainHost = "192.168.60.225";
            var domainPort = 5060;
            var account = new SIPAccount(registrationRequired, displayName, userName, authenticationId, registerPassword, domainHost, domainPort);
            RegisterAccount(account);
            mediaSender = new PhoneCallAudioSender();
            connector = new MediaConnector();
            int count = 0;
            while (done == 0 && count < 120) { count++; Thread.Sleep(1000); }
            return message;
        }
Ejemplo n.º 30
0
        private void Nasluchuj()
        {
            softphone     = SoftPhoneFactory.CreateSoftPhone(zalogowanyUzytkownik.AdresIP, 4900, 5100);
            mediaSender   = new PhoneCallAudioSender();
            mediaReceiver = new PhoneCallAudioReceiver();
            connector     = new MediaConnector();
            var config = new DirectIPPhoneLineConfig(zalogowanyUzytkownik.AdresIP.ToString(), 5060);

            phoneLine = softphone.CreateDirectIPPhoneLine(config);
            phoneLine.Config.SRTPMode           = Ozeki.Common.SRTPMode.Prefer;
            phoneLine.RegistrationStateChanged += line_RegStateChanged;
            phoneLine.SIPAccount.UserName       = zalogowanyUzytkownik.login;
            phoneLine.SIPAccount.DisplayName    = zalogowanyUzytkownik.imie + " " + zalogowanyUzytkownik.nazwisko;
            System.Windows.Application.Current.Dispatcher.Invoke(() => { System.Windows.Application.Current.MainWindow.Title = "SuperIP Phone - " + zalogowanyUzytkownik.login + "@" + zalogowanyUzytkownik.AdresIP + ":" + phoneLine.SIPAccount.DomainServerPort; });//ustawienie nazwy okna
            softphone.IncomingCall += softphone_IncomingCall;
            phoneLine.InstantMessaging.MessageReceived += PhoneLine_InstantMessageReceived;
            softphone.RegisterPhoneLine(phoneLine);
            foreach (var kodek in softphone.Codecs)
            {
                softphone.EnableCodec(kodek.PayloadType);
            }
        }
Ejemplo n.º 31
0
        static IPhoneLine phoneLine;   // phoneline object

        private static void Main(string[] args)
        {
            // Create a softphone object with RTP port range 5000-10000
            softphone = SoftPhoneFactory.CreateSoftPhone(5000, 10000);

            // SIP account registration data, (supplied by your VoIP service provider)
            var registrationRequired = true;
            var userName             = "******";
            var displayName          = "iamboss";
            var authenticationId     = "iamboss";
            var registerPassword     = "******";
            var domainHost           = "sip.linphone.org";
            var domainPort           = 5060;

            var account = new SIPAccount(registrationRequired, displayName, userName, authenticationId, registerPassword, domainHost, domainPort);

            // Send SIP regitration request
            RegisterAccount(account);

            // Prevents the termination of the application
            Console.ReadLine();
        }
Ejemplo n.º 32
0
        void InitializeSoftphone()
        {
            try
            {
                _softPhone = SoftPhoneFactory.CreateSoftPhone(SoftPhoneFactory.GetLocalIP(), 5700, 5750);
                SIPAccount sa = new SIPAccount(true, "1000", "1000", "1000", "1000", "192.168.115.100", 5060);

                _phoneLine = _softPhone.CreatePhoneLine(sa);
                _phoneLine.RegistrationStateChanged += _phoneLine_RegistrationStateChanged;

                _softPhone.IncomingCall += _softPhone_IncomingCall;

                _softPhone.RegisterPhoneLine(_phoneLine);

                _incomingCall = false;

                ConnectMedia();
            }
            catch (Exception ex)
            {
                InvokeGUIThread(() => { tb_Display.Text = ex.Message; });
            }
        }
Ejemplo n.º 33
0
        private void InitalizeSoftPhone()
        {
            try
            {
                SoftPhone             = SoftPhoneFactory.CreateSoftPhone(SoftPhoneFactory.GetLocalIP(), 5000, 10000);
                InvokeGUIThread(mymsg = "SoftPhoneCreated!");

                SoftPhone.IncomingCall += new EventHandler <VoIPEventArgs <IPhoneCall> >(SoftPhone_inComingCall);

                var        registrationRequired = true;
                var        userName             = "******";
                var        displayName          = "858";
                var        authenticationId     = "858";
                var        registerPassword     = "******";
                var        domainHost           = SoftPhoneFactory.GetLocalIP().ToString();
                var        domainPort           = 5060;
                SIPAccount sa = new SIPAccount(registrationRequired, displayName, userName, authenticationId, registerPassword, domainHost, domainPort);
                InvokeGUIThread(mymsg = "SIP Acc Created!!");

                NatConfiguration nc = new NatConfiguration();
                nc.AutoDetect = true;

                PhoneLineConfiguration config = new PhoneLineConfiguration(sa);
                config.NatConfig = nc;

                PhoneLine = SoftPhone.CreatePhoneLine(config);
                PhoneLine.RegistrationStateChanged += PhoneLine_PhoneLineInfo;
                InvokeGUIThread(mymsg = "PhoneLine Created!!");
                SoftPhone.RegisterPhoneLine(PhoneLine);

                ConnectMedia();
            }
            catch (Exception ex)
            {
                InvokeGUIThread(mymsg = ("Unknown Error: " + ex));
            }
        }
Ejemplo n.º 34
0
        void Form_Load(object sender, EventArgs e)
        {
            _txtFromAlias.Text = "alice";
            _txtToAlias.Text = "bob";
            _chkPeerToPeer.Checked = false;
            _chkPeerToPeer_CheckedChanged(null,null);

            _softPhone = SoftPhoneFactory.CreateSoftPhone(SipUtil.ParseIpEndPoint(this.MainForm.Configuration.BindIpEndPoint));
            _softPhone.IncomingCall += _softPhone_IncomingCall;
            _softPhone.Start();
        }
Ejemplo n.º 35
0
        private SoftphoneEngine()
        {
            sipMessageLogger = new SIPMessageLogger();
            sipMessageLogger.SIPMessageReceived += (sipMessageLogger_SIPMessageReceived);
            sipMessageLogger.SIPMessageSent += (sipMessageLogger_SIPMessageSent);
            Logger.Attach(sipMessageLogger);
            Logger.Open(LogLevel.Information);
            //SoftPhone = new ArbSoftPhone(10000, 200000, 20000, 500000);

            softPhone = SoftPhoneFactory.CreateSoftPhone(SoftPhoneFactory.GetLocalIP(), 5000, 7000, 5060);
            //SoftPhone.SetSIPMessageManipulator(this);
            //OzSIP.Log.SIPMessageLogger.NewSIPMessage += SIPMessageLogger_NewSIPMessage;

            phoneCallsBijection = new Bijection<PhoneCallInfo, IPhoneCall>();
            PhoneLinesBijection = new Bijection<PhoneLineInfo, IPhoneLine>();
            incomingCallsBijection = new Bijection<PhoneCallInfo, IPhoneCall>();

            softPhone.IncomingCall += SoftPhone_IncomingCall;
            PhoneLinesBijection.PropertyChanged += PhoneLinesBijection_PropertyChanged;
            phoneCallsBijection.PropertyChanged += PhoneCallsBijection_PropertyChanged;

            callHistory = new List<PhoneCallInfo>();

            CreateMediaHandlers();
            activeAudioCallListener.Start();

            disposed = false;
            ForwardCallTo = "";
        }
Ejemplo n.º 36
0
        /// <summary>
        ///It initializes a softphone object with a SIP PBX, and it is for requisiting a SIP account that is nedded for a SIP PBX service. It registers this SIP
        ///account to the SIP PBX through an ’IphoneLine’ object which represents the telephoneline. 
        ///If the telephone registration is successful we have a call ready softphone. In this example the softphone can be reached by dialing the registername.
        /// </summary>
        /// <param name="registerName">The SIP ID what will registered into your PBX</param>
        /// <param name="domainHost">The address of your PBX</param>
        private void InitializeSoftPhone(string registerName, string domainHost)
        {
            try
            {
                softPhone = SoftPhoneFactory.CreateSoftPhone(5700, 5800);
                softPhone.IncomingCall += softPhone_IncomingCall;
                phoneLine = softPhone.CreatePhoneLine(new SIPAccount(true, registerName, registerName, registerName, registerName, domainHost, 5060));
                phoneLine.RegistrationStateChanged += phoneLine_PhoneLineInformation;

                softPhone.RegisterPhoneLine(phoneLine);
            }
            catch (Exception ex)
            {
                Console.WriteLine("You didn't give your local IP adress, so the program won't run properly.\n {0}", ex.Message);
            }
        }
Ejemplo n.º 37
0
 /// <summary>
 /// Reinitialize the softphone with new selected IP.
 /// </summary>
 /// <param name="ip">new IP address.</param>
 private void restartSoftphoneWithNewIP(IPAddress ip)
 {
     if (ip == null)
         return;
      lock (softPhone)
     {
         softPhone.Close();
         softPhone.IncomingCall -= SoftPhone_IncomingCall;
     }
      softPhone = SoftPhoneFactory.CreateSoftPhone(ip, 5000, 7000, 5060);
      softPhone.IncomingCall += SoftPhone_IncomingCall;
 }
Ejemplo n.º 38
0
        /// <summary>
        ///It initializes a softphone object with a SIP BPX, and it is for requisiting a SIP account that is nedded for a SIP PBX service. It registers this SIP
        ///account to the SIP PBX through an ’IphoneLine’ object which represents the telephoneline. 
        ///If the telephone registration is successful we have a call ready softphone. In this example the softphone can be reached by dialing the number 891.
        /// </summary>
        private void InitializeSoftPhone()
        {
            try
            {
                if (Ozeki.VoIP.SDK.Protection.LicenseManager.Instance.LicenseType != Ozeki.VoIP.SDK.Protection.LicenseType.Activated)
                    Ozeki.VoIP.SDK.Protection.LicenseManager.Instance.SetLicense(m_OzekiLicenseId, m_OzekiLicenseKey);

                using (BrightPlatformEntities objDbModel = new BrightPlatformEntities(UserSession.EntityConnection)) {
                    int? _SipAcctId = objDbModel.users.FirstOrDefault(i => i.id == UserSession.CurrentUser.UserId).sip_id;
                    if (!_SipAcctId.HasValue) {
                        //MessageBox.Show(
                        //    string.Format("Your account is not yet configured for calling.{0}Please contact your administrator.", Environment.NewLine),
                        //    "Bright Sales",
                        //    MessageBoxButtons.OK,
                        //    MessageBoxIcon.Information
                        //);
                        BrightVision.Common.UI.NotificationDialog.Error(
                            "Bright Sales",
                            string.Format("Your account is not yet configured for calling.{0}Please contact your administrator.", Environment.NewLine)
                        );
                        return;
                    }

                    sip_accounts sip = objDbModel.sip_accounts.FirstOrDefault(i => i.id == _SipAcctId);
                    if (sip != null)
                        objDbModel.Detach(sip);

                    if (m_UserAudioSetting == null)
                        m_UserAudioSetting = AudioSettingUtility.GetUserAudioSetting();

                    m_UserMicrophone = AudioSettingUtility.GetDefaultDeviceMicrophone();
                    m_UserSpeaker = AudioSettingUtility.GetDefaultDeviceSpeaker();
                    m_UserMicrophone.Volume = (float)m_UserAudioSetting.mic_volume / 10;
                    m_UserSpeaker.Volume = (float)m_UserAudioSetting.speaker_volume / 10;

                    try {
                        softPhone = SoftPhoneFactory.CreateSoftPhone(SoftPhoneFactory.GetLocalIP(), 5700, 5750, 5780);
                    }
                    catch {
                    }

                    this.DisableUnwantedCodec();
                    softPhone.IncomingCall -= new EventHandler<VoIPEventArgs<IPhoneCall>>(softPhone_IncomingCall);
                    softPhone.IncomingCall += new EventHandler<VoIPEventArgs<IPhoneCall>>(softPhone_IncomingCall);
                    SIPAccount acc = new SIPAccount(
                       true,
                       sip.display_name.Trim(),
                       sip.username.Trim(),
                       sip.username.Trim(),
                       sip.password,
                       sip.sip_url.Trim(),
                       5060,
                       ""
                    );
                    // var acc = new SIPAccount(true, sip.display_name, sip.username, sip.username, sip.password, sip.sip_url, 5060,"");
                    //  NatConfiguration newNatConfiguration = new NatConfiguration(NatTraversalMethod.Auto, new NatRemoteServer("stun.ozekiphone.com", "", ""));
                    phoneLine = softPhone.CreatePhoneLine(acc, Ozeki.Network.TransportType.Udp, SRTPMode.None);
                    phoneLine.PhoneLineStateChanged -= new EventHandler<VoIPEventArgs<PhoneLineState>>(phoneLine_PhoneLineInformation);
                    phoneLine.PhoneLineStateChanged += new EventHandler<VoIPEventArgs<PhoneLineState>>(phoneLine_PhoneLineInformation);
                    softPhone.RegisterPhoneLine(phoneLine);
                    objDbModel.Dispose();
                }
            }
            catch (Exception ex) {
            }
        }
        /// <summary>
        /// Initializes the base softphone engine.
        /// </summary>
        internal void InitSoftphone(bool useFixIP)
        {
            // if the softphone is already created, then close it
            if (softPhone != null)
            {
                // unregister the phone lines, because if the local IP address changed, the existing registrations will not work
                foreach (var line in PhoneLines)
                {
                    if (line.RegState == RegState.RegistrationSucceeded)
                        softPhone.UnregisterPhoneLine(line);
                }

                softPhone.IncomingCall -= (SoftPhone_IncomingCall);
                softPhone.Close();
            }

            // create new softphone
            if (LocalIP == null || !useFixIP)
                softPhone = SoftPhoneFactory.CreateSoftPhone(MinPort, MaxPort);
            else
                softPhone = SoftPhoneFactory.CreateSoftPhone(LocalIP, MinPort, MaxPort);

            softPhone.IncomingCall += (SoftPhone_IncomingCall);
        }
Ejemplo n.º 40
0
        /// <summary>
        /// Initializes the base softphone engine.
        /// </summary>
        internal void InitSoftphone(bool useFixIP)
        {
            Logger.Open(LogLevel.Trace); // open logger
            // if the softphone is already created, then close it
            if (softPhone != null)
            {
                // unregister the phone lines, because if the local IP address changed, the existing registrations will not work
                foreach (var line in PhoneLines)
                {
                    if (line.LineState == PhoneLineState.RegistrationSucceeded || line.LineState == PhoneLineState.NoRegNeeded)
                        softPhone.UnregisterPhoneLine(line);
                }

                softPhone.IncomingCall -= (SoftPhone_IncomingCall);
                softPhone.Close();
            }

            // create new softphone
            if (LocalIP == null || !useFixIP)
                //softPhone = SoftPhoneFactory.CreateSoftPhone(MinPort, MaxPort, 5060, "c:\\log.txt");
                softPhone = SoftPhoneFactory.CreateSoftPhone(MinPort, MaxPort, 5060, "c:\\YEK\\log.txt");
            else
                //softPhone = SoftPhoneFactory.CreateSoftPhone(LocalIP, MinPort, MaxPort, 5060, "c:\\log.txt");
                softPhone = SoftPhoneFactory.CreateSoftPhone(LocalIP, MinPort, MaxPort, 5060, "c:\\YEK\\log.txt");

            softPhone.IncomingCall += (SoftPhone_IncomingCall);
        }