diff options
author | z3bra <contactatz3bradotorg> | 2016-11-25 17:29:00 +0100 |
---|---|---|
committer | z3bra <contactatz3bradotorg> | 2016-11-25 17:29:00 +0100 |
commit | ab7bdb2634ca1866bb9c8db53e7f5848b8146f8e (patch) | |
tree | 76fdbf765a7c48854035aea53fa16e7621c35108 | |
parent | b0571c7aabe1874c7180ec340ad3901967acbe0d (diff) |
Cancel calls ringing longer than RINGINGDELAY
-rw-r--r-- | ratox.c | 12 |
1 files changed, 10 insertions, 2 deletions
@@ -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; |