UCT IMS Client Source Code Analysis
Overview
It is an IMS user agent based on osip/eXsip library. The source code the document analyzes is uctimsclient1.0.6
• Feature list:
– AKAv1 and AKAv2 registration
– Subscribe to reg event and watcher info event
– instant messaging
– DTMF tones via SIP INFO messages
– Presence support
– XCAP Presence Rules Support
• Depends on following open source lib:
– libosip2
– libeXosip2
– Gstreamer libraries
– libgtk2
• File List
– Entry
• imsUA.c: application entry, create GUI, init eXosip2 library and fetch events from eXosip2 library
– GUI
• Interface.c: used to create GUI and set GUI signal handler
• Callback.c: GUI signal handlers
• Ims_interface_event_handler.c: functions called by signal handlers in callback.c
• Common_interface_event_handler.c: functions called by event handlers in callback.c
• Preferences.c: used to set preference parameters
• Presence.c: edit and show presence info
• Watchers.c: list who are interested in your presence info
• Xcap.c: handler XDMS manager
– eXosip event
• Ims_exosip_event_handler.c: callback called by eXosip2 library
• Common_exosip_event_handler.c: common functions called by callbacks in Ims_exosip_event_handler.c
• Media.c: common functions called by callbacks in Ims_exosip_event_handler.c
– authentication
• DigestAKAv1MD5.c
• Base64.c
• Md5.c
• Rfc2617.c
– media:
• Gstreamer.c: used to set GStreamer pipeline for audio and video call
– Utilities:
• Support.c: utilities for GUI fuctions
• Useful_method.c: utilities for processing SIP message
• Sdp_method.c: used to build SDP parameters for SIP message
– SIP-to-IMS Gateway(not used)
• Milenage.c
• Rijndael.c
• Sound_conv.c
startup process
create_imsUA: create GUI, and set signal handler for each GUI component
initialise_eXosip
set eXosip event process function get_exosip_events: all events from eXosip is fetched by this function, and then handle in Ims_exosip_event_handler.c
Registration Process
User click “Registration”:
on_register2_activate --->ims_send_register:
Build and send a register request(eXosip_register_send_register)
Wait for event EXOSIP_REGISTRATION_FAILURE:
If error code is 401, it does not mean registration failed, it means we need to do authentication:
ims_process_401: build an another register request with authentication info, and send it.
wait for event EXOSIP_REGISTRATION_SUCCESS:
ims_process_registration_200ok:
subscribe presence info and watchers info
Presence and watcher
When any buddy is online or update its presence info, or anyone subscribes your presence info, the event EXOSIP_SUBSCRIPTION_NOTIFY will be received:
ims_process_notify:
presence_process_notify to handle presence info, or watchers_process_notify to handle watch info
Calling Process
User click “Call or answer”button:
on_call_button_clicked---ims_call_initiate--ims_call_initiate
build and send a invite request(eXosip_call_send_initial_invite)
wait for event EXOSIP_CALL_RINGING:
ims_process_18x:
(the status code is 183 on the first round)
if require 180rel: build and send a prack(eXosip_call_send_prack)
wait fro event EXOSIP_CALL_MESSAGE_ANSWERED:
ims_process_2xx:
build and send update message: eXosip_call_build_update and eXosip_call_send_request
wait for message EXOSIP_CALL_RINGING:
ims_process_18x:
(the status code is 180 on the second round)
initialiseRingingPipeline: initialize GStreamer ringing pipeline.
wait until remote accept or reject the call:
EXOSIP_CALL_ANSWERED means accept call:
ims_process_200ok:
build and send an ack message.
start_rtp_session: destroy GStreamer ringing pipeline, and start GStreamer voice and video pipeline
Incoming Call:
event EXOSIP_CALL_INVITE:
ims_process_incoming_invite
if busy at this moment, send reject(eXosip_call_send_answer(je->tid, 486, NULL))
build and send answer: (eXosip_call_send_answer(je->tid, 183, session_progress))
wait EXOSIP_CALL_MESSAGE_NEW:
ims_process_prack: (why there is no place to send an ack for prack?)
build and send answer(eXosip_call_send_answer)
initialiseRingingPipeline: initialize GStreamer ringing pipeline.
if user click “call or answer” button:
on_call_button_clicked---- ims_call_answer
build and send answer(eXosip_call_send_answer)
wait for event EXOSIP_CALL_ACK:
ims_process_ack:
start_rtp_session: destroy GStreamer ringing pipeline, and start GStreamer voice and video pipeline
If user click “hangup or refuse” button:
on_hangup_button_clicked--- terminate_call
DTMF:
click “DTMF digits” buttons during call:
common_send_dtmf:
create and send request: eXosip_call_build_info and eXosip_call_send_request
IM
user click “start chat” button:
on_start_chat_clicked--ims_open_im_window:
if no IM window, create_im_window: connect signal
g_signal_connect ((gpointer) send_im_button, "clicked",
G_CALLBACK (on_send_im_button_clicked),
NULL);
the peer who receives IM message:
receives event EXOSIP_MESSAGE_NEW:
ims_start_im_session:
if no IM window, create_im_window: connect signal
g_signal_connect ((gpointer) send_im_button, "clicked",
G_CALLBACK (on_send_im_button_clicked),
NULL);
on_send_im_button_clicked:
ims_send_instant_message: build and send message(eXosip_message_send_request)