parent
979d0b7c64
commit
47d4849bab
181
chan_capi.c
181
chan_capi.c
|
@ -591,10 +591,11 @@ static int capi_check_diva_tone_function_allowed(struct capi_pvt *i)
|
|||
int ecAvail = 0;
|
||||
|
||||
if ((i->isdnstate & CAPI_ISDN_STATE_DISCONNECT))
|
||||
return (-1);
|
||||
return -1;
|
||||
|
||||
if (i->channeltype == CAPI_CHANNELTYPE_NULL && i->resource_plci_type != CAPI_RESOURCE_PLCI_DATA) {
|
||||
return (-1);
|
||||
if ((i->channeltype == CAPI_CHANNELTYPE_NULL) &&
|
||||
(i->resource_plci_type != CAPI_RESOURCE_PLCI_DATA)) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* check for old echo-cancel configuration */
|
||||
|
@ -607,17 +608,18 @@ static int capi_check_diva_tone_function_allowed(struct capi_pvt *i)
|
|||
ecAvail = 1;
|
||||
}
|
||||
|
||||
if (ecAvail == 0 || capi_controllers[i->controller]->divaExtendedFeaturesAvailable == 0) {
|
||||
return (-1);
|
||||
if ((ecAvail == 0) ||
|
||||
(capi_controllers[i->controller]->divaExtendedFeaturesAvailable == 0)) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (capi_tcap_is_digital(i->transfercapability)) {
|
||||
cc_verbose(3, 1, VERBOSE_PREFIX_2 "%s: No audio features in digital mode (PLCI=%#x)\n",
|
||||
i->vname, i->PLCI);
|
||||
return (-1);
|
||||
return -1;
|
||||
}
|
||||
|
||||
return (0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -631,7 +633,6 @@ static void capi_diva_audio_features(struct capi_pvt *i)
|
|||
cc_verbose(3, 0, VERBOSE_PREFIX_2 "%s: Setting up audio features (PLCI=%#x, function=%04x, rx=%u, tx=%u)\n",
|
||||
i->vname, i->PLCI, i->divaAudioFlags, i->divaDigitalRxGain, i->divaDigitalTxGain);
|
||||
|
||||
|
||||
capi_sendf (i, 0, CAPI_MANUFACTURER_REQ, i->PLCI, get_capi_MessageNumber(),
|
||||
"dw(b(bwww))",
|
||||
_DI_MANU_ID,
|
||||
|
@ -666,12 +667,13 @@ static void capi_diva_tone_processing_function(struct capi_pvt *i, unsigned char
|
|||
capi_sendf (i, 0, CAPI_FACILITY_REQ, i->PLCI, get_capi_MessageNumber(), "w(www())", 1, function, 0, 0);
|
||||
}
|
||||
|
||||
static void capi_diva_send_tone_function(struct capi_pvt *i, unsigned char tone) {
|
||||
static void capi_diva_send_tone_function(struct capi_pvt *i, unsigned char tone)
|
||||
{
|
||||
if (capi_check_diva_tone_function_allowed(i) != 0)
|
||||
return;
|
||||
|
||||
capi_sendf (i, 0, CAPI_FACILITY_REQ, i->PLCI, get_capi_MessageNumber(), "w(www(b)())",
|
||||
FACILITYSELECTOR_DTMF, 252, /* send tone */ 0, 0, tone);
|
||||
FACILITYSELECTOR_DTMF, 252, /* send tone */ 0, 0, tone);
|
||||
}
|
||||
|
||||
static void capi_diva_pitch_control_command(struct capi_pvt *i, int enable, unsigned short rxpitch, unsigned short txpitch)
|
||||
|
@ -700,7 +702,8 @@ static int capi_detect_dtmf(struct capi_pvt *i, int flag)
|
|||
if ((i->isdnstate & CAPI_ISDN_STATE_DISCONNECT))
|
||||
return 0;
|
||||
|
||||
if (i->channeltype == CAPI_CHANNELTYPE_NULL && i->resource_plci_type != CAPI_RESOURCE_PLCI_DATA) {
|
||||
if ((i->channeltype == CAPI_CHANNELTYPE_NULL) &&
|
||||
(i->resource_plci_type != CAPI_RESOURCE_PLCI_DATA)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -2392,44 +2395,44 @@ static int pbx_capi_receive_fax(struct ast_channel *c, char *data)
|
|||
break;
|
||||
case 'f': /* use Fine resolution */
|
||||
cc_verbose(3, 1,
|
||||
VERBOSE_PREFIX_3 CC_MESSAGE_NAME " receivefax: Allow Fine resolution");
|
||||
b3_protocol_options |= 0x0001;
|
||||
VERBOSE_PREFIX_3 CC_MESSAGE_NAME " receivefax: Allow Fine resolution\n");
|
||||
b3_protocol_options |= 0x0001;
|
||||
break;
|
||||
case 'u': /* use Fine resolution */
|
||||
cc_verbose(3, 1,
|
||||
VERBOSE_PREFIX_3 CC_MESSAGE_NAME " receivefax: Allow Super/Ultra fine resolution");
|
||||
b3_protocol_options |= 0x0001;
|
||||
VERBOSE_PREFIX_3 CC_MESSAGE_NAME " receivefax: Allow Super/Ultra fine resolution\n");
|
||||
b3_protocol_options |= 0x0001;
|
||||
extended_resolution = 1;
|
||||
break;
|
||||
case 'j': /* enable JPEG encoding */
|
||||
cc_verbose(3, 1,
|
||||
VERBOSE_PREFIX_3 CC_MESSAGE_NAME " receivefax: enable JPEG coding");
|
||||
VERBOSE_PREFIX_3 CC_MESSAGE_NAME " receivefax: enable JPEG coding\n");
|
||||
b3_protocol_options |= 0x0400;
|
||||
break;
|
||||
case 'b': /* enable T.43 encoding */
|
||||
cc_verbose(3, 1,
|
||||
VERBOSE_PREFIX_3 CC_MESSAGE_NAME " receivefax: enable T.43 coding");
|
||||
VERBOSE_PREFIX_3 CC_MESSAGE_NAME " receivefax: enable T.43 coding\n");
|
||||
b3_protocol_options |= 0x0800;
|
||||
break;
|
||||
case 't': /* diasble T.85 encoding */
|
||||
cc_verbose(3, 1,
|
||||
VERBOSE_PREFIX_3 CC_MESSAGE_NAME " receivefax: Do not use T.85 coding");
|
||||
b3_protocol_options |= 0x1000;
|
||||
VERBOSE_PREFIX_3 CC_MESSAGE_NAME " receivefax: Do not use T.85 coding\n");
|
||||
b3_protocol_options |= 0x1000;
|
||||
break;
|
||||
case 'e': /* disable ECM encoding */
|
||||
cc_verbose(3, 1,
|
||||
VERBOSE_PREFIX_3 CC_MESSAGE_NAME " receivefax: Do not use ECM");
|
||||
b3_protocol_options |= 0x8000;
|
||||
VERBOSE_PREFIX_3 CC_MESSAGE_NAME " receivefax: Do not use ECM\n");
|
||||
b3_protocol_options |= 0x8000;
|
||||
break;
|
||||
case 'm': /* disable MMR encoding */
|
||||
cc_verbose(3, 1,
|
||||
VERBOSE_PREFIX_3 CC_MESSAGE_NAME " receivefax: do not use MMR (T.6) coding");
|
||||
b3_protocol_options |= 0x4000;
|
||||
VERBOSE_PREFIX_3 CC_MESSAGE_NAME " receivefax: do not use MMR (T.6) coding\n");
|
||||
b3_protocol_options |= 0x4000;
|
||||
break;
|
||||
case 'd': /* disable MR encoding */
|
||||
cc_verbose(3, 1,
|
||||
VERBOSE_PREFIX_3 CC_MESSAGE_NAME " receivefax: do not use MR (2D) coding");
|
||||
b3_protocol_options |= 0x2000;
|
||||
VERBOSE_PREFIX_3 CC_MESSAGE_NAME " receivefax: do not use MR (2D) coding\n");
|
||||
b3_protocol_options |= 0x2000;
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -2451,9 +2454,9 @@ static int pbx_capi_receive_fax(struct ast_channel *c, char *data)
|
|||
/*
|
||||
Per PLCI control is available only starting with Diva 9.0 SU1
|
||||
Without per PLCI control setting is applied to controller
|
||||
*/
|
||||
*/
|
||||
capi_sendf (NULL, 0, CAPI_MANUFACTURER_REQ, i->PLCI, get_capi_MessageNumber(),
|
||||
"dw(d)", _DI_MANU_ID, _DI_OPTIONS_REQUEST, 0x00000040L);
|
||||
"dw(d)", _DI_MANU_ID, _DI_OPTIONS_REQUEST, 0x00000040L);
|
||||
}
|
||||
|
||||
i->FaxState |= CAPI_FAX_STATE_ACTIVE;
|
||||
|
@ -2565,23 +2568,23 @@ static int pbx_capi_send_fax(struct ast_channel *c, char *data)
|
|||
|
||||
/*
|
||||
Get file format
|
||||
*/
|
||||
*/
|
||||
{
|
||||
unsigned char tmp[2] = { 0, 0 };
|
||||
|
||||
if (fread (tmp, 1, 2, i->fFax) != 2) {
|
||||
if (fread(tmp, 1, 2, i->fFax) != 2) {
|
||||
cc_log(LOG_WARNING, "can't read fax file (%s)\n", strerror(errno));
|
||||
fclose (i->fFax);
|
||||
fclose(i->fFax);
|
||||
i->fFax = 0;
|
||||
return (-1);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (tmp[0] == 0x53 && tmp[1] == 0x66) { /* SFF */
|
||||
if ((tmp[0] == 0x53) && (tmp[1] == 0x66)) { /* SFF */
|
||||
file_format = FAX_SFF_FORMAT;
|
||||
} else if (tmp[0] == 0xff && tmp[1] == 0xd8) { /* JPEG */
|
||||
} else if ((tmp[0] == 0xff) && (tmp[1] == 0xd8)) { /* JPEG */
|
||||
file_format = FAX_NATIVE_FILE_TRANSFER_FORMAT;
|
||||
b3_protocol_options |= 0x0400;
|
||||
} else if (tmp[0] == 0xff && tmp[1] == 0xa8) { /* T.43 */
|
||||
} else if ((tmp[0] == 0xff) && (tmp[1] == 0xa8)) { /* T.43 */
|
||||
file_format = FAX_NATIVE_FILE_TRANSFER_FORMAT;
|
||||
b3_protocol_options |= 0x0800;
|
||||
} else { /* TXT */
|
||||
|
@ -2589,44 +2592,43 @@ static int pbx_capi_send_fax(struct ast_channel *c, char *data)
|
|||
}
|
||||
}
|
||||
|
||||
rewind (i->fFax);
|
||||
rewind(i->fFax);
|
||||
|
||||
/* parse the options */
|
||||
while ((options) && (*options)) {
|
||||
switch (*options) {
|
||||
case 'f': /* use Fine resolution */
|
||||
cc_verbose(3, 1,
|
||||
VERBOSE_PREFIX_3 CC_MESSAGE_NAME " receivefax: Use Fine resolution");
|
||||
b3_protocol_options |= 0x0001;
|
||||
VERBOSE_PREFIX_3 CC_MESSAGE_NAME " receivefax: Use Fine resolution\n");
|
||||
b3_protocol_options |= 0x0001;
|
||||
break;
|
||||
case 'u': /* use Fine resolution */
|
||||
cc_verbose(3, 1,
|
||||
VERBOSE_PREFIX_3 CC_MESSAGE_NAME " receivefax: Allow Super/Ultra fine resolution");
|
||||
b3_protocol_options |= 0x0001;
|
||||
VERBOSE_PREFIX_3 CC_MESSAGE_NAME " receivefax: Allow Super/Ultra fine resolution\n");
|
||||
b3_protocol_options |= 0x0001;
|
||||
extended_resolution = 1;
|
||||
break;
|
||||
case 'j': /* enable JPEG encoding */
|
||||
case 't': /* diasble T.85 encoding */
|
||||
cc_verbose(3, 1,
|
||||
VERBOSE_PREFIX_3 CC_MESSAGE_NAME " receivefax: Do not use T.85 coding");
|
||||
b3_protocol_options |= 0x1000;
|
||||
VERBOSE_PREFIX_3 CC_MESSAGE_NAME " receivefax: Do not use T.85 coding\n");
|
||||
b3_protocol_options |= 0x1000;
|
||||
break;
|
||||
case 'e': /* disable ECM encoding */
|
||||
cc_verbose(3, 1,
|
||||
VERBOSE_PREFIX_3 CC_MESSAGE_NAME " receivefax: Do not use ECM");
|
||||
b3_protocol_options |= 0x8000;
|
||||
VERBOSE_PREFIX_3 CC_MESSAGE_NAME " receivefax: Do not use EC\nM");
|
||||
b3_protocol_options |= 0x8000;
|
||||
break;
|
||||
case 'm': /* disable MMR encoding */
|
||||
cc_verbose(3, 1,
|
||||
VERBOSE_PREFIX_3 CC_MESSAGE_NAME " receivefax: do not use MMR (T.6) coding");
|
||||
b3_protocol_options |= 0x4000;
|
||||
VERBOSE_PREFIX_3 CC_MESSAGE_NAME " receivefax: do not use MMR (T.6) coding\n");
|
||||
b3_protocol_options |= 0x4000;
|
||||
break;
|
||||
case 'd': /* disable MR encoding */
|
||||
cc_verbose(3, 1,
|
||||
VERBOSE_PREFIX_3 CC_MESSAGE_NAME " receivefax: do not use MR (2D) coding");
|
||||
b3_protocol_options |= 0x2000;
|
||||
VERBOSE_PREFIX_3 CC_MESSAGE_NAME " receivefax: do not use MR (2D) coding\n");
|
||||
b3_protocol_options |= 0x2000;
|
||||
break;
|
||||
|
||||
default:
|
||||
cc_log(LOG_WARNING, "Unknown option '%c' for receivefax.\n",
|
||||
*options);
|
||||
|
@ -2638,9 +2640,9 @@ static int pbx_capi_send_fax(struct ast_channel *c, char *data)
|
|||
/*
|
||||
Per PLCI control is available only starting with Diva 9.0 SU1
|
||||
Without per PLCI control setting is applied to controller
|
||||
*/
|
||||
*/
|
||||
capi_sendf (NULL, 0, CAPI_MANUFACTURER_REQ, i->PLCI, get_capi_MessageNumber(),
|
||||
"dw(d)", _DI_MANU_ID, _DI_OPTIONS_REQUEST, 0x00000040L);
|
||||
"dw(d)", _DI_MANU_ID, _DI_OPTIONS_REQUEST, 0x00000040L);
|
||||
}
|
||||
|
||||
i->FaxState |= (CAPI_FAX_STATE_ACTIVE | CAPI_FAX_STATE_SENDMODE);
|
||||
|
@ -3514,7 +3516,8 @@ static int handle_facility_indication_dtmf(
|
|||
dtmf = '*';
|
||||
break;
|
||||
|
||||
default: {
|
||||
default:
|
||||
{
|
||||
const char* special_tone_name = pbx_capi_map_detected_tone(dtmf);
|
||||
if ((special_tone_name != 0) && (i->owner != 0)) {
|
||||
int n = 0;
|
||||
|
@ -3536,7 +3539,8 @@ static int handle_facility_indication_dtmf(
|
|||
local_queue_frame(i, &fr);
|
||||
}
|
||||
}
|
||||
} break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (ignore_digit == 0) {
|
||||
|
@ -5035,7 +5039,7 @@ static int pbx_capi_noisesuppressor(struct ast_channel *c, char *param)
|
|||
{
|
||||
struct capi_pvt *i = CC_CHANNEL_PVT(c);
|
||||
|
||||
if (param == 0) {
|
||||
if (param == NULL) {
|
||||
cc_log(LOG_WARNING, "Parameter for noise suppressor missing.\n");
|
||||
return -1;
|
||||
}
|
||||
|
@ -5052,7 +5056,7 @@ static int pbx_capi_noisesuppressor(struct ast_channel *c, char *param)
|
|||
}
|
||||
|
||||
cc_verbose(2, 0, VERBOSE_PREFIX_4 "%s: noise suppressor switched %s\n",
|
||||
i->vname, (i->divaAudioFlags & 0x0080) != 0 ? "ON":"OFF");
|
||||
i->vname, (i->divaAudioFlags & 0x0080) != 0 ? "ON":"OFF");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -5065,13 +5069,13 @@ static unsigned short dbGain2DivaGain(float dbGain)
|
|||
float newGain;
|
||||
|
||||
if (dbGain < -126)
|
||||
return (0x100);
|
||||
return 0x100;
|
||||
if (dbGain == -126)
|
||||
return (0x101);
|
||||
return 0x101;
|
||||
if (dbGain == 0)
|
||||
return (0x8000);
|
||||
return 0x8000;
|
||||
if (dbGain >= 6)
|
||||
return (0x8600);
|
||||
return 0x8600;
|
||||
|
||||
newGain = 0x8000 + (dbGain * 256.0);
|
||||
|
||||
|
@ -5083,12 +5087,12 @@ static int pbx_capi_rxdgain(struct ast_channel *c, char *param)
|
|||
struct capi_pvt *i = CC_CHANNEL_PVT(c);
|
||||
float dbGain;
|
||||
|
||||
if (param == 0) {
|
||||
if (param == NULL) {
|
||||
cc_log(LOG_WARNING, "Parameter for rx gain missing.\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
dbGain = atof (param);
|
||||
dbGain = atof(param);
|
||||
|
||||
cc_mutex_lock(&i->lock);
|
||||
i->divaDigitalRxGainDB = dbGain;
|
||||
|
@ -5108,7 +5112,7 @@ static int pbx_capi_incrxdgain(struct ast_channel *c, char *param)
|
|||
struct capi_pvt *i = CC_CHANNEL_PVT(c);
|
||||
float dbGainInc;
|
||||
|
||||
if (param == 0) {
|
||||
if (param == NULL) {
|
||||
cc_log(LOG_WARNING, "Parameter for nncremental rx gain missing.\n");
|
||||
return -1;
|
||||
}
|
||||
|
@ -5124,7 +5128,7 @@ static int pbx_capi_incrxdgain(struct ast_channel *c, char *param)
|
|||
cc_verbose(2, 0, VERBOSE_PREFIX_4 "%s: inc rx gain %f : %04x\n",
|
||||
i->vname, i->divaDigitalRxGainDB, i->divaDigitalRxGain);
|
||||
|
||||
return (0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int pbx_capi_txdgain(struct ast_channel *c, char *param)
|
||||
|
@ -5132,7 +5136,7 @@ static int pbx_capi_txdgain(struct ast_channel *c, char *param)
|
|||
struct capi_pvt *i = CC_CHANNEL_PVT(c);
|
||||
float dbGain;
|
||||
|
||||
if (param == 0) {
|
||||
if (param == NULL) {
|
||||
cc_log(LOG_WARNING, "Parameter for tx gain missing.\n");
|
||||
return -1;
|
||||
}
|
||||
|
@ -5199,7 +5203,7 @@ static int pbx_capi_rxagc(struct ast_channel *c, char *param)
|
|||
}
|
||||
|
||||
cc_verbose(2, 0, VERBOSE_PREFIX_4 "%s: rx AGC switched %s\n",
|
||||
i->vname, (i->divaAudioFlags & 0x0008) != 0 ? "ON":"OFF");
|
||||
i->vname, (i->divaAudioFlags & 0x0008) != 0 ? "ON":"OFF");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -5225,7 +5229,7 @@ static int pbx_capi_txagc(struct ast_channel *c, char *param)
|
|||
}
|
||||
|
||||
cc_verbose(2, 0, VERBOSE_PREFIX_4 "%s: tx AGC switched %s\n",
|
||||
i->vname, (i->divaAudioFlags & 0x0004) != 0 ? "ON":"OFF");
|
||||
i->vname, (i->divaAudioFlags & 0x0004) != 0 ? "ON":"OFF");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -5242,7 +5246,7 @@ static int pbx_capi_getplci(struct ast_channel *c, char *param)
|
|||
pbx_builtin_setvar_helper(c, "CAPIPLCI", buffer);
|
||||
}
|
||||
|
||||
return (0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -5254,10 +5258,10 @@ static int pbx_capi_clamping(struct ast_channel *c, char *param)
|
|||
int duration = 0;
|
||||
|
||||
i = pbx_check_resource_plci (c);
|
||||
if (i == 0)
|
||||
if (i == NULL)
|
||||
i = CC_CHANNEL_PVT(c);
|
||||
|
||||
if (param != 0) {
|
||||
if (param != NULL) {
|
||||
duration = atoi(param);
|
||||
if (duration != 0 && duration < 10)
|
||||
duration = 10;
|
||||
|
@ -5267,7 +5271,7 @@ static int pbx_capi_clamping(struct ast_channel *c, char *param)
|
|||
|
||||
capi_diva_clamping(i, (unsigned short)duration);
|
||||
|
||||
return (0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
@ -5386,7 +5390,7 @@ static int pbx_capi_sendtone(struct ast_channel *c, char *param)
|
|||
for (n = 0; n < sizeof(diva_tx_tones)/sizeof(diva_tx_tones[0]) && diva_tx_tones[n].tone != tone; n++);
|
||||
if (n >= sizeof(diva_tx_tones)/sizeof(diva_tx_tones[0])) {
|
||||
cc_log(LOG_WARNING, "Unsupported tone %02x\n", tone);
|
||||
return (-1);
|
||||
return -1;
|
||||
}
|
||||
|
||||
capi_diva_send_tone_function(i, tone);
|
||||
|
@ -5405,7 +5409,7 @@ static int pbx_capi_stoptone(struct ast_channel *c, char *param)
|
|||
cc_verbose(2, 0, VERBOSE_PREFIX_4 "%s: stopped transmission of tones\n",
|
||||
i->vname);
|
||||
|
||||
return (0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const char* pbx_capi_map_detected_tone (unsigned char tone)
|
||||
|
@ -5466,7 +5470,7 @@ static const char* pbx_capi_map_detected_tone (unsigned char tone)
|
|||
}
|
||||
}
|
||||
|
||||
return (0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int pbx_capi_starttonedetection(struct ast_channel *c, char *param)
|
||||
|
@ -5491,7 +5495,7 @@ static int pbx_capi_starttonedetection(struct ast_channel *c, char *param)
|
|||
cc_verbose(2, 0, VERBOSE_PREFIX_4 "%s: Tone detection switched ON\n",
|
||||
i->vname);
|
||||
|
||||
return (0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int pbx_capi_stoptonedetection(struct ast_channel *c, char *param)
|
||||
|
@ -5507,7 +5511,7 @@ static int pbx_capi_stoptonedetection(struct ast_channel *c, char *param)
|
|||
cc_verbose(2, 0, VERBOSE_PREFIX_4 "%s: Tone detection switched OFF\n",
|
||||
i->vname);
|
||||
|
||||
return (0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int pbx_capi_pitchcontrol(struct ast_channel *c, char *param)
|
||||
|
@ -5516,8 +5520,8 @@ static int pbx_capi_pitchcontrol(struct ast_channel *c, char *param)
|
|||
unsigned short rxpitch = 0, txpitch = 0;
|
||||
int enabled = 1;
|
||||
|
||||
if ((param != 0) && (*param != 0)) {
|
||||
char* p = 0;
|
||||
if ((param != NULL) && (*param != 0)) {
|
||||
char* p = NULL;
|
||||
|
||||
txpitch = rxpitch = (unsigned short)strtol(param, &p, 0);
|
||||
if (p == param) {
|
||||
|
@ -5560,7 +5564,7 @@ static int pbx_capi_pitchcontrol(struct ast_channel *c, char *param)
|
|||
cc_verbose(2, 0, VERBOSE_PREFIX_4 "%s: Pitch control Rx:%u Tx:%u\n",
|
||||
i->vname, rxpitch, txpitch);
|
||||
|
||||
return (0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int pbx_capi_incpitchcontrol(struct ast_channel *c, char *param)
|
||||
|
@ -5568,16 +5572,16 @@ static int pbx_capi_incpitchcontrol(struct ast_channel *c, char *param)
|
|||
struct capi_pvt *i = CC_CHANNEL_PVT(c);
|
||||
signed short rxpitchinc = 0, txpitchinc = 0;
|
||||
int rxPitch = i->rxPitch, txPitch = i->txPitch;
|
||||
char* p = 0;
|
||||
char* p = NULL;
|
||||
|
||||
if ((param == 0) || (*param == 0)) {
|
||||
if ((param == NULL) || (*param == 0)) {
|
||||
cc_log(LOG_WARNING, "Parameter for incremental pitch control missing.\n");
|
||||
return (-1);
|
||||
return -1;
|
||||
}
|
||||
|
||||
rxpitchinc = (signed short)atoi(param);
|
||||
p = strchr(param, '|');
|
||||
if (p == 0) {
|
||||
if (p == NULL) {
|
||||
txpitchinc = rxpitchinc;
|
||||
} else {
|
||||
txpitchinc = (signed short)atoi(&p[1]);
|
||||
|
@ -5585,7 +5589,7 @@ static int pbx_capi_incpitchcontrol(struct ast_channel *c, char *param)
|
|||
|
||||
if ((rxpitchinc == 0) && (txpitchinc == 0)) {
|
||||
cc_log(LOG_WARNING, "Wrong parameter for incremental pitch control.\n");
|
||||
return (-1);
|
||||
return -1;
|
||||
}
|
||||
|
||||
rxPitch += rxpitchinc;
|
||||
|
@ -5607,7 +5611,7 @@ static int pbx_capi_incpitchcontrol(struct ast_channel *c, char *param)
|
|||
cc_verbose(2, 0, VERBOSE_PREFIX_4 "%s: Pitch control Rx:%u Tx:%u\n",
|
||||
i->vname, rxPitch, txPitch);
|
||||
|
||||
return (0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -5890,7 +5894,7 @@ pbx_capi_command_proc_t pbx_capi_lockup_command_by_name(const char* name)
|
|||
}
|
||||
}
|
||||
|
||||
return (0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -5934,7 +5938,7 @@ static int pbx_capicommand_exec(struct ast_channel *chan, void *data)
|
|||
}
|
||||
if (!capicmd->cmd) {
|
||||
#ifdef CC_AST_HAS_VERSION_1_4
|
||||
ast_module_user_remove(u);
|
||||
ast_module_user_remove(u);
|
||||
#else
|
||||
LOCAL_USER_REMOVE(u);
|
||||
#endif
|
||||
|
@ -5943,9 +5947,10 @@ static int pbx_capicommand_exec(struct ast_channel *chan, void *data)
|
|||
return -1;
|
||||
}
|
||||
|
||||
if ((capicmd->capionly != 0 && capicmd->resourceplcisupported == 0) && (chan->tech != &capi_tech)) {
|
||||
if (((capicmd->capionly != 0) && (capicmd->resourceplcisupported == 0)) &&
|
||||
(chan->tech != &capi_tech)) {
|
||||
#ifdef CC_AST_HAS_VERSION_1_4
|
||||
ast_module_user_remove(u);
|
||||
ast_module_user_remove(u);
|
||||
#else
|
||||
LOCAL_USER_REMOVE(u);
|
||||
#endif
|
||||
|
@ -5961,7 +5966,7 @@ static int pbx_capicommand_exec(struct ast_channel *chan, void *data)
|
|||
#else
|
||||
LOCAL_USER_REMOVE(u);
|
||||
#endif
|
||||
return(res);
|
||||
return res;
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -659,6 +659,7 @@ extern char chatinfo_usage[];
|
|||
typedef int (*pbx_capi_command_proc_t)(struct ast_channel *, char *);
|
||||
pbx_capi_command_proc_t pbx_capi_lockup_command_by_name(const char* name);
|
||||
|
||||
/* DIVA specific MANUFACTURER definitions */
|
||||
#define _DI_MANU_ID 0x44444944
|
||||
#define _DI_ASSIGN_PLCI 0x0001
|
||||
#define _DI_DSP_CTRL 0x0003
|
||||
|
|
|
@ -47,14 +47,15 @@ AST_MUTEX_DEFINE_STATIC(chat_lock);
|
|||
/*
|
||||
* partial update the capi mixer for the given char room
|
||||
*/
|
||||
static struct capichat_s* update_capi_mixer_part(struct capichat_s *chat_start,
|
||||
int overall_found,
|
||||
deffered_chat_capi_message_t* capi_msg,
|
||||
int remove,
|
||||
unsigned int roomnumber,
|
||||
struct capi_pvt *i)
|
||||
static struct capichat_s* update_capi_mixer_part(
|
||||
struct capichat_s *chat_start,
|
||||
int overall_found,
|
||||
deffered_chat_capi_message_t* capi_msg,
|
||||
int remove,
|
||||
unsigned int roomnumber,
|
||||
struct capi_pvt *i)
|
||||
{
|
||||
struct capi_pvt *ii, *ii_last = 0;
|
||||
struct capi_pvt *ii, *ii_last = NULL;
|
||||
struct capichat_s *room;
|
||||
unsigned char* p_list = &capi_msg->p_list[0];
|
||||
_cdword dest;
|
||||
|
@ -62,15 +63,15 @@ static struct capichat_s* update_capi_mixer_part(struct capichat_s *chat_start,
|
|||
capi_prestruct_t* p_struct = &capi_msg->p_struct;
|
||||
unsigned int found = 0;
|
||||
_cword j = 0;
|
||||
struct capichat_s *new_chat_start = 0;
|
||||
struct capichat_s *new_chat_start = NULL;
|
||||
|
||||
room = chat_start;
|
||||
while (room) {
|
||||
if ((room->number == roomnumber) &&
|
||||
(room->i != i)) {
|
||||
if (found >= PLCI_PER_LX_REQUEST || j + 9 > sizeof(capi_msg->p_list)) {
|
||||
if ((found >= PLCI_PER_LX_REQUEST) || ((j + 9) > sizeof(capi_msg->p_list))) {
|
||||
/* maybe we need to split capi messages here */
|
||||
new_chat_start = room;
|
||||
new_chat_start = room;
|
||||
break;
|
||||
}
|
||||
found++;
|
||||
|
@ -145,7 +146,7 @@ static void update_capi_mixer(int remove, unsigned int roomnumber, struct capi_p
|
|||
cc_mutex_lock(&chat_lock);
|
||||
/*
|
||||
Get overall amount of parties
|
||||
*/
|
||||
*/
|
||||
for (room = chat_list, overall_found = 0; room != 0; room = room->next) {
|
||||
overall_found += ((room->number == roomnumber) && (room->i != i));
|
||||
}
|
||||
|
@ -178,14 +179,14 @@ static void update_capi_mixer(int remove, unsigned int roomnumber, struct capi_p
|
|||
for (nr = 0; nr < segment_nr; nr++) {
|
||||
if (segments[nr].busy != 0) {
|
||||
cc_verbose(3, 1, VERBOSE_PREFIX_3 CC_MESSAGE_NAME
|
||||
" mixer: %s PLCI=0x%04x LI=0x%x\n", i->vname, i->PLCI, segments[nr].datapath);
|
||||
" mixer: %s PLCI=0x%04x LI=0x%x\n", i->vname, i->PLCI, segments[nr].datapath);
|
||||
|
||||
capi_sendf(NULL, 0, CAPI_FACILITY_REQ, i->PLCI, get_capi_MessageNumber(),
|
||||
"w(w(dc))",
|
||||
FACILITYSELECTOR_LINE_INTERCONNECT,
|
||||
0x0001, /* CONNECT */
|
||||
segments[nr].datapath,
|
||||
&segments[nr].p_struct);
|
||||
"w(w(dc))",
|
||||
FACILITYSELECTOR_LINE_INTERCONNECT,
|
||||
0x0001, /* CONNECT */
|
||||
segments[nr].datapath,
|
||||
&segments[nr].p_struct);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -424,11 +425,12 @@ int pbx_capi_chat(struct ast_channel *c, char *param)
|
|||
i = CC_CHANNEL_PVT(c);
|
||||
} else {
|
||||
/* virtual CAPI channel */
|
||||
i = pbx_check_resource_plci (c);
|
||||
i = pbx_check_resource_plci(c);
|
||||
|
||||
if (i == 0)
|
||||
if (i == NULL) {
|
||||
i = capi_mknullif(c, contr);
|
||||
if (!i) {
|
||||
}
|
||||
if (i == NULL) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
@ -459,7 +461,7 @@ out:
|
|||
return 0;
|
||||
}
|
||||
|
||||
struct capi_pvt* pbx_check_resource_plci (struct ast_channel *c)
|
||||
struct capi_pvt* pbx_check_resource_plci(struct ast_channel *c)
|
||||
{
|
||||
struct capi_pvt *i = NULL;
|
||||
const char* id = pbx_builtin_getvar_helper(c, "RESOURCEPLCI");
|
||||
|
@ -491,14 +493,14 @@ int pbx_capi_chat_associate_resource_plci(struct ast_channel *c, char *param)
|
|||
|
||||
if (c->tech != &capi_tech) {
|
||||
i = capi_mkresourceif(c, contr);
|
||||
if (i != 0) {
|
||||
if (i != NULL) {
|
||||
char buffer[24];
|
||||
snprintf(buffer, sizeof(buffer)-1, "%p", i);
|
||||
pbx_builtin_setvar_helper(c, "RESOURCEPLCI", buffer);
|
||||
}
|
||||
}
|
||||
|
||||
return ((i != 0) ? 0 : -1);
|
||||
return ((i != NULL) ? 0 : -1);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
*/
|
||||
extern int pbx_capi_chat(struct ast_channel *c, char *param);
|
||||
extern int pbx_capi_chat_associate_resource_plci(struct ast_channel *c, char *param);
|
||||
extern struct capi_pvt* pbx_check_resource_plci (struct ast_channel *c);
|
||||
extern struct capi_pvt* pbx_check_resource_plci(struct ast_channel *c);
|
||||
#ifdef CC_AST_HAS_VERSION_1_6
|
||||
extern char *pbxcli_capi_chatinfo(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a);
|
||||
#else
|
||||
|
|
|
@ -71,18 +71,19 @@ static void pbx_capi_voicecommand_insert_command (diva_entity_queue_t* q, pbx_ca
|
|||
* voicecommand|key|param1|param2|...
|
||||
*
|
||||
*/
|
||||
int pbx_capi_voicecommand (struct ast_channel *c, char *param) {
|
||||
int pbx_capi_voicecommand(struct ast_channel *c, char *param)
|
||||
{
|
||||
struct capi_pvt *i = CC_CHANNEL_PVT(c);
|
||||
pbx_capi_voice_command_t* cmd;
|
||||
const char* command[2];
|
||||
const char* key[2];
|
||||
size_t length;
|
||||
|
||||
if (param == 0 || *param == 0) { /* Remove all voice commands */
|
||||
if ((param == NULL) || (*param == 0)) { /* Remove all voice commands */
|
||||
cc_mutex_lock(&i->lock);
|
||||
pbx_capi_voicecommand_cleanup (i);
|
||||
pbx_capi_voicecommand_cleanup(i);
|
||||
cc_mutex_unlock(&i->lock);
|
||||
return (0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
command[0] = param;
|
||||
|
@ -103,7 +104,7 @@ int pbx_capi_voicecommand (struct ast_channel *c, char *param) {
|
|||
if ((command[1] - command[0]) < 2 || (command[1] - command[0]) >= sizeof(cmd->command_name) ||
|
||||
strchr(pbx_capi_voicecommand_digits, command[1][1]) == 0) {
|
||||
cc_log(LOG_WARNING, CC_MESSAGE_NAME" voicecommand requires an argument im format 'voicecommand[|key[|param1|param2|...]]'\n");
|
||||
return (-1);
|
||||
return -1;
|
||||
}
|
||||
key[0] = &command[1][1];
|
||||
key[1] = strchr (key[0], '|');
|
||||
|
@ -113,8 +114,8 @@ int pbx_capi_voicecommand (struct ast_channel *c, char *param) {
|
|||
key[1][1] == 0 || (length = strlen (&key[1][1])) >= sizeof(cmd->command_parameters)))) {
|
||||
|
||||
cc_log(LOG_WARNING, CC_MESSAGE_NAME
|
||||
" voicecommand requires an argument im format 'voicecommand[|key[|param1|param2|...]]'\n");
|
||||
return (-1);
|
||||
" voicecommand requires an argument im format 'voicecommand[|key[|param1|param2|...]]'\n");
|
||||
return -1;
|
||||
}
|
||||
if (key[1] == 0) {
|
||||
key[1] = key[0] + strlen(key[0]);
|
||||
|
@ -127,16 +128,16 @@ int pbx_capi_voicecommand (struct ast_channel *c, char *param) {
|
|||
for (p = key[0]; p < key[1]; p++) {
|
||||
if (strchr(pbx_capi_voicecommand_digits, *p) == 0) {
|
||||
cc_log(LOG_WARNING, CC_MESSAGE_NAME
|
||||
" voicecommand key can use only '%s'\n", pbx_capi_voicecommand_digits);
|
||||
return (-1);
|
||||
" voicecommand key can use only '%s'\n", pbx_capi_voicecommand_digits);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
cmd = malloc (sizeof(*cmd));
|
||||
if (cmd == 0) {
|
||||
cmd = malloc(sizeof(*cmd));
|
||||
if (cmd == NULL) {
|
||||
cc_log(LOG_WARNING, CC_MESSAGE_NAME " can not allocate memory for voice command\n");
|
||||
return (-1);
|
||||
return -1;
|
||||
}
|
||||
|
||||
memcpy (cmd->command_parameters, &key[1][1], length);
|
||||
|
@ -158,8 +159,8 @@ int pbx_capi_voicecommand (struct ast_channel *c, char *param) {
|
|||
|
||||
|
||||
cc_verbose(2, 0, VERBOSE_PREFIX_4 "%s: %svoicecommand:%s|%s|%s\n",
|
||||
i->vname, (cmd->pbx_capi_command == pbx_capi_command_nop) ? "dummy " : "",
|
||||
cmd->command_name, cmd->channel_command_digits, cmd->command_parameters);
|
||||
i->vname, (cmd->pbx_capi_command == pbx_capi_command_nop) ? "dummy " : "",
|
||||
cmd->command_name, cmd->channel_command_digits, cmd->command_parameters);
|
||||
|
||||
{
|
||||
pbx_capi_voice_command_t* present_cmd;
|
||||
|
@ -177,15 +178,16 @@ int pbx_capi_voicecommand (struct ast_channel *c, char *param) {
|
|||
}
|
||||
}
|
||||
|
||||
return (0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int pbx_capi_voicecommand_transparency (struct ast_channel *c, char *param) {
|
||||
int pbx_capi_voicecommand_transparency(struct ast_channel *c, char *param)
|
||||
{
|
||||
struct capi_pvt *i = CC_CHANNEL_PVT(c);
|
||||
|
||||
if (param == 0 || *param == 0) {
|
||||
if ((param == NULL) || (*param == 0)) {
|
||||
cc_log(LOG_WARNING, "Parameter for voicecommand transparency missing.\n");
|
||||
return (-1);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (ast_true(param)) {
|
||||
|
@ -194,51 +196,54 @@ int pbx_capi_voicecommand_transparency (struct ast_channel *c, char *param) {
|
|||
i->command_pass_digits = 0;
|
||||
} else {
|
||||
cc_log(LOG_WARNING, "Wrong parameter for voicecommand transparency.\n");
|
||||
return (-1);
|
||||
return -1;
|
||||
}
|
||||
|
||||
return (0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int pbx_capi_voicecommand_cleanup (struct capi_pvt *i) {
|
||||
int pbx_capi_voicecommand_cleanup(struct capi_pvt *i)
|
||||
{
|
||||
diva_entity_link_t* link;
|
||||
|
||||
while ((link = diva_q_get_head (&i->channel_command_q)) != 0) {
|
||||
diva_q_remove (&i->channel_command_q, link);
|
||||
free (link);
|
||||
while ((link = diva_q_get_head(&i->channel_command_q)) != NULL) {
|
||||
diva_q_remove(&i->channel_command_q, link);
|
||||
free(link);
|
||||
}
|
||||
|
||||
i->channel_command_digit = 0;
|
||||
i->channel_command_timestamp = 0;
|
||||
i->command_pass_digits = 0;
|
||||
|
||||
return (0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static pbx_capi_voice_command_t* pbx_capi_find_command (struct ast_channel *c, const char* name) {
|
||||
static pbx_capi_voice_command_t* pbx_capi_find_command(struct ast_channel *c, const char* name)
|
||||
{
|
||||
struct capi_pvt *i = CC_CHANNEL_PVT(c);
|
||||
diva_entity_link_t* link;
|
||||
|
||||
for (link = diva_q_get_head (&i->channel_command_q); link != 0; link = diva_q_get_next (link)) {
|
||||
if (strcmp (((pbx_capi_voice_command_t*)link)->command_name, name) == 0) {
|
||||
for (link = diva_q_get_head (&i->channel_command_q); link != 0; link = diva_q_get_next(link)) {
|
||||
if (strcmp(((pbx_capi_voice_command_t*)link)->command_name, name) == 0) {
|
||||
return ((pbx_capi_voice_command_t*)link);
|
||||
}
|
||||
}
|
||||
|
||||
return (0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static pbx_capi_voice_command_t* pbx_capi_find_command_by_key (struct ast_channel *c, const char* key) {
|
||||
static pbx_capi_voice_command_t* pbx_capi_find_command_by_key(struct ast_channel *c, const char* key)
|
||||
{
|
||||
struct capi_pvt *i = CC_CHANNEL_PVT(c);
|
||||
diva_entity_link_t* link;
|
||||
|
||||
for (link = diva_q_get_head (&i->channel_command_q); link != 0; link = diva_q_get_next (link)) {
|
||||
for (link = diva_q_get_head (&i->channel_command_q); link != 0; link = diva_q_get_next(link)) {
|
||||
if (strcmp (((pbx_capi_voice_command_t*)link)->channel_command_digits, key) == 0) {
|
||||
return ((pbx_capi_voice_command_t*)link);
|
||||
}
|
||||
}
|
||||
|
||||
return (0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -247,7 +252,8 @@ static pbx_capi_voice_command_t* pbx_capi_find_command_by_key (struct ast_channe
|
|||
* returs zero if digit should be processed as usually
|
||||
* returns -1 if digit should be discarded
|
||||
*/
|
||||
int pbx_capi_voicecommand_process_digit (struct capi_pvt *i, char digit) {
|
||||
int pbx_capi_voicecommand_process_digit(struct capi_pvt *i, char digit)
|
||||
{
|
||||
struct ast_channel *c = i->owner;
|
||||
pbx_capi_voice_command_t* cmd;
|
||||
int info;
|
||||
|
@ -256,15 +262,15 @@ int pbx_capi_voicecommand_process_digit (struct capi_pvt *i, char digit) {
|
|||
/*
|
||||
Simple algorithm due to low amount of entries, moreover all sequences will be short, only 1 ... 2 digits
|
||||
*/
|
||||
if (c == 0 || diva_q_get_head (&i->channel_command_q) == 0 ||
|
||||
strchr (pbx_capi_voicecommand_digits, digit) == 0) {
|
||||
if ((c == NULL) || (diva_q_get_head(&i->channel_command_q) == 0) ||
|
||||
(strchr(pbx_capi_voicecommand_digits, digit) == 0)) {
|
||||
i->channel_command_digit = 0;
|
||||
return (0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
t = time(0);
|
||||
if ((i->channel_command_digit != 0 && difftime (t, i->channel_command_timestamp) > 2) ||
|
||||
i->channel_command_digit >= (sizeof(i->channel_command_digits) - 1)) {
|
||||
if (((i->channel_command_digit != 0) && (difftime(t, i->channel_command_timestamp) > 2)) ||
|
||||
(i->channel_command_digit >= (sizeof(i->channel_command_digits) - 1))) {
|
||||
i->channel_command_digit = 0;
|
||||
}
|
||||
|
||||
|
@ -272,59 +278,65 @@ int pbx_capi_voicecommand_process_digit (struct capi_pvt *i, char digit) {
|
|||
|
||||
i->channel_command_digits[i->channel_command_digit++] = digit;
|
||||
i->channel_command_digits[i->channel_command_digit] = 0;
|
||||
cmd = pbx_capi_voicecommand_find_digit_command (&i->channel_command_q,
|
||||
i->channel_command_digits,
|
||||
i->channel_command_digit,
|
||||
&info);
|
||||
cmd = pbx_capi_voicecommand_find_digit_command(
|
||||
&i->channel_command_q,
|
||||
i->channel_command_digits,
|
||||
i->channel_command_digit,
|
||||
&info);
|
||||
|
||||
if (cmd != 0) {
|
||||
char command_parameters_copy[sizeof( cmd->command_parameters)];
|
||||
|
||||
i->channel_command_digit = 0;
|
||||
|
||||
cc_verbose(2, 0, VERBOSE_PREFIX_4 "%s: call voicecommand:%s|%s|%s\n",
|
||||
i->vname, cmd->command_name, cmd->channel_command_digits, cmd->command_parameters);
|
||||
i->vname, cmd->command_name, cmd->channel_command_digits, cmd->command_parameters);
|
||||
|
||||
strcpy (command_parameters_copy, cmd->command_parameters);
|
||||
info = ((*(cmd->pbx_capi_command))(c, command_parameters_copy));
|
||||
|
||||
cc_verbose(2, 0, VERBOSE_PREFIX_4 "%s: voicecommand:%s|%s|%s %s\n",
|
||||
i->vname, cmd->command_name, cmd->channel_command_digits, cmd->command_parameters, info == 0 ? "OK" : "ERROR");
|
||||
i->vname, cmd->command_name, cmd->channel_command_digits, cmd->command_parameters, info == 0 ? "OK" : "ERROR");
|
||||
|
||||
} else if (info == 0) {
|
||||
i->channel_command_digit = 0;
|
||||
return (0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return ((i->command_pass_digits != 0) ? 0 : -1);
|
||||
}
|
||||
|
||||
static pbx_capi_voice_command_t* pbx_capi_voicecommand_find_digit_command (diva_entity_queue_t* q,
|
||||
const char* digits,
|
||||
int length,
|
||||
int* info) {
|
||||
static pbx_capi_voice_command_t* pbx_capi_voicecommand_find_digit_command(
|
||||
diva_entity_queue_t* q,
|
||||
const char* digits,
|
||||
int length,
|
||||
int* info)
|
||||
{
|
||||
diva_entity_link_t* link;
|
||||
|
||||
for (*info = 0, link = diva_q_get_head (q);
|
||||
for (*info = 0, link = diva_q_get_head(q);
|
||||
link != 0 && length <= ((pbx_capi_voice_command_t*)link)->length;
|
||||
link = diva_q_get_next (link)) {
|
||||
pbx_capi_voice_command_t* cmd = (pbx_capi_voice_command_t*)link;
|
||||
|
||||
if (memcmp (digits, cmd->channel_command_digits, length) == 0) {
|
||||
if (memcmp(digits, cmd->channel_command_digits, length) == 0) {
|
||||
*info = 1;
|
||||
if (length == cmd->length) {
|
||||
return (cmd);
|
||||
return cmd;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return (0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int pbx_capi_command_nop (struct ast_channel *c, char *param) {
|
||||
return (0);
|
||||
static int pbx_capi_command_nop(struct ast_channel *c, char *param)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void pbx_capi_voicecommand_insert_command (diva_entity_queue_t* q, pbx_capi_voice_command_t* cmd) {
|
||||
static void pbx_capi_voicecommand_insert_command(diva_entity_queue_t* q, pbx_capi_voice_command_t* cmd)
|
||||
{
|
||||
diva_entity_link_t* link;
|
||||
|
||||
for (link = diva_q_get_head (q); link != 0; link = diva_q_get_next (link)) {
|
||||
|
@ -334,7 +346,7 @@ static void pbx_capi_voicecommand_insert_command (diva_entity_queue_t* q, pbx_ca
|
|||
}
|
||||
}
|
||||
|
||||
diva_q_add_tail (q, &cmd->link);
|
||||
diva_q_add_tail(q, &cmd->link);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -213,7 +213,7 @@ struct capi_pvt *capi_mknullif(struct ast_channel *c, unsigned long long control
|
|||
|
||||
struct capi_pvt *capi_mkresourceif(struct ast_channel *c, unsigned long long controllermask)
|
||||
{
|
||||
struct capi_pvt *data_ifc /*, *line_ifc */;
|
||||
struct capi_pvt *data_ifc /*, *line_ifc */;
|
||||
unsigned int controller = 1;
|
||||
int contrcount;
|
||||
int channelcount = 0xffff;
|
||||
|
@ -287,22 +287,22 @@ struct capi_pvt *capi_mkresourceif(struct ast_channel *c, unsigned long long con
|
|||
data_ifc->MessageNumber = get_capi_MessageNumber();
|
||||
|
||||
capi_sendf(NULL,
|
||||
0,
|
||||
CAPI_MANUFACTURER_REQ,
|
||||
controller,
|
||||
data_ifc->MessageNumber,
|
||||
"dw(wbb(www()()()()))",
|
||||
_DI_MANU_ID,
|
||||
_DI_ASSIGN_PLCI,
|
||||
4, /* data */
|
||||
0, /* bchannel */
|
||||
1, /* connect */
|
||||
1,1,0);
|
||||
0,
|
||||
CAPI_MANUFACTURER_REQ,
|
||||
controller,
|
||||
data_ifc->MessageNumber,
|
||||
"dw(wbb(www()()()()))",
|
||||
_DI_MANU_ID,
|
||||
_DI_ASSIGN_PLCI,
|
||||
4, /* data */
|
||||
0, /* bchannel */
|
||||
1, /* connect */
|
||||
1, 1, 0);
|
||||
|
||||
cc_verbose(3, 1, VERBOSE_PREFIX_4 "%s: created resource-interface on controller %d.\n",
|
||||
data_ifc->vname, data_ifc->controller);
|
||||
|
||||
return (data_ifc);
|
||||
return data_ifc;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -324,7 +324,7 @@ _cword get_capi_MessageNumber(void)
|
|||
|
||||
cc_mutex_unlock(&messagenumber_lock);
|
||||
|
||||
return(mn);
|
||||
return mn;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -627,7 +627,7 @@ MESSAGE_EXCHANGE_ERROR capi_sendf(
|
|||
ret = capi_wait_conf(capii, (command & 0xff00) | CAPI_CONF);
|
||||
}
|
||||
|
||||
return (ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -986,7 +986,6 @@ void show_capi_info(struct capi_pvt *i, _cword info)
|
|||
|
||||
cc_verbose(3, 0, VERBOSE_PREFIX_4 "%s: CAPI INFO 0x%04x: %s\n",
|
||||
name, info, p);
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1031,34 +1030,34 @@ unsigned capi_ListenOnController(unsigned int CIPmask, unsigned controller)
|
|||
*/
|
||||
unsigned capi_ManufacturerAllowOnController(unsigned controller)
|
||||
{
|
||||
MESSAGE_EXCHANGE_ERROR error;
|
||||
int waitcount = 50;
|
||||
_cmsg CMSG;
|
||||
MESSAGE_EXCHANGE_ERROR error;
|
||||
int waitcount = 50;
|
||||
_cmsg CMSG;
|
||||
|
||||
error = capi_sendf (NULL, 0, CAPI_MANUFACTURER_REQ, controller, get_capi_MessageNumber(),
|
||||
"dw(d)", _DI_MANU_ID, _DI_OPTIONS_REQUEST, 0x00000020L);
|
||||
error = capi_sendf (NULL, 0, CAPI_MANUFACTURER_REQ, controller, get_capi_MessageNumber(),
|
||||
"dw(d)", _DI_MANU_ID, _DI_OPTIONS_REQUEST, 0x00000020L);
|
||||
|
||||
if (error)
|
||||
goto done;
|
||||
if (error)
|
||||
goto done;
|
||||
|
||||
while (waitcount) {
|
||||
error = capidev_check_wait_get_cmsg(&CMSG);
|
||||
while (waitcount) {
|
||||
error = capidev_check_wait_get_cmsg(&CMSG);
|
||||
|
||||
if (IS_MANUFACTURER_CONF(&CMSG) && CMSG.ManuID == _DI_MANU_ID && (CMSG.Class & 0xffff) == _DI_OPTIONS_REQUEST) {
|
||||
error = (MESSAGE_EXCHANGE_ERROR)(CMSG.Class >> 16);
|
||||
break;
|
||||
}
|
||||
usleep(30000);
|
||||
waitcount--;
|
||||
}
|
||||
if (!waitcount)
|
||||
error = 0x100F;
|
||||
if (IS_MANUFACTURER_CONF(&CMSG) && (CMSG.ManuID == _DI_MANU_ID) &&
|
||||
((CMSG.Class & 0xffff) == _DI_OPTIONS_REQUEST)) {
|
||||
error = (MESSAGE_EXCHANGE_ERROR)(CMSG.Class >> 16);
|
||||
break;
|
||||
}
|
||||
usleep(30000);
|
||||
waitcount--;
|
||||
}
|
||||
if (!waitcount)
|
||||
error = 0x100F;
|
||||
|
||||
done:
|
||||
return error;
|
||||
done:
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* convert a number
|
||||
*/
|
||||
|
|
|
@ -20,21 +20,24 @@ extern char *emptyid;
|
|||
|
||||
extern void cc_verbose_internal(char *text, ...);
|
||||
|
||||
static inline int cc_verbose_check(int o_v, int c_d) {
|
||||
if (unlikely(((o_v == 0) || (option_verbose > o_v)) && ((!c_d) || ((c_d) && (capidebug)))))
|
||||
return (1);
|
||||
static inline int cc_verbose_check(int o_v, int c_d)
|
||||
{
|
||||
if (unlikely(((o_v == 0) || (option_verbose > o_v)) &&
|
||||
((!c_d) || ((c_d) && (capidebug))))) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
return (0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* helper for <pbx>_verbose with different verbose settings
|
||||
*/
|
||||
#define cc_verbose(o_v,c_d,text, args...) do { \
|
||||
if (cc_verbose_check(o_v, c_d) != 0) { \
|
||||
cc_verbose_internal(text , ## args); \
|
||||
if (cc_verbose_check(o_v, c_d) != 0) { \
|
||||
cc_verbose_internal(text , ## args); \
|
||||
} \
|
||||
}while(0)
|
||||
} while(0)
|
||||
|
||||
extern _cword get_capi_MessageNumber(void);
|
||||
extern struct capi_pvt *capi_find_interface_by_msgnum(unsigned short msgnum);
|
||||
|
@ -71,6 +74,6 @@ typedef struct capi_prestruct_s {
|
|||
*/
|
||||
extern MESSAGE_EXCHANGE_ERROR capi_sendf(
|
||||
struct capi_pvt *capii, int waitconf,
|
||||
_cword command, _cdword Id, _cword Number, char * format, ...);
|
||||
_cword command, _cdword Id, _cword Number, char * format, ...);
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue