|
libsangoma
1
|
WANPIPE(tm) API C Sample Code. More...

Go to the source code of this file.
Classes | |
| struct | sangoma_chan |
Macros | |
| #define | TEST_NUMBER_OF_OBJECTS 1 |
| Number of wait objects to define in object array. More... | |
Typedefs | |
| typedef struct sangoma_chan | sangoma_chan_t |
Functions | |
| int __cdecl | main (int argc, char *argv[]) |
| Main function that starts the sample code. More... | |
| int | open_sangoma_device (void) |
| Open a single span chan device. More... | |
| void | handle_span_chan (int open_device_counter) |
| Write data buffer into a file. More... | |
| int | handle_tdm_event (uint32_t dev_index) |
| Read Event buffer from the device. More... | |
| int | handle_data (uint32_t dev_index, int flags_out) |
| Read data buffer from the device and transmit it back down. More... | |
| int | read_data (uint32_t dev_index, wp_api_hdr_t *rx_hdr, void *rx_buffer, int rx_buffer_length) |
| int | write_data (uint32_t dev_index, wp_api_hdr_t *tx_hdr, void *tx_buffer, int tx_len) |
| Transmit a data buffer to a device. More... | |
| int | dtmf_event (sng_fd_t fd, unsigned char digit, unsigned char type, unsigned char port) |
| int | rbs_event (sng_fd_t fd, unsigned char rbs_bits) |
| int | rxhook_event (sng_fd_t fd, unsigned char hook_state) |
| int | rxring_event (sng_fd_t fd, unsigned char ring_state) |
| int | ringtrip_event (sng_fd_t fd, unsigned char ring_state) |
| int | write_data_to_file (unsigned char *data, unsigned int data_length) |
| Write data buffer into a file. More... | |
| int | sangoma_print_stats (sng_fd_t sangoma_dev) |
| void | cleanup (void) |
| Protperly shutdown single device. More... | |
| int | handle_fe_rw (void) |
| void | TerminateHandler (int) |
| Signal handler for graceful shutdown. More... | |
| void | print_rxdata (unsigned char *data, int datalen, wp_api_hdr_t *hdr) |
Variables | |
| sangoma_chan_t | sangoma_channels [TEST_NUMBER_OF_OBJECTS] |
| unsigned char | rx_rbs_bits = WAN_RBS_SIG_A |
| FILE * | pRxFile |
| int | application_termination_flag = 0 |
WANPIPE(tm) API C Sample Code.
Authors: David Rokhvarg davidr@sangoma.com Nenad Corbic ncorbic@sangoma.com
Copyright (c) 2007 - 08, Sangoma Technologies All rights reserved.
THIS SOFTWARE IS PROVIDED BY Sangoma Technologies ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL Sangoma Technologies BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
Definition in file sample.c.
| #define TEST_NUMBER_OF_OBJECTS 1 |
Number of wait objects to define in object array.
Objects are used to wait on file descripotrs. Usually there is one wait object per file descriptor.
In this example there is a single file descriptor and a single wait object.
Definition at line 50 of file sample.c.
Referenced by cleanup(), handle_span_chan(), and main().
| int main | ( | int | argc, |
| char * | argv[] | ||
| ) |
Main function that starts the sample code.
Main function start of the applicatoin.
| argc | number of arguments |
| argv | argument list |
| argc | number of arguments |
| argv | argument list |
Get user Input Set program settings based on user input Create SangomaInterface Class based on user span/chan input. Bind callback functions read/event to SangomaInteface class. Execute the SangomaInterface handling function -> start() The start function will read/write/event data. In Main thread prompt the user for commands.
Definition at line 1018 of file sample.c.
References _getch, cleanup(), handle_span_chan(), open_sangoma_device(), TerminateHandler(), TEST_NUMBER_OF_OBJECTS, and TRUE.

| int open_sangoma_device | ( | void | ) |
Open a single span chan device.
This function will open a single span chan.
However it can be rewritten to iterate for all spans and chans and try to open all existing wanpipe devices.
For each opened device, a wait object will be initialized. For each device, configure the chunk size for tx/rx enable events such as DTMF/RBS ...etc
Definition at line 760 of file sample.c.
References __sangoma_open_api_span_chan(), INVALID_HANDLE_VALUE, SANG_STATUS_SUCCESS, SANGOMA_DEVICE_WAIT_OBJ, sangoma_fe_reg_read(), sangoma_flush_bufs(), sangoma_flush_stats(), sangoma_get_full_cfg(), sangoma_get_rx_queue_sz(), sangoma_get_tx_queue_sz(), sangoma_open_api_span_chan(), sangoma_set_rx_queue_sz(), sangoma_set_tx_queue_sz(), sangoma_ss7_get_cfg_status(), sangoma_tdm_enable_dtmf_events(), sangoma_tdm_enable_rbs_events(), sangoma_tdm_enable_rm_dtmf_events(), sangoma_tdm_enable_rxhook_events(), sangoma_tdm_set_buffer_multiplier(), sangoma_tdm_set_codec(), sangoma_tdm_set_usr_period(), and sangoma_wait_obj_create().
Referenced by main().


| void handle_span_chan | ( | int | open_device_counter | ) |
Write data buffer into a file.
| open_device_counter | number of opened devices |
This function will wait on all opened devices. This example will wait for RX and EVENT signals. In case of POLLIN - rx data available In case of POLLPRI - event is available
Definition at line 576 of file sample.c.
References handle_data(), handle_tdm_event(), SANG_STATUS_APIPOLL_TIMEOUT, SANG_STATUS_SUCCESS, sangoma_wait_obj_get_fd(), SDLA_DECODE_SANG_STATUS, and TEST_NUMBER_OF_OBJECTS.
Referenced by main().


| int handle_tdm_event | ( | uint32_t | dev_index | ) |
Read Event buffer from the device.
| dev_index | device index number associated with device file descriptor |
An EVENT has occoured. Execute a system call to read the EVENT on a device.
Definition at line 513 of file sample.c.
References wanpipe_api_cmd::event, sangoma_read_event(), sangoma_wait_obj_get_fd(), and wanpipe_api::wp_cmd.
Referenced by handle_span_chan().


| int handle_data | ( | uint32_t | dev_index, |
| int | flags_out | ||
| ) |
Read data buffer from the device and transmit it back down.
| dev_index | device index number associated with device file descriptor |
Read data buffer from a device.
Definition at line 391 of file sample.c.
References wp_api_hdr::data_length, MAX_NO_DATA_BYTES_IN_FRAME, and write_data().
Referenced by handle_span_chan().


| int write_data | ( | uint32_t | dev_index, |
| wp_api_hdr_t * | tx_hdr, | ||
| void * | tx_data, | ||
| int | tx_len | ||
| ) |
Transmit a data buffer to a device.
| dev_index | device index number associated with device file descriptor |
| tx_hdr | pointer to a wp_api_hdr_t |
| tx_data | pointer to a data buffer |
| tx_len | tx data buffer len |
Definition at line 325 of file sample.c.
References sangoma_msleep, sangoma_wait_obj_get_context(), sangoma_wait_obj_get_fd(), and sangoma_writemsg().
Referenced by handle_data().


| int write_data_to_file | ( | unsigned char * | data, |
| unsigned int | data_length | ||
| ) |
| void cleanup | ( | void | ) |
Protperly shutdown single device.
| dev_no | device index number |
Definition at line 697 of file sample.c.
References sangoma_close(), sangoma_tdm_disable_dtmf_events(), sangoma_tdm_disable_rbs_events(), sangoma_tdm_disable_rm_dtmf_events(), sangoma_tdm_disable_rxhook_events(), sangoma_wait_obj_delete(), sangoma_wait_obj_get_context(), sangoma_wait_obj_get_fd(), and TEST_NUMBER_OF_OBJECTS.
Referenced by main(), and TerminateHandler().


1.8.5