Allow to select codecs for capicommand rresource. Clean up.
This commit is contained in:
parent
f9f8279d8c
commit
3e71cbcc24
|
@ -189,11 +189,7 @@ static char capi_subscriber_prefix[AST_MAX_EXTENSION];
|
||||||
|
|
||||||
static char default_language[MAX_LANGUAGE] = "";
|
static char default_language[MAX_LANGUAGE] = "";
|
||||||
|
|
||||||
#ifdef CC_AST_HAS_FORMAT_T
|
cc_format_t capi_capability = AST_FORMAT_ALAW;
|
||||||
format_t capi_capability = AST_FORMAT_ALAW;
|
|
||||||
#else
|
|
||||||
int capi_capability = AST_FORMAT_ALAW;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static int null_plci_dtmf_support = 1;
|
static int null_plci_dtmf_support = 1;
|
||||||
|
|
||||||
|
@ -9019,7 +9015,7 @@ static void pbx_capi_add_diva_protocol_independent_extension (struct capi_pvt *i
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int pbx_capi_get_controller_codecs (int controller) {
|
cc_format_t pbx_capi_get_controller_codecs (int controller) {
|
||||||
return (capi_controllers[controller]->rtpcodec);
|
return (capi_controllers[controller]->rtpcodec);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
15
chan_capi.h
15
chan_capi.h
|
@ -71,6 +71,12 @@ struct _diva_stream_scheduling_entry;
|
||||||
|
|
||||||
#define CAPI_MAX_FACILITYDATAARRAY_SIZE 300
|
#define CAPI_MAX_FACILITYDATAARRAY_SIZE 300
|
||||||
|
|
||||||
|
#ifdef CC_AST_HAS_FORMAT_T
|
||||||
|
typedef format_t cc_format_t;
|
||||||
|
#else
|
||||||
|
typedef int cc_format_t;
|
||||||
|
#endif
|
||||||
|
|
||||||
/* some helper functions */
|
/* some helper functions */
|
||||||
static inline void write_capi_word(void *m, unsigned short val)
|
static inline void write_capi_word(void *m, unsigned short val)
|
||||||
{
|
{
|
||||||
|
@ -528,11 +534,7 @@ struct capi_pvt {
|
||||||
#else
|
#else
|
||||||
struct ast_rtp *rtp;
|
struct ast_rtp *rtp;
|
||||||
#endif
|
#endif
|
||||||
#ifdef CC_AST_HAS_FORMAT_T
|
cc_format_t capability;
|
||||||
format_t capability;
|
|
||||||
#else
|
|
||||||
int capability;
|
|
||||||
#endif
|
|
||||||
int rtpcodec;
|
int rtpcodec;
|
||||||
int codec;
|
int codec;
|
||||||
unsigned int timestamp;
|
unsigned int timestamp;
|
||||||
|
@ -729,7 +731,7 @@ pbx_capi_command_proc_t pbx_capi_lockup_command_by_name(const char* name);
|
||||||
/*!
|
/*!
|
||||||
* \brief returns list of supported by this controller RTP codecs
|
* \brief returns list of supported by this controller RTP codecs
|
||||||
*/
|
*/
|
||||||
int pbx_capi_get_controller_codecs (int controller);
|
cc_format_t pbx_capi_get_controller_codecs (int controller);
|
||||||
_cstruct diva_get_b1_conf (struct capi_pvt *i);
|
_cstruct diva_get_b1_conf (struct capi_pvt *i);
|
||||||
|
|
||||||
#ifdef DIVA_STREAMING
|
#ifdef DIVA_STREAMING
|
||||||
|
@ -749,5 +751,4 @@ int pbx_capi_streaming_supported (struct capi_pvt *i);
|
||||||
#define _DI_DSP_CTRL 0x0003
|
#define _DI_DSP_CTRL 0x0003
|
||||||
#define _DI_OPTIONS_REQUEST 0x0009
|
#define _DI_OPTIONS_REQUEST 0x0009
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -932,12 +932,15 @@ struct capi_pvt* pbx_check_resource_plci(struct ast_channel *c)
|
||||||
int pbx_capi_chat_associate_resource_plci(struct ast_channel *c, char *param)
|
int pbx_capi_chat_associate_resource_plci(struct ast_channel *c, char *param)
|
||||||
{
|
{
|
||||||
struct capi_pvt *i = NULL;
|
struct capi_pvt *i = NULL;
|
||||||
char *controller;
|
char *controller, *codeclist;
|
||||||
char *p;
|
char *p;
|
||||||
ast_group_t tmpcntr;
|
ast_group_t tmpcntr;
|
||||||
unsigned long long contr = 0;
|
unsigned long long contr = 0;
|
||||||
|
cc_format_t codecs = 0; /* codecs are disabled by default */
|
||||||
|
int all = 0;
|
||||||
|
|
||||||
controller = param;
|
controller = strsep(¶m, "|");
|
||||||
|
codeclist = param;
|
||||||
|
|
||||||
if (controller) {
|
if (controller) {
|
||||||
for (p = controller; p && *p; p++) {
|
for (p = controller; p && *p; p++) {
|
||||||
|
@ -946,9 +949,20 @@ int pbx_capi_chat_associate_resource_plci(struct ast_channel *c, char *param)
|
||||||
tmpcntr = ast_get_group(controller);
|
tmpcntr = ast_get_group(controller);
|
||||||
contr = (unsigned long long)(tmpcntr >> 1);
|
contr = (unsigned long long)(tmpcntr >> 1);
|
||||||
}
|
}
|
||||||
|
if (param != 0) { /* Separated by '+' list of codecs */
|
||||||
|
char* currentcodec;
|
||||||
|
|
||||||
|
while (all == 0 && (currentcodec = strsep (¶m, "+")) != 0) {
|
||||||
|
if (strcmp (currentcodec, "all") == 0) {
|
||||||
|
all = 1; /* All supported by selected controller codecs */
|
||||||
|
} else {
|
||||||
|
codecs |= ast_getformatbyname (currentcodec);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (c->tech != &capi_tech) {
|
if (c->tech != &capi_tech) {
|
||||||
i = capi_mkresourceif(c, contr, 0);
|
i = capi_mkresourceif(c, contr, 0, codecs, all);
|
||||||
if (i != NULL) {
|
if (i != NULL) {
|
||||||
char buffer[24];
|
char buffer[24];
|
||||||
snprintf(buffer, sizeof(buffer)-1, "%p", i);
|
snprintf(buffer, sizeof(buffer)-1, "%p", i);
|
||||||
|
@ -964,7 +978,7 @@ int pbx_capi_chat_associate_resource_plci(struct ast_channel *c, char *param)
|
||||||
*/
|
*/
|
||||||
pbx_builtin_setvar_helper(c, "RESOURCEPLCI", buffer);
|
pbx_builtin_setvar_helper(c, "RESOURCEPLCI", buffer);
|
||||||
|
|
||||||
capi_mkresourceif(c, contr, i);
|
capi_mkresourceif(c, contr, i, codecs, all);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -245,7 +245,7 @@ struct capi_pvt *capi_mknullif(struct ast_channel *c, unsigned long long control
|
||||||
return tmp;
|
return tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct capi_pvt *capi_mkresourceif(struct ast_channel *c, unsigned long long controllermask, struct capi_pvt *data_plci_ifc) {
|
struct capi_pvt *capi_mkresourceif(struct ast_channel *c, unsigned long long controllermask, struct capi_pvt *data_plci_ifc, cc_format_t codecs, int all) {
|
||||||
struct capi_pvt *data_ifc /*, *line_ifc */;
|
struct capi_pvt *data_ifc /*, *line_ifc */;
|
||||||
unsigned int controller = 1;
|
unsigned int controller = 1;
|
||||||
int fmt = 0;
|
int fmt = 0;
|
||||||
|
@ -270,7 +270,8 @@ struct capi_pvt *capi_mkresourceif(struct ast_channel *c, unsigned long long con
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
controller = data_plci_ifc->controller;
|
controller = data_plci_ifc->controller;
|
||||||
fmt = pbx_capi_get_controller_codecs (controller) & c->nativeformats;
|
codecs = (all != 0) ? pbx_capi_get_controller_codecs (controller) : codecs;
|
||||||
|
fmt = pbx_capi_get_controller_codecs (controller) & codecs & c->nativeformats;
|
||||||
if (fmt != 0)
|
if (fmt != 0)
|
||||||
fmt = ast_best_codec(fmt);
|
fmt = ast_best_codec(fmt);
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,7 +54,7 @@ extern int cc_add_peer_link_id(struct ast_channel *c);
|
||||||
extern struct ast_channel *cc_get_peer_link_id(const char *p);
|
extern struct ast_channel *cc_get_peer_link_id(const char *p);
|
||||||
extern void capi_remove_nullif(struct capi_pvt *i);
|
extern void capi_remove_nullif(struct capi_pvt *i);
|
||||||
extern struct capi_pvt *capi_mknullif(struct ast_channel *c, unsigned long long controllermask);
|
extern struct capi_pvt *capi_mknullif(struct ast_channel *c, unsigned long long controllermask);
|
||||||
struct capi_pvt *capi_mkresourceif(struct ast_channel *c, unsigned long long controllermask, struct capi_pvt *data_plci_ifc);
|
struct capi_pvt *capi_mkresourceif(struct ast_channel *c, unsigned long long controllermask, struct capi_pvt *data_plci_ifc, cc_format_t codecs, int all);
|
||||||
extern int capi_create_reader_writer_pipe(struct capi_pvt *i);
|
extern int capi_create_reader_writer_pipe(struct capi_pvt *i);
|
||||||
extern struct ast_frame *capi_read_pipeframe(struct capi_pvt *i);
|
extern struct ast_frame *capi_read_pipeframe(struct capi_pvt *i);
|
||||||
extern int capi_write_frame(struct capi_pvt *i, struct ast_frame *f);
|
extern int capi_write_frame(struct capi_pvt *i, struct ast_frame *f);
|
||||||
|
|
Loading…
Reference in New Issue