FreeCalypso > hg > themwi-system-sw
changeset 150:529906fddcfa
mgw DTMF timing fix in the corner case of no speech
arriving between the end of one DTMF and the start of next
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Tue, 11 Oct 2022 14:10:29 -0800 |
parents | cfc249906145 |
children | 0ecbc3dc8f93 |
files | mgw/dtmf_ctrl.c mgw/dtmf_timer.c mgw/struct.h |
diffstat | 3 files changed, 10 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/mgw/dtmf_ctrl.c Tue Oct 11 13:48:39 2022 -0800 +++ b/mgw/dtmf_ctrl.c Tue Oct 11 14:10:29 2022 -0800 @@ -62,7 +62,7 @@ { struct endpoint *ep; struct dtmf_desc *desc; - struct timeval tv_diff; + struct timeval tv_last, tv_diff; unsigned delta_frames; ep = find_ep_by_id(conn, req->ep_id); @@ -90,11 +90,15 @@ return; } /* figure out starting timestamp */ - if (!ep->dtmf_aftermath) + if (ep->dtmf_aftermath) + tv_last = ep->dtmf_last_time; + else { ep->dtmf_last_ts = ep->g2p_last_ts; + tv_last = ep->g2p_local_time; + } ep->dtmf_m_bit = 0; - if (timercmp(&cur_event_time, &ep->g2p_local_time, >)) { - timersub(&cur_event_time, &ep->g2p_local_time, &tv_diff); + if (timercmp(&cur_event_time, &tv_last, >)) { + timersub(&cur_event_time, &tv_last, &tv_diff); delta_frames = tv_diff.tv_sec * 50 + tv_diff.tv_usec / 20000; if (delta_frames) { ep->dtmf_last_ts += delta_frames * SAMPLES_PER_FRAME;
--- a/mgw/dtmf_timer.c Tue Oct 11 13:48:39 2022 -0800 +++ b/mgw/dtmf_timer.c Tue Oct 11 14:10:29 2022 -0800 @@ -55,6 +55,7 @@ sendto(ep->rtp_pstn.rtp_fd, &pkt, RTP_PACKET_SIZE_PSTN, 0, (struct sockaddr *) &ep->rtp_pstn.remote_addr, addrlen); ep->dtmf_frames_sent++; + ep->dtmf_last_time = cur_event_time; frame_limit = ep->dtmf_stop_req ? DTMF_MIN_FRAMES : DTMF_MAX_FRAMES; if (ep->dtmf_frames_sent >= frame_limit) return 1;