Recepcion de Videollamada

De Open movilforum wiki

Tabla de contenidos

[editar] Register

First of all, you have to send an empty REGISTER request

REGISTER sip:195.76.180.160 SIP/2.0
Via: SIP/2.0/UDP localIP:5061;rport;branch=z9hG4bK21898
From: <sip:msisdn@movistar.es>;tag=fromTag
To: <sip:msisdn@movistar.es>
Call-ID: callId@localIP
CSeq: 1 REGISTER
Contact: <sip:msisdn@localIP:5061>
Max-Forwards: 70
Expires: 3600
Allow-Events: presence
Event: registration
User-Agent: Intellivic/PC
Allow: ACK, BYE, CANCEL, INVITE, MESSAGE, OPTIONS, REFER, PRACK
Content-Length: 0

The server will respond you with a 401 Unauthorize message where it sends the data needed to register successfully

SIP/2.0 401 Unauthorized
Via: SIP/2.0/UDP localIP:5061;received=121.76.32.139;branch=z9hG4bK21898;rport=14890
From: <sip:msisdn@movistar.es>;tag=13939
To: <sip:msisdn@movistar.es>;tag=SDgphm399-b72e12N2648086bda-4371
Call-ID: callId@localIP
CSeq: 1 REGISTER
Contact: <sip:msisdn-34jqqpc874a7d@127.0.0.100:5060;transport=udp>;expires=3600
Expires: 3600
User-Agent: Intellivic/PC
WWW-Authenticate: digest realm="movistar.es", qop="auth", nonce="480879ea3eae663bb2e61ec43831734064b1dfb38fa926d8244d034bd40bd66341894f85cdb79a40e394f2e514651dcca4eab581", opaque="", stale=false, algorithm=md5
Content-Length:0

You have to use MD5 encryption to calculate a Response value that you will have to provide to a new REGISTER request

HA1 = MD5(user:realm:password)
HA2 = MD5(method:digestURI)

Response = MD5(HA1:nonce:nonceCount:clientNonce:qop:HA2)

In our sample:

msisdn:movistar.es:password	=>	e880269bd29912c6397ce24dfd4325b6
REGISTER:sip:localIP		=>	61b88b7f3dc58536aef97ceffbf3ab47

e880269bd29912c6397ce24dfd4325b6:480879ea3eae663bb2e61ec43831734064b1dfb38fa926d8244d034bd40bd66341894f85cdb79a40e394f2e514651dcca4eab581:00000001:14122:auth:61b88b7f3dc58536aef97ceffbf3ab47 =>	839e13d654ab3ef2e6f4e5649afc969f

You have to send the last response obtained

REGISTER sip:195.76.180.160 SIP/2.0
Via: SIP/2.0/UDP localIP:5061;rport;branch=z9hG4bK23080
From: <sip:msisdn@movistar.es>;tag=fromTag
To: <sip:msisdn@movistar.es>
Call-ID: callId@localIP
CSeq: 2 REGISTER
Contact: <sip:msisdn@localIP:5061>
Authorization: digest username="msisdn", realm="movistar.es", nonce="480879ea3eae663bb2e61ec43831734064b1dfb38fa926d8244d034bd40bd66341894f85cdb79a40e394f2e514651dcca4eab581", uri="sip:195.76.180.160", response="839e13d654ab3ef2e6f4e5649afc969f", algorithm=md5, cnonce="14122", qop=auth, nc=00000001
Max-Forwards: 70
Expires: 3600
Allow-Events: presence
Event: registration
User-Agent: Intellivic/PC
Allow: ACK, BYE, CANCEL, INVITE, MESSAGE, OPTIONS, REFER, PRACK
Content-Length: 0

If the server responds you with 200 OK you are registered.

SIP/2.0 200 OK
Via: SIP/2.0/UDP localIP:5061;received=121.76.32.139;branch=z9hG4bK23080;rport=14890
From: <sip:msisdn@movistar.es>;tag=13939
To: <sip:msisdn@movistar.es>;tag=SDgphm399-
Call-ID: callId@localIP
CSeq: 2 REGISTER
Contact: <sip:msisdn@121.76.32.139:14890>;expires=3600
Expires: 3600
User-Agent: Intellivic/PC
Content-Length: 0

After this you have to register periodically, each about 45 seconds to keep the server informed that you are online

The following texts have to be replaced by:

  • msisdn - Your telephone number
  • password - Your password to movistar services
  • localIP - Local IP of your PC
  • callId - Random number to identify the register process
  • fromTag - Random number to identify the register process

[editar] Call reception

While you are registered you can receive video-calls by the following message

INVITE sip:msisdn@movistar.es:5061 SIP/2.0
Via: SIP/2.0/UDP 195.76.180.160:5060;branch=callBranch
From: <sip:calling@movistar.es>;tag=fromTag
To: <sip:msisdn@movistar.es:5060;user=phone>
Call-ID: callId
CSeq: 1 INVITE
Max-Forwards: 26
Contact: "sipua" <sip:calling@195.76.180.160:5060;transport=udp>
Allow: INVITE,REGISTER,ACK,OPTIONS,BYE,INFO,REFER,NOTIFY,SUBSCRIBE,MESSAGE,CANCEL,PRACK,UPDATE
Content-Length: 0

You must keep the value of Call-ID in order to use it in the following messages. You have to respond with a 100 Trying message to inform the calling party that you have received the invitation.

SIP/2.0 100 Trying
Via: SIP/2.0/UDP 195.76.180.160:5060;branch=callBranch
From: <sip:calling@movistar.es>;tag=fromTag
To: <sip:msisdn@movistar.es:5060;user=phone>
Call-ID: callId
CSeq: 1 INVITE
Content-Length: 0

and then a 180 Ringing to inform that the called party is being alerted.

SIP/2.0 180 Ringing
Via: SIP/2.0/UDP 195.76.180.160:5060;branch=callBranch
From: <sip:calling@movistar.es>;tag=fromTag
To: <sip:msisdn@movistar.es:5060;user=phone>;tag=9095
Call-ID: callId
CSeq: 1 INVITE
Contact: <sip:msisdn@localIP:5061>
Content-Length: 0

To negotiate the audio and video format, and the ports for both streamings you have to send

SIP/2.0 200 OK
Via: SIP/2.0/UDP 195.76.180.160:5060;branch=callBranch
From: <sip:calling@movistar.es>;tag=fromTag
To: <sip:msisdn@movistar.es:5060;user=phone>;tag=9095
Call-ID: callId
CSeq: 1 INVITE
Contact: <sip:msisdn@localIP:5061>
User-Agent: Intellivic/PC
Supported: replaces
Allow: ACK, BYE, CANCEL, INVITE, OPTIONS
Content-Type: application/sdp
Accept: application/sdp, application/media_control+xml, application/dtmf-relay
Content-Length: 458

v=0
o=- 26069 29246 IN IP4 localIP
s=-
c=IN IP4 localIP
t=0 0
m=audio audioPort RTP/AVP 101 99 0 8 104
a=rtpmap:101 speex/16000
a=fmtp:101 vbr=on;mode=6
a=rtpmap:99 speex/8000
a=fmtp:99 vbr=on;mode=3
a=rtpmap:0 PCMU/8000
a=rtpmap:8 PCMA/8000
a=rtpmap:104 telephone-event/8000
a=fmtp:104 0-15
m=video videoPort RTP/AVP 97 34
a=rtpmap:97 MP4V-ES/90000
a=fmtp:97 profile-level-id=1
a=rtpmap:34 H263/90000
a=fmtp:34 QCIF=2 SQCIF=2/MaxBR=560

If everything goes fine the server will respond you:

ACK sip:msisdn@172.16.90.74:5061 SIP/2.0
Via: SIP/2.0/UDP 195.76.180.160:5060;branch=callBranch
From: <sip:calling@movistar.es>;tag=fromTag
To: <sip:msisdn@movistar.es:5060;user=phone>;tag=9095
Call-ID: callId
CSeq: 1 ACK
Max-Forwards: 28
Contact: "sipua" <sip:calling@195.76.180.160:5060;transport=udp>
Content-Type: application/sdp
Content-Length: 261

v=0
o=iwfuser 3232404366 3232409445 IN IP4 195.76.180.160
s=-
t=0 0
m=audio remoteAudioPort RTP/AVP 0
c=IN IP4 195.76.180.160
a=rtpmap:0 PCMU/8000/1
a=maxptime:400
a=sendrecv
m=video remoteVideoPort RTP/AVP 34
c=IN IP4 195.76.180.160
a=rtpmap:34 H263/90000
a=sendrecv

where it selects the audio and video formats and the ports to send/receive them.

The following texts have to be replaced by:

  • msisdn - Your telephone number
  • calling - Calling party number
  • fromTag - Tag that identifies the from field
  • callBranch - Tag that identifies the call
  • callId - Call Identifier
  • localIP - Your local IP address
  • audioPort - The port opened to send and receive the audio stream. You also have to open audioPort + 1 to send and receive audio control data.
  • videoPort - The port opened to send and receive the video stream. You also have to open videoPort + 1 to send and receive video control data.
  • remoteAudioPort - The port where the server will receive our audio streaming.
  • remoteVideoPort - The port where the server will receive our video streaming.

[editar] Call-end reception

Whe the calling party ends the call you will receive

BYE sip:msisdn@localIP:5061 SIP/2.0
Via: SIP/2.0/UDP 195.76.180.160:5060;branch=callBranch
From: <sip:calling@movistar.es>;tag=fromTag
To: <sip:msisdn@movistar.es:5060;user=phone>;tag=9095
Call-ID: callId
CSeq: 2 BYE
Max-Forwards: 28
Content-Length: 0

that you should resond sending this

SIP/2.0 200 OK
Via: SIP/2.0/UDP 195.76.180.160:5060;branch=callBranch
From: <sip:calling@movistar.es>;tag=fromTag
To: <sip:msisdn@movistar.es:5060;user=phone>;tag=9095
Call-ID: callId
CSeq: 2 BYE
Content-Length: 0

The following texts have to be replaced by:

  • msisdn - Your telephone number
  • calling - Calling party number
  • fromTag - Tag that identifies the from field
  • callBranch - Tag that identifies the call
  • callId - Call Identifier

[editar] Unregister

You have to send the same REGISTER data but using Expires: 0

REGISTER sip:195.76.180.160 SIP/2.0
Via: SIP/2.0/UDP localIP:5061;rport;branch=z9hG4bK23080
From: <sip:msisdn@movistar.es>;tag=fromTag
To: <sip:msisdn@movistar.es>
Call-ID: callId@localIP
CSeq: 2 REGISTER
Contact: <sip:msisdn@localIP:5061>
Authorization: digest username="msisdn", realm="movistar.es", nonce="480879ea3eae663bb2e61ec43831734064b1dfb38fa926d8244d034bd40bd66341894f85cdb79a40e394f2e514651dcca4eab581", uri="sip:195.76.180.160", response="839e13d654ab3ef2e6f4e5649afc969f", algorithm=md5, cnonce="14122", qop=auth, nc=00000001
Max-Forwards: 70
Expires: 0
Allow-Events: presence
Event: registration
User-Agent: Intellivic/PC
Allow: ACK, BYE, CANCEL, INVITE, MESSAGE, OPTIONS, REFER, PRACK
Content-Length: 0

Bold texts have the following meaning and you will have to replace them by:

  • msisdn - Your telephone number
  • password - Your password to movistar services
  • localIP - Local IP of your PC
  • callId - Random number to identify the register process
  • fromTag - Random number to identify the register process