Click here to Skip to main content
15,884,298 members
Articles / Programming Languages / C#

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

Rate me:
Please Sign up or sign in to vote.
4.79/5 (15 votes)
18 Mar 2011CPOL9 min read 139.3K   11.6K   44  
Essay and tutorial about how to easily build a softphone application

This article appears in the Third Party Products and Tools section. Articles in this section are for the members only and must not be used to promote or advertise products in any way, shape or form. Please report any spam or advertising.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Timers;
using VoIP;
//using VoIP;

namespace FunnyPhone
{
    class PongCallListener : IPhoneCallListener
    {
        public void DtmfReceived(object sender, VoIPEventArgs<DTMF> e)
        {
            var dtmf = e.Item;
            var call = (PhoneCall)sender;
            Console.WriteLine("Dtmf received");
            call.SendDTMFSignal(VoIPMediaType.Audio, e.Item);
        }

        public void CallErrorOccured(object sender, VoIPEventArgs<CallError> e)
        {
            var call = (PhoneCall)sender;
            Console.WriteLine("Call error occured: " + e.Item);
        }

        public void MediaDataReceived(object sender, VoIPEventArgs<VoIPMediaData> e)
        {
            var call = (PhoneCall)sender;
            call.SendMediaData(e.Item.MediaType, e.Item.PCMData);
        }

        public void CallStateChanged(object sender, VoIPEventArgs<CallState> e)
        {
            var call = (PhoneCall)sender;
            Console.WriteLine("Call state changed: " + e.Item);

            if (e.Item > CallState.InCall)
                call.DetachListener(this);
        }

        public void PlainMediaDataReceived(object sender, VoIPEventArgs<EncodedMediaData> e)
        {
        }

    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Spain Spain
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions