git-svn-id: http://svn.openzap.org/svn/openzap/trunk@212 a93c3328-9c30-0410-af19-c9cd2b2d52af
This commit is contained in:
Anthony Minessale 2007-06-05 03:04:35 +00:00
parent 5fb33efc0b
commit 9d1b445884
5 changed files with 44 additions and 4 deletions

View File

@ -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;

View File

@ -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);
}

View File

@ -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);

View File

@ -36,7 +36,8 @@
#include "openzap.h"
#include "zap_wanpipe.h"
#include <sangoma_tdm_api.h>
/*#include <sangoma_tdm_api.h>*/
#include <wanpipe_tdm_api.h>
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;

View File

@ -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;