diff options
Diffstat (limited to 'include/asterisk/channel.h')
-rw-r--r-- | include/asterisk/channel.h | 138 |
1 files changed, 114 insertions, 24 deletions
diff --git a/include/asterisk/channel.h b/include/asterisk/channel.h index a32486a39..119dc42e8 100644 --- a/include/asterisk/channel.h +++ b/include/asterisk/channel.h @@ -148,6 +148,8 @@ extern "C" { #include "asterisk/linkedlists.h" #include "asterisk/stringfields.h" #include "asterisk/datastore.h" +#include "asterisk/channelstate.h" +#include "asterisk/ccss.h" #define DATASTORE_INHERIT_FOREVER INT_MAX @@ -507,6 +509,29 @@ struct ast_channel_tech { /*! \brief Get the unique identifier for the PVT, i.e. SIP call-ID for SIP */ const char * (* get_pvt_uniqueid)(struct ast_channel *chan); + + /*! \brief Call a function with cc parameters as a function parameter + * + * \details + * This is a highly specialized callback that is not likely to be needed in many + * channel drivers. When dealing with a busy channel, for instance, most channel + * drivers will successfully return a channel to the requester. Once called, the channel + * can then queue a busy frame when it receives an appropriate message from the far end. + * In such a case, the channel driver has the opportunity to also queue a CC frame. + * The parameters for the CC channel can be retrieved from the channel structure. + * + * For other channel drivers, notably those that deal with "dumb" phones, the channel + * driver will not return a channel when one is requested. In such a scenario, there is never + * an opportunity for the channel driver to queue a CC frame since the channel is never + * called. Furthermore, it is not possible to retrieve the CC configuration parameters + * for the desired channel because no channel is ever allocated or returned to the + * requester. In such a case, call completion may still be a viable option. What we do is + * pass the same string that the requester used originally to request the channel to the + * channel driver. The channel driver can then find any potential channels/devices that + * match the input and return call the designated callback with the device's call completion + * parameters as a parameter. + */ + int (* cc_callback)(struct ast_channel *inbound, const char *dest, ast_cc_callback_fn callback); }; struct ast_epoll_data; @@ -535,27 +560,6 @@ enum ast_channel_adsicpe { }; /*! - * \brief ast_channel states - * - * \note Bits 0-15 of state are reserved for the state (up/down) of the line - * Bits 16-32 of state are reserved for flags - */ -enum ast_channel_state { - AST_STATE_DOWN, /*!< Channel is down and available */ - AST_STATE_RESERVED, /*!< Channel is down, but reserved */ - AST_STATE_OFFHOOK, /*!< Channel is off hook */ - AST_STATE_DIALING, /*!< Digits (or equivalent) have been dialed */ - AST_STATE_RING, /*!< Line is ringing */ - AST_STATE_RINGING, /*!< Remote end is ringing */ - AST_STATE_UP, /*!< Line is up */ - AST_STATE_BUSY, /*!< Line is busy */ - AST_STATE_DIALING_OFFHOOK, /*!< Digits (or equivalent) have been dialed while offhook */ - AST_STATE_PRERING, /*!< Channel has detected an incoming call and is waiting for ring */ - - AST_STATE_MUTE = (1 << 16), /*!< Do not transmit voice data */ -}; - -/*! * \brief Possible T38 states on channels */ enum ast_t38_state { @@ -950,9 +954,6 @@ int ast_channel_datastore_remove(struct ast_channel *chan, struct ast_datastore */ struct ast_datastore *ast_channel_datastore_find(struct ast_channel *chan, const struct ast_datastore_info *info, const char *uid); -/*! \brief Change the state of a channel */ -int ast_setstate(struct ast_channel *chan, enum ast_channel_state); - /*! * \brief Create a channel structure * \since 1.8 @@ -2756,6 +2757,95 @@ void ast_channel_queue_redirecting_update(struct ast_channel *chan, const struct * '0' */ int ast_channel_connected_line_macro(struct ast_channel *autoservice_chan, struct ast_channel *macro_chan, const void *connected_info, int caller, int frame); + +#include "asterisk/ccss.h" + +/*! + * \since 1.8 + * \brief Set up datastore with CCSS parameters for a channel + * + * \note + * If base_params is NULL, the channel will get the default + * values for all CCSS parameters. + * + * \details + * This function makes use of datastore operations on the channel, so + * it is important to lock the channel before calling this function. + * + * \param chan The channel to create the datastore on + * \param base_params CCSS parameters we wish to copy into the channel + * \retval 0 Success + * \retval -1 Failure + */ +int ast_channel_cc_params_init(struct ast_channel *chan, + const struct ast_cc_config_params *base_params); + +/*! + * \since 1.8 + * \brief Get the CCSS parameters from a channel + * + * \details + * This function makes use of datastore operations on the channel, so + * it is important to lock the channel before calling this function. + * + * \param chan Channel to retrieve parameters from + * \retval NULL Failure + * \retval non-NULL The parameters desired + */ +struct ast_cc_config_params *ast_channel_get_cc_config_params(struct ast_channel *chan); + + +/*! + * \since 1.8 + * \brief Get a device name given its channel structure + * + * \details + * A common practice in Asterisk is to determine the device being talked + * to by dissecting the channel name. For certain channel types, this is not + * accurate. For instance, an ISDN channel is named based on what B channel is + * used, not the device being communicated with. + * + * This function interfaces with a channel tech's queryoption callback to + * retrieve the name of the device being communicated with. If the channel does not + * implement this specific option, then the traditional method of using the channel + * name is used instead. + * + * \param chan The channel to retrieve the information from + * \param device_name[out] The buffer to place the device's name into + * \param name_buffer_length The allocated space for the device_name + * \return 0 always + */ +int ast_channel_get_device_name(struct ast_channel *chan, char *device_name, size_t name_buffer_length); + +/*! + * \since 1.8 + * \brief Find the appropriate CC agent type to use given a channel + * + * \details + * During call completion, we will need to create a call completion agent structure. To + * figure out the type of agent to construct, we need to ask the channel driver for the + * appropriate type. + * + * Prior to adding this function, the call completion core attempted to figure this + * out for itself by stripping the technology off the channel's name. However, in the + * case of chan_dahdi, there are multiple agent types registered, and so simply searching + * for an agent type called "DAHDI" is not possible. In a case where multiple agent types + * are defined, the channel driver must have a queryoption callback defined in its + * channel_tech, and the queryoption callback must handle AST_OPTION_CC_AGENT_TYPE + * + * If a channel driver does not have a queryoption callback or if the queryoption callback + * does not handle AST_OPTION_CC_AGENT_TYPE, then the old behavior of using the technology + * portion of the channel name is used instead. This is perfectly suitable for channel drivers + * whose channel technologies are a one-to-one match with the agent types defined within. + * + * Note that this function is only called when the agent policy on a given channel is set + * to "native." Generic agents' type can be determined automatically by the core. + * + * \param chan The channel for which we wish to retrieve the agent type + * \param[out] agent_type The type of agent the channel driver wants us to use + * \param size The size of the buffer to write to + */ +int ast_channel_get_cc_agent_type(struct ast_channel *chan, char *agent_type, size_t size); #if defined(__cplusplus) || defined(c_plusplus) } #endif |