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


Top 5 Contributors of the Month
david stephan

Home >> Articles >> Vb Script >> Post New Resource Bookmark and Share   

 Subscribe to Articles

How to build a Windows Form Softphone in VB.NET

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

Earlier I've already shown you how to build a Windows Form Softphone in C#, now I would like you to present the sam process in the case of programming in VB.NET.
 

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 PhoneForm.vb 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 PhoneForm.vb file:

1.    Private Sub InitializeSoftPhone()  

2.        Try  

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

4.    softPhone.ChangeNATSettings(OzNat.NATTraversalMethodType.NONE, "", "", "")   

5.            AddHandler softPhone.IncommingCall, New EventHandler(Of VoIPEventArgs(Of IPhoneCall))(AddressOf softPhone_IncommingCall)  

6.            phoneLine = softPhone.CreatePhoneLine(New SIPAccount(True, "oz891", "oz891", "oz891", "oz891", "192.168.91.212", 5060))  

7.            AddHandler phoneLine.PhoneLineInformation, New EventHandler(Of VoIPEventArgs(Of PhoneLineInformation))(AddressOf phoneLine_PhoneLineInformation)  

8.            softPhone.RegisterPhoneLine(phoneLine, Nothing)  

9.        Catch ex As Exception  

10.                               MessageBox.Show("You didn't give your local IP adress, so the program won't run properly.")  

11.                           End Try  

12.                       End Sub  

In this section search for the following line:

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

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", "192.168.91.212", 5060))  

Where "true" is the registrationRequired parameter: this is a true value and it allows to receive calls (not just to initiate them) in case the registration is successful. (In case of "False" value registration, calls can only be initiated).

In the sample program "oz891" marks the SipAccount displayname, the username, the registername and the registerpassword.

The following two parameters are the IP address or domain address and the port of the SIP PBX.

 

Step 4: When you are finished you only need to 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.

 

PhoneForm.vb 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 PhoneForm.vb file includes the full logic of the sample program. By opening this PhoneForm.vb 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 Class PhoneForm  

2.      

3.        ' Fields  

4.        Private phoneCall As IPhoneCall  

5.        Private phoneLine As IPhoneLine  

6.        Private phoneLineInformation As PhoneLineInformation  

7.        Private softPhone As ISoftPhone  

8.        Private inComingCall As Boolean  

9.        Private ActiveAudioCallListener As ActiveAudio  

10.                           Private Mixer As AudioMixer  

11.                           ...  

ISoftphone:

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


Iphoneline:

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


PhoneLineInformation:

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


IphoneCall:

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.


OzPipeStream:

It is an optional device and it helps in the processing of the incoming sound data which comes from the other party.


ozWavePlayer:

It plays the received sound data on the speaker.


ozWavRecorder:

It processes the sound data which 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:

Responses

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