.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Sandeep Singh
Melody Anderson
Eminent IT

Home >> Articles >> C# >> Post New Resource Bookmark and Share   

 Subscribe to Articles

How to build a C# open source VoIP softphone with WPF GUI

Posted By:Evan Miller       Posted Date: July 04, 2011    Points: 200    Category: C#    URL: http://www.dotnetspark.com  

This article is inspired to present the easiest way of buildin a C# open source VoIP softphone with WPF GUI.

How to build a C# open source VoIP softphone with WPF GUI

A softphone is a software program for making telephone calls over the Internet using a general purpose computer, rather than using dedicated hardware. Recently I've been thinking about building one. But with not much of developing experience, I've started to look for the easiest way of creating a softphone. Finally, I've found a software development kit, which has proved to be the perfect choice for me. Now, I would like to share my experiences with you, because I do believe this guide can be very useful for many of you.

First, let's see the step-by-step guide of configuring the sample program through of which I would like to present my work.

Step 1: Download and extract the sample program

Step 2: Load it into Project Visual Studio 2010

Step 3: Some changes are necessary. First, you need to replace some parameters in the following section of PhoneWindow.xaml.cs file:

  1. private void InitializeSoftPhone()  

  2.         {  

  3.             softPhone = SoftPhoneFactory.CreateSoftPhone("", 5700, 5750, 5780);  

  4.             softPhone.IncommingCall += new EventHandler>(softPhone_IncommingCall);  

  5.             phoneLine = softPhone.CreatePhoneLine(new SIPAccount(true, "oz891", "oz891", "oz891", "oz891", "", 5060));  

  6.             phoneLine.PhoneLineInformation += new EventHandler>(phoneLine_PhoneLineInformation);  


  8.             softPhone.RegisterPhoneLine(phoneLine);  

  9.         }  


Then you need to replace the local IP address of the running system instead of "your local IP Address" section in this line:

  1. softPhone = SoftPhoneFactory.CreateSoftPhone("your local IP Address", 5700, 5750, 5780);  

Finally, you need to provide the user data of the chosen SIP PBX as the data of the SIPAccount object, as you see in this line:

  1. phoneLine = softPhone.CreatePhoneLine(new SIPAccount(true, "oz891", "oz891",   

  2. "oz891", "oz891", "", 5060));  

Often a softphone is designed to behave like a traditional telephone, sometimes appearing as an image of a phone, with a display panel and buttons with which the user can interact. The Graphical User Interface (GUI) of this sample program has been developed with Microsoft WPF (Windows Presentation Foundation) technology, which allows great flexibility regarding the appearance of the program. You can easily customize its look according to your taste, the possibilities are only limited by your fantasy. I think this is a great feature of this software kit. But for now, you need to settle for seeing the simpliest appearance (see the picture), because "designing a softphone" is outside the question. Instead, let's get to know the functions of the main buttons.

This softphone is set up with every function a basic telephone should have.

You can answer to a call or (after dialing the number) you can make a call pressing the "Pick Up" button.

If you want to end a call in progress you press the "Hang Up" button.

As a normal phone, the softphone also can display call statuses like: Ringing, InCall, Completed, Rejected, etc.

Now, for those who are more interested in some techical details, let's see a brief desription of the source code. These are the devices of the SDK that are needed for making phone calls.

  1. public partial class PhoneWindow : Window  

  2. {  

  3.     ISoftPhone softPhone;  

  4.     IPhoneLine phoneLine;  

  5.     PhoneLineInformation phoneLineInformation;  

  6.     IPhoneCall call;  

  7.     ActiveAudio ActiveAudioCallListener;  

  8.     AudioMixer Mixer;  

  9.     bool inComingCall;  

  10.         ...  

It represents a telephone, and its telephone line is represented by the IphoneLine. There can be more telephone lines which means that you can develop a multi line phone.

It represents a telephone line that can be registered to a SIP PBX, for example Asterisk, 3CX, or maybe to other free PBXs that are offered by SIP providers. Registration is made via a SIP account.

It is an enum type that represents the status of the phone line with the PBX. For example, registered, not registered, successful/unsuccessful registration.

It represents a call: the status of the call, the direction of the call, on which telephone line it was created, the called person, etc.

Additional info: This is a very flexible SDK because it can be included into any program that was developed in .Net. It is compatible with ATA and PBX systems, too, they only need to support SIP protocol.

I hope I could serve you with some useful information. Of course this article only containes a few main issues connected to the subject, but I think there are others who can explain these things more precisely. If you'd like to know more, I suggest you to visit the website I've been using as the source of my article.


 Subscribe to Articles


Further Readings:

Author: Rinosh         Company URL: http://www.dotnetspark.com
Posted Date: November 05, 2011

Hello I have downloaded the application,
but how can i configure both the proxy and client application in my machine
much thanks in advance
Author: Simon Robert VoIP         Company URL: http://www.dotnetspark.com
Posted Date: March 20, 2014

It could be helpful for the begginnings: http://voip-sip-sdk.com/p_539-sip-registration-voip.html

Post Comment

You must Sign In To post reply
Find More Articles on C#, ASP.Net, Vb.Net, SQL Server and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend