ratox

FIFO based tox client
git clone git://git.2f30.org/ratox
Log | Files | Refs | README | LICENSE

commit ab7bdb2634ca1866bb9c8db53e7f5848b8146f8e
parent b0571c7aabe1874c7180ec340ad3901967acbe0d
Author: z3bra <contactatz3bradotorg>
Date:   Fri, 25 Nov 2016 17:29:00 +0100

Cancel calls ringing longer than RINGINGDELAY

Diffstat:
Mratox.c | 12++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/ratox.c b/ratox.c @@ -448,7 +448,7 @@ cancelcall(struct friend *f, char *action) { logmsg(": %s : Audio > %s\n", f->name, action); - if (f->av.state & TRANSMITTING) { + if (f->av.state & TRANSMITTING || f->av.state & RINGING) { if (!toxav_call_control(toxav, f->num, TOXAV_CALL_CONTROL_CANCEL, NULL)) weprintf("Failed to terminate call\n"); } @@ -1545,6 +1545,7 @@ loop(void) struct friend *f, *ftmp; struct request *req, *rtmp; struct timeval tv; + struct timespec callstart, now; fd_set rfds; time_t t0, t1; size_t i; @@ -1598,7 +1599,7 @@ loop(void) if (f->tx.state == TRANSFER_NONE) FD_APPEND(f->fd[FFILE_IN]); - if (!f->av.state || (f->av.state & OUTGOING)) + if (!f->av.state || ((f->av.state & TRANSMITTING) && (f->av.state & OUTGOING))) FD_APPEND(f->fd[FCALL_IN]); } FD_APPEND(f->fd[FREMOVE]); @@ -1671,7 +1672,13 @@ loop(void) if (f->av.state == TRANSMITTING) cancelcall(f, "Hung up"); + if (f->av.state & RINGING) { + if (f->av.state & OUTGOING) { + clock_gettime(CLOCK_MONOTONIC, &now); + if (now.tv_sec - callstart.tv_sec > RINGINGDELAY) + cancelcall(f, "Timeout"); + } if (!(f->av.state & INCOMING)) continue; if (!toxav_answer(toxav, f->num, AUDIOBITRATE, 0, NULL)) { @@ -1754,6 +1761,7 @@ loop(void) fiforeset(f->dirfd, &f->fd[FCALL_IN], ffiles[FCALL_IN]); break; } + clock_gettime(CLOCK_MONOTONIC, &callstart); f->av.n = 0; f->av.lastsent.tv_sec = 0; f->av.lastsent.tv_nsec = 0;