
Description | Cautions | Example | Errors | See Also
Name: |
int dcb_getatibits(devh,atibits) | |
Inputs: |
int devh unsigned long *atibits |
|
Returns: |
0 on success -1 on failure | |
Includes: |
srllib.h dtilib.h msilib.h | |
Category: |
Auxiliary | |
Mode: |
synchronous | |
The dcb_getatibits( ) function returns the active talker indicator bits set at the time this function is called. This function is provided to give more control to the application and must be used with the resource assignment table update event to implement active talker retrieval.
Parameter |
Description |
devh: |
The valid DSP device handle returned by a call to dcb_open( ). |
atibits: |
Pointer to location where active talker indicator bits will be stored. |
atibits is 4 bytes long. Each bit corresponds to one DSP resource and is updated every 100 ms. Bits are turned on or off by the DSP based on the speaker energy (volume) level.
Bit 0 of atibits corresponds to resource 0 on the specified DSP. atibits should be used with the resource assignment table. The table is copied from the event data returned once the current DCBEV_CTU event is detected by the application. DCBEV_CTU is enabled using the dcb_evtstatus( ) function. Bit n should be paired with the nth DCB_CT element of the resource table.
This function fails when the device handle is invalid.
#include <windows.h>
#include <stdio.h>
#include "srllib.h"
#include "dtilib.h"
#include "msilib.h"
#include "dcblib.h"
#include "errno.h"
#define MAX_PTY 32
#define TABLE_SIZE 192
DCB_CT res_table[MAX_PTY]; /* DCB_CT structure array */
void handler()
{
int size = sr_getevtlen();
char *datap = (char *)sr_getevtdatap();
int event_type = (int)sr_getevttype();
printf("Event occurred on %s : Data size = %d : Data is at 0x%x\n",
ATDV_NAMEP(sr_getevtdev()), size, datap);
if (event_type == DCBEV_CTU) {
memcpy(res_table, datap, TABLE_SIZE);
}
else {
for (i=0; i<size; i++){
printf("%d\n", *(datap++));
}
}
}
main()
{
int bddevh, dspdevh; /* DCB/SC board and DSP device descriptors */
unsigned long atibits; /* Active talker indicator bits */
int mode = SR_POLLMODE; /* SRL function-call mode */
unsigned int status; /* DCB/SC Feature status */
unsigned int i, count = 1000; /* Loop counters */
/* Open DCB/SC board device */
if ((bddevh = dcb_open("dcbB1",0)) == -1) {
printf("Cannot open dcbB1. errno = %d", errno);
exit(1);
}
/* Set SRL function call mode */
if (sr_setparm(SRL_DEVICE, SR_MODEID, (void *)&mode) == -1){
printf("Error setting sr_setparm()\n");
exit(1);
}
/* Enable SRL event handler */
if (sr_enbhdlr(EV_ANYDEV, EV_ANYEVT, (void *)handler) == -1) {
printf("Error setting sr_enbhdlr()\n");
exit(1);
}
/* Set Active Talker On */
status = ACTID_ON;
if (dcb_setbrdparm(bddevh, MSG_ACTID, (void *)&status) == -1) {
printf("Error setting board parameter - %s\n", ATDV_ERRMSGP(bddevh));
exit(1);
}
/* Done with board-level calls : close device */
if (dcb_close(bddevh) == -1) {
printf("Cannot close dcbB1. errno = %d\n", errno);
exit(1);
}
/* Set Resource Table Update events ON */
status = ON;
if (dcb_evtstatus(MSG_RESTBL, SET_EVENT, &status) == -1) {
printf("Error enabling system-wide event\n");
exit(1);
}
/* Open board 1, DSP 1 device */
if ((dspdevh = dcb_open("dcbB1D1",0)) == -1) {
printf("Cannot open dcbB1D1. errno = %d", errno);
exit(1);
}
/* Establish a conference and continue processing */
/* Wait in a 1000-count loop to get the active talkers */
while (count--) {
if (dcb_getatibits(dspdevh, &atibits) == -1){
printf("Error Message : %s", ATDV_ERRMSGP(dspdevh));
exit(1);
}
printf("ATIBITS = %d\n", atibits);
for (i=0; i<32; i++){
if (atibits & (1<<i)){
printf("confid = %d, TimeSlot = %d, Selector = %d\n",
res_table[i].confid, res_table[i].chan_num,
res_table[i].chan_sel);
}
} /* End of for() loop */
} /* End of while() loop */
/* Set Resource Table Update events OFF */
status = OFF;
if (dcb_evtstatus(MSG_RESTBL, SET_EVENT, &status) == -1) {
printf("Error enabling system-wide event\n");
exit(1);
}
/* Disable event handler */
if (sr_dishdlr(EV_ANYDEV, DCBEV_CTU, (void *)handler) == -1) {
printf("Error in sr_dishdlr()\n");
exit(1);
}
/* Done processing - close DSP device */
if (dcb_close(dspdevh) == -1) {
printf("Cannot close dcbB1D1. errno = %d\n", errno);
exit(1);
}
}
If the function does not complete successfully, it will return -1 to indicate an error. Use the Standard Attribute functions ATDV_LASTERR( ) to obtain the applicable error value, or ATDV_ERRMSGP( ) to obtain a more descriptive error message.
Refer to the error type tables found in Chapter 2 of this guide. Error defines can be found in dtilib.h, msilib.h or dcblib.h.
Click here to contact Dialogic Customer Engineering
Copyright 2000, Dialogic Corporation