interval
git-svn-id: http://svn.openzap.org/svn/openzap/trunk@41 a93c3328-9c30-0410-af19-c9cd2b2d52af
This commit is contained in:
parent
425083a45d
commit
426739b6b9
|
@ -166,6 +166,9 @@ struct zap_channel {
|
|||
zap_channel_feature_t features;
|
||||
zap_codec_t effective_codec;
|
||||
zap_codec_t native_codec;
|
||||
uint32_t effective_interval;
|
||||
uint32_t native_interval;
|
||||
uint32_t packet_len;
|
||||
teletone_dtmf_detect_state_t dtmf_detect;
|
||||
zap_event_t event_header;
|
||||
char last_error[256];
|
||||
|
|
|
@ -109,7 +109,8 @@ typedef enum {
|
|||
|
||||
typedef enum {
|
||||
ZAP_CHANNEL_FEATURE_DTMF = (1 << 0),
|
||||
ZAP_CHANNEL_FEATURE_CODECS = (1 << 1)
|
||||
ZAP_CHANNEL_FEATURE_CODECS = (1 << 1),
|
||||
ZAP_CHANNEL_FEATURE_INTERVAL = (1 << 2)
|
||||
} zap_channel_feature_t;
|
||||
|
||||
typedef enum {
|
||||
|
@ -118,7 +119,8 @@ typedef enum {
|
|||
ZAP_CHANNEL_OPEN = (1 << 2),
|
||||
ZAP_CHANNEL_DTMF_DETECT = (1 << 3),
|
||||
ZAP_CHANNEL_SUPRESS_DTMF = (1 << 4),
|
||||
ZAP_CHANNEL_TRANSCODE = (1 << 5)
|
||||
ZAP_CHANNEL_TRANSCODE = (1 << 5),
|
||||
ZAP_CHANNEL_BUFFER = (1 << 6)
|
||||
} zap_channel_flag_t;
|
||||
|
||||
typedef struct zap_channel zap_channel_t;
|
||||
|
|
|
@ -414,7 +414,29 @@ zap_status_t zap_channel_command(zap_channel_t *zchan, zap_command_t command, vo
|
|||
}
|
||||
|
||||
switch(command) {
|
||||
case ZAP_COMMAND_SET_CODEC:
|
||||
case ZAP_COMMAND_SET_INTERVAL:
|
||||
{
|
||||
if (!zap_channel_test_feature(zchan, ZAP_CHANNEL_FEATURE_INTERVAL)) {
|
||||
zchan->effective_interval = ZAP_COMMAND_OBJ_INT;
|
||||
if (zchan->effective_interval == zchan->native_interval) {
|
||||
zap_clear_flag(zchan, ZAP_CHANNEL_BUFFER);
|
||||
} else {
|
||||
zap_set_flag(zchan, ZAP_CHANNEL_BUFFER);
|
||||
}
|
||||
zchan->packet_len = zchan->native_interval * (zchan->effective_codec == ZAP_CODEC_SLIN ? 16 : 8);
|
||||
return ZAP_SUCCESS;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case ZAP_COMMAND_GET_INTERVAL:
|
||||
{
|
||||
if (!zap_channel_test_feature(zchan, ZAP_CHANNEL_FEATURE_INTERVAL)) {
|
||||
ZAP_COMMAND_OBJ_INT = zchan->effective_interval;
|
||||
return ZAP_SUCCESS;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case ZAP_COMMAND_SET_CODEC:
|
||||
{
|
||||
if (!zap_channel_test_feature(zchan, ZAP_CHANNEL_FEATURE_CODECS)) {
|
||||
zchan->effective_codec = ZAP_COMMAND_OBJ_INT;
|
||||
|
@ -423,6 +445,7 @@ zap_status_t zap_channel_command(zap_channel_t *zchan, zap_command_t command, vo
|
|||
} else {
|
||||
zap_set_flag(zchan, ZAP_CHANNEL_TRANSCODE);
|
||||
}
|
||||
zchan->packet_len = zchan->native_interval * (zchan->effective_codec == ZAP_CODEC_SLIN ? 16 : 8);
|
||||
return ZAP_SUCCESS;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -76,7 +76,6 @@ static unsigned wp_open_range(zap_span_t *span, unsigned spanno, unsigned start,
|
|||
if (sockfd != WP_INVALID_SOCKET && zap_span_add_channel(span, sockfd, type, &chan) == ZAP_SUCCESS) {
|
||||
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);
|
||||
configured++;
|
||||
|
||||
} else {
|
||||
zap_log(ZAP_LOG_ERROR, "failure configuring device s%dc%d\n", spanno, x);
|
||||
}
|
||||
|
@ -250,7 +249,10 @@ static ZINT_OPEN_FUNCTION(wanpipe_open)
|
|||
tdm_api.wp_tdm_cmd.cmd = SIOC_WP_TDM_SET_USR_PERIOD;
|
||||
tdm_api.wp_tdm_cmd.usr_period = wp_globals.codec_ms;
|
||||
wp_tdm_cmd_exec(zchan, &tdm_api);
|
||||
|
||||
zap_channel_set_feature(zchan, ZAP_CHANNEL_FEATURE_INTERVAL);
|
||||
zchan->effective_interval = zchan->native_interval = wp_globals.codec_ms;
|
||||
zchan->packet_len = zchan->native_interval * 8;
|
||||
|
||||
tdm_api.wp_tdm_cmd.cmd = SIOC_WP_TDM_GET_HW_CODING;
|
||||
if (tdm_api.wp_tdm_cmd.hw_tdm_coding) {
|
||||
zchan->native_codec = zchan->effective_codec = ZAP_CODEC_ULAW;
|
||||
|
@ -293,6 +295,7 @@ static ZINT_COMMAND_FUNCTION(wanpipe_command)
|
|||
tdm_api.wp_tdm_cmd.cmd = SIOC_WP_TDM_SET_USR_PERIOD;
|
||||
tdm_api.wp_tdm_cmd.usr_period = ZAP_COMMAND_OBJ_INT;
|
||||
err = wp_tdm_cmd_exec(zchan, &tdm_api);
|
||||
zchan->packet_len = zchan->native_interval * (zchan->effective_codec == ZAP_CODEC_SLIN ? 16 : 8);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
|
Loading…
Reference in New Issue