mirror of
https://github.com/signalwire/freeswitch.git
synced 2026-10-31 07:34:19 +00:00
update some macros and analog stuff
git-svn-id: http://svn.openzap.org/svn/openzap/trunk@142 a93c3328-9c30-0410-af19-c9cd2b2d52af
This commit is contained in:
1 parent
ea0cd7baf8
commit
7973f377e7
7 files changed
+140
-122
No files matched your search
@@ -34,17 +34,19 @@
|
||||
#include "openzap.h"
|
||||
#include "zap_analog.h"
|
||||
|
||||
zap_status_t zap_analog_configure_span(zap_span_t *span, zio_signal_cb_t sig_cb)
|
||||
zap_status_t zap_analog_configure_span(zap_span_t *span, char *tonemap, zio_signal_cb_t sig_cb)
|
||||
{
|
||||
|
||||
if (span->signal_type) {
|
||||
snprintf(span->last_error, sizeof(span->last_error), "Span is already configured for signalling.");
|
||||
return ZAP_FAIL;
|
||||
}
|
||||
|
||||
|
||||
span->analog_data = malloc(sizeof(*span->analog_data));
|
||||
assert(span->analog_data != NULL);
|
||||
memset(span->analog_data, 0, sizeof(*span->analog_data));
|
||||
span->signal_type = ZAP_SIGTYPE_ANALOG;
|
||||
zap_span_load_tones(span, tonemap);
|
||||
|
||||
return ZAP_SUCCESS;
|
||||
|
||||
@@ -60,7 +62,6 @@ static int teletone_handler(teletone_generation_session_t *ts, teletone_tone_map
|
||||
}
|
||||
wrote = teletone_mux_tones(ts, map);
|
||||
zap_buffer_write(dt_buffer, ts->buffer, wrote * 2);
|
||||
printf("add %d\n", wrote * 2);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -72,17 +73,18 @@ static void *zap_analog_channel_run(zap_thread_t *me, void *obj)
|
||||
uint8_t frame[1024];
|
||||
zap_size_t len, rlen;
|
||||
zap_codec_t codec = ZAP_CODEC_SLIN, old_codec;
|
||||
char *tones[] = { "%(1000,0,350,440)",
|
||||
"%(500,500,480,620)",
|
||||
"v=2000;%(100,100,1400,2060,2450,2600)",
|
||||
NULL };
|
||||
|
||||
char *tones[4] = {0};
|
||||
time_t start;
|
||||
int isbz = 0;
|
||||
int wtime = 10;
|
||||
zap_tone_type_t tt = ZAP_TONE_DTMF;
|
||||
int play_tones = 1;
|
||||
|
||||
|
||||
tones[0] = chan->span->tone_map[ZAP_TONEMAP_DIAL];
|
||||
tones[1] = chan->span->tone_map[ZAP_TONEMAP_BUSY];
|
||||
tones[2] = chan->span->tone_map[ZAP_TONEMAP_ATTN];
|
||||
|
||||
zap_log(ZAP_LOG_DEBUG, "ANALOG CHANNEL thread starting.\n");
|
||||
|
||||
if (zap_channel_open_chan(chan) != ZAP_SUCCESS) {
|
||||
@@ -96,16 +98,16 @@ static void *zap_analog_channel_run(zap_thread_t *me, void *obj)
|
||||
if (zap_channel_command(chan, ZAP_COMMAND_ENABLE_TONE_DETECT, &tt) != ZAP_SUCCESS) {
|
||||
goto done;
|
||||
}
|
||||
/*zap_channel_set_event_callback(chan, my_zap_event_handler);*/
|
||||
|
||||
|
||||
zap_set_flag_locked(chan, ZAP_CHANNEL_INTHREAD);
|
||||
zap_set_state_locked(chan, ZAP_CHANNEL_STATE_DIALTONE);
|
||||
|
||||
teletone_init_session(&ts, 0, teletone_handler, dt_buffer);
|
||||
ts.rate = 8000;
|
||||
#if 0
|
||||
ts.debug = 1;
|
||||
ts.debug_stream = stdout;
|
||||
#endif
|
||||
ts.rate = 8000;
|
||||
teletone_run(&ts, tones[isbz++]);
|
||||
zap_channel_command(chan, ZAP_COMMAND_GET_CODEC, &old_codec);
|
||||
zap_channel_command(chan, ZAP_COMMAND_SET_CODEC, &codec);
|
||||
@@ -113,8 +115,6 @@ static void *zap_analog_channel_run(zap_thread_t *me, void *obj)
|
||||
|
||||
time(&start);
|
||||
|
||||
|
||||
|
||||
while (chan->state >= ZAP_CHANNEL_STATE_DIALTONE && zap_test_flag(chan, ZAP_CHANNEL_INTHREAD)) {
|
||||
zap_wait_flag_t flags = ZAP_READ;
|
||||
char dtmf[128];
|
||||
@@ -167,7 +167,7 @@ static void *zap_analog_channel_run(zap_thread_t *me, void *obj)
|
||||
|
||||
static zap_status_t process_event(zap_span_t *span, zap_event_t *event)
|
||||
{
|
||||
zap_log(ZAP_LOG_DEBUG, "EVENT [%s][%d:%d]\n", zap_oob_signal2str(event->enum_id), event->channel->span_id, event->channel->chan_id);
|
||||
zap_log(ZAP_LOG_DEBUG, "EVENT [%s][%d:%d]\n", zap_oob_event2str(event->enum_id), event->channel->span_id, event->channel->chan_id);
|
||||
|
||||
switch(event->enum_id) {
|
||||
case ZAP_OOB_ONHOOK:
|
||||
|
||||
Reference in new issue
Block a user