mirror of
https://github.com/servalproject/serval-dna.git
synced 2025-01-30 16:13:51 +00:00
Got VoMP ticks to update call state running.
This commit is contained in:
parent
db68286426
commit
9b409c2891
@ -163,11 +163,16 @@ int overlayServerMode()
|
|||||||
will need to tick in order to keep each tick nice and fast. */
|
will need to tick in order to keep each tick nice and fast. */
|
||||||
int route_tick_interval=overlay_route_tick();
|
int route_tick_interval=overlay_route_tick();
|
||||||
if (ms>route_tick_interval) ms=route_tick_interval;
|
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)
|
if (debug&DEBUG_VERBOSE_IO)
|
||||||
fprintf(stderr,"Waiting via poll() for up to %lldms\n",ms);
|
fprintf(stderr,"Waiting via poll() for up to %lldms\n",ms);
|
||||||
int r=poll(fds,fdcount,ms);
|
int r=poll(fds,fdcount,ms);
|
||||||
|
|
||||||
|
/* Do high-priority audio handling first */
|
||||||
|
vomp_tick();
|
||||||
|
|
||||||
if (r<0) {
|
if (r<0) {
|
||||||
/* select had a problem */
|
/* select had a problem */
|
||||||
if (debug&DEBUG_IO) perror("poll()");
|
if (debug&DEBUG_IO) perror("poll()");
|
||||||
|
9
serval.h
9
serval.h
@ -1253,7 +1253,7 @@ typedef struct vomp_call_half {
|
|||||||
unsigned long long milliseconds_since_call_start;
|
unsigned long long milliseconds_since_call_start;
|
||||||
} vomp_call_half;
|
} vomp_call_half;
|
||||||
|
|
||||||
typedef struct vomp_call_stateo {
|
typedef struct vomp_call_state {
|
||||||
vomp_call_half local;
|
vomp_call_half local;
|
||||||
vomp_call_half remote;
|
vomp_call_half remote;
|
||||||
int ringing;
|
int ringing;
|
||||||
@ -1261,6 +1261,7 @@ typedef struct vomp_call_stateo {
|
|||||||
unsigned long long last_activity;
|
unsigned long long last_activity;
|
||||||
int audio_started;
|
int audio_started;
|
||||||
int last_sent_status;
|
int last_sent_status;
|
||||||
|
int next_status_time;
|
||||||
} vomp_call_state;
|
} vomp_call_state;
|
||||||
|
|
||||||
#define VOMP_CODEC_NONE 0x00
|
#define VOMP_CODEC_NONE 0x00
|
||||||
@ -1279,10 +1280,16 @@ typedef struct vomp_call_stateo {
|
|||||||
#define VOMP_STATE_RINGINGIN 4
|
#define VOMP_STATE_RINGINGIN 4
|
||||||
#define VOMP_STATE_INCALL 5
|
#define VOMP_STATE_INCALL 5
|
||||||
#define VOMP_STATE_CALLENDED 6
|
#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,
|
int vomp_mdp_event(overlay_mdp_frame *mdp,
|
||||||
struct sockaddr_un *recvaddr,int recvaddrlen);
|
struct sockaddr_un *recvaddr,int recvaddrlen);
|
||||||
int vomp_mdp_received(overlay_mdp_frame *mdp);
|
int vomp_mdp_received(overlay_mdp_frame *mdp);
|
||||||
char *vomp_describe_state(int state);
|
char *vomp_describe_state(int state);
|
||||||
|
int vomp_tick();
|
||||||
|
int vomp_tick_interval();
|
||||||
|
|
||||||
typedef struct command_line_option {
|
typedef struct command_line_option {
|
||||||
int (*function)(int argc,char **argv,struct command_line_option *o);
|
int (*function)(int argc,char **argv,struct command_line_option *o);
|
||||||
|
53
vomp.c
53
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
|
the last activity time rather than subtract from the current time
|
||||||
when calculating the timeout.
|
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("slot %d has expired.",i);
|
||||||
WHYF(" last_activity=%lld, now=%lld",
|
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_TELLINTERESTED (1<<0)
|
||||||
#define VOMP_TELLREMOTE (1<<1)
|
#define VOMP_TELLREMOTE (1<<1)
|
||||||
#define VOMP_NEWCALL (1<<2)
|
#define VOMP_NEWCALL (1<<2)
|
||||||
|
#define VOMP_FORCETELLREMOTE ((1<<3)|VOMP_TELLREMOTE)
|
||||||
|
|
||||||
int vomp_send_status(vomp_call_state *call,int flags)
|
int vomp_send_status(vomp_call_state *call,int flags)
|
||||||
{
|
{
|
||||||
if (flags&VOMP_TELLREMOTE) {
|
if (flags&VOMP_TELLREMOTE) {
|
||||||
int combined_status=(call->remote.state<<4)|call->local.state;
|
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;
|
call->last_sent_status=combined_status;
|
||||||
|
|
||||||
overlay_mdp_frame mdp;
|
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);
|
bcopy(&a.addrlist.sids[0][0],sid,SID_SIZE);
|
||||||
return 0;
|
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;
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user