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

Top 5 Contributors of the Month
Melody Anderson

Home >> Articles >> General >> Post New Resource Bookmark and Share   

 Subscribe to Articles

How to build your own Windows Form softphone

Posted By:Evan Miller       Posted Date: July 07, 2011    Points: 200    Category: General    URL: http://www.dotnetspark.com  

My next article is about softphone building. Everyone could use this article who wants to build a Windows Form softphone.

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.


In the telephone initialization section of the PhoneMain.cs file you need to replace the local IP address of the PC on which the system runs instead of "your local IP Address". Below you can find this step in details.

This is the telephone initialization section of the PhoneMain.cs file:

1.    private void InitializeSoftPhone()  

2.    {  

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

4.    Phone.ChangeNATSettings(NATTraversalMethodType.NONE, "", "", "");  


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

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

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


10.                           softPhone.RegisterPhoneLine(phoneLine);  

11.                       }  

In this section search for the following line:

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

In this line replace the local IP address of the PC on which the system runs instead of "your local IP Address".

Also set that the NAT should be between the softphone and the SIP server. This setting depends on the environment (depends on the construction of the network). If this setting is specified incorrectly, audio data from the remote end will not be received during the phone call.

As a next step you also need to provide the user data of your selected SIP PBX as the SIP account object values. Then you need to provide the user data of your selected SIP PBX as the SIP account object values similarly to the following line:

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

ñ Finally, you only need to make a build and run the program.


Because of this is being a developing article, you are probably interested in some coding, too. So, let's take a sneak peek at the Source code for creating a Windows Form softphone.


PhoneMain.cs code-behind file belonging to the program interface describes the control events related to the interface and connects the GUI with the logics. The sample program focuses on simplicity and representativeness. The PhoneMain.cs file includes the full logic of the sample program. By opening this PhoneMain.cs file, you can see a few lines of declaration right the beginning that are needed for the use of Ozeki VoIP SIP SDK.

1.    public partial class PhoneMain : Form  

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 IphoneLine. It is also possible to develop a multiline phone.

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

It is an enum type that represents the telephone line status related to 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, who is the called person, etc.

It is an optional device and it helps process the incoming audio data that comes from the remote end.

It plays the received audio data on the speaker.

It processes the audio data that comes from the default input device (microphone) of the operation system.


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:


No response found. Be the first to respond this post

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