]> sjero.net Git - linphone/blob - coreapi/help/doxygen.dox
Add fmtp parameters to opus payload to enable FEC and DTX
[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  * - linphonec (console interface)
14  * - linphone for iOS
15  * - linphone for Android
16  *
17  * Liblinphone is GPL (see COPYING file). Please understand the licencing details
18  * before using it!
19  * 
20  * For any use of this library beyond the rights granted to you by the
21  * GPL license, please contact Belledonne Communications 
22  * (contact@belledonne-communications.com)
23  * 
24  *
25 **/
26
27 /**
28  * @page liblinphone_license COPYING 
29  * @include COPYING
30  */
31
32 /**
33  * @defgroup initializing Initializing liblinphone
34 **/
35
36 /**
37  * @defgroup call_control Placing and receiving calls
38  *
39  * The #LinphoneCall object represents an incoming or outgoing call managed by the #LinphoneCore.
40  * Outgoing calls can be created using linphone_core_invite() or linphone_core_invite_address(), while incoming calls are notified to the application
41  * through the LinphoneCoreVTable::call_state_changed callback.
42  *
43  * See the basic call \ref basic_call_tutorials "tutorial".
44  *
45 **/
46
47 /**
48  * @defgroup call_misc Obtaining information about a running call: sound volumes, quality indicators
49  *
50  * When a call is running, it is possible to retrieve in real time current measured volumes and quality indicator.
51  *
52 **/
53
54 /**
55  * @defgroup media_parameters Controlling media parameters
56 **/
57
58 /**
59  * @defgroup proxies Managing proxies
60  *User registration is controled by  #LinphoneProxyConfig settings.<br> Each #LinphoneProxyConfig object can be configured with registration informations 
61  *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. 
62  *<br> A created proxy config using linphone_proxy_config_new(), once configured, must be added to #LinphoneCore using function linphone_core_add_proxy_config().
63  *<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.  
64  *<br> Registration status is reported by #LinphoneRegistrationStateCb.
65  *<br>
66  *<br> This pseudo code demonstrates basic registration operations:
67  *<br> \code
68  *      
69  *      LinphoneProxyConfig* proxy_cfg;
70  *      /*create proxy config*/
71  *      proxy_cfg = linphone_proxy_config_new();
72  *      /*parse identity*/
73  *      LinphoneAddress *from = linphone_address_new("sip:toto@sip.titi.com");
74  *      LinphoneAuthInfo *info;
75  *      if (password!=NULL){
76  *              info=linphone_auth_info_new(linphone_address_get_username(from),NULL,"secret",NULL,NULL); /*create authentication structure from identity*/
77  *              linphone_core_add_auth_info(lc,info); /*add authentication info to LinphoneCore*/
78  *      }       
79  *      // configure proxy entries
80  *      linphone_proxy_config_set_identity(proxy_cfg,identity); /*set identity with user name and domain*/
81  *      const char* server_addr = linphone_address_get_domain(from); /*extract domain address from identity*/
82  *      linphone_proxy_config_set_server_addr(proxy_cfg,server_addr); /* we assume domain = proxy server address*/
83  *      linphone_proxy_config_enable_register(proxy_cfg,TRUE); /*activate registration for this proxy config*/
84  *      linphone_address_destroy(from); /*release resource*/
85  *      
86  *      linphone_core_add_proxy_config(lc,proxy_cfg); /*add proxy config to linphone core*/
87  *      linphone_core_set_default_proxy(lc,proxy_cfg); /*set to default proxy*/ \endcode
88  *<br>
89  * Registration sate call back:
90  \code
91  static void registration_state_changed(struct _LinphoneCore *lc, LinphoneProxyConfig *cfg, LinphoneRegistrationState cstate, const char *message){
92                 printf("New registration state %s for user id [%s] at proxy [%s]\n"
93                                 ,linphone_registration_state_to_string(cstate)
94                                 ,linphone_proxy_config_get_identity(cfg)
95                                 ,linphone_proxy_config_get_addr(cfg));
96 }
97  \endcode
98  *<br><b>Authentication:</b>
99  *<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 .    
100  *<br>
101  *<br><b>Unregistration:</b>
102  *<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()
103  *<br> This pseudo code shows how to unregister a user associated to a #LinphoneProxyConfig
104  *\code
105         LinphoneProxyConfig* proxy_cfg;
106         linphone_core_get_default_proxy(lc,&proxy_cfg); /* get default proxy config*/
107         linphone_proxy_config_edit(proxy_cfg); /*start editing proxy configuration*/
108         linphone_proxy_config_enable_register(proxy_cfg,FALSE); /*de-activate registration for this proxy config*/
109         linphone_proxy_config_done(proxy_cfg); /*initiate REGISTER with expire = 0*/
110 \endcode
111         <br>
112         A complete tutorial can be found at : \ref registration_tutorials "Registration tutorial" 
113 **/
114
115 /**
116  * @defgroup network_parameters Controlling network parameters (ports, mtu...)
117 **/
118
119 /**
120  * @defgroup authentication Managing authentication: userid and passwords
121 **/
122
123 /**
124 * @defgroup buddy_list Managing Buddies and buddy list and presence 
125 <b>Buddies and buddy list</b>
126 <br>Each buddy is represented by a #LinphoneFriend object created by function linphone_friend_new(). 
127 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.
128 <br>Here under a typical buddy creation:
129 <br>
130 \code
131 LinphoneFriend* my_friend=linphone_friend_new_with_addr("sip:joe@sip.linphone.org"); /*creates friend object for buddy joe*/
132 linphone_friend_enable_subscribes(my_friend,TRUE); /*configure this friend to emit SUBSCRIBE message after being added to LinphoneCore*/
133 linphone_friend_set_inc_subscribe_policy(my_friend,LinphoneSPAccept); /* accept Incoming subscription request for this friend*/
134 \endcode
135 \link #LinphoneFriend  friends \endlink status changes are reported by callback LinphoneCoreVTable.notify_presence_recv
136 \code
137 static void notify_presence_recv_updated (struct _LinphoneCore *lc,  LinphoneFriend *friend) {
138         const LinphoneAddress* friend_address = linphone_friend_get_address(friend);
139         printf("New state state [%s] for user id [%s] \n"
140                                 ,linphone_online_status_to_string(linphone_friend_get_status(friend))
141                                 ,linphone_address_as_string (friend_address));
142 }
143 \endcode
144 <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
145 <br>
146 Any subsequente modifications to #LinphoneFriend must be first started by a call to function linphone_friend_edit() and validated by  function linphone_friend_done()
147 \code
148 linphone_friend_edit(my_friend); /* start editing friend */
149 linphone_friend_enable_subscribes(my_friend,FALSE); /*disable subscription for this friend*/
150 linphone_friend_done(my_friend); /*commit changes triggering an UNSUBSCRIBE message*/
151 \endcode
152
153
154 <b> Publishing presence status </b>
155 <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. 
156
157 <b>Handling incoming subscription request</b>
158 <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
159 <br> For incoming request comming from an unknown buddy, the call back  LinphoneCoreVTable.new_subscription_request is invoked.
160
161 <br> A complete tutorial can be found at : \ref buddy_tutorials "Registration tutorial" 
162
163
164 **/
165
166 /**
167 * @defgroup chatroom Chat room and Messaging 
168 <b> Exchanging text messages</b>
169 <br> Messages are sent using #LinphoneChatRoom object. First step is to create a \link linphone_core_create_chat_room() chat room \endlink
170 from a peer sip uri.
171 \code
172 LinphoneChatRoom* chat_room = linphone_core_create_chat_room(lc,"sip:joe@sip.linphone.org");
173 \endcode
174
175 <br>Once created, messages are sent using function linphone_chat_room_send_message()  . 
176 \code
177 linphone_chat_room_send_message(chat_room,"Hello world"); /*sending message*/
178 \endcode
179 <br>Incoming message are received from call back LinphoneCoreVTable.text_received
180 \code
181 void text_received(LinphoneCore *lc, LinphoneChatRoom *room, const LinphoneAddress *from, const char *message) {
182         printf(" Message [%s] received from [%s] \n",message,linphone_address_as_string (from));
183 }
184 \endcode
185 <br> A complete tutorial can be found at : \ref chatroom_tuto "Chat room tutorial" 
186 **/
187
188 /**
189  * @defgroup call_logs Managing call logs
190 **/
191
192
193 /**
194  * @defgroup linphone_address SIP address parser API.
195  * This api is useful for manipulating SIP addresses ('from' or 'to' headers).
196 **/
197
198 /**
199  * @defgroup conferencing Making an audio conference.
200  * This API allows to create a conference entirely managed by the client. No server capabilities are required.
201  * The way such conference is created is by doing the following:<br>
202  * The application shall makes "normal" calls to several destinations (using linphone_core_invite() ), one after another. 
203  * While initiating the second call, the first one is automatically paused.
204  * Then, once the second call is established, the application has the possibility to merge the two calls to form a conference where each participant
205  * (the local participant, the remote destination of the first call, the remote destination of the second call) can talk together.
206  * This must be done by adding the two calls to the conference using \link linphone_call_add_to_conference() \endlink
207  *
208  * Once merged into a conference the LinphoneCall objects representing the calls that were established remain unchanged, except that 
209  * they are tagged as part of the conference (see \link linphone_call_is_in_conference() \endlink ). The calls in a conference are in the LinphoneCallStreamsRunning state.
210  * 
211  * Only a single conference can be created: the purpose of this feature is to allow the local user to create, take part and manage the conference. 
212  * This API is not designed to create a conference server application.
213  *
214  * Up to 10 calls can be merged into the conference, however depending on the CPU usage required for doing the encoding/decoding of the streams of each participants,
215  * the effective limit can be lower.
216  * 
217 **/
218
219 /**
220  * @defgroup misc Miscenalleous: logs, version strings, config storage
221 **/
222
223 /**
224  * @defgroup tutorials Tutorials: 
225  *
226 **/
227
228 /**
229  * @defgroup port Portability: 
230  *
231 **/
232 /**
233  * @defgroup IOS IOS
234  * @ingroup port
235  *<br>
236  <b>Multitasking</b>
237  <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.
238  <br>
239  \code
240         <key>UIBackgroundModes</key>
241         <array>
242                 <string>voip</string>
243                 <string>audio</string>
244         </array>
245 \endcode
246 <br>
247 <ul>
248 <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>
249 For TCP, liblinphone automatically configures SIP socket for voip  (I.E kCFStreamNetworkServiceType set to kCFStreamNetworkServiceTypeVoIP). 
250 <br><b>Since IOS > 4.1 Apple disabled voip mode for UDP sockets </b> 
251 <li><b>Entering background mode</b>
252 <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();
253 and register a keep-alive handler for periodically refreshing the registration. The speudo code below shows how to register a keep alive handler:
254 \code
255         //First refresh registration
256         linphone_core_refresh_registers(theLinphoneCore);
257         //wait for registration answer
258         int i=0;
259         while (!linphone_proxy_config_is_registered(proxyCfg) && i++<40 ) {
260                 linphone_core_iterate(theLinphoneCore);
261                 usleep(100000);
262         }
263         //register keepalive handler
264         [[UIApplication sharedApplication] setKeepAliveTimeout:600/*minimal interval is 600 s*/ 
265                                                        handler:^{
266                                                                 //refresh sip registration
267                                                                 linphone_core_refresh_registers(theLinphoneCore);
268                                                                 //make sure sip REGISTER is sent
269                                                                 linphone_core_iterate(theLinphoneCore);
270                                                                  }];
271 \endcode
272 <li><b>Incoming call notification while in background mode</b>
273 <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:
274 \code
275         if ([UIApplication sharedApplication].applicationState !=  UIApplicationStateActive) {
276                 // Create a new notification
277                 UILocalNotification* notif = [[[UILocalNotification alloc] init] autorelease];
278                 if (notif) {
279                         notif.repeatInterval = 0;
280                         notif.alertBody =@"New incoming call";
281                         notif.alertAction = @"Answer";
282                         notif.soundName = @"oldphone-mono-30s.caf";
283                         
284                         [[UIApplication sharedApplication]  presentLocalNotificationNow:notif];
285                 }
286 \endcode
287 </ul>
288 <b>Networking</b>
289 <br>
290 <ul><li><b>WWAN connection</b>
291 <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.
292 \code
293 /*start a new thread to avoid blocking the main ui in case of peer host failure*/
294 [NSThread detachNewThreadSelector:@selector(runNetworkConnection) toTarget:self withObject:nil];
295 -(void) runNetworkConnection {
296         CFWriteStreamRef writeStream;
297         //create a dummy socket
298         CFStreamCreatePairWithSocketToHost(NULL, (CFStringRef)@"192.168.0.200", 15000, nil, &writeStream);
299         CFWriteStreamOpen (writeStream);
300         const char* buff="hello";
301         //try to write on this socket
302         CFWriteStreamWrite (writeStream,(const UInt8*)buff,strlen(buff));
303         CFWriteStreamClose (writeStream);
304 }       
305 \endcode  
306 It is recommanded to perform this task each time the application is woken up, including keep alive handler.
307 <li><b>Managing IP connection state</b>
308 <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:
309 \code
310 //typical reachability callback
311 void networkReachabilityCallBack(SCNetworkReachabilityRef target, SCNetworkReachabilityFlags flags, void * info) {
312         if ((flags == 0) | (flags & (kSCNetworkReachabilityFlagsConnectionRequired |kSCNetworkReachabilityFlagsConnectionOnTraffic))) {
313                 //network state is off
314                 linphone_core_set_network_reachable(lc,false);
315                 ((LinphoneManager*)info).connectivity = none;
316         } else {
317                 Connectivity  newConnectivity = flags & kSCNetworkReachabilityFlagsIsWWAN ? wwan:wifi;
318                 if (lLinphoneMgr.connectivity == none) {
319                         //notify new network state
320                         linphone_core_set_network_reachable(lc,true);
321                 } else if (lLinphoneMgr.connectivity != newConnectivity) {
322                         // connectivity has changed
323                         linphone_core_set_network_reachable(lc,false);
324                         linphone_core_set_network_reachable(lc,true);
325                 }
326                 //store new connectivity status
327                 lLinphoneMgr.connectivity=newConnectivity;
328         }
329 }
330 }
331         
332 \endcode  
333 </ul>
334 <b> Sound cards </b>
335 <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)
336 \code
337         linphone_core_set_playback_device(lc, "AU: Audio Unit Receiver");
338         linphone_core_set_ringer_device(lc, "AQ: Audio Queue Device");
339         linphone_core_set_capture_device(lc, "AU: Audio Unit Receiver");
340 \endcode
341 <b> GSM call interaction </b>
342 <br> To ensure gentle interaction with GSM calls, it is recommended to register an AudioSession delegate. This allows the application to be notified when its audio session is interrupted/resumed (presumably by a GSM call).
343 \code
344     // declare a class handling the AVAudioSessionDelegate protocol
345     @interface MyClass : NSObject <AVAudioSessionDelegate> { [...] }
346     // implement 2 methods : here's an example implementation
347     -(void) beginInterruption {
348         LinphoneCall* c = linphone_core_get_current_call(theLinphoneCore);
349         ms_message("Sound interruption detected!");
350         if (c) {
351             linphone_core_pause_call(theLinphoneCore, c);
352         }
353     }
354
355     -(void) endInterruption {
356         ms_message("Sound interruption ended!");
357         const MSList* c = linphone_core_get_calls(theLinphoneCore);
358     
359         if (c) {
360             ms_message("Auto resuming call");
361             linphone_core_resume_call(theLinphoneCore, (LinphoneCall*) c->data);
362         }
363     }
364 \endcode
365 @see http://developer.apple.com/library/ios/#documentation/AVFoundation/Reference/AVAudioSessionDelegate_ProtocolReference/Reference/Reference.html
366
367 <br> Declare an instance of your class as AudioSession's delegate :
368 \code
369     [audioSession setDelegate:myClassInstance];
370 \endcode
371 @see http://developer.apple.com/library/ios/#documentation/AVFoundation/Reference/AVAudioSession_ClassReference/Reference/Reference.html
372
373 <b> Video </b>
374 <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.
375 <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:
376 \code
377         UIView* display = [[UIView alloc] init];
378         UIView* preview = [[UIView alloc] init];
379         linphone_core_set_native_video_window_id(lc,(unsigned long)display);    
380         linphone_core_set_native_preview_window_id(lc,(unsigned long)preview);
381 \endcode
382 <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
383 \code
384
385 -(void) configureOrientation:(UIInterfaceOrientation) oritentation  {
386         int oldLinphoneOrientation = linphone_core_get_device_rotation(lc);
387         if (oritentation == UIInterfaceOrientationPortrait ) {
388                 linphone_core_set_native_video_window_id(lc,(unsigned long)display-portrait);   
389                 linphone_core_set_native_preview_window_id(lc,(unsigned long)preview-portrait);
390                 linphone_core_set_device_rotation(lc, 0);
391                 
392         } else if (oritentation == UIInterfaceOrientationLandscapeRight ) {
393                 linphone_core_set_native_video_window_id(lc,(unsigned long)display-landscape);  
394                 linphone_core_set_native_preview_window_id(lc,(unsigned long)preview-landscape);
395                 linphone_core_set_device_rotation(lc, 270);
396         }
397         
398         if ((oldLinphoneOrientation != linphone_core_get_device_rotation(lc))
399                 && linphone_core_get_current_call(lc)) {
400                 //Orientation has changed, must call update call
401                 linphone_core_update_call(lc, linphone_core_get_current_call(lc), NULL);
402         }
403 }
404
405 \endcode
406
407 <b>DTMF feebacks</b>
408 <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.  
409 <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. 
410 */
411