Index: configure
===================================================================
--- configure	(.../vendor/linphone/linphone-2.1.1)	(revision 3519)
+++ configure	(.../trunk/RemoteStations/Koala_baobab/ThirdPartyLibs/linphone)	(revision 3519)
@@ -26457,7 +26457,7 @@
 
 
 
-ac_config_files="$ac_config_files Makefile m4/Makefile po/Makefile.in pixmaps/Makefile ipkg/Makefile ipkg/linphone.control media_api/Makefile coreapi/Makefile gtk/Makefile console/Makefile share/Makefile share/C/Makefile share/fr/Makefile share/it/Makefile share/ja/Makefile share/cs/Makefile share/linphone.pc linphone.spec"
+ac_config_files="$ac_config_files Makefile m4/Makefile po/Makefile.in pixmaps/Makefile ipkg/Makefile ipkg/linphone.control media_api/Makefile coreapi/Makefile gtk/Makefile console/Makefile share/Makefile share/C/Makefile share/fr/Makefile share/it/Makefile share/ja/Makefile share/cs/Makefile share/linphone.pc linphone.spec daemon/Makefile"
 
 cat >confcache <<\_ACEOF
 # This file is a shell script that caches the results of configure
@@ -27148,6 +27148,7 @@
     "share/cs/Makefile") CONFIG_FILES="$CONFIG_FILES share/cs/Makefile" ;;
     "share/linphone.pc") CONFIG_FILES="$CONFIG_FILES share/linphone.pc" ;;
     "linphone.spec") CONFIG_FILES="$CONFIG_FILES linphone.spec" ;;
+    "daemon/Makefile") CONFIG_FILES="$CONFIG_FILES daemon/Makefile" ;;
     "po/stamp-it") CONFIG_COMMANDS="$CONFIG_COMMANDS po/stamp-it" ;;
 
   *) { { echo "$as_me:$LINENO: error: invalid argument: $ac_config_target" >&5
Index: Makefile.in
===================================================================
--- Makefile.in	(.../vendor/linphone/linphone-2.1.1)	(revision 3519)
+++ Makefile.in	(.../trunk/RemoteStations/Koala_baobab/ThirdPartyLibs/linphone)	(revision 3519)
@@ -69,7 +69,7 @@
 ETAGS = etags
 CTAGS = ctags
 DIST_SUBDIRS = m4 pixmaps po ipkg oRTP mediastreamer2 media_api \
-	coreapi console gtk share
+	coreapi console gtk share daemon
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
 distdir = $(PACKAGE)-$(VERSION)
 top_distdir = $(distdir)
@@ -272,7 +272,7 @@
 @EXTERNAL_ORTP_FALSE@ORTP_DIR = oRTP
 @EXTERNAL_ORTP_TRUE@ORTP_DIR = 
 SUBDIRS = m4 pixmaps po ipkg $(ORTP_DIR) mediastreamer2\
-		media_api coreapi console gtk share
+		media_api coreapi console gtk share daemon
 
 EXTRA_DIST = config.rpath   linphone2.glade BUGS linphone.kdevprj \
 				intltool-extract.in	\
Index: mediastreamer2/src/oss.c
===================================================================
--- mediastreamer2/src/oss.c	(.../vendor/linphone/linphone-2.1.1)	(revision 3519)
+++ mediastreamer2/src/oss.c	(.../trunk/RemoteStations/Koala_baobab/ThirdPartyLibs/linphone)	(revision 3519)
@@ -35,8 +35,76 @@
 MSFilter *ms_oss_read_new(MSSndCard *card);
 MSFilter *ms_oss_write_new(MSSndCard *card);
 
-static int oss_open(const char *devname, int bits,int stereo, int rate, int *minsz)
+
+int (*read_dsp)(int fd, void* buf, size_t size);
+int (*write_dsp)(int fd, void* buf, size_t size);
+
+
+static int read_stereo (int fd, const void* buf, size_t count)
 {
+    /* Hack to read a single stream from an stereo channel */
+
+    uint8_t* new_buff;
+    int i;
+    int r;
+
+    new_buff = malloc (count * 2);
+
+    r = read (fd, (void*) new_buff, count * 2);
+
+    if (r < 0) 
+    {
+        free (new_buff);
+        return r/2;
+    }
+
+    for (i=0; i<count; i=i+2)
+    {
+        ((uint8_t*) buf)[i]   = new_buff[i*2];
+        ((uint8_t*) buf)[i+1] = new_buff[i*2+1];
+    } 
+
+    free (new_buff);
+
+    return r / 2;
+}
+
+
+static int write_stereo (int fd, const void* buf, size_t count) 
+{
+    /* Hack to write single stream to an stereo channel */
+
+    uint8_t* new_buff;
+    int i;
+
+    new_buff = malloc (count * 2);
+
+    for (i=0; i<count; i=i+2)
+    {
+        new_buff[i*2]  =((uint8_t*) buf)[i];
+        new_buff[i*2+1]=((uint8_t*) buf)[i+1];
+        new_buff[i*2+2]=((uint8_t*) buf)[i];
+        new_buff[i*2+3]=((uint8_t*) buf)[i+1];
+    }
+
+    i = write (fd, new_buff, count * 2);
+
+    free (new_buff);
+
+    return i / 2;
+}
+
+
+
+
+
+static int oss_open(const char *devname, 
+                    int bits,
+                    int stereo, 
+                    int rate, 
+                    int *minsz,
+                    int flags)
+{
 	int fd;
 	int p=0,cond=0;
 	int i=0;
@@ -44,9 +112,10 @@
 	int err;
 	int frag;
 	audio_buf_info info;
-  
-	//g_message("opening sound device");
-	fd=open(devname,O_RDWR|O_NONBLOCK);
+
+
+//	fd=open(devname,O_RDWR|O_NONBLOCK);
+	fd=open(devname, flags | O_NONBLOCK);
 	if (fd<0) return -EWOULDBLOCK;
 	/* unset nonblocking mode */
 	/* We wanted non blocking open but now put it back to normal ; thanks Xine !*/
@@ -87,9 +156,22 @@
 	if (err<0){
 		ms_warning("oss_open: can't set mono/stereo mode:%s.",strerror(errno));
 	}
-	
-	if (rate==16000) blocksize=4096;	/* oss emulation is not very good at 16khz */
-	else blocksize=blocksize*(rate/8000);
+
+    if (p == 1 && stereo == 0)
+    {
+        ms_warning("mono requested but device only accepts stereo.\n");
+        ms_warning("overwriting read/write functions.\n");
+
+        read_dsp = read_stereo;
+        write_dsp = write_stereo;
+    }
+
+
+	if (rate==16000)
+        blocksize=4096;	/* oss emulation is not very good at 16khz */
+	else 
+        blocksize=blocksize*(rate/8000);
+
 	ioctl(fd, SNDCTL_DSP_GETBLKSIZE, &min_size);
 
 	/* try to subdivide BLKSIZE to reach blocksize if necessary */
@@ -114,9 +196,6 @@
 		min_size=blocksize;
 	}
 
-	ms_message("/dev/dsp opened: rate=%i,bits=%i,stereo=%i blocksize=%i.",
-			rate,bits,stereo,min_size);
-	
 	if( ioctl( fd, SNDCTL_DSP_GETISPACE, &info ) == -1 ) {
 		ms_warning("oss_open: can't get ispace:%s.",strerror(errno));
 	}
@@ -140,7 +219,8 @@
 typedef struct OssData{
 	char *pcmdev;
 	char *mixdev;
-	int pcmfd;
+	int read_fd;
+    int write_fd;
 	int rate;
 	int bits;
 	ms_thread_t thread;
@@ -229,7 +309,8 @@
 	OssData *d=ms_new(OssData,1);
 	d->pcmdev=NULL;
 	d->mixdev=NULL;
-	d->pcmfd=-1;
+	d->read_fd=-1;
+    d->write_fd=-1;
 	d->read_started=FALSE;
 	d->write_started=FALSE;
 	d->bits=16;
@@ -239,6 +320,8 @@
 	d->bufferizer=ms_bufferizer_new();
 	ms_mutex_init(&d->mutex,NULL);
 	card->data=d;
+    write_dsp = write;
+    read_dsp = read;
 }
 
 static void oss_uninit(MSSndCard *card){
@@ -309,6 +392,7 @@
 	}
 }
 
+
 static void * oss_thread(void *p){
 	MSSndCard *card=(MSSndCard*)p;
 	OssData *d=(OssData*)card->data;
@@ -317,18 +401,29 @@
 	uint8_t *wtmpbuff=NULL;
 	int err;
 	mblk_t *rm=NULL;
-	d->pcmfd=oss_open(d->pcmdev,d->bits,d->stereo,d->rate,&bsize);
-	if (d->pcmfd>=0){
+
+	d->read_fd=oss_open(d->pcmdev,d->bits,d->stereo,d->rate,&bsize, O_RDONLY);
+	d->write_fd=oss_open(d->pcmdev,d->bits,d->stereo,d->rate,&bsize, O_WRONLY);
+
+	if (d->read_fd >= 0) {
 		rtmpbuff=(uint8_t*)malloc(bsize);
+
+		if(rtmpbuff == NULL) {
+			free(rtmpbuff);
+			return NULL;
+        }
+    }
+
+    if (d->write_fd >= 0) {
 		wtmpbuff=(uint8_t*)malloc(bsize);
-		if(rtmpbuff == NULL || wtmpbuff == NULL) {
-			free(rtmpbuff);
+		if(wtmpbuff == NULL) {
 			free(wtmpbuff);
 			return NULL;
 		}
 	}
+
 	while(d->read_started || d->write_started){
-		if (d->pcmfd>=0){
+		if (d->read_fd>=0){
 			if (d->read_started){
 				struct timeval timeout;
 				fd_set read_fds;
@@ -338,14 +433,14 @@
 				timeout.tv_sec = 0;
 				timeout.tv_usec = 0;
 				FD_ZERO( &read_fds );
-				FD_SET( d->pcmfd, &read_fds );
-				if( select( d->pcmfd + 1, &read_fds, NULL, NULL, &timeout ) == -1 ) {
+				FD_SET( d->read_fd, &read_fds );
+				if( select( d->read_fd + 1, &read_fds, NULL, NULL, &timeout ) == -1 ) {
 				}
-				if (FD_ISSET( d->pcmfd, &read_fds ) &&  ioctl( d->pcmfd, SNDCTL_DSP_GETISPACE, &info ) != -1)
+				if (FD_ISSET( d->read_fd, &read_fds ) &&  ioctl( d->read_fd, SNDCTL_DSP_GETISPACE, &info ) != -1)
 				{
 					if (info.bytes>=bsize)
 					{
-						err=read(d->pcmfd,rm->b_wptr,bsize);
+						err=read_dsp(d->read_fd,rm->b_wptr,bsize);
 						if (err<0){
 							ms_warning("Fail to read %i bytes from soundcard: %s",
 								   bsize,strerror(errno));
@@ -371,13 +466,13 @@
 				    select(0, 0, NULL, NULL, &timeout );
 				  }
 			}else {
-				int sz = read(d->pcmfd,rtmpbuff,bsize);
+				int sz = read_dsp(d->read_fd,rtmpbuff,bsize);
 				if( sz!=bsize) ms_warning("sound device read returned %i !",sz);
 			}
 			if (d->write_started){
 
 				audio_buf_info info;
-				if( ms_bufferizer_get_avail(d->bufferizer)>=bsize && ioctl( d->pcmfd, SNDCTL_DSP_GETOSPACE, &info ) == 0 ) {
+				if( ms_bufferizer_get_avail(d->bufferizer)>=bsize && ioctl( d->write_fd, SNDCTL_DSP_GETOSPACE, &info ) == 0 ) {
 					if( info.fragstotal - info.fragments > 15 ) {
 						static int c=0;
 						/* drop the fragment if the buffer starts to fill up */
@@ -399,7 +494,7 @@
 						ms_mutex_lock(&d->mutex);
 						err=ms_bufferizer_read(d->bufferizer,wtmpbuff,bsize);
 						ms_mutex_unlock(&d->mutex);
-						err=write(d->pcmfd,wtmpbuff,bsize);
+						err=write_dsp(d->write_fd,wtmpbuff,bsize);
 						if (err<0){
 							ms_warning("Fail to write %i bytes from soundcard: %s",
 								   bsize,strerror(errno));
@@ -410,15 +505,20 @@
 			}else {
 				int sz;
 				memset(wtmpbuff,0,bsize);
-				sz = write(d->pcmfd,wtmpbuff,bsize);
+				sz = write_dsp(d->write_fd,wtmpbuff,bsize);
 				if( sz!=bsize) ms_warning("sound device write returned %i !",sz);
 			}
 		}else usleep(20000);
 	}
-	if (d->pcmfd>=0) {
-		close(d->pcmfd);
-		d->pcmfd=-1;
+	if (d->read_fd>=0) {
+		close(d->read_fd);
+		d->read_fd=-1;
 	}
+    if (d->write_fd>=0) {
+        close(d->write_fd);
+        d->write_fd=-1;
+    }
+
 	free(rtmpbuff);
 	free(wtmpbuff);
 	if (rm!=NULL) freemsg(rm);
@@ -434,7 +534,7 @@
 	if (d->read_started==FALSE && d->write_started==FALSE){
 		d->read_started=TRUE;
 		ms_thread_create(&d->thread,NULL,oss_thread,card);
-	}else d->read_started=TRUE;
+	}else d->read_started=TRUE; 
 }
 
 static void oss_stop_r(MSSndCard *card){
@@ -442,7 +542,7 @@
 	d->read_started=FALSE;
 	if (d->write_started==FALSE){
 		ms_thread_join(d->thread,NULL);
-	}
+	} 
 }
 
 static void oss_start_w(MSSndCard *card){
Index: coreapi/exevents.c
===================================================================
--- coreapi/exevents.c	(.../vendor/linphone/linphone-2.1.1)	(revision 3519)
+++ coreapi/exevents.c	(.../trunk/RemoteStations/Koala_baobab/ThirdPartyLibs/linphone)	(revision 3519)
@@ -247,8 +247,9 @@
 
 int linphone_inc_new_call(LinphoneCore *lc, eXosip_event_t *ev)
 {
-	sdp_message_t *sdp=eXosip_get_sdp_info(ev->request);
-	osip_from_t *from_url=ev->request->from;
+	sdp_message_t           *sdp=eXosip_get_sdp_info(ev->request);
+	osip_from_t             *from_url=ev->request->from;
+
 	char *barmesg;
 	char *from;
 	char *to;
@@ -296,6 +297,53 @@
 		eXosip_unlock();
 		goto end;
 	}
+
+    if (linphone_authenticate_inc_call (lc, ev) != 0)
+    {
+        /* tell caller that he is not authorized */
+        osip_message_t          *msg;
+        osip_www_authenticate_t *www_auth;
+        char                    *www_authenticate_header;
+        char                    *realm;
+        char                    *nonce;
+        char                    *quoted_nonce;
+ 
+        linphone_auth_info_inc_realm (lc, &realm);
+        
+        if (realm != NULL)
+        {
+            generate_nonce (lc, ev, &nonce);
+
+            eXosip_lock();
+
+            quoted_nonce = osip_malloc (strlen (nonce) + 3);
+            snprintf (quoted_nonce, strlen (nonce) + 3, "\"%s\"", nonce);
+
+            osip_www_authenticate_init (&www_auth);
+            osip_www_authenticate_set_auth_type (www_auth, "Digest");
+            osip_www_authenticate_set_realm (www_auth, realm);
+            osip_www_authenticate_set_nonce (www_auth, quoted_nonce);
+            osip_www_authenticate_set_opaque (www_auth, "\"\"");
+            osip_www_authenticate_set_algorithm (www_auth, "\"MD5\"");
+            osip_www_authenticate_to_str (www_auth, &www_authenticate_header);
+
+            eXosip_call_build_answer(ev->tid, 401, &msg);
+
+            osip_message_set_www_authenticate (msg, www_authenticate_header);
+
+            eXosip_call_send_answer(ev->tid, 401, msg);
+
+            eXosip_unlock();
+
+            ms_free (realm);
+            free (nonce); 
+            osip_free (quoted_nonce);
+            osip_free (www_auth); 
+
+            goto end;
+        }
+    }
+
 	lc->call=linphone_call_new_incoming(lc,from,to,ev->cid,ev->did,ev->tid);
 	gstate_new_state(lc, GSTATE_CALL_IN_INVITE, NULL);
 	if (sdp==NULL){
Index: coreapi/private.h
===================================================================
--- coreapi/private.h	(.../vendor/linphone/linphone-2.1.1)	(revision 3519)
+++ coreapi/private.h	(.../trunk/RemoteStations/Koala_baobab/ThirdPartyLibs/linphone)	(revision 3519)
@@ -99,6 +99,9 @@
 
 #define PAYLOAD_TYPE_ENABLED	PAYLOAD_TYPE_USER_FLAG_0
 
+int linphone_authenticate_inc_call(LinphoneCore *lc, eXosip_event_t *ev);
+void generate_nonce (LinphoneCore* lc, eXosip_event_t* ev, char** nonce);
+void linphone_auth_info_inc_realm (LinphoneCore *lc, char** realm);
 void linphone_process_authentication(LinphoneCore* lc, eXosip_event_t *ev);
 void linphone_authentication_ok(LinphoneCore *lc, eXosip_event_t *ev);
 void linphone_subscription_new(LinphoneCore *lc, eXosip_event_t *ev);
Index: coreapi/authentication.c
===================================================================
--- coreapi/authentication.c	(.../vendor/linphone/linphone-2.1.1)	(revision 3519)
+++ coreapi/authentication.c	(.../trunk/RemoteStations/Koala_baobab/ThirdPartyLibs/linphone)	(revision 3519)
@@ -90,6 +90,70 @@
 	lp_config_sync(config);
 }
 
+
+LinphoneAuthInfo *linphone_auth_info_inc(LpConfig * config)
+{
+    const char *username, *userid, *passwd, *ha1, *realm;
+    const char key[] = "auth_info_incoming";
+
+    if (!lp_config_has_section(config, key)){
+        return NULL;
+    }
+
+    username=lp_config_get_string(config,key,"username",NULL);
+    userid=lp_config_get_string(config,key,"userid",NULL);
+    passwd=lp_config_get_string(config,key,"passwd",NULL);
+    ha1=lp_config_get_string(config,key,"ha1","supercow");
+    realm=lp_config_get_string(config,key,"realm",NULL);
+    return linphone_auth_info_new(username,userid,passwd,ha1,realm);
+}
+
+void linphone_auth_info_inc_realm (LinphoneCore *lc,
+                                   char** realm)
+{
+    *realm = NULL;
+    LinphoneAuthInfo        *as = linphone_auth_info_inc(lc->config);
+
+    if (as != NULL)  
+    {
+        *realm = ms_strdup (as->realm);
+        linphone_auth_info_destroy (as); 
+    }
+}
+
+void generate_nonce (LinphoneCore* lc, 
+                     eXosip_event_t* ev, 
+                     char** nonce)
+{
+    osip_from_t             *from = ev->request->from;
+    char                    *sip_tag = "missingtag";
+    LinphoneAuthInfo        *as;
+
+    if (from != NULL)
+    {
+        int i;
+
+        for (i=0; i < from->gen_params.nb_elt; i++)
+        {
+            osip_generic_param_t *param= (osip_generic_param_t*) 
+                                    osip_list_get (&from->gen_params,i);
+
+            if (strcmp (param->gname, "tag") == 0) 
+            {
+                sip_tag = param->gvalue;
+            }
+        }
+    }
+
+    as = linphone_auth_info_inc(lc->config);
+
+    eXosip_lock ();
+    eXosip_generate_nonce (nonce, sip_tag, as->ha1); 
+    eXosip_unlock ();
+
+    linphone_auth_info_destroy (as); 
+}
+
 LinphoneAuthInfo *linphone_auth_info_new_from_config_file(LpConfig * config, int pos)
 {
 	char key[50];
@@ -140,6 +204,9 @@
 	char *userid;
 	if (info->userid==NULL || info->userid[0]=='\0') userid=info->username;
 	else userid=info->userid;
+
+    ms_message ("adding auth info: userid=%s\n", userid);
+
 	eXosip_lock();
 	eXosip_add_authentication_info(info->username,userid,
 				info->passwd,info->ha1,info->realm);
@@ -237,6 +304,48 @@
 	}
 }
 
+int linphone_authenticate_inc_call(LinphoneCore *lc, eXosip_event_t *ev)
+{
+    osip_authorization_t *authorization;
+    int                  ret_val=1;
+
+    osip_message_get_authorization (ev->request, 0, &authorization);
+
+    if (authorization != NULL && authorization->response != NULL)
+    {
+        /* first verify that we have auth info for incoming calls. */
+
+        LinphoneAuthInfo *as;
+
+        if ((as=linphone_auth_info_inc (lc->config)) != NULL &&
+             as->username != NULL                            && 
+             as->passwd != NULL                              &&
+             authorization->uri != NULL                      &&
+             authorization->nonce != NULL                    &&
+             ev->request->sip_method != NULL                 &&
+             authorization->response != NULL)
+        {
+            /* then verify digest */
+            eXosip_lock ();
+            if (eXosip_validate_nonce (authorization->nonce) == 0) 
+            {
+                ret_val = eXosip_authenticate_digest (as->username,
+                                                      as->realm,
+                                                      as->passwd,
+                                                      authorization->uri,
+                                                      authorization->nonce,
+                                                      ev->request->sip_method,
+                                                      authorization->response);
+            }
+
+            linphone_auth_info_destroy (as);
+            eXosip_unlock ();
+        }
+    }
+
+    return ret_val;
+}
+
 void linphone_process_authentication(LinphoneCore *lc, eXosip_event_t *ev)
 {
 	char *prx_realm=NULL,*www_realm=NULL;
Index: coreapi/linphonecore.c
===================================================================
--- coreapi/linphonecore.c	(.../vendor/linphone/linphone-2.1.1)	(revision 3519)
+++ coreapi/linphonecore.c	(.../trunk/RemoteStations/Koala_baobab/ThirdPartyLibs/linphone)	(revision 3519)
@@ -427,6 +427,9 @@
 	tmp=lp_config_get_int(lc->config,"sip","inc_timeout",15);
 	linphone_core_set_inc_timeout(lc,tmp);
 
+	tmp=lp_config_get_int(lc->config,"sip","rtp_timeout",30);
+	linphone_core_set_rtp_timeout(lc,tmp);
+
 	/* get proxies config */
 	for(i=0;; i++){
 		LinphoneProxyConfig *cfg=linphone_proxy_config_new_from_config_file(lc->config,i);
@@ -943,6 +946,56 @@
 	(vs!=NULL) ? (rtp_session_compute_send_bandwidth(vs)*1e-3) : 0);
 }
 
+int linphone_core_is_timeout (LinphoneCore *lc)
+{
+    /* signal timeout if it's been a while since last time a rtp/rtcp packet 
+     * was received. But only do so if we have already sent some rtp/rtcp 
+     * packets ourselves, i.e. rtp.snd_seq is larger than some arbitrary 
+     * number. */
+
+    time_t curtime=time(NULL);
+    struct timeval last_recv_time;
+    RtpSession *as=NULL,*vs=NULL;
+    int elapsed;
+    int as_timeout=0;
+    int vs_timeout=0;
+
+    if (lc->audiostream!=NULL)
+	    as=lc->audiostream->session;
+
+    if (lc->videostream!=NULL)
+		vs=lc->videostream->session;
+
+    if (as != NULL)
+    { 
+        rtp_session_get_last_recv_time (as, &last_recv_time); 
+        elapsed=curtime-last_recv_time.tv_sec;
+
+        if (as->rtp.snd_seq > 69 && elapsed > lc->sip_conf.rtp_timeout)
+        {
+            ms_message("no audio rtp/rtcp packet received for %i seconds.", 
+                       elapsed); 
+            as_timeout = 1;
+        }
+    }
+
+    if (vs != NULL)
+    { 
+        rtp_session_get_last_recv_time (vs, &last_recv_time); 
+        elapsed=curtime-last_recv_time.tv_sec;
+
+        if (vs->rtp.snd_seq > 69 && elapsed > lc->sip_conf.rtp_timeout)
+        {
+            ms_message("no audio rtp/rtcp packet received for %i seconds.", 
+                       elapsed); 
+
+            vs_timeout = 1;
+        }
+    }
+
+    return as_timeout | vs_timeout;
+}
+
 void linphone_core_iterate(LinphoneCore *lc)
 {
 	eXosip_event_t *ev;
@@ -963,6 +1016,7 @@
 		LinphoneCall *call=lc->call;
 		int elapsed;
 		time_t curtime=time(NULL);
+
 		if (call->dir==LinphoneCallIncoming && call->state==LCStateRinging){
 			elapsed=curtime-call->start_time;
 			ms_message("incoming call ringing for %i seconds",elapsed);
@@ -978,7 +1032,10 @@
 					as=lc->audiostream->session;
 				if (lc->videostream!=NULL)
 					vs=lc->videostream->session;
-				display_bandwidth(as,vs);
+
+		        display_bandwidth(as,vs);
+   
+
 			}
 #ifdef VIDEO_ENABLED
 			if (lc->videostream!=NULL)
@@ -1516,10 +1573,18 @@
 	return 0;
 }
 
+void linphone_core_set_rtp_timeout(LinphoneCore *lc, int seconds){
+    lc->sip_conf.rtp_timeout=seconds;
+}
+
 void linphone_core_set_inc_timeout(LinphoneCore *lc, int seconds){
 	lc->sip_conf.inc_timeout=seconds;
 }
 
+int linphone_core_get_rtp_timeout(LinphoneCore *lc){
+	return lc->sip_conf.rtp_timeout;
+}
+
 int linphone_core_get_inc_timeout(LinphoneCore *lc){
 	return lc->sip_conf.inc_timeout;
 }
@@ -1958,6 +2023,7 @@
 	lp_config_set_int(lc->config,"sip","guess_hostname",config->guess_hostname);
 	lp_config_set_string(lc->config,"sip","contact",config->contact);
 	lp_config_set_int(lc->config,"sip","inc_timeout",config->inc_timeout);
+    lp_config_set_int(lc->config,"sip","rtp_timeout",config->rtp_timeout);
 	lp_config_set_int(lc->config,"sip","use_info",config->use_info);
 	lp_config_set_int(lc->config,"sip","use_ipv6",config->ipv6_enabled);
 	for(elem=config->proxies,i=0;elem!=NULL;elem=ms_list_next(elem),i++){
Index: coreapi/linphonecore.h
===================================================================
--- coreapi/linphonecore.h	(.../vendor/linphone/linphone-2.1.1)	(revision 3519)
+++ coreapi/linphonecore.h	(.../trunk/RemoteStations/Koala_baobab/ThirdPartyLibs/linphone)	(revision 3519)
@@ -51,6 +51,8 @@
 	MSList *proxies;
 	MSList *deleted_proxies;
 	int inc_timeout;	/*timeout after an un-answered incoming call is rejected*/
+    int rtp_timeout;    /*timeout after which if no rtp or rtcp packet is 
+                          received the call is terminated. */
 	bool_t use_info;
 	bool_t guess_hostname;
 	bool_t loopback_only;
@@ -486,6 +488,8 @@
 /* function to be periodically called in a main loop */
 void linphone_core_iterate(LinphoneCore *lc);
 
+int linphone_core_is_timeout (LinphoneCore *lc);
+
 int linphone_core_invite(LinphoneCore *lc, const char *url);
 
 int linphone_core_refer(LinphoneCore *lc, const char *url);
@@ -578,6 +582,10 @@
 
 int linphone_core_get_inc_timeout(LinphoneCore *lc);
 
+void linphone_core_set_rtp_timeout(LinphoneCore *lc, int seconds);
+
+int linphone_core_get_rtp_timeout(LinphoneCore *lc);
+
 void linphone_core_set_stun_server(LinphoneCore *lc, const char *server);
 
 const char * linphone_core_get_stun_server(const LinphoneCore *lc);
Index: configure.in
===================================================================
--- configure.in	(.../vendor/linphone/linphone-2.1.1)	(revision 3519)
+++ configure.in	(.../trunk/RemoteStations/Koala_baobab/ThirdPartyLibs/linphone)	(revision 3519)
@@ -349,6 +349,7 @@
 share/cs/Makefile
 share/linphone.pc
 linphone.spec
+daemon/Makefile
 ])
 
 echo "Linphone build configuration ended."
Index: console/linphonec.c
===================================================================
--- console/linphonec.c	(.../vendor/linphone/linphone-2.1.1)	(revision 3519)
+++ console/linphonec.c	(.../trunk/RemoteStations/Koala_baobab/ThirdPartyLibs/linphone)	(revision 3519)
@@ -584,6 +584,7 @@
 	/* printf(".\n"); */
 
 	linphone_core_iterate(opm);
+
 	if (answer_call){
 		fprintf (stdout, "-------auto answering to call-------\n" );
 		linphone_core_accept_call(opm,NULL);
@@ -609,6 +610,19 @@
 		rl_inhibit_completion=0;
 	}
 
+    if (linphone_core_is_timeout (opm))
+    {
+        fprintf (stdout, "\ntimeout\n");
+
+        linphone_core_terminate_call(opm, NULL);
+    }
+
+
+    /* the following sleep is needed to prevent cpu from skyrocketing when
+       linphone is used as a daemon and it is not reading from a tty. */
+
+    usleep (50000L);
+
 	return 0;
 }
 
Index: daemon/linphoned.c
===================================================================
--- daemon/linphoned.c	(.../vendor/linphone/linphone-2.1.1)	(revision 0)
+++ daemon/linphoned.c	(.../trunk/RemoteStations/Koala_baobab/ThirdPartyLibs/linphone)	(revision 3519)
@@ -0,0 +1,253 @@
+/****************************************************************************
+ *
+ *  Copyright (C) 2008  Carlos Rivera <carlos@superkaos.org>
+ *  
+ *
+ ****************************************************************************
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU Library General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ ****************************************************************************/
+
+/* run linphonec as a daemon in autoanswer mode */
+
+#define _GNU_SOURCE
+
+#include <stdio.h>
+#include <errno.h>
+#include <sys/types.h>
+#include <unistd.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+#include <pwd.h>
+#include <grp.h>
+
+#include "config.h"
+
+/* daemonize function taken from 
+   http://www.developerweb.net/forum/archive/index.php/t-3025.html */
+
+void daemonize (void) 
+{
+    int fd;
+
+    switch (fork ()) 
+    {
+        case 0:
+            break;
+
+        case -1:
+            // Error
+            fprintf (stderr, 
+                     "Error demonizing (fork)! %d - %s\n", 
+                     errno, 
+                     strerror (errno));
+            exit (0);
+            break;
+
+        default:
+            _exit (0);
+    }
+
+    if (setsid () < 0) 
+    {
+        fprintf (stderr, 
+                 "Error demonizing (setsid)! %d - %s\n", 
+                 errno, 
+                 strerror (errno));
+        exit (0);
+    }
+
+    switch (fork ()) 
+    {
+        case 0:
+            break;
+
+        case -1:
+            // Error
+            fprintf (stderr, 
+                     "Error demonizing (fork2)! %d - %s\n", 
+                     errno, 
+                     strerror (errno));
+            exit (0);
+            break;
+
+        default:
+            _exit (0);
+    }
+
+    chdir ("/");
+
+    fd = open ("/dev/null", O_RDONLY);
+
+    if (fd != 0) 
+    {
+        dup2 (fd, 0);
+        close (fd);
+        fcntl (0, F_SETFD, !FD_CLOEXEC);
+    }  
+
+    fd = open ("/dev/null", O_WRONLY);
+
+    if (fd != 1) 
+    {
+        dup2 (fd, 1);
+        close (fd);
+        fcntl (1, F_SETFD, !FD_CLOEXEC);
+    } 
+
+    fd = open ("/dev/null", O_WRONLY);
+
+    if (fd != 2) 
+    {
+        dup2 (fd, 2);
+        close (fd);
+        fcntl (2, F_SETFD, !FD_CLOEXEC);
+    } 
+
+}
+
+
+void usage () 
+{
+    printf ("Usage: linphoned -c confile -l logfile -p pidfile -u user -d debug_level [0-6]\n");
+    printf ("\n");
+}
+
+
+int main (int argc, char *argv[])
+{
+    int fd;
+    pid_t pid;
+    char pid_str[32];
+
+    char *log_fname    = NULL;
+    char *pid_fname    = NULL;
+    char *config_fname = NULL;
+    char *user_name    = NULL;
+    char *debug_level  = NULL;
+
+    struct passwd* pwd;
+
+    int c;
+     
+    opterr = 0;
+     
+    while ((c = getopt (argc, argv, "l:p:u:c:d:")) != -1)
+    {
+        switch (c)
+        {
+            case 'l':
+                log_fname = optarg;
+                break;
+
+            case 'p':
+                pid_fname = optarg;
+                break;
+
+            case 'u':
+                user_name = optarg;
+                break;
+
+            case 'c':
+                config_fname = optarg;
+                break;
+
+            case 'd':
+                debug_level = optarg;
+                break;
+
+            case '?':
+                if (optopt == 'l' || 
+                    optopt == 'p' || 
+                    optopt == 'u' || 
+                    optopt == 'c' ||
+                    optopt == 'd')
+                    fprintf (stderr, 
+                             "Option -%c requires an argument.\n", 
+                             optopt);
+
+                 else if (isprint (optopt))
+                    fprintf (stderr, "Unknown option `-%c'.\n", optopt);
+
+                 else
+                    fprintf (stderr,
+                             "Unknown option character `\\x%x'.\n",
+                             optopt);
+            default:
+             usage ();
+             exit (-1);
+        }
+    
+    }
+
+    if (log_fname    == NULL || 
+        pid_fname    == NULL || 
+        user_name    == NULL || 
+        config_fname == NULL ||
+        debug_level  == NULL)
+    {
+        usage ();
+        exit (-1);
+    }
+
+    pwd = getpwnam (user_name);
+
+    if (pwd == NULL)
+    {
+        fprintf (stderr, "Unknow user %s\n", user_name);
+        exit (-1);
+    }
+
+    daemonize ();
+
+    pid = getpid ();
+    snprintf (pid_str, sizeof (pid_str), "%ld\n", (long) pid);
+
+
+    /* write pid file */
+    fd = open (pid_fname, O_WRONLY | O_CREAT, S_IRUSR | S_IWUSR);
+    write (fd, pid_str, strnlen (pid_str, sizeof (pid_str)));
+    close (fd);
+
+
+    /* restore user and group ids */
+    initgroups(pwd->pw_name, pwd->pw_gid);
+
+    setgid (pwd->pw_gid);
+    setegid (pwd->pw_gid);
+
+    setuid (pwd->pw_uid);
+    seteuid (pwd->pw_uid);
+
+    if (execl (LINPHONEC_CMD_PATH,
+               LINPHONEC_CMD, 
+               "-a", 
+               "-l", 
+               log_fname,
+               "-c",
+               config_fname,
+               "-d",
+               debug_level,
+               (char*) NULL) == -1) 
+    {
+        exit (errno); /* since there is no stderr at least exit with errno. */
+    }
+
+    exit (0);
+}
Index: daemon/Makefile.in
===================================================================
--- daemon/Makefile.in	(.../vendor/linphone/linphone-2.1.1)	(revision 0)
+++ daemon/Makefile.in	(.../trunk/RemoteStations/Koala_baobab/ThirdPartyLibs/linphone)	(revision 3519)
@@ -0,0 +1,43 @@
+# ****************************************************************************
+# 
+#   Copyright (C) 2008  Carlos Rivera <carlos@superkaos.org>
+#   
+# 
+# ****************************************************************************
+# 
+#  This program is free software; you can redistribute it and/or modify
+#  it under the terms of the GNU General Public License as published by
+#  the Free Software Foundation; either version 2 of the License, or
+#  (at your option) any later version.
+# 
+#  This program is distributed in the hope that it will be useful,
+#  but WITHOUT ANY WARRANTY; without even the implied warranty of
+#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#  GNU Library General Public License for more details.
+#
+#  You should have received a copy of the GNU General Public License
+#  along with this program; if not, write to the Free Software
+#  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+#
+# ****************************************************************************
+
+prefix = @prefix@
+
+all: config.h
+	gcc -Wall linphoned.c -o linphoned
+	strip linphoned
+
+config.h: 
+	echo -e "#define LINPHONEC_CMD \"linphonec\"" > config.h
+	echo -e "#define LINPHONEC_CMD_PATH \"$(prefix)/bin/linphonec\"" >> config.h
+
+install:
+	install -m 766 -o root -g root linphoned $(DESTDIR)$(prefix)/bin
+
+distclean: clean
+	-rm config.h
+	-rm Makefile
+
+clean:
+	-rm linphoned
+
Index: config.h
===================================================================
--- config.h	(.../vendor/linphone/linphone-2.1.1)	(revision 3519)
+++ config.h	(.../trunk/RemoteStations/Koala_baobab/ThirdPartyLibs/linphone)	(revision 3519)
@@ -1,164 +0,0 @@
-/* config.h.  Generated from config.h.in by configure.  */
-/* config.h.in.  Generated from configure.in by autoheader.  */
-#define ENABLE_NLS 1
-/* #undef HAVE_CATGETS */
-#define HAVE_GETTEXT 1
-#define GETTEXT_PACKAGE "linphone"
-/* #undef HAVE_LC_MESSAGES */
-#define HAVE_STPCPY 1
-/* #undef HAVE_LIBSM */
-
-/* Define to 1 if translation of program messages to the user's native
-   language is requested. */
-#define ENABLE_NLS 1
-
-/* The name of the gettext package name */
-#define GETTEXT_PACKAGE "linphone"
-
-/* Define to 1 if you have the MacOS X function CFLocaleCopyCurrent in the
-   CoreFoundation framework. */
-/* #undef HAVE_CFLOCALECOPYCURRENT */
-
-/* Define to 1 if you have the MacOS X function CFPreferencesCopyAppValue in
-   the CoreFoundation framework. */
-/* #undef HAVE_CFPREFERENCESCOPYAPPVALUE */
-
-/* Define if the GNU dcgettext() function is already present or preinstalled.
-   */
-#define HAVE_DCGETTEXT 1
-
-/* Define to 1 if you have the <dlfcn.h> header file. */
-#define HAVE_DLFCN_H 1
-
-/* Defined when eXosip_get_version is available */
-#define HAVE_EXOSIP_GET_VERSION 1
-
-/* Define to 1 if you have the `getifaddrs' function. */
-#define HAVE_GETIFADDRS 1
-
-/* Define if the GNU gettext() function is already present or preinstalled. */
-#define HAVE_GETTEXT 1
-
-/* Define to 1 if you have the `get_current_dir_name' function. */
-#define HAVE_GET_CURRENT_DIR_NAME 1
-
-/* Defined if we can use the gtk api */
-#define HAVE_GTK 1
-
-/* Define to 1 if you have the <history.h> header file. */
-/* #undef HAVE_HISTORY_H */
-
-/* Define if you have the iconv() function. */
-/* #undef HAVE_ICONV */
-
-/* Define to 1 if you have the <inttypes.h> header file. */
-#define HAVE_INTTYPES_H 1
-
-/* Define to 1 if you have the `eXosip2' library (-leXosip2). */
-#define HAVE_LIBEXOSIP2 1
-
-/* Define to 1 if you have the `intl' library (-lintl). */
-/* #undef HAVE_LIBINTL */
-
-/* Define to 1 if you have the `ortp' library (-lortp). */
-/* #undef HAVE_LIBORTP */
-
-/* Define to 1 if you have the <memory.h> header file. */
-#define HAVE_MEMORY_H 1
-
-/* Define to 1 if you have the <readline.h> header file. */
-/* #undef HAVE_READLINE_H */
-
-/* Define to 1 if you have the <readline/history.h> header file. */
-#define HAVE_READLINE_HISTORY_H 1
-
-/* Define to 1 if you have the <readline/readline.h> header file. */
-#define HAVE_READLINE_READLINE_H 1
-
-/* Define to 1 if you have the <stdint.h> header file. */
-#define HAVE_STDINT_H 1
-
-/* Define to 1 if you have the <stdlib.h> header file. */
-#define HAVE_STDLIB_H 1
-
-/* Define to 1 if you have the `stpcpy' function. */
-#define HAVE_STPCPY 1
-
-/* Define to 1 if you have the <strings.h> header file. */
-#define HAVE_STRINGS_H 1
-
-/* Define to 1 if you have the <string.h> header file. */
-#define HAVE_STRING_H 1
-
-/* Define to 1 if you have the `strndup' function. */
-#define HAVE_STRNDUP 1
-
-/* Define to 1 if you have the <sys/stat.h> header file. */
-#define HAVE_SYS_STAT_H 1
-
-/* Define to 1 if you have the <sys/types.h> header file. */
-#define HAVE_SYS_TYPES_H 1
-
-/* Define to 1 if you have the <unistd.h> header file. */
-#define HAVE_UNISTD_H 1
-
-/* Linphone's version number */
-#define LINPHONE_VERSION "2.1.1"
-
-/* Name of package */
-#define PACKAGE "linphone"
-
-/* Define to the address where bug reports for this package should be sent. */
-#define PACKAGE_BUGREPORT "linphone-developers@nongnu.org"
-
-/* Defines the place where data are found */
-#define PACKAGE_DATA_DIR "/usr/local/share"
-
-/* Defines the place where locales can be found */
-#define PACKAGE_LOCALE_DIR "/usr/local/share/locale"
-
-/* Define to the full name of this package. */
-#define PACKAGE_NAME "linphone"
-
-/* Defines the place where linphone sounds are found */
-#define PACKAGE_SOUND_DIR "/usr/local/share/sounds/linphone"
-
-/* Define to the full name and version of this package. */
-#define PACKAGE_STRING "linphone 2.1.1"
-
-/* Define to the one symbol short name of this package. */
-#define PACKAGE_TARNAME "linphone"
-
-/* Define to the version of this package. */
-#define PACKAGE_VERSION "2.1.1"
-
-/* Define to 1 if you have the ANSI C header files. */
-#define STDC_HEADERS 1
-
-/* Version number of package */
-#define VERSION "2.1.1"
-
-/* defined if video support is available */
-#define VIDEO_ENABLED 1
-
-/* Tell whether RSVP support should be compiled. */
-/* #undef VINCENT_MAURY_RSVP */
-
-/* Define to 1 if your processor stores words with the most significant byte
-   first (like Motorola and SPARC, unlike Intel and VAX). */
-/* #undef WORDS_BIGENDIAN */
-
-/* Defined if we are compiling for arm processor */
-/* #undef __ARM__ */
-
-/* Defined if we are compiling for FreeBSD */
-/* #undef __FreeBSD__ */
-
-/* Defined if we are compiling for linux */
-#define __LINUX__ 1
-
-/* Define to `__inline__' or `__inline' if that's what the C compiler
-   calls it, or to nothing if 'inline' is not supported under any name.  */
-#ifndef __cplusplus
-/* #undef inline */
-#endif

Property changes on: .
___________________________________________________________________
Name: svn:ignore
   + config.h


