From 9b409c28910238fc63d259eff6721d95addb0b54 Mon Sep 17 00:00:00 2001 From: gardners Date: Sat, 21 Apr 2012 21:21:26 +0930 Subject: [PATCH] Got VoMP ticks to update call state running. --- overlay.c | 5 +++++ serval.h | 9 ++++++++- vomp.c | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++-- 3 files changed, 64 insertions(+), 3 deletions(-) diff --git a/overlay.c b/overlay.c index f252407b..264ab213 100644 --- a/overlay.c +++ b/overlay.c @@ -163,11 +163,16 @@ int overlayServerMode() will need to tick in order to keep each tick nice and fast. */ int route_tick_interval=overlay_route_tick(); if (ms>route_tick_interval) ms=route_tick_interval; + int vomp_tick_time=vomp_tick_interval(); + if (ms>vomp_tick_time) ms=vomp_tick_time; if (debug&DEBUG_VERBOSE_IO) fprintf(stderr,"Waiting via poll() for up to %lldms\n",ms); int r=poll(fds,fdcount,ms); + /* Do high-priority audio handling first */ + vomp_tick(); + if (r<0) { /* select had a problem */ if (debug&DEBUG_IO) perror("poll()"); diff --git a/serval.h b/serval.h index 66d6f0b5..d5491f39 100644 --- a/serval.h +++ b/serval.h @@ -1253,7 +1253,7 @@ typedef struct vomp_call_half { unsigned long long milliseconds_since_call_start; } vomp_call_half; -typedef struct vomp_call_stateo { +typedef struct vomp_call_state { vomp_call_half local; vomp_call_half remote; int ringing; @@ -1261,6 +1261,7 @@ typedef struct vomp_call_stateo { unsigned long long last_activity; int audio_started; int last_sent_status; + int next_status_time; } vomp_call_state; #define VOMP_CODEC_NONE 0x00 @@ -1279,10 +1280,16 @@ typedef struct vomp_call_stateo { #define VOMP_STATE_RINGINGIN 4 #define VOMP_STATE_INCALL 5 #define VOMP_STATE_CALLENDED 6 + +/* in milliseconds of inactivity */ +#define VOMP_CALL_TIMEOUT 120000 +#define VOMP_CALL_STATUS_INTERVAL 1000 int vomp_mdp_event(overlay_mdp_frame *mdp, struct sockaddr_un *recvaddr,int recvaddrlen); int vomp_mdp_received(overlay_mdp_frame *mdp); char *vomp_describe_state(int state); +int vomp_tick(); +int vomp_tick_interval(); typedef struct command_line_option { int (*function)(int argc,char **argv,struct command_line_option *o); diff --git a/vomp.c b/vomp.c index 48c0b0a1..1680df99 100644 --- a/vomp.c +++ b/vomp.c @@ -76,7 +76,7 @@ vomp_call_state *vomp_find_or_create_call(unsigned char *remote_sid, the last activity time rather than subtract from the current time when calculating the timeout. */ - if (vomp_call_states[i].last_activity+120000<(overlay_gettime_ms())) + if (vomp_call_states[i].last_activity+VOMP_CALL_TIMEOUT<(overlay_gettime_ms())) { WHYF("slot %d has expired.",i); WHYF(" last_activity=%lld, now=%lld", @@ -138,11 +138,14 @@ vomp_call_state *vomp_find_or_create_call(unsigned char *remote_sid, #define VOMP_TELLINTERESTED (1<<0) #define VOMP_TELLREMOTE (1<<1) #define VOMP_NEWCALL (1<<2) +#define VOMP_FORCETELLREMOTE ((1<<3)|VOMP_TELLREMOTE) + int vomp_send_status(vomp_call_state *call,int flags) { if (flags&VOMP_TELLREMOTE) { int combined_status=(call->remote.state<<4)|call->local.state; - if (call->last_sent_status!=combined_status) { + if (call->last_sent_status!=combined_status|| + (flags&VOMP_FORCETELLREMOTE)==VOMP_FORCETELLREMOTE) { call->last_sent_status=combined_status; overlay_mdp_frame mdp; @@ -863,3 +866,49 @@ int overlay_mdp_getmyaddr(int index,unsigned char *sid) bcopy(&a.addrlist.sids[0][0],sid,SID_SIZE); return 0; } + +int vomp_tick() +{ + /* Send any reminder packets for call state, and also process any audio. */ + unsigned long long now=overlay_gettime_ms(); + int i; + + for(i=0;ivomp_call_states[i].next_status_time) + { + vomp_send_status(&vomp_call_states[i],VOMP_FORCETELLREMOTE); + vomp_call_states[i].next_status_time=now+VOMP_CALL_STATUS_INTERVAL; + } + /* See if any calls need to begin expiring */ + if (vomp_call_states[i].last_activity+VOMP_CALL_TIMEOUT