mirror of
https://github.com/servalproject/serval-dna.git
synced 2024-12-19 21:27:57 +00:00
progress towards monitor interface for following calls.
This commit is contained in:
parent
d637f31ab7
commit
eb8ffeb71f
51
monitor.c
51
monitor.c
@ -53,6 +53,7 @@ struct monitor_context {
|
||||
#define MAX_MONITOR_SOCKETS 8
|
||||
int monitor_socket_count=0;
|
||||
struct monitor_context monitor_sockets[MAX_MONITOR_SOCKETS];
|
||||
long long monitor_last_update_time=0;
|
||||
|
||||
int monitor_process_command(int index,char *cmd);
|
||||
int monitor_process_data(int index);
|
||||
@ -136,6 +137,15 @@ int monitor_poll()
|
||||
struct sockaddr ignored_address;
|
||||
socklen_t ignored_length=sizeof(ignored_address);
|
||||
|
||||
/* tell all monitor clients about status of all calls periodically */
|
||||
long long now=overlay_gettime_ms();
|
||||
if (now>(monitor_last_update_time+1000)) {
|
||||
monitor_last_update_time=now;
|
||||
int i;
|
||||
for(i=0;i<vomp_call_count;i++)
|
||||
monitor_call_status(&vomp_call_states[i]);
|
||||
}
|
||||
|
||||
/* Check for new connections */
|
||||
while((s=accept(monitor_named_socket,&ignored_address,&ignored_length))>-1) {
|
||||
int res = fcntl(s,F_SETFL, O_NONBLOCK);
|
||||
@ -243,11 +253,20 @@ int monitor_poll()
|
||||
int monitor_process_command(int index,char *cmd)
|
||||
{
|
||||
int callSessionToken,sampleType,bytes;
|
||||
char sid[80],localDid[80],remoteDid[80];
|
||||
overlay_mdp_frame mdp;
|
||||
mdp.packetTypeAndFlags=MDP_VOMPEVENT;
|
||||
|
||||
struct monitor_context *c=&monitor_sockets[index];
|
||||
c->line_length=0;
|
||||
|
||||
if (sscanf(cmd,cmd,"AUDIO:%x:%d:%d",
|
||||
if (strlen(cmd)>80) {
|
||||
write(c->socket,"ERROR:Command too long\n",
|
||||
strlen("ERROR:Command too long\n"));
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (sscanf(cmd,"AUDIO:%x:%d:%d",
|
||||
&callSessionToken,&sampleType,&bytes)==3)
|
||||
{
|
||||
/* Start getting sample */
|
||||
@ -266,6 +285,22 @@ int monitor_process_command(int index,char *cmd)
|
||||
c->flags|=MONITOR_RHIZOME;
|
||||
else if (!strcasecmp(cmd,"ignore rhizome"))
|
||||
c->flags&=~MONITOR_RHIZOME;
|
||||
else if (sscanf(cmd,"CREATECALL:%s:%s:%s",sid,localDid,remoteDid)==3) {
|
||||
mdp.vompevent.flags=VOMPEVENT_DIAL;
|
||||
if (overlay_mdp_getmyaddr(0,&mdp.vompevent.local_sid[0])) return -1;
|
||||
stowSid(&mdp.vompevent.remote_sid[0],0,sid);
|
||||
vomp_mdp_event(&mdp,NULL,0);
|
||||
}
|
||||
else if (sscanf(cmd,"PICKUP:%x",callSessionToken)==1) {
|
||||
mdp.vompevent.flags=VOMPEVENT_PICKUP;
|
||||
mdp.vompevent.call_session_token=callSessionToken;
|
||||
vomp_mdp_event(&mdp,NULL,0);
|
||||
}
|
||||
else if (sscanf(cmd,"HANGUP:%x",callSessionToken)==1) {
|
||||
mdp.vompevent.flags=VOMPEVENT_HANGUP;
|
||||
mdp.vompevent.call_session_token=callSessionToken;
|
||||
vomp_mdp_event(&mdp,NULL,0);
|
||||
}
|
||||
|
||||
char msg[1024];
|
||||
snprintf(msg,1024,"MONITORSTATUS:%d\n",c->flags);
|
||||
@ -301,3 +336,17 @@ int monitor_process_data(int index)
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int monitor_call_status(vomp_call_state *call)
|
||||
{
|
||||
WHYF("Tell call monitor about call %06x:%06x",
|
||||
call->local.session,call->remote.session);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int monitor_send_audio(vomp_call_state *call,overlay_mdp_frame *audio)
|
||||
{
|
||||
WHYF("Tell call monitor about audio for call %06x:%06x",
|
||||
call->local.session,call->remote.session);
|
||||
return 0;
|
||||
}
|
||||
|
@ -153,6 +153,8 @@ int overlay_mdp_reply(int sock,struct sockaddr_un *recvaddr,int recvaddrlen,
|
||||
{
|
||||
int replylen;
|
||||
|
||||
if (!recvaddr) return 0;
|
||||
|
||||
replylen=overlay_mdp_relevant_bytes(mdpreply);
|
||||
if (replylen<0) return WHY("Invalid MDP frame (could not compute length)");
|
||||
|
||||
|
8
serval.h
8
serval.h
@ -1304,6 +1304,11 @@ typedef struct vomp_call_state {
|
||||
vomp_sample_block recent_samples[VOMP_MAX_RECENT_SAMPLES];
|
||||
} vomp_call_state;
|
||||
|
||||
extern int vomp_call_count;
|
||||
extern int vomp_active_call;
|
||||
extern vomp_call_state vomp_call_states[VOMP_MAX_CALLS];
|
||||
|
||||
|
||||
#define VOMP_CODEC_NONE 0x00
|
||||
#define VOMP_CODEC_CODEC2_2400 0x01
|
||||
#define VOMP_CODEC_CODEC2_1400 0x02
|
||||
@ -1384,3 +1389,6 @@ int monitor_get_fds(struct pollfd *fds,int *fdcount,int fdmax);
|
||||
int monitor_setup_sockets();
|
||||
int monitor_poll();
|
||||
int monitor_get_fds(struct pollfd *fds,int *fdcount,int fdmax);
|
||||
int monitor_call_status(vomp_call_state *call);
|
||||
int monitor_send_audio(vomp_call_state *call,overlay_mdp_frame *audio);
|
||||
extern int monitor_socket_count;
|
||||
|
8
vomp.c
8
vomp.c
@ -286,6 +286,7 @@ int vomp_send_status(vomp_call_state *call,int flags,overlay_mdp_frame *arg)
|
||||
mdp.vompevent.flags|=VOMPEVENT_CALLCREATED;
|
||||
mdp.vompevent.local_state=call->local.state;
|
||||
mdp.vompevent.remote_state=call->remote.state;
|
||||
monitor_call_status(call);
|
||||
|
||||
bcopy(&call->remote_codec_list[0],&mdp.vompevent.supported_codecs[0],256);
|
||||
|
||||
@ -297,6 +298,7 @@ int vomp_send_status(vomp_call_state *call,int flags,overlay_mdp_frame *arg)
|
||||
mdp.vompevent.audio_sample_bytes=arg->vompevent.audio_sample_bytes;
|
||||
mdp.vompevent.audio_sample_starttime=arg->vompevent.audio_sample_starttime;
|
||||
mdp.vompevent.audio_sample_endtime=arg->vompevent.audio_sample_endtime;
|
||||
monitor_send_audio(call,arg);
|
||||
}
|
||||
|
||||
int i;
|
||||
@ -565,7 +567,7 @@ int vomp_mdp_event(overlay_mdp_frame *mdp,
|
||||
=vomp_call_states[i].local.state;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return overlay_mdp_reply(mdp_named_socket,recvaddr,recvaddrlen,&mdpreply);
|
||||
}
|
||||
break;
|
||||
@ -763,7 +765,9 @@ int vomp_mdp_received(overlay_mdp_frame *mdp)
|
||||
return WHY("VoMP frame does not correspond to an active call - stale traffic or replay attack?");
|
||||
}
|
||||
|
||||
if (!vomp_interested_usock_count) {
|
||||
if ((!vomp_interested_usock_count)
|
||||
&&(!monitor_socket_count))
|
||||
{
|
||||
/* No registered listener, so we cannot answer the call, so just reject
|
||||
it. */
|
||||
call->local.state=VOMP_STATE_CALLENDED;
|
||||
|
Loading…
Reference in New Issue
Block a user