diff --git a/libs/freetdm/src/include/openzap.h b/libs/freetdm/src/include/openzap.h index dcbbf41ef9..f7a020d4c8 100644 --- a/libs/freetdm/src/include/openzap.h +++ b/libs/freetdm/src/include/openzap.h @@ -237,6 +237,7 @@ struct zap_channel { uint32_t chan_id; uint32_t physical_span_id; uint32_t physical_chan_id; + uint32_t rate; zap_chan_type_t type; zap_socket_t sockfd; zap_channel_flag_t flags; diff --git a/libs/freetdm/src/testcid.c b/libs/freetdm/src/testcid.c new file mode 100644 index 0000000000..f91ee59d96 --- /dev/null +++ b/libs/freetdm/src/testcid.c @@ -0,0 +1,35 @@ +#include "openzap.h" + +int main(int argc, char *argv[]) +{ + zap_fsk_data_state_t state = {0}; + int fd; + int16_t buf[160] = {0}; + ssize_t len = 0; + int type, mlen; + char str[128]; + char fbuf[256]; + + if (argc < 2 || zap_fsk_demod_init(&state, 8000, fbuf, sizeof(fbuf))) { + printf("wtf\n"); + return 0; + } + + if ((fd = open(argv[1], O_RDONLY)) < 0) { + fprintf(stderr, "cant open file %s\n", argv[1]); + exit (-1); + } + + while((len = read(fd, buf, sizeof(buf))) > 0) { + if (zap_fsk_demod_feed(&state, buf, len / 2) != ZAP_SUCCESS) { + break; + } + } + + while(zap_fsk_data_parse(&state, &type, &mlen, str, sizeof(str)) == ZAP_SUCCESS) { + printf("TYPE %d LEN %d VAL [%s]\n", type, mlen, str); + } + + + close(fd); +} diff --git a/libs/freetdm/src/zap_io.c b/libs/freetdm/src/zap_io.c index 96089c5322..a792ab6b0f 100644 --- a/libs/freetdm/src/zap_io.c +++ b/libs/freetdm/src/zap_io.c @@ -770,7 +770,7 @@ static zap_status_t zchan_activate_dtmf_buffer(zap_channel_t *zchan) memset(&zchan->tone_session, 0, sizeof(zchan->tone_session)); teletone_init_session(&zchan->tone_session, 0, NULL, NULL); - zchan->tone_session.rate = 8000; + zchan->tone_session.rate = zchan->rate; zchan->tone_session.duration = zchan->dtmf_on * (zchan->tone_session.rate / 1000); zchan->tone_session.wait = zchan->dtmf_off * (zchan->tone_session.rate / 1000); /* @@ -910,7 +910,7 @@ zap_status_t zap_channel_command(zap_channel_t *zchan, zap_command_t command, vo if (!zap_channel_test_feature(zchan, ZAP_CHANNEL_FEATURE_DTMF)) { zap_tone_type_t tt = ZAP_COMMAND_OBJ_INT; if (tt == ZAP_TONE_DTMF) { - teletone_dtmf_detect_init (&zchan->dtmf_detect, 8000); + teletone_dtmf_detect_init (&zchan->dtmf_detect, zchan->rate); zap_set_flag_locked(zchan, ZAP_CHANNEL_DTMF_DETECT); zap_set_flag_locked(zchan, ZAP_CHANNEL_SUPRESS_DTMF); GOTO_STATUS(done, ZAP_SUCCESS); @@ -926,7 +926,7 @@ zap_status_t zap_channel_command(zap_channel_t *zchan, zap_command_t command, vo if (!zap_channel_test_feature(zchan, ZAP_CHANNEL_FEATURE_DTMF)) { zap_tone_type_t tt = ZAP_COMMAND_OBJ_INT; if (tt == ZAP_TONE_DTMF) { - teletone_dtmf_detect_init (&zchan->dtmf_detect, 8000); + teletone_dtmf_detect_init (&zchan->dtmf_detect, zchan->rate); zap_clear_flag(zchan, ZAP_CHANNEL_DTMF_DETECT); zap_clear_flag(zchan, ZAP_CHANNEL_SUPRESS_DTMF); GOTO_STATUS(done, ZAP_SUCCESS); diff --git a/libs/freetdm/src/zap_wanpipe.c b/libs/freetdm/src/zap_wanpipe.c index 3e9e7501de..c5883bdd86 100644 --- a/libs/freetdm/src/zap_wanpipe.c +++ b/libs/freetdm/src/zap_wanpipe.c @@ -36,7 +36,8 @@ #include "openzap.h" #include "zap_wanpipe.h" -#include +/*#include */ +#include static struct { uint32_t codec_ms; @@ -74,6 +75,8 @@ static unsigned wp_open_range(zap_span_t *span, unsigned spanno, unsigned start, zap_log(ZAP_LOG_INFO, "configuring device s%dc%d as OpenZAP device %d:%d fd:%d\n", spanno, x, chan->span_id, chan->chan_id, sockfd); chan->physical_span_id = spanno; chan->physical_chan_id = x; + chan->rate = 8000; + if (type == ZAP_CHAN_TYPE_FXS || type == ZAP_CHAN_TYPE_FXO) { wanpipe_tdm_api_t tdm_api; diff --git a/libs/freetdm/src/zap_zt.c b/libs/freetdm/src/zap_zt.c index 49d9edea60..db940d5c54 100644 --- a/libs/freetdm/src/zap_zt.c +++ b/libs/freetdm/src/zap_zt.c @@ -90,6 +90,7 @@ static unsigned zt_open_range(zap_span_t *span, unsigned start, unsigned end, za } zap_log(ZAP_LOG_INFO, "configuring device %s as OpenZAP device %d:%d fd:%d\n", path, chan->span_id, chan->chan_id, sockfd); + chan->rate = 8000; chan->physical_span_id = ztp.span_no; chan->physical_chan_id = ztp.chan_no;