From 7be7d7c6a958641dcf86bea0baf0903c1bb4a681 Mon Sep 17 00:00:00 2001 From: MelwareDE Date: Mon, 28 Jun 2010 21:37:56 +0000 Subject: [PATCH] Check if Diva streaming available. Implemented Diva streaming for outgoing calls --- chan_capi.c | 12 +++++++--- chan_capi_utils.c | 57 +++++++++++++++++++++++++++++++++++++++++++++-- chan_capi_utils.h | 3 ++- 3 files changed, 66 insertions(+), 6 deletions(-) diff --git a/chan_capi.c b/chan_capi.c index 5fd86df..33029cd 100644 --- a/chan_capi.c +++ b/chan_capi.c @@ -1538,6 +1538,13 @@ static int pbx_capi_call(struct ast_channel *c, char *idest, int timeout) cc_qsig_add_call_setup_data(facilityarray, i, c); } +#ifdef DIVA_STREAMING + i->diva_stream_entry = 0; + if (capi_controllers[i->controller]->divaStreaming != 0) { + capi_DivaStreamingOn(i, 1, i->MessageNumber); + } +#endif + error = capi_sendf(NULL, 0, CAPI_CONNECT_REQ, i->controller, i->MessageNumber, "wssss(wwwsss())()()()((w)()()ss)", cip, /* CIP value */ @@ -4925,7 +4932,7 @@ static void capidev_handle_connect_indication(_cmsg *CMSG, unsigned int PLCI, un #ifdef DIVA_STREAMING i->diva_stream_entry = 0; if (capi_controllers[i->controller]->divaStreaming != 0) { - capi_DivaStreamingOn(i); + capi_DivaStreamingOn(i, 0, 0); } #endif @@ -8030,9 +8037,8 @@ static int cc_init_capi(void) cc_verbose(3, 0, VERBOSE_PREFIX_4 "T.38 is supported (not implemented yet)\n"); } #ifdef DIVA_STREAMING - /** \todo check CAPI profile */ + cp->divaStreaming = capi_DivaStreamingSupported(cp->controller); cc_verbose(3, 0, VERBOSE_PREFIX_4 "CAPI %d Diva streaming is supported\n", cp->controller); - cp->divaStreaming = 1; #endif capi_controllers[controller] = cp; } diff --git a/chan_capi_utils.c b/chan_capi_utils.c index d2d9f54..1fd2f5e 100644 --- a/chan_capi_utils.c +++ b/chan_capi_utils.c @@ -1162,6 +1162,45 @@ done: } #ifdef DIVA_STREAMING +int capi_DivaStreamingSupported (unsigned controller) +{ + MESSAGE_EXCHANGE_ERROR error; + int waitcount = 50; + unsigned char manbuf[CAPI_MANUFACTURER_LEN]; + _cmsg CMSG; + int ret = 0; + + if (capi20_get_manufacturer(controller, manbuf) == NULL) { + goto done; + } + if ((strstr((char *)manbuf, "Eicon") == 0) && + (strstr((char *)manbuf, "Dialogic") == 0)) { + goto done; + } + + error = capi_sendf (NULL, 0, CAPI_MANUFACTURER_REQ, controller, get_capi_MessageNumber(), + "dw(bs)", _DI_MANU_ID, _DI_STREAM_CTRL, 2, ""); + + if (error) + goto done; + + while (waitcount) { + error = capidev_check_wait_get_cmsg(&CMSG); + + if (IS_MANUFACTURER_CONF(&CMSG) && (CMSG.ManuID == _DI_MANU_ID) && + ((CMSG.Class & 0xffff) == _DI_STREAM_CTRL)) { + error = (MESSAGE_EXCHANGE_ERROR)(CMSG.Class >> 16); + ret = (error == 0); + break; + } + usleep(30000); + waitcount--; + } + +done: + return ret; +} + static int divaStreamingMessageRx (void* user_context, dword message, dword length, const struct _diva_streaming_vector* v, dword nr_v) { diva_stream_scheduling_entry_t* pE = (diva_stream_scheduling_entry_t*)user_context; @@ -1242,11 +1281,12 @@ static int divaStreamingMessageRx (void* user_context, dword message, dword leng * Create Diva stream * */ -void capi_DivaStreamingOn(struct capi_pvt *i) +void capi_DivaStreamingOn(struct capi_pvt *i, byte streamCommand, _cword messageNumber) { diva_stream_scheduling_entry_t* pE; int ret; char trace_ident[8]; + unsigned int effectivePLCI; pE = malloc (sizeof(*pE)); if (pE == 0) @@ -1263,9 +1303,22 @@ void capi_DivaStreamingOn(struct capi_pvt *i) byte* description = (byte*)pE->diva_stream->description (pE->diva_stream); MESSAGE_EXCHANGE_ERROR error; + description[1] = streamCommand; + description[3] |= 0x01; - error = capi_sendf (NULL, 0, CAPI_MANUFACTURER_REQ, i->PLCI, get_capi_MessageNumber(), + if (streamCommand == 0) { + messageNumber = get_capi_MessageNumber(); + effectivePLCI = i->PLCI; + } else { + /* + PLCI still not assigned. Send to controller and tag with message number + where command receives effective + */ + effectivePLCI = i->controller; + } + + error = capi_sendf (NULL, 0, CAPI_MANUFACTURER_REQ, effectivePLCI, messageNumber, "dws", _DI_MANU_ID, _DI_STREAM_CTRL, description); if (error == 0) { pE->diva_stream_state = DivaStreamCreated; diff --git a/chan_capi_utils.h b/chan_capi_utils.h index d549645..029a34b 100644 --- a/chan_capi_utils.h +++ b/chan_capi_utils.h @@ -60,7 +60,8 @@ 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_verify_resource_plci(const struct capi_pvt *i); #ifdef DIVA_STREAMING -extern void capi_DivaStreamingOn(struct capi_pvt *i); +extern int capi_DivaStreamingSupported (unsigned controller); +extern void capi_DivaStreamingOn(struct capi_pvt *i, unsigned char streamCommand, _cword messageNumber); extern void capi_DivaStreamingRemoveInfo(struct capi_pvt *i); extern void capi_DivaStreamingRemove(struct capi_pvt *i); extern void divaStreamingWakeup (void);