mirror of
https://github.com/servalproject/serval-dna.git
synced 2025-02-11 13:16:08 +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
20
monitor.c
20
monitor.c
@ -153,9 +153,9 @@ int monitor_get_fds(struct pollfd *fds,int *fdcount,int fdmax)
|
|||||||
int monitor_poll()
|
int monitor_poll()
|
||||||
{
|
{
|
||||||
int s;
|
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);
|
socklen_t ignored_length=sizeof(ignored_address);
|
||||||
WHY("here");
|
|
||||||
|
|
||||||
/* tell all monitor clients about status of all calls periodically */
|
/* tell all monitor clients about status of all calls periodically */
|
||||||
long long now=overlay_gettime_ms();
|
long long now=overlay_gettime_ms();
|
||||||
@ -186,16 +186,20 @@ int monitor_poll()
|
|||||||
fcntl(monitor_named_socket, F_GETFL, NULL)|O_NONBLOCK);
|
fcntl(monitor_named_socket, F_GETFL, NULL)|O_NONBLOCK);
|
||||||
while((
|
while((
|
||||||
#ifdef HAVE_LINUX_IF_H
|
#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
|
#else
|
||||||
s=accept(monitor_named_socket,&ignored_address,&ignored_length)
|
s=accept(monitor_named_socket,&ignored_address,&ignored_length)
|
||||||
#endif
|
#endif
|
||||||
)>-1) {
|
)>-1) {
|
||||||
|
WHYF("ignored_length=%d",ignored_length);
|
||||||
int res = fcntl(s,F_SETFL, O_NONBLOCK);
|
int res = fcntl(s,F_SETFL, O_NONBLOCK);
|
||||||
if (res) { close(s); continue; }
|
if (res) { close(s); continue; }
|
||||||
struct ucred ucred;
|
struct ucred ucred;
|
||||||
socklen_t len=sizeof(ucred);
|
socklen_t len=sizeof(ucred);
|
||||||
res = getsockopt(s,SOL_SOCKET,SO_PEERCRED,&ucred,&len);
|
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) {
|
if (res) {
|
||||||
WHY("Failed to read credentials of monitor.socket client");
|
WHY("Failed to read credentials of monitor.socket client");
|
||||||
close(s); continue; }
|
close(s); continue; }
|
||||||
@ -205,7 +209,8 @@ int monitor_poll()
|
|||||||
write(s,"\nCLOSE:Incorrect UID\n",strlen("\nCLOSE:Incorrect UID\n"));
|
write(s,"\nCLOSE:Incorrect UID\n",strlen("\nCLOSE:Incorrect UID\n"));
|
||||||
close(s); continue;
|
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"));
|
write(s,"\nCLOSE:All sockets busy\n",strlen("\nCLOSE:All sockets busy\n"));
|
||||||
close(s);
|
close(s);
|
||||||
} else {
|
} else {
|
||||||
@ -254,7 +259,7 @@ int monitor_poll()
|
|||||||
default:
|
default:
|
||||||
/* all other errors; close socket */
|
/* all other errors; close socket */
|
||||||
WHYF("Tearing down monitor client #%d due to errno=%d (%s)",
|
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);
|
close(c->socket);
|
||||||
if (i==monitor_socket_count-1) {
|
if (i==monitor_socket_count-1) {
|
||||||
monitor_socket_count--;
|
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->local.sid),
|
||||||
overlay_render_sid(call->remote.sid),
|
overlay_render_sid(call->remote.sid),
|
||||||
call->local.did,call->remote.did);
|
call->local.did,call->remote.did);
|
||||||
|
msg[1023]=0;
|
||||||
for(i=0;i<monitor_socket_count;i++)
|
for(i=0;i<monitor_socket_count;i++)
|
||||||
{
|
{
|
||||||
if (!(monitor_sockets[i].flags&MONITOR_VOMP))
|
if (!(monitor_sockets[i].flags&MONITOR_VOMP))
|
||||||
@ -538,7 +544,7 @@ int monitor_call_status(vomp_call_state *call)
|
|||||||
|
|
||||||
int monitor_send_audio(vomp_call_state *call,overlay_mdp_frame *audio)
|
int monitor_send_audio(vomp_call_state *call,overlay_mdp_frame *audio)
|
||||||
{
|
{
|
||||||
WHYF("Tell call monitor about audio for call %06x:%06x",
|
if (0) WHYF("Tell call monitor about audio for call %06x:%06x",
|
||||||
call->local.session,call->remote.session);
|
call->local.session,call->remote.session);
|
||||||
|
|
||||||
int sample_bytes=vomp_sample_size(audio->vompevent.audio_sample_codec);
|
int sample_bytes=vomp_sample_size(audio->vompevent.audio_sample_codec);
|
||||||
@ -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_SETFL,
|
||||||
fcntl(monitor_sockets[i].socket, F_GETFL, NULL)|O_NONBLOCK);
|
fcntl(monitor_sockets[i].socket, F_GETFL, NULL)|O_NONBLOCK);
|
||||||
write(monitor_sockets[i].socket,msg,msglen);
|
write(monitor_sockets[i].socket,msg,msglen);
|
||||||
WHYF("Writing AUDIOPACKET to client");
|
// WHYF("Writing AUDIOPACKET to client");
|
||||||
if (errno&&(errno!=EINTR)&&(errno!=EAGAIN)) {
|
if (errno&&(errno!=EINTR)&&(errno!=EAGAIN)) {
|
||||||
/* error sending update, so kill monitor socket */
|
/* error sending update, so kill monitor socket */
|
||||||
WHYF("Tearing down monitor client #%d due to errno=%d",
|
WHYF("Tearing down monitor client #%d due to errno=%d",
|
||||||
|
17
vomp.c
17
vomp.c
@ -212,7 +212,7 @@ int vomp_send_status(vomp_call_state *call,int flags,overlay_mdp_frame *arg)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (flags&VOMP_SENDAUDIO) {
|
if (flags&VOMP_SENDAUDIO) {
|
||||||
WHYF("got %d sample bytes, expecting %d",
|
if (0) WHYF("got %d sample bytes, expecting %d",
|
||||||
arg->vompevent.audio_sample_bytes,
|
arg->vompevent.audio_sample_bytes,
|
||||||
vomp_sample_size(arg->vompevent.audio_sample_codec));
|
vomp_sample_size(arg->vompevent.audio_sample_codec));
|
||||||
if (vomp_sample_size(arg->vompevent.audio_sample_codec)
|
if (vomp_sample_size(arg->vompevent.audio_sample_codec)
|
||||||
@ -220,7 +220,7 @@ int vomp_send_status(vomp_call_state *call,int flags,overlay_mdp_frame *arg)
|
|||||||
unsigned short *len=&mdp.out.payload_length;
|
unsigned short *len=&mdp.out.payload_length;
|
||||||
unsigned char *p=&mdp.out.payload[0];
|
unsigned char *p=&mdp.out.payload[0];
|
||||||
|
|
||||||
WHY("Including audio sample block");
|
// WHY("Including audio sample block");
|
||||||
|
|
||||||
/* record sample in recent list.
|
/* record sample in recent list.
|
||||||
XXX - What timestamp to attach to the sample?
|
XXX - What timestamp to attach to the sample?
|
||||||
@ -298,7 +298,7 @@ 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);
|
bcopy(&call->remote_codec_list[0],&mdp.vompevent.supported_codecs[0],256);
|
||||||
|
|
||||||
if (flags&VOMP_SENDAUDIO) {
|
if (flags&VOMP_SENDAUDIO) {
|
||||||
WHYF("Frame contains audio (codec=%s)",
|
if (0) WHYF("Frame contains audio (codec=%s)",
|
||||||
vomp_describe_codec(arg->vompevent.audio_sample_codec));
|
vomp_describe_codec(arg->vompevent.audio_sample_codec));
|
||||||
bcopy(&arg->vompevent.audio_bytes[0],
|
bcopy(&arg->vompevent.audio_bytes[0],
|
||||||
&mdp.vompevent.audio_bytes[0],
|
&mdp.vompevent.audio_bytes[0],
|
||||||
@ -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 vomp_process_audio(vomp_call_state *call,overlay_mdp_frame *mdp)
|
||||||
{
|
{
|
||||||
int ofs=14;
|
int ofs=14;
|
||||||
if (mdp->in.payload_length>14)
|
// if (mdp->in.payload_length>14)
|
||||||
WHYF("got here (payload has %d bytes)",mdp->in.payload_length);
|
// WHYF("got here (payload has %d bytes)",mdp->in.payload_length);
|
||||||
|
|
||||||
/* Get end time marker for sample block collection */
|
/* Get end time marker for sample block collection */
|
||||||
unsigned int e=0;
|
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)
|
while(ofs<mdp->in.payload_length)
|
||||||
{
|
{
|
||||||
int codec=mdp->in.payload[ofs];
|
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 (!codec||vomp_sample_size(codec)<0) break;
|
||||||
if ((ofs+1+vomp_sample_size(codec))>mdp->in.payload_length) 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->remote.sid,mdpreply.vompevent.remote_sid,SID_SIZE);
|
||||||
bcopy(call->local.did,mdpreply.vompevent.local_did,64);
|
bcopy(call->local.did,mdpreply.vompevent.local_did,64);
|
||||||
bcopy(call->remote.did,mdpreply.vompevent.remote_did,64);
|
bcopy(call->remote.did,mdpreply.vompevent.remote_did,64);
|
||||||
|
dump_vomp_status();
|
||||||
} else
|
} else
|
||||||
if (mdp->vompevent.call_session_token)
|
if (mdp->vompevent.call_session_token)
|
||||||
/* let the requestor know that the requested call doesn't exist */
|
/* let the requestor know that the requested call doesn't exist */
|
||||||
@ -679,11 +680,11 @@ int vomp_mdp_event(overlay_mdp_frame *mdp,
|
|||||||
break;
|
break;
|
||||||
case VOMPEVENT_AUDIOPACKET: /* user supplying audio */
|
case VOMPEVENT_AUDIOPACKET: /* user supplying audio */
|
||||||
{
|
{
|
||||||
WHY("Audio packet arrived");
|
// WHY("Audio packet arrived");
|
||||||
vomp_call_state *call
|
vomp_call_state *call
|
||||||
=vomp_find_call_by_session(mdp->vompevent.call_session_token);
|
=vomp_find_call_by_session(mdp->vompevent.call_session_token);
|
||||||
if (call) {
|
if (call) {
|
||||||
WHY("pushing audio sample out");
|
// WHY("pushing audio sample out");
|
||||||
return vomp_send_status(call,VOMP_TELLREMOTE|VOMP_SENDAUDIO,mdp);
|
return vomp_send_status(call,VOMP_TELLREMOTE|VOMP_SENDAUDIO,mdp);
|
||||||
}
|
}
|
||||||
else WHY("audio packet had invalid call session token");
|
else WHY("audio packet had invalid call session token");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user