Got VoMP ticks to update call state running.

This commit is contained in:
gardners 2012-04-21 21:21:26 +09:30
parent db68286426
commit 9b409c2891
3 changed files with 64 additions and 3 deletions

View File

@ -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()");

View File

@ -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);

53
vomp.c
View File

@ -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;i<vomp_call_count;i++)
{
if (now>vomp_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<now)
switch(vomp_call_states[i].local.state)
{
case VOMP_STATE_INCALL:
/* Timeout while call in progress, so end call.
Keep call structure hanging around for a bit so that we can
synchonrise with the far end if possible. */
vomp_call_states[i].local.state=VOMP_STATE_CALLENDED;
vomp_send_status(&vomp_call_states[i],
VOMP_TELLREMOTE|VOMP_TELLINTERESTED);
vomp_call_states[i].last_activity=now;
vomp_call_stop_audio(&vomp_call_states[i]);
break;
default:
/* Call timed out while not actually in progress, so just immmediately
tear the call down */
vomp_call_destroy(&vomp_call_states[i]);
/* since this slot will get reclaimed, we need to wind back one in
the iteration of the list of slots */
i--;
break;
}
}
return 0;
}
int vomp_tick_interval()
{
/* Work out the number of milliseconds until the next vomp tick is required. */
return 1000;
}