FreeCalypso > hg > themwi-system-sw
diff mgw/dtmf_ctrl.c @ 170:a6eb2de277f6
mgw: massive simplification for continuous RTP stream from BTS
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sun, 20 Nov 2022 01:58:47 -0800 |
parents | 529906fddcfa |
children | 0047c4c08d9e |
line wrap: on
line diff
--- a/mgw/dtmf_ctrl.c Sat Nov 19 23:08:49 2022 -0800 +++ b/mgw/dtmf_ctrl.c Sun Nov 20 01:58:47 2022 -0800 @@ -21,38 +21,7 @@ extern struct endpoint *find_ep_by_id(); -extern struct timeval cur_event_time; extern struct dtmf_desc dtmf_table[]; -extern int dtmf_timer_running; - -struct endpoint *dtmf_list_head; - -static void -add_to_dtmf_list(new_ep) - struct endpoint *new_ep; -{ - struct endpoint *ep, **epp; - - for (epp = &dtmf_list_head; *epp; epp = &ep->dtmf_next) - ; - *epp = new_ep; - new_ep->dtmf_pp = epp; -} - -void -dtmf_stop_immediate(ep) - struct endpoint *ep; -{ - if (ep->dtmf_frames_sent) - ep->dtmf_aftermath = 1; - *ep->dtmf_pp = ep->dtmf_next; - if (ep->dtmf_next) - ep->dtmf_next->dtmf_pp = ep->dtmf_pp; - ep->dtmf_pp = 0; - ep->dtmf_next = 0; - if (!dtmf_list_head) - dtmf_timer_running = 0; -} void process_dtmf_start(conn, req, resp) @@ -62,8 +31,6 @@ { struct endpoint *ep; struct dtmf_desc *desc; - struct timeval tv_last, tv_diff; - unsigned delta_frames; ep = find_ep_by_id(conn, req->ep_id); if (!ep) { @@ -81,37 +48,13 @@ resp->res = TMGW_RESP_ERR_PARAM; return; } - if (ep->dtmf_pp) { + if (ep->dtmf_sample_ptr) { resp->res = TMGW_RESP_ERR_BUSY; return; } - if (!ep->g2p_state) { - resp->res = TMGW_RESP_ERR_NOTRDY; - return; - } - /* figure out starting timestamp */ - 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, &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; - ep->dtmf_m_bit = 1; - } - } - /* initialize other state vars */ + /* start it */ + ep->dtmf_sample_ptr = desc->samples; ep->dtmf_frames_sent = 0; - ep->dtmf_sample_ptr = desc->samples; - ep->dtmf_stop_req = 0; - /* link it and start it */ - add_to_dtmf_list(ep); - start_dtmf_timer(); /* return success */ resp->res = TMGW_RESP_OK; } @@ -131,11 +74,6 @@ } if (ep->ep_type != TMGW_EP_TYPE_GATEWAY) goto protocol_err; - /* return OK whether we stop a tone or if there was none running */ + ep->dtmf_sample_ptr = 0; resp->res = TMGW_RESP_OK; - if (ep->dtmf_pp) { - ep->dtmf_stop_req = 1; - if (ep->dtmf_frames_sent >= DTMF_MIN_FRAMES) - dtmf_stop_immediate(ep); - } }