mirror of
https://github.com/servalproject/serval-dna.git
synced 2025-01-29 15:43:56 +00:00
stripped out lots of debugging for audio frame handling ready for
audio-streaming of call.
This commit is contained in:
parent
68cfa6218c
commit
fbd19db931
24
monitor.c
24
monitor.c
@ -153,9 +153,9 @@ int monitor_get_fds(struct pollfd *fds,int *fdcount,int fdmax)
|
||||
int monitor_poll()
|
||||
{
|
||||
int s;
|
||||
struct sockaddr ignored_address;
|
||||
unsigned char buffer[1024];
|
||||
struct sockaddr *ignored_address=(struct sockaddr *)&buffer[0];
|
||||
socklen_t ignored_length=sizeof(ignored_address);
|
||||
WHY("here");
|
||||
|
||||
/* tell all monitor clients about status of all calls periodically */
|
||||
long long now=overlay_gettime_ms();
|
||||
@ -173,7 +173,7 @@ int monitor_poll()
|
||||
/* Push out any undelivered status changes */
|
||||
monitor_call_status(&vomp_call_states[i]);
|
||||
WHYF("Sending keepalives for call #%d",i);
|
||||
|
||||
|
||||
/* And let far-end know that call is still alive */
|
||||
snprintf(msg,128,"\nKEEPALIVE:%06x\n",vomp_call_states[i].local.session);
|
||||
for(m=0;m<monitor_socket_count;m++)
|
||||
@ -186,16 +186,20 @@ int monitor_poll()
|
||||
fcntl(monitor_named_socket, F_GETFL, NULL)|O_NONBLOCK);
|
||||
while((
|
||||
#ifdef HAVE_LINUX_IF_H
|
||||
s=accept4(monitor_named_socket,&ignored_address,&ignored_length,O_NONBLOCK)
|
||||
s=accept4(monitor_named_socket,ignored_address,&ignored_length,O_NONBLOCK)
|
||||
#else
|
||||
s=accept(monitor_named_socket,&ignored_address,&ignored_length)
|
||||
#endif
|
||||
)>-1) {
|
||||
WHYF("ignored_length=%d",ignored_length);
|
||||
int res = fcntl(s,F_SETFL, O_NONBLOCK);
|
||||
if (res) { close(s); continue; }
|
||||
struct ucred ucred;
|
||||
socklen_t len=sizeof(ucred);
|
||||
res = getsockopt(s,SOL_SOCKET,SO_PEERCRED,&ucred,&len);
|
||||
if (len>sizeof(ucred)) {
|
||||
WHYF("This is likely to be bad (memory overrun by getsockopt())");
|
||||
}
|
||||
if (res) {
|
||||
WHY("Failed to read credentials of monitor.socket client");
|
||||
close(s); continue; }
|
||||
@ -205,7 +209,8 @@ int monitor_poll()
|
||||
write(s,"\nCLOSE:Incorrect UID\n",strlen("\nCLOSE:Incorrect UID\n"));
|
||||
close(s); continue;
|
||||
}
|
||||
else if (monitor_socket_count>=MAX_MONITOR_SOCKETS) {
|
||||
else if (monitor_socket_count>=MAX_MONITOR_SOCKETS
|
||||
||monitor_socket_count<0) {
|
||||
write(s,"\nCLOSE:All sockets busy\n",strlen("\nCLOSE:All sockets busy\n"));
|
||||
close(s);
|
||||
} else {
|
||||
@ -254,7 +259,7 @@ int monitor_poll()
|
||||
default:
|
||||
/* all other errors; close socket */
|
||||
WHYF("Tearing down monitor client #%d due to errno=%d (%s)",
|
||||
i,errno,strerror(errno));
|
||||
i,errno,strerror(errno)?strerror(errno):"<unknown error>");
|
||||
close(c->socket);
|
||||
if (i==monitor_socket_count-1) {
|
||||
monitor_socket_count--;
|
||||
@ -506,6 +511,7 @@ int monitor_call_status(vomp_call_state *call)
|
||||
overlay_render_sid(call->local.sid),
|
||||
overlay_render_sid(call->remote.sid),
|
||||
call->local.did,call->remote.did);
|
||||
msg[1023]=0;
|
||||
for(i=0;i<monitor_socket_count;i++)
|
||||
{
|
||||
if (!(monitor_sockets[i].flags&MONITOR_VOMP))
|
||||
@ -538,8 +544,8 @@ int monitor_call_status(vomp_call_state *call)
|
||||
|
||||
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);
|
||||
if (0) WHYF("Tell call monitor about audio for call %06x:%06x",
|
||||
call->local.session,call->remote.session);
|
||||
|
||||
int sample_bytes=vomp_sample_size(audio->vompevent.audio_sample_codec);
|
||||
unsigned char msg[1024+MAX_AUDIO_BYTES];
|
||||
@ -570,7 +576,7 @@ int monitor_send_audio(vomp_call_state *call,overlay_mdp_frame *audio)
|
||||
fcntl(monitor_sockets[i].socket,F_SETFL,
|
||||
fcntl(monitor_sockets[i].socket, F_GETFL, NULL)|O_NONBLOCK);
|
||||
write(monitor_sockets[i].socket,msg,msglen);
|
||||
WHYF("Writing AUDIOPACKET to client");
|
||||
// WHYF("Writing AUDIOPACKET to client");
|
||||
if (errno&&(errno!=EINTR)&&(errno!=EAGAIN)) {
|
||||
/* error sending update, so kill monitor socket */
|
||||
WHYF("Tearing down monitor client #%d due to errno=%d",
|
||||
|
23
vomp.c
23
vomp.c
@ -212,15 +212,15 @@ int vomp_send_status(vomp_call_state *call,int flags,overlay_mdp_frame *arg)
|
||||
}
|
||||
|
||||
if (flags&VOMP_SENDAUDIO) {
|
||||
WHYF("got %d sample bytes, expecting %d",
|
||||
arg->vompevent.audio_sample_bytes,
|
||||
vomp_sample_size(arg->vompevent.audio_sample_codec));
|
||||
if (0) WHYF("got %d sample bytes, expecting %d",
|
||||
arg->vompevent.audio_sample_bytes,
|
||||
vomp_sample_size(arg->vompevent.audio_sample_codec));
|
||||
if (vomp_sample_size(arg->vompevent.audio_sample_codec)
|
||||
==arg->vompevent.audio_sample_bytes) {
|
||||
unsigned short *len=&mdp.out.payload_length;
|
||||
unsigned char *p=&mdp.out.payload[0];
|
||||
|
||||
WHY("Including audio sample block");
|
||||
// WHY("Including audio sample block");
|
||||
|
||||
/* record sample in recent list.
|
||||
XXX - What timestamp to attach to the sample?
|
||||
@ -298,8 +298,8 @@ int vomp_send_status(vomp_call_state *call,int flags,overlay_mdp_frame *arg)
|
||||
bcopy(&call->remote_codec_list[0],&mdp.vompevent.supported_codecs[0],256);
|
||||
|
||||
if (flags&VOMP_SENDAUDIO) {
|
||||
WHYF("Frame contains audio (codec=%s)",
|
||||
vomp_describe_codec(arg->vompevent.audio_sample_codec));
|
||||
if (0) WHYF("Frame contains audio (codec=%s)",
|
||||
vomp_describe_codec(arg->vompevent.audio_sample_codec));
|
||||
bcopy(&arg->vompevent.audio_bytes[0],
|
||||
&mdp.vompevent.audio_bytes[0],
|
||||
vomp_sample_size(arg->vompevent.audio_sample_codec));
|
||||
@ -332,8 +332,8 @@ int vomp_call_start_audio(vomp_call_state *call)
|
||||
int vomp_process_audio(vomp_call_state *call,overlay_mdp_frame *mdp)
|
||||
{
|
||||
int ofs=14;
|
||||
if (mdp->in.payload_length>14)
|
||||
WHYF("got here (payload has %d bytes)",mdp->in.payload_length);
|
||||
// if (mdp->in.payload_length>14)
|
||||
// WHYF("got here (payload has %d bytes)",mdp->in.payload_length);
|
||||
|
||||
/* Get end time marker for sample block collection */
|
||||
unsigned int e=0;
|
||||
@ -345,7 +345,7 @@ int vomp_process_audio(vomp_call_state *call,overlay_mdp_frame *mdp)
|
||||
while(ofs<mdp->in.payload_length)
|
||||
{
|
||||
int codec=mdp->in.payload[ofs];
|
||||
WHYF("Spotted a %s sample block",vomp_describe_codec(codec));
|
||||
// WHYF("Spotted a %s sample block",vomp_describe_codec(codec));
|
||||
if (!codec||vomp_sample_size(codec)<0) break;
|
||||
if ((ofs+1+vomp_sample_size(codec))>mdp->in.payload_length) break;
|
||||
|
||||
@ -560,6 +560,7 @@ int vomp_mdp_event(overlay_mdp_frame *mdp,
|
||||
bcopy(call->remote.sid,mdpreply.vompevent.remote_sid,SID_SIZE);
|
||||
bcopy(call->local.did,mdpreply.vompevent.local_did,64);
|
||||
bcopy(call->remote.did,mdpreply.vompevent.remote_did,64);
|
||||
dump_vomp_status();
|
||||
} else
|
||||
if (mdp->vompevent.call_session_token)
|
||||
/* let the requestor know that the requested call doesn't exist */
|
||||
@ -679,11 +680,11 @@ int vomp_mdp_event(overlay_mdp_frame *mdp,
|
||||
break;
|
||||
case VOMPEVENT_AUDIOPACKET: /* user supplying audio */
|
||||
{
|
||||
WHY("Audio packet arrived");
|
||||
// WHY("Audio packet arrived");
|
||||
vomp_call_state *call
|
||||
=vomp_find_call_by_session(mdp->vompevent.call_session_token);
|
||||
if (call) {
|
||||
WHY("pushing audio sample out");
|
||||
// WHY("pushing audio sample out");
|
||||
return vomp_send_status(call,VOMP_TELLREMOTE|VOMP_SENDAUDIO,mdp);
|
||||
}
|
||||
else WHY("audio packet had invalid call session token");
|
||||
|
Loading…
x
Reference in New Issue
Block a user