How to develop a softphone in C#
How to enable and disable different codecs
Download: | codecs-handler.zip |
Here you can learn how to enable/disable the (different) codecs in order to determine which codecs should be used during calls. This example requires the knowledge of SIP registering and the making of phone calles with the softphone. To learn these, you can visit the previous examples:
In this tutorial example we will learn the followings:
- How to enable a codec
- How to disable a codec
Please note that, only the softphone's new elements will be introduced here. You can find the registration's process and the needed elements for that at the first example, called "SIP Registration". You can find how to make and accept calls, how to begin to handle the call's states in the second example, called "Making and accepting calls".
Source code analysis
To understand the source code, the softphone's functions and their usage, we need to discuss the details.
Softphone.cs
This class 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 of that's functions. In other words, we would like to create a "telephone software", which has the same functions (or much more), as an ordinary mobile (or any other) phone. In the Program.cs class we will use this class to create a new softphone, so we can use the functions, we can listen to the events placed here. Please note that, this softphone is not able to accept calls. That function is removed in purpose to reduce the code's size, and to be more understandable.
Access to the codecs
With the help of the softphone object, you can have access to the list of available codecs:
softphone.Codecs;
Enabling and disabling codecs
In order for you to be able to disable a given codec, you should use the DisableCodec() method. In this method, you should provide the payLoadType of the codec you wish to disable as a parameter. This is a number which identifies the given codec. Enabling a codec works in a similar manner. In this case, you should use the EnableCodec() method.
softphone.DisableCodec(codec); softphone.EnableCodec(codec);
Program.cs
In this example, the softphone asks the user which codecs should be used. If the user does not wish to manually provide such codecs, by pressing Enter the default codec settings will be valid. This application guides you through the following steps:
- Lists the available codecs so that the codecs you wish to use can be easily selected.
- Afterwards, the numbers of these codecs will be requested or by pressing Enter, you can use the default codecs.
- Shows which codecs will be used at that moment as a result of your settings.
- Finally, by dialling a phone number, you can make calls using the previously selected codecs.
This code is handling everything with separate methods. These methods are communicating with each other, and making the source code more understandable and reusable.
Using Wireshark, you can check to see if the used codecs are the same as the codecs the user selected.
All you have to do is to filter the relevant data from the network traffic with the help of a SIP filter. This way you will be able to check which codecs were used during the call.
Conclusion
After reading this documentation and studying the source code, you are now familiar with how you can handle: enable and disable various codecs.
If you have any questions or need assistance, please contact us at info@voip-sip-sdk.com
Related Pages
More information
- How to register to a pbx using sip account
- How to use media handlers
- How to make and accept calls using sip voip
- How to control calls using sip messages
- How to send and receive sip instant messages
- How to enable and diasble the different codecs
- How to handle more than one call in the same time
- How to build an autodialer in c# with Ozeki VoIP SIP SDK
- How to make predictive autodialer using csharp
- How to implement autodialer which handles multiple sip accounts
- How to create a ring group in C# to improve your softphone
- How to create a call assistant
- Customize the features and GUI of your softphone
- C# voip softphone video tutorial part 1 sip registration
- C# voip softphone video tutorial part 2 Making and receiving calls
- C# voip softphone video tutorial part 3 sip call controlling