Allow to select codecs for capicommand rresource. Clean up.

This commit is contained in:
MelwareDE 2010-09-20 11:05:58 +00:00
parent f9f8279d8c
commit 3e71cbcc24
5 changed files with 32 additions and 20 deletions

View File

@ -189,11 +189,7 @@ static char capi_subscriber_prefix[AST_MAX_EXTENSION];
static char default_language[MAX_LANGUAGE] = "";
#ifdef CC_AST_HAS_FORMAT_T
format_t capi_capability = AST_FORMAT_ALAW;
#else
int capi_capability = AST_FORMAT_ALAW;
#endif
cc_format_t capi_capability = AST_FORMAT_ALAW;
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;
}
int pbx_capi_get_controller_codecs (int controller) {
cc_format_t pbx_capi_get_controller_codecs (int controller) {
return (capi_controllers[controller]->rtpcodec);
}

View File

@ -71,6 +71,12 @@ struct _diva_stream_scheduling_entry;
#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 */
static inline void write_capi_word(void *m, unsigned short val)
{
@ -528,11 +534,7 @@ struct capi_pvt {
#else
struct ast_rtp *rtp;
#endif
#ifdef CC_AST_HAS_FORMAT_T
format_t capability;
#else
int capability;
#endif
cc_format_t capability;
int rtpcodec;
int codec;
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
*/
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);
#ifdef DIVA_STREAMING
@ -749,5 +751,4 @@ int pbx_capi_streaming_supported (struct capi_pvt *i);
#define _DI_DSP_CTRL 0x0003
#define _DI_OPTIONS_REQUEST 0x0009
#endif

View File

@ -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)
{
struct capi_pvt *i = NULL;
char *controller;
char *controller, *codeclist;
char *p;
ast_group_t tmpcntr;
unsigned long long contr = 0;
cc_format_t codecs = 0; /* codecs are disabled by default */
int all = 0;
controller = param;
controller = strsep(&param, "|");
codeclist = param;
if (controller) {
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);
contr = (unsigned long long)(tmpcntr >> 1);
}
if (param != 0) { /* Separated by '+' list of codecs */
char* currentcodec;
while (all == 0 && (currentcodec = strsep (&param, "+")) != 0) {
if (strcmp (currentcodec, "all") == 0) {
all = 1; /* All supported by selected controller codecs */
} else {
codecs |= ast_getformatbyname (currentcodec);
}
}
}
if (c->tech != &capi_tech) {
i = capi_mkresourceif(c, contr, 0);
i = capi_mkresourceif(c, contr, 0, codecs, all);
if (i != NULL) {
char buffer[24];
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);
capi_mkresourceif(c, contr, i);
capi_mkresourceif(c, contr, i, codecs, all);
}
}

View File

@ -245,7 +245,7 @@ struct capi_pvt *capi_mknullif(struct ast_channel *c, unsigned long long control
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 */;
unsigned int controller = 1;
int fmt = 0;
@ -270,7 +270,8 @@ struct capi_pvt *capi_mkresourceif(struct ast_channel *c, unsigned long long con
}
} else {
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)
fmt = ast_best_codec(fmt);
}

View File

@ -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 void capi_remove_nullif(struct capi_pvt *i);
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 struct ast_frame *capi_read_pipeframe(struct capi_pvt *i);
extern int capi_write_frame(struct capi_pvt *i, struct ast_frame *f);