#3 How to develop a VoIP softphone in C# by using Ozeki VoIP SIP SDK

64 %
36 %
Information about #3 How to develop a VoIP softphone in C# by using Ozeki VoIP SIP SDK
Product-Training-Manuals

Published on March 14, 2014

Author: willmoore

Source: authorstream.com

How to develop a VoIP softphone in C# by using OZEKI VoIP SIP SDK: How to develop a VoIP softphone in C# by using OZEKI VoIP SIP SDK This presentation shows the final steps concerning to how to build a fully-functional softphone in C# in the most simplest way - by using the previously written components of Ozeki VoIP SIP SDK . Having done the SIP registration and after conducting some test calls , let’s learn how to control your calls . development tutorial The great softphone Part 3 Part 1: SIP registration Part 2: Making and receiving calls  Part 3: Controlling the calls 1/14 Previously on this series: Previously on this series Windows PC .NET compatible development kit installed on your PC .NET Framework installed on your PC Ozeki VoIP SIP SDK installed on your PC In order to build a VoIP softphone application in C# you will need the followings: 2/14 Download free example source code for this project ( Part 1 ) from http://voip-sip-sdk.com/p_539-sip-registration-voip.html ! After studying the previous 2 tutorials , you need to be fully familiar with using VoIP development components . Now you have a console window which interact s with the user and handl es y our softphone with the provided opportunities. You also know how to make and accept calls , and how to handle the call states and events . Download free example source code for this project ( Part 2 ) from http://voip-sip-sdk.com/p_540-making-and-accepting-calls-voip.html ! Download free example source code for this project ( Part 3 ) from http://voip-sip-sdk.com/p_541-controlling-the-call-voip.html ! Source code analysis: Source code analysis 3/14 Classes : Softphone.cs is used to introduce how to declare, define and initialize a softphone , how to handle some of the Ozeki VoIP SIP SDK's events and how to use some features . So the aim is creating a ‘t elephone software ’ , which has the same functionalities (or much more), as an ordinary phone ’s. You will use the Program.cs class to create a new softphone , so you can use the functions and listen to the events placed here. Handling the call states: When the  call state is ‘ LocalHeld ’ , the devices stop . Please note that if the call is taken off from hold, then you will e nter into the ‘ InCall ’ state (again), so you need to start the devices there as well. Since the call can enter into the InCall state several times during a call, this is the reason why you attach the media handlers at the ‘ Answered ’ state. Please also note that the hold function notifies the other client to do not send data (in this case: do not talk into the microphone). In the most of the cases you do not want y our voice to be heard either by to other party while you are holding the call, so you do no t need the microphone or the speaker either . T his is the reason for stop ping them. Handling the call states mediaReceiver.AttachToCall(call);   mediaSender.AttachToCall(call);   There are some changes in the method which handles the call states. You attac h the media handlers to the  call  object only once, so the ideal state to do this is the ‘ Answered ’ state, since it occurs only once per a call. 4/14 Putting the call on hold and taking off from hold (1): In this method, first you need to check that you have an active communication or not (is the  call  object ‘ null ’ or not), then you can start to  handle the ‘ holding ’ / ’ unholding ’ process . If there is an active call and you call this method, there can be two cases: if the call is in not in ‘ LocalHeld ’ state, that means you haven't put the call on hold yet, and you   can put the call on hold . If the call is in the ‘ LocalHeld ’ state, it indicates that you are already holding the call, so you can   take the call off hold . You can do it by checking the call state and using the commands introduced below: Putting the call on hold and taking off from hold (1) call.HoldCall();   call.UnholdCall();    5/14 Putting the call on hold and taking off from hold (2): But the simplest way to do this: As you can see, with the  ToggleHold ()  method you do not even need to check the call state or store/check that the call is held or not. This method does the work for you . Putting the call on hold and taking off from hold (2) 6/14 if  (call !=  null )   {   call.ToggleHold();   }  Hanging up the call: This is a really simple function. If the call exists, you only need to use the  HangUp () method of the call  object, and then to set the  call  object to ‘ null ’ . Hanging up the call if  (call !=  null )   {   call.HangUp();   call =  null ;   }     7/14 Transferring the call (1): Transferring the call (1) This is a nother very simple function, when you would like to  transfer the call to an other destination , to an other client . T here are several ways to do this, for example you can transfer the call with one of the BlindTransfer () or the AttendedTransfer () methods, or you can forward the call with the ForwardCall () one. BlindTransfer ():  using this during a call, the third party's phone starts to ring, like it would be dialled first, and not y ours. When the third party answers the call, you s tep out from that. AttendedTransfer ():  using this during a call, you can notify the third party about the incoming call by calling it, and then redirect the call. ForwardCall ():  without answering the call, you can set the softphone to redirect the incoming call to an other destination. (For example: if you leave y our office, you can forward the calls incoming to your office phone to y our mobile phone.) 8/14 Transferring the call (2): This example uses the  BlindTransfer()  method for this purpose. As you can see, first you check, if the destination has been set, and of course you can only transfer an existing call. After that, you use t he  BlindTransfer()  method of the call  object with the other client's number as a string parameter. Transferring the call (2) if   (call !=  null  && ! string .IsNullOrEmpty(destination))   {   call.BlindTransfer(destination);   }   9/14 Transferring the call (3): Program.cs This class will introduce the usage of a softphone object, handles the console events, interacts with the user, and uses the opportunities provided by the Softphone class. In this example, the softphone asks the user for a number to dial, and for a number to transfer the call to. The  application guides you through the following steps: Asks the user  for two numbers (to call, and to transfer to) Makes a call  and when it is answered,  puts that on hold , immediately Waits for a  key to be pressed  to  take the call off hold Takes the call off hold , than  hangs up the call  immediately Waits for a  key to be pressed , than it  redials  the last called number When the call is answered, it will be transferred  to the other number given by the user. You can handle everything with separated methods. These methods communicat e with each other and mak e the source code more understandable and reusable. Transferring the call (3) 10/14 Initialization: Three new string variables have been used in t his example . You need to initialize them to empty: The  numberToCall  is the phone number needs to be dial ed first and redial ed when it is needed . The call will be transferred to the  numberToTransfer  phone number. The  exampleSteps  variable will guide you through the call events. You need this variable, since you would enter into the same states several times and that would cause troubles in the guiding. You can also follow the user interacts (it is mostly automatized this time) with the help of this variable by writing the user events to the console. Initialization numberToTransfer =  string .Empty;   numberToCall =  string .Empty;   exampleSteps =  string .Empty;   11/14 Asking the user about phone numbers: This method asks the user about two phone numbers (as strings). By storing the last called number (and the last incoming one) and then using that number again to dial without setting the called number manually, you’ve just created a feature functioning just like the redial button of the traditional telephones. You need to call this method after the welcoming messages. When both numbers are given, the numberToCall will be dialed immediately, and the exampleSteps variable is being set to ‘ Calling ’ , so in the console window you can see; the user is calling the number, and the call state is changing , too. Asking the user about phone numbers 12/14 Handling the call and the guide states: The user can be guided through states by only pressing a few keys. For the guide you need to handle the  actual state of the call  and the value of the   exampleSteps variable : The first case, when the call is in ‘ Answered ’ state and the value of the variable is ‘ Calling ’ . In this case, the softphone   puts the call on hold , and sets the variable to ‘ Held ’ . The call enters to ‘ LocalHeld ’ state, sets the variable to ‘ Unheld ’ and takes the call off hold, when the user presses a button. The call enters to ‘ InCall ’ state (again), and if the variable is ‘ Unheld ’ , changes that to ‘ HangedUp ’ and hangs up the call. The call enters to ‘ Compl e ted ’ state, and if the variable is ‘ HangedUp ’ , changes that to ‘ Redialed ’ , and waits for a key to be pressed. If that happens, it redials the last called number. When the other phone answers the call, it enters into ‘ Answered ’ state, and if the variable is "Redialed", the call will be transferred to the other phone number immediately. The value of the variable is also changed to ‘ Transfering ’ . By writing the  exampleSteps value of the  variable to the console, you can see what would happen, if a real user would use these functions, actions. Handling the call and the guide states 13/14 It was the last part of the ‘How to develop a VoIP softphone in C# by using OZEKI VoIP SIP SDK’ tutorial series. Find further example projects and demo software at the official website of Ozeki VoIP SIP SDK: http://voip-sip-sdk.com/p_332-voip-sdk-developers-guide-voip.html : It was the last part of the ‘How to develop a VoIP softphone in C# by using OZEKI VoIP SIP SDK’ tutorial series. Find further example projects and demo software at the official website of Ozeki VoIP SIP SDK: http://voip-sip-sdk.com/p_332-voip-sdk-developers-guide-voip.html After studying this tutorial , you need be familiar with controlling calls by redialing , call holding, call transferring etc. However , these are only basic functions . You can write your own ones. You can handle more calls simultaneously, play audio files into the call as voice, you can create message recorder, IVR menu system , etc. development tutorial The great softphone Part 3 Thank you for your attention! For more information please visit www.voip-sip-sdk.com or send an e-mail to info@voip-sip-sdk.com 14/ 14

Add a comment

Related presentations

Related pages

Ozeki C# SIP Stack - Ozeki VoIP SIP SDK Home Page

... the home page of ozeki voip sip sdk. this is the best ... to develop a softphone in C#. ... can develop a simple SIP softphone for audio VoIP SIP ...
Read more

Ozeki C# VoIP SDK - A SIP SDK for software developers

A high performance VoIP SIP SDK for .Net developers to develop VoIP SIP programs e.g. SIP softphone ... on using Ozeki VoIP SDK ... Mobile Development.
Read more

#3 How to develop a SIP PBX in C# by using Ozeki VoIP SIP ...

#3 How to develop a SIP PBX in C# by using ... PBX by using Ozeki VoIP SIP SDK. This guide is the 3 ... by using Ozeki VoIP SIP SDK ...
Read more

#3 How to develop a softphone by using Ozeki VoIP SIP SDK ...

... to build a softphone by using Ozeki VoIP SIP SDK. ... #3 How to develop a softphone by using ... develop a SIP PBX in C# by using ...
Read more

How to Build a .NET Softphone in C# with SIP, SDP, RTP and ...

The communication process is built up by using SIP, ... by Ozeki. Ozeki VoIP SIP SDK provides an ... SoftPhone = new VoIP.SDK.Mock ...
Read more

Creating a C# Softphone - C# Corner - Developers and IT ...

Creating a C# Softphone. ... The new version of the Ozeki VoIP SIP SDK I ... I need to say thanks to the great developer and support teams of Ozeki ...
Read more