Sangoma SDK Interfaces
Sangoma HW Operation Interface
Detect Sangoma Hardware
Load kernel module
Iterate over all hw ports
call back user for each port
Configure Sangoma HW Port
For each port save configuration to the driver
Start Sangoma HW Port
Start driver/hw port.
Start Sangoma HW Port
Stop driver/hw port.
Sangoma FreeTDM Operation Interface
Once sangoma hw ports are configured and started, the FreeTDM Framework can be started for each span.
Create FreeTDM Span
Start FreeTDM Span
Refer to the Sangoma FreeTDM Configuration Interface
Sangoma FreeTDM Signaling and Media Interface
Once FreeTDM Spans are started user application will wait for events.
On call start event, do something useful
Eg: Launch a thread and start recording the media to file from a bchannel
Refer to Sangoma FreeTDM Signaling and Media Interface
Sangoma HW Operation Interface Functions
The Sangoma SDK HW operation interface is located in:
applications/common/libsangoma_wp_config.h |
HW Operation Interface Data Structures
/*! Sangoma port object structure contains all hw port information The object is provided to user opaque in order to simplify development. /*! The callback structure allows user application to pass on user_obj - is a user pointer that will be passed back to the user application hw_probe_callback() - is functin that will be called for each port detected |
Hardware Detection Function
/*! A very first access to the sangoma operations library. /*! Detect sangoma hardware on a machine In callback function user application should: |
Sangoma Port Object Config and Misc Methods
/*! This is a method that operates on sangoma_port_obj. */ /*! This is a method that operates on sangoma_port_obj. /*! This is a method that operates on sangoma_port_obj. char* sangoma_config_port_hwinfo_get_model_str(sangoma_port_obj_t sangoma_port_obj); |
Sangoma HW Port Operation Methods
/*! This is a method that operates on sangoma_port_obj. /*! This is a method that operates on sangoma_port_obj. /*! This is a method that operates on sangoma_port_obj.
|
Sangoma FreeTDM Configuration Functions
The Sangoma FreeTDM Operation Interface is located in:
applications/common/libsangoma_freetdm.h |
/*! Main FreeTDM initializatino function. */ /*! \fn int sangoma_freetdm_destroy(void); \brief Stop the FreeTDM Framework. All Spans will be deallocated. \param void \return File Descriptor: Non Zero is error, 0 is success Stop the FreeTDM Framework. All spans will be deallocated. Usually called before the application exits. Must be the first function to be called before any other FreeTDM call. */ int sangoma_freetdm_destroy(void); /*! \fn int sangoma_freetdm_create_span(sangoma_port_obj_t port, ftdm_span_t **span, int operating_mode); \brief Create FreeTDM Span. User hw port object for span cfg info. \param port Sangoma hw prot obj. \param span Created span will be stored in this pointer. Span is an opaque object. \param operating_mode will contain the mode on which span needs to be operated like ANALOG/ISUP_SIG/ISUP_VOICE/ISDN/MTP2_API_LSL/MTP2_API_HSL \return File Descriptor: Non Zero is error, 0 is success Create FreeTDM Span in FreeTDM framework. The Sangoma port object will be used to extract hw configuration necessary to create the span. The FreeTDM span opaque object will be stored in the span argument. At this point span is only half configured. Next step is to call span configuration function. */ int sangoma_freetdm_create_span(sangoma_port_obj_t port, ftdm_span_t **span, int operating_mode); /*! \fn int sangoma_freetdm_span_config_and_start(sangoma_port_obj_t port, ftdm_span_t *span, int operating_mode); \brief Configure FreeTDM span based on sangoma port object configuration options. \param port Sangoma hw prot obj. \param span FreeTDM span object \param operating_mode will contain the mode on which span needs to be configured and started like ANALOG/ISUP_SIG/ISUP_VOICE/ISDN/MTP2_API_LSL/MTP2_API_HSL \return File Descriptor: Non Zero is error, 0 is success This function will configure the FreeTDM span using information from sangoma port obj. Once the span is fully configured, the span will be started. Once the FreeTDM span starts it will Initialize and start signaling on port dchan Wait for dchan events. One signaling event (such as call start) FreeTDM pass the event structure to user application via callback function. At this point application is able to call FreeTDM Signaling and Media Functions. */ int sangoma_freetdm_span_config_and_start(sangoma_port_obj_t port, ftdm_span_t *span, int operating_mode); |
Sangoma FreeTDM Signaling and Media I/O Interface Functions
The Sangoma FreeTDM Signaling and Media Interface is located in:
libs/freetdm/src/include/freetdm.h |
FreeTDM Place Call, Indicate Call, Answer Call
/*! \brief Place an outgoing call with the given caller data in a channel according to the hunting scheme provided and records
*
*
*/ /*! \brief Place an outgoing call with the given caller data in a channel according to the hunting scheme provided */ /*! \brief Indicate a new condition in an incoming call
*
*/ /*! \brief Answer call. This can also be accomplished by ftdm_channel_call_indicate with FTDM_CHANNEL_INDICATE_ANSWER, in both
*/ |
FreeTDM Hangup Call
/*! \brief Hangup the call without cause */ #define ftdm_channel_call_hangup(ftdmchan) /*! \brief Hangup the call with cause */ #define ftdm_channel_call_hangup_with_cause(ftdmchan, cause) |
Hangup Cause Codes
Note that some of the hangup codes only apply to FreeTDM framework internals,
not the use application
/*! \brief Hangup cause codes */ |
FreeTDM Call Support Functions
/*! \brief Check if the call is answered already */ FT_DECLARE(ftdm_bool_t) ftdm_channel_call_check_answered(const ftdm_channel_t *ftdmchan); /*! \brief Check if the call is busy */ FT_DECLARE(ftdm_bool_t) ftdm_channel_call_check_busy(const ftdm_channel_t *ftdmchan); /*! \brief Check if the call is hangup */ FT_DECLARE(ftdm_bool_t) ftdm_channel_call_check_hangup(const ftdm_channel_t *ftdmchan); /*! \brief Check if the call is done (final state for a call, just after hangup) */ FT_DECLARE(ftdm_bool_t) ftdm_channel_call_check_done(const ftdm_channel_t *ftdmchan); |
FreeTDM Channel Support Functions
/*!
*
*
*/ /*!
*
* /*!
*
* /*!
*
*
*/ /*!
*
*/ /*!
*
*
*/ /*!
*
*
*/ /*!
*
*
*/ |
FreeTDM Media Wait, Read, Write
/*! * \brief Wait for I/O events in a channel * * \param ftdmchan The channel to wait I/O for * \param flags The wait I/O flags * \param timeout The timeout in milliseconds * * \retval FTDM_SUCCESS success (a suitable channel was found available) * \retval FTDM_FAIL failure (no suitable channel was found available) */ FT_DECLARE(ftdm_status_t) ftdm_channel_wait(ftdm_channel_t *ftdmchan, ftdm_wait_flag_t *flags, int32_t timeout); /*! * \brief Read data from a channel * * \param ftdmchan The channel to read data from * \param data The pointer to the buffer to store the read data * \param datalen The size in bytes of the provided buffer * * \retval FTDM_SUCCESS success (a suitable channel was found available) * \retval FTDM_FAIL failure (no suitable channel was found available) */ FT_DECLARE(ftdm_status_t) ftdm_channel_read(ftdm_channel_t *ftdmchan, void *data, ftdm_size_t *datalen); /*! * \brief Write data to a channel * * \note The difference between data and datasize is subtle but important. * * datalen is a pointer to the size of the actual data that you want to write. This pointer * will be updated with the number of bytes actually written. * * datasize on the other hand is the size of the entire buffer provided in data, whether * all of that buffer is in use or not is a different matter. The difference becomes * important only if you are using FreeTDM doing transcoding, for example, providing * a ulaw frame of 160 bytes but where the I/O device accepts input in signed linear, * the data to write will be 320 bytes, therefore datasize is expected to be at least * 320 where datalen would be just 160. * * \param ftdmchan The channel to write data to * \param data The pointer to the buffer to write * \param datasize The maximum number of bytes in data that can be used (in case transcoding is necessary) * \param datalen The size of the actual data * * \retval FTDM_SUCCESS success (a suitable channel was found available) * \retval FTDM_FAIL failure (no suitable channel was found available) */ FT_DECLARE(ftdm_status_t) ftdm_channel_write(ftdm_channel_t *ftdmchan, void *data, ftdm_size_t datasize, ftdm_size_t *datalen); |
FreeTDM Media Support Functions
/*! * \brief Get the I/O read/write interval * * \param ftdmchan The channel to get the interval from * * \retval The interval in milliseconds */ FT_DECLARE(uint32_t) ftdm_channel_get_io_interval(const ftdm_channel_t *ftdmchan); /*! * \brief Get the I/O read/write packet length per interval * * \param ftdmchan The channel to get the packet length from * * \retval The packet length interval in bytes */ FT_DECLARE(uint32_t) ftdm_channel_get_io_packet_len(const ftdm_channel_t *ftdmchan); /*! * \brief Get the I/O read/write codec * * \param ftdmchan The channel to get the codec from * * \retval The codec type */ FT_DECLARE(ftdm_codec_t) ftdm_channel_get_codec(const ftdm_channel_t *ftdmchan); |
FreeTDM Alarm and Statistics
/*! * \brief Get the current alarm bitmask for the channel * * \param ftdmchan The channel to get the alarm bitmask from * \param alarmbits The alarm bitmask pointer to store the current alarms (you are responsible for allocation/deallocation) * * \retval FTDM_SUCCESS success * \retval FTDM_FAIL failure */ FT_DECLARE(ftdm_status_t) ftdm_channel_get_alarms(ftdm_channel_t *ftdmchan, ftdm_alarm_flag_t *alarmbits); |