]> sjero.net Git - linphone/blob - coreapi/help/doxygen.dox
update doxygen for linphoen 1.1 for IOS
[linphone] / coreapi / help / doxygen.dox
1 /**
2  * @mainpage
3  *
4  * @see http://www.linphone.org
5  *
6  * @section what_is_it What is liblinphone
7  *
8  * Liblinphone is a high level library for bringing SIP video call functionnality
9  * into an application. It aims at making easy the integration of the SIP
10  * video calls into any applications. All variants of linphone are directly based
11  * on it:
12  * - linphone (gtk interface)
13  *
14  * - linphonec (console interface)
15  *
16  * Liblinphone is GPL (see COPYING file). Please understand the licencing details
17  * before using it!
18  * 
19  * For any use of this library beyond the rights granted to you by the
20  * GPL license, please contact Belledonne Communications 
21  * (contact@belledonne-communications.com)
22  * 
23  *
24 **/
25
26 /**
27  * @page liblinphone_license COPYING 
28  * @include COPYING
29  */
30
31 /**
32  * @defgroup initializing Initializing liblinphone
33 **/
34
35 /**
36  * @defgroup call_control Placing and receiving calls
37  *
38  * The #LinphoneCall object represents an incoming or outgoing call managed by the #LinphoneCore.
39  * Outgoing calls can be created using linphone_core_invite() or linphone_core_invite_address(), while incoming calls are notified to the application
40  * through the LinphoneCoreVTable::call_state_changed callback.
41  *
42  * See the basic call \ref basic_call_tutorials "tutorial".
43  *
44 **/
45
46 /**
47  * @defgroup call_misc Obtaining information about a running call: sound volumes, quality indicators
48  *
49  * When a call is running, it is possible to retrieve in real time current measured volumes and quality indicator.
50  *
51 **/
52
53 /**
54  * @defgroup media_parameters Controlling media parameters
55 **/
56
57 /**
58  * @defgroup proxies Managing proxies
59  *User registration is controled by  #LinphoneProxyConfig settings.<br> Each #LinphoneProxyConfig object can be configured with registration informations 
60  *like \link linphone_proxy_config_set_server_addr() proxy address \endlink , \link linphone_proxy_config_set_identity() user id \endlink, \link linphone_proxy_config_expires() refresh period \endlink, and so on. 
61  *<br> A created proxy config using linphone_proxy_config_new(), once configured, must be added to #LinphoneCore using function linphone_core_add_proxy_config().
62  *<br> It is recommended to set a default \link #LinphoneProxyConfig proxy config \endlink using function linphone_core_set_default_proxy(). Once done, if \link #LinphoneProxyConfig a proxy config \endlink has been configured with attribute \link linphone_proxy_config_enable_register() enable register \endlink  , next call to linphone_core_iterate() triggers a SIP register.  
63  *<br> Registration status is reported by #LinphoneRegistrationStateCb.
64  *<br>
65  *<br> This pseudo code demonstrates basic registration operations:
66  *<br> \code
67  *      
68  *      LinphoneProxyConfig* proxy_cfg;
69  *      /*create proxy config*/
70  *      proxy_cfg = linphone_proxy_config_new();
71  *      /*parse identity*/
72  *      LinphoneAddress *from = linphone_address_new("sip:toto@sip.titi.com");
73  *      LinphoneAuthInfo *info;
74  *      if (password!=NULL){
75  *              info=linphone_auth_info_new(linphone_address_get_username(from),NULL,"secret",NULL,NULL); /*create authentication structure from identity*/
76  *              linphone_core_add_auth_info(lc,info); /*add authentication info to LinphoneCore*/
77  *      }       
78  *      // configure proxy entries
79  *      linphone_proxy_config_set_identity(proxy_cfg,identity); /*set identity with user name and domain*/
80  *      const char* server_addr = linphone_address_get_domain(from); /*extract domain address from identity*/
81  *      linphone_proxy_config_set_server_addr(proxy_cfg,server_addr); /* we assume domain = proxy server address*/
82  *      linphone_proxy_config_enable_register(proxy_cfg,TRUE); /*activate registration for this proxy config*/
83  *      linphone_address_destroy(from); /*release resource*/
84  *      
85  *      linphone_core_add_proxy_config(lc,proxy_cfg); /*add proxy config to linphone core*/
86  *      linphone_core_set_default_proxy(lc,proxy_cfg); /*set to default proxy*/ \endcode
87  *<br>
88  * Registration sate call back:
89  \code
90  static void registration_state_changed(struct _LinphoneCore *lc, LinphoneProxyConfig *cfg, LinphoneRegistrationState cstate, const char *message){
91                 printf("New registration state %s for user id [%s] at proxy [%s]\n"
92                                 ,linphone_registration_state_to_string(cstate)
93                                 ,linphone_proxy_config_get_identity(cfg)
94                                 ,linphone_proxy_config_get_addr(cfg));
95 }
96  \endcode
97  *<br><b>Authentication:</b>
98  *<br>Most of the time, registration requires \ref authentication "authentication" to succed. #LinphoneAuthInfo info must be either added to #LinphoneCore  using function linphone_core_add_auth_info() before #LinphoneProxyConfig is added to Linphone core, or on demand from call back #AuthInfoRequested .    
99  *<br>
100  *<br><b>Unregistration:</b>
101  *<br> Unregistration or any changes to #LinphoneProxyConfig must be first started by a call to function linphone_proxy_config_edit() and validated by  function linphone_proxy_config_done()
102  *<br> This pseudo code shows how to unregister a user associated to a #LinphoneProxyConfig
103  *\code
104         LinphoneProxyConfig* proxy_cfg;
105         linphone_core_get_default_proxy(lc,&proxy_cfg); /* get default proxy config*/
106         linphone_proxy_config_edit(proxy_cfg); /*start editing proxy configuration*/
107         linphone_proxy_config_enable_register(proxy_cfg,FALSE); /*de-activate registration for this proxy config*/
108         linphone_proxy_config_done(proxy_cfg); /*initiate REGISTER with expire = 0*/
109 \endcode
110         <br>
111         A complete tutorial can be found at : \ref registration_tutorials "Registration tutorial" 
112 **/
113
114 /**
115  * @defgroup network_parameters Controlling network parameters (ports, mtu...)
116 **/
117
118 /**
119  * @defgroup authentication Managing authentication: userid and passwords
120 **/
121
122 /**
123 * @defgroup buddy_list Managing Buddies and buddy list and presence 
124 <b>Buddies and buddy list</b>
125 <br>Each buddy is represented by a #LinphoneFriend object created by function linphone_friend_new(). 
126 Buddy configuration parameters like \link linphone_friend_set_addr() sip uri \endlink or  \link linphone_friend_set_inc_subscribe_policy() status publication \endlink policy for this \link #LinphoneFriend friend \endlink  are configurable for each buddy.
127 <br>Here under a typical buddy creation:
128 <br>
129 \code
130 LinphoneFriend* my_friend=linphone_friend_new_with_addr("sip:joe@sip.linphone.org"); /*creates friend object for buddy joe*/
131 linphone_friend_enable_subscribes(my_friend,TRUE); /*configure this friend to emit SUBSCRIBE message after being added to LinphoneCore*/
132 linphone_friend_set_inc_subscribe_policy(my_friend,LinphoneSPAccept); /* accept Incoming subscription request for this friend*/
133 \endcode
134 \link #LinphoneFriend  friends \endlink status changes are reported by callback LinphoneCoreVTable.notify_presence_recv
135 \code
136 static void notify_presence_recv_updated (struct _LinphoneCore *lc,  LinphoneFriend *friend) {
137         const LinphoneAddress* friend_address = linphone_friend_get_address(friend);
138         printf("New state state [%s] for user id [%s] \n"
139                                 ,linphone_online_status_to_string(linphone_friend_get_status(friend))
140                                 ,linphone_address_as_string (friend_address));
141 }
142 \endcode
143 <br>Once created a buddy can be added to the buddy list using function linphone_core_add_friend() . Added friends will be notified about \link linphone_core_set_presence_info() local status changes \endlink
144 <br>
145 Any subsequente modifications to #LinphoneFriend must be first started by a call to function linphone_friend_edit() and validated by  function linphone_friend_done()
146 \code
147 linphone_friend_edit(my_friend); /* start editing friend */
148 linphone_friend_enable_subscribes(my_friend,FALSE); /*disable subscription for this friend*/
149 linphone_friend_done(my_friend); /*commit changes triggering an UNSUBSCRIBE message*/
150 \endcode
151
152
153 <b> Publishing presence status </b>
154 <br>Local presence status can be changed using function linphone_core_set_presence_info() .New status is propagated to all friends \link linphone_core_add_friend() previously added \endlink to #LinphoneCore. 
155
156 <b>Handling incoming subscription request</b>
157 <br> New incoming subscription requests are process according to \link linphone_friend_set_inc_subscribe_policy() the incoming subscription policy state \endlink for subscription initiated by \link linphone_core_add_friend() members of the buddy list. \endlink
158 <br> For incoming request comming from an unknown buddy, the call back  LinphoneCoreVTable.new_subscription_request is invoked.
159
160 <br> A complete tutorial can be found at : \ref buddy_tutorials "Registration tutorial" 
161
162
163 **/
164
165 /**
166 * @defgroup chatroom Chat room and Messaging 
167 <b> Exchanging text messages</b>
168 <br> Messages are sent using #LinphoneChatRoom object. First step is to create a \link linphone_core_create_chat_room() chat room \endlink
169 from a peer sip uri.
170 \code
171 LinphoneChatRoom* chat_room = linphone_core_create_chat_room(lc,"sip:joe@sip.linphone.org");
172 \endcode
173
174 <br>Once created, messages are sent using function linphone_chat_room_send_message()  . 
175 \code
176 linphone_chat_room_send_message(chat_room,"Hello world"); /*sending message*/
177 \endcode
178 <br>Incoming message are received from call back LinphoneCoreVTable.text_received
179 \code
180 void text_received(LinphoneCore *lc, LinphoneChatRoom *room, const LinphoneAddress *from, const char *message) {
181         printf(" Message [%s] received from [%s] \n",message,linphone_address_as_string (from));
182 }
183 \endcode
184 <br> A complete tutorial can be found at : \ref chatroom_tuto "Chat room tutorial" 
185 **/
186
187 /**
188  * @defgroup call_logs Managing call logs
189 **/
190
191
192 /**
193  * @defgroup linphone_address SIP address parser API.
194  * This api is useful for manipulating SIP addresses ('from' or 'to' headers).
195 **/
196
197 /**
198  * @defgroup misc Miscenalleous: logs, version strings, config storage
199 **/
200
201 /**
202  * @defgroup tutorials Tutorials: 
203  *
204 **/
205
206 /**
207  * @defgroup port Portability: 
208  *
209 **/
210 /**
211  * @defgroup IOS IOS
212  * @ingroup port
213  *<br>
214  <b>Multitasking</b>
215  <br> Liblinphone for IOS natively supports multitasking assuming application follows multitasking guides provided by Apple. First step is to declare application as multitasked. It means adding background mode for both audio and voip to Info.plist file.
216  <br>
217  \code
218         <key>UIBackgroundModes</key>
219         <array>
220                 <string>voip</string>
221                 <string>audio</string>
222         </array>
223 \endcode
224 <br>
225 <ul>
226 <li><b>SIP socket </b><br>Recommended mode is SIP over TCP, because UDP usually requires frequent keep alives for maintaining NAT association at the IP router level. This can be as frequent as one UDP packet every 15 seconds to maintain the NAT association accross NAT routers. Doing such drains the battery very fast, and furthermore the iOS keep-alive designed by Apple to handle this task can only be called with a minimum of 10 minutes interval.<br>
227 For TCP, liblinphone automatically configures SIP socket for voip  (I.E kCFStreamNetworkServiceType set to kCFStreamNetworkServiceTypeVoIP). 
228 <br><b>Since IOS > 4.1 Apple disabled voip mode for UDP sockets </b> 
229 <li><b>Entering background mode</b>
230 <br> Before entering in background mode (through \code - (void)applicationDidEnterBackground:(UIApplication *)application \endcode  ), the application must first refresh sip registration using function #linphone_core_refresh_registers();
231 and register a keep-alive handler for periodically refreshing the registration. The speudo code below shows how to register a keep alive handler:
232 \code
233         //First refresh registration
234         linphone_core_refresh_registers(theLinphoneCore);
235         //wait for registration answer
236         int i=0;
237         while (!linphone_proxy_config_is_registered(proxyCfg) && i++<40 ) {
238                 linphone_core_iterate(theLinphoneCore);
239                 usleep(100000);
240         }
241         //register keepalive handler
242         [[UIApplication sharedApplication] setKeepAliveTimeout:600/*minimal interval is 600 s*/ 
243                                                        handler:^{
244                                                                 //refresh sip registration
245                                                                 linphone_core_refresh_registers(theLinphoneCore);
246                                                                 //make sure sip REGISTER is sent
247                                                                 linphone_core_iterate(theLinphoneCore);
248                                                                  }];
249 \endcode
250 <li><b>Incoming call notification while in background mode</b>
251 <br>Assuming application using liblinphone is well configured for multitasking, incoming calls arriving while liblinphone is in background mode will simply wakeup liblinphone thread but not resume GUI. To wakeup GUI, it is recommended to send a Local Notification to the user from the #LinphoneCallStateCb. Here under a speudo code for this operation:
252 \code
253         if ([UIApplication sharedApplication].applicationState !=  UIApplicationStateActive) {
254                 // Create a new notification
255                 UILocalNotification* notif = [[[UILocalNotification alloc] init] autorelease];
256                 if (notif) {
257                         notif.repeatInterval = 0;
258                         notif.alertBody =@"New incoming call";
259                         notif.alertAction = @"Answer";
260                         notif.soundName = @"oldphone-mono-30s.caf";
261                         
262                         [[UIApplication sharedApplication]  presentLocalNotificationNow:notif];
263                 }
264 \endcode
265 </ul>
266 <b>Networking</b>
267 <br>
268 <ul><li><b>WWAN connection</b>
269 <br>Liblinphone relies on iOS's standard BSD socket layer for sip/rtp networking. On IOS, WWAN connection is supposed to automatically bring up on any networking resquest issued by an application. At least on iPhone OS 3.x, BSD sockets do not implement this behavior. So it is recomended to add a special code to make sure the WWAN connection is properly setup. Pseudo code below describes a way to force WWAN connection by setting up a dummy TCP connection.
270 \code
271 /*start a new thread to avoid blocking the main ui in case of peer host failure*/
272 [NSThread detachNewThreadSelector:@selector(runNetworkConnection) toTarget:self withObject:nil];
273 -(void) runNetworkConnection {
274         CFWriteStreamRef writeStream;
275         //create a dummy socket
276         CFStreamCreatePairWithSocketToHost(NULL, (CFStringRef)@"192.168.0.200", 15000, nil, &writeStream);
277         CFWriteStreamOpen (writeStream);
278         const char* buff="hello";
279         //try to write on this socket
280         CFWriteStreamWrite (writeStream,(const UInt8*)buff,strlen(buff));
281         CFWriteStreamClose (writeStream);
282 }       
283 \endcode  
284 It is recommanded to perform this task each time the application is woken up, including keep alive handler.
285 <li><b>Managing IP connection state</b>
286 <br>Liblinphone for IOS relies on the application to be informed of network connectivity changes. Network state changes when the IP connection moves from DOWN to UP, or from WIFI to WWAN. Applications using liblinphone must inform libliblinphone of this changes using function #linphone_core_set_network_reachable(). Usually this method is called from the IOS NetworkReachability callback. Here under a sample code:
287 \code
288 //typical reachability callback
289 void networkReachabilityCallBack(SCNetworkReachabilityRef target, SCNetworkReachabilityFlags flags, void * info) {
290         if ((flags == 0) | (flags & (kSCNetworkReachabilityFlagsConnectionRequired |kSCNetworkReachabilityFlagsConnectionOnTraffic))) {
291                 //network state is off
292                 linphone_core_set_network_reachable(lc,false);
293                 ((LinphoneManager*)info).connectivity = none;
294         } else {
295                 Connectivity  newConnectivity = flags & kSCNetworkReachabilityFlagsIsWWAN ? wwan:wifi;
296                 if (lLinphoneMgr.connectivity == none) {
297                         //notify new network state
298                         linphone_core_set_network_reachable(lc,true);
299                 } else if (lLinphoneMgr.connectivity != newConnectivity) {
300                         // connectivity has changed
301                         linphone_core_set_network_reachable(lc,false);
302                         linphone_core_set_network_reachable(lc,true);
303                 }
304                 //store new connectivity status
305                 lLinphoneMgr.connectivity=newConnectivity;
306         }
307 }
308 }
309         
310 \endcode  
311 </ul>
312 <b> Sound cards </b>
313 <br> Since IOS 5.0, liblinphone supports 2 sound cards. <i>AU: Audio Unit Receiver</i> based on IO units for voice calls plus <i>AQ: Audio Queue Device</i> dedicated to rings. Here under the recommended settings (I.E default one)
314 \code
315         linphone_core_set_playback_device(lc, "AU: Audio Unit Receiver");
316         linphone_core_set_ringer_device(lc, "AQ: Audio Queue Device");
317         linphone_core_set_capture_device(lc, "AU: Audio Unit Receiver");
318 \endcode
319 <b> Video </b>
320 <br>Since 3.5 video support has been added to liblinphone for IOS. It requires the application to provide liblinphone with pointers to IOS's views hosting video display and video previous.
321 <br> These 2 UIView objects must be passed to the core using functions  #linphone_core_set_native_video_window_id() and #linphone_core_set_native_preview_window_id(). here under speudo code:
322 \code
323         UIView* display = [[UIView alloc] init];
324         UIView* preview = [[UIView alloc] init];
325         linphone_core_set_native_video_window_id(lc,(unsigned long)display);    
326         linphone_core_set_native_preview_window_id(lc,(unsigned long)preview);
327 \endcode
328 <br> Screen rotations are also handled by liblinphone. 2 positions are currently supported, namely <i>UIInterfaceOrientationPortrait</i> and <i>UIInterfaceOrientationLandscapeRight</i>. Applications may invoke #linphone_core_set_device_rotation() followed by #linphone_core_update_call() to notify liblinphone of an orientation change. Here under a speudo code to handle orientation changes
329 \code
330
331 -(void) configureOrientation:(UIInterfaceOrientation) oritentation  {
332         int oldLinphoneOrientation = linphone_core_get_device_rotation(lc);
333         if (oritentation == UIInterfaceOrientationPortrait ) {
334                 linphone_core_set_native_video_window_id(lc,(unsigned long)display-portrait);   
335                 linphone_core_set_native_preview_window_id(lc,(unsigned long)preview-portrait);
336                 linphone_core_set_device_rotation(lc, 0);
337                 
338         } else if (oritentation == UIInterfaceOrientationLandscapeRight ) {
339                 linphone_core_set_native_video_window_id(lc,(unsigned long)display-landscape);  
340                 linphone_core_set_native_preview_window_id(lc,(unsigned long)preview-landscape);
341                 linphone_core_set_device_rotation(lc, 270);
342         }
343         
344         if ((oldLinphoneOrientation != linphone_core_get_device_rotation(lc))
345                 && linphone_core_get_current_call(lc)) {
346                 //Orientation has changed, must call update call
347                 linphone_core_update_call(lc, linphone_core_get_current_call(lc), NULL);
348         }
349 }
350
351 \endcode
352
353 <b>DTMF feebacks</b>
354 <br>Liblinphone provides functions \link #linphone_core_play_dtmf() to play dtmf \endlink to the local user. Usually this is used to play a sound when the user presses a digit, inside or outside of any call. On IOS, libLinphone relies on AudioUnits for interfacing with the audio system. Unfortunately the Audio Unit initialization is a quite long operation that may trigger a bad user experience if performed each time a DTMF is played, the sound being delayed half a second after the press. To solve this issue and thus insure real-time precision, liblinphone introduces 2 functions for \link linphone_core_start_dtmf_stream() preloading \endlink and \link #linphone_core_start_dtmf_stream() unloading \endlink the underlying audio graph responsible for playing DTMFs.  
355 <br> For an application using function #linphone_core_play_dtmf(), it is recommanded to call #linphone_core_start_dtmf_stream() when entering in foreground and #linphone_core_stop_dtmf_stream() upon entering background mode. 
356 */
357