This is a mirror of official site: http://jasper-net.blogspot.com/

Simple SIP(VOIP) based phone in C#

| Wednesday, December 22, 2010
Introduction

This application was developed and is currently in use as "Help -> Call to support". The idea is to create zero configuration very simple call-out phone, thats how it is now.  (Though IP based incoming calls supported. Example To: sip:test@ip:7666, 7666 is the port SIP_Call out runs).

Currently this application runs on windows only. For some reason .NET "still" has no managed support for audio-in and audio-out. Audio part uses unmanaged windows wave API.

I tried to make example application well organized,clear and well commented - don't know how it turned out, that you can judge. For beginners i suggest to google and read some SIP introduction, otherwise you never get whats going on.

Because code is full of comments, i think there is no need blaa blaa text here, just dig into the code.

SIP commands and terms used(in example application):

INVITE - Invite has 2 meanings:
          1) Initial INVITE - In simple words we or remote-party just sends call offer.
          2) Mid-dialog INVITE - In SIP specifications this is called "RE-INVITE".
             RE-INVITE is used to modify session info, in our case implementing call onhold.
             RE-INVVITE can be sent by us or remote-party.

ACK - ACK must be sent to remote-party each INVITE/RE-INVITE postitive 2xx response.
      ACK just confirms that we received 2xx rescponse.

CANCEL - CANCEL can be used to cancel pending INVITE or RE-INVVITE request.

BYE - BYE is used to end the active call. Call terminating side must send BYE.

SIP dilaog - We can imagine this as session between us and remote-party.

SIP call - SIP call consists SIP dialog and audio RTP session.
Establishing a call:

Call establishing starts from creating RTP audio session, because we need to advertise our RTP session IP:port in SDP. After it we need to do NAT handling if it's needed. Now inital INVITE request can be created and send to remote-party. For more detail RFC 3216 should be read, see links below.

Example SIP messages exchanged:

INVITE sip:bob@192.168.1.44 SIP/2.0
Via: SIP/2.0/UDP 192.168.1.33;branch=z9hG4bKnashds8
Max-Forwards: 70
To: Bob <sip:bob@domain.com>
From: Alice <sip:alice@domain.com>;tag=1928301774
Call-ID: a84b4c76e66710
CSeq: 314159 INVITE
Contact: <sip:alice@192.168.1.33>
Content-Type: application/sdp
Content-Length: sdp_size_in_bytes

v=0
o=- 2890844526 2890844526 IN IP4 192.168.1.33
s=
c=IN IP4 192.168.1.33
t=0 0
m=audio 1111 RTP/AVP 0 97
a=rtpmap:0 PCMU/8000
a=sendrecv


SIP/2.0 180 Ringing
Via: SIP/2.0/UDP 192.168.1.33;branch=z9hG4bK4b43c2ff8.1 ;received=192.0.2.3
To: Bob <sip:bob@domain.com>;tag=a6c85cf
From: Alice <sip:alice@domain.com>;tag=1928301774

Read more: Codeproject

Posted via email from .NET Info

0 comments: