How to make SIP video calls in C#


/ Published in: C#
Save to your folder(s)

While searching on the Internet on how to make SIP video calls using C#, I recognised that there aren’t any brief and straightforward tutorial in this topic. I found multi-page articles (sorry, but some of them are full of bullsh*t) and neverending forum threads, but none of them provided me complete solution. Therefore, I undertook to create a short and concise guide on how to make video calls in C# using the VoIP technology.

Look at the prerequisites:

- PBX: To be able to make and receive video calls you, a phone system (e.g. Asterisk) is essentially needed. You need to add a new SIP account in your PBX for this application.

- Visual Studio: This solution is based on a console softphone, so a new Visual C# Console Application is just enough.

- VoIPSDK.dll: I used prewritten VoIP components to implement the SIP video calling feature. The necessary .dll file can be found on this website: http://www.voip-sip-sdk.com/. It should be added to your references.

- Test phone: To test your application you can use any VoIP phone stat supports video calling (e.g. Bria softphone).

Now take a look at the code. As you can see below, just a few lines of C# code are enough to connect the application to a PBX and to initiate a video call. Firstly, you need to perform the SIP registration tasks. You need to create a softphone and a phone line object, then you need to specify the SIP account to be used for the phone line. These configurations are needed to be able to register to your PBX. After calling the RegisterPhoneLine method the regsitration procedure starts, and the application will indicates its status due to the mySoftphone_PhoneLineStateChanged method. The PhoneCallVideoSender and PhoneCallVideoReceiver objects are responsible for video handling. To handle the USB webcamera, the WebCamera object can be used. The CallType class is used to identify whether the call is a video or an audio call.

To make a test call, provide valid SIP account details for this console application to be able to register to your PBX, then specify a telephone number to be dialled (it can be an other SIP account that has been previously registered to the PBX). After running the application, it dials the provided phone number automatically meanwhile sending the image of the webcamera.

URL: http://www.voip-sip-sdk.com

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.