#include "asterisk.h"
#include "asterisk/_private.h"
#include <sys/time.h>
#include <signal.h>
#include <math.h>
#include "asterisk/paths.h"
#include "asterisk/pbx.h"
#include "asterisk/frame.h"
#include "asterisk/mod_format.h"
#include "asterisk/sched.h"
#include "asterisk/channel.h"
#include "asterisk/musiconhold.h"
#include "asterisk/say.h"
#include "asterisk/file.h"
#include "asterisk/cli.h"
#include "asterisk/translate.h"
#include "asterisk/manager.h"
#include "asterisk/cel.h"
#include "asterisk/chanvars.h"
#include "asterisk/linkedlists.h"
#include "asterisk/indications.h"
#include "asterisk/monitor.h"
#include "asterisk/causes.h"
#include "asterisk/callerid.h"
#include "asterisk/utils.h"
#include "asterisk/lock.h"
#include "asterisk/app.h"
#include "asterisk/transcap.h"
#include "asterisk/devicestate.h"
#include "asterisk/sha1.h"
#include "asterisk/threadstorage.h"
#include "asterisk/slinfactory.h"
#include "asterisk/audiohook.h"
#include "asterisk/framehook.h"
#include "asterisk/timing.h"
#include "asterisk/autochan.h"
#include "asterisk/stringfields.h"
#include "asterisk/global_datastores.h"
#include "asterisk/data.h"

Go to the source code of this file.
Data Structures | |
| struct | ast_channel_iterator |
| struct | ast_epoll_data |
| struct | ast_party_id_ies |
| struct | ast_party_name_ies |
| struct | ast_party_number_ies |
| struct | ast_party_subaddress_ies |
| struct | ast_silence_generator |
| struct | backends |
| the list of registered channel types More... | |
| struct | chanlist |
| List of channel drivers. More... | |
| struct | plc_ds |
| struct | tonepair_def |
| struct | tonepair_state |
Defines | |
| #define | AST_DEFAULT_EMULATE_DTMF_DURATION 100 |
| #define | AST_MIN_DTMF_DURATION 80 |
| #define | AST_MIN_DTMF_GAP 45 |
| #define | DATA_EXPORT_CHANNEL(MEMBER) |
| #define | FORMAT "%-10.10s %-40.40s %-12.12s %-12.12s %-12.12s\n" |
| #define | NUM_CHANNEL_BUCKETS 1567 |
| #define | STATE2STR_BUFSIZE 32 |
Enumerations | |
| enum | { AST_CONNECTED_LINE_NUMBER, AST_CONNECTED_LINE_NAME, AST_CONNECTED_LINE_NUMBER_PLAN, AST_CONNECTED_LINE_ID_PRESENTATION, AST_CONNECTED_LINE_SOURCE, AST_CONNECTED_LINE_SUBADDRESS, AST_CONNECTED_LINE_SUBADDRESS_TYPE, AST_CONNECTED_LINE_SUBADDRESS_ODD_EVEN, AST_CONNECTED_LINE_SUBADDRESS_VALID, AST_CONNECTED_LINE_TAG, AST_CONNECTED_LINE_VERSION, AST_CONNECTED_LINE_NAME_VALID, AST_CONNECTED_LINE_NAME_CHAR_SET, AST_CONNECTED_LINE_NAME_PRESENTATION, AST_CONNECTED_LINE_NUMBER_VALID, AST_CONNECTED_LINE_NUMBER_PRESENTATION } |
| Element identifiers for connected line indication frame data. More... | |
| enum | { AST_REDIRECTING_FROM_NUMBER, AST_REDIRECTING_FROM_NAME, AST_REDIRECTING_FROM_NUMBER_PLAN, AST_REDIRECTING_FROM_ID_PRESENTATION, AST_REDIRECTING_TO_NUMBER, AST_REDIRECTING_TO_NAME, AST_REDIRECTING_TO_NUMBER_PLAN, AST_REDIRECTING_TO_ID_PRESENTATION, AST_REDIRECTING_REASON, AST_REDIRECTING_COUNT, AST_REDIRECTING_FROM_SUBADDRESS, AST_REDIRECTING_FROM_SUBADDRESS_TYPE, AST_REDIRECTING_FROM_SUBADDRESS_ODD_EVEN, AST_REDIRECTING_FROM_SUBADDRESS_VALID, AST_REDIRECTING_TO_SUBADDRESS, AST_REDIRECTING_TO_SUBADDRESS_TYPE, AST_REDIRECTING_TO_SUBADDRESS_ODD_EVEN, AST_REDIRECTING_TO_SUBADDRESS_VALID, AST_REDIRECTING_FROM_TAG, AST_REDIRECTING_TO_TAG, AST_REDIRECTING_VERSION, AST_REDIRECTING_FROM_NAME_VALID, AST_REDIRECTING_FROM_NAME_CHAR_SET, AST_REDIRECTING_FROM_NAME_PRESENTATION, AST_REDIRECTING_FROM_NUMBER_VALID, AST_REDIRECTING_FROM_NUMBER_PRESENTATION, AST_REDIRECTING_TO_NAME_VALID, AST_REDIRECTING_TO_NAME_CHAR_SET, AST_REDIRECTING_TO_NAME_PRESENTATION, AST_REDIRECTING_TO_NUMBER_VALID, AST_REDIRECTING_TO_NUMBER_PRESENTATION } |
| Element identifiers for redirecting indication frame data. More... | |
Functions | |
| int | __ast_answer (struct ast_channel *chan, unsigned int delay, int cdr_answer) |
| Answer a channel, with a selectable delay before returning. | |
| static void | __ast_change_name_nolink (struct ast_channel *chan, const char *newname) |
| this function simply changes the name of the channel and issues a manager_event with out unlinking and linking the channel from the ao2_container. This should only be used when the channel has already been unlinked from the ao2_container. | |
| struct ast_channel * | __ast_channel_alloc (int needqueue, int state, const char *cid_num, const char *cid_name, const char *acctcode, const char *exten, const char *context, const char *linkedid, const int amaflag, const char *file, int line, const char *function, const char *name_fmt,...) |
| Create a channel structure. | |
| static struct ast_channel *attribute_malloc | __ast_channel_alloc_ap (int needqueue, int state, const char *cid_num, const char *cid_name, const char *acctcode, const char *exten, const char *context, const char *linkedid, const int amaflag, const char *file, int line, const char *function, const char *name_fmt, va_list ap1, va_list ap2) |
| Create a new channel structure. | |
| static int | __ast_queue_frame (struct ast_channel *chan, struct ast_frame *fin, int head, struct ast_frame *after) |
| static struct ast_frame * | __ast_read (struct ast_channel *chan, int dropaudio) |
| struct ast_channel * | __ast_request_and_dial (const char *type, format_t format, const struct ast_channel *requestor, void *data, int timeout, int *outstate, const char *cid_num, const char *cid_name, struct outgoing_helper *oh) |
| Request a channel of a given type, with data as optional information used by the low level module and attempt to place a call on it. | |
| static void | __init_state2str_threadbuf (void) |
| static void | adjust_frame_for_plc (struct ast_channel *chan, struct ast_frame *frame, struct ast_datastore *datastore) |
| static void | apply_plc (struct ast_channel *chan, struct ast_frame *frame) |
| int | ast_activate_generator (struct ast_channel *chan, struct ast_generator *gen, void *params) |
| int | ast_active_channels (void) |
| returns number of active/allocated channels | |
| int | ast_answer (struct ast_channel *chan) |
| Answer a channel. | |
| void | ast_begin_shutdown (int hangup) |
| format_t | ast_best_codec (format_t fmts) |
| Pick the best audio codec. | |
| struct ast_channel * | ast_bridged_channel (struct ast_channel *chan) |
| Find bridged channel. | |
| int | ast_call (struct ast_channel *chan, char *addr, int timeout) |
| Make a call. | |
| struct ast_channel * | ast_call_forward (struct ast_channel *caller, struct ast_channel *orig, int *timeout, format_t format, struct outgoing_helper *oh, int *outstate) |
| Forwards a call to a new channel specified by the original channel's call_forward str. If possible, the new forwarded channel is created and returned while the original one is terminated. | |
| void | ast_cancel_shutdown (void) |
| Cancel a shutdown in progress. | |
| const char * | ast_cause2str (int cause) |
| Gives the string form of a given hangup cause. | |
| void | ast_change_name (struct ast_channel *chan, const char *newname) |
| Change channel name. | |
| struct ast_channel * | ast_channel_alloc (int needqueue, int state, const char *cid_num, const char *cid_name, const char *acctcode, const char *exten, const char *context, const char *linkedid, const int amaflag, const char *name_fmt,...) |
| enum ast_bridge_result | ast_channel_bridge (struct ast_channel *c0, struct ast_channel *c1, struct ast_bridge_config *config, struct ast_frame **fo, struct ast_channel **rc) |
| Bridge two channels together. | |
| struct ast_channel * | ast_channel_callback (ao2_callback_data_fn *cb_fn, void *arg, void *data, int ao2_flags) |
| Call a function with every active channel. | |
| int | ast_channel_cc_params_init (struct ast_channel *chan, const struct ast_cc_config_params *base_params) |
| Set up datastore with CCSS parameters for a channel. | |
| static void | ast_channel_change_linkedid (struct ast_channel *chan, const char *linkedid) |
| static int | ast_channel_cmp_cb (void *obj, void *arg, int flags) |
| int | ast_channel_cmpwhentohangup (struct ast_channel *chan, time_t offset) |
| Compare a offset with the settings of when to hang a channel up. | |
| int | ast_channel_cmpwhentohangup_tv (struct ast_channel *chan, struct timeval offset) |
| Compare a offset with when to hangup channel. | |
| int | ast_channel_connected_line_macro (struct ast_channel *autoservice_chan, struct ast_channel *macro_chan, const void *connected_info, int is_caller, int is_frame) |
| Run a connected line interception macro and update a channel's connected line information. | |
| int | ast_channel_data_add_structure (struct ast_data *tree, struct ast_channel *chan, int add_bridged) |
| Insert into an astdata tree, the channel structure. | |
| int | ast_channel_data_cmp_structure (const struct ast_data_search *tree, struct ast_channel *chan, const char *structure_name) |
| Compare to channel structures using the data api. | |
| int | ast_channel_datastore_add (struct ast_channel *chan, struct ast_datastore *datastore) |
| Add a datastore to a channel. | |
| struct ast_datastore * | ast_channel_datastore_alloc (const struct ast_datastore_info *info, const char *uid) |
| Create a channel data store object. | |
| struct ast_datastore * | ast_channel_datastore_find (struct ast_channel *chan, const struct ast_datastore_info *info, const char *uid) |
| Find a datastore on a channel. | |
| int | ast_channel_datastore_free (struct ast_datastore *datastore) |
| Free a channel data store object. | |
| int | ast_channel_datastore_inherit (struct ast_channel *from, struct ast_channel *to) |
| Inherit datastores from a parent to a child. | |
| int | ast_channel_datastore_remove (struct ast_channel *chan, struct ast_datastore *datastore) |
| Remove a datastore from a channel. | |
| int | ast_channel_defer_dtmf (struct ast_channel *chan) |
| Set defer DTMF flag on channel. | |
| static void | ast_channel_destructor (void *obj) |
| Free a channel structure. | |
| int | ast_channel_early_bridge (struct ast_channel *c0, struct ast_channel *c1) |
| Bridge two channels together (early). | |
| struct ast_channel * | ast_channel_get_by_exten (const char *exten, const char *context) |
| Find a channel by extension and context. | |
| struct ast_channel * | ast_channel_get_by_name (const char *name) |
| Find a channel by name. | |
| struct ast_channel * | ast_channel_get_by_name_prefix (const char *name, size_t name_len) |
| Find a channel by a name prefix. | |
| int | ast_channel_get_cc_agent_type (struct ast_channel *chan, char *agent_type, size_t size) |
| Find the appropriate CC agent type to use given a channel. | |
| struct ast_cc_config_params * | ast_channel_get_cc_config_params (struct ast_channel *chan) |
| Get the CCSS parameters from a channel. | |
| int | ast_channel_get_device_name (struct ast_channel *chan, char *device_name, size_t name_buffer_length) |
| Get a device name given its channel structure. | |
| static struct ast_channel * | ast_channel_get_full (const char *name, size_t name_len, const char *exten, const char *context) |
| static int | ast_channel_hash_cb (const void *obj, const int flags) |
| void | ast_channel_inherit_variables (const struct ast_channel *parent, struct ast_channel *child) |
| Inherits channel variable from parent to child channel. | |
| struct ast_channel_iterator * | ast_channel_iterator_all_new (void) |
| Create a new channel iterator. | |
| struct ast_channel_iterator * | ast_channel_iterator_by_exten_new (const char *exten, const char *context) |
| Create a new channel iterator based on extension. | |
| struct ast_channel_iterator * | ast_channel_iterator_by_name_new (const char *name, size_t name_len) |
| Create a new channel iterator based on name. | |
| struct ast_channel_iterator * | ast_channel_iterator_destroy (struct ast_channel_iterator *i) |
| Destroy a channel iterator. | |
| struct ast_channel * | ast_channel_iterator_next (struct ast_channel_iterator *i) |
| Get the next channel for a channel iterator. | |
| int | ast_channel_make_compatible (struct ast_channel *chan, struct ast_channel *peer) |
| Makes two channel formats compatible. | |
| static int | ast_channel_make_compatible_helper (struct ast_channel *from, struct ast_channel *to) |
| Set up translation from one channel to another. | |
| int | ast_channel_masquerade (struct ast_channel *original, struct ast_channel *clonechan) |
| Weird function made for call transfers. | |
| int | ast_channel_queryoption (struct ast_channel *chan, int option, void *data, int *datalen, int block) |
| Checks the value of an option. | |
| void | ast_channel_queue_connected_line_update (struct ast_channel *chan, const struct ast_party_connected_line *connected, const struct ast_set_party_connected_line *update) |
| Queue a connected line update frame on a channel. | |
| void | ast_channel_queue_redirecting_update (struct ast_channel *chan, const struct ast_party_redirecting *redirecting, const struct ast_set_party_redirecting *update) |
| Queue a redirecting update frame on a channel. | |
| const char * | ast_channel_reason2str (int reason) |
| return an english explanation of the code returned thru __ast_request_and_dial's 'outstate' argument | |
| int | ast_channel_redirecting_macro (struct ast_channel *autoservice_chan, struct ast_channel *macro_chan, const void *redirecting_info, int is_caller, int is_frame) |
| Run a redirecting interception macro and update a channel's redirecting information. | |
| int | ast_channel_register (const struct ast_channel_tech *tech) |
| Register a new telephony channel in Asterisk. | |
| struct ast_channel * | ast_channel_release (struct ast_channel *chan) |
| Unlink and release reference to a channel. | |
| int | ast_channel_sendhtml (struct ast_channel *chan, int subclass, const char *data, int datalen) |
| Sends HTML on given channel Send HTML or URL on link. | |
| int | ast_channel_sendurl (struct ast_channel *chan, const char *url) |
| Sends a URL on a given link Send URL on link. | |
| void | ast_channel_set_caller (struct ast_channel *chan, const struct ast_party_caller *caller, const struct ast_set_party_caller *update) |
| Set the caller id information in the Asterisk channel. | |
| void | ast_channel_set_caller_event (struct ast_channel *chan, const struct ast_party_caller *caller, const struct ast_set_party_caller *update) |
| Set the caller id information in the Asterisk channel and generate an AMI event if the caller id name or number changed. | |
| void | ast_channel_set_connected_line (struct ast_channel *chan, const struct ast_party_connected_line *connected, const struct ast_set_party_connected_line *update) |
| Set the connected line information in the Asterisk channel. | |
| void | ast_channel_set_fd (struct ast_channel *chan, int which, int fd) |
| void | ast_channel_set_linkgroup (struct ast_channel *chan, struct ast_channel *peer) |
| Propagate the oldest linkedid between associated channels. | |
| void | ast_channel_set_redirecting (struct ast_channel *chan, const struct ast_party_redirecting *redirecting, const struct ast_set_party_redirecting *update) |
| Set the redirecting id information in the Asterisk channel. | |
| int | ast_channel_setoption (struct ast_channel *chan, int option, void *data, int datalen, int block) |
| Sets an option on a channel. | |
| void | ast_channel_setwhentohangup (struct ast_channel *chan, time_t offset) |
| Set when to hang a channel up. | |
| void | ast_channel_setwhentohangup_tv (struct ast_channel *chan, struct timeval offset) |
| Set when to hangup channel. | |
| static int | ast_channel_softhangup_cb (void *obj, void *arg, int flags) |
| struct ast_silence_generator * | ast_channel_start_silence_generator (struct ast_channel *chan) |
| Starts a silence generator on the given channel. | |
| void | ast_channel_stop_silence_generator (struct ast_channel *chan, struct ast_silence_generator *state) |
| Stops a previously-started silence generator on the given channel. | |
| int | ast_channel_supports_html (struct ast_channel *chan) |
| Checks for HTML support on a channel. | |
| void | ast_channel_undefer_dtmf (struct ast_channel *chan) |
| Unset defer DTMF flag on channel. | |
| void | ast_channel_unregister (const struct ast_channel_tech *tech) |
| Unregister channel driver. | |
| void | ast_channel_update_connected_line (struct ast_channel *chan, const struct ast_party_connected_line *connected, const struct ast_set_party_connected_line *update) |
| Indicate that the connected line information has changed. | |
| void | ast_channel_update_redirecting (struct ast_channel *chan, const struct ast_party_redirecting *redirecting, const struct ast_set_party_redirecting *update) |
| Indicate that the redirecting id has changed. | |
| void | ast_channels_init (void) |
| struct ast_variable * | ast_channeltype_list (void) |
| return an ast_variable list of channeltypes | |
| int | ast_check_hangup (struct ast_channel *chan) |
| Checks to see if a channel is needing hang up. | |
| int | ast_check_hangup_locked (struct ast_channel *chan) |
| int | ast_connected_line_build_data (unsigned char *data, size_t datalen, const struct ast_party_connected_line *connected, const struct ast_set_party_connected_line *update) |
| Build the connected line information data frame. | |
| void | ast_connected_line_copy_from_caller (struct ast_party_connected_line *dest, const struct ast_party_caller *src) |
| Copy the caller information to the connected line information. | |
| void | ast_connected_line_copy_to_caller (struct ast_party_caller *dest, const struct ast_party_connected_line *src) |
| Copy the connected line information to the caller information. | |
| int | ast_connected_line_parse_data (const unsigned char *data, size_t datalen, struct ast_party_connected_line *connected) |
| Parse connected line indication frame data. | |
| AST_DATA_STRUCTURE (ast_channel, DATA_EXPORT_CHANNEL) | |
| void | ast_deactivate_generator (struct ast_channel *chan) |
| int | ast_do_masquerade (struct ast_channel *original) |
| Masquerade a channel. | |
| struct ast_channel * | ast_dummy_channel_alloc (void) |
| Create a fake channel structure. | |
| static void | ast_dummy_channel_destructor (void *obj) |
| Free a dummy channel structure. | |
| static enum ast_bridge_result | ast_generic_bridge (struct ast_channel *c0, struct ast_channel *c1, struct ast_bridge_config *config, struct ast_frame **fo, struct ast_channel **rc) |
| struct ast_channel_tech * | ast_get_channel_tech (const char *name) |
| Get handle to channel driver based on name. | |
| ast_group_t | ast_get_group (const char *s) |
| int | ast_hangup (struct ast_channel *chan) |
| Hangup a channel. | |
| int | ast_indicate (struct ast_channel *chan, int condition) |
| Indicates condition of channel. | |
| int | ast_indicate_data (struct ast_channel *chan, int _condition, const void *data, size_t datalen) |
| Indicates condition of channel, with payload. | |
| void | ast_install_music_functions (int(*start_ptr)(struct ast_channel *, const char *, const char *), void(*stop_ptr)(struct ast_channel *), void(*cleanup_ptr)(struct ast_channel *)) |
| int | ast_internal_timing_enabled (struct ast_channel *chan) |
| Check if the channel can run in internal timing mode. | |
| int | ast_is_deferrable_frame (const struct ast_frame *frame) |
| Should we keep this frame for later? | |
| void | ast_moh_cleanup (struct ast_channel *chan) |
| int | ast_moh_start (struct ast_channel *chan, const char *mclass, const char *interpclass) |
| Turn on music on hold on a given channel. | |
| void | ast_moh_stop (struct ast_channel *chan) |
| Turn off music on hold on a given channel. | |
| void | ast_party_caller_copy (struct ast_party_caller *dest, const struct ast_party_caller *src) |
| Copy the source caller information to the destination caller. | |
| void | ast_party_caller_free (struct ast_party_caller *doomed) |
| Destroy the caller party contents. | |
| void | ast_party_caller_init (struct ast_party_caller *init) |
| Initialize the given caller structure. | |
| void | ast_party_caller_set (struct ast_party_caller *dest, const struct ast_party_caller *src, const struct ast_set_party_caller *update) |
| Set the caller information based on another caller source. | |
| void | ast_party_caller_set_init (struct ast_party_caller *init, const struct ast_party_caller *guide) |
| Initialize the given caller structure using the given guide for a set update operation. | |
| void | ast_party_connected_line_collect_caller (struct ast_party_connected_line *connected, struct ast_party_caller *caller) |
| Collect the caller party information into a connected line structure. | |
| void | ast_party_connected_line_copy (struct ast_party_connected_line *dest, const struct ast_party_connected_line *src) |
| Copy the source connected line information to the destination connected line. | |
| void | ast_party_connected_line_free (struct ast_party_connected_line *doomed) |
| Destroy the connected line information contents. | |
| void | ast_party_connected_line_init (struct ast_party_connected_line *init) |
| Initialize the given connected line structure. | |
| void | ast_party_connected_line_set (struct ast_party_connected_line *dest, const struct ast_party_connected_line *src, const struct ast_set_party_connected_line *update) |
| Set the connected line information based on another connected line source. | |
| void | ast_party_connected_line_set_init (struct ast_party_connected_line *init, const struct ast_party_connected_line *guide) |
| Initialize the given connected line structure using the given guide for a set update operation. | |
| void | ast_party_dialed_copy (struct ast_party_dialed *dest, const struct ast_party_dialed *src) |
| Copy the source dialed party information to the destination dialed party. | |
| void | ast_party_dialed_free (struct ast_party_dialed *doomed) |
| Destroy the dialed party contents. | |
| void | ast_party_dialed_init (struct ast_party_dialed *init) |
| Initialize the given dialed structure. | |
| void | ast_party_dialed_set (struct ast_party_dialed *dest, const struct ast_party_dialed *src) |
| Set the dialed information based on another dialed source. | |
| void | ast_party_dialed_set_init (struct ast_party_dialed *init, const struct ast_party_dialed *guide) |
| Initialize the given dialed structure using the given guide for a set update operation. | |
| void | ast_party_id_copy (struct ast_party_id *dest, const struct ast_party_id *src) |
| Copy the source party id information to the destination party id. | |
| void | ast_party_id_free (struct ast_party_id *doomed) |
| Destroy the party id contents. | |
| void | ast_party_id_init (struct ast_party_id *init) |
| Initialize the given party id structure. | |
| int | ast_party_id_presentation (const struct ast_party_id *id) |
| Determine the overall presentation value for the given party. | |
| void | ast_party_id_set (struct ast_party_id *dest, const struct ast_party_id *src, const struct ast_set_party_id *update) |
| Set the source party id information into the destination party id. | |
| void | ast_party_id_set_init (struct ast_party_id *init, const struct ast_party_id *guide) |
| Initialize the given party id structure using the given guide for a set update operation. | |
| void | ast_party_name_copy (struct ast_party_name *dest, const struct ast_party_name *src) |
| Copy the source party name information to the destination party name. | |
| void | ast_party_name_free (struct ast_party_name *doomed) |
| Destroy the party name contents. | |
| void | ast_party_name_init (struct ast_party_name *init) |
| Initialize the given name structure. | |
| void | ast_party_name_set (struct ast_party_name *dest, const struct ast_party_name *src) |
| Set the source party name information into the destination party name. | |
| void | ast_party_name_set_init (struct ast_party_name *init, const struct ast_party_name *guide) |
| Initialize the given party name structure using the given guide for a set update operation. | |
| void | ast_party_number_copy (struct ast_party_number *dest, const struct ast_party_number *src) |
| Copy the source party number information to the destination party number. | |
| void | ast_party_number_free (struct ast_party_number *doomed) |
| Destroy the party number contents. | |
| void | ast_party_number_init (struct ast_party_number *init) |
| Initialize the given number structure. | |
| void | ast_party_number_set (struct ast_party_number *dest, const struct ast_party_number *src) |
| Set the source party number information into the destination party number. | |
| void | ast_party_number_set_init (struct ast_party_number *init, const struct ast_party_number *guide) |
| Initialize the given party number structure using the given guide for a set update operation. | |
| void | ast_party_redirecting_copy (struct ast_party_redirecting *dest, const struct ast_party_redirecting *src) |
| Copy the source redirecting information to the destination redirecting. | |
| void | ast_party_redirecting_free (struct ast_party_redirecting *doomed) |
| Destroy the redirecting information contents. | |
| void | ast_party_redirecting_init (struct ast_party_redirecting *init) |
| Initialize the given redirecting structure. | |
| void | ast_party_redirecting_set (struct ast_party_redirecting *dest, const struct ast_party_redirecting *src, const struct ast_set_party_redirecting *update) |
| Set the redirecting information based on another redirecting source. | |
| void | ast_party_redirecting_set_init (struct ast_party_redirecting *init, const struct ast_party_redirecting *guide) |
| Initialize the given redirecting id structure using the given guide for a set update operation. | |
| void | ast_party_subaddress_copy (struct ast_party_subaddress *dest, const struct ast_party_subaddress *src) |
| Copy the source party subaddress information to the destination party subaddress. | |
| void | ast_party_subaddress_free (struct ast_party_subaddress *doomed) |
| Destroy the party subaddress contents. | |
| void | ast_party_subaddress_init (struct ast_party_subaddress *init) |
| Initialize the given subaddress structure. | |
| void | ast_party_subaddress_set (struct ast_party_subaddress *dest, const struct ast_party_subaddress *src) |
| Set the source party subaddress information into the destination party subaddress. | |
| void | ast_party_subaddress_set_init (struct ast_party_subaddress *init, const struct ast_party_subaddress *guide) |
| Initialize the given party subaddress structure using the given guide for a set update operation. | |
| int | ast_plc_reload (void) |
| Reload genericplc configuration value from codecs.conf. | |
| void | ast_poll_channel_add (struct ast_channel *chan0, struct ast_channel *chan1) |
| void | ast_poll_channel_del (struct ast_channel *chan0, struct ast_channel *chan1) |
| char * | ast_print_group (char *buf, int buflen, ast_group_t group) |
| Print call group and pickup group ---. | |
| int | ast_prod (struct ast_channel *chan) |
| Send empty audio to prime a channel driver. | |
| int | ast_queue_control (struct ast_channel *chan, enum ast_control_frame_type control) |
| Queue a control frame. | |
| int | ast_queue_control_data (struct ast_channel *chan, enum ast_control_frame_type control, const void *data, size_t datalen) |
| Queue a control frame with payload. | |
| int | ast_queue_frame (struct ast_channel *chan, struct ast_frame *fin) |
| Queue one or more frames to a channel's frame queue. | |
| int | ast_queue_frame_head (struct ast_channel *chan, struct ast_frame *fin) |
| Queue one or more frames to the head of a channel's frame queue. | |
| int | ast_queue_hangup (struct ast_channel *chan) |
| Queue a hangup frame for channel. | |
| int | ast_queue_hangup_with_cause (struct ast_channel *chan, int cause) |
| Queue a hangup frame for channel. | |
| int | ast_raw_answer (struct ast_channel *chan, int cdr_answer) |
| Answer a channel. | |
| struct ast_frame * | ast_read (struct ast_channel *chan) |
| Reads a frame. | |
| static void | ast_read_generator_actions (struct ast_channel *chan, struct ast_frame *f) |
| struct ast_frame * | ast_read_noaudio (struct ast_channel *chan) |
| Reads a frame, returning AST_FRAME_NULL frame if audio. | |
| int | ast_readstring (struct ast_channel *c, char *s, int len, int timeout, int ftimeout, char *enders) |
| Reads multiple digits. | |
| int | ast_readstring_full (struct ast_channel *c, char *s, int len, int timeout, int ftimeout, char *enders, int audiofd, int ctrlfd) |
| int | ast_recvchar (struct ast_channel *chan, int timeout) |
| Receives a text character from a channel. | |
| char * | ast_recvtext (struct ast_channel *chan, int timeout) |
| Receives a text string from a channel Read a string of text from a channel. | |
| int | ast_redirecting_build_data (unsigned char *data, size_t datalen, const struct ast_party_redirecting *redirecting, const struct ast_set_party_redirecting *update) |
| Build the redirecting id data frame. | |
| int | ast_redirecting_parse_data (const unsigned char *data, size_t datalen, struct ast_party_redirecting *redirecting) |
| Parse redirecting indication frame data. | |
| struct ast_channel * | ast_request (const char *type, format_t format, const struct ast_channel *requestor, void *data, int *cause) |
| Requests a channel. | |
| struct ast_channel * | ast_request_and_dial (const char *type, format_t format, const struct ast_channel *requestor, void *data, int timeout, int *outstate, const char *cidnum, const char *cidname) |
| Request a channel of a given type, with data as optional information used by the low level module and attempt to place a call on it. | |
| int | ast_safe_sleep (struct ast_channel *chan, int ms) |
| Wait, look for hangups. | |
| int | ast_safe_sleep_conditional (struct ast_channel *chan, int ms, int(*cond)(void *), void *data) |
| Wait, look for hangups and condition arg. | |
| int | ast_say_character_str (struct ast_channel *chan, const char *str, const char *ints, const char *lang) |
| int | ast_say_digit_str (struct ast_channel *chan, const char *str, const char *ints, const char *lang) |
| says digits of a string | |
| int | ast_say_digits (struct ast_channel *chan, int num, const char *ints, const char *lang) |
| says digits | |
| int | ast_say_digits_full (struct ast_channel *chan, int num, const char *ints, const char *lang, int audiofd, int ctrlfd) |
| int | ast_say_enumeration (struct ast_channel *chan, int num, const char *ints, const char *language, const char *options) |
| says an enumeration | |
| int | ast_say_number (struct ast_channel *chan, int num, const char *ints, const char *language, const char *options) |
| says a number | |
| int | ast_say_phonetic_str (struct ast_channel *chan, const char *str, const char *ints, const char *lang) |
| int | ast_senddigit (struct ast_channel *chan, char digit, unsigned int duration) |
| Send a DTMF digit to a channel. | |
| int | ast_senddigit_begin (struct ast_channel *chan, char digit) |
| Send a DTMF digit to a channel. | |
| int | ast_senddigit_end (struct ast_channel *chan, char digit, unsigned int duration) |
| Send a DTMF digit to a channel. | |
| int | ast_sendtext (struct ast_channel *chan, const char *text) |
| Sends text to a channel. | |
| void | ast_set_callerid (struct ast_channel *chan, const char *cid_num, const char *cid_name, const char *cid_ani) |
| Set caller ID number, name and ANI and generate AMI event. | |
| void | ast_set_hangupsource (struct ast_channel *chan, const char *source, int force) |
| Set the source of the hangup in this channel and it's bridge. | |
| static void | ast_set_owners_and_peers (struct ast_channel *chan1, struct ast_channel *chan2) |
| int | ast_set_read_format (struct ast_channel *chan, format_t fmt) |
| Sets read format on channel chan Set read format for channel to whichever component of "format" is best. | |
| void | ast_set_variables (struct ast_channel *chan, struct ast_variable *vars) |
| adds a list of channel variables to a channel | |
| int | ast_set_write_format (struct ast_channel *chan, format_t fmt) |
| Sets write format on channel chan Set write format for channel to whichever component of "format" is best. | |
| int | ast_setstate (struct ast_channel *chan, enum ast_channel_state state) |
| Change the state of a channel. | |
| int | ast_settimeout (struct ast_channel *c, unsigned int rate, int(*func)(const void *data), void *data) |
| Enable or disable timer ticks for a channel. | |
| int | ast_shutting_down (void) |
| Returns non-zero if Asterisk is being shut down. | |
| int | ast_softhangup (struct ast_channel *chan, int cause) |
| Softly hangup a channel, lock. | |
| int | ast_softhangup_nolock (struct ast_channel *chan, int cause) |
| Softly hangup a channel, don't lock. | |
| const char * | ast_state2str (enum ast_channel_state state) |
| Gives the string form of a given channel state. | |
| int | ast_str2cause (const char *name) |
| Convert a symbolic hangup cause to number. | |
| int | ast_tonepair (struct ast_channel *chan, int freq1, int freq2, int duration, int vol) |
| int | ast_tonepair_start (struct ast_channel *chan, int freq1, int freq2, int duration, int vol) |
| void | ast_tonepair_stop (struct ast_channel *chan) |
| int | ast_transfer (struct ast_channel *chan, char *dest) |
| Transfer a call to dest, if the channel supports transfer. | |
| char * | ast_transfercapability2str (int transfercapability) |
| Gives the string form of a given transfer capability. | |
| void | ast_uninstall_music_functions (void) |
| int | ast_waitfor (struct ast_channel *c, int ms) |
| Wait for input on a channel. | |
| struct ast_channel * | ast_waitfor_n (struct ast_channel **c, int n, int *ms) |
| Waits for input on a group of channels Wait for input on an array of channels for a given # of milliseconds. | |
| int | ast_waitfor_n_fd (int *fds, int n, int *ms, int *exception) |
| Wait for x amount of time on a file descriptor to have input. | |
| struct ast_channel * | ast_waitfor_nandfds (struct ast_channel **c, int n, int *fds, int nfds, int *exception, int *outfd, int *ms) |
| Wait for x amount of time on a file descriptor to have input. | |
| int | ast_waitfordigit (struct ast_channel *c, int ms) |
| Waits for a digit. | |
| int | ast_waitfordigit_full (struct ast_channel *c, int ms, int audiofd, int cmdfd) |
| Wait for a digit Same as ast_waitfordigit() with audio fd for outputting read audio and ctrlfd to monitor for reading. | |
| int | ast_write (struct ast_channel *chan, struct ast_frame *fr) |
| Write a frame to a channel This function writes the given frame to the indicated channel. | |
| int | ast_write_video (struct ast_channel *chan, struct ast_frame *fr) |
| Write video frame to a channel This function writes the given frame to the indicated channel. | |
| static void | bridge_play_sounds (struct ast_channel *c0, struct ast_channel *c1) |
| static void | bridge_playfile (struct ast_channel *chan, struct ast_channel *peer, const char *sound, int remain) |
| static int | calc_monitor_jump (int samples, int sample_rate, int seek_rate) |
| calculates the number of samples to jump forward with in a monitor stream. | |
| static void * | channel_cc_params_copy (void *data) |
| static void | channel_cc_params_destroy (void *data) |
| static void | channel_data_add_flags (struct ast_data *tree, struct ast_channel *chan) |
| static struct ast_channel_iterator * | channel_iterator_search (const char *name, size_t name_len, const char *exten, const char *context) |
| const char * | channelreloadreason2txt (enum channelreloadreason reason) |
| Convert enum channelreloadreason to text string for manager event. | |
| static void | clone_variables (struct ast_channel *original, struct ast_channel *clonechan) |
| Clone channel variables from 'clone' channel into 'original' channel. | |
| static char * | complete_channeltypes (struct ast_cli_args *a) |
| static int | data_channels_provider_handler (const struct ast_data_search *search, struct ast_data *root) |
| static int | data_channeltypes_provider_handler (const struct ast_data_search *search, struct ast_data *data_root) |
| static void | free_translation (struct ast_channel *clonechan) |
| static int | generator_force (const void *data) |
| static void | handle_cause (int cause, int *outstate) |
| static char * | handle_cli_core_show_channeltype (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) |
| Show details about a channel driver - CLI command. | |
| static char * | handle_cli_core_show_channeltypes (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) |
| Show channel types - CLI command. | |
| static int attribute_const | is_visible_indication (enum ast_control_frame_type condition) |
| static void | manager_bridge_event (int onoff, int type, struct ast_channel *c0, struct ast_channel *c1) |
| Send manager event for bridge link and unlink events. | |
| static const char * | oldest_linkedid (const char *a, const char *b) |
| static int | party_id_build_data (unsigned char *data, size_t datalen, const struct ast_party_id *id, const char *label, const struct ast_party_id_ies *ies, const struct ast_set_party_id *update) |
| static int | party_name_build_data (unsigned char *data, size_t datalen, const struct ast_party_name *name, const char *label, const struct ast_party_name_ies *ies) |
| static int | party_number_build_data (unsigned char *data, size_t datalen, const struct ast_party_number *number, const char *label, const struct ast_party_number_ies *ies) |
| static int | party_subaddress_build_data (unsigned char *data, size_t datalen, const struct ast_party_subaddress *subaddress, const char *label, const struct ast_party_subaddress_ies *ies) |
| static void | plc_ds_destroy (void *data) |
| static void | queue_dtmf_readq (struct ast_channel *chan, struct ast_frame *f) |
| static void | report_new_callerid (struct ast_channel *chan) |
| static void | send_dtmf_event (struct ast_channel *chan, const char *direction, const char digit, const char *begin, const char *end) |
| static int | set_format (struct ast_channel *chan, format_t fmt, format_t *rawformat, format_t *format, struct ast_trans_pvt **trans, const int direction) |
| static int | set_security_requirements (const struct ast_channel *requestor, struct ast_channel *out) |
| static int | should_skip_dtmf (struct ast_channel *chan) |
| Determine whether or not we should ignore DTMF in the readq. | |
| static void * | silence_generator_alloc (struct ast_channel *chan, void *data) |
| static int | silence_generator_generate (struct ast_channel *chan, void *data, int len, int samples) |
| static void | silence_generator_release (struct ast_channel *chan, void *data) |
| static void * | tonepair_alloc (struct ast_channel *chan, void *params) |
| static int | tonepair_generator (struct ast_channel *chan, void *data, int len, int samples) |
| static void | tonepair_release (struct ast_channel *chan, void *params) |
| static void | update_bridge_vars (struct ast_channel *c0, struct ast_channel *c1) |
Variables | |
| static void(* | ast_moh_cleanup_ptr )(struct ast_channel *) = NULL |
| static int(* | ast_moh_start_ptr )(struct ast_channel *, const char *, const char *) = NULL |
| static void(* | ast_moh_stop_ptr )(struct ast_channel *) = NULL |
| struct { | |
| int cause | |
| const char * desc | |
| const char * name | |
| } | causes [] |
| map AST_CAUSE's to readable string representations | |
| static struct ast_datastore_info | cc_channel_datastore_info |
| static struct ast_data_entry | channel_providers [] |
| static struct ao2_container * | channels |
| All active channels on the system. | |
| static struct ast_data_handler | channels_provider |
| static struct ast_data_handler | channeltypes_provider |
| static struct ast_cli_entry | cli_channel [] |
| unsigned long | global_fin |
| unsigned long | global_fout |
| static struct ast_channel_tech | null_tech |
| static struct ast_datastore_info | plc_ds_info |
| static int | shutting_down |
| Prevent new channel allocation if shutting down. | |
| static struct ast_generator | silence_generator |
| static struct ast_threadstorage | state2str_threadbuf = { .once = PTHREAD_ONCE_INIT , .key_init = __init_state2str_threadbuf , .custom_init = NULL , } |
| static struct ast_generator | tonepair |
| static int | uniqueint |
Definition in file channel.c.
| #define AST_DEFAULT_EMULATE_DTMF_DURATION 100 |
Default amount of time to use when emulating a digit as a begin and end 100ms
Definition at line 105 of file channel.c.
Referenced by __ast_read(), and ast_senddigit().
| #define AST_MIN_DTMF_DURATION 80 |
Minimum allowed digit length - 80ms
Definition at line 108 of file channel.c.
Referenced by __ast_read().
| #define AST_MIN_DTMF_GAP 45 |
Minimum amount of time between the end of the last digit and the beginning of a new one - 45ms
Definition at line 112 of file channel.c.
Referenced by __ast_read(), and should_skip_dtmf().
| #define FORMAT "%-10.10s %-40.40s %-12.12s %-12.12s %-12.12s\n" |
| #define NUM_CHANNEL_BUCKETS 1567 |
| #define STATE2STR_BUFSIZE 32 |
| anonymous enum |
Element identifiers for connected line indication frame data.
Definition at line 7981 of file channel.c.
07981 { 07982 AST_CONNECTED_LINE_NUMBER, 07983 AST_CONNECTED_LINE_NAME, 07984 AST_CONNECTED_LINE_NUMBER_PLAN, 07985 AST_CONNECTED_LINE_ID_PRESENTATION,/* Combined number and name presentation. */ 07986 AST_CONNECTED_LINE_SOURCE, 07987 AST_CONNECTED_LINE_SUBADDRESS, 07988 AST_CONNECTED_LINE_SUBADDRESS_TYPE, 07989 AST_CONNECTED_LINE_SUBADDRESS_ODD_EVEN, 07990 AST_CONNECTED_LINE_SUBADDRESS_VALID, 07991 AST_CONNECTED_LINE_TAG, 07992 AST_CONNECTED_LINE_VERSION, 07993 AST_CONNECTED_LINE_NAME_VALID, 07994 AST_CONNECTED_LINE_NAME_CHAR_SET, 07995 AST_CONNECTED_LINE_NAME_PRESENTATION, 07996 AST_CONNECTED_LINE_NUMBER_VALID, 07997 AST_CONNECTED_LINE_NUMBER_PRESENTATION, 07998 };
| anonymous enum |
Element identifiers for redirecting indication frame data.
Definition at line 8302 of file channel.c.
08302 { 08303 AST_REDIRECTING_FROM_NUMBER, 08304 AST_REDIRECTING_FROM_NAME, 08305 AST_REDIRECTING_FROM_NUMBER_PLAN, 08306 AST_REDIRECTING_FROM_ID_PRESENTATION, 08307 AST_REDIRECTING_TO_NUMBER, 08308 AST_REDIRECTING_TO_NAME, 08309 AST_REDIRECTING_TO_NUMBER_PLAN, 08310 AST_REDIRECTING_TO_ID_PRESENTATION, 08311 AST_REDIRECTING_REASON, 08312 AST_REDIRECTING_COUNT, 08313 AST_REDIRECTING_FROM_SUBADDRESS, 08314 AST_REDIRECTING_FROM_SUBADDRESS_TYPE, 08315 AST_REDIRECTING_FROM_SUBADDRESS_ODD_EVEN, 08316 AST_REDIRECTING_FROM_SUBADDRESS_VALID, 08317 AST_REDIRECTING_TO_SUBADDRESS, 08318 AST_REDIRECTING_TO_SUBADDRESS_TYPE, 08319 AST_REDIRECTING_TO_SUBADDRESS_ODD_EVEN, 08320 AST_REDIRECTING_TO_SUBADDRESS_VALID, 08321 AST_REDIRECTING_FROM_TAG, 08322 AST_REDIRECTING_TO_TAG, 08323 AST_REDIRECTING_VERSION, 08324 AST_REDIRECTING_FROM_NAME_VALID, 08325 AST_REDIRECTING_FROM_NAME_CHAR_SET, 08326 AST_REDIRECTING_FROM_NAME_PRESENTATION, 08327 AST_REDIRECTING_FROM_NUMBER_VALID, 08328 AST_REDIRECTING_FROM_NUMBER_PRESENTATION, 08329 AST_REDIRECTING_TO_NAME_VALID, 08330 AST_REDIRECTING_TO_NAME_CHAR_SET, 08331 AST_REDIRECTING_TO_NAME_PRESENTATION, 08332 AST_REDIRECTING_TO_NUMBER_VALID, 08333 AST_REDIRECTING_TO_NUMBER_PRESENTATION, 08334 };
| int __ast_answer | ( | struct ast_channel * | chan, | |
| unsigned int | delay, | |||
| int | cdr_answer | |||
| ) |
Answer a channel, with a selectable delay before returning.
| chan | channel to answer | |
| delay | maximum amount of time to wait for incoming media | |
| cdr_answer | flag to control whether any associated CDR should be marked as 'answered' |
This function will wait up to 'delay' milliseconds for media to arrive on the channel before returning to the caller, so that the caller can properly assume the channel is 'ready' for media flow. If 'delay' is less than 500, the function will wait up to 500 milliseconds.
| 0 | on success | |
| non-zero | on failure |
Definition at line 2797 of file channel.c.
References ast_channel::_state, ast_channel_lock, ast_channel_unlock, AST_CONTROL_HANGUP, ast_debug, AST_FRAME_CNG, AST_FRAME_CONTROL, AST_FRAME_DTMF_BEGIN, AST_FRAME_DTMF_END, AST_FRAME_HTML, AST_FRAME_IAX, AST_FRAME_IMAGE, AST_FRAME_MODEM, AST_FRAME_NULL, AST_FRAME_TEXT, AST_FRAME_VIDEO, AST_FRAME_VOICE, ast_frfree, ast_frisolate(), AST_LIST_HEAD_INIT_NOLOCK, AST_LIST_HEAD_NOLOCK, AST_LIST_INSERT_HEAD, AST_LIST_REMOVE_HEAD, ast_log(), ast_queue_frame_head(), ast_raw_answer(), ast_read(), AST_STATE_RING, AST_STATE_RINGING, ast_waitfor(), errno, frames, ast_frame::frametype, ast_frame_subclass::integer, LOG_WARNING, MAX, ast_channel::name, and ast_frame::subclass.
Referenced by ast_answer(), dial_exec_full(), pbx_builtin_answer(), and pbx_builtin_incomplete().
02798 { 02799 int res = 0; 02800 enum ast_channel_state old_state; 02801 02802 old_state = chan->_state; 02803 if ((res = ast_raw_answer(chan, cdr_answer))) { 02804 return res; 02805 } 02806 02807 switch (old_state) { 02808 case AST_STATE_RINGING: 02809 case AST_STATE_RING: 02810 /* wait for media to start flowing, but don't wait any longer 02811 * than 'delay' or 500 milliseconds, whichever is longer 02812 */ 02813 do { 02814 AST_LIST_HEAD_NOLOCK(, ast_frame) frames; 02815 struct ast_frame *cur, *new; 02816 int ms = MAX(delay, 500); 02817 unsigned int done = 0; 02818 02819 AST_LIST_HEAD_INIT_NOLOCK(&frames); 02820 02821 for (;;) { 02822 ms = ast_waitfor(chan, ms); 02823 if (ms < 0) { 02824 ast_log(LOG_WARNING, "Error condition occurred when polling channel %s for a voice frame: %s\n", chan->name, strerror(errno)); 02825 res = -1; 02826 break; 02827 } 02828 if (ms == 0) { 02829 ast_debug(2, "Didn't receive a media frame from %s within %d ms of answering. Continuing anyway\n", chan->name, MAX(delay, 500)); 02830 break; 02831 } 02832 cur = ast_read(chan); 02833 if (!cur || ((cur->frametype == AST_FRAME_CONTROL) && 02834 (cur->subclass.integer == AST_CONTROL_HANGUP))) { 02835 if (cur) { 02836 ast_frfree(cur); 02837 } 02838 res = -1; 02839 ast_debug(2, "Hangup of channel %s detected in answer routine\n", chan->name); 02840 break; 02841 } 02842 02843 if ((new = ast_frisolate(cur)) != cur) { 02844 ast_frfree(cur); 02845 } 02846 02847 AST_LIST_INSERT_HEAD(&frames, new, frame_list); 02848 02849 /* if a specific delay period was requested, continue 02850 * until that delay has passed. don't stop just because 02851 * incoming media has arrived. 02852 */ 02853 if (delay) { 02854 continue; 02855 } 02856 02857 switch (new->frametype) { 02858 /* all of these frametypes qualify as 'media' */ 02859 case AST_FRAME_VOICE: 02860 case AST_FRAME_VIDEO: 02861 case AST_FRAME_TEXT: 02862 case AST_FRAME_DTMF_BEGIN: 02863 case AST_FRAME_DTMF_END: 02864 case AST_FRAME_IMAGE: 02865 case AST_FRAME_HTML: 02866 case AST_FRAME_MODEM: 02867 done = 1; 02868 break; 02869 case AST_FRAME_CONTROL: 02870 case AST_FRAME_IAX: 02871 case AST_FRAME_NULL: 02872 case AST_FRAME_CNG: 02873 break; 02874 } 02875 02876 if (done) { 02877 break; 02878 } 02879 } 02880 02881 if (res == 0) { 02882 ast_channel_lock(chan); 02883 while ((cur = AST_LIST_REMOVE_HEAD(&frames, frame_list))) { 02884 ast_queue_frame_head(chan, cur); 02885 ast_frfree(cur); 02886 } 02887 ast_channel_unlock(chan); 02888 } 02889 } while (0); 02890 break; 02891 default: 02892 break; 02893 } 02894 02895 return res; 02896 }
| static void __ast_change_name_nolink | ( | struct ast_channel * | chan, | |
| const char * | newname | |||
| ) | [static] |
this function simply changes the name of the channel and issues a manager_event with out unlinking and linking the channel from the ao2_container. This should only be used when the channel has already been unlinked from the ao2_container.
Definition at line 5677 of file channel.c.
References ast_manager_event, ast_string_field_set, EVENT_FLAG_CALL, name, ast_channel::name, and ast_channel::uniqueid.
Referenced by ast_change_name(), and ast_do_masquerade().
05678 { 05679 ast_manager_event(chan, EVENT_FLAG_CALL, "Rename", "Channel: %s\r\nNewname: %s\r\nUniqueid: %s\r\n", chan->name, newname, chan->uniqueid); 05680 ast_string_field_set(chan, name, newname); 05681 }
| struct ast_channel* __ast_channel_alloc | ( | int | needqueue, | |
| int | state, | |||
| const char * | cid_num, | |||
| const char * | cid_name, | |||
| const char * | acctcode, | |||
| const char * | exten, | |||
| const char * | context, | |||
| const char * | linkedid, | |||
| const int | amaflag, | |||
| const char * | file, | |||
| int | line, | |||
| const char * | function, | |||
| const char * | name_fmt, | |||
| ... | ||||
| ) | [read] |
Create a channel structure.
| NULL | failure | |
| non-NULL | successfully allocated channel |
Definition at line 1293 of file channel.c.
References __ast_channel_alloc_ap().
01299 { 01300 va_list ap1, ap2; 01301 struct ast_channel *result; 01302 01303 va_start(ap1, name_fmt); 01304 va_start(ap2, name_fmt); 01305 result = __ast_channel_alloc_ap(needqueue, state, cid_num, cid_name, acctcode, exten, context, 01306 linkedid, amaflag, file, line, function, name_fmt, ap1, ap2); 01307 va_end(ap1); 01308 va_end(ap2); 01309 01310 return result; 01311 }
| static struct ast_channel* attribute_malloc __ast_channel_alloc_ap | ( | int | needqueue, | |
| int | state, | |||
| const char * | cid_num, | |||
| const char * | cid_name, | |||
| const char * | acctcode, | |||
| const char * | exten, | |||
| const char * | context, | |||
| const char * | linkedid, | |||
| const int | amaflag, | |||
| const char * | file, | |||
| int | line, | |||
| const char * | function, | |||
| const char * | name_fmt, | |||
| va_list | ap1, | |||
| va_list | ap2 | |||
| ) | [static, read] |
Create a new channel structure.
Definition at line 1060 of file channel.c.
References __ao2_alloc_debug(), ast_channel::_state, ast_channel::accountcode, accountcode, ast_channel::alertpipe, ast_channel::amaflags, ao2_alloc, ao2_link, ARRAY_LEN, AST_ALERT_FD, ast_atomic_fetchadd_int(), ast_cdr_alloc(), ast_cdr_init(), ast_cdr_start(), AST_CEL_CHANNEL_START, ast_cel_report_event(), ast_channel_destructor(), ast_channel_set_fd(), ast_channel_unref, ast_config_AST_SYSTEM_NAME, ast_copy_string(), ast_default_accountcode, ast_default_amaflags, ast_get_channel_tech(), AST_LIST_HEAD_INIT_NOLOCK, ast_log(), ast_manager_event, ast_party_caller_init(), ast_party_connected_line_init(), ast_party_dialed_init(), ast_party_redirecting_init(), ast_state2str(), ast_strdup, ast_strdupa, ast_string_field_build, ast_string_field_build_va, ast_string_field_init, ast_string_field_set, ast_strlen_zero(), ast_timer_fd(), ast_timer_open(), AST_TIMING_FD, ast_channel::autochans, ast_channel::caller, ast_channel::cdr, channels, ast_channel::connected, ast_channel::context, ast_channel::datastores, defaultlanguage, ast_channel::dialed, errno, EVENT_FLAG_CALL, ast_channel::exten, ast_channel::fds, ast_channel::fin, chanlist::flags, ast_channel::fout, ast_party_caller::id, language, LOG_WARNING, ast_channel::name, name, ast_party_id::name, null_tech, ast_party_id::number, ast_channel::priority, ast_channel::redirecting, S_OR, ast_channel::sched, sched_context_create(), ast_party_number::str, ast_party_name::str, ast_channel::streamid, ast_channel::tech, chanlist::tech, ast_channel::timer, ast_channel::timingfd, ast_channel::uniqueid, ast_party_number::valid, ast_party_name::valid, and ast_channel::varshead.
Referenced by __ast_channel_alloc(), and ast_channel_alloc().
01064 { 01065 struct ast_channel *tmp; 01066 int x; 01067 int flags; 01068 struct varshead *headp; 01069 char *tech = "", *tech2 = NULL; 01070 01071 /* If shutting down, don't allocate any new channels */ 01072 if (shutting_down) { 01073 ast_log(LOG_WARNING, "Channel allocation failed: Refusing due to active shutdown\n"); 01074 return NULL; 01075 } 01076 01077 #if defined(REF_DEBUG) 01078 tmp = __ao2_alloc_debug(sizeof(*tmp), ast_channel_destructor, "", file, line, 01079 function, 1); 01080 #elif defined(__AST_DEBUG_MALLOC) 01081 tmp = __ao2_alloc_debug(sizeof(*tmp), ast_channel_destructor, "", file, line, 01082 function, 0); 01083 #else 01084 tmp = ao2_alloc(sizeof(*tmp), ast_channel_destructor); 01085 #endif 01086 if (!tmp) { 01087 /* Channel structure allocation failure. */ 01088 return NULL; 01089 } 01090 01091 /* 01092 * Init file descriptors to unopened state so 01093 * the destructor can know not to close them. 01094 */ 01095 tmp->timingfd = -1; 01096 for (x = 0; x < ARRAY_LEN(tmp->alertpipe); ++x) { 01097 tmp->alertpipe[x] = -1; 01098 } 01099 for (x = 0; x < ARRAY_LEN(tmp->fds); ++x) { 01100 tmp->fds[x] = -1; 01101 } 01102 #ifdef HAVE_EPOLL 01103 tmp->epfd = epoll_create(25); 01104 #endif 01105 01106 if (!(tmp->sched = sched_context_create())) { 01107 ast_log(LOG_WARNING, "Channel allocation failed: Unable to create schedule context\n"); 01108 return ast_channel_unref(tmp); 01109 } 01110 01111 ast_party_dialed_init(&tmp->dialed); 01112 ast_party_caller_init(&tmp->caller); 01113 ast_party_connected_line_init(&tmp->connected); 01114 ast_party_redirecting_init(&tmp->redirecting); 01115 01116 if (cid_name) { 01117 tmp->caller.id.name.valid = 1; 01118 tmp->caller.id.name.str = ast_strdup(cid_name); 01119 if (!tmp->caller.id.name.str) { 01120 return ast_channel_unref(tmp); 01121 } 01122 } 01123 if (cid_num) { 01124 tmp->caller.id.number.valid = 1; 01125 tmp->caller.id.number.str = ast_strdup(cid_num); 01126 if (!tmp->caller.id.number.str) { 01127 return ast_channel_unref(tmp); 01128 } 01129 } 01130 01131 if ((tmp->timer = ast_timer_open())) { 01132 needqueue = 0; 01133 tmp->timingfd = ast_timer_fd(tmp->timer); 01134 } 01135 01136 if (needqueue) { 01137 if (pipe(tmp->alertpipe)) { 01138 ast_log(LOG_WARNING, "Channel allocation failed: Can't create alert pipe! Try increasing max file descriptors with ulimit -n\n"); 01139 return ast_channel_unref(tmp); 01140 } else { 01141 flags = fcntl(tmp->alertpipe[0], F_GETFL); 01142 if (fcntl(tmp->alertpipe[0], F_SETFL, flags | O_NONBLOCK) < 0) { 01143 ast_log(LOG_WARNING, "Channel allocation failed: Unable to set alertpipe nonblocking! (%d: %s)\n", errno, strerror(errno)); 01144 return ast_channel_unref(tmp); 01145 } 01146 flags = fcntl(tmp->alertpipe[1], F_GETFL); 01147 if (fcntl(tmp->alertpipe[1], F_SETFL, flags | O_NONBLOCK) < 0) { 01148 ast_log(LOG_WARNING, "Channel allocation failed: Unable to set alertpipe nonblocking! (%d: %s)\n", errno, strerror(errno)); 01149 return ast_channel_unref(tmp); 01150 } 01151 } 01152 } 01153 01154 /* 01155 * This is the last place the channel constructor can fail. 01156 * 01157 * The destructor takes advantage of this fact to ensure that the 01158 * AST_CEL_CHANNEL_END is not posted if we have not posted the 01159 * AST_CEL_CHANNEL_START yet. 01160 */ 01161 if ((ast_string_field_init(tmp, 128))) { 01162 return ast_channel_unref(tmp); 01163 } 01164 01165 /* Always watch the alertpipe */ 01166 ast_channel_set_fd(tmp, AST_ALERT_FD, tmp->alertpipe[0]); 01167 /* And timing pipe */ 01168 ast_channel_set_fd(tmp, AST_TIMING_FD, tmp->timingfd); 01169 01170 /* Initial state */ 01171 tmp->_state = state; 01172 01173 tmp->streamid = -1; 01174 01175 tmp->fin = global_fin; 01176 tmp->fout = global_fout; 01177 01178 if (ast_strlen_zero(ast_config_AST_SYSTEM_NAME)) { 01179 ast_string_field_build(tmp, uniqueid, "%li.%d", (long) time(NULL), 01180 ast_atomic_fetchadd_int(&uniqueint, 1)); 01181 } else { 01182 ast_string_field_build(tmp, uniqueid, "%s-%li.%d", ast_config_AST_SYSTEM_NAME, 01183 (long) time(NULL), ast_atomic_fetchadd_int(&uniqueint, 1)); 01184 } 01185 01186 if (!ast_strlen_zero(linkedid)) { 01187 ast_string_field_set(tmp, linkedid, linkedid); 01188 } else { 01189 ast_string_field_set(tmp, linkedid, tmp->uniqueid); 01190 } 01191 01192 if (!ast_strlen_zero(name_fmt)) { 01193 char *slash, *slash2; 01194 /* Almost every channel is calling this function, and setting the name via the ast_string_field_build() call. 01195 * And they all use slightly different formats for their name string. 01196 * This means, to set the name here, we have to accept variable args, and call the string_field_build from here. 01197 * This means, that the stringfields must have a routine that takes the va_lists directly, and 01198 * uses them to build the string, instead of forming the va_lists internally from the vararg ... list. 01199 * This new function was written so this can be accomplished. 01200 */ 01201 ast_string_field_build_va(tmp, name, name_fmt, ap1, ap2); 01202 tech = ast_strdupa(tmp->name); 01203 if ((slash = strchr(tech, '/'))) { 01204 if ((slash2 = strchr(slash + 1, '/'))) { 01205 tech2 = slash + 1; 01206 *slash2 = '\0'; 01207 } 01208 *slash = '\0'; 01209 } 01210 } else { 01211 /* 01212 * Start the string with '-' so it becomes an empty string 01213 * in the destructor. 01214 */ 01215 ast_string_field_set(tmp, name, "-**Unknown**"); 01216 } 01217 01218 /* Reminder for the future: under what conditions do we NOT want to track cdrs on channels? */ 01219 01220 /* These 4 variables need to be set up for the cdr_init() to work right */ 01221 if (amaflag) 01222 tmp->amaflags = amaflag; 01223 else 01224 tmp->amaflags = ast_default_amaflags; 01225 01226 if (!ast_strlen_zero(acctcode)) 01227 ast_string_field_set(tmp, accountcode, acctcode); 01228 else 01229 ast_string_field_set(tmp, accountcode, ast_default_accountcode); 01230 01231 if (!ast_strlen_zero(context)) 01232 ast_copy_string(tmp->context, context, sizeof(tmp->context)); 01233 else 01234 strcpy(tmp->context, "default"); 01235 01236 if (!ast_strlen_zero(exten)) 01237 ast_copy_string(tmp->exten, exten, sizeof(tmp->exten)); 01238 else 01239 strcpy(tmp->exten, "s"); 01240 01241 tmp->priority = 1; 01242 01243 tmp->cdr = ast_cdr_alloc(); 01244 ast_cdr_init(tmp->cdr, tmp); 01245 ast_cdr_start(tmp->cdr); 01246 01247 ast_cel_report_event(tmp, AST_CEL_CHANNEL_START, NULL, NULL, NULL); 01248 01249 headp = &tmp->varshead; 01250 AST_LIST_HEAD_INIT_NOLOCK(headp); 01251 01252 AST_LIST_HEAD_INIT_NOLOCK(&tmp->datastores); 01253 01254 AST_LIST_HEAD_INIT_NOLOCK(&tmp->autochans); 01255 01256 ast_string_field_set(tmp, language, defaultlanguage); 01257 01258 tmp->tech = &null_tech; 01259 01260 ao2_link(channels, tmp); 01261 01262 /* 01263 * And now, since the channel structure is built, and has its name, let's 01264 * call the manager event generator with this Newchannel event. This is the 01265 * proper and correct place to make this call, but you sure do have to pass 01266 * a lot of data into this func to do it here! 01267 */ 01268 if (ast_get_channel_tech(tech) || (tech2 && ast_get_channel_tech(tech2))) { 01269 ast_manager_event(tmp, EVENT_FLAG_CALL, "Newchannel", 01270 "Channel: %s\r\n" 01271 "ChannelState: %d\r\n" 01272 "ChannelStateDesc: %s\r\n" 01273 "CallerIDNum: %s\r\n" 01274 "CallerIDName: %s\r\n" 01275 "AccountCode: %s\r\n" 01276 "Exten: %s\r\n" 01277 "Context: %s\r\n" 01278 "Uniqueid: %s\r\n", 01279 tmp->name, 01280 state, 01281 ast_state2str(state), 01282 S_OR(cid_num, ""), 01283 S_OR(cid_name, ""), 01284 tmp->accountcode, 01285 S_OR(exten, ""), 01286 S_OR(context, ""), 01287 tmp->uniqueid); 01288 } 01289 01290 return tmp; 01291 }
| static int __ast_queue_frame | ( | struct ast_channel * | chan, | |
| struct ast_frame * | fin, | |||
| int | head, | |||
| struct ast_frame * | after | |||
| ) | [static] |
Definition at line 1348 of file channel.c.
References ast_channel::alertpipe, ast_channel_lock, ast_channel_unlock, AST_CONTROL_HANGUP, AST_FLAG_BLOCKING, AST_FRAME_CONTROL, AST_FRAME_NULL, AST_FRAME_VIDEO, AST_FRAME_VOICE, ast_frdup(), ast_frfree, AST_LIST_APPEND_LIST, AST_LIST_FIRST, AST_LIST_HEAD_INIT_NOLOCK, AST_LIST_HEAD_NOLOCK, AST_LIST_INSERT_LIST_AFTER, AST_LIST_INSERT_TAIL, AST_LIST_LAST, AST_LIST_NEXT, AST_LIST_REMOVE_CURRENT, AST_LIST_TRAVERSE, AST_LIST_TRAVERSE_SAFE_BEGIN, AST_LIST_TRAVERSE_SAFE_END, ast_log(), ast_test_flag, ast_timer_enable_continuous(), ast_channel::blocker, errno, f, frames, ast_frame::frametype, ast_frame_subclass::integer, LOG_WARNING, ast_channel::name, ast_channel::readq, ast_frame::subclass, ast_channel::timer, and ast_channel::timingfd.
Referenced by __ast_read(), ast_queue_frame(), and ast_queue_frame_head().
01349 { 01350 struct ast_frame *f; 01351 struct ast_frame *cur; 01352 int blah = 1; 01353 unsigned int new_frames = 0; 01354 unsigned int new_voice_frames = 0; 01355 unsigned int queued_frames = 0; 01356 unsigned int queued_voice_frames = 0; 01357 AST_LIST_HEAD_NOLOCK(, ast_frame) frames; 01358 01359 ast_channel_lock(chan); 01360 01361 /* See if the last frame on the queue is a hangup, if so don't queue anything */ 01362 if ((cur = AST_LIST_LAST(&chan->readq)) && 01363 (cur->frametype == AST_FRAME_CONTROL) && 01364 (cur->subclass.integer == AST_CONTROL_HANGUP)) { 01365 ast_channel_unlock(chan); 01366 return 0; 01367 } 01368 01369 /* Build copies of all the frames and count them */ 01370 AST_LIST_HEAD_INIT_NOLOCK(&frames); 01371 for (cur = fin; cur; cur = AST_LIST_NEXT(cur, frame_list)) { 01372 if (!(f = ast_frdup(cur))) { 01373 if (AST_LIST_FIRST(&frames)) { 01374 ast_frfree(AST_LIST_FIRST(&frames)); 01375 } 01376 ast_channel_unlock(chan); 01377 return -1; 01378 } 01379 01380 AST_LIST_INSERT_TAIL(&frames, f, frame_list); 01381 new_frames++; 01382 if (f->frametype == AST_FRAME_VOICE) { 01383 new_voice_frames++; 01384 } 01385 } 01386 01387 /* Count how many frames exist on the queue */ 01388 AST_LIST_TRAVERSE(&chan->readq, cur, frame_list) { 01389 queued_frames++; 01390 if (cur->frametype == AST_FRAME_VOICE) { 01391 queued_voice_frames++; 01392 } 01393 } 01394 01395 if ((queued_frames + new_frames > 128 || queued_voice_frames + new_voice_frames > 96)) { 01396 int count = 0; 01397 ast_log(LOG_WARNING, "Exceptionally long %squeue length queuing to %s\n", queued_frames + new_frames > 128 ? "" : "voice ", chan->name); 01398 AST_LIST_TRAVERSE_SAFE_BEGIN(&chan->readq, cur, frame_list) { 01399 /* Save the most recent frame */ 01400 if (!AST_LIST_NEXT(cur, frame_list)) { 01401 break; 01402 } else if (cur->frametype == AST_FRAME_VOICE || cur->frametype == AST_FRAME_VIDEO || cur->frametype == AST_FRAME_NULL) { 01403 if (++count > 64) { 01404 break; 01405 } 01406 AST_LIST_REMOVE_CURRENT(frame_list); 01407 ast_frfree(cur); 01408 } 01409 } 01410 AST_LIST_TRAVERSE_SAFE_END; 01411 } 01412 01413 if (after) { 01414 AST_LIST_INSERT_LIST_AFTER(&chan->readq, &frames, after, frame_list); 01415 } else { 01416 if (head) { 01417 AST_LIST_APPEND_LIST(&frames, &chan->readq, frame_list); 01418 AST_LIST_HEAD_INIT_NOLOCK(&chan->readq); 01419 } 01420 AST_LIST_APPEND_LIST(&chan->readq, &frames, frame_list); 01421 } 01422 01423 if (chan->alertpipe[1] > -1) { 01424 if (write(chan->alertpipe[1], &blah, new_frames * sizeof(blah)) != (new_frames * sizeof(blah))) { 01425 ast_log(LOG_WARNING, "Unable to write to alert pipe on %s (qlen = %d): %s!\n", 01426 chan->name, queued_frames, strerror(errno)); 01427 } 01428 } else if (chan->timingfd > -1) { 01429 ast_timer_enable_continuous(chan->timer); 01430 } else if (ast_test_flag(chan, AST_FLAG_BLOCKING)) { 01431 pthread_kill(chan->blocker, SIGURG); 01432 } 01433 01434 ast_channel_unlock(chan); 01435 01436 return 0; 01437 }
| static struct ast_frame* __ast_read | ( | struct ast_channel * | chan, | |
| int | dropaudio | |||
| ) | [static, read] |
Definition at line 3588 of file channel.c.
References __ast_queue_frame(), ast_channel::_softhangup, ast_channel::_state, ast_control_read_action_payload::action, ast_channel::alertpipe, ast_audiohook_detach_list(), AST_AUDIOHOOK_DIRECTION_READ, ast_audiohook_write_list(), ast_audiohook_write_list_empty(), ast_bridged_channel(), AST_CEL_ANSWER, ast_cel_report_event(), ast_channel_connected_line_macro(), ast_channel_lock, ast_channel_unlock, ast_check_hangup(), ast_clear_flag, ast_connected_line_parse_data(), AST_CONTROL_ANSWER, AST_CONTROL_CONNECTED_LINE, AST_CONTROL_HANGUP, AST_CONTROL_READ_ACTION, ast_deactivate_generator(), ast_debug, AST_DEFAULT_EMULATE_DTMF_DURATION, ast_do_masquerade(), AST_FLAG_DEFER_DTMF, AST_FLAG_EMULATE_DTMF, AST_FLAG_END_DTMF_ONLY, AST_FLAG_EXCEPTION, AST_FLAG_IN_DTMF, AST_FLAG_OUTGOING, AST_FLAG_ZOMBIE, ast_format_rate(), AST_FRAME_CONTROL, AST_FRAME_DTMF_BEGIN, AST_FRAME_DTMF_END, ast_frame_dump(), AST_FRAME_NULL, AST_FRAME_READ_ACTION_CONNECTED_LINE_MACRO, AST_FRAME_VOICE, ast_framehook_list_read_event(), ast_frfree, AST_GENERATOR_FD, ast_getformatname(), ast_getformatname_multiple(), ast_indicate_data(), AST_LIST_EMPTY, AST_LIST_FIRST, AST_LIST_LAST, AST_LIST_NEXT, AST_LIST_REMOVE_CURRENT, AST_LIST_TRAVERSE_SAFE_BEGIN, AST_LIST_TRAVERSE_SAFE_END, ast_log(), AST_MIN_DTMF_DURATION, AST_MIN_DTMF_GAP, AST_MONITOR_RUNNING, ast_null_frame, ast_party_connected_line_copy(), ast_party_connected_line_free(), ast_party_connected_line_init(), ast_queue_control(), ast_queue_frame(), ast_queue_frame_head(), ast_read_generator_actions(), ast_seekstream(), ast_set_flag, ast_setstate(), AST_SOFTHANGUP_DEV, AST_STATE_UP, ast_test_flag, ast_timer_ack(), ast_timer_disable_continuous(), ast_timer_get_event(), ast_timer_set_rate(), AST_TIMING_EVENT_CONTINUOUS, AST_TIMING_EVENT_EXPIRED, AST_TIMING_FD, ast_translate(), ast_tvdiff_ms(), ast_tvnow(), ast_tvzero(), ast_writestream(), ast_channel::audiohooks, ast_channel::blocker, calc_monitor_jump(), cause, ast_frame_subclass::codec, ast_channel::connected, ast_frame::data, DEBUGCHAN_FLAG, ast_generator::digit, ast_channel::dtmf_tv, ast_channel::dtmff, ast_channel::emulate_dtmf_digit, ast_channel::emulate_dtmf_duration, errno, ast_channel_tech::exception, ast_channel::fdno, ast_channel::fds, ast_channel::fin, chanlist::flags, ast_filestream::fmt, ast_format::format, FRAMECOUNT_INC, ast_channel::framehooks, ast_frame::frametype, ast_generator::generate, ast_channel::generator, ast_channel::generatordata, ast_channel::hangupcause, ast_channel::insmpl, ast_frame_subclass::integer, ast_frame::len, LOG_DTMF, LOG_ERROR, LOG_NOTICE, LOG_WARNING, ast_channel::masq, ast_channel::monitor, ast_channel::music_state, ast_channel::name, ast_channel::nativeformats, ast_channel::outsmpl, ast_control_read_action_payload::payload, ast_control_read_action_payload::payload_size, ast_frame::ptr, queue_dtmf_readq(), ast_channel_tech::read, ast_channel_monitor::read_stream, ast_channel::readq, ast_channel::readtrans, ast_frame::samples, SEEK_FORCECUR, send_dtmf_event(), should_skip_dtmf(), ast_channel_monitor::state, ast_frame::subclass, ast_channel::tech, ast_channel::timer, ast_channel::timingdata, ast_channel::timingfd, ast_channel::timingfunc, and ast_frame::uint32.
Referenced by ast_read(), and ast_read_noaudio().
03589 { 03590 struct ast_frame *f = NULL; /* the return value */ 03591 int blah; 03592 int prestate; 03593 int cause = 0; 03594 03595 /* this function is very long so make sure there is only one return 03596 * point at the end (there are only two exceptions to this). 03597 */ 03598 03599 if (chan->masq) { 03600 if (ast_do_masquerade(chan)) 03601 ast_log(LOG_WARNING, "Failed to perform masquerade\n"); 03602 else 03603 f = &ast_null_frame; 03604 return f; 03605 } 03606 03607 /* if here, no masq has happened, lock the channel and proceed */ 03608 ast_channel_lock(chan); 03609 03610 /* Stop if we're a zombie or need a soft hangup */ 03611 if (ast_test_flag(chan, AST_FLAG_ZOMBIE) || ast_check_hangup(chan)) { 03612 if (chan->generator) 03613 ast_deactivate_generator(chan); 03614 03615 /* It is possible for chan->_softhangup to be set, yet there still be control 03616 * frames that still need to be read. Instead of just going to 'done' in the 03617 * case of ast_check_hangup(), we instead need to send the HANGUP frame so that 03618 * it can mark the end of the read queue. If there are frames to be read, 03619 * ast_queue_control will be called repeatedly, but will only queue one hangup 03620 * frame. */ 03621 if (ast_check_hangup(chan)) { 03622 ast_queue_control(chan, AST_CONTROL_HANGUP); 03623 } else { 03624 goto done; 03625 } 03626 } 03627 03628 #ifdef AST_DEVMODE 03629 /* 03630 * The ast_waitfor() code records which of the channel's file descriptors reported that 03631 * data is available. In theory, ast_read() should only be called after ast_waitfor() 03632 * reports that a channel has data available for reading. However, there still may be 03633 * some edge cases throughout the code where ast_read() is called improperly. This can 03634 * potentially cause problems, so if this is a developer build, make a lot of noise if 03635 * this happens so that it can be addressed. 03636 */ 03637 if (chan->fdno == -1) { 03638 ast_log(LOG_ERROR, 03639 "ast_read() on chan '%s' called with no recorded file descriptor.\n", 03640 chan->name); 03641 } 03642 #endif 03643 03644 prestate = chan->_state; 03645 03646 /* Read and ignore anything on the alertpipe, but read only 03647 one sizeof(blah) per frame that we send from it */ 03648 if (chan->alertpipe[0] > -1) { 03649 int flags = fcntl(chan->alertpipe[0], F_GETFL); 03650 /* For some odd reason, the alertpipe occasionally loses nonblocking status, 03651 * which immediately causes a deadlock scenario. Detect and prevent this. */ 03652 if ((flags & O_NONBLOCK) == 0) { 03653 ast_log(LOG_ERROR, "Alertpipe on channel %s lost O_NONBLOCK?!!\n", chan->name); 03654 if (fcntl(chan->alertpipe[0], F_SETFL, flags | O_NONBLOCK) < 0) { 03655 ast_log(LOG_WARNING, "Unable to set alertpipe nonblocking! (%d: %s)\n", errno, strerror(errno)); 03656 f = &ast_null_frame; 03657 goto done; 03658 } 03659 } 03660 if (read(chan->alertpipe[0], &blah, sizeof(blah)) < 0) { 03661 if (errno != EINTR && errno != EAGAIN) 03662 ast_log(LOG_WARNING, "read() failed: %s\n", strerror(errno)); 03663 } 03664 } 03665 03666 if (chan->timingfd > -1 && chan->fdno == AST_TIMING_FD) { 03667 enum ast_timer_event res; 03668 03669 ast_clear_flag(chan, AST_FLAG_EXCEPTION); 03670 03671 res = ast_timer_get_event(chan->timer); 03672 03673 switch (res) { 03674 case AST_TIMING_EVENT_EXPIRED: 03675 ast_timer_ack(chan->timer, 1); 03676 03677 if (chan->timingfunc) { 03678 /* save a copy of func/data before unlocking the channel */ 03679 int (*func)(const void *) = chan->timingfunc; 03680 void *data = chan->timingdata; 03681 chan->fdno = -1; 03682 ast_channel_unlock(chan); 03683 func(data); 03684 } else { 03685 ast_timer_set_rate(chan->timer, 0); 03686 chan->fdno = -1; 03687 ast_channel_unlock(chan); 03688 } 03689 03690 /* cannot 'goto done' because the channel is already unlocked */ 03691 return &ast_null_frame; 03692 03693 case AST_TIMING_EVENT_CONTINUOUS: 03694 if (AST_LIST_EMPTY(&chan->readq) || 03695 !AST_LIST_NEXT(AST_LIST_FIRST(&chan->readq), frame_list)) { 03696 ast_timer_disable_continuous(chan->timer); 03697 } 03698 break; 03699 } 03700 03701 } else if (chan->fds[AST_GENERATOR_FD] > -1 && chan->fdno == AST_GENERATOR_FD) { 03702 /* if the AST_GENERATOR_FD is set, call the generator with args 03703 * set to -1 so it can do whatever it needs to. 03704 */ 03705 void *tmp = chan->generatordata; 03706 chan->generatordata = NULL; /* reset to let ast_write get through */ 03707 chan->generator->generate(chan, tmp, -1, -1); 03708 chan->generatordata = tmp; 03709 f = &ast_null_frame; 03710 chan->fdno = -1; 03711 goto done; 03712 } 03713 03714 /* Check for pending read queue */ 03715 if (!AST_LIST_EMPTY(&chan->readq)) { 03716 int skip_dtmf = should_skip_dtmf(chan); 03717 03718 AST_LIST_TRAVERSE_SAFE_BEGIN(&chan->readq, f, frame_list) { 03719 /* We have to be picky about which frame we pull off of the readq because 03720 * there are cases where we want to leave DTMF frames on the queue until 03721 * some later time. */ 03722 03723 if ( (f->frametype == AST_FRAME_DTMF_BEGIN || f->frametype == AST_FRAME_DTMF_END) && skip_dtmf) { 03724 continue; 03725 } 03726 03727 AST_LIST_REMOVE_CURRENT(frame_list); 03728 break; 03729 } 03730 AST_LIST_TRAVERSE_SAFE_END; 03731 03732 if (!f) { 03733 /* There were no acceptable frames on the readq. */ 03734 f = &ast_null_frame; 03735 if (chan->alertpipe[0] > -1) { 03736 int poke = 0; 03737 /* Restore the state of the alertpipe since we aren't ready for any 03738 * of the frames in the readq. */ 03739 if (write(chan->alertpipe[1], &poke, sizeof(poke)) != sizeof(poke)) { 03740 ast_log(LOG_ERROR, "Failed to write to alertpipe: %s\n", strerror(errno)); 03741 } 03742 } 03743 } 03744 03745 /* Interpret hangup and return NULL */ 03746 /* XXX why not the same for frames from the channel ? */ 03747 if (f->frametype == AST_FRAME_CONTROL && f->subclass.integer == AST_CONTROL_HANGUP) { 03748 cause = f->data.uint32; 03749 ast_frfree(f); 03750 f = NULL; 03751 } 03752 } else { 03753 chan->blocker = pthread_self(); 03754 if (ast_test_flag(chan, AST_FLAG_EXCEPTION)) { 03755 if (chan->tech->exception) 03756 f = chan->tech->exception(chan); 03757 else { 03758 ast_log(LOG_WARNING, "Exception flag set on '%s', but no exception handler\n", chan->name); 03759 f = &ast_null_frame; 03760 } 03761 /* Clear the exception flag */ 03762 ast_clear_flag(chan, AST_FLAG_EXCEPTION); 03763 } else if (chan->tech->read) 03764 f = chan->tech->read(chan); 03765 else 03766 ast_log(LOG_WARNING, "No read routine on channel %s\n", chan->name); 03767 } 03768 03769 /* 03770 * Reset the recorded file descriptor that triggered this read so that we can 03771 * easily detect when ast_read() is called without properly using ast_waitfor(). 03772 */ 03773 chan->fdno = -1; 03774 03775 /* Perform the framehook read event here. After the frame enters the framehook list 03776 * there is no telling what will happen, <insert mad scientist laugh here>!!! */ 03777 f = ast_framehook_list_read_event(chan->framehooks, f); 03778 03779 if (f) { 03780 struct ast_frame *readq_tail = AST_LIST_LAST(&chan->readq); 03781 struct ast_control_read_action_payload *read_action_payload; 03782 struct ast_party_connected_line connected; 03783 03784 /* if the channel driver returned more than one frame, stuff the excess 03785 into the readq for the next ast_read call 03786 */ 03787 if (AST_LIST_NEXT(f, frame_list)) { 03788 ast_queue_frame(chan, AST_LIST_NEXT(f, frame_list)); 03789 ast_frfree(AST_LIST_NEXT(f, frame_list)); 03790 AST_LIST_NEXT(f, frame_list) = NULL; 03791 } 03792 03793 switch (f->frametype) { 03794 case AST_FRAME_CONTROL: 03795 if (f->subclass.integer == AST_CONTROL_ANSWER) { 03796 if (!ast_test_flag(chan, AST_FLAG_OUTGOING)) { 03797 ast_debug(1, "Ignoring answer on an inbound call!\n"); 03798 ast_frfree(f); 03799 f = &ast_null_frame; 03800 } else if (prestate == AST_STATE_UP && ast_bridged_channel(chan)) { 03801 ast_debug(1, "Dropping duplicate answer!\n"); 03802 ast_frfree(f); 03803 f = &ast_null_frame; 03804 } else { 03805 /* Answer the CDR */ 03806 ast_setstate(chan, AST_STATE_UP); 03807 /* removed a call to ast_cdr_answer(chan->cdr) from here. */ 03808 ast_cel_report_event(chan, AST_CEL_ANSWER, NULL, NULL, NULL); 03809 } 03810 } else if (f->subclass.integer == AST_CONTROL_READ_ACTION) { 03811 read_action_payload = f->data.ptr; 03812 switch (read_action_payload->action) { 03813 case AST_FRAME_READ_ACTION_CONNECTED_LINE_MACRO: 03814 ast_party_connected_line_init(&connected); 03815 ast_party_connected_line_copy(&connected, &chan->connected); 03816 if (ast_connected_line_parse_data(read_action_payload->payload, 03817 read_action_payload->payload_size, &connected)) { 03818 ast_party_connected_line_free(&connected); 03819 break; 03820 } 03821 if (ast_channel_connected_line_macro(NULL, chan, &connected, 1, 0)) { 03822 ast_indicate_data(chan, AST_CONTROL_CONNECTED_LINE, 03823 read_action_payload->payload, 03824 read_action_payload->payload_size); 03825 } 03826 ast_party_connected_line_free(&connected); 03827 break; 03828 } 03829 ast_frfree(f); 03830 f = &ast_null_frame; 03831 } 03832 break; 03833 case AST_FRAME_DTMF_END: 03834 send_dtmf_event(chan, "Received", f->subclass.integer, "No", "Yes"); 03835 ast_log(LOG_DTMF, "DTMF end '%c' received on %s, duration %ld ms\n", f->subclass.integer, chan->name, f->len); 03836 /* Queue it up if DTMF is deferred, or if DTMF emulation is forced. */ 03837 if (ast_test_flag(chan, AST_FLAG_DEFER_DTMF) || ast_test_flag(chan, AST_FLAG_EMULATE_DTMF)) { 03838 queue_dtmf_readq(chan, f); 03839 ast_frfree(f); 03840 f = &ast_null_frame; 03841 } else if (!ast_test_flag(chan, AST_FLAG_IN_DTMF | AST_FLAG_END_DTMF_ONLY)) { 03842 if (!ast_tvzero(chan->dtmf_tv) && 03843 ast_tvdiff_ms(ast_tvnow(), chan->dtmf_tv) < AST_MIN_DTMF_GAP) { 03844 /* If it hasn't been long enough, defer this digit */ 03845 queue_dtmf_readq(chan, f); 03846 ast_frfree(f); 03847 f = &ast_null_frame; 03848 } else { 03849 /* There was no begin, turn this into a begin and send the end later */ 03850 f->frametype = AST_FRAME_DTMF_BEGIN; 03851 ast_set_flag(chan, AST_FLAG_EMULATE_DTMF); 03852 chan->emulate_dtmf_digit = f->subclass.integer; 03853 chan->dtmf_tv = ast_tvnow(); 03854 if (f->len) { 03855 if (f->len > AST_MIN_DTMF_DURATION) 03856 chan->emulate_dtmf_duration = f->len; 03857 else 03858 chan->emulate_dtmf_duration = AST_MIN_DTMF_DURATION; 03859 } else 03860 chan->emulate_dtmf_duration = AST_DEFAULT_EMULATE_DTMF_DURATION; 03861 ast_log(LOG_DTMF, "DTMF begin emulation of '%c' with duration %u queued on %s\n", f->subclass.integer, chan->emulate_dtmf_duration, chan->name); 03862 } 03863 if (chan->audiohooks) { 03864 struct ast_frame *old_frame = f; 03865 /*! 03866 * \todo XXX It is possible to write a digit to the audiohook twice 03867 * if the digit was originally read while the channel was in autoservice. */ 03868 f = ast_audiohook_write_list(chan, chan->audiohooks, AST_AUDIOHOOK_DIRECTION_READ, f); 03869 if (old_frame != f) 03870 ast_frfree(old_frame); 03871 } 03872 } else { 03873 struct timeval now = ast_tvnow(); 03874 if (ast_test_flag(chan, AST_FLAG_IN_DTMF)) { 03875 ast_log(LOG_DTMF, "DTMF end accepted with begin '%c' on %s\n", f->subclass.integer, chan->name); 03876 ast_clear_flag(chan, AST_FLAG_IN_DTMF); 03877 if (!f->len) 03878 f->len = ast_tvdiff_ms(now, chan->dtmf_tv); 03879 03880 /* detect tones that were received on 03881 * the wire with durations shorter than 03882 * AST_MIN_DTMF_DURATION and set f->len 03883 * to the actual duration of the DTMF 03884 * frames on the wire. This will cause 03885 * dtmf emulation to be triggered later 03886 * on. 03887 */ 03888 if (ast_tvdiff_ms(now, chan->dtmf_tv) < AST_MIN_DTMF_DURATION) { 03889 f->len = ast_tvdiff_ms(now, chan->dtmf_tv); 03890 ast_log(LOG_DTMF, "DTMF end '%c' detected to have actual duration %ld on the wire, emulation will be triggered on %s\n", f->subclass.integer, f->len, chan->name); 03891 } 03892 } else if (!f->len) { 03893 ast_log(LOG_DTMF, "DTMF end accepted without begin '%c' on %s\n", f->subclass.integer, chan->name); 03894 f->len = AST_MIN_DTMF_DURATION; 03895 } 03896 if (f->len < AST_MIN_DTMF_DURATION && !ast_test_flag(chan, AST_FLAG_END_DTMF_ONLY)) { 03897 ast_log(LOG_DTMF, "DTMF end '%c' has duration %ld but want minimum %d, emulating on %s\n", f->subclass.integer, f->len, AST_MIN_DTMF_DURATION, chan->name); 03898 ast_set_flag(chan, AST_FLAG_EMULATE_DTMF); 03899 chan->emulate_dtmf_digit = f->subclass.integer; 03900 chan->emulate_dtmf_duration = AST_MIN_DTMF_DURATION - f->len; 03901 ast_frfree(f); 03902 f = &ast_null_frame; 03903 } else { 03904 ast_log(LOG_DTMF, "DTMF end passthrough '%c' on %s\n", f->subclass.integer, chan->name); 03905 if (f->len < AST_MIN_DTMF_DURATION) { 03906 f->len = AST_MIN_DTMF_DURATION; 03907 } 03908 chan->dtmf_tv = now; 03909 } 03910 if (chan->audiohooks) { 03911 struct ast_frame *old_frame = f; 03912 f = ast_audiohook_write_list(chan, chan->audiohooks, AST_AUDIOHOOK_DIRECTION_READ, f); 03913 if (old_frame != f) 03914 ast_frfree(old_frame); 03915 } 03916 } 03917 break; 03918 case AST_FRAME_DTMF_BEGIN: 03919 send_dtmf_event(chan, "Received", f->subclass.integer, "Yes", "No"); 03920 ast_log(LOG_DTMF, "DTMF begin '%c' received on %s\n", f->subclass.integer, chan->name); 03921 if ( ast_test_flag(chan, AST_FLAG_DEFER_DTMF | AST_FLAG_END_DTMF_ONLY | AST_FLAG_EMULATE_DTMF) || 03922 (!ast_tvzero(chan->dtmf_tv) && 03923 ast_tvdiff_ms(ast_tvnow(), chan->dtmf_tv) < AST_MIN_DTMF_GAP) ) { 03924 ast_log(LOG_DTMF, "DTMF begin ignored '%c' on %s\n", f->subclass.integer, chan->name); 03925 ast_frfree(f); 03926 f = &ast_null_frame; 03927 } else { 03928 ast_set_flag(chan, AST_FLAG_IN_DTMF); 03929 chan->dtmf_tv = ast_tvnow(); 03930 ast_log(LOG_DTMF, "DTMF begin passthrough '%c' on %s\n", f->subclass.integer, chan->name); 03931 } 03932 break; 03933 case AST_FRAME_NULL: 03934 /* The EMULATE_DTMF flag must be cleared here as opposed to when the duration 03935 * is reached , because we want to make sure we pass at least one 03936 * voice frame through before starting the next digit, to ensure a gap 03937 * between DTMF digits. */ 03938 if (ast_test_flag(chan, AST_FLAG_EMULATE_DTMF)) { 03939 struct timeval now = ast_tvnow(); 03940 if (!chan->emulate_dtmf_duration) { 03941 ast_clear_flag(chan, AST_FLAG_EMULATE_DTMF); 03942 chan->emulate_dtmf_digit = 0; 03943 } else if (ast_tvdiff_ms(now, chan->dtmf_tv) >= chan->emulate_dtmf_duration) { 03944 chan->emulate_dtmf_duration = 0; 03945 ast_frfree(f); 03946 f = &chan->dtmff; 03947 f->frametype = AST_FRAME_DTMF_END; 03948 f->subclass.integer = chan->emulate_dtmf_digit; 03949 f->len = ast_tvdiff_ms(now, chan->dtmf_tv); 03950 chan->dtmf_tv = now; 03951 ast_clear_flag(chan, AST_FLAG_EMULATE_DTMF); 03952 chan->emulate_dtmf_digit = 0; 03953 ast_log(LOG_DTMF, "DTMF end emulation of '%c' queued on %s\n", f->subclass.integer, chan->name); 03954 if (chan->audiohooks) { 03955 struct ast_frame *old_frame = f; 03956 f = ast_audiohook_write_list(chan, chan->audiohooks, AST_AUDIOHOOK_DIRECTION_READ, f); 03957 if (old_frame != f) { 03958 ast_frfree(old_frame); 03959 } 03960 } 03961 } 03962 } 03963 break; 03964 case AST_FRAME_VOICE: 03965 /* The EMULATE_DTMF flag must be cleared here as opposed to when the duration 03966 * is reached , because we want to make sure we pass at least one 03967 * voice frame through before starting the next digit, to ensure a gap 03968 * between DTMF digits. */ 03969 if (ast_test_flag(chan, AST_FLAG_EMULATE_DTMF) && !chan->emulate_dtmf_duration) { 03970 ast_clear_flag(chan, AST_FLAG_EMULATE_DTMF); 03971 chan->emulate_dtmf_digit = 0; 03972 } 03973 03974 if (dropaudio || ast_test_flag(chan, AST_FLAG_IN_DTMF)) { 03975 if (dropaudio) 03976 ast_read_generator_actions(chan, f); 03977 ast_frfree(f); 03978 f = &ast_null_frame; 03979 } 03980 03981 if (ast_test_flag(chan, AST_FLAG_EMULATE_DTMF) && !ast_test_flag(chan, AST_FLAG_IN_DTMF)) { 03982 struct timeval now = ast_tvnow(); 03983 if (ast_tvdiff_ms(now, chan->dtmf_tv) >= chan->emulate_dtmf_duration) { 03984 chan->emulate_dtmf_duration = 0; 03985 ast_frfree(f); 03986 f = &chan->dtmff; 03987 f->frametype = AST_FRAME_DTMF_END; 03988 f->subclass.integer = chan->emulate_dtmf_digit; 03989 f->len = ast_tvdiff_ms(now, chan->dtmf_tv); 03990 chan->dtmf_tv = now; 03991 if (chan->audiohooks) { 03992 struct ast_frame *old_frame = f; 03993 f = ast_audiohook_write_list(chan, chan->audiohooks, AST_AUDIOHOOK_DIRECTION_READ, f); 03994 if (old_frame != f) 03995 ast_frfree(old_frame); 03996 } 03997 ast_log(LOG_DTMF, "DTMF end emulation of '%c' queued on %s\n", f->subclass.integer, chan->name); 03998 } else { 03999 /* Drop voice frames while we're still in the middle of the digit */ 04000 ast_frfree(f); 04001 f = &ast_null_frame; 04002 } 04003 } else if ((f->frametype == AST_FRAME_VOICE) && !(f->subclass.codec & chan->nativeformats)) { 04004 /* This frame is not one of the current native formats -- drop it on the floor */ 04005 char to[200]; 04006 ast_log(LOG_NOTICE, "Dropping incompatible voice frame on %s of format %s since our native format has changed to %s\n", 04007 chan->name, ast_getformatname(f->subclass.codec), ast_getformatname_multiple(to, sizeof(to), chan->nativeformats)); 04008 ast_frfree(f); 04009 f = &ast_null_frame; 04010 } else if ((f->frametype == AST_FRAME_VOICE)) { 04011 /* Send frame to audiohooks if present */ 04012 if (chan->audiohooks) { 04013 struct ast_frame *old_frame = f; 04014 f = ast_audiohook_write_list(chan, chan->audiohooks, AST_AUDIOHOOK_DIRECTION_READ, f); 04015 if (old_frame != f) 04016 ast_frfree(old_frame); 04017 } 04018 if (chan->monitor && chan->monitor->read_stream ) { 04019 /* XXX what does this do ? */ 04020 #ifndef MONITOR_CONSTANT_DELAY 04021 int jump = chan->outsmpl - chan->insmpl - 4 * f->samples; 04022 if (jump >= 0) { 04023 jump = calc_monitor_jump((chan->outsmpl - chan->insmpl), ast_format_rate(f->subclass.codec), ast_format_rate(chan->monitor->read_stream->fmt->format)); 04024 if (ast_seekstream(chan->monitor->read_stream, jump, SEEK_FORCECUR) == -1) 04025 ast_log(LOG_WARNING, "Failed to perform seek in monitoring read stream, synchronization between the files may be broken\n"); 04026 chan->insmpl += (chan->outsmpl - chan->insmpl) + f->samples; 04027 } else 04028 chan->insmpl+= f->samples; 04029 #else 04030 int jump = calc_monitor_jump((chan->outsmpl - chan->insmpl), ast_format_rate(f->subclass.codec), ast_format_rate(chan->monitor->read_stream->fmt->format)); 04031 if (jump - MONITOR_DELAY >= 0) { 04032 if (ast_seekstream(chan->monitor->read_stream, jump - f->samples, SEEK_FORCECUR) == -1) 04033 ast_log(LOG_WARNING, "Failed to perform seek in monitoring read stream, synchronization between the files may be broken\n"); 04034 chan->insmpl += chan->outsmpl - chan->insmpl; 04035 } else 04036 chan->insmpl += f->samples; 04037 #endif 04038 if (chan->monitor->state == AST_MONITOR_RUNNING) { 04039 if (ast_writestream(chan->monitor->read_stream, f) < 0) 04040 ast_log(LOG_WARNING, "Failed to write data to channel monitor read stream\n"); 04041 } 04042 } 04043 04044 if (chan->readtrans && (f = ast_translate(chan->readtrans, f, 1)) == NULL) { 04045 f = &ast_null_frame; 04046 } 04047 04048 /* it is possible for the translation process on chan->readtrans to have 04049 produced multiple frames from the single input frame we passed it; if 04050 this happens, queue the additional frames *before* the frames we may 04051 have queued earlier. if the readq was empty, put them at the head of 04052 the queue, and if it was not, put them just after the frame that was 04053 at the end of the queue. 04054 */ 04055 if (AST_LIST_NEXT(f, frame_list)) { 04056 if (!readq_tail) { 04057 ast_queue_frame_head(chan, AST_LIST_NEXT(f, frame_list)); 04058 } else { 04059 __ast_queue_frame(chan, AST_LIST_NEXT(f, frame_list), 0, readq_tail); 04060 } 04061 ast_frfree(AST_LIST_NEXT(f, frame_list)); 04062 AST_LIST_NEXT(f, frame_list) = NULL; 04063 } 04064 04065 /* Run generator sitting on the line if timing device not available 04066 * and synchronous generation of outgoing frames is necessary */ 04067 ast_read_generator_actions(chan, f); 04068 } 04069 break; 04070 default: 04071 /* Just pass it on! */ 04072 break; 04073 } 04074 } else { 04075 /* Make sure we always return NULL in the future */ 04076 chan->_softhangup |= AST_SOFTHANGUP_DEV; 04077 if (cause) 04078 chan->hangupcause = cause; 04079 if (chan->generator) 04080 ast_deactivate_generator(chan); 04081 /* We no longer End the CDR here */ 04082 } 04083 04084 /* High bit prints debugging */ 04085 if (chan->fin & DEBUGCHAN_FLAG) 04086 ast_frame_dump(chan->name, f, "<<"); 04087 chan->fin = FRAMECOUNT_INC(chan->fin); 04088 04089 done: 04090 if (chan->music_state && chan->generator && chan->generator->digit && f && f->frametype == AST_FRAME_DTMF_END) 04091 chan->generator->digit(chan, f->subclass.integer); 04092 04093 if (chan->audiohooks && ast_audiohook_write_list_empty(chan->audiohooks)) { 04094 /* The list gets recreated if audiohooks are added again later */ 04095 ast_audiohook_detach_list(chan->audiohooks); 04096 chan->audiohooks = NULL; 04097 } 04098 ast_channel_unlock(chan); 04099 return f; 04100 }
| struct ast_channel* __ast_request_and_dial | ( | const char * | type, | |
| format_t | format, | |||
| const struct ast_channel * | requestor, | |||
| void * | data, | |||
| int | timeout, | |||
| int * | reason, | |||
| const char * | cid_num, | |||
| const char * | cid_name, | |||
| struct outgoing_helper * | oh | |||
| ) | [read] |
Request a channel of a given type, with data as optional information used by the low level module and attempt to place a call on it.
| type | type of channel to request | |
| format | requested channel format | |
| requestor | channel requesting data | |
| data | data to pass to the channel requester | |
| timeout | maximum amount of time to wait for an answer | |
| reason | why unsuccessful (if unsuccessful) | |
| cid_num | Caller-ID Number | |
| cid_name | Caller-ID Name (ascii) | |
| oh | Outgoing helper |
Definition at line 5090 of file channel.c.
References ast_channel::_state, outgoing_helper::account, ast_call(), ast_call_forward(), AST_CAUSE_NO_ANSWER, ast_cdr_alloc(), ast_cdr_answer(), ast_cdr_busy(), ast_cdr_disposition(), ast_cdr_end(), ast_cdr_failed(), AST_CDR_FLAG_ORIGINATED, ast_cdr_init(), ast_cdr_setaccount(), ast_cdr_setapp(), ast_cdr_start(), ast_cdr_update(), ast_channel_datastore_inherit(), ast_channel_inherit_variables(), ast_channel_set_connected_line(), AST_CONTROL_ANSWER, AST_CONTROL_BUSY, AST_CONTROL_CC, AST_CONTROL_CONGESTION, AST_CONTROL_CONNECTED_LINE, AST_CONTROL_HANGUP, AST_CONTROL_HOLD, AST_CONTROL_PROCEEDING, AST_CONTROL_PROGRESS, AST_CONTROL_REDIRECTING, AST_CONTROL_RINGING, AST_CONTROL_SRCCHANGE, AST_CONTROL_SRCUPDATE, AST_CONTROL_UNHOLD, AST_CONTROL_VIDUPDATE, ast_copy_string(), AST_FRAME_CONTROL, ast_frfree, ast_hangup(), ast_log(), ast_party_connected_line_set_init(), AST_PRES_ALLOWED_USER_NUMBER_NOT_SCREENED, ast_read(), ast_request(), ast_set_callerid(), ast_set_flag, ast_set_variables(), AST_STATE_UP, ast_strlen_zero(), ast_waitfor(), ast_channel::call_forward, cause, ast_channel::cdr, outgoing_helper::cid_name, outgoing_helper::cid_num, ast_channel::connected, ast_channel::context, outgoing_helper::context, ast_channel::exten, outgoing_helper::exten, ast_frame::frametype, handle_cause(), ast_channel::hangupcause, ast_party_connected_line::id, ast_frame_subclass::integer, LOG_NOTICE, ast_party_id::name, ast_party_id::number, outgoing_helper::parent_channel, ast_party_name::presentation, ast_party_number::presentation, ast_channel::priority, outgoing_helper::priority, ast_party_name::str, ast_party_number::str, ast_frame::subclass, ast_party_name::valid, ast_party_number::valid, and outgoing_helper::vars.
Referenced by ast_pbx_outgoing_app(), ast_pbx_outgoing_exten(), ast_request_and_dial(), and parkandannounce_exec().
05091 { 05092 int dummy_outstate; 05093 int cause = 0; 05094 struct ast_channel *chan; 05095 int res = 0; 05096 int last_subclass = 0; 05097 struct ast_party_connected_line connected; 05098 05099 if (outstate) 05100 *outstate = 0; 05101 else 05102 outstate = &dummy_outstate; /* make outstate always a valid pointer */ 05103 05104 chan = ast_request(type, format, requestor, data, &cause); 05105 if (!chan) { 05106 ast_log(LOG_NOTICE, "Unable to request channel %s/%s\n", type, (char *)data); 05107 handle_cause(cause, outstate); 05108 return NULL; 05109 } 05110 05111 if (oh) { 05112 if (oh->vars) 05113 ast_set_variables(chan, oh->vars); 05114 /* XXX why is this necessary, for the parent_channel perhaps ? */ 05115 if (!ast_strlen_zero(oh->cid_num) && !ast_strlen_zero(oh->cid_name)) 05116 ast_set_callerid(chan, oh->cid_num, oh->cid_name, oh->cid_num); 05117 if (oh->parent_channel) { 05118 ast_channel_inherit_variables(oh->parent_channel, chan); 05119 ast_channel_datastore_inherit(oh->parent_channel, chan); 05120 } 05121 if (oh->account) 05122 ast_cdr_setaccount(chan, oh->account); 05123 } 05124 05125 ast_set_callerid(chan, cid_num, cid_name, cid_num); 05126 ast_set_flag(chan->cdr, AST_CDR_FLAG_ORIGINATED); 05127 ast_party_connected_line_set_init(&connected, &chan->connected); 05128 if (cid_num) { 05129 connected.id.number.valid = 1; 05130 connected.id.number.str = (char *) cid_num; 05131 connected.id.number.presentation = AST_PRES_ALLOWED_USER_NUMBER_NOT_SCREENED; 05132 } 05133 if (cid_name) { 05134 connected.id.name.valid = 1; 05135 connected.id.name.str = (char *) cid_name; 05136 connected.id.name.presentation = AST_PRES_ALLOWED_USER_NUMBER_NOT_SCREENED; 05137 } 05138 ast_channel_set_connected_line(chan, &connected, NULL); 05139 05140 if (ast_call(chan, data, 0)) { /* ast_call failed... */ 05141 ast_log(LOG_NOTICE, "Unable to call channel %s/%s\n", type, (char *)data); 05142 } else { 05143 res = 1; /* mark success in case chan->_state is already AST_STATE_UP */ 05144 while (timeout && chan->_state != AST_STATE_UP) { 05145 struct ast_frame *f; 05146 res = ast_waitfor(chan, timeout); 05147 if (res == 0) { /* timeout, treat it like ringing */ 05148 *outstate = AST_CONTROL_RINGING; 05149 break; 05150 } 05151 if (res < 0) /* error or done */ 05152 break; 05153 if (timeout > -1) 05154 timeout = res; 05155 if (!ast_strlen_zero(chan->call_forward)) { 05156 if (!(chan = ast_call_forward(NULL, chan, NULL, format, oh, outstate))) { 05157 return NULL; 05158 } 05159 continue; 05160 } 05161 05162 f = ast_read(chan); 05163 if (!f) { 05164 *outstate = AST_CONTROL_HANGUP; 05165 res = 0; 05166 break; 05167 } 05168 if (f->frametype == AST_FRAME_CONTROL) { 05169 switch (f->subclass.integer) { 05170 case AST_CONTROL_RINGING: /* record but keep going */ 05171 *outstate = f->subclass.integer; 05172 break; 05173 05174 case AST_CONTROL_BUSY: 05175 ast_cdr_busy(chan->cdr); 05176 *outstate = f->subclass.integer; 05177 timeout = 0; 05178 break; 05179 05180 case AST_CONTROL_CONGESTION: 05181 ast_cdr_failed(chan->cdr); 05182 *outstate = f->subclass.integer; 05183 timeout = 0; 05184 break; 05185 05186 case AST_CONTROL_ANSWER: 05187 ast_cdr_answer(chan->cdr); 05188 *outstate = f->subclass.integer; 05189 timeout = 0; /* trick to force exit from the while() */ 05190 break; 05191 05192 /* Ignore these */ 05193 case AST_CONTROL_PROGRESS: 05194 case AST_CONTROL_PROCEEDING: 05195 case AST_CONTROL_HOLD: 05196 case AST_CONTROL_UNHOLD: 05197 case AST_CONTROL_VIDUPDATE: 05198 case AST_CONTROL_SRCUPDATE: 05199 case AST_CONTROL_SRCCHANGE: 05200 case AST_CONTROL_CONNECTED_LINE: 05201 case AST_CONTROL_REDIRECTING: 05202 case AST_CONTROL_CC: 05203 case -1: /* Ignore -- just stopping indications */ 05204 break; 05205 05206 default: 05207 ast_log(LOG_NOTICE, "Don't know what to do with control frame %d\n", f->subclass.integer); 05208 } 05209 last_subclass = f->subclass.integer; 05210 } 05211 ast_frfree(f); 05212 } 05213 } 05214 05215 /* Final fixups */ 05216 if (oh) { 05217 if (!ast_strlen_zero(oh->context)) 05218 ast_copy_string(chan->context, oh->context, sizeof(chan->context)); 05219 if (!ast_strlen_zero(oh->exten)) 05220 ast_copy_string(chan->exten, oh->exten, sizeof(chan->exten)); 05221 if (oh->priority) 05222 chan->priority = oh->priority; 05223 } 05224 if (chan->_state == AST_STATE_UP) 05225 *outstate = AST_CONTROL_ANSWER; 05226 05227 if (res <= 0) { 05228 if ( AST_CONTROL_RINGING == last_subclass ) 05229 chan->hangupcause = AST_CAUSE_NO_ANSWER; 05230 if (!chan->cdr && (chan->cdr = ast_cdr_alloc())) 05231 ast_cdr_init(chan->cdr, chan); 05232 if (chan->cdr) { 05233 char tmp[256]; 05234 snprintf(tmp, sizeof(tmp), "%s/%s", type, (char *)data); 05235 ast_cdr_setapp(chan->cdr,"Dial",tmp); 05236 ast_cdr_update(chan); 05237 ast_cdr_start(chan->cdr); 05238 ast_cdr_end(chan->cdr); 05239 /* If the cause wasn't handled properly */ 05240 if (ast_cdr_disposition(chan->cdr,chan->hangupcause)) 05241 ast_cdr_failed(chan->cdr); 05242 } 05243 ast_hangup(chan); 05244 chan = NULL; 05245 } 05246 return chan; 05247 }
| static void __init_state2str_threadbuf | ( | void | ) | [static] |
| static void adjust_frame_for_plc | ( | struct ast_channel * | chan, | |
| struct ast_frame * | frame, | |||
| struct ast_datastore * | datastore | |||
| ) | [static] |
Definition at line 4526 of file channel.c.
References ast_calloc, ast_channel_datastore_remove(), ast_datastore_free(), ast_free, AST_FRIENDLY_OFFSET, ast_frame::data, ast_datastore::data, ast_frame::datalen, plc_ds::num_samples, ast_frame::offset, plc_fillin(), plc_rx(), plc_ds::plc_state, ast_frame::ptr, ast_frame::samples, and plc_ds::samples_buf.
Referenced by apply_plc().
04527 { 04528 int num_new_samples = frame->samples; 04529 struct plc_ds *plc = datastore->data; 04530 04531 /* As a general note, let me explain the somewhat odd calculations used when taking 04532 * the frame offset into account here. According to documentation in frame.h, the frame's 04533 * offset field indicates the number of bytes that the audio is offset. The plc->samples_buf 04534 * is not an array of bytes, but rather an array of 16-bit integers since it holds SLIN 04535 * samples. So I had two choices to make here with the offset. 04536 * 04537 * 1. Make the offset AST_FRIENDLY_OFFSET bytes. The main downside for this is that 04538 * I can't just add AST_FRIENDLY_OFFSET to the plc->samples_buf and have the pointer 04539 * arithmetic come out right. I would have to do some odd casting or division for this to 04540 * work as I wanted. 04541 * 2. Make the offset AST_FRIENDLY_OFFSET * 2 bytes. This allows the pointer arithmetic 04542 * to work out better with the plc->samples_buf. The downside here is that the buffer's 04543 * allocation contains an extra 64 bytes of unused space. 04544 * 04545 * I decided to go with option 2. This is why in the calloc statement and the statement that 04546 * sets the frame's offset, AST_FRIENDLY_OFFSET is multiplied by 2. 04547 */ 04548 04549 /* If this audio frame has no samples to fill in, ignore it */ 04550 if (!num_new_samples) { 04551 return; 04552 } 04553 04554 /* First, we need to be sure that our buffer is large enough to accomodate 04555 * the samples we need to fill in. This will likely only occur on the first 04556 * frame we write. 04557 */ 04558 if (plc->num_samples < num_new_samples) { 04559 ast_free(plc->samples_buf); 04560 plc->samples_buf = ast_calloc(1, (num_new_samples * sizeof(*plc->samples_buf)) + (AST_FRIENDLY_OFFSET * 2)); 04561 if (!plc->samples_buf) { 04562 ast_channel_datastore_remove(chan, datastore); 04563 ast_datastore_free(datastore); 04564 return; 04565 } 04566 plc->num_samples = num_new_samples; 04567 } 04568 04569 if (frame->datalen == 0) { 04570 plc_fillin(&plc->plc_state, plc->samples_buf + AST_FRIENDLY_OFFSET, frame->samples); 04571 frame->data.ptr = plc->samples_buf + AST_FRIENDLY_OFFSET; 04572 frame->datalen = num_new_samples * 2; 04573 frame->offset = AST_FRIENDLY_OFFSET * 2; 04574 } else { 04575 plc_rx(&plc->plc_state, frame->data.ptr, frame->samples); 04576 } 04577 }
| static void apply_plc | ( | struct ast_channel * | chan, | |
| struct ast_frame * | frame | |||
| ) | [static] |
Definition at line 4579 of file channel.c.
References adjust_frame_for_plc(), ast_calloc, ast_channel_datastore_add(), ast_channel_datastore_find(), ast_datastore_alloc, ast_datastore_free(), and ast_datastore::data.
Referenced by ast_write().
04580 { 04581 struct ast_datastore *datastore; 04582 struct plc_ds *plc; 04583 04584 datastore = ast_channel_datastore_find(chan, &plc_ds_info, NULL); 04585 if (datastore) { 04586 plc = datastore->data; 04587 adjust_frame_for_plc(chan, frame, datastore); 04588 return; 04589 } 04590 04591 datastore = ast_datastore_alloc(&plc_ds_info, NULL); 04592 if (!datastore) { 04593 return; 04594 } 04595 plc = ast_calloc(1, sizeof(*plc)); 04596 if (!plc) { 04597 ast_datastore_free(datastore); 04598 return; 04599 } 04600 datastore->data = plc; 04601 ast_channel_datastore_add(chan, datastore); 04602 adjust_frame_for_plc(chan, frame, datastore); 04603 }
| int ast_activate_generator | ( | struct ast_channel * | chan, | |
| struct ast_generator * | gen, | |||
| void * | params | |||
| ) |
Activate a given generator
Definition at line 2948 of file channel.c.
References ast_generator::alloc, ast_channel_lock, ast_channel_unlock, ast_prod(), ast_settimeout(), ast_channel::generator, generator_force(), ast_channel::generatordata, and ast_generator::release.
Referenced by app_exec(), ast_channel_start_silence_generator(), ast_linear_stream(), ast_playtones_start(), ast_tonepair_start(), channel_spy(), eivr_comm(), local_ast_moh_start(), old_milliwatt_exec(), and transmit_audio().
02949 { 02950 int res = 0; 02951 02952 ast_channel_lock(chan); 02953 if (chan->generatordata) { 02954 if (chan->generator && chan->generator->release) 02955 chan->generator->release(chan, chan->generatordata); 02956 chan->generatordata = NULL; 02957 } 02958 if (gen->alloc && !(chan->generatordata = gen->alloc(chan, params))) { 02959 res = -1; 02960 } 02961 if (!res) { 02962 ast_settimeout(chan, 50, generator_force, chan); 02963 chan->generator = gen; 02964 } 02965 ast_channel_unlock(chan); 02966 02967 ast_prod(chan); 02968 02969 return res; 02970 }
| int ast_active_channels | ( | void | ) |
returns number of active/allocated channels
Definition at line 783 of file channel.c.
References ao2_container_count(), and channels.
Referenced by action_corestatus(), ast_var_channels(), ast_var_channels_table(), dahdi_restart(), handle_chanlist(), handle_show_settings(), and quit_handler().
00784 { 00785 return channels ? ao2_container_count(channels) : 0; 00786 }
| int ast_answer | ( | struct ast_channel * | chan | ) |
Answer a channel.
| chan | channel to answer |
This function will wait up to 500 milliseconds for media to arrive on the channel before returning to the caller, so that the caller can properly assume the channel is 'ready' for media flow.
| 0 | on success | |
| non-zero | on failure |
Definition at line 2898 of file channel.c.
References __ast_answer().
Referenced by action_bridge(), agi_exec_full(), alarmreceiver_exec(), answer_trunk_chan(), app_exec(), ast_control_streamfile(), ast_pickup_call(), auth_exec(), background_detect_exec(), bridge_exec(), common_exec(), conf_exec(), count_exec(), dahdiras_exec(), dial_exec_full(), dictate_exec(), directory_exec(), disa_exec(), eivr_comm(), handle_answer(), ices_exec(), login_exec(), minivm_accmess_exec(), minivm_greet_exec(), minivm_record_exec(), old_milliwatt_exec(), park_call_exec(), park_exec_full(), parkcall_helper(), pbx_builtin_background(), pickup_do(), playback_exec(), privacy_exec(), read_exec(), readexten_exec(), receivefax_exec(), record_exec(), rpt_exec(), sayunixtime_exec(), send_waveform_to_channel(), sendfax_exec(), setup_privacy_args(), skel_exec(), sla_station_exec(), speech_background(), testclient_exec(), testserver_exec(), transmit(), vm_exec(), vm_execmain(), waitfor_exec(), and zapateller_exec().
02899 { 02900 return __ast_answer(chan, 0, 1); 02901 }
| void ast_begin_shutdown | ( | int | hangup | ) |
Initiate system shutdown -- prevents new channels from being allocated.
| hangup | If "hangup" is non-zero, all existing channels will receive soft hangups |
Definition at line 773 of file channel.c.
References ao2_callback, ast_channel_softhangup_cb(), channels, OBJ_MULTIPLE, and OBJ_NODATA.
Referenced by quit_handler().
00774 { 00775 shutting_down = 1; 00776 00777 if (hangup) { 00778 ao2_callback(channels, OBJ_NODATA | OBJ_MULTIPLE, ast_channel_softhangup_cb, NULL); 00779 } 00780 }
Pick the best audio codec.
Pick the best codec Choose the best codec... Uhhh... Yah.
Okay, ulaw is used by all telephony equipment, so start with it
Unless of course, you're a silly European, so then prefer ALAW
G.722 is better then all below, but not as common as the above... so give ulaw and alaw priority
Okay, well, signed linear is easy to translate into other stuff
G.726 is standard ADPCM, in RFC3551 packing order
G.726 is standard ADPCM, in AAL2 packing order
ADPCM has great sound quality and is still pretty easy to translate
Okay, we're down to vocoders now, so pick GSM because it's small and easier to translate and sounds pretty good
iLBC is not too bad
Speex is free, but computationally more expensive than GSM
Ick, LPC10 sounds terrible, but at least we have code for it, if you're tacky enough to use it
G.729a is faster than 723 and slightly less expensive
Down to G.723.1 which is proprietary but at least designed for voice
Definition at line 992 of file channel.c.
References ARRAY_LEN, AST_FORMAT_ADPCM, AST_FORMAT_ALAW, AST_FORMAT_AUDIO_MASK, AST_FORMAT_G719, AST_FORMAT_G722, AST_FORMAT_G723_1, AST_FORMAT_G726, AST_FORMAT_G726_AAL2, AST_FORMAT_G729A, AST_FORMAT_GSM, AST_FORMAT_ILBC, AST_FORMAT_LPC10, AST_FORMAT_SIREN14, AST_FORMAT_SIREN7, AST_FORMAT_SLINEAR, AST_FORMAT_SLINEAR16, AST_FORMAT_SPEEX, AST_FORMAT_SPEEX16, AST_FORMAT_TESTLAW, AST_FORMAT_ULAW, ast_getformatname_multiple(), ast_log(), LOG_WARNING, and prefs.
Referenced by __oh323_new(), agent_call(), ast_codec_choose(), ast_iax2_new(), ast_speech_new(), bridge_make_compatible(), builtin_atxfer(), echo_exec(), findmeexec(), gtalk_new(), handle_open_receive_channel_ack_message(), iax2_request(), jingle_new(), local_new(), login_exec(), mgcp_new(), multicast_rtp_request(), set_format(), sip_new(), skinny_new(), skinny_set_rtp_peer(), socket_process(), start_rtp(), transmit_connect(), and unistim_new().
00993 { 00994 /* This just our opinion, expressed in code. We are asked to choose 00995 the best codec to use, given no information */ 00996 int x; 00997 static const format_t prefs[] = 00998 { 00999 /*! Okay, ulaw is used by all telephony equipment, so start with it */ 01000 AST_FORMAT_ULAW, 01001 /*! Unless of course, you're a silly European, so then prefer ALAW */ 01002 AST_FORMAT_ALAW, 01003 AST_FORMAT_G719, 01004 AST_FORMAT_SIREN14, 01005 AST_FORMAT_SIREN7, 01006 AST_FORMAT_TESTLAW, 01007 /*! G.722 is better then all below, but not as common as the above... so give ulaw and alaw priority */ 01008 AST_FORMAT_G722, 01009 /*! Okay, well, signed linear is easy to translate into other stuff */ 01010 AST_FORMAT_SLINEAR16, 01011 AST_FORMAT_SLINEAR, 01012 /*! G.726 is standard ADPCM, in RFC3551 packing order */ 01013 AST_FORMAT_G726, 01014 /*! G.726 is standard ADPCM, in AAL2 packing order */ 01015 AST_FORMAT_G726_AAL2, 01016 /*! ADPCM has great sound quality and is still pretty easy to translate */ 01017 AST_FORMAT_ADPCM, 01018 /*! Okay, we're down to vocoders now, so pick GSM because it's small and easier to 01019 translate and sounds pretty good */ 01020 AST_FORMAT_GSM, 01021 /*! iLBC is not too bad */ 01022 AST_FORMAT_ILBC, 01023 /*! Speex is free, but computationally more expensive than GSM */ 01024 AST_FORMAT_SPEEX16, 01025 AST_FORMAT_SPEEX, 01026 /*! Ick, LPC10 sounds terrible, but at least we have code for it, if you're tacky enough 01027 to use it */ 01028 AST_FORMAT_LPC10, 01029 /*! G.729a is faster than 723 and slightly less expensive */ 01030 AST_FORMAT_G729A, 01031 /*! Down to G.723.1 which is proprietary but at least designed for voice */ 01032 AST_FORMAT_G723_1, 01033 }; 01034 char buf[512]; 01035 01036 /* Strip out video */ 01037 fmts &= AST_FORMAT_AUDIO_MASK; 01038 01039 /* Find the first preferred codec in the format given */ 01040 for (x = 0; x < ARRAY_LEN(prefs); x++) { 01041 if (fmts & prefs[x]) 01042 return prefs[x]; 01043 } 01044 01045 ast_log(LOG_WARNING, "Don't know any of %s formats\n", ast_getformatname_multiple(buf, sizeof(buf), fmts)); 01046 01047 return 0; 01048 }
| struct ast_channel* ast_bridged_channel | ( | struct ast_channel * | chan | ) | [read] |
Find bridged channel.
| chan | Current channel |
Definition at line 6408 of file channel.c.
References ast_channel::_bridge, ast_channel_tech::bridged_channel, and ast_channel::tech.
Referenced by __analog_handle_event(), __analog_ss_thread(), __ast_read(), __dahdi_exception(), _skinny_show_lines(), action_agents(), action_coreshowchannels(), agents_data_provider_get(), agents_show(), agents_show_online(), analog_attempt_transfer(), analog_exception(), analog_hangup(), analog_ss_thread(), ast_bridge_call(), ast_cel_report_event(), ast_channel_data_add_structure(), ast_channel_masquerade(), ast_channel_set_linkgroup(), ast_do_masquerade(), ast_rtp_instance_set_stats_vars(), ast_set_hangupsource(), ast_var_channel_bridge(), ast_var_channels_table(), attempt_transfer(), cb_events(), channel_spy(), check_bridge(), common_exec(), console_transfer(), create_jb(), dahdi_handle_event(), dahdi_hangup(), export_aoc_vars(), func_channel_read(), get_refer_info(), handle_chanlist(), handle_hd_hf(), handle_invite_replaces(), handle_request(), handle_request_bye(), handle_request_info(), handle_request_refer(), handle_showchan(), handle_soft_key_event_message(), handle_stimulus_message(), key_call(), key_dial_page(), local_attended_transfer(), local_queryoption(), mgcp_hangup(), mgcp_ss(), misdn_attempt_transfer(), mixmonitor_thread(), my_get_sigpvt_bridged_channel(), park_call_full(), pri_dchannel(), schedule_delivery(), sig_pri_attempt_transfer(), sig_pri_handle_hold(), sip_hangup(), sip_set_rtp_peer(), skinny_transfer(), socket_process(), start_spying(), startmon(), TransferCallStep1(), and unistim_hangup().
06409 { 06410 struct ast_channel *bridged; 06411 bridged = chan->_bridge; 06412 if (bridged && bridged->tech->bridged_channel) 06413 bridged = bridged->tech->bridged_channel(chan, bridged); 06414 return bridged; 06415 }
| int ast_call | ( | struct ast_channel * | chan, | |
| char * | addr, | |||
| int | timeout | |||
| ) |
Make a call.
| chan | which channel to make the call on | |
| addr | destination of the call | |
| timeout | time to wait on for connect |
Definition at line 5360 of file channel.c.
References AST_CDR_FLAG_DIALED, ast_channel_lock, ast_channel_unlock, ast_check_hangup(), AST_FLAG_OUTGOING, AST_FLAG_ZOMBIE, ast_set_flag, ast_test_flag, ast_channel_tech::call, ast_channel::cdr, and ast_channel::tech.
Referenced by __ast_request_and_dial(), ast_call_forward(), attempt_reconnect(), begin_dial_channel(), connect_link(), dial_exec_full(), dial_transfer(), do_forward(), do_idle_thread(), feature_request_and_dial(), findmeexec(), play_sound_file(), ring_entry(), rpt(), rpt_exec(), and wait_for_answer().
05361 { 05362 /* Place an outgoing call, but don't wait any longer than timeout ms before returning. 05363 If the remote end does not answer within the timeout, then do NOT hang up, but 05364 return anyway. */ 05365 int res = -1; 05366 /* Stop if we're a zombie or need a soft hangup */ 05367 ast_channel_lock(chan); 05368 if (!ast_test_flag(chan, AST_FLAG_ZOMBIE) && !ast_check_hangup(chan)) { 05369 if (chan->cdr) { 05370 ast_set_flag(chan->cdr, AST_CDR_FLAG_DIALED); 05371 } 05372 if (chan->tech->call) 05373 res = chan->tech->call(chan, addr, timeout); 05374 ast_set_flag(chan, AST_FLAG_OUTGOING); 05375 } 05376 ast_channel_unlock(chan); 05377 return res; 05378 }
| struct ast_channel* ast_call_forward | ( | struct ast_channel * | caller, | |
| struct ast_channel * | orig, | |||
| int * | timeout, | |||
| format_t | format, | |||
| struct outgoing_helper * | oh, | |||
| int * | outstate | |||
| ) | [read] |
Forwards a call to a new channel specified by the original channel's call_forward str. If possible, the new forwarded channel is created and returned while the original one is terminated.
| caller | in channel that requested orig | |
| orig | channel being replaced by the call forward channel | |
| timeout | maximum amount of time to wait for setup of new forward channel | |
| format | requested channel format | |
| oh | outgoing helper used with original channel | |
| outstate | reason why unsuccessful (if uncuccessful) |
Definition at line 5009 of file channel.c.
References outgoing_helper::account, ast_channel::accountcode, accountcode, ast_call(), AST_CDR_FLAG_ORIGINATED, ast_cdr_setaccount(), ast_channel_datastore_inherit(), ast_channel_inherit_variables(), ast_channel_lock, ast_channel_set_redirecting(), ast_channel_trylock, ast_channel_unlock, ast_channel_update_redirecting(), ast_copy_flags, ast_copy_string(), ast_hangup(), ast_log(), ast_party_caller_copy(), ast_party_connected_line_copy(), ast_request(), ast_set_callerid(), ast_set_variables(), ast_string_field_set, ast_strlen_zero(), ast_channel::call_forward, ast_channel::caller, cause, ast_channel::cdr, CHANNEL_DEADLOCK_AVOIDANCE, outgoing_helper::cid_name, outgoing_helper::cid_num, ast_channel::connected, ast_channel::context, handle_cause(), LOG_NOTICE, outgoing_helper::parent_channel, pbx_builtin_getvar_helper(), ast_channel::redirecting, S_OR, type, and outgoing_helper::vars.
Referenced by __ast_request_and_dial(), and feature_request_and_dial().
05010 { 05011 char tmpchan[256]; 05012 struct ast_channel *new = NULL; 05013 struct ast_party_redirecting *apr = &orig->redirecting; 05014 char *data, *type; 05015 int cause = 0; 05016 int res; 05017 05018 /* gather data and request the new forward channel */ 05019 ast_copy_string(tmpchan, orig->call_forward, sizeof(tmpchan)); 05020 if ((data = strchr(tmpchan, '/'))) { 05021 *data++ = '\0'; 05022 type = tmpchan; 05023 } else { 05024 const char *forward_context; 05025 ast_channel_lock(orig); 05026 forward_context = pbx_builtin_getvar_helper(orig, "FORWARD_CONTEXT"); 05027 snprintf(tmpchan, sizeof(tmpchan), "%s@%s", orig->call_forward, S_OR(forward_context, orig->context)); 05028 ast_channel_unlock(orig); 05029 data = tmpchan; 05030 type = "Local"; 05031 } 05032 if (!(new = ast_request(type, format, orig, data, &cause))) { 05033 ast_log(LOG_NOTICE, "Unable to create channel for call forward to '%s/%s' (cause = %d)\n", type, data, cause); 05034 handle_cause(cause, outstate); 05035 ast_hangup(orig); 05036 return NULL; 05037 } 05038 05039 ast_channel_set_redirecting(new, apr, NULL); 05040 05041 /* Copy/inherit important information into new channel */ 05042 if (oh) { 05043 if (oh->vars) { 05044 ast_set_variables(new, oh->vars); 05045 } 05046 if (!ast_strlen_zero(oh->cid_num) && !ast_strlen_zero(oh->cid_name)) { 05047 ast_set_callerid(new, oh->cid_num, oh->cid_name, oh->cid_num); 05048 } 05049 if (oh->parent_channel) { 05050 ast_channel_update_redirecting(oh->parent_channel, apr, NULL); 05051 ast_channel_inherit_variables(oh->parent_channel, new); 05052 ast_channel_datastore_inherit(oh->parent_channel, new); 05053 } 05054 if (oh->account) { 05055 ast_cdr_setaccount(new, oh->account); 05056 } 05057 } else if (caller) { /* no outgoing helper so use caller if avaliable */ 05058 ast_channel_update_redirecting(caller, apr, NULL); 05059 ast_channel_inherit_variables(caller, new); 05060 ast_channel_datastore_inherit(caller, new); 05061 } 05062 05063 ast_channel_lock(orig); 05064 while (ast_channel_trylock(new)) { 05065 CHANNEL_DEADLOCK_AVOIDANCE(orig); 05066 } 05067 ast_copy_flags(new->cdr, orig->cdr, AST_CDR_FLAG_ORIGINATED); 05068 ast_string_field_set(new, accountcode, orig->accountcode); 05069 ast_party_caller_copy(&new->caller, &orig->caller); 05070 ast_party_connected_line_copy(&new->connected, &orig->connected); 05071 ast_channel_unlock(new); 05072 ast_channel_unlock(orig); 05073 05074 /* call new channel */ 05075 res = ast_call(new, data, 0); 05076 if (timeout) { 05077 *timeout = res; 05078 } 05079 if (res) { 05080 ast_log(LOG_NOTICE, "Unable to call forward to channel %s/%s\n", type, (char *)data); 05081 ast_hangup(orig); 05082 ast_hangup(new); 05083 return NULL; 05084 } 05085 ast_hangup(orig); 05086 05087 return new; 05088 }
| void ast_cancel_shutdown | ( | void | ) |
Cancel a shutdown in progress.
Cancels an existing shutdown and returns to normal operation
Definition at line 789 of file channel.c.
Referenced by handle_abort_shutdown().
00790 { 00791 shutting_down = 0; 00792 }
| const char* ast_cause2str | ( | int | cause | ) |
Gives the string form of a given hangup cause.
Gives the string form of a given cause code.
Definition at line 910 of file channel.c.
References ARRAY_LEN, and causes.
Referenced by __transmit_response(), ast_channel_data_add_structure(), ast_do_masquerade(), ast_hangup(), dial_exec_full(), findmeexec(), sip_hangup(), and transmit_request_with_auth().
00911 { 00912 int x; 00913 00914 for (x = 0; x < ARRAY_LEN(causes); x++) { 00915 if (causes[x].cause == cause) 00916 return causes[x].desc; 00917 } 00918 00919 return "Unknown"; 00920 }
| void ast_change_name | ( | struct ast_channel * | chan, | |
| const char * | newname | |||
| ) |
Change channel name.
| chan | the channel to change the name of | |
| newname | the name to change to |
Definition at line 5683 of file channel.c.
References __ast_change_name_nolink(), ao2_link, ao2_unlink, ast_channel_lock, ast_channel_unlock, and channels.
Referenced by update_name().
05684 { 05685 /* We must re-link, as the hash value will change here. */ 05686 ao2_unlink(channels, chan); 05687 ast_channel_lock(chan); 05688 __ast_change_name_nolink(chan, newname); 05689 ast_channel_unlock(chan); 05690 ao2_link(channels, chan); 05691 }
| struct ast_channel * ast_channel_alloc | ( | int | needqueue, | |
| int | state, | |||
| const char * | cid_num, | |||
| const char * | cid_name, | |||
| const char * | acctcode, | |||
| const char * | exten, | |||
| const char * | context, | |||
| const char * | linkedid, | |||
| const int | amaflag, | |||
| const char * | name_fmt, | |||
| ... | ||||
| ) | [read] |
Definition at line 8989 of file channel.c.
References __ast_channel_alloc_ap().
08994 { 08995 va_list ap1, ap2; 08996 struct ast_channel *result; 08997 08998 08999 va_start(ap1, name_fmt); 09000 va_start(ap2, name_fmt); 09001 result = __ast_channel_alloc_ap(needqueue, state, cid_num, cid_name, acctcode, exten, context, 09002 linkedid, amaflag, __FILE__, __LINE__, __FUNCTION__, name_fmt, ap1, ap2); 09003 va_end(ap1); 09004 va_end(ap2); 09005 09006 return result; 09007 }
| enum ast_bridge_result ast_channel_bridge | ( | struct ast_channel * | c0, | |
| struct ast_channel * | c1, | |||
| struct ast_bridge_config * | config, | |||
| struct ast_frame ** | fo, | |||
| struct ast_channel ** | rc | |||
| ) |
Bridge two channels together.
| c0 | first channel to bridge | |
| c1 | second channel to bridge | |
| config | config for the channels | |
| fo | destination frame(?) | |
| rc | destination channel(?) |
Definition at line 6749 of file channel.c.
References ast_channel::_bridge, ast_channel::_softhangup, AST_BRIDGE_COMPLETE, AST_BRIDGE_FAILED, AST_BRIDGE_FAILED_NOWARN, AST_BRIDGE_RETRY, ast_channel_make_compatible(), ast_check_hangup(), ast_check_hangup_locked(), ast_clear_flag, AST_CONTROL_SRCCHANGE, AST_CONTROL_SRCUPDATE, ast_debug, AST_FEATURE_PLAY_WARNING, AST_FEATURE_WARNING_ACTIVE, AST_FLAG_END_DTMF_ONLY, AST_FLAG_NBRIDGE, AST_FLAG_ZOMBIE, ast_generic_bridge(), ast_indicate(), ast_log(), ast_manager_event_multichan, ast_samp2tv(), ast_set_flag, ast_set_owners_and_peers(), AST_SOFTHANGUP_UNBRIDGE, ast_test_flag, ast_tvadd(), ast_tvdiff_ms(), ast_tvnow(), ast_tvsub(), ast_tvzero(), ast_verb, ast_channel::audiohooks, ast_channel_tech::bridge, bridge_play_sounds(), bridge_playfile(), ast_channel::caller, ast_bridge_config::end_sound, EVENT_FLAG_CALL, ast_bridge_config::feature_start_time, ast_bridge_config::feature_timer, ast_bridge_config::features_callee, ast_bridge_config::features_caller, ast_bridge_config::flags, ast_channel::generator, ast_party_caller::id, LOG_WARNING, manager_bridge_event(), ast_channel::masq, ast_channel::masqr, ast_channel::monitor, ast_channel::name, ast_channel::nativeformats, ast_bridge_config::nexteventts, ast_party_id::number, ast_bridge_config::play_warning, ast_channel::readformat, S_COR, ast_channel_tech::send_digit_begin, ast_bridge_config::start_sound, ast_bridge_config::start_time, ast_party_number::str, ast_channel::tech, ast_bridge_config::timelimit, ast_channel::uniqueid, update_bridge_vars(), ast_party_number::valid, ast_bridge_config::warning_freq, ast_bridge_config::warning_sound, and ast_channel::writeformat.
Referenced by ast_bridge_call().
06751 { 06752 struct ast_channel *who = NULL, *chans[2] = { c0, c1 }; 06753 enum ast_bridge_result res = AST_BRIDGE_COMPLETE; 06754 format_t o0nativeformats; 06755 format_t o1nativeformats; 06756 long time_left_ms=0; 06757 char caller_warning = 0; 06758 char callee_warning = 0; 06759 06760 if (c0->_bridge) { 06761 ast_log(LOG_WARNING, "%s is already in a bridge with %s\n", 06762 c0->name, c0->_bridge->name); 06763 return -1; 06764 } 06765 if (c1->_bridge) { 06766 ast_log(LOG_WARNING, "%s is already in a bridge with %s\n", 06767 c1->name, c1->_bridge->name); 06768 return -1; 06769 } 06770 06771 /* Stop if we're a zombie or need a soft hangup */ 06772 if (ast_test_flag(c0, AST_FLAG_ZOMBIE) || ast_check_hangup_locked(c0) || 06773 ast_test_flag(c1, AST_FLAG_ZOMBIE) || ast_check_hangup_locked(c1)) 06774 return -1; 06775 06776 *fo = NULL; 06777 06778 if (ast_tvzero(config->start_time)) { 06779 config->start_time = ast_tvnow(); 06780 if (config->start_sound) { 06781 if (caller_warning) { 06782 bridge_playfile(c0, c1, config->start_sound, config->timelimit / 1000); 06783 } 06784 if (callee_warning) { 06785 bridge_playfile(c1, c0, config->start_sound, config->timelimit / 1000); 06786 } 06787 } 06788 } 06789 06790 /* Keep track of bridge */ 06791 c0->_bridge = c1; 06792 c1->_bridge = c0; 06793 06794 ast_set_owners_and_peers(c0, c1); 06795 06796 o0nativeformats = c0->nativeformats; 06797 o1nativeformats = c1->nativeformats; 06798 06799 if (config->feature_timer && !ast_tvzero(config->nexteventts)) { 06800 config->nexteventts = ast_tvadd(config->feature_start_time, ast_samp2tv(config->feature_timer, 1000)); 06801 } else if (config->timelimit) { 06802 time_left_ms = config->timelimit - ast_tvdiff_ms(ast_tvnow(), config->start_time); 06803 caller_warning = ast_test_flag(&config->features_caller, AST_FEATURE_PLAY_WARNING); 06804 callee_warning = ast_test_flag(&config->features_callee, AST_FEATURE_PLAY_WARNING); 06805 config->nexteventts = ast_tvadd(config->start_time, ast_samp2tv(config->timelimit, 1000)); 06806 if ((caller_warning || callee_warning) && config->play_warning) { 06807 long next_warn = config->play_warning; 06808 if (time_left_ms < config->play_warning) { 06809 /* At least one warning was played, which means we are returning after feature */ 06810 long warns_passed = (config->play_warning - time_left_ms) / config->warning_freq; 06811 /* It is 'warns_passed * warning_freq' NOT '(warns_passed + 1) * warning_freq', 06812 because nexteventts will be updated once again in the 'if (!to)' block */ 06813 next_warn = config->play_warning - warns_passed * config->warning_freq; 06814 } 06815 config->nexteventts = ast_tvsub(config->nexteventts, ast_samp2tv(next_warn, 1000)); 06816 } 06817 } else { 06818 config->nexteventts.tv_sec = 0; 06819 config->nexteventts.tv_usec = 0; 06820 } 06821 06822 if (!c0->tech->send_digit_begin) 06823 ast_set_flag(c1, AST_FLAG_END_DTMF_ONLY); 06824 if (!c1->tech->send_digit_begin) 06825 ast_set_flag(c0, AST_FLAG_END_DTMF_ONLY); 06826 manager_bridge_event(1, 1, c0, c1); 06827 06828 /* Before we enter in and bridge these two together tell them both the source of audio has changed */ 06829 ast_indicate(c0, AST_CONTROL_SRCCHANGE); 06830 ast_indicate(c1, AST_CONTROL_SRCCHANGE); 06831 06832 for (/* ever */;;) { 06833 struct timeval now = { 0, }; 06834 int to; 06835 06836 to = -1; 06837 06838 if (!ast_tvzero(config->nexteventts)) { 06839 now = ast_tvnow(); 06840 to = ast_tvdiff_ms(config->nexteventts, now); 06841 if (to <= 0) { 06842 if (!config->timelimit) { 06843 res = AST_BRIDGE_COMPLETE; 06844 break; 06845 } 06846 to = 0; 06847 } 06848 } 06849 06850 if (config->timelimit) { 06851 time_left_ms = config->timelimit - ast_tvdiff_ms(now, config->start_time); 06852 if (time_left_ms < to) 06853 to = time_left_ms; 06854 06855 if (time_left_ms <= 0) { 06856 if (caller_warning && config->end_sound) 06857 bridge_playfile(c0, c1, config->end_sound, 0); 06858 if (callee_warning && config->end_sound) 06859 bridge_playfile(c1, c0, config->end_sound, 0); 06860 *fo = NULL; 06861 if (who) 06862 *rc = who; 06863 res = 0; 06864 break; 06865 } 06866 06867 if (!to) { 06868 if (time_left_ms >= 5000 && config->warning_sound && config->play_warning && ast_test_flag(config, AST_FEATURE_WARNING_ACTIVE)) { 06869 int t = (time_left_ms + 500) / 1000; /* round to nearest second */ 06870 if (caller_warning) 06871 bridge_playfile(c0, c1, config->warning_sound, t); 06872 if (callee_warning) 06873 bridge_playfile(c1, c0, config->warning_sound, t); 06874 } 06875 06876 if (config->warning_freq && (time_left_ms > (config->warning_freq + 5000))) { 06877 config->nexteventts = ast_tvadd(config->nexteventts, ast_samp2tv(config->warning_freq, 1000)); 06878 } else { 06879 config->nexteventts = ast_tvadd(config->start_time, ast_samp2tv(config->timelimit, 1000)); 06880 } 06881 } 06882 ast_clear_flag(config, AST_FEATURE_WARNING_ACTIVE); 06883 } 06884 06885 if (c0->_softhangup == AST_SOFTHANGUP_UNBRIDGE || c1->_softhangup == AST_SOFTHANGUP_UNBRIDGE) { 06886 if (c0->_softhangup == AST_SOFTHANGUP_UNBRIDGE) 06887 c0->_softhangup = 0; 06888 if (c1->_softhangup == AST_SOFTHANGUP_UNBRIDGE) 06889 c1->_softhangup = 0; 06890 c0->_bridge = c1; 06891 c1->_bridge = c0; 06892 ast_debug(1, "Unbridge signal received. Ending native bridge.\n"); 06893 continue; 06894 } 06895 06896 /* Stop if we're a zombie or need a soft hangup */ 06897 if (ast_test_flag(c0, AST_FLAG_ZOMBIE) || ast_check_hangup_locked(c0) || 06898 ast_test_flag(c1, AST_FLAG_ZOMBIE) || ast_check_hangup_locked(c1)) { 06899 *fo = NULL; 06900 if (who) 06901 *rc = who; 06902 res = 0; 06903 ast_debug(1, "Bridge stops because we're zombie or need a soft hangup: c0=%s, c1=%s, flags: %s,%s,%s,%s\n", 06904 c0->name, c1->name, 06905 ast_test_flag(c0, AST_FLAG_ZOMBIE) ? "Yes" : "No", 06906 ast_check_hangup(c0) ? "Yes" : "No", 06907 ast_test_flag(c1, AST_FLAG_ZOMBIE) ? "Yes" : "No", 06908 ast_check_hangup(c1) ? "Yes" : "No"); 06909 break; 06910 } 06911 06912 update_bridge_vars(c0, c1); 06913 06914 bridge_play_sounds(c0, c1); 06915 06916 if (c0->tech->bridge && 06917 /* if < 1 ms remains use generic bridging for accurate timing */ 06918 (!config->timelimit || to > 1000 || to == 0) && 06919 (c0->tech->bridge == c1->tech->bridge) && 06920 !c0->monitor && !c1->monitor && 06921 !c0->audiohooks && !c1->audiohooks && 06922 !c0->masq && !c0->masqr && !c1->masq && !c1->masqr) { 06923 int timeoutms = to - 1000 > 0 ? to - 1000 : to; 06924 /* Looks like they share a bridge method and nothing else is in the way */ 06925 ast_set_flag(c0, AST_FLAG_NBRIDGE); 06926 ast_set_flag(c1, AST_FLAG_NBRIDGE); 06927 if ((res = c0->tech->bridge(c0, c1, config->flags, fo, rc, timeoutms)) == AST_BRIDGE_COMPLETE) { 06928 ast_manager_event_multichan(EVENT_FLAG_CALL, "Unlink", 2, chans, 06929 "Channel1: %s\r\n" 06930 "Channel2: %s\r\n" 06931 "Uniqueid1: %s\r\n" 06932 "Uniqueid2: %s\r\n" 06933 "CallerID1: %s\r\n" 06934 "CallerID2: %s\r\n", 06935 c0->name, c1->name, 06936 c0->uniqueid, c1->uniqueid, 06937 S_COR(c0->caller.id.number.valid, c0->caller.id.number.str, "<unknown>"), 06938 S_COR(c1->caller.id.number.valid, c1->caller.id.number.str, "<unknown>")); 06939 06940 ast_debug(1, "Returning from native bridge, channels: %s, %s\n", c0->name, c1->name); 06941 06942 ast_clear_flag(c0, AST_FLAG_NBRIDGE); 06943 ast_clear_flag(c1, AST_FLAG_NBRIDGE); 06944 06945 if (c0->_softhangup == AST_SOFTHANGUP_UNBRIDGE || c1->_softhangup == AST_SOFTHANGUP_UNBRIDGE) 06946 continue; 06947 06948 c0->_bridge = NULL; 06949 c1->_bridge = NULL; 06950 return res; 06951 } else { 06952 ast_clear_flag(c0, AST_FLAG_NBRIDGE); 06953 ast_clear_flag(c1, AST_FLAG_NBRIDGE); 06954 } 06955 switch (res) { 06956 case AST_BRIDGE_RETRY: 06957 if (config->play_warning) { 06958 ast_set_flag(config, AST_FEATURE_WARNING_ACTIVE); 06959 } 06960 continue; 06961 default: 06962 ast_verb(3, "Native bridging %s and %s ended\n", c0->name, c1->name); 06963 /* fallthrough */ 06964 case AST_BRIDGE_FAILED_NOWARN: 06965 break; 06966 } 06967 } 06968 06969 if (((c0->writeformat != c1->readformat) || (c0->readformat != c1->writeformat) || 06970 (c0->nativeformats != o0nativeformats) || (c1->nativeformats != o1nativeformats)) && 06971 !(c0->generator || c1->generator)) { 06972 if (ast_channel_make_compatible(c0, c1)) { 06973 ast_log(LOG_WARNING, "Can't make %s and %s compatible\n", c0->name, c1->name); 06974 manager_bridge_event(0, 1, c0, c1); 06975 return AST_BRIDGE_FAILED; 06976 } 06977 o0nativeformats = c0->nativeformats; 06978 o1nativeformats = c1->nativeformats; 06979 } 06980 06981 update_bridge_vars(c0, c1); 06982 06983 res = ast_generic_bridge(c0, c1, config, fo, rc); 06984 if (res != AST_BRIDGE_RETRY) { 06985 break; 06986 } else if (config->feature_timer) { 06987 /* feature timer expired but has not been updated, sending to ast_bridge_call to do so */ 06988 break; 06989 } 06990 } 06991 06992 ast_clear_flag(c0, AST_FLAG_END_DTMF_ONLY); 06993 ast_clear_flag(c1, AST_FLAG_END_DTMF_ONLY); 06994 06995 /* Now that we have broken the bridge the source will change yet again */ 06996 ast_indicate(c0, AST_CONTROL_SRCUPDATE); 06997 ast_indicate(c1, AST_CONTROL_SRCUPDATE); 06998 06999 c0->_bridge = NULL; 07000 c1->_bridge = NULL; 07001 07002 ast_manager_event_multichan(EVENT_FLAG_CALL, "Unlink", 2, chans, 07003 "Channel1: %s\r\n" 07004 "Channel2: %s\r\n" 07005 "Uniqueid1: %s\r\n" 07006 "Uniqueid2: %s\r\n" 07007 "CallerID1: %s\r\n" 07008 "CallerID2: %s\r\n", 07009 c0->name, c1->name, 07010 c0->uniqueid, c1->uniqueid, 07011 S_COR(c0->caller.id.number.valid, c0->caller.id.number.str, "<unknown>"), 07012 S_COR(c1->caller.id.number.valid, c1->caller.id.number.str, "<unknown>")); 07013 ast_debug(1, "Bridge stops bridging channels %s and %s\n", c0->name, c1->name); 07014 07015 return res; 07016 }
| struct ast_channel* ast_channel_callback | ( | ao2_callback_data_fn * | cb_fn, | |
| void * | arg, | |||
| void * | data, | |||
| int | ao2_flags | |||
| ) | [read] |
Call a function with every active channel.
This function executes a callback one time for each active channel on the system. The channel is provided as an argument to the function.
Definition at line 1515 of file channel.c.
References ao2_callback_data, and channels.
Referenced by ast_cel_check_retire_linkedid(), ast_pickup_call(), handle_core_set_debug_channel(), my_ast_get_channel_by_name_locked(), pickup_by_mark(), pickup_by_part(), and state_notify_build_xml().
01517 { 01518 return ao2_callback_data(channels, ao2_flags, cb_fn, arg, data); 01519 }
| int ast_channel_cc_params_init | ( | struct ast_channel * | chan, | |
| const struct ast_cc_config_params * | base_params | |||
| ) |
Set up datastore with CCSS parameters for a channel.
| chan | The channel to create the datastore on | |
| base_params | CCSS parameters we wish to copy into the channel |
| 0 | Success | |
| -1 | Failure |
Definition at line 8895 of file channel.c.
References ast_cc_config_params_destroy(), ast_cc_config_params_init, ast_cc_copy_config_params(), ast_channel_datastore_add(), ast_datastore_alloc, and ast_datastore::data.
Referenced by ast_channel_get_cc_config_params(), dahdi_new(), local_call(), local_request(), and sip_new().
08897 { 08898 struct ast_cc_config_params *cc_params; 08899 struct ast_datastore *cc_datastore; 08900 08901 if (!(cc_params = ast_cc_config_params_init())) { 08902 return -1; 08903 } 08904 08905 if (!(cc_datastore = ast_datastore_alloc(&cc_channel_datastore_info, NULL))) { 08906 ast_cc_config_params_destroy(cc_params); 08907 return -1; 08908 } 08909 08910 if (base_params) { 08911 ast_cc_copy_config_params(cc_params, base_params); 08912 } 08913 cc_datastore->data = cc_params; 08914 ast_channel_datastore_add(chan, cc_datastore); 08915 return 0; 08916 }
| static void ast_channel_change_linkedid | ( | struct ast_channel * | chan, | |
| const char * | linkedid | |||
| ) | [static] |
Set the channel's linkedid to the given string, and also check to see if the channel's old linkedid is now being retired
Definition at line 5822 of file channel.c.
References ast_cel_check_retire_linkedid(), ast_string_field_set, ast_strlen_zero(), and ast_channel::linkedid.
Referenced by ast_channel_set_linkgroup().
05823 { 05824 /* if the linkedid for this channel is being changed from something, check... */ 05825 if (!ast_strlen_zero(chan->linkedid) && 0 != strcmp(chan->linkedid, linkedid)) { 05826 ast_cel_check_retire_linkedid(chan); 05827 } 05828 05829 ast_string_field_set(chan, linkedid, linkedid); 05830 }
| static int ast_channel_cmp_cb | ( | void * | obj, | |
| void * | arg, | |||
| int | flags | |||
| ) | [static] |
Definition at line 1601 of file channel.c.
References ast_channel_lock, ast_channel_unlock, ast_strlen_zero(), CMP_MATCH, ast_channel::context, ast_channel::exten, ast_channel::macrocontext, ast_channel::macroexten, ast_channel::name, and ast_channel::uniqueid.
Referenced by ast_channels_init().
01602 { 01603 struct ast_channel *chan = obj, *cmp_args = arg; 01604 size_t name_len; 01605 int ret = CMP_MATCH; 01606 01607 /* This is sort of a hack. Basically, we're using an arbitrary field 01608 * in ast_channel to pass the name_len for a prefix match. If this 01609 * gets changed, then the uses of ao2_find() must be changed, too. */ 01610 name_len = cmp_args->rings; 01611 01612 ast_channel_lock(chan); 01613 01614 if (!ast_strlen_zero(cmp_args->name)) { /* match by name */ 01615 if ((!name_len && strcasecmp(chan->name, cmp_args->name)) || 01616 (name_len && strncasecmp(chan->name, cmp_args->name, name_len))) { 01617 ret = 0; /* name match failed */ 01618 } 01619 } else if (!ast_strlen_zero(cmp_args->exten)) { 01620 if (cmp_args->context && strcasecmp(chan->context, cmp_args->context) && 01621 strcasecmp(chan->macrocontext, cmp_args->context)) { 01622 ret = 0; /* context match failed */ 01623 } 01624 if (ret && strcasecmp(chan->exten, cmp_args->exten) && 01625 strcasecmp(chan->macroexten, cmp_args->exten)) { 01626 ret = 0; /* exten match failed */ 01627 } 01628 } else if (!ast_strlen_zero(cmp_args->uniqueid)) { 01629 if ((!name_len && strcasecmp(chan->uniqueid, cmp_args->uniqueid)) || 01630 (name_len && strncasecmp(chan->uniqueid, cmp_args->uniqueid, name_len))) { 01631 ret = 0; /* uniqueid match failed */ 01632 } 01633 } else { 01634 ret = 0; 01635 } 01636 01637 ast_channel_unlock(chan); 01638 01639 return ret; 01640 }
| int ast_channel_cmpwhentohangup | ( | struct ast_channel * | chan, | |
| time_t | offset | |||
| ) |
Compare a offset with the settings of when to hang a channel up.
| chan | channel on which to check for hang up | |
| offset | offset in seconds from current time |
Definition at line 830 of file channel.c.
References ast_channel_cmpwhentohangup_tv().
00831 { 00832 struct timeval when = { offset, }; 00833 return ast_channel_cmpwhentohangup_tv(chan, when); 00834 }
| int ast_channel_cmpwhentohangup_tv | ( | struct ast_channel * | chan, | |
| struct timeval | offset | |||
| ) |
Compare a offset with when to hangup channel.
Compare a offset with the settings of when to hang a channel up.
Definition at line 815 of file channel.c.
References ast_tvadd(), ast_tvdiff_ms(), ast_tvnow(), ast_tvzero(), and ast_channel::whentohangup.
Referenced by ast_channel_cmpwhentohangup().
00816 { 00817 struct timeval whentohangup; 00818 00819 if (ast_tvzero(chan->whentohangup)) 00820 return ast_tvzero(offset) ? 0 : -1; 00821 00822 if (ast_tvzero(offset)) 00823 return 1; 00824 00825 whentohangup = ast_tvadd(offset, ast_tvnow()); 00826 00827 return ast_tvdiff_ms(whentohangup, chan->whentohangup); 00828 }
| int ast_channel_connected_line_macro | ( | struct ast_channel * | autoservice_chan, | |
| struct ast_channel * | macro_chan, | |||
| const void * | connected_info, | |||
| int | caller, | |||
| int | frame | |||
| ) |
Run a connected line interception macro and update a channel's connected line information.
| autoservice_chan | Channel to place into autoservice while the macro is running. It is perfectly safe for this to be NULL | |
| macro_chan | The channel to run the macro on. Also the channel from which we determine which macro we need to run. | |
| connected_info | Either an ast_party_connected_line or ast_frame pointer of type AST_CONTROL_CONNECTED_LINE | |
| caller | If true, then run CONNECTED_LINE_CALLER_SEND_MACRO, otherwise run CONNECTED_LINE_CALLEE_SEND_MACRO | |
| frame | If true, then connected_info is an ast_frame pointer, otherwise it is an ast_party_connected_line pointer. |
| 0 | Success | |
| -1 | Either the macro does not exist, or there was an error while attempting to run the macro |
Make constants so that caller and frame can be more expressive than just '1' and '0'
Definition at line 8793 of file channel.c.
References ast_app_run_macro(), ast_channel_lock, ast_channel_unlock, ast_channel_update_connected_line(), ast_connected_line_parse_data(), ast_party_connected_line_copy(), ast_strdupa, ast_strlen_zero(), chanlist::connected, ast_channel::connected, ast_frame::data, ast_frame::datalen, pbx_builtin_getvar_helper(), ast_frame::ptr, and S_OR.
Referenced by __ast_read(), ast_bridge_call(), ast_generic_bridge(), ast_pickup_call(), builtin_atxfer(), builtin_blindtransfer(), feature_request_and_dial(), handle_frame(), local_bridge_loop(), pickup_do(), remote_bridge_loop(), and wait_for_answer().
08794 { 08795 const char *macro; 08796 const char *macro_args; 08797 int retval; 08798 08799 ast_channel_lock(macro_chan); 08800 macro = pbx_builtin_getvar_helper(macro_chan, is_caller 08801 ? "CONNECTED_LINE_CALLER_SEND_MACRO" : "CONNECTED_LINE_CALLEE_SEND_MACRO"); 08802 macro = ast_strdupa(S_OR(macro, "")); 08803 macro_args = pbx_builtin_getvar_helper(macro_chan, is_caller 08804 ? "CONNECTED_LINE_CALLER_SEND_MACRO_ARGS" : "CONNECTED_LINE_CALLEE_SEND_MACRO_ARGS"); 08805 macro_args = ast_strdupa(S_OR(macro_args, "")); 08806 08807 if (ast_strlen_zero(macro)) { 08808 ast_channel_unlock(macro_chan); 08809 return -1; 08810 } 08811 08812 if (is_frame) { 08813 const struct ast_frame *frame = connected_info; 08814 08815 ast_connected_line_parse_data(frame->data.ptr, frame->datalen, ¯o_chan->connected); 08816 } else { 08817 const struct ast_party_connected_line *connected = connected_info; 08818 08819 ast_party_connected_line_copy(¯o_chan->connected, connected); 08820 } 08821 ast_channel_unlock(macro_chan); 08822 08823 if (!(retval = ast_app_run_macro(autoservice_chan, macro_chan, macro, macro_args))) { 08824 ast_channel_lock(macro_chan); 08825 ast_channel_update_connected_line(macro_chan, ¯o_chan->connected, NULL); 08826 ast_channel_unlock(macro_chan); 08827 } 08828 08829 return retval; 08830 }
| int ast_channel_data_add_structure | ( | struct ast_data * | tree, | |
| struct ast_channel * | chan, | |||
| int | add_bridged | |||
| ) |
Insert into an astdata tree, the channel structure.
| [in] | tree | The ast data tree. |
| [in] | chan | The channel structure to add to tree. |
| [in] | add_bridged | Add the bridged channel to the structure. |
| <0 | on error. | |
| 0 | on success. |
Definition at line 343 of file channel.c.
References ast_channel::_softhangup, ast_channel::_state, ast_channel::amaflags, ast_bridged_channel(), ast_cause2str(), ast_cdr_data_add_structure(), ast_cdr_flags2str(), ast_channel_data_add_structure(), ast_data_add_bool(), ast_data_add_codecs(), ast_data_add_int(), ast_data_add_node(), ast_data_add_str(), ast_data_add_structure, ast_data_add_uint(), AST_SOFTHANGUP_APPUNLOAD, AST_SOFTHANGUP_ASYNCGOTO, AST_SOFTHANGUP_DEV, AST_SOFTHANGUP_EXPLICIT, AST_SOFTHANGUP_SHUTDOWN, AST_SOFTHANGUP_TIMEOUT, AST_SOFTHANGUP_UNBRIDGE, ast_state2str(), ast_tone_zone_data_add_structure(), ast_transfercapability2str(), ast_channel::cdr, channel_data_add_flags(), ast_channel::hangupcause, ast_channel::nativeformats, ast_channel::oldwriteformat, ast_channel::rawreadformat, ast_channel::rawwriteformat, ast_channel::readformat, ast_channel::transfercapability, ast_channel::whentohangup, ast_channel::writeformat, and ast_channel::zone.
Referenced by agents_data_provider_get(), ast_channel_data_add_structure(), data_channels_provider_handler(), queues_data_provider_get_helper(), and user_add_provider_cb().
00345 { 00346 struct ast_channel *bc; 00347 struct ast_data *data_bridged; 00348 struct ast_data *data_cdr; 00349 struct ast_data *data_flags; 00350 struct ast_data *data_zones; 00351 struct ast_data *enum_node; 00352 struct ast_data *data_softhangup; 00353 #if 0 /* XXX AstData: ast_callerid no longer exists. (Equivalent code not readily apparent.) */ 00354 struct ast_data *data_callerid; 00355 char value_str[100]; 00356 #endif 00357 00358 if (!tree) { 00359 return -1; 00360 } 00361 00362 ast_data_add_structure(ast_channel, tree, chan); 00363 00364 if (add_bridged) { 00365 bc = ast_bridged_channel(chan); 00366 if (bc) { 00367 data_bridged = ast_data_add_node(tree, "bridged"); 00368 if (!data_bridged) { 00369 return -1; 00370 } 00371 ast_channel_data_add_structure(data_bridged, bc, 0); 00372 } 00373 } 00374 00375 ast_data_add_codecs(tree, "oldwriteformat", chan->oldwriteformat); 00376 ast_data_add_codecs(tree, "nativeformats", chan->nativeformats); 00377 ast_data_add_codecs(tree, "readformat", chan->readformat); 00378 ast_data_add_codecs(tree, "writeformat", chan->writeformat); 00379 ast_data_add_codecs(tree, "rawreadformat", chan->rawreadformat); 00380 ast_data_add_codecs(tree, "rawwriteformat", chan->rawwriteformat); 00381 00382 /* state */ 00383 enum_node = ast_data_add_node(tree, "state"); 00384 if (!enum_node) { 00385 return -1; 00386 } 00387 ast_data_add_str(enum_node, "text", ast_state2str(chan->_state)); 00388 ast_data_add_int(enum_node, "value", chan->_state); 00389 00390 /* hangupcause */ 00391 enum_node = ast_data_add_node(tree, "hangupcause"); 00392 if (!enum_node) { 00393 return -1; 00394 } 00395 ast_data_add_str(enum_node, "text", ast_cause2str(chan->hangupcause)); 00396 ast_data_add_int(enum_node, "value", chan->hangupcause); 00397 00398 /* amaflags */ 00399 enum_node = ast_data_add_node(tree, "amaflags"); 00400 if (!enum_node) { 00401 return -1; 00402 } 00403 ast_data_add_str(enum_node, "text", ast_cdr_flags2str(chan->amaflags)); 00404 ast_data_add_int(enum_node, "value", chan->amaflags); 00405 00406 /* transfercapability */ 00407 enum_node = ast_data_add_node(tree, "transfercapability"); 00408 if (!enum_node) { 00409 return -1; 00410 } 00411 ast_data_add_str(enum_node, "text", ast_transfercapability2str(chan->transfercapability)); 00412 ast_data_add_int(enum_node, "value", chan->transfercapability); 00413 00414 /* _softphangup */ 00415 data_softhangup = ast_data_add_node(tree, "softhangup"); 00416 if (!data_softhangup) { 00417 return -1; 00418 } 00419 ast_data_add_bool(data_softhangup, "dev", chan->_softhangup & AST_SOFTHANGUP_DEV); 00420 ast_data_add_bool(data_softhangup, "asyncgoto", chan->_softhangup & AST_SOFTHANGUP_ASYNCGOTO); 00421 ast_data_add_bool(data_softhangup, "shutdown", chan->_softhangup & AST_SOFTHANGUP_SHUTDOWN); 00422 ast_data_add_bool(data_softhangup, "timeout", chan->_softhangup & AST_SOFTHANGUP_TIMEOUT); 00423 ast_data_add_bool(data_softhangup, "appunload", chan->_softhangup & AST_SOFTHANGUP_APPUNLOAD); 00424 ast_data_add_bool(data_softhangup, "explicit", chan->_softhangup & AST_SOFTHANGUP_EXPLICIT); 00425 ast_data_add_bool(data_softhangup, "unbridge", chan->_softhangup & AST_SOFTHANGUP_UNBRIDGE); 00426 00427 /* channel flags */ 00428 data_flags = ast_data_add_node(tree, "flags"); 00429 if (!data_flags) { 00430 return -1; 00431 } 00432 channel_data_add_flags(data_flags, chan); 00433 00434 ast_data_add_uint(tree, "timetohangup", chan->whentohangup.tv_sec); 00435 00436 #if 0 /* XXX AstData: ast_callerid no longer exists. (Equivalent code not readily apparent.) */ 00437 /* callerid */ 00438 data_callerid = ast_data_add_node(tree, "callerid"); 00439 if (!data_callerid) { 00440 return -1; 00441 } 00442 ast_data_add_structure(ast_callerid, data_callerid, &(chan->cid)); 00443 /* insert the callerid ton */ 00444 enum_node = ast_data_add_node(data_callerid, "cid_ton"); 00445 if (!enum_node) { 00446 return -1; 00447 } 00448 ast_data_add_int(enum_node, "value", chan->cid.cid_ton); 00449 snprintf(value_str, sizeof(value_str), "TON: %s/Plan: %s", 00450 party_number_ton2str(chan->cid.cid_ton), 00451 party_number_plan2str(chan->cid.cid_ton)); 00452 ast_data_add_str(enum_node, "text", value_str); 00453 #endif 00454 00455 /* tone zone */ 00456 if (chan->zone) { 00457 data_zones = ast_data_add_node(tree, "zone"); 00458 if (!data_zones) { 00459 return -1; 00460 } 00461 ast_tone_zone_data_add_structure(data_zones, chan->zone); 00462 } 00463 00464 /* insert cdr */ 00465 data_cdr = ast_data_add_node(tree, "cdr"); 00466 if (!data_cdr) { 00467 return -1; 00468 } 00469 00470 ast_cdr_data_add_structure(data_cdr, chan->cdr, 1); 00471 00472 return 0; 00473 }
| int ast_channel_data_cmp_structure | ( | const struct ast_data_search * | tree, | |
| struct ast_channel * | chan, | |||
| const char * | structure_name | |||
| ) |
Compare to channel structures using the data api.
| [in] | tree | The search tree generated by the data api. |
| [in] | chan | The channel to compare. |
| [in] | structure_name | The name of the node of the channel structure. |
| 0 | The structure matches. | |
| 1 | The structure doesn't matches. |
Definition at line 475 of file channel.c.
References ast_data_search_cmp_structure.
00477 { 00478 return ast_data_search_cmp_structure(tree, ast_channel, chan, structure_name); 00479 }
| int ast_channel_datastore_add | ( | struct ast_channel * | chan, | |
| struct ast_datastore * | datastore | |||
| ) |
Add a datastore to a channel.
| 0 | success | |
| non-zero | failure |
Definition at line 2455 of file channel.c.
References AST_LIST_INSERT_HEAD, and ast_channel::datastores.
Referenced by _macro_exec(), acf_curlopt_write(), acf_iaxvar_write(), acf_odbc_read(), add_features_datastores(), add_to_agi(), apply_plc(), ast_channel_cc_params_init(), ast_iax2_new(), ast_setup_cc_recall_datastore(), audiohook_volume_get(), authenticate_reply(), calendar_query_exec(), cc_interfaces_datastore_init(), dial_exec_full(), do_notify(), dundi_query_read(), enable_jack_hook(), enum_query_read(), find_or_create_details(), find_transaction(), frame_trace_helper(), func_channel_write_real(), get_lock(), gosub_exec(), lua_get_state(), mute_add_audiohook(), pbx_builtin_raise_exception(), pitchshift_helper(), setup_inheritance_datastore(), setup_mixmonitor_ds(), setup_transfer_datastore(), shared_write(), smdi_msg_retrieve_read(), socket_process(), speech_create(), speex_write(), srv_datastore_setup(), try_calling(), and volume_write().
02456 { 02457 int res = 0; 02458 02459 AST_LIST_INSERT_HEAD(&chan->datastores, datastore, entry); 02460 02461 return res; 02462 }
| struct ast_datastore* ast_channel_datastore_alloc | ( | const struct ast_datastore_info * | info, | |
| const char * | uid | |||
| ) | [read] |
Create a channel data store object.
Definition at line 2428 of file channel.c.
References ast_datastore_alloc.
02429 { 02430 return ast_datastore_alloc(info, uid); 02431 }
| struct ast_datastore* ast_channel_datastore_find | ( | struct ast_channel * | chan, | |
| const struct ast_datastore_info * | info, | |||
| const char * | uid | |||
| ) | [read] |
Find a datastore on a channel.
The datastore returned from this function must not be used if the reference to the channel is released.
| pointer | to the datastore if found | |
| NULL | if not found |
Definition at line 2469 of file channel.c.
References AST_LIST_TRAVERSE_SAFE_BEGIN, AST_LIST_TRAVERSE_SAFE_END, ast_channel::datastores, ast_datastore::info, and ast_datastore::uid.
Referenced by _macro_exec(), acf_curl_helper(), acf_curlopt_helper(), acf_curlopt_write(), acf_exception_read(), acf_fetch(), acf_iaxvar_read(), acf_iaxvar_write(), acf_odbc_read(), add_agi_cmd(), add_features_datastores(), add_to_agi(), apply_plc(), ast_cc_agent_set_interfaces_chanvar(), ast_cc_call_init(), ast_cc_completed(), ast_cc_extension_monitor_add_dialstring(), ast_cc_get_current_core_id(), ast_cc_is_recall(), ast_cc_offer(), ast_channel_get_cc_config_params(), ast_handle_cc_control_frame(), ast_ignore_cc(), ast_odbc_retrieve_transaction_obj(), ast_set_cc_interfaces_chanvar(), attended_transfer_occurred(), audiohook_volume_callback(), audiohook_volume_get(), builtin_atxfer(), calendar_event_read(), calendar_query_exec(), calendar_query_result_exec(), cc_build_payload(), dial_exec_full(), disable_jack_hook(), dundi_result_read(), enable_jack_hook(), enum_result_read(), exec_odbcfinish(), find_details(), find_speech(), find_transaction(), frame_trace_helper(), func_channel_read(), func_channel_write_real(), func_inheritance_write(), func_mute_write(), get_agi_cmd(), get_lock(), gosub_exec(), handle_gosub(), iax2_call(), jack_hook_callback(), local_read(), local_write(), lock_fixup(), lua_get_state(), manage_parkinglot(), manager_mutestream(), mark_transaction_active(), mute_callback(), park_exec_full(), pbx_builtin_raise_exception(), pitchshift_cb(), pitchshift_helper(), pop_exec(), queue_transfer_fixup(), release_transaction(), return_exec(), set_security_requirements(), shared_read(), shared_write(), smdi_msg_read(), speech_background(), speech_destroy(), speex_callback(), speex_read(), speex_write(), srv_query_read(), srv_result_read(), stop_mixmonitor_exec(), try_calling(), unlock_read(), volume_callback(), and volume_write().
02470 { 02471 struct ast_datastore *datastore = NULL; 02472 02473 if (info == NULL) 02474 return NULL; 02475 02476 AST_LIST_TRAVERSE_SAFE_BEGIN(&chan->datastores, datastore, entry) { 02477 if (datastore->info != info) { 02478 continue; 02479 } 02480 02481 if (uid == NULL) { 02482 /* matched by type only */ 02483 break; 02484 } 02485 02486 if ((datastore->uid != NULL) && !strcasecmp(uid, datastore->uid)) { 02487 /* Matched by type AND uid */ 02488 break; 02489 } 02490 } 02491 AST_LIST_TRAVERSE_SAFE_END; 02492 02493 return datastore; 02494 }
| int ast_channel_datastore_free | ( | struct ast_datastore * | datastore | ) |
Free a channel data store object.
Definition at line 2433 of file channel.c.
References ast_datastore_free().
02434 { 02435 return ast_datastore_free(datastore); 02436 }
| int ast_channel_datastore_inherit | ( | struct ast_channel * | from, | |
| struct ast_channel * | to | |||
| ) |
Inherit datastores from a parent to a child.
Definition at line 2438 of file channel.c.
References ast_datastore_alloc, AST_LIST_INSERT_TAIL, AST_LIST_TRAVERSE, ast_datastore::data, DATASTORE_INHERIT_FOREVER, ast_channel::datastores, ast_datastore_info::duplicate, ast_datastore::info, ast_datastore::inheritance, and ast_datastore::uid.
Referenced by __ast_request_and_dial(), ast_call_forward(), begin_dial_channel(), dial_exec_full(), do_forward(), findmeexec(), local_call(), ring_entry(), and wait_for_answer().
02439 { 02440 struct ast_datastore *datastore = NULL, *datastore2; 02441 02442 AST_LIST_TRAVERSE(&from->datastores, datastore, entry) { 02443 if (datastore->inheritance > 0) { 02444 datastore2 = ast_datastore_alloc(datastore->info, datastore->uid); 02445 if (datastore2) { 02446 datastore2->data = datastore->info->duplicate ? datastore->info->duplicate(datastore->data) : NULL; 02447 datastore2->inheritance = datastore->inheritance == DATASTORE_INHERIT_FOREVER ? DATASTORE_INHERIT_FOREVER : datastore->inheritance - 1; 02448 AST_LIST_INSERT_TAIL(&to->datastores, datastore2, entry); 02449 } 02450 } 02451 } 02452 return 0; 02453 }
| int ast_channel_datastore_remove | ( | struct ast_channel * | chan, | |
| struct ast_datastore * | datastore | |||
| ) |
Remove a datastore from a channel.
| 0 | success | |
| non-zero | failure |
Definition at line 2464 of file channel.c.
References AST_LIST_REMOVE, and ast_channel::datastores.
Referenced by acf_fetch(), acf_odbc_read(), adjust_frame_for_plc(), dial_exec_full(), disable_jack_hook(), exec_odbcfinish(), frame_trace_helper(), lua_get_state(), queue_transfer_fixup(), speech_background(), speech_destroy(), speex_write(), srv_query_read(), stop_mixmonitor_exec(), and try_calling().
02465 { 02466 return AST_LIST_REMOVE(&chan->datastores, datastore, entry) ? 0 : -1; 02467 }
| int ast_channel_defer_dtmf | ( | struct ast_channel * | chan | ) |
Set defer DTMF flag on channel.
Defers DTMF so that you only read things like hangups and audio.
Definition at line 1497 of file channel.c.
References AST_FLAG_DEFER_DTMF, ast_set_flag, and ast_test_flag.
Referenced by __adsi_transmit_messages(), and find_cache().
01498 { 01499 int pre = 0; 01500 01501 if (chan) { 01502 pre = ast_test_flag(chan, AST_FLAG_DEFER_DTMF); 01503 ast_set_flag(chan, AST_FLAG_DEFER_DTMF); 01504 } 01505 return pre; 01506 }
| static void ast_channel_destructor | ( | void * | obj | ) | [static] |
Free a channel structure.
Definition at line 2277 of file channel.c.
References ast_channel::alertpipe, ast_app_group_discard(), ast_cdr_discard(), AST_CEL_CHANNEL_END, ast_cel_check_retire_linkedid(), ast_cel_report_event(), ast_channel_lock, AST_CHANNEL_NAME, ast_channel_unlock, ast_copy_string(), ast_datastore_free(), AST_DEVICE_UNKNOWN, ast_devstate_changed_literal(), ast_free, ast_frfree, ast_jb_destroy(), AST_LIST_REMOVE_HEAD, ast_log(), AST_MAX_FDS, ast_moh_cleanup(), ast_party_caller_free(), ast_party_connected_line_free(), ast_party_dialed_free(), ast_party_redirecting_free(), ast_string_field_free_memory, ast_timer_close(), ast_tone_zone_unref(), ast_translator_free_path(), ast_var_delete(), ast_channel::caller, ast_channel::cdr, ast_channel::connected, ast_channel::datastores, ast_channel::dialed, free, LOG_WARNING, ast_channel::monitor, ast_channel::music_state, ast_channel::name, ast_channel::pbx, ast_channel::readq, ast_channel::readtrans, ast_channel::redirecting, ast_channel::sched, sched_context_destroy(), ast_channel_monitor::stop, ast_channel::tech_pvt, ast_channel::timer, ast_channel::varshead, ast_channel::writetrans, and ast_channel::zone.
Referenced by __ast_channel_alloc_ap().
02278 { 02279 struct ast_channel *chan = obj; 02280 int fd; 02281 #ifdef HAVE_EPOLL 02282 int i; 02283 #endif 02284 struct ast_var_t *vardata; 02285 struct ast_frame *f; 02286 struct varshead *headp; 02287 struct ast_datastore *datastore; 02288 char device_name[AST_CHANNEL_NAME]; 02289 02290 if (chan->name) { 02291 /* The string fields were initialized. */ 02292 ast_cel_report_event(chan, AST_CEL_CHANNEL_END, NULL, NULL, NULL); 02293 ast_cel_check_retire_linkedid(chan); 02294 } 02295 02296 /* Get rid of each of the data stores on the channel */ 02297 ast_channel_lock(chan); 02298 while ((datastore = AST_LIST_REMOVE_HEAD(&chan->datastores, entry))) 02299 /* Free the data store */ 02300 ast_datastore_free(datastore); 02301 ast_channel_unlock(chan); 02302 02303 /* Lock and unlock the channel just to be sure nobody has it locked still 02304 due to a reference that was stored in a datastore. (i.e. app_chanspy) */ 02305 ast_channel_lock(chan); 02306 ast_channel_unlock(chan); 02307 02308 if (chan->tech_pvt) { 02309 ast_log(LOG_WARNING, "Channel '%s' may not have been hung up properly\n", chan->name); 02310 ast_free(chan->tech_pvt); 02311 } 02312 02313 if (chan->sched) 02314 sched_context_destroy(chan->sched); 02315 02316 if (chan->name) { 02317 char *dashptr; 02318 02319 /* The string fields were initialized. */ 02320 ast_copy_string(device_name, chan->name, sizeof(device_name)); 02321 if ((dashptr = strrchr(device_name, '-'))) { 02322 *dashptr = '\0'; 02323 } 02324 } else { 02325 device_name[0] = '\0'; 02326 } 02327 02328 /* Stop monitoring */ 02329 if (chan->monitor) 02330 chan->monitor->stop( chan, 0 ); 02331 02332 /* If there is native format music-on-hold state, free it */ 02333 if (chan->music_state) 02334 ast_moh_cleanup(chan); 02335 02336 /* Free translators */ 02337 if (chan->readtrans) 02338 ast_translator_free_path(chan->readtrans); 02339 if (chan->writetrans) 02340 ast_translator_free_path(chan->writetrans); 02341 if (chan->pbx) 02342 ast_log(LOG_WARNING, "PBX may not have been terminated properly on '%s'\n", chan->name); 02343 02344 ast_party_dialed_free(&chan->dialed); 02345 ast_party_caller_free(&chan->caller); 02346 ast_party_connected_line_free(&chan->connected); 02347 ast_party_redirecting_free(&chan->redirecting); 02348 02349 /* Close pipes if appropriate */ 02350 if ((fd = chan->alertpipe[0]) > -1) 02351 close(fd); 02352 if ((fd = chan->alertpipe[1]) > -1) 02353 close(fd); 02354 if (chan->timer) { 02355 ast_timer_close(chan->timer); 02356 } 02357 #ifdef HAVE_EPOLL 02358 for (i = 0; i < AST_MAX_FDS; i++) { 02359 if (chan->epfd_data[i]) 02360 free(chan->epfd_data[i]); 02361 } 02362 close(chan->epfd); 02363 #endif 02364 while ((f = AST_LIST_REMOVE_HEAD(&chan->readq, frame_list))) 02365 ast_frfree(f); 02366 02367 /* loop over the variables list, freeing all data and deleting list items */ 02368 /* no need to lock the list, as the channel is already locked */ 02369 headp = &chan->varshead; 02370 while ((vardata = AST_LIST_REMOVE_HEAD(headp, entries))) 02371 ast_var_delete(vardata); 02372 02373 ast_app_group_discard(chan); 02374 02375 /* Destroy the jitterbuffer */ 02376 ast_jb_destroy(chan); 02377 02378 if (chan->cdr) { 02379 ast_cdr_discard(chan->cdr); 02380 chan->cdr = NULL; 02381 } 02382 02383 if (chan->zone) { 02384 chan->zone = ast_tone_zone_unref(chan->zone); 02385 } 02386 02387 ast_string_field_free_memory(chan); 02388 02389 if (device_name[0]) { 02390 /* 02391 * We have a device name to notify of a new state. 02392 * 02393 * Queue an unknown state, because, while we know that this particular 02394 * instance is dead, we don't know the state of all other possible 02395 * instances. 02396 */ 02397 ast_devstate_changed_literal(AST_DEVICE_UNKNOWN, device_name); 02398 } 02399 }
| int ast_channel_early_bridge | ( | struct ast_channel * | c0, | |
| struct ast_channel * | c1 | |||
| ) |
Bridge two channels together (early).
| c0 | first channel to bridge | |
| c1 | second channel to bridge |
Definition at line 6649 of file channel.c.
References ast_channel_tech::early_bridge, and ast_channel::tech.
Referenced by dial_exec_full(), and wait_for_answer().
06650 { 06651 /* Make sure we can early bridge, if not error out */ 06652 if (!c0->tech->early_bridge || (c1 && (!c1->tech->early_bridge || c0->tech->early_bridge != c1->tech->early_bridge))) 06653 return -1; 06654 06655 return c0->tech->early_bridge(c0, c1); 06656 }
| struct ast_channel* ast_channel_get_by_exten | ( | const char * | exten, | |
| const char * | context | |||
| ) | [read] |
Find a channel by extension and context.
| a | channel that is at the specified extension and context | |
| NULL | if no channel was found |
Definition at line 1694 of file channel.c.
References ast_channel_get_full().
01695 { 01696 return ast_channel_get_full(NULL, 0, exten, context); 01697 }
| struct ast_channel* ast_channel_get_by_name | ( | const char * | name | ) | [read] |
Find a channel by name.
Channel search functions
| a | channel with the name specified by the argument | |
| NULL | if no channel was found |
Definition at line 1684 of file channel.c.
References ast_channel_get_full().
Referenced by action_add_agi_cmd(), action_aocmessage(), action_atxfer(), action_getvar(), action_hangup(), action_redirect(), action_sendtext(), action_setvar(), action_status(), action_timeout(), ast_async_goto_by_name(), ast_bridge_call(), asyncgoto_exec(), change_monitor_action(), do_pause_or_unpause(), func_mchan_read(), func_mchan_write(), handle_channelstatus(), handle_cli_agi_add_cmd(), handle_core_set_debug_channel(), handle_getvariablefull(), handle_hangup(), handle_redirect(), handle_set_chanvar(), handle_show_chanvar(), handle_showchan(), handle_softhangup(), import_helper(), manager_mute_mixmonitor(), manager_mutestream(), manager_optimize_away(), manager_park(), manager_play_dtmf(), park_call_full(), pbx_builtin_importvar(), senddtmf_exec(), shared_read(), shared_write(), start_monitor_action(), and stop_monitor_action().
01685 { 01686 return ast_channel_get_full(name, 0, NULL, NULL); 01687 }
| struct ast_channel* ast_channel_get_by_name_prefix | ( | const char * | name, | |
| size_t | name_len | |||
| ) | [read] |
Find a channel by a name prefix.
| a | channel with the name prefix specified by the arguments | |
| NULL | if no channel was found |
Definition at line 1689 of file channel.c.
References ast_channel_get_full().
Referenced by action_aocmessage(), action_bridge(), ast_parse_device_state(), bridge_exec(), cc_generic_agent_stop_ringing(), common_exec(), handle_cli_mixmonitor(), shared_read(), and shared_write().
01690 { 01691 return ast_channel_get_full(name, name_len, NULL, NULL); 01692 }
| int ast_channel_get_cc_agent_type | ( | struct ast_channel * | chan, | |
| char * | agent_type, | |||
| size_t | size | |||
| ) |
Find the appropriate CC agent type to use given a channel.
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.
| chan | The channel for which we wish to retrieve the agent type | |
| [out] | agent_type | The type of agent the channel driver wants us to use |
| size | The size of the buffer to write to |
Definition at line 8957 of file channel.c.
References ast_channel_queryoption(), ast_copy_string(), AST_OPTION_CC_AGENT_TYPE, and ast_channel::name.
Referenced by find_agent_callbacks().
08958 { 08959 int len = size; 08960 char *slash; 08961 08962 if (!ast_channel_queryoption(chan, AST_OPTION_CC_AGENT_TYPE, agent_type, &len, 0)) { 08963 return 0; 08964 } 08965 08966 ast_copy_string(agent_type, chan->name, size); 08967 if ((slash = strchr(agent_type, '/'))) { 08968 *slash = '\0'; 08969 } 08970 return 0; 08971 }
| struct ast_cc_config_params* ast_channel_get_cc_config_params | ( | struct ast_channel * | chan | ) | [read] |
Get the CCSS parameters from a channel.
| chan | Channel to retrieve parameters from |
| NULL | Failure | |
| non-NULL | The parameters desired |
Definition at line 8918 of file channel.c.
References ast_assert, ast_channel_cc_params_init(), ast_channel_datastore_find(), and ast_datastore::data.
Referenced by acf_cc_read(), acf_cc_write(), analog_call(), ast_cc_call_failed(), ast_cc_call_init(), ast_queue_cc_frame(), cc_agent_init(), cc_core_init_instance(), find_agent_callbacks(), local_call(), local_request(), and sig_pri_cc_generic_check().
08919 { 08920 struct ast_datastore *cc_datastore; 08921 08922 if (!(cc_datastore = ast_channel_datastore_find(chan, &cc_channel_datastore_info, NULL))) { 08923 /* If we can't find the datastore, it almost definitely means that the channel type being 08924 * used has not had its driver modified to parse CC config parameters. The best action 08925 * to take here is to create the parameters on the spot with the defaults set. 08926 */ 08927 if (ast_channel_cc_params_init(chan, NULL)) { 08928 return NULL; 08929 } 08930 if (!(cc_datastore = ast_channel_datastore_find(chan, &cc_channel_datastore_info, NULL))) { 08931 /* Should be impossible */ 08932 return NULL; 08933 } 08934 } 08935 08936 ast_assert(cc_datastore->data != NULL); 08937 return cc_datastore->data; 08938 }
| int ast_channel_get_device_name | ( | struct ast_channel * | chan, | |
| char * | device_name, | |||
| size_t | name_buffer_length | |||
| ) |
Get a device name given its channel structure.
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.
| chan | The channel to retrieve the information from | |
| [out] | device_name | The buffer to place the device's name into |
| name_buffer_length | The allocated space for the device_name |
Definition at line 8940 of file channel.c.
References ast_channel_queryoption(), ast_copy_string(), AST_OPTION_DEVICE_NAME, and ast_channel::name.
Referenced by ast_cc_call_failed(), ast_cc_is_recall(), ast_queue_cc_frame(), cc_core_init_instance(), cccancel_exec(), ccreq_exec(), dial_exec_full(), sig_pri_call(), sig_pri_cc_generic_check(), sip_call(), and sip_handle_cc().
08941 { 08942 int len = name_buffer_length; 08943 char *dash; 08944 if (!ast_channel_queryoption(chan, AST_OPTION_DEVICE_NAME, device_name, &len, 0)) { 08945 return 0; 08946 } 08947 08948 /* Dang. Do it the old-fashioned way */ 08949 ast_copy_string(device_name, chan->name, name_buffer_length); 08950 if ((dash = strrchr(device_name, '-'))) { 08951 *dash = '\0'; 08952 } 08953 08954 return 0; 08955 }
| static struct ast_channel* ast_channel_get_full | ( | const char * | name, | |
| size_t | name_len, | |||
| const char * | exten, | |||
| const char * | context | |||
| ) | [static, read] |
Definition at line 1642 of file channel.c.
References ao2_find, ast_copy_string(), ast_strlen_zero(), channels, ast_channel::context, ast_channel::exten, ast_channel::name, OBJ_POINTER, and ast_channel::uniqueid.
Referenced by ast_channel_get_by_exten(), ast_channel_get_by_name(), and ast_channel_get_by_name_prefix().
01644 { 01645 struct ast_channel tmp_chan = { 01646 .name = name, 01647 /* This is sort of a hack. Basically, we're using an arbitrary field 01648 * in ast_channel to pass the name_len for a prefix match. If this 01649 * gets changed, then the compare callback must be changed, too. */ 01650 .rings = name_len, 01651 }; 01652 struct ast_channel *chan; 01653 01654 if (exten) { 01655 ast_copy_string(tmp_chan.exten, exten, sizeof(tmp_chan.exten)); 01656 } 01657 01658 if (context) { 01659 ast_copy_string(tmp_chan.context, context, sizeof(tmp_chan.context)); 01660 } 01661 01662 if ((chan = ao2_find(channels, &tmp_chan, 01663 (!ast_strlen_zero(name) && (name_len == 0)) ? OBJ_POINTER : 0))) { 01664 return chan; 01665 } 01666 01667 if (!name) { 01668 return NULL; 01669 } 01670 01671 /* If name was specified, but the result was NULL, 01672 * try a search on uniqueid, instead. */ 01673 01674 { 01675 struct ast_channel tmp_chan2 = { 01676 .uniqueid = name, 01677 .rings = name_len, 01678 }; 01679 01680 return ao2_find(channels, &tmp_chan2, 0); 01681 } 01682 }
| static int ast_channel_hash_cb | ( | const void * | obj, | |
| const int | flags | |||
| ) | [static] |
Definition at line 7273 of file channel.c.
References ast_str_case_hash(), ast_strlen_zero(), and ast_channel::name.
Referenced by ast_channels_init().
07274 { 07275 const struct ast_channel *chan = obj; 07276 07277 /* If the name isn't set, return 0 so that the ao2_find() search will 07278 * start in the first bucket. */ 07279 if (ast_strlen_zero(chan->name)) { 07280 return 0; 07281 } 07282 07283 return ast_str_case_hash(chan->name); 07284 }
| void ast_channel_inherit_variables | ( | const struct ast_channel * | parent, | |
| struct ast_channel * | child | |||
| ) |
Inherits channel variable from parent to child channel.
| parent | Parent channel | |
| child | Child channel |
Definition at line 5693 of file channel.c.
References ast_debug, AST_LIST_INSERT_TAIL, AST_LIST_TRAVERSE, ast_var_assign(), ast_var_full_name(), ast_var_name(), ast_var_value(), ast_var_t::entries, and ast_channel::varshead.
Referenced by __ast_request_and_dial(), ast_call_forward(), begin_dial_channel(), dial_exec_full(), dial_transfer(), do_forward(), feature_request_and_dial(), findmeexec(), ring_entry(), and wait_for_answer().
05694 { 05695 struct ast_var_t *current, *newvar; 05696 const char *varname; 05697 05698 AST_LIST_TRAVERSE(&parent->varshead, current, entries) { 05699 int vartype = 0; 05700 05701 varname = ast_var_full_name(current); 05702 if (!varname) 05703 continue; 05704 05705 if (varname[0] == '_') { 05706 vartype = 1; 05707 if (varname[1] == '_') 05708 vartype = 2; 05709 } 05710 05711 switch (vartype) { 05712 case 1: 05713 newvar = ast_var_assign(&varname[1], ast_var_value(current)); 05714 if (newvar) { 05715 AST_LIST_INSERT_TAIL(&child->varshead, newvar, entries); 05716 ast_debug(1, "Copying soft-transferable variable %s.\n", ast_var_name(newvar)); 05717 } 05718 break; 05719 case 2: 05720 newvar = ast_var_assign(varname, ast_var_value(current)); 05721 if (newvar) { 05722 AST_LIST_INSERT_TAIL(&child->varshead, newvar, entries); 05723 ast_debug(1, "Copying hard-transferable variable %s.\n", ast_var_name(newvar)); 05724 } 05725 break; 05726 default: 05727 ast_debug(1, "Not copying variable %s.\n", ast_var_name(current)); 05728 break; 05729 } 05730 } 05731 }
| struct ast_channel_iterator* ast_channel_iterator_all_new | ( | void | ) | [read] |
Create a new channel iterator.
After creating an iterator using this function, the ast_channel_iterator_next() function can be used to iterate through all channels that exist.
| NULL | on failure | |
| a | new channel iterator |
Definition at line 1582 of file channel.c.
References ast_channel_iterator::active_iterator, ao2_iterator_init(), ast_calloc, channels, and ast_channel_iterator::simple_iterator.
Referenced by action_coreshowchannels(), action_status(), ast_complete_channels(), ast_var_channel_bridge(), ast_var_channel_types_table(), ast_var_channels_table(), common_exec(), data_channels_provider_handler(), func_channels_read(), handle_chanlist(), and handle_softhangup().
01583 { 01584 struct ast_channel_iterator *i; 01585 01586 if (!(i = ast_calloc(1, sizeof(*i)))) { 01587 return NULL; 01588 } 01589 01590 i->simple_iterator = ao2_iterator_init(channels, 0); 01591 i->active_iterator = &i->simple_iterator; 01592 01593 return i; 01594 }
| struct ast_channel_iterator* ast_channel_iterator_by_exten_new | ( | const char * | exten, | |
| const char * | context | |||
| ) | [read] |
Create a new channel iterator based on extension.
| NULL | on failure | |
| a | new channel iterator based on the specified parameters |
Definition at line 1572 of file channel.c.
References channel_iterator_search().
Referenced by common_exec(), and pickup_by_exten().
01573 { 01574 return channel_iterator_search(NULL, 0, exten, context); 01575 }
| struct ast_channel_iterator* ast_channel_iterator_by_name_new | ( | const char * | name, | |
| size_t | name_len | |||
| ) | [read] |
Create a new channel iterator based on name.
| NULL | on failure | |
| a | new channel iterator based on the specified parameters |
Definition at line 1577 of file channel.c.
References channel_iterator_search().
Referenced by ast_complete_channels(), common_exec(), and softhangup_exec().
01578 { 01579 return channel_iterator_search(name, name_len, NULL, NULL); 01580 }
| struct ast_channel_iterator* ast_channel_iterator_destroy | ( | struct ast_channel_iterator * | i | ) | [read] |
Destroy a channel iterator.
Definition at line 1530 of file channel.c.
References ast_channel_iterator::active_iterator, ao2_iterator_destroy(), and ast_free.
Referenced by action_coreshowchannels(), action_status(), ast_complete_channels(), ast_var_channel_bridge(), ast_var_channel_types_table(), ast_var_channels_table(), common_exec(), data_channels_provider_handler(), func_channels_read(), handle_chanlist(), handle_softhangup(), pickup_by_exten(), and softhangup_exec().
01531 { 01532 ao2_iterator_destroy(i->active_iterator); 01533 ast_free(i); 01534 01535 return NULL; 01536 }
| struct ast_channel* ast_channel_iterator_next | ( | struct ast_channel_iterator * | i | ) | [read] |
Get the next channel for a channel iterator.
| the | next channel that matches the parameters used when the iterator was created. | |
| NULL,if | no more channels match the iterator parameters. |
Definition at line 1596 of file channel.c.
References ast_channel_iterator::active_iterator, and ao2_iterator_next.
Referenced by action_coreshowchannels(), action_status(), ast_complete_channels(), ast_var_channel_bridge(), ast_var_channel_types_table(), ast_var_channels_table(), data_channels_provider_handler(), func_channels_read(), handle_chanlist(), handle_softhangup(), next_channel(), pickup_by_exten(), and softhangup_exec().
01597 { 01598 return ao2_iterator_next(i->active_iterator); 01599 }
| int ast_channel_make_compatible | ( | struct ast_channel * | c0, | |
| struct ast_channel * | c1 | |||
| ) |
Makes two channel formats compatible.
| c0 | first channel to make compatible | |
| c1 | other channel to make compatible |
Definition at line 5569 of file channel.c.
References ast_channel_make_compatible_helper().
Referenced by action_bridge(), app_exec(), ast_channel_bridge(), bridge_exec(), check_compat(), dial_exec_full(), do_forward(), multiplexed_bridge_join(), park_exec_full(), simple_bridge_join(), try_calling(), and wait_for_answer().
05570 { 05571 /* Some callers do not check return code, and we must try to set all call legs correctly */ 05572 int rc = 0; 05573 05574 /* Set up translation from the chan to the peer */ 05575 rc = ast_channel_make_compatible_helper(chan, peer); 05576 05577 if (rc < 0) 05578 return rc; 05579 05580 /* Set up translation from the peer to the chan */ 05581 rc = ast_channel_make_compatible_helper(peer, chan); 05582 05583 return rc; 05584 }
| static int ast_channel_make_compatible_helper | ( | struct ast_channel * | from, | |
| struct ast_channel * | to | |||
| ) | [static] |
Set up translation from one channel to another.
Definition at line 5519 of file channel.c.
References ast_channel_setoption(), AST_FORMAT_AUDIO_MASK, AST_FORMAT_SLINEAR, ast_getformatname(), ast_log(), ast_opt_generic_plc, ast_opt_transcode_via_slin, AST_OPTION_MAKE_COMPATIBLE, ast_set_read_format(), ast_set_write_format(), ast_translate_path_steps(), ast_translator_best_choice(), ast_channel_tech::bridge, LOG_WARNING, ast_channel::name, ast_channel::nativeformats, ast_channel::readformat, ast_channel::tech, and ast_channel::writeformat.
Referenced by ast_channel_make_compatible().
05520 { 05521 format_t src, dst; 05522 int use_slin; 05523 05524 /* See if the channel driver can natively make these two channels compatible */ 05525 if (from->tech->bridge && from->tech->bridge == to->tech->bridge && 05526 !ast_channel_setoption(from, AST_OPTION_MAKE_COMPATIBLE, to, sizeof(struct ast_channel *), 0)) { 05527 return 0; 05528 } 05529 05530 if (from->readformat == to->writeformat && from->writeformat == to->readformat) { 05531 /* Already compatible! Moving on ... */ 05532 return 0; 05533 } 05534 05535 /* Set up translation from the 'from' channel to the 'to' channel */ 05536 src = from->nativeformats; 05537 dst = to->nativeformats; 05538 05539 /* If there's no audio in this call, don't bother with trying to find a translation path */ 05540 if ((src & AST_FORMAT_AUDIO_MASK) == 0 || (dst & AST_FORMAT_AUDIO_MASK) == 0) 05541 return 0; 05542 05543 if (ast_translator_best_choice(&dst, &src) < 0) { 05544 ast_log(LOG_WARNING, "No path to translate from %s to %s\n", from->name, to->name); 05545 return -1; 05546 } 05547 05548 /* if the best path is not 'pass through', then 05549 * transcoding is needed; if desired, force transcode path 05550 * to use SLINEAR between channels, but only if there is 05551 * no direct conversion available. If generic PLC is 05552 * desired, then transcoding via SLINEAR is a requirement 05553 */ 05554 use_slin = (src == AST_FORMAT_SLINEAR || dst == AST_FORMAT_SLINEAR); 05555 if ((src != dst) && (ast_opt_generic_plc || ast_opt_transcode_via_slin) && 05556 (ast_translate_path_steps(dst, src) != 1 || use_slin)) 05557 dst = AST_FORMAT_SLINEAR; 05558 if (ast_set_read_format(from, dst) < 0) { 05559 ast_log(LOG_WARNING, "Unable to set read format on channel %s to %s\n", from->name, ast_getformatname(dst)); 05560 return -1; 05561 } 05562 if (ast_set_write_format(to, dst) < 0) { 05563 ast_log(LOG_WARNING, "Unable to set write format on channel %s to %s\n", to->name, ast_getformatname(dst)); 05564 return -1; 05565 } 05566 return 0; 05567 }
| int ast_channel_masquerade | ( | struct ast_channel * | original, | |
| struct ast_channel * | clone | |||
| ) |
Weird function made for call transfers.
| original | channel to make a copy of | |
| clone | copy of the original channel |
Definition at line 5586 of file channel.c.
References ast_channel::_bridge, ast_bridged_channel(), ast_channel_lock, ast_channel_trylock, ast_channel_unlock, ast_debug, ast_log(), ast_null_frame, ast_queue_frame(), ast_channel_tech::get_base_channel, LOG_WARNING, ast_channel::masq, ast_channel::masqr, ast_channel::name, and ast_channel::tech.
Referenced by analog_attempt_transfer(), ast_async_goto(), ast_pickup_call(), attempt_transfer(), builtin_atxfer(), check_availability(), check_bridge(), check_goto_on_transfer(), do_bridge_masquerade(), handle_invite_replaces(), iax_park(), masq_park_call(), misdn_attempt_transfer(), pickup_do(), sig_pri_attempt_transfer(), sip_park(), and skinny_transfer().
05587 { 05588 int res = -1; 05589 struct ast_channel *final_orig, *final_clone, *base; 05590 05591 retrymasq: 05592 final_orig = original; 05593 final_clone = clonechan; 05594 05595 ast_channel_lock(original); 05596 while (ast_channel_trylock(clonechan)) { 05597 ast_channel_unlock(original); 05598 usleep(1); 05599 ast_channel_lock(original); 05600 } 05601 05602 /* each of these channels may be sitting behind a channel proxy (i.e. chan_agent) 05603 and if so, we don't really want to masquerade it, but its proxy */ 05604 if (original->_bridge && (original->_bridge != ast_bridged_channel(original)) && (original->_bridge->_bridge != original)) 05605 final_orig = original->_bridge; 05606 05607 if (clonechan->_bridge && (clonechan->_bridge != ast_bridged_channel(clonechan)) && (clonechan->_bridge->_bridge != clonechan)) 05608 final_clone = clonechan->_bridge; 05609 05610 if (final_clone->tech->get_base_channel && (base = final_clone->tech->get_base_channel(final_clone))) { 05611 final_clone = base; 05612 } 05613 05614 if ((final_orig != original) || (final_clone != clonechan)) { 05615 /* Lots and lots of deadlock avoidance. The main one we're competing with 05616 * is ast_write(), which locks channels recursively, when working with a 05617 * proxy channel. */ 05618 if (ast_channel_trylock(final_orig)) { 05619 ast_channel_unlock(clonechan); 05620 ast_channel_unlock(original); 05621 goto retrymasq; 05622 } 05623 if (ast_channel_trylock(final_clone)) { 05624 ast_channel_unlock(final_orig); 05625 ast_channel_unlock(clonechan); 05626 ast_channel_unlock(original); 05627 goto retrymasq; 05628 } 05629 ast_channel_unlock(clonechan); 05630 ast_channel_unlock(original); 05631 original = final_orig; 05632 clonechan = final_clone; 05633 } 05634 05635 if (original == clonechan) { 05636 ast_log(LOG_WARNING, "Can't masquerade channel '%s' into itself!\n", original->name); 05637 ast_channel_unlock(clonechan); 05638 ast_channel_unlock(original); 05639 return -1; 05640 } 05641 05642 ast_debug(1, "Planning to masquerade channel %s into the structure of %s\n", 05643 clonechan->name, original->name); 05644 05645 if (!original->masqr && !original->masq && !clonechan->masq && !clonechan->masqr) { 05646 original->masq = clonechan; 05647 clonechan->masqr = original; 05648 ast_queue_frame(original, &ast_null_frame); 05649 ast_queue_frame(clonechan, &ast_null_frame); 05650 ast_debug(1, "Done planning to masquerade channel %s into the structure of %s\n", clonechan->name, original->name); 05651 res = 0; 05652 } else if (original->masq) { 05653 ast_log(LOG_WARNING, "%s is already going to masquerade as %s\n", 05654 original->masq->name, original->name); 05655 } else if (original->masqr) { 05656 /* not yet as a previously planned masq hasn't yet happened */ 05657 ast_log(LOG_WARNING, "%s is already going to masquerade as %s\n", 05658 original->name, original->masqr->name); 05659 } else if (clonechan->masq) { 05660 ast_log(LOG_WARNING, "%s is already going to masquerade as %s\n", 05661 clonechan->masq->name, clonechan->name); 05662 } else { /* (clonechan->masqr) */ 05663 ast_log(LOG_WARNING, "%s is already going to masquerade as %s\n", 05664 clonechan->name, clonechan->masqr->name); 05665 } 05666 05667 ast_channel_unlock(clonechan); 05668 ast_channel_unlock(original); 05669 05670 return res; 05671 }
| int ast_channel_queryoption | ( | struct ast_channel * | channel, | |
| int | option, | |||
| void * | data, | |||
| int * | datalen, | |||
| int | block | |||
| ) |
Checks the value of an option.
Query the value of an option Works similarly to setoption except only reads the options.
Definition at line 7032 of file channel.c.
References ast_log(), errno, LOG_ERROR, ast_channel_tech::queryoption, and ast_channel::tech.
Referenced by ast_channel_get_cc_agent_type(), ast_channel_get_device_name(), ast_channel_get_t38_state(), local_queryoption(), rcvfax_exec(), and sndfax_exec().
07033 { 07034 if (!chan->tech->queryoption) { 07035 errno = ENOSYS; 07036 return -1; 07037 } 07038 07039 if (block) 07040 ast_log(LOG_ERROR, "XXX Blocking not implemented yet XXX\n"); 07041 07042 return chan->tech->queryoption(chan, option, data, datalen); 07043 }
| void ast_channel_queue_connected_line_update | ( | struct ast_channel * | chan, | |
| const struct ast_party_connected_line * | connected, | |||
| const struct ast_set_party_connected_line * | update | |||
| ) |
Queue a connected line update frame on a channel.
| chan | Asterisk channel to indicate connected line information | |
| connected | Connected line information | |
| update | What connected line information to update. NULL if all. |
Definition at line 8273 of file channel.c.
References ast_connected_line_build_data(), AST_CONTROL_CONNECTED_LINE, and ast_queue_control_data().
Referenced by ast_pickup_call(), handle_request_invite(), handle_request_update(), handle_response_invite(), local_attended_transfer(), misdn_queue_connected_line_update(), pickup_do(), and sig_pri_handle_subcmds().
08274 { 08275 unsigned char data[1024]; /* This should be large enough */ 08276 size_t datalen; 08277 08278 datalen = ast_connected_line_build_data(data, sizeof(data), connected, update); 08279 if (datalen == (size_t) -1) { 08280 return; 08281 } 08282 08283 ast_queue_control_data(chan, AST_CONTROL_CONNECTED_LINE, data, datalen); 08284 }
| void ast_channel_queue_redirecting_update | ( | struct ast_channel * | chan, | |
| const struct ast_party_redirecting * | redirecting, | |||
| const struct ast_set_party_redirecting * | update | |||
| ) |
Queue a redirecting update frame on a channel.
| chan | Asterisk channel to indicate redirecting id information | |
| redirecting | Redirecting id information | |
| update | What redirecting information to update. NULL if all. |
Definition at line 8780 of file channel.c.
References AST_CONTROL_REDIRECTING, ast_queue_control_data(), and ast_redirecting_build_data().
Referenced by cb_events(), handle_response_invite(), misdn_facility_ie_handler(), and sig_pri_handle_subcmds().
08781 { 08782 unsigned char data[1024]; /* This should be large enough */ 08783 size_t datalen; 08784 08785 datalen = ast_redirecting_build_data(data, sizeof(data), redirecting, update); 08786 if (datalen == (size_t) -1) { 08787 return; 08788 } 08789 08790 ast_queue_control_data(chan, AST_CONTROL_REDIRECTING, data, datalen); 08791 }
| const char* ast_channel_reason2str | ( | int | reason | ) |
return an english explanation of the code returned thru __ast_request_and_dial's 'outstate' argument
| reason | The integer argument, usually taken from AST_CONTROL_ macros |
Definition at line 4973 of file channel.c.
References AST_CONTROL_ANSWER, AST_CONTROL_BUSY, AST_CONTROL_CONGESTION, AST_CONTROL_HANGUP, AST_CONTROL_RING, and AST_CONTROL_RINGING.
Referenced by attempt_thread().
04974 { 04975 switch (reason) /* the following appear to be the only ones actually returned by request_and_dial */ 04976 { 04977 case 0: 04978 return "Call Failure (not BUSY, and not NO_ANSWER, maybe Circuit busy or down?)"; 04979 case AST_CONTROL_HANGUP: 04980 return "Hangup"; 04981 case AST_CONTROL_RING: 04982 return "Local Ring"; 04983 case AST_CONTROL_RINGING: 04984 return "Remote end Ringing"; 04985 case AST_CONTROL_ANSWER: 04986 return "Remote end has Answered"; 04987 case AST_CONTROL_BUSY: 04988 return "Remote end is Busy"; 04989 case AST_CONTROL_CONGESTION: 04990 return "Congestion (circuits busy)"; 04991 default: 04992 return "Unknown Reason!!"; 04993 } 04994 }
| int ast_channel_redirecting_macro | ( | struct ast_channel * | autoservice_chan, | |
| struct ast_channel * | macro_chan, | |||
| const void * | redirecting_info, | |||
| int | is_caller, | |||
| int | is_frame | |||
| ) |
Run a redirecting interception macro and update a channel's redirecting information.
| autoservice_chan | Channel to place into autoservice while the macro is running. It is perfectly safe for this to be NULL | |
| macro_chan | The channel to run the macro on. Also the channel from which we determine which macro we need to run. | |
| redirecting_info | Either an ast_party_redirecting or ast_frame pointer of type AST_CONTROL_REDIRECTING | |
| is_caller | If true, then run REDIRECTING_CALLER_SEND_MACRO, otherwise run REDIRECTING_CALLEE_SEND_MACRO | |
| is_frame | If true, then redirecting_info is an ast_frame pointer, otherwise it is an ast_party_redirecting pointer. |
| 0 | Success | |
| -1 | Either the macro does not exist, or there was an error while attempting to run the macro |
Make constants so that caller and frame can be more expressive than just '1' and '0'
Definition at line 8832 of file channel.c.
References ast_app_run_macro(), ast_channel_lock, ast_channel_unlock, ast_channel_update_redirecting(), ast_party_redirecting_copy(), ast_redirecting_parse_data(), ast_strdupa, ast_strlen_zero(), ast_frame::data, ast_frame::datalen, pbx_builtin_getvar_helper(), ast_frame::ptr, ast_channel::redirecting, and S_OR.
Referenced by ast_bridge_call(), ast_generic_bridge(), do_forward(), feature_request_and_dial(), handle_frame(), local_bridge_loop(), remote_bridge_loop(), and wait_for_answer().
08833 { 08834 const char *macro; 08835 const char *macro_args; 08836 int retval; 08837 08838 ast_channel_lock(macro_chan); 08839 macro = pbx_builtin_getvar_helper(macro_chan, is_caller 08840 ? "REDIRECTING_CALLER_SEND_MACRO" : "REDIRECTING_CALLEE_SEND_MACRO"); 08841 macro = ast_strdupa(S_OR(macro, "")); 08842 macro_args = pbx_builtin_getvar_helper(macro_chan, is_caller 08843 ? "REDIRECTING_CALLER_SEND_MACRO_ARGS" : "REDIRECTING_CALLEE_SEND_MACRO_ARGS"); 08844 macro_args = ast_strdupa(S_OR(macro_args, "")); 08845 08846 if (ast_strlen_zero(macro)) { 08847 ast_channel_unlock(macro_chan); 08848 return -1; 08849 } 08850 08851 if (is_frame) { 08852 const struct ast_frame *frame = redirecting_info; 08853 08854 ast_redirecting_parse_data(frame->data.ptr, frame->datalen, ¯o_chan->redirecting); 08855 } else { 08856 const struct ast_party_redirecting *redirecting = redirecting_info; 08857 08858 ast_party_redirecting_copy(¯o_chan->redirecting, redirecting); 08859 } 08860 ast_channel_unlock(macro_chan); 08861 08862 retval = ast_app_run_macro(autoservice_chan, macro_chan, macro, macro_args); 08863 if (!retval) { 08864 ast_channel_lock(macro_chan); 08865 ast_channel_update_redirecting(macro_chan, ¯o_chan->redirecting, NULL); 08866 ast_channel_unlock(macro_chan); 08867 } 08868 08869 return retval; 08870 }
| int ast_channel_register | ( | const struct ast_channel_tech * | tech | ) |
Register a new telephony channel in Asterisk.
Register a channel technology (a new channel driver) Called by a channel module to register the kind of channels it supports.
Definition at line 837 of file channel.c.
References ast_calloc, ast_debug, ast_log(), AST_RWLIST_INSERT_HEAD, AST_RWLIST_TRAVERSE, AST_RWLIST_UNLOCK, AST_RWLIST_WRLOCK, ast_verb, ast_channel_tech::description, LOG_WARNING, chanlist::tech, and ast_channel_tech::type.
Referenced by load_module(), and unload_module().
00838 { 00839 struct chanlist *chan; 00840 00841 AST_RWLIST_WRLOCK(&backends); 00842 00843 AST_RWLIST_TRAVERSE(&backends, chan, list) { 00844 if (!strcasecmp(tech->type, chan->tech->type)) { 00845 ast_log(LOG_WARNING, "Already have a handler for type '%s'\n", tech->type); 00846 AST_RWLIST_UNLOCK(&backends); 00847 return -1; 00848 } 00849 } 00850 00851 if (!(chan = ast_calloc(1, sizeof(*chan)))) { 00852 AST_RWLIST_UNLOCK(&backends); 00853 return -1; 00854 } 00855 chan->tech = tech; 00856 AST_RWLIST_INSERT_HEAD(&backends, chan, list); 00857 00858 ast_debug(1, "Registered handler for '%s' (%s)\n", chan->tech->type, chan->tech->description); 00859 00860 ast_verb(2, "Registered channel type '%s' (%s)\n", chan->tech->type, chan->tech->description); 00861 00862 AST_RWLIST_UNLOCK(&backends); 00863 00864 return 0; 00865 }
| struct ast_channel* ast_channel_release | ( | struct ast_channel * | chan | ) | [read] |
Unlink and release reference to a channel.
This function will unlink the channel from the global channels container if it is still there and also release the current reference to the channel.
Definition at line 1798 of file channel.c.
References ao2_unlink, ast_channel_unref, and channels.
Referenced by acf_odbc_read(), acf_odbc_write(), action_getvar(), agent_cleanup(), agent_new(), ast_add_extension2_lockopt(), ast_cel_fabricate_channel_from_event(), ast_do_masquerade(), ast_hangup(), ast_iax2_new(), ast_pbx_outgoing_cdr_failed(), ast_request(), ast_str_substitute_variables_full(), bridge_request(), cli_odbc_read(), cli_odbc_write(), custom_log(), do_notify(), gtalk_newcall(), local_new(), local_request(), make_email_file(), manager_log(), pbx_substitute_variables_helper_full(), rotate_file(), sendmail(), sendpage(), syslog_log(), and write_cdr().
01799 { 01800 /* Safe, even if already unlinked. */ 01801 ao2_unlink(channels, chan); 01802 return ast_channel_unref(chan); 01803 }
| int ast_channel_sendhtml | ( | struct ast_channel * | channel, | |
| int | subclass, | |||
| const char * | data, | |||
| int | datalen | |||
| ) |
Sends HTML on given channel Send HTML or URL on link.
Definition at line 5506 of file channel.c.
References ast_channel_tech::send_html, and ast_channel::tech.
Referenced by agent_sendhtml(), ast_channel_sendurl(), and wait_for_answer().
05507 { 05508 if (chan->tech->send_html) 05509 return chan->tech->send_html(chan, subclass, data, datalen); 05510 return -1; 05511 }
| int ast_channel_sendurl | ( | struct ast_channel * | channel, | |
| const char * | url | |||
| ) |
Sends a URL on a given link Send URL on link.
Definition at line 5513 of file channel.c.
References ast_channel_sendhtml(), and AST_HTML_URL.
Referenced by dial_exec_full(), sendurl_exec(), and try_calling().
05514 { 05515 return ast_channel_sendhtml(chan, AST_HTML_URL, url, strlen(url) + 1); 05516 }
| void ast_channel_set_caller | ( | struct ast_channel * | chan, | |
| const struct ast_party_caller * | caller, | |||
| const struct ast_set_party_caller * | update | |||
| ) |
Set the caller id information in the Asterisk channel.
| chan | Asterisk channel to set caller id information | |
| caller | Caller id information | |
| update | What caller information to update. NULL if all. |
Definition at line 6334 of file channel.c.
References ast_channel_lock, ast_channel_unlock, ast_party_caller_set(), and ast_channel::caller.
06335 { 06336 if (&chan->caller == caller) { 06337 /* Don't set to self */ 06338 return; 06339 } 06340 06341 ast_channel_lock(chan); 06342 ast_party_caller_set(&chan->caller, caller, update); 06343 ast_channel_unlock(chan); 06344 }
| void ast_channel_set_caller_event | ( | struct ast_channel * | chan, | |
| const struct ast_party_caller * | caller, | |||
| const struct ast_set_party_caller * | update | |||
| ) |
Set the caller id information in the Asterisk channel and generate an AMI event if the caller id name or number changed.
| chan | Asterisk channel to set caller id information | |
| caller | Caller id information | |
| update | What caller information to update. NULL if all. |
Definition at line 6346 of file channel.c.
References ast_cdr_setcid(), ast_channel_lock, ast_channel_unlock, ast_party_caller_set(), ast_channel::caller, ast_channel::cdr, ast_party_caller::id, ast_party_id::name, ast_party_id::number, report_new_callerid(), S_COR, ast_party_name::str, ast_party_number::str, ast_party_name::valid, and ast_party_number::valid.
Referenced by callerid_write(), dial_exec_full(), misdn_update_caller_id(), and ring_entry().
06347 { 06348 struct ast_party_caller pre_set; 06349 06350 if (&chan->caller == caller) { 06351 /* Don't set to self */ 06352 return; 06353 } 06354 06355 ast_channel_lock(chan); 06356 pre_set = chan->caller; 06357 ast_party_caller_set(&chan->caller, caller, update); 06358 if (S_COR(pre_set.id.number.valid, pre_set.id.number.str, NULL) 06359 != S_COR(chan->caller.id.number.valid, chan->caller.id.number.str, NULL) 06360 || S_COR(pre_set.id.name.valid, pre_set.id.name.str, NULL) 06361 != S_COR(chan->caller.id.name.valid, chan->caller.id.name.str, NULL)) { 06362 /* The caller id name or number changed. */ 06363 report_new_callerid(chan); 06364 } 06365 if (chan->cdr) { 06366 ast_cdr_setcid(chan->cdr, chan); 06367 } 06368 ast_channel_unlock(chan); 06369 }
| void ast_channel_set_connected_line | ( | struct ast_channel * | chan, | |
| const struct ast_party_connected_line * | connected, | |||
| const struct ast_set_party_connected_line * | update | |||
| ) |
Set the connected line information in the Asterisk channel.
| chan | Asterisk channel to set connected line information | |
| connected | Connected line information | |
| update | What connected line information to update. NULL if all. |
Definition at line 7633 of file channel.c.
References ast_channel_lock, ast_channel_unlock, ast_party_connected_line_set(), and ast_channel::connected.
Referenced by __ast_request_and_dial(), ast_indicate_data(), connectedline_write(), and dial_exec_full().
07634 { 07635 if (&chan->connected == connected) { 07636 /* Don't set to self */ 07637 return; 07638 } 07639 07640 ast_channel_lock(chan); 07641 ast_party_connected_line_set(&chan->connected, connected, update); 07642 ast_channel_unlock(chan); 07643 }
| void ast_channel_set_fd | ( | struct ast_channel * | chan, | |
| int | which, | |||
| int | fd | |||
| ) |
Set the file descriptor on the channel
Definition at line 2497 of file channel.c.
References ast_calloc, ast_epoll_data::chan, ast_channel::fds, free, and ast_epoll_data::which.
Referenced by __ast_channel_alloc_ap(), __oh323_new(), __oh323_rtp_create(), __oh323_update_info(), alsa_new(), ast_deactivate_generator(), ast_do_masquerade(), dahdi_new(), gtalk_new(), jingle_new(), mgcp_new(), misdn_new(), my_swap_subchannels(), nbs_new(), oss_new(), phone_new(), setformat(), sip_new(), skinny_new(), start_rtp(), and swap_subs().
02498 { 02499 #ifdef HAVE_EPOLL 02500 struct epoll_event ev; 02501 struct ast_epoll_data *aed = NULL; 02502 02503 if (chan->fds[which] > -1) { 02504 epoll_ctl(chan->epfd, EPOLL_CTL_DEL, chan->fds[which], &ev); 02505 aed = chan->epfd_data[which]; 02506 } 02507 02508 /* If this new fd is valid, add it to the epoll */ 02509 if (fd > -1) { 02510 if (!aed && (!(aed = ast_calloc(1, sizeof(*aed))))) 02511 return; 02512 02513 chan->epfd_data[which] = aed; 02514 aed->chan = chan; 02515 aed->which = which; 02516 02517 ev.events = EPOLLIN | EPOLLPRI | EPOLLERR | EPOLLHUP; 02518 ev.data.ptr = aed; 02519 epoll_ctl(chan->epfd, EPOLL_CTL_ADD, fd, &ev); 02520 } else if (aed) { 02521 /* We don't have to keep around this epoll data structure now */ 02522 free(aed); 02523 chan->epfd_data[which] = NULL; 02524 } 02525 #endif 02526 chan->fds[which] = fd; 02527 return; 02528 }
| void ast_channel_set_linkgroup | ( | struct ast_channel * | chan, | |
| struct ast_channel * | peer | |||
| ) |
Propagate the oldest linkedid between associated channels.
propagate the linked id between chan and peer
Definition at line 5837 of file channel.c.
References ast_channel::_bridge, ast_bridged_channel(), ast_channel_change_linkedid(), ast_strdupa, ast_channel::linkedid, oldest_linkedid(), and ast_channel::uniqueid.
Referenced by ast_bridge_call(), and ast_do_masquerade().
05838 { 05839 const char* linkedid=NULL; 05840 struct ast_channel *bridged; 05841 05842 linkedid = oldest_linkedid(chan->linkedid, peer->linkedid); 05843 linkedid = oldest_linkedid(linkedid, chan->uniqueid); 05844 linkedid = oldest_linkedid(linkedid, peer->uniqueid); 05845 if (chan->_bridge) { 05846 bridged = ast_bridged_channel(chan); 05847 if (bridged != peer) { 05848 linkedid = oldest_linkedid(linkedid, bridged->linkedid); 05849 linkedid = oldest_linkedid(linkedid, bridged->uniqueid); 05850 } 05851 } 05852 if (peer->_bridge) { 05853 bridged = ast_bridged_channel(peer); 05854 if (bridged != chan) { 05855 linkedid = oldest_linkedid(linkedid, bridged->linkedid); 05856 linkedid = oldest_linkedid(linkedid, bridged->uniqueid); 05857 } 05858 } 05859 05860 /* just in case setting a stringfield to itself causes problems */ 05861 linkedid = ast_strdupa(linkedid); 05862 05863 ast_channel_change_linkedid(chan, linkedid); 05864 ast_channel_change_linkedid(peer, linkedid); 05865 if (chan->_bridge) { 05866 bridged = ast_bridged_channel(chan); 05867 if (bridged != peer) { 05868 ast_channel_change_linkedid(bridged, linkedid); 05869 } 05870 } 05871 if (peer->_bridge) { 05872 bridged = ast_bridged_channel(peer); 05873 if (bridged != chan) { 05874 ast_channel_change_linkedid(bridged, linkedid); 05875 } 05876 } 05877 }
| void ast_channel_set_redirecting | ( | struct ast_channel * | chan, | |
| const struct ast_party_redirecting * | redirecting, | |||
| const struct ast_set_party_redirecting * | update | |||
| ) |
Set the redirecting id information in the Asterisk channel.
| chan | Asterisk channel to set redirecting id information | |
| redirecting | Redirecting id information | |
| update | What redirecting information to update. NULL if all. |
Definition at line 8286 of file channel.c.
References ast_channel_lock, ast_channel_unlock, ast_party_redirecting_set(), and ast_channel::redirecting.
Referenced by ast_call_forward(), ast_indicate_data(), do_forward(), handle_request_invite(), handle_response(), misdn_copy_redirecting_to_ast(), redirecting_write(), sig_pri_handle_subcmds(), and wait_for_answer().
08287 { 08288 if (&chan->redirecting == redirecting) { 08289 /* Don't set to self */ 08290 return; 08291 } 08292 08293 ast_channel_lock(chan); 08294 ast_party_redirecting_set(&chan->redirecting, redirecting, update); 08295 ast_channel_unlock(chan); 08296 }
| int ast_channel_setoption | ( | struct ast_channel * | channel, | |
| int | option, | |||
| void * | data, | |||
| int | datalen, | |||
| int | block | |||
| ) |
Sets an option on a channel.
| channel | channel to set options on | |
| option | option to change | |
| data | data specific to option | |
| datalen | length of the data | |
| block | blocking or not |
Definition at line 7019 of file channel.c.
References ast_log(), errno, LOG_ERROR, ast_channel_tech::setoption, and ast_channel::tech.
Referenced by analog_hangup(), ast_bridge_call(), ast_channel_make_compatible_helper(), common_exec(), conf_run(), dahdi_hangup(), dial_exec_full(), func_channel_write(), func_channel_write_real(), handle_tddmode(), play_record_review(), rcvfax_exec(), reset_volumes(), rpt(), rpt_exec(), set_format(), set_listen_volume(), set_security_requirements(), set_talk_volume(), sndfax_exec(), try_calling(), and vm_forwardoptions().
07020 { 07021 if (!chan->tech->setoption) { 07022 errno = ENOSYS; 07023 return -1; 07024 } 07025 07026 if (block) 07027 ast_log(LOG_ERROR, "XXX Blocking not implemented yet XXX\n"); 07028 07029 return chan->tech->setoption(chan, option, data, datalen); 07030 }
| void ast_channel_setwhentohangup | ( | struct ast_channel * | chan, | |
| time_t | offset | |||
| ) |
Set when to hang a channel up.
| chan | channel on which to check for hang up | |
| offset | offset in seconds relative to the current time of when to hang up |
Definition at line 808 of file channel.c.
References ast_channel_setwhentohangup_tv().
00809 { 00810 struct timeval when = { offset, }; 00811 ast_channel_setwhentohangup_tv(chan, when); 00812 }
| void ast_channel_setwhentohangup_tv | ( | struct ast_channel * | chan, | |
| struct timeval | offset | |||
| ) |
Set when to hangup channel.
Set when to hang a channel up.
Definition at line 801 of file channel.c.
References ast_null_frame, ast_queue_frame(), ast_tvadd(), ast_tvnow(), ast_tvzero(), and ast_channel::whentohangup.
Referenced by action_timeout(), ast_channel_setwhentohangup(), handle_autohangup(), and timeout_write().
00802 { 00803 chan->whentohangup = ast_tvzero(offset) ? offset : ast_tvadd(offset, ast_tvnow()); 00804 ast_queue_frame(chan, &ast_null_frame); 00805 return; 00806 }
| static int ast_channel_softhangup_cb | ( | void * | obj, | |
| void * | arg, | |||
| int | flags | |||
| ) | [static] |
Definition at line 764 of file channel.c.
References ast_softhangup(), and AST_SOFTHANGUP_SHUTDOWN.
Referenced by ast_begin_shutdown().
00765 { 00766 struct ast_channel *chan = obj; 00767 00768 ast_softhangup(chan, AST_SOFTHANGUP_SHUTDOWN); 00769 00770 return 0; 00771 }
| struct ast_silence_generator* ast_channel_start_silence_generator | ( | struct ast_channel * | chan | ) | [read] |
Starts a silence generator on the given channel.
| chan | The channel to generate silence on |
Definition at line 7507 of file channel.c.
References ast_activate_generator(), ast_calloc, ast_debug, AST_FORMAT_SLINEAR, ast_free, ast_log(), ast_set_write_format(), LOG_ERROR, ast_channel::name, ast_silence_generator::old_write_format, and ast_channel::writeformat.
Referenced by __ast_play_and_record(), ast_dtmf_stream(), ast_readstring_full(), ast_safe_sleep_conditional(), channel_spy(), record_exec(), TransferCallStep1(), waitfor_exec(), and waitforring_exec().
07508 { 07509 struct ast_silence_generator *state; 07510 07511 if (!(state = ast_calloc(1, sizeof(*state)))) { 07512 return NULL; 07513 } 07514 07515 state->old_write_format = chan->writeformat; 07516 07517 if (ast_set_write_format(chan, AST_FORMAT_SLINEAR) < 0) { 07518 ast_log(LOG_ERROR, "Could not set write format to SLINEAR\n"); 07519 ast_free(state); 07520 return NULL; 07521 } 07522 07523 ast_activate_generator(chan, &silence_generator, state); 07524 07525 ast_debug(1, "Started silence generator on '%s'\n", chan->name); 07526 07527 return state; 07528 }
| void ast_channel_stop_silence_generator | ( | struct ast_channel * | chan, | |
| struct ast_silence_generator * | state | |||
| ) |
Stops a previously-started silence generator on the given channel.
| chan | The channel to operate on | |
| state | The ast_silence_generator pointer return by a previous call to ast_channel_start_silence_generator. |
Definition at line 7530 of file channel.c.
References ast_deactivate_generator(), ast_debug, ast_free, ast_log(), ast_set_write_format(), LOG_ERROR, ast_channel::name, and ast_silence_generator::old_write_format.
Referenced by __ast_play_and_record(), ast_dtmf_stream(), ast_readstring_full(), ast_safe_sleep_conditional(), channel_spy(), HandleCallOutgoing(), key_dial_page(), record_exec(), unistim_hangup(), waitfor_exec(), and waitforring_exec().
07531 { 07532 if (!state) 07533 return; 07534 07535 ast_deactivate_generator(chan); 07536 07537 ast_debug(1, "Stopped silence generator on '%s'\n", chan->name); 07538 07539 if (ast_set_write_format(chan, state->old_write_format) < 0) 07540 ast_log(LOG_ERROR, "Could not return write format to its original state\n"); 07541 07542 ast_free(state); 07543 }
| int ast_channel_supports_html | ( | struct ast_channel * | channel | ) |
Checks for HTML support on a channel.
Definition at line 5501 of file channel.c.
References ast_channel_tech::send_html, and ast_channel::tech.
Referenced by dial_exec_full(), sendurl_exec(), and try_calling().
| void ast_channel_undefer_dtmf | ( | struct ast_channel * | chan | ) |
Unset defer DTMF flag on channel.
Undo defer. ast_read will return any DTMF characters that were queued
Definition at line 1509 of file channel.c.
References ast_clear_flag, and AST_FLAG_DEFER_DTMF.
Referenced by __adsi_transmit_messages(), find_cache(), and rpt_call().
01510 { 01511 if (chan) 01512 ast_clear_flag(chan, AST_FLAG_DEFER_DTMF); 01513 }
| void ast_channel_unregister | ( | const struct ast_channel_tech * | tech | ) |
Unregister channel driver.
Unregister a channel technology.
Definition at line 868 of file channel.c.
References ast_debug, ast_free, AST_LIST_REMOVE_CURRENT, AST_LIST_TRAVERSE_SAFE_END, AST_RWLIST_TRAVERSE_SAFE_BEGIN, AST_RWLIST_UNLOCK, AST_RWLIST_WRLOCK, ast_verb, chanlist::tech, and ast_channel_tech::type.
Referenced by __unload_module(), load_module(), and unload_module().
00869 { 00870 struct chanlist *chan; 00871 00872 ast_debug(1, "Unregistering channel type '%s'\n", tech->type); 00873 00874 AST_RWLIST_WRLOCK(&backends); 00875 00876 AST_RWLIST_TRAVERSE_SAFE_BEGIN(&backends, chan, list) { 00877 if (chan->tech == tech) { 00878 AST_LIST_REMOVE_CURRENT(list); 00879 ast_free(chan); 00880 ast_verb(2, "Unregistered channel type '%s'\n", tech->type); 00881 break; 00882 } 00883 } 00884 AST_LIST_TRAVERSE_SAFE_END; 00885 00886 AST_RWLIST_UNLOCK(&backends); 00887 }
| void ast_channel_update_connected_line | ( | struct ast_channel * | chan, | |
| const struct ast_party_connected_line * | connected, | |||
| const struct ast_set_party_connected_line * | update | |||
| ) |
Indicate that the connected line information has changed.
| chan | Asterisk channel to indicate connected line information | |
| connected | Connected line information | |
| update | What connected line information to update. NULL if all. |
Definition at line 8260 of file channel.c.
References ast_connected_line_build_data(), AST_CONTROL_CONNECTED_LINE, and ast_indicate_data().
Referenced by ast_channel_connected_line_macro(), ast_pickup_call(), builtin_atxfer(), builtin_blindtransfer(), connectedline_write(), pickup_do(), and wait_for_answer().
08261 { 08262 unsigned char data[1024]; /* This should be large enough */ 08263 size_t datalen; 08264 08265 datalen = ast_connected_line_build_data(data, sizeof(data), connected, update); 08266 if (datalen == (size_t) -1) { 08267 return; 08268 } 08269 08270 ast_indicate_data(chan, AST_CONTROL_CONNECTED_LINE, data, datalen); 08271 }
| void ast_channel_update_redirecting | ( | struct ast_channel * | chan, | |
| const struct ast_party_redirecting * | redirecting, | |||
| const struct ast_set_party_redirecting * | update | |||
| ) |
Indicate that the redirecting id has changed.
| chan | Asterisk channel to indicate redirecting id information | |
| redirecting | Redirecting id information | |
| update | What redirecting information to update. NULL if all. |
Definition at line 8767 of file channel.c.
References AST_CONTROL_REDIRECTING, ast_indicate_data(), and ast_redirecting_build_data().
Referenced by ast_call_forward(), ast_channel_redirecting_macro(), do_forward(), redirecting_write(), and wait_for_answer().
08768 { 08769 unsigned char data[1024]; /* This should be large enough */ 08770 size_t datalen; 08771 08772 datalen = ast_redirecting_build_data(data, sizeof(data), redirecting, update); 08773 if (datalen == (size_t) -1) { 08774 return; 08775 } 08776 08777 ast_indicate_data(chan, AST_CONTROL_REDIRECTING, data, datalen); 08778 }
| void ast_channels_init | ( | void | ) |
Provided by channel.c
Definition at line 7421 of file channel.c.
References ao2_container_alloc, ARRAY_LEN, ast_channel_cmp_cb(), ast_channel_hash_cb(), ast_cli_register_multiple(), ast_data_register_multiple_core, ast_plc_reload(), channels, cli_channel, and NUM_CHANNEL_BUCKETS.
Referenced by main().
07422 { 07423 channels = ao2_container_alloc(NUM_CHANNEL_BUCKETS, 07424 ast_channel_hash_cb, ast_channel_cmp_cb); 07425 07426 ast_cli_register_multiple(cli_channel, ARRAY_LEN(cli_channel)); 07427 07428 ast_data_register_multiple_core(channel_providers, ARRAY_LEN(channel_providers)); 07429 07430 ast_plc_reload(); 07431 }
| struct ast_variable* ast_channeltype_list | ( | void | ) | [read] |
return an ast_variable list of channeltypes
Definition at line 248 of file channel.c.
References AST_RWLIST_RDLOCK, AST_RWLIST_TRAVERSE, AST_RWLIST_UNLOCK, ast_variable_new(), ast_channel_tech::description, chanlist::tech, ast_channel_tech::type, and var.
Referenced by ast_var_channel_types(), and ast_var_channel_types_table().
00249 { 00250 struct chanlist *cl; 00251 struct ast_variable *var = NULL, *prev = NULL; 00252 00253 AST_RWLIST_RDLOCK(&backends); 00254 AST_RWLIST_TRAVERSE(&backends, cl, list) { 00255 if (prev) { 00256 if ((prev->next = ast_variable_new(cl->tech->type, cl->tech->description, ""))) 00257 prev = prev->next; 00258 } else { 00259 var = ast_variable_new(cl->tech->type, cl->tech->description, ""); 00260 prev = var; 00261 } 00262 } 00263 AST_RWLIST_UNLOCK(&backends); 00264 00265 return var; 00266 }
| int ast_check_hangup | ( | struct ast_channel * | chan | ) |
Checks to see if a channel is needing hang up.
Check to see if a channel is needing hang up.
Definition at line 742 of file channel.c.
References ast_channel::_softhangup, ast_debug, AST_SOFTHANGUP_TIMEOUT, ast_tvdiff_ms(), ast_tvnow(), ast_tvzero(), and ast_channel::whentohangup.
Referenced by __ast_pbx_run(), __ast_read(), _macro_exec(), agent_indicate(), agi_exec(), agi_handle_command(), announce_thread(), ast_bridge_call(), ast_call(), ast_channel_bridge(), ast_check_hangup_locked(), ast_indicate_data(), ast_raw_answer(), ast_readstring_full(), ast_recvtext(), ast_rtp_instance_bridge(), ast_sendtext(), ast_transfer(), ast_udptl_bridge(), ast_waitfordigit_full(), ast_write(), autoservice_run(), bridge_call_thread(), bridge_exec(), builtin_atxfer(), channel_spy(), check_bridge(), common_exec(), conf_play(), conf_run(), dahdi_accept_r2_call_exec(), dahdi_sendtext(), dahdi_setoption(), dial_exec_full(), dundi_lookup_internal(), eagi_exec(), eivr_comm(), feature_request_and_dial(), findmeexec(), func_channel_read(), handle_sendimage(), iax2_bridge(), launch_asyncagi(), local_bridge_loop(), local_fixup(), lua_check_hangup(), ospfinished_exec(), pbx_builtin_incomplete(), pbx_exec(), read_exec(), readexten_exec(), remote_bridge_loop(), rpt(), rpt_exec(), run_ras(), try_calling(), and wait_for_answer().
00743 { 00744 if (chan->_softhangup) /* yes if soft hangup flag set */ 00745 return 1; 00746 if (ast_tvzero(chan->whentohangup)) /* no if no hangup scheduled */ 00747 return 0; 00748 if (ast_tvdiff_ms(chan->whentohangup, ast_tvnow()) > 0) /* no if hangup time has not come yet. */ 00749 return 0; 00750 ast_debug(4, "Hangup time has come: %" PRIi64 "\n", ast_tvdiff_ms(chan->whentohangup, ast_tvnow())); 00751 chan->_softhangup |= AST_SOFTHANGUP_TIMEOUT; /* record event */ 00752 return 1; 00753 }
| int ast_check_hangup_locked | ( | struct ast_channel * | chan | ) |
Definition at line 755 of file channel.c.
References ast_channel_lock, ast_channel_unlock, and ast_check_hangup().
Referenced by action_redirect(), and ast_channel_bridge().
00756 { 00757 int res; 00758 ast_channel_lock(chan); 00759 res = ast_check_hangup(chan); 00760 ast_channel_unlock(chan); 00761 return res; 00762 }
| int ast_connected_line_build_data | ( | unsigned char * | data, | |
| size_t | datalen, | |||
| const struct ast_party_connected_line * | connected, | |||
| const struct ast_set_party_connected_line * | update | |||
| ) |
Build the connected line information data frame.
| data | Buffer to fill with the frame data | |
| datalen | Size of the buffer to fill | |
| connected | Connected line information | |
| update | What connected line information to build. NULL if all. |
| -1 | if error | |
| Amount | of data buffer used |
Definition at line 8000 of file channel.c.
References AST_CONNECTED_LINE_ID_PRESENTATION, AST_CONNECTED_LINE_NAME, AST_CONNECTED_LINE_NAME_CHAR_SET, AST_CONNECTED_LINE_NAME_PRESENTATION, AST_CONNECTED_LINE_NAME_VALID, AST_CONNECTED_LINE_NUMBER, AST_CONNECTED_LINE_NUMBER_PLAN, AST_CONNECTED_LINE_NUMBER_PRESENTATION, AST_CONNECTED_LINE_NUMBER_VALID, AST_CONNECTED_LINE_SOURCE, AST_CONNECTED_LINE_SUBADDRESS, AST_CONNECTED_LINE_SUBADDRESS_ODD_EVEN, AST_CONNECTED_LINE_SUBADDRESS_TYPE, AST_CONNECTED_LINE_SUBADDRESS_VALID, AST_CONNECTED_LINE_TAG, AST_CONNECTED_LINE_VERSION, ast_log(), ast_set_party_connected_line::id, ast_party_connected_line::id, LOG_WARNING, ast_party_id_ies::name, party_id_build_data(), ast_party_connected_line::source, ast_party_name_ies::str, and value.
Referenced by ast_channel_queue_connected_line_update(), ast_channel_update_connected_line(), local_attended_transfer(), and local_indicate().
08001 { 08002 int32_t value; 08003 size_t pos = 0; 08004 int res; 08005 08006 static const struct ast_party_id_ies ies = { 08007 .name.str = AST_CONNECTED_LINE_NAME, 08008 .name.char_set = AST_CONNECTED_LINE_NAME_CHAR_SET, 08009 .name.presentation = AST_CONNECTED_LINE_NAME_PRESENTATION, 08010 .name.valid = AST_CONNECTED_LINE_NAME_VALID, 08011 08012 .number.str = AST_CONNECTED_LINE_NUMBER, 08013 .number.plan = AST_CONNECTED_LINE_NUMBER_PLAN, 08014 .number.presentation = AST_CONNECTED_LINE_NUMBER_PRESENTATION, 08015 .number.valid = AST_CONNECTED_LINE_NUMBER_VALID, 08016 08017 .subaddress.str = AST_CONNECTED_LINE_SUBADDRESS, 08018 .subaddress.type = AST_CONNECTED_LINE_SUBADDRESS_TYPE, 08019 .subaddress.odd_even_indicator = AST_CONNECTED_LINE_SUBADDRESS_ODD_EVEN, 08020 .subaddress.valid = AST_CONNECTED_LINE_SUBADDRESS_VALID, 08021 08022 .tag = AST_CONNECTED_LINE_TAG, 08023 .combined_presentation = AST_CONNECTED_LINE_ID_PRESENTATION, 08024 }; 08025 08026 /* 08027 * The size of integer values must be fixed in case the frame is 08028 * shipped to another machine. 08029 */ 08030 08031 /* Connected line frame version */ 08032 if (datalen < pos + (sizeof(data[0]) * 2) + 1) { 08033 ast_log(LOG_WARNING, "No space left for connected line frame version\n"); 08034 return -1; 08035 } 08036 data[pos++] = AST_CONNECTED_LINE_VERSION; 08037 data[pos++] = 1; 08038 data[pos++] = 2;/* Version 1 did not have a version ie */ 08039 08040 res = party_id_build_data(data + pos, datalen - pos, &connected->id, 08041 "connected line", &ies, update ? &update->id : NULL); 08042 if (res < 0) { 08043 return -1; 08044 } 08045 pos += res; 08046 08047 /* Connected line source */ 08048 if (datalen < pos + (sizeof(data[0]) * 2) + sizeof(value)) { 08049 ast_log(LOG_WARNING, "No space left for connected line source\n"); 08050 return -1; 08051 } 08052 data[pos++] = AST_CONNECTED_LINE_SOURCE; 08053 data[pos++] = sizeof(value); 08054 value = htonl(connected->source); 08055 memcpy(data + pos, &value, sizeof(value)); 08056 pos += sizeof(value); 08057 08058 return pos; 08059 }
| void ast_connected_line_copy_from_caller | ( | struct ast_party_connected_line * | dest, | |
| const struct ast_party_caller * | src | |||
| ) |
Copy the caller information to the connected line information.
| dest | Destination connected line information | |
| src | Source caller information |
Definition at line 7618 of file channel.c.
References ast_party_caller::ani, ast_party_connected_line::ani, ast_party_caller::ani2, ast_party_connected_line::ani2, ast_party_id_copy(), ast_party_caller::id, and ast_party_connected_line::id.
Referenced by begin_dial_channel(), builtin_atxfer(), dial_exec_full(), feature_request_and_dial(), local_call(), pickup_do(), ring_entry(), and wait_for_answer().
07619 { 07620 ast_party_id_copy(&dest->id, &src->id); 07621 ast_party_id_copy(&dest->ani, &src->ani); 07622 dest->ani2 = src->ani2; 07623 }
| void ast_connected_line_copy_to_caller | ( | struct ast_party_caller * | dest, | |
| const struct ast_party_connected_line * | src | |||
| ) |
Copy the connected line information to the caller information.
| dest | Destination caller information | |
| src | Source connected line information |
Definition at line 7625 of file channel.c.
References ast_party_connected_line::ani, ast_party_caller::ani, ast_party_connected_line::ani2, ast_party_caller::ani2, ast_party_id_copy(), ast_party_connected_line::id, and ast_party_caller::id.
Referenced by local_call(), and local_indicate().
07626 { 07627 ast_party_id_copy(&dest->id, &src->id); 07628 ast_party_id_copy(&dest->ani, &src->ani); 07629 07630 dest->ani2 = src->ani2; 07631 }
| int ast_connected_line_parse_data | ( | const unsigned char * | data, | |
| size_t | datalen, | |||
| struct ast_party_connected_line * | connected | |||
| ) |
Parse connected line indication frame data.
| data | Buffer with the frame data to parse | |
| datalen | Size of the buffer | |
| connected | Extracted connected line information |
| 0 | on success. | |
| -1 | on error. |
The filled in connected line structure needs to be destroyed by ast_party_connected_line_free() when it is no longer needed.
Definition at line 8061 of file channel.c.
References AST_CONNECTED_LINE_ID_PRESENTATION, AST_CONNECTED_LINE_NAME, AST_CONNECTED_LINE_NAME_CHAR_SET, AST_CONNECTED_LINE_NAME_PRESENTATION, AST_CONNECTED_LINE_NAME_VALID, AST_CONNECTED_LINE_NUMBER, AST_CONNECTED_LINE_NUMBER_PLAN, AST_CONNECTED_LINE_NUMBER_PRESENTATION, AST_CONNECTED_LINE_NUMBER_VALID, AST_CONNECTED_LINE_SOURCE, AST_CONNECTED_LINE_SUBADDRESS, AST_CONNECTED_LINE_SUBADDRESS_ODD_EVEN, AST_CONNECTED_LINE_SUBADDRESS_TYPE, AST_CONNECTED_LINE_SUBADDRESS_VALID, AST_CONNECTED_LINE_TAG, AST_CONNECTED_LINE_VERSION, ast_free, ast_log(), ast_malloc, AST_PARTY_CHAR_SET_ISO8859_1, ast_party_name::char_set, ast_party_id_ies::combined_presentation, ast_party_connected_line::id, LOG_DEBUG, LOG_WARNING, ast_party_id::name, ast_party_id::number, ast_party_subaddress::odd_even_indicator, ast_party_number::plan, ast_party_number::presentation, ast_party_name::presentation, ast_party_connected_line::source, ast_party_subaddress::str, ast_party_number::str, ast_party_name::str, ast_party_id::subaddress, ast_party_id::tag, ast_party_subaddress::type, ast_party_subaddress::valid, ast_party_number::valid, ast_party_name::valid, and value.
Referenced by __ast_read(), ast_channel_connected_line_macro(), ast_indicate_data(), socket_process(), and wait_for_answer().
08062 { 08063 size_t pos; 08064 unsigned char ie_len; 08065 unsigned char ie_id; 08066 int32_t value; 08067 int frame_version = 1; 08068 int combined_presentation = 0; 08069 int got_combined_presentation = 0;/* TRUE if got a combined name and number presentation value. */ 08070 08071 for (pos = 0; pos < datalen; pos += ie_len) { 08072 if (datalen < pos + sizeof(ie_id) + sizeof(ie_len)) { 08073 ast_log(LOG_WARNING, "Invalid connected line update\n"); 08074 return -1; 08075 } 08076 ie_id = data[pos++]; 08077 ie_len = data[pos++]; 08078 if (datalen < pos + ie_len) { 08079 ast_log(LOG_WARNING, "Invalid connected line update\n"); 08080 return -1; 08081 } 08082 08083 switch (ie_id) { 08084 /* Connected line party frame version */ 08085 case AST_CONNECTED_LINE_VERSION: 08086 if (ie_len != 1) { 08087 ast_log(LOG_WARNING, "Invalid connected line frame version (%u)\n", 08088 (unsigned) ie_len); 08089 break; 08090 } 08091 frame_version = data[pos]; 08092 break; 08093 /* Connected line party id name */ 08094 case AST_CONNECTED_LINE_NAME: 08095 ast_free(connected->id.name.str); 08096 connected->id.name.str = ast_malloc(ie_len + 1); 08097 if (connected->id.name.str) { 08098 memcpy(connected->id.name.str, data + pos, ie_len); 08099 connected->id.name.str[ie_len] = 0; 08100 } 08101 break; 08102 case AST_CONNECTED_LINE_NAME_CHAR_SET: 08103 if (ie_len != 1) { 08104 ast_log(LOG_WARNING, "Invalid connected line name char set (%u)\n", 08105 (unsigned) ie_len); 08106 break; 08107 } 08108 connected->id.name.char_set = data[pos]; 08109 break; 08110 case AST_CONNECTED_LINE_NAME_PRESENTATION: 08111 if (ie_len != 1) { 08112 ast_log(LOG_WARNING, "Invalid connected line name presentation (%u)\n", 08113 (unsigned) ie_len); 08114 break; 08115 } 08116 connected->id.name.presentation = data[pos]; 08117 break; 08118 case AST_CONNECTED_LINE_NAME_VALID: 08119 if (ie_len != 1) { 08120 ast_log(LOG_WARNING, "Invalid connected line name valid (%u)\n", 08121 (unsigned) ie_len); 08122 break; 08123 } 08124 connected->id.name.valid = data[pos]; 08125 break; 08126 /* Connected line party id number */ 08127 case AST_CONNECTED_LINE_NUMBER: 08128 ast_free(connected->id.number.str); 08129 connected->id.number.str = ast_malloc(ie_len + 1); 08130 if (connected->id.number.str) { 08131 memcpy(connected->id.number.str, data + pos, ie_len); 08132 connected->id.number.str[ie_len] = 0; 08133 } 08134 break; 08135 case AST_CONNECTED_LINE_NUMBER_PLAN: 08136 if (ie_len != 1) { 08137 ast_log(LOG_WARNING, "Invalid connected line numbering plan (%u)\n", 08138 (unsigned) ie_len); 08139 break; 08140 } 08141 connected->id.number.plan = data[pos]; 08142 break; 08143 case AST_CONNECTED_LINE_NUMBER_PRESENTATION: 08144 if (ie_len != 1) { 08145 ast_log(LOG_WARNING, "Invalid connected line number presentation (%u)\n", 08146 (unsigned) ie_len); 08147 break; 08148 } 08149 connected->id.number.presentation = data[pos]; 08150 break; 08151 case AST_CONNECTED_LINE_NUMBER_VALID: 08152 if (ie_len != 1) { 08153 ast_log(LOG_WARNING, "Invalid connected line number valid (%u)\n", 08154 (unsigned) ie_len); 08155 break; 08156 } 08157 connected->id.number.valid = data[pos]; 08158 break; 08159 /* Connected line party id combined presentation */ 08160 case AST_CONNECTED_LINE_ID_PRESENTATION: 08161 if (ie_len != 1) { 08162 ast_log(LOG_WARNING, "Invalid connected line combined presentation (%u)\n", 08163 (unsigned) ie_len); 08164 break; 08165 } 08166 combined_presentation = data[pos]; 08167 got_combined_presentation = 1; 08168 break; 08169 /* Connected line party id subaddress */ 08170 case AST_CONNECTED_LINE_SUBADDRESS: 08171 ast_free(connected->id.subaddress.str); 08172 connected->id.subaddress.str = ast_malloc(ie_len + 1); 08173 if (connected->id.subaddress.str) { 08174 memcpy(connected->id.subaddress.str, data + pos, ie_len); 08175 connected->id.subaddress.str[ie_len] = 0; 08176 } 08177 break; 08178 case AST_CONNECTED_LINE_SUBADDRESS_TYPE: 08179 if (ie_len != 1) { 08180 ast_log(LOG_WARNING, "Invalid connected line type of subaddress (%u)\n", 08181 (unsigned) ie_len); 08182 break; 08183 } 08184 connected->id.subaddress.type = data[pos]; 08185 break; 08186 case AST_CONNECTED_LINE_SUBADDRESS_ODD_EVEN: 08187 if (ie_len != 1) { 08188 ast_log(LOG_WARNING, 08189 "Invalid connected line subaddress odd-even indicator (%u)\n", 08190 (unsigned) ie_len); 08191 break; 08192 } 08193 connected->id.subaddress.odd_even_indicator = data[pos]; 08194 break; 08195 case AST_CONNECTED_LINE_SUBADDRESS_VALID: 08196 if (ie_len != 1) { 08197 ast_log(LOG_WARNING, "Invalid connected line subaddress valid (%u)\n", 08198 (unsigned) ie_len); 08199 break; 08200 } 08201 connected->id.subaddress.valid = data[pos]; 08202 break; 08203 /* Connected line party tag */ 08204 case AST_CONNECTED_LINE_TAG: 08205 ast_free(connected->id.tag); 08206 connected->id.tag = ast_malloc(ie_len + 1); 08207 if (connected->id.tag) { 08208 memcpy(connected->id.tag, data + pos, ie_len); 08209 connected->id.tag[ie_len] = 0; 08210 } 08211 break; 08212 /* Connected line party source */ 08213 case AST_CONNECTED_LINE_SOURCE: 08214 if (ie_len != sizeof(value)) { 08215 ast_log(LOG_WARNING, "Invalid connected line source (%u)\n", 08216 (unsigned) ie_len); 08217 break; 08218 } 08219 memcpy(&value, data + pos, sizeof(value)); 08220 connected->source = ntohl(value); 08221 break; 08222 /* Connected line party unknown element */ 08223 default: 08224 ast_log(LOG_DEBUG, "Unknown connected line element: %u (%u)\n", 08225 (unsigned) ie_id, (unsigned) ie_len); 08226 break; 08227 } 08228 } 08229 08230 switch (frame_version) { 08231 case 1: 08232 /* 08233 * The other end is an earlier version that we need to adjust 08234 * for compatibility. 08235 */ 08236 connected->id.name.valid = 1; 08237 connected->id.name.char_set = AST_PARTY_CHAR_SET_ISO8859_1; 08238 connected->id.number.valid = 1; 08239 if (got_combined_presentation) { 08240 connected->id.name.presentation = combined_presentation; 08241 connected->id.number.presentation = combined_presentation; 08242 } 08243 break; 08244 case 2: 08245 /* The other end is at the same level as we are. */ 08246 break; 08247 default: 08248 /* 08249 * The other end is newer than we are. 08250 * We need to assume that they are compatible with us. 08251 */ 08252 ast_log(LOG_DEBUG, "Connected line frame has newer version: %u\n", 08253 (unsigned) frame_version); 08254 break; 08255 } 08256 08257 return 0; 08258 }
| AST_DATA_STRUCTURE | ( | ast_channel | , | |
| DATA_EXPORT_CHANNEL | ||||
| ) |
| void ast_deactivate_generator | ( | struct ast_channel * | chan | ) |
Deactivate an active generator
Definition at line 2903 of file channel.c.
References ast_channel_lock, ast_channel_set_fd(), ast_channel_unlock, ast_clear_flag, AST_FLAG_WRITE_INT, AST_GENERATOR_FD, ast_settimeout(), ast_channel::generator, ast_channel::generatordata, and ast_generator::release.
Referenced by __ast_read(), app_exec(), ast_channel_stop_silence_generator(), ast_openstream_full(), ast_playtones_stop(), ast_quiet_chan(), ast_read_generator_actions(), ast_tonepair_stop(), ast_write(), cb_events(), channel_spy(), dial_exec_full(), generator_force(), local_ast_moh_stop(), old_milliwatt_exec(), transmit_audio(), and wait_for_answer().
02904 { 02905 ast_channel_lock(chan); 02906 if (chan->generatordata) { 02907 if (chan->generator && chan->generator->release) 02908 chan->generator->release(chan, chan->generatordata); 02909 chan->generatordata = NULL; 02910 chan->generator = NULL; 02911 ast_channel_set_fd(chan, AST_GENERATOR_FD, -1); 02912 ast_clear_flag(chan, AST_FLAG_WRITE_INT); 02913 ast_settimeout(chan, 0, NULL, NULL); 02914 } 02915 ast_channel_unlock(chan); 02916 }
| int ast_do_masquerade | ( | struct ast_channel * | original | ) |
Masquerade a channel.
Start masquerading a channel.
Definition at line 5945 of file channel.c.
References __ast_change_name_nolink(), ast_channel::_bridge, ast_channel::_softhangup, ast_channel::_state, ast_channel::accountcode, accountcode, ast_channel::adsicpe, ast_channel::alertpipe, ao2_link, ao2_lock, ao2_unlink, ao2_unlock, ast_app_group_update(), ast_autochan_new_channel(), ast_bridged_channel(), ast_cause2str(), AST_CEL_BRIDGE_UPDATE, ast_cel_report_event(), ast_channel_lock, AST_CHANNEL_NAME, ast_channel_release(), ast_channel_set_fd(), ast_channel_set_linkgroup(), ast_channel_trylock, ast_channel_unlock, AST_CONTROL_SRCCHANGE, ast_copy_string(), ast_debug, AST_FLAG_BLOCKING, AST_FLAG_EXCEPTION, AST_FLAG_OUTGOING, AST_FLAG_ZOMBIE, AST_GENERATOR_FD, ast_getformatname(), ast_indicate(), AST_LIST_APPEND_LIST, AST_LIST_FIRST, AST_LIST_HEAD_NOLOCK, AST_LIST_HEAD_SET_NOLOCK, AST_LIST_INSERT_TAIL, AST_LIST_REMOVE_HEAD, AST_LIST_TRAVERSE_SAFE_BEGIN, AST_LIST_TRAVERSE_SAFE_END, ast_log(), ast_manager_event, ast_manager_event_multichan, AST_MAX_FDS, ast_null_frame, ast_queue_frame(), ast_set_flag, ast_set_read_format(), ast_set_write_format(), AST_SOFTHANGUP_DEV, ast_state2str(), ast_string_field_set, ast_test_flag, AST_TIMING_FD, ast_channel::blocker, ast_channel::caller, ast_channel::cdr, ast_datastore_info::chan_fixup, CHANNEL_DEADLOCK_AVOIDANCE, channels, clone_variables(), ast_channel::connected, ast_datastore::data, ast_channel::datastores, ast_channel::dialed, errno, EVENT_FLAG_CALL, ast_channel::fdno, ast_channel::fds, ast_channel_tech::fixup, free_translation(), ast_channel_tech::hangup, ast_channel::hangupcause, ast_datastore::info, ast_channel::language, language, LOG_WARNING, ast_channel::masq, ast_channel::masqr, ast_channel::monitor, ast_channel::musicclass, musicclass, ast_channel::name, ast_channel::nativeformats, ast_channel::rawreadformat, ast_channel::rawwriteformat, ast_channel::readformat, ast_channel::readq, ast_channel::redirecting, report_new_callerid(), S_OR, ast_channel::tech, ast_channel::tech_pvt, ast_channel::timingfd, ast_channel_tech::type, ast_channel::uniqueid, ast_channel::visible_indication, and ast_channel::writeformat.
Referenced by __ast_read(), ast_async_goto(), ast_hangup(), ast_waitfor_nandfds(), ast_write(), do_bridge_masquerade(), handle_invite_replaces(), iax_park(), local_attended_transfer(), sip_park(), and sip_park_thread().
05946 { 05947 format_t x; 05948 int i; 05949 int res=0; 05950 int origstate; 05951 struct ast_frame *current; 05952 const struct ast_channel_tech *t; 05953 void *t_pvt; 05954 union { 05955 struct ast_party_dialed dialed; 05956 struct ast_party_caller caller; 05957 struct ast_party_connected_line connected; 05958 struct ast_party_redirecting redirecting; 05959 } exchange; 05960 struct ast_channel *clonechan, *chans[2]; 05961 struct ast_channel *bridged; 05962 struct ast_cdr *cdr; 05963 format_t rformat = original->readformat; 05964 format_t wformat = original->writeformat; 05965 char newn[AST_CHANNEL_NAME]; 05966 char orig[AST_CHANNEL_NAME]; 05967 char masqn[AST_CHANNEL_NAME]; 05968 char zombn[AST_CHANNEL_NAME]; 05969 05970 /* XXX This operation is a bit odd. We're essentially putting the guts of 05971 * the clone channel into the original channel. Start by killing off the 05972 * original channel's backend. While the features are nice, which is the 05973 * reason we're keeping it, it's still awesomely weird. XXX */ 05974 05975 /* The reasoning for the channels ao2_container lock here is complex. 05976 * 05977 * In order to check for a race condition, the original channel must 05978 * be locked. If it is determined that the masquerade should proceed 05979 * the original channel can absolutely not be unlocked until the end 05980 * of the function. Since after determining the masquerade should 05981 * continue requires the channels to be unlinked from the ao2_container, 05982 * the container lock must be held first to achieve proper locking order. 05983 */ 05984 ao2_lock(channels); 05985 05986 /* lock the original channel to determine if the masquerade is require or not */ 05987 ast_channel_lock(original); 05988 05989 /* This checks to see if the masquerade has already happened or not. There is a 05990 * race condition that exists for this function. Since all pvt and channel locks 05991 * must be let go before calling do_masquerade, it is possible that it could be 05992 * called multiple times for the same channel. This check verifies whether 05993 * or not the masquerade has already been completed by another thread */ 05994 if (!original->masq) { 05995 ast_channel_unlock(original); 05996 ao2_unlock(channels); 05997 return 0; /* masq already completed by another thread, or never needed to be done to begin with */ 05998 } 05999 06000 /* now that we have verified no race condition exists, set the clone channel */ 06001 clonechan = original->masq; 06002 06003 /* since this function already holds the global container lock, unlocking original 06004 * for deadlock avoidance will not result in any sort of masquerade race condition. 06005 * If masq is called by a different thread while this happens, it will be stuck waiting 06006 * until we unlock the container. */ 06007 while (ast_channel_trylock(clonechan)) { 06008 CHANNEL_DEADLOCK_AVOIDANCE(original); 06009 } 06010 06011 /* clear the masquerade channels */ 06012 original->masq = NULL; 06013 clonechan->masqr = NULL; 06014 06015 /* unlink from channels container as name (which is the hash value) will change */ 06016 ao2_unlink(channels, original); 06017 ao2_unlink(channels, clonechan); 06018 06019 ast_debug(4, "Actually Masquerading %s(%d) into the structure of %s(%d)\n", 06020 clonechan->name, clonechan->_state, original->name, original->_state); 06021 06022 chans[0] = clonechan; 06023 chans[1] = original; 06024 ast_manager_event_multichan(EVENT_FLAG_CALL, "Masquerade", 2, chans, "Clone: %s\r\nCloneState: %s\r\nOriginal: %s\r\nOriginalState: %s\r\n", 06025 clonechan->name, ast_state2str(clonechan->_state), original->name, ast_state2str(original->_state)); 06026 06027 /* Having remembered the original read/write formats, we turn off any translation on either 06028 one */ 06029 free_translation(clonechan); 06030 free_translation(original); 06031 06032 /* Save the original name */ 06033 ast_copy_string(orig, original->name, sizeof(orig)); 06034 /* Save the new name */ 06035 ast_copy_string(newn, clonechan->name, sizeof(newn)); 06036 /* Create the masq name */ 06037 snprintf(masqn, sizeof(masqn), "%s<MASQ>", newn); 06038 06039 /* Mangle the name of the clone channel */ 06040 __ast_change_name_nolink(clonechan, masqn); 06041 06042 /* Copy the name from the clone channel */ 06043 __ast_change_name_nolink(original, newn); 06044 06045 /* share linked id's */ 06046 ast_channel_set_linkgroup(original, clonechan); 06047 06048 /* Swap the technologies */ 06049 t = original->tech; 06050 original->tech = clonechan->tech; 06051 clonechan->tech = t; 06052 06053 /* Swap the cdrs */ 06054 cdr = original->cdr; 06055 original->cdr = clonechan->cdr; 06056 clonechan->cdr = cdr; 06057 06058 t_pvt = original->tech_pvt; 06059 original->tech_pvt = clonechan->tech_pvt; 06060 clonechan->tech_pvt = t_pvt; 06061 06062 /* Swap the alertpipes */ 06063 for (i = 0; i < 2; i++) { 06064 x = original->alertpipe[i]; 06065 original->alertpipe[i] = clonechan->alertpipe[i]; 06066 clonechan->alertpipe[i] = x; 06067 } 06068 06069 /* 06070 * Swap the readq's. The end result should be this: 06071 * 06072 * 1) All frames should be on the new (original) channel. 06073 * 2) Any frames that were already on the new channel before this 06074 * masquerade need to be at the end of the readq, after all of the 06075 * frames on the old (clone) channel. 06076 * 3) The alertpipe needs to get poked for every frame that was already 06077 * on the new channel, since we are now using the alert pipe from the 06078 * old (clone) channel. 06079 */ 06080 { 06081 AST_LIST_HEAD_NOLOCK(, ast_frame) tmp_readq; 06082 AST_LIST_HEAD_SET_NOLOCK(&tmp_readq, NULL); 06083 06084 AST_LIST_APPEND_LIST(&tmp_readq, &original->readq, frame_list); 06085 AST_LIST_APPEND_LIST(&original->readq, &clonechan->readq, frame_list); 06086 06087 while ((current = AST_LIST_REMOVE_HEAD(&tmp_readq, frame_list))) { 06088 AST_LIST_INSERT_TAIL(&original->readq, current, frame_list); 06089 if (original->alertpipe[1] > -1) { 06090 int poke = 0; 06091 06092 if (write(original->alertpipe[1], &poke, sizeof(poke)) < 0) { 06093 ast_log(LOG_WARNING, "write() failed: %s\n", strerror(errno)); 06094 } 06095 } 06096 } 06097 } 06098 06099 /* Swap the raw formats */ 06100 x = original->rawreadformat; 06101 original->rawreadformat = clonechan->rawreadformat; 06102 clonechan->rawreadformat = x; 06103 x = original->rawwriteformat; 06104 original->rawwriteformat = clonechan->rawwriteformat; 06105 clonechan->rawwriteformat = x; 06106 06107 clonechan->_softhangup = AST_SOFTHANGUP_DEV; 06108 06109 /* And of course, so does our current state. Note we need not 06110 call ast_setstate since the event manager doesn't really consider 06111 these separate. We do this early so that the clone has the proper 06112 state of the original channel. */ 06113 origstate = original->_state; 06114 original->_state = clonechan->_state; 06115 clonechan->_state = origstate; 06116 06117 if (clonechan->tech->fixup && clonechan->tech->fixup(original, clonechan)) { 06118 ast_log(LOG_WARNING, "Fixup failed on channel %s, strange things may happen.\n", clonechan->name); 06119 } 06120 06121 /* Start by disconnecting the original's physical side */ 06122 if (clonechan->tech->hangup && clonechan->tech->hangup(clonechan)) { 06123 ast_log(LOG_WARNING, "Hangup failed! Strange things may happen!\n"); 06124 res = -1; 06125 goto done; 06126 } 06127 06128 /* Mangle the name of the clone channel */ 06129 snprintf(zombn, sizeof(zombn), "%s<ZOMBIE>", orig); /* quick, hide the brains! */ 06130 __ast_change_name_nolink(clonechan, zombn); 06131 06132 /* Update the type. */ 06133 t_pvt = original->monitor; 06134 original->monitor = clonechan->monitor; 06135 clonechan->monitor = t_pvt; 06136 06137 /* Keep the same language. */ 06138 ast_string_field_set(original, language, clonechan->language); 06139 /* Copy the FD's other than the generator fd */ 06140 for (x = 0; x < AST_MAX_FDS; x++) { 06141 if (x != AST_GENERATOR_FD) 06142 ast_channel_set_fd(original, x, clonechan->fds[x]); 06143 } 06144 06145 ast_app_group_update(clonechan, original); 06146 06147 /* Move data stores over */ 06148 if (AST_LIST_FIRST(&clonechan->datastores)) { 06149 struct ast_datastore *ds; 06150 /* We use a safe traversal here because some fixup routines actually 06151 * remove the datastore from the list and free them. 06152 */ 06153 AST_LIST_TRAVERSE_SAFE_BEGIN(&clonechan->datastores, ds, entry) { 06154 if (ds->info->chan_fixup) 06155 ds->info->chan_fixup(ds->data, clonechan, original); 06156 } 06157 AST_LIST_TRAVERSE_SAFE_END; 06158 AST_LIST_APPEND_LIST(&original->datastores, &clonechan->datastores, entry); 06159 } 06160 06161 ast_autochan_new_channel(clonechan, original); 06162 06163 clone_variables(original, clonechan); 06164 /* Presense of ADSI capable CPE follows clone */ 06165 original->adsicpe = clonechan->adsicpe; 06166 /* Bridge remains the same */ 06167 /* CDR fields remain the same */ 06168 /* XXX What about blocking, softhangup, blocker, and lock and blockproc? XXX */ 06169 /* Application and data remain the same */ 06170 /* Clone exception becomes real one, as with fdno */ 06171 ast_set_flag(original, ast_test_flag(clonechan, AST_FLAG_EXCEPTION | AST_FLAG_OUTGOING)); 06172 original->fdno = clonechan->fdno; 06173 /* Schedule context remains the same */ 06174 /* Stream stuff stays the same */ 06175 /* Keep the original state. The fixup code will need to work with it most likely */ 06176 06177 /* 06178 * Just swap the whole structures, nevermind the allocations, 06179 * they'll work themselves out. 06180 */ 06181 exchange.dialed = original->dialed; 06182 original->dialed = clonechan->dialed; 06183 clonechan->dialed = exchange.dialed; 06184 06185 exchange.caller = original->caller; 06186 original->caller = clonechan->caller; 06187 clonechan->caller = exchange.caller; 06188 06189 exchange.connected = original->connected; 06190 original->connected = clonechan->connected; 06191 clonechan->connected = exchange.connected; 06192 06193 exchange.redirecting = original->redirecting; 06194 original->redirecting = clonechan->redirecting; 06195 clonechan->redirecting = exchange.redirecting; 06196 06197 report_new_callerid(original); 06198 06199 /* Restore original timing file descriptor */ 06200 ast_channel_set_fd(original, AST_TIMING_FD, original->timingfd); 06201 06202 /* Our native formats are different now */ 06203 original->nativeformats = clonechan->nativeformats; 06204 06205 /* Context, extension, priority, app data, jump table, remain the same */ 06206 /* pvt switches. pbx stays the same, as does next */ 06207 06208 /* Set the write format */ 06209 ast_set_write_format(original, wformat); 06210 06211 /* Set the read format */ 06212 ast_set_read_format(original, rformat); 06213 06214 /* Copy the music class */ 06215 ast_string_field_set(original, musicclass, clonechan->musicclass); 06216 06217 /* copy over accuntcode and set peeraccount across the bridge */ 06218 ast_string_field_set(original, accountcode, S_OR(clonechan->accountcode, "")); 06219 if (original->_bridge) { 06220 /* XXX - should we try to lock original->_bridge here? */ 06221 ast_string_field_set(original->_bridge, peeraccount, S_OR(clonechan->accountcode, "")); 06222 ast_cel_report_event(original, AST_CEL_BRIDGE_UPDATE, NULL, NULL, NULL); 06223 } 06224 06225 ast_debug(1, "Putting channel %s in %s/%s formats\n", original->name, 06226 ast_getformatname(wformat), ast_getformatname(rformat)); 06227 06228 /* Okay. Last thing is to let the channel driver know about all this mess, so he 06229 can fix up everything as best as possible */ 06230 if (original->tech->fixup) { 06231 if (original->tech->fixup(clonechan, original)) { 06232 ast_log(LOG_WARNING, "Channel for type '%s' could not fixup channel %s\n", 06233 original->tech->type, original->name); 06234 res = -1; 06235 goto done; 06236 } 06237 } else 06238 ast_log(LOG_WARNING, "Channel type '%s' does not have a fixup routine (for %s)! Bad things may happen.\n", 06239 original->tech->type, original->name); 06240 06241 /* 06242 * If an indication is currently playing, maintain it on the channel 06243 * that is taking the place of original 06244 * 06245 * This is needed because the masquerade is swapping out in the internals 06246 * of this channel, and the new channel private data needs to be made 06247 * aware of the current visible indication (RINGING, CONGESTION, etc.) 06248 */ 06249 if (original->visible_indication) { 06250 ast_indicate(original, original->visible_indication); 06251 } 06252 06253 /* Now, at this point, the "clone" channel is totally F'd up. We mark it as 06254 a zombie so nothing tries to touch it. If it's already been marked as a 06255 zombie, then free it now (since it already is considered invalid). */ 06256 if (ast_test_flag(clonechan, AST_FLAG_ZOMBIE)) { 06257 ast_debug(1, "Destroying channel clone '%s'\n", clonechan->name); 06258 ast_channel_unlock(clonechan); 06259 ast_manager_event(clonechan, EVENT_FLAG_CALL, "Hangup", 06260 "Channel: %s\r\n" 06261 "Uniqueid: %s\r\n" 06262 "Cause: %d\r\n" 06263 "Cause-txt: %s\r\n", 06264 clonechan->name, 06265 clonechan->uniqueid, 06266 clonechan->hangupcause, 06267 ast_cause2str(clonechan->hangupcause) 06268 ); 06269 clonechan = ast_channel_release(clonechan); 06270 } else { 06271 ast_debug(1, "Released clone lock on '%s'\n", clonechan->name); 06272 ast_set_flag(clonechan, AST_FLAG_ZOMBIE); 06273 ast_queue_frame(clonechan, &ast_null_frame); 06274 } 06275 06276 /* Signal any blocker */ 06277 if (ast_test_flag(original, AST_FLAG_BLOCKING)) 06278 pthread_kill(original->blocker, SIGURG); 06279 ast_debug(1, "Done Masquerading %s (%d)\n", original->name, original->_state); 06280 06281 if ((bridged = ast_bridged_channel(original))) { 06282 ast_channel_lock(bridged); 06283 ast_indicate(bridged, AST_CONTROL_SRCCHANGE); 06284 ast_channel_unlock(bridged); 06285 } 06286 06287 ast_indicate(original, AST_CONTROL_SRCCHANGE); 06288 06289 done: 06290 /* it is possible for the clone channel to disappear during this */ 06291 if (clonechan) { 06292 ast_channel_unlock(original); 06293 ast_channel_unlock(clonechan); 06294 ao2_link(channels, clonechan); 06295 ao2_link(channels, original); 06296 } else { 06297 ast_channel_unlock(original); 06298 ao2_link(channels, original); 06299 } 06300 06301 ao2_unlock(channels); 06302 06303 return 0; 06304 }
| struct ast_channel* ast_dummy_channel_alloc | ( | void | ) | [read] |
Create a fake channel structure.
| NULL | failure | |
| non-NULL | successfully allocated channel |
Definition at line 1318 of file channel.c.
References __ao2_alloc_debug(), ao2_alloc, ast_channel_unref, ast_dummy_channel_destructor(), AST_LIST_HEAD_INIT_NOLOCK, ast_string_field_init, and ast_channel::varshead.
Referenced by acf_odbc_read(), acf_odbc_write(), action_getvar(), ast_add_extension2_lockopt(), ast_cel_fabricate_channel_from_event(), ast_pbx_outgoing_cdr_failed(), ast_str_substitute_variables_full(), cli_odbc_read(), cli_odbc_write(), custom_log(), make_email_file(), manager_log(), pbx_substitute_variables_helper_full(), rotate_file(), sendmail(), sendpage(), syslog_log(), and write_cdr().
01320 { 01321 struct ast_channel *tmp; 01322 struct varshead *headp; 01323 01324 #if defined(REF_DEBUG) 01325 tmp = __ao2_alloc_debug(sizeof(*tmp), ast_dummy_channel_destructor, "dummy channel", 01326 file, line, function, 1); 01327 #elif defined(__AST_DEBUG_MALLOC) 01328 tmp = __ao2_alloc_debug(sizeof(*tmp), ast_dummy_channel_destructor, "dummy channel", 01329 file, line, function, 0); 01330 #else 01331 tmp = ao2_alloc(sizeof(*tmp), ast_dummy_channel_destructor); 01332 #endif 01333 if (!tmp) { 01334 /* Dummy channel structure allocation failure. */ 01335 return NULL; 01336 } 01337 01338 if ((ast_string_field_init(tmp, 128))) { 01339 return ast_channel_unref(tmp); 01340 } 01341 01342 headp = &tmp->varshead; 01343 AST_LIST_HEAD_INIT_NOLOCK(headp); 01344 01345 return tmp; 01346 }
| static void ast_dummy_channel_destructor | ( | void * | obj | ) | [static] |
Free a dummy channel structure.
Definition at line 2402 of file channel.c.
References ast_cdr_discard(), AST_LIST_REMOVE_HEAD, ast_party_caller_free(), ast_party_connected_line_free(), ast_party_dialed_free(), ast_party_redirecting_free(), ast_string_field_free_memory, ast_var_delete(), ast_channel::caller, ast_channel::cdr, ast_channel::connected, ast_channel::dialed, ast_channel::redirecting, and ast_channel::varshead.
Referenced by ast_dummy_channel_alloc().
02403 { 02404 struct ast_channel *chan = obj; 02405 struct ast_var_t *vardata; 02406 struct varshead *headp; 02407 02408 headp = &chan->varshead; 02409 02410 ast_party_dialed_free(&chan->dialed); 02411 ast_party_caller_free(&chan->caller); 02412 ast_party_connected_line_free(&chan->connected); 02413 ast_party_redirecting_free(&chan->redirecting); 02414 02415 /* loop over the variables list, freeing all data and deleting list items */ 02416 /* no need to lock the list, as the channel is already locked */ 02417 while ((vardata = AST_LIST_REMOVE_HEAD(headp, entries))) 02418 ast_var_delete(vardata); 02419 02420 if (chan->cdr) { 02421 ast_cdr_discard(chan->cdr); 02422 chan->cdr = NULL; 02423 } 02424 02425 ast_string_field_free_memory(chan); 02426 }
| static enum ast_bridge_result ast_generic_bridge | ( | struct ast_channel * | c0, | |
| struct ast_channel * | c1, | |||
| struct ast_bridge_config * | config, | |||
| struct ast_frame ** | fo, | |||
| struct ast_channel ** | rc | |||
| ) | [static] |
Definition at line 6451 of file channel.c.
References ast_channel::_bridge, ast_channel::_softhangup, AST_BRIDGE_COMPLETE, AST_BRIDGE_DTMF_CHANNEL_0, AST_BRIDGE_DTMF_CHANNEL_1, AST_BRIDGE_IGNORE_SIGS, AST_BRIDGE_RETRY, ast_channel_connected_line_macro(), ast_channel_redirecting_macro(), ast_clear_flag, AST_CONTROL_AOC, AST_CONTROL_CONNECTED_LINE, AST_CONTROL_HOLD, AST_CONTROL_REDIRECTING, AST_CONTROL_SRCCHANGE, AST_CONTROL_SRCUPDATE, AST_CONTROL_T38_PARAMETERS, AST_CONTROL_UNHOLD, AST_CONTROL_VIDUPDATE, ast_debug, AST_FEATURE_WARNING_ACTIVE, AST_FRAME_CONTROL, AST_FRAME_DTMF, AST_FRAME_DTMF_BEGIN, AST_FRAME_DTMF_END, AST_FRAME_HTML, AST_FRAME_IMAGE, AST_FRAME_MODEM, AST_FRAME_TEXT, AST_FRAME_VIDEO, AST_FRAME_VOICE, ast_frfree, ast_indicate_data(), ast_jb_do_usecheck(), ast_jb_empty_and_reset(), ast_jb_get_and_deliver(), ast_jb_get_when_to_wakeup(), ast_jb_put(), ast_poll_channel_add(), ast_poll_channel_del(), ast_read(), ast_samp2tv(), ast_set_flag, AST_SOFTHANGUP_UNBRIDGE, ast_test_flag, ast_tvadd(), ast_tvdiff_ms(), ast_tvnow(), ast_tvzero(), ast_waitfor_n(), ast_write(), ast_frame::data, ast_frame::datalen, ast_bridge_config::feature_timer, ast_bridge_config::flags, ast_frame::frametype, ast_frame_subclass::integer, ast_channel::name, ast_channel::nativeformats, ast_bridge_config::nexteventts, ast_frame::ptr, ast_frame::subclass, ast_channel::tech_pvt, and ast_bridge_config::timelimit.
Referenced by ast_channel_bridge().
06454 { 06455 /* Copy voice back and forth between the two channels. */ 06456 struct ast_channel *cs[3]; 06457 struct ast_frame *f; 06458 enum ast_bridge_result res = AST_BRIDGE_COMPLETE; 06459 format_t o0nativeformats; 06460 format_t o1nativeformats; 06461 int watch_c0_dtmf; 06462 int watch_c1_dtmf; 06463 void *pvt0, *pvt1; 06464 /* Indicates whether a frame was queued into a jitterbuffer */ 06465 int frame_put_in_jb = 0; 06466 int jb_in_use; 06467 int to; 06468 06469 cs[0] = c0; 06470 cs[1] = c1; 06471 pvt0 = c0->tech_pvt; 06472 pvt1 = c1->tech_pvt; 06473 o0nativeformats = c0->nativeformats; 06474 o1nativeformats = c1->nativeformats; 06475 watch_c0_dtmf = config->flags & AST_BRIDGE_DTMF_CHANNEL_0; 06476 watch_c1_dtmf = config->flags & AST_BRIDGE_DTMF_CHANNEL_1; 06477 06478 /* Check the need of a jitterbuffer for each channel */ 06479 jb_in_use = ast_jb_do_usecheck(c0, c1); 06480 if (jb_in_use) 06481 ast_jb_empty_and_reset(c0, c1); 06482 06483 ast_poll_channel_add(c0, c1); 06484 06485 if (config->feature_timer > 0 && ast_tvzero(config->nexteventts)) { 06486 /* nexteventts is not set when the bridge is not scheduled to 06487 * break, so calculate when the bridge should possibly break 06488 * if a partial feature match timed out */ 06489 config->nexteventts = ast_tvadd(ast_tvnow(), ast_samp2tv(config->feature_timer, 1000)); 06490 } 06491 06492 for (;;) { 06493 struct ast_channel *who, *other; 06494 06495 if ((c0->tech_pvt != pvt0) || (c1->tech_pvt != pvt1) || 06496 (o0nativeformats != c0->nativeformats) || 06497 (o1nativeformats != c1->nativeformats)) { 06498 /* Check for Masquerade, codec changes, etc */ 06499 res = AST_BRIDGE_RETRY; 06500 break; 06501 } 06502 if (config->nexteventts.tv_sec) { 06503 to = ast_tvdiff_ms(config->nexteventts, ast_tvnow()); 06504 if (to <= 0) { 06505 if (config->timelimit && !config->feature_timer && !ast_test_flag(config, AST_FEATURE_WARNING_ACTIVE)) { 06506 res = AST_BRIDGE_RETRY; 06507 /* generic bridge ending to play warning */ 06508 ast_set_flag(config, AST_FEATURE_WARNING_ACTIVE); 06509 } else if (config->feature_timer) { 06510 /* feature timer expired - make sure we do not play warning */ 06511 ast_clear_flag(config, AST_FEATURE_WARNING_ACTIVE); 06512 res = AST_BRIDGE_RETRY; 06513 } else { 06514 res = AST_BRIDGE_COMPLETE; 06515 } 06516 break; 06517 } 06518 } else { 06519 /* If a feature has been started and the bridge is configured to 06520 * to not break, leave the channel bridge when the feature timer 06521 * time has elapsed so the DTMF will be sent to the other side. 06522 */ 06523 if (!ast_tvzero(config->nexteventts)) { 06524 int diff = ast_tvdiff_ms(config->nexteventts, ast_tvnow()); 06525 if (diff <= 0) { 06526 res = AST_BRIDGE_RETRY; 06527 break; 06528 } 06529 } 06530 to = -1; 06531 } 06532 /* Calculate the appropriate max sleep interval - in general, this is the time, 06533 left to the closest jb delivery moment */ 06534 if (jb_in_use) 06535 to = ast_jb_get_when_to_wakeup(c0, c1, to); 06536 who = ast_waitfor_n(cs, 2, &to); 06537 if (!who) { 06538 /* No frame received within the specified timeout - check if we have to deliver now */ 06539 if (jb_in_use) 06540 ast_jb_get_and_deliver(c0, c1); 06541 if (c0->_softhangup == AST_SOFTHANGUP_UNBRIDGE || c1->_softhangup == AST_SOFTHANGUP_UNBRIDGE) { 06542 if (c0->_softhangup == AST_SOFTHANGUP_UNBRIDGE) 06543 c0->_softhangup = 0; 06544 if (c1->_softhangup == AST_SOFTHANGUP_UNBRIDGE) 06545 c1->_softhangup = 0; 06546 c0->_bridge = c1; 06547 c1->_bridge = c0; 06548 } 06549 continue; 06550 } 06551 f = ast_read(who); 06552 if (!f) { 06553 *fo = NULL; 06554 *rc = who; 06555 ast_debug(1, "Didn't get a frame from channel: %s\n",who->name); 06556 break; 06557 } 06558 06559 other = (who == c0) ? c1 : c0; /* the 'other' channel */ 06560 /* Try add the frame info the who's bridged channel jitterbuff */ 06561 if (jb_in_use) 06562 frame_put_in_jb = !ast_jb_put(other, f); 06563 06564 if ((f->frametype == AST_FRAME_CONTROL) && !(config->flags & AST_BRIDGE_IGNORE_SIGS)) { 06565 int bridge_exit = 0; 06566 06567 switch (f->subclass.integer) { 06568 case AST_CONTROL_AOC: 06569 ast_indicate_data(other, f->subclass.integer, f->data.ptr, f->datalen); 06570 break; 06571 case AST_CONTROL_REDIRECTING: 06572 if (ast_channel_redirecting_macro(who, other, f, other == c0, 1)) { 06573 ast_indicate_data(other, f->subclass.integer, f->data.ptr, f->datalen); 06574 } 06575 break; 06576 case AST_CONTROL_CONNECTED_LINE: 06577 if (ast_channel_connected_line_macro(who, other, f, other == c0, 1)) { 06578 ast_indicate_data(other, f->subclass.integer, f->data.ptr, f->datalen); 06579 } 06580 break; 06581 case AST_CONTROL_HOLD: 06582 case AST_CONTROL_UNHOLD: 06583 case AST_CONTROL_VIDUPDATE: 06584 case AST_CONTROL_SRCUPDATE: 06585 case AST_CONTROL_SRCCHANGE: 06586 case AST_CONTROL_T38_PARAMETERS: 06587 ast_indicate_data(other, f->subclass.integer, f->data.ptr, f->datalen); 06588 if (jb_in_use) { 06589 ast_jb_empty_and_reset(c0, c1); 06590 } 06591 break; 06592 default: 06593 *fo = f; 06594 *rc = who; 06595 bridge_exit = 1; 06596 ast_debug(1, "Got a FRAME_CONTROL (%d) frame on channel %s\n", f->subclass.integer, who->name); 06597 break; 06598 } 06599 if (bridge_exit) 06600 break; 06601 } 06602 if ((f->frametype == AST_FRAME_VOICE) || 06603 (f->frametype == AST_FRAME_DTMF_BEGIN) || 06604 (f->frametype == AST_FRAME_DTMF) || 06605 (f->frametype == AST_FRAME_VIDEO) || 06606 (f->frametype == AST_FRAME_IMAGE) || 06607 (f->frametype == AST_FRAME_HTML) || 06608 (f->frametype == AST_FRAME_MODEM) || 06609 (f->frametype == AST_FRAME_TEXT)) { 06610 /* monitored dtmf causes exit from bridge */ 06611 int monitored_source = (who == c0) ? watch_c0_dtmf : watch_c1_dtmf; 06612 06613 if (monitored_source && 06614 (f->frametype == AST_FRAME_DTMF_END || 06615 f->frametype == AST_FRAME_DTMF_BEGIN)) { 06616 *fo = f; 06617 *rc = who; 06618 ast_debug(1, "Got DTMF %s on channel (%s)\n", 06619 f->frametype == AST_FRAME_DTMF_END ? "end" : "begin", 06620 who->name); 06621 06622 break; 06623 } 06624 /* Write immediately frames, not passed through jb */ 06625 if (!frame_put_in_jb) 06626 ast_write(other, f); 06627 06628 /* Check if we have to deliver now */ 06629 if (jb_in_use) 06630 ast_jb_get_and_deliver(c0, c1); 06631 } 06632 /* XXX do we want to pass on also frames not matched above ? */ 06633 ast_frfree(f); 06634 06635 #ifndef HAVE_EPOLL 06636 /* Swap who gets priority */ 06637 cs[2] = cs[0]; 06638 cs[0] = cs[1]; 06639 cs[1] = cs[2]; 06640 #endif 06641 } 06642 06643 ast_poll_channel_del(c0, c1); 06644 06645 return res; 06646 }
| struct ast_channel_tech* ast_get_channel_tech | ( | const char * | name | ) | [read] |
Get handle to channel driver based on name.
Get a channel technology structure by name.
Definition at line 890 of file channel.c.
References AST_RWLIST_RDLOCK, AST_RWLIST_TRAVERSE, AST_RWLIST_UNLOCK, chanlist::tech, and ast_channel_tech::type.
Referenced by __ast_channel_alloc_ap(), _ast_device_state(), ast_cc_callback(), and ast_var_channel_types_table().
00891 { 00892 struct chanlist *chanls; 00893 const struct ast_channel_tech *ret = NULL; 00894 00895 AST_RWLIST_RDLOCK(&backends); 00896 00897 AST_RWLIST_TRAVERSE(&backends, chanls, list) { 00898 if (!strcasecmp(name, chanls->tech->type)) { 00899 ret = chanls->tech; 00900 break; 00901 } 00902 } 00903 00904 AST_RWLIST_UNLOCK(&backends); 00905 00906 return ret; 00907 }
| ast_group_t ast_get_group | ( | const char * | s | ) |
Definition at line 7197 of file channel.c.
References ast_log(), ast_strdupa, ast_strlen_zero(), LOG_ERROR, LOG_WARNING, and strsep().
Referenced by _parse(), build_device(), build_gateway(), build_peer(), config_parse_variables(), func_channel_write_real(), process_dahdi(), and read_agent_config().
07198 { 07199 char *piece; 07200 char *c; 07201 int start=0, finish=0, x; 07202 ast_group_t group = 0; 07203 07204 if (ast_strlen_zero(s)) 07205 return 0; 07206 07207 c = ast_strdupa(s); 07208 07209 while ((piece = strsep(&c, ","))) { 07210 if (sscanf(piece, "%30d-%30d", &start, &finish) == 2) { 07211 /* Range */ 07212 } else if (sscanf(piece, "%30d", &start)) { 07213 /* Just one */ 07214 finish = start; 07215 } else { 07216 ast_log(LOG_ERROR, "Syntax error parsing group configuration '%s' at '%s'. Ignoring.\n", s, piece); 07217 continue; 07218 } 07219 for (x = start; x <= finish; x++) { 07220 if ((x > 63) || (x < 0)) { 07221 ast_log(LOG_WARNING, "Ignoring invalid group %d (maximum group is 63)\n", x); 07222 } else 07223 group |= ((ast_group_t) 1 << x); 07224 } 07225 } 07226 return group; 07227 }
| int ast_hangup | ( | struct ast_channel * | chan | ) |
Hangup a channel.
Hang up a channel.
Definition at line 2629 of file channel.c.
References ao2_unlink, ast_assert, ast_audiohook_detach_list(), ast_autoservice_stop(), ast_cause2str(), ast_cc_offer(), ast_cdr_detach(), ast_cdr_end(), AST_CDR_FLAG_BRIDGED, AST_CDR_FLAG_DIALED, AST_CDR_FLAG_POST_DISABLED, AST_CDR_NULL, AST_CEL_HANGUP, ast_cel_report_event(), ast_channel_lock, ast_channel_release(), ast_channel_unlock, ast_closestream(), ast_debug, ast_do_masquerade(), AST_FLAG_BLOCKING, AST_FLAG_ZOMBIE, ast_framehook_list_destroy(), ast_log(), ast_manager_event, ast_set_flag, ast_test_flag, ast_channel::audiohooks, ast_channel::blocker, ast_channel::blockproc, ast_channel::caller, ast_channel::cdr, channels, ast_cdr::disposition, EVENT_FLAG_CALL, free_translation(), ast_channel::generator, ast_channel::generatordata, ast_channel_tech::hangup, ast_channel::hangupcause, ast_channel::hangupsource, ast_party_caller::id, LOG_WARNING, ast_channel::masq, ast_channel::masqr, ast_party_id::name, ast_channel::name, ast_party_id::number, pbx_builtin_getvar_helper(), ast_generator::release, S_COR, S_OR, ast_channel::sched, sched_context_destroy(), ast_party_name::str, ast_party_number::str, ast_channel::stream, ast_channel::tech, ast_channel::uniqueid, ast_party_name::valid, ast_party_number::valid, and ast_channel::vstream.
Referenced by __analog_handle_event(), __analog_ss_thread(), __ast_pbx_run(), __ast_request_and_dial(), __oh323_new(), action_bridge(), alsa_new(), analog_handle_init_event(), analog_ss_thread(), answer_exec_run(), app_exec(), ast_async_goto(), ast_call_forward(), ast_dial_destroy(), ast_dial_hangup(), ast_iax2_new(), ast_pbx_outgoing_app(), ast_pbx_outgoing_exten(), ast_pbx_run_app(), async_wait(), begin_dial_channel(), bridge_call_thread(), bridge_channel_thread(), bridge_exec(), build_conf(), builtin_atxfer(), chanavail_exec(), check_compat(), check_goto_on_transfer(), clear_caller(), conf_free(), conf_run(), connect_link(), console_new(), dahdi_handle_event(), dahdi_new(), destroy_conference_bridge(), dial_exec_full(), dial_transfer(), do_forward(), do_hang(), do_idle_thread(), feature_attended_transfer(), feature_request_and_dial(), findmeexec(), generic_recall(), gtalk_new(), handle_call_forward(), handle_callforward_button(), handle_enbloc_call_message(), handle_frame(), handle_frame_ownerless(), handle_hd_hf(), handle_init_event(), handle_invite_replaces(), handle_offhook_message(), handle_request_invite(), handle_soft_key_event_message(), handle_stimulus_message(), handle_timeout_trip(), handle_transfer_button(), HandleCallOutgoing(), hangup_chan(), hangupcalls(), hanguptree(), iax2_request(), iax_park(), iax_park_thread(), jingle_new(), local_hangup(), manage_parkinglot(), mgcp_new(), mgcp_ss(), monitor_dial(), mwi_thread(), my_distinctive_ring(), my_handle_notify_message(), nbs_new(), oss_new(), park_exec_full(), parkandannounce_exec(), phone_new(), play_sound_file(), pri_dchannel(), pri_ss_thread(), rpt(), rpt_call(), rpt_exec(), rpt_tele_thread(), sip_new(), sip_park(), sip_park_thread(), skinny_new(), skinny_ss(), ss7_start_call(), try_calling(), unistim_new(), usbradio_new(), wait_for_answer(), and wait_for_winner().
02630 { 02631 int res = 0; 02632 char extra_str[64]; /* used for cel logging below */ 02633 02634 /* Don't actually hang up a channel that will masquerade as someone else, or 02635 if someone is going to masquerade as us */ 02636 ast_channel_lock(chan); 02637 02638 if (chan->audiohooks) { 02639 ast_audiohook_detach_list(chan->audiohooks); 02640 chan->audiohooks = NULL; 02641 } 02642 02643 ast_framehook_list_destroy(chan); 02644 02645 ast_autoservice_stop(chan); 02646 02647 if (chan->masq) { 02648 ast_channel_unlock(chan); 02649 if (ast_do_masquerade(chan)) { 02650 ast_log(LOG_WARNING, "Failed to perform masquerade\n"); 02651 } 02652 ast_channel_lock(chan); 02653 } 02654 02655 if (chan->masq) { 02656 ast_log(LOG_WARNING, "%s getting hung up, but someone is trying to masq into us?!?\n", chan->name); 02657 ast_channel_unlock(chan); 02658 return 0; 02659 } 02660 /* If this channel is one which will be masqueraded into something, 02661 mark it as a zombie already, so we know to free it later */ 02662 if (chan->masqr) { 02663 ast_set_flag(chan, AST_FLAG_ZOMBIE); 02664 ast_channel_unlock(chan); 02665 return 0; 02666 } 02667 ast_channel_unlock(chan); 02668 02669 ao2_unlink(channels, chan); 02670 02671 ast_channel_lock(chan); 02672 free_translation(chan); 02673 /* Close audio stream */ 02674 if (chan->stream) { 02675 ast_closestream(chan->stream); 02676 chan->stream = NULL; 02677 } 02678 /* Close video stream */ 02679 if (chan->vstream) { 02680 ast_closestream(chan->vstream); 02681 chan->vstream = NULL; 02682 } 02683 if (chan->sched) { 02684 sched_context_destroy(chan->sched); 02685 chan->sched = NULL; 02686 } 02687 02688 if (chan->generatordata) /* Clear any tone stuff remaining */ 02689 if (chan->generator && chan->generator->release) 02690 chan->generator->release(chan, chan->generatordata); 02691 chan->generatordata = NULL; 02692 chan->generator = NULL; 02693 02694 snprintf(extra_str, sizeof(extra_str), "%d,%s,%s", chan->hangupcause, chan->hangupsource, S_OR(pbx_builtin_getvar_helper(chan, "DIALSTATUS"), "")); 02695 ast_cel_report_event(chan, AST_CEL_HANGUP, NULL, extra_str, NULL); 02696 02697 if (ast_test_flag(chan, AST_FLAG_BLOCKING)) { 02698 ast_log(LOG_WARNING, "Hard hangup called by thread %ld on %s, while fd " 02699 "is blocked by thread %ld in procedure %s! Expect a failure\n", 02700 (long)pthread_self(), chan->name, (long)chan->blocker, chan->blockproc); 02701 ast_assert(ast_test_flag(chan, AST_FLAG_BLOCKING) == 0); 02702 } 02703 if (!ast_test_flag(chan, AST_FLAG_ZOMBIE)) { 02704 ast_debug(1, "Hanging up channel '%s'\n", chan->name); 02705 if (chan->tech->hangup) 02706 res = chan->tech->hangup(chan); 02707 } else { 02708 ast_debug(1, "Hanging up zombie '%s'\n", chan->name); 02709 } 02710 02711 ast_channel_unlock(chan); 02712 ast_cc_offer(chan); 02713 ast_manager_event(chan, EVENT_FLAG_CALL, "Hangup", 02714 "Channel: %s\r\n" 02715 "Uniqueid: %s\r\n" 02716 "CallerIDNum: %s\r\n" 02717 "CallerIDName: %s\r\n" 02718 "Cause: %d\r\n" 02719 "Cause-txt: %s\r\n", 02720 chan->name, 02721 chan->uniqueid, 02722 S_COR(chan->caller.id.number.valid, chan->caller.id.number.str, "<unknown>"), 02723 S_COR(chan->caller.id.name.valid, chan->caller.id.name.str, "<unknown>"), 02724 chan->hangupcause, 02725 ast_cause2str(chan->hangupcause) 02726 ); 02727 02728 if (chan->cdr && !ast_test_flag(chan->cdr, AST_CDR_FLAG_BRIDGED) && 02729 !ast_test_flag(chan->cdr, AST_CDR_FLAG_POST_DISABLED) && 02730 (chan->cdr->disposition != AST_CDR_NULL || ast_test_flag(chan->cdr, AST_CDR_FLAG_DIALED))) { 02731 ast_channel_lock(chan); 02732 02733 ast_cdr_end(chan->cdr); 02734 ast_cdr_detach(chan->cdr); 02735 chan->cdr = NULL; 02736 ast_channel_unlock(chan); 02737 } 02738 02739 chan = ast_channel_release(chan); 02740 02741 return res; 02742 }
| int ast_indicate | ( | struct ast_channel * | chan, | |
| int | condition | |||
| ) |
Indicates condition of channel.
| chan | channel to change the indication | |
| condition | which condition to indicate on the channel |
Definition at line 4117 of file channel.c.
References ast_indicate_data().
Referenced by __ast_play_and_record(), agent_new(), alsa_call(), analog_attempt_transfer(), answer_trunk_chan(), ast_bridge_call(), ast_channel_bridge(), ast_do_masquerade(), ast_dtmf_stream(), ast_raw_answer(), attempt_transfer(), builtin_atxfer(), builtin_blindtransfer(), cli_console_answer(), conf_run(), console_call(), dial_exec_full(), disa_exec(), do_forward(), feature_request_and_dial(), finishup(), function_remote(), handle_callforward_button(), handle_frame(), handle_recordfile(), local_attended_transfer(), manage_parkinglot(), mgcp_ss(), monitor_dial(), oss_call(), park_call_full(), park_exec_full(), pbx_builtin_busy(), pbx_builtin_congestion(), pbx_builtin_proceeding(), pbx_builtin_progress(), pbx_builtin_ringing(), pbx_builtin_waitexten(), queue_exec(), record_exec(), rna(), rpt(), rpt_exec(), say_periodic_announcement(), say_position(), send_waveform_to_channel(), skinny_ss(), sla_handle_hold_event(), sla_station_exec(), sla_trunk_exec(), try_calling(), and wait_for_answer().
04118 { 04119 return ast_indicate_data(chan, condition, NULL, 0); 04120 }
| int ast_indicate_data | ( | struct ast_channel * | chan, | |
| int | condition, | |||
| const void * | data, | |||
| size_t | datalen | |||
| ) |
Indicates condition of channel, with payload.
| chan | channel to change the indication | |
| condition | which condition to indicate on the channel | |
| data | pointer to payload data | |
| datalen | size of payload data |
Definition at line 4164 of file channel.c.
References ast_channel::_state, _XXX_AST_CONTROL_T38, ast_channel_lock, ast_channel_set_connected_line(), ast_channel_set_redirecting(), ast_channel_unlock, ast_check_hangup(), ast_connected_line_parse_data(), AST_CONTROL_ANSWER, AST_CONTROL_AOC, AST_CONTROL_BUSY, AST_CONTROL_CC, AST_CONTROL_CONGESTION, AST_CONTROL_CONNECTED_LINE, AST_CONTROL_FLASH, AST_CONTROL_HANGUP, AST_CONTROL_HOLD, AST_CONTROL_OFFHOOK, AST_CONTROL_OPTION, AST_CONTROL_PROCEEDING, AST_CONTROL_PROGRESS, AST_CONTROL_RADIO_KEY, AST_CONTROL_RADIO_UNKEY, AST_CONTROL_READ_ACTION, AST_CONTROL_REDIRECTING, AST_CONTROL_RING, AST_CONTROL_RINGING, AST_CONTROL_SRCCHANGE, AST_CONTROL_SRCUPDATE, AST_CONTROL_T38_PARAMETERS, AST_CONTROL_TAKEOFFHOOK, AST_CONTROL_TRANSFER, AST_CONTROL_UNHOLD, AST_CONTROL_VIDUPDATE, AST_CONTROL_WINK, ast_debug, AST_FLAG_ZOMBIE, AST_FRAME_CONTROL, ast_framehook_list_is_empty(), ast_framehook_list_read_event(), ast_frdup(), ast_frfree, ast_get_indication_tone(), ast_log(), ast_party_connected_line_free(), ast_party_connected_line_set_init(), ast_party_redirecting_free(), ast_party_redirecting_set_init(), ast_playtones_start(), ast_playtones_stop(), ast_redirecting_parse_data(), AST_STATE_UP, ast_test_flag, ast_tone_zone_sound_unref(), ast_channel::connected, ast_tone_zone_sound::data, ast_frame::data, ast_frame::datalen, ast_channel::framehooks, ast_frame::frametype, ast_channel_tech::indicate, ast_frame_subclass::integer, is_visible_indication(), LOG_WARNING, ast_channel::name, ast_frame::ptr, ast_channel::redirecting, ast_frame::subclass, ast_channel::tech, ast_channel::visible_indication, and ast_channel::zone.
Referenced by __ast_read(), action_aocmessage(), agent_hangup(), ast_bridge_call(), ast_channel_update_connected_line(), ast_channel_update_redirecting(), ast_generic_bridge(), ast_handle_cc_control_frame(), ast_indicate(), disable_t38(), feature_request_and_dial(), generic_fax_exec(), handle_frame(), local_bridge_loop(), login_exec(), manage_parkinglot(), park_call_full(), pbx_builtin_waitexten(), receivefax_t38_init(), remote_bridge_loop(), sendfax_t38_init(), set_fax_t38_caps(), transmit_audio(), transmit_t38(), and wait_for_answer().
04166 { 04167 /* By using an enum, we'll get compiler warnings for values not handled 04168 * in switch statements. */ 04169 enum ast_control_frame_type condition = _condition; 04170 struct ast_tone_zone_sound *ts = NULL; 04171 int res; 04172 /* this frame is used by framehooks. if it is set, we must free it at the end of this function */ 04173 struct ast_frame *awesome_frame = NULL; 04174 04175 ast_channel_lock(chan); 04176 04177 /* Don't bother if the channel is about to go away, anyway. */ 04178 if (ast_test_flag(chan, AST_FLAG_ZOMBIE) || ast_check_hangup(chan)) { 04179 ast_channel_unlock(chan); 04180 res = -1; 04181 goto indicate_cleanup; 04182 } 04183 04184 if (!ast_framehook_list_is_empty(chan->framehooks)) { 04185 /* Do framehooks now, do it, go, go now */ 04186 struct ast_frame frame = { 04187 .frametype = AST_FRAME_CONTROL, 04188 .subclass.integer = condition, 04189 .data.ptr = (void *) data, /* this cast from const is only okay because we do the ast_frdup below */ 04190 .datalen = datalen 04191 }; 04192 04193 /* we have now committed to freeing this frame */ 04194 awesome_frame = ast_frdup(&frame); 04195 04196 /* who knows what we will get back! the anticipation is killing me. */ 04197 if (!(awesome_frame = ast_framehook_list_read_event(chan->framehooks, &frame))) { 04198 ast_channel_unlock(chan); 04199 res = 0; 04200 goto indicate_cleanup; 04201 } 04202 04203 condition = awesome_frame->subclass.integer; 04204 data = awesome_frame->data.ptr; 04205 datalen = awesome_frame->datalen; 04206 } 04207 04208 switch (condition) { 04209 case AST_CONTROL_CONNECTED_LINE: 04210 { 04211 struct ast_party_connected_line connected; 04212 04213 ast_party_connected_line_set_init(&connected, &chan->connected); 04214 res = ast_connected_line_parse_data(data, datalen, &connected); 04215 if (!res) { 04216 ast_channel_set_connected_line(chan, &connected, NULL); 04217 } 04218 ast_party_connected_line_free(&connected); 04219 } 04220 break; 04221 04222 case AST_CONTROL_REDIRECTING: 04223 { 04224 struct ast_party_redirecting redirecting; 04225 04226 ast_party_redirecting_set_init(&redirecting, &chan->redirecting); 04227 res = ast_redirecting_parse_data(data, datalen, &redirecting); 04228 if (!res) { 04229 ast_channel_set_redirecting(chan, &redirecting, NULL); 04230 } 04231 ast_party_redirecting_free(&redirecting); 04232 } 04233 break; 04234 04235 default: 04236 break; 04237 } 04238 04239 if (chan->tech->indicate) { 04240 /* See if the channel driver can handle this condition. */ 04241 res = chan->tech->indicate(chan, condition, data, datalen); 04242 } else { 04243 res = -1; 04244 } 04245 04246 ast_channel_unlock(chan); 04247 04248 if (!res) { 04249 /* The channel driver successfully handled this indication */ 04250 if (is_visible_indication(condition)) { 04251 chan->visible_indication = condition; 04252 } 04253 res = 0; 04254 goto indicate_cleanup; 04255 } 04256 04257 /* The channel driver does not support this indication, let's fake 04258 * it by doing our own tone generation if applicable. */ 04259 04260 /*!\note If we compare the enumeration type, which does not have any 04261 * negative constants, the compiler may optimize this code away. 04262 * Therefore, we must perform an integer comparison here. */ 04263 if (_condition < 0) { 04264 /* Stop any tones that are playing */ 04265 ast_playtones_stop(chan); 04266 res = 0; 04267 goto indicate_cleanup; 04268 } 04269 04270 /* Handle conditions that we have tones for. */ 04271 switch (condition) { 04272 case _XXX_AST_CONTROL_T38: 04273 /* deprecated T.38 control frame */ 04274 res = -1; 04275 goto indicate_cleanup; 04276 case AST_CONTROL_T38_PARAMETERS: 04277 /* there is no way to provide 'default' behavior for these 04278 * control frames, so we need to return failure, but there 04279 * is also no value in the log message below being emitted 04280 * since failure to handle these frames is not an 'error' 04281 * so just return right now. in addition, we want to return 04282 * whatever value the channel driver returned, in case it 04283 * has some meaning.*/ 04284 goto indicate_cleanup; 04285 case AST_CONTROL_RINGING: 04286 ts = ast_get_indication_tone(chan->zone, "ring"); 04287 /* It is common practice for channel drivers to return -1 if trying 04288 * to indicate ringing on a channel which is up. The idea is to let the 04289 * core generate the ringing inband. However, we don't want the 04290 * warning message about not being able to handle the specific indication 04291 * to print nor do we want ast_indicate_data to return an "error" for this 04292 * condition 04293 */ 04294 if (chan->_state == AST_STATE_UP) { 04295 res = 0; 04296 } 04297 break; 04298 case AST_CONTROL_BUSY: 04299 ts = ast_get_indication_tone(chan->zone, "busy"); 04300 break; 04301 case AST_CONTROL_CONGESTION: 04302 ts = ast_get_indication_tone(chan->zone, "congestion"); 04303 break; 04304 case AST_CONTROL_PROGRESS: 04305 case AST_CONTROL_PROCEEDING: 04306 case AST_CONTROL_VIDUPDATE: 04307 case AST_CONTROL_SRCUPDATE: 04308 case AST_CONTROL_SRCCHANGE: 04309 case AST_CONTROL_RADIO_KEY: 04310 case AST_CONTROL_RADIO_UNKEY: 04311 case AST_CONTROL_OPTION: 04312 case AST_CONTROL_WINK: 04313 case AST_CONTROL_FLASH: 04314 case AST_CONTROL_OFFHOOK: 04315 case AST_CONTROL_TAKEOFFHOOK: 04316 case AST_CONTROL_ANSWER: 04317 case AST_CONTROL_HANGUP: 04318 case AST_CONTROL_RING: 04319 case AST_CONTROL_HOLD: 04320 case AST_CONTROL_UNHOLD: 04321 case AST_CONTROL_TRANSFER: 04322 case AST_CONTROL_CONNECTED_LINE: 04323 case AST_CONTROL_REDIRECTING: 04324 case AST_CONTROL_CC: 04325 case AST_CONTROL_READ_ACTION: 04326 case AST_CONTROL_AOC: 04327 /* Nothing left to do for these. */ 04328 res = 0; 04329 break; 04330 } 04331 04332 if (ts) { 04333 /* We have a tone to play, yay. */ 04334 ast_debug(1, "Driver for channel '%s' does not support indication %d, emulating it\n", chan->name, condition); 04335 ast_playtones_start(chan, 0, ts->data, 1); 04336 ts = ast_tone_zone_sound_unref(ts); 04337 res = 0; 04338 chan->visible_indication = condition; 04339 } 04340 04341 if (res) { 04342 /* not handled */ 04343 ast_log(LOG_WARNING, "Unable to handle indication %d for '%s'\n", condition, chan->name); 04344 } 04345 04346 indicate_cleanup: 04347 if (awesome_frame) { 04348 ast_frfree(awesome_frame); 04349 } 04350 04351 return res; 04352 }
| void ast_install_music_functions | ( | int(*)(struct ast_channel *, const char *, const char *) | start_ptr, | |
| void(*)(struct ast_channel *) | stop_ptr, | |||
| void(*)(struct ast_channel *) | cleanup_ptr | |||
| ) |
Definition at line 7233 of file channel.c.
References ast_moh_cleanup_ptr, ast_moh_start_ptr, and ast_moh_stop_ptr.
Referenced by load_module().
07236 { 07237 ast_moh_start_ptr = start_ptr; 07238 ast_moh_stop_ptr = stop_ptr; 07239 ast_moh_cleanup_ptr = cleanup_ptr; 07240 }
| int ast_internal_timing_enabled | ( | struct ast_channel * | chan | ) |
Check if the channel can run in internal timing mode.
| chan | The channel to check |
Definition at line 4102 of file channel.c.
References ast_opt_internal_timing, and ast_channel::timingfd.
Referenced by add_sdp(), and ast_read_generator_actions().
04103 { 04104 return (ast_opt_internal_timing && chan->timingfd > -1); 04105 }
| int ast_is_deferrable_frame | ( | const struct ast_frame * | frame | ) |
Should we keep this frame for later?
There are functions such as ast_safe_sleep which will service a channel to ensure that it does not have a large backlog of queued frames. When this happens, we want to hold on to specific frame types and just drop others. This function will tell if the frame we just read should be held onto.
| frame | The frame we just read |
| 1 | frame should be kept | |
| 0 | frame should be dropped |
Definition at line 1699 of file channel.c.
References AST_FRAME_CNG, AST_FRAME_CONTROL, AST_FRAME_DTMF_BEGIN, AST_FRAME_DTMF_END, AST_FRAME_HTML, AST_FRAME_IAX, AST_FRAME_IMAGE, AST_FRAME_MODEM, AST_FRAME_NULL, AST_FRAME_TEXT, AST_FRAME_VIDEO, AST_FRAME_VOICE, and ast_frame::frametype.
Referenced by ast_safe_sleep_conditional(), and autoservice_run().
01700 { 01701 /* Do not add a default entry in this switch statement. Each new 01702 * frame type should be addressed directly as to whether it should 01703 * be queued up or not. 01704 */ 01705 switch (frame->frametype) { 01706 case AST_FRAME_DTMF_END: 01707 case AST_FRAME_CONTROL: 01708 case AST_FRAME_TEXT: 01709 case AST_FRAME_IMAGE: 01710 case AST_FRAME_HTML: 01711 return 1; 01712 01713 case AST_FRAME_DTMF_BEGIN: 01714 case AST_FRAME_VOICE: 01715 case AST_FRAME_VIDEO: 01716 case AST_FRAME_NULL: 01717 case AST_FRAME_IAX: 01718 case AST_FRAME_CNG: 01719 case AST_FRAME_MODEM: 01720 return 0; 01721 } 01722 return 0; 01723 }
| void ast_moh_cleanup | ( | struct ast_channel * | chan | ) |
Definition at line 7267 of file channel.c.
References ast_moh_cleanup_ptr.
Referenced by ast_channel_destructor().
07268 { 07269 if (ast_moh_cleanup_ptr) 07270 ast_moh_cleanup_ptr(chan); 07271 }
| int ast_moh_start | ( | struct ast_channel * | chan, | |
| const char * | mclass, | |||
| const char * | interpclass | |||
| ) |
Turn on music on hold on a given channel.
| chan | The channel structure that will get music on hold | |
| mclass | The class to use if the musicclass is not currently set on the channel structure. | |
| interpclass | The class to use if the musicclass is not currently set on the channel structure or in the mclass argument. |
| Zero | on success | |
| non-zero | on failure |
Definition at line 7250 of file channel.c.
References ast_moh_start_ptr, and ast_verb.
Referenced by alsa_indicate(), app_exec(), conf_run(), conf_start_moh(), console_indicate(), dahdi_indicate(), dial_exec_full(), feature_exec_app(), gtalk_indicate(), handle_setmusic(), iax2_indicate(), jingle_indicate(), key_call(), leave_conference_bridge(), local_indicate(), menu_callback(), mgcp_indicate(), misdn_indication(), moh_handle_digit(), monitor_dial(), oh323_indicate(), oss_indicate(), phone_indicate(), play_moh_exec(), post_join_marked(), post_join_unmarked(), queue_exec(), retrydial_exec(), rna(), say_periodic_announcement(), say_position(), sig_pri_indicate(), sig_ss7_indicate(), sip_indicate(), skinny_indicate(), start_moh_exec(), TransferCallStep1(), unistim_indicate(), usbradio_indicate(), and wait_moh_exec().
07251 { 07252 if (ast_moh_start_ptr) 07253 return ast_moh_start_ptr(chan, mclass, interpclass); 07254 07255 ast_verb(3, "Music class %s requested but no musiconhold loaded.\n", mclass ? mclass : (interpclass ? interpclass : "default")); 07256 07257 return 0; 07258 }
| void ast_moh_stop | ( | struct ast_channel * | chan | ) |
Turn off music on hold on a given channel.
Turn off music on hold on a given channel
Definition at line 7261 of file channel.c.
References ast_moh_stop_ptr.
Referenced by alsa_indicate(), app_exec(), ast_quiet_chan(), conf_run(), console_indicate(), dahdi_indicate(), dial_exec_full(), do_bridge_masquerade(), feature_exec_app(), gtalk_indicate(), handle_setmusic(), iax2_indicate(), jingle_indicate(), key_call(), key_dial_page(), local_indicate(), menu_callback(), mgcp_indicate(), misdn_indication(), moh_handle_digit(), monitor_dial(), oh323_indicate(), oss_indicate(), phone_indicate(), play_moh_exec(), post_join_marked(), post_join_unmarked(), queue_exec(), retrydial_exec(), say_periodic_announcement(), say_position(), sig_pri_indicate(), sig_ss7_indicate(), sip_indicate(), skinny_indicate(), stop_moh_exec(), try_calling(), unistim_hangup(), unistim_indicate(), usbradio_indicate(), wait_for_answer(), and wait_moh_exec().
07262 { 07263 if (ast_moh_stop_ptr) 07264 ast_moh_stop_ptr(chan); 07265 }
| void ast_party_caller_copy | ( | struct ast_party_caller * | dest, | |
| const struct ast_party_caller * | src | |||
| ) |
Copy the source caller information to the destination caller.
| dest | Destination caller | |
| src | Source caller |
Definition at line 2150 of file channel.c.
References ast_party_caller::ani, ast_party_caller::ani2, ast_party_id_copy(), and ast_party_caller::id.
Referenced by ast_call_forward(), do_forward(), and wait_for_answer().
02151 { 02152 if (dest == src) { 02153 /* Don't copy to self */ 02154 return; 02155 } 02156 02157 ast_party_id_copy(&dest->id, &src->id); 02158 ast_party_id_copy(&dest->ani, &src->ani); 02159 dest->ani2 = src->ani2; 02160 }
| void ast_party_caller_free | ( | struct ast_party_caller * | doomed | ) |
Destroy the caller party contents.
| doomed | The caller party to destroy. |
Definition at line 2176 of file channel.c.
References ast_party_caller::ani, ast_party_id_free(), and ast_party_caller::id.
Referenced by ast_channel_destructor(), ast_dummy_channel_destructor(), callerid_write(), dial_trunk(), and sla_ring_station().
02177 { 02178 ast_party_id_free(&doomed->id); 02179 ast_party_id_free(&doomed->ani); 02180 }
| void ast_party_caller_init | ( | struct ast_party_caller * | init | ) |
Initialize the given caller structure.
| init | Caller structure to initialize. |
Definition at line 2143 of file channel.c.
References ast_party_caller::ani, ast_party_caller::ani2, ast_party_id_init(), and ast_party_caller::id.
Referenced by __ast_channel_alloc_ap(), dial_trunk(), sig_pri_set_caller_id(), sig_ss7_set_caller_id(), and sla_ring_station().
02144 { 02145 ast_party_id_init(&init->id); 02146 ast_party_id_init(&init->ani); 02147 init->ani2 = 0; 02148 }
| void ast_party_caller_set | ( | struct ast_party_caller * | dest, | |
| const struct ast_party_caller * | src, | |||
| const struct ast_set_party_caller * | update | |||
| ) |
Set the caller information based on another caller source.
| dest | The caller one wishes to update | |
| src | The new caller values to update the dest | |
| update | What caller information to update. NULL if all. |
Definition at line 2169 of file channel.c.
References ast_set_party_caller::ani, ast_party_caller::ani, ast_party_caller::ani2, ast_party_id_set(), ast_set_party_caller::id, and ast_party_caller::id.
Referenced by ast_channel_set_caller(), ast_channel_set_caller_event(), and callerid_write().
02170 { 02171 ast_party_id_set(&dest->id, &src->id, update ? &update->id : NULL); 02172 ast_party_id_set(&dest->ani, &src->ani, update ? &update->ani : NULL); 02173 dest->ani2 = src->ani2; 02174 }
| void ast_party_caller_set_init | ( | struct ast_party_caller * | init, | |
| const struct ast_party_caller * | guide | |||
| ) |
Initialize the given caller structure using the given guide for a set update operation.
| init | Caller structure to initialize. | |
| guide | Source caller to use as a guide in initializing. |
Definition at line 2162 of file channel.c.
References ast_party_caller::ani, ast_party_caller::ani2, ast_party_id_set_init(), and ast_party_caller::id.
Referenced by callerid_write(), dial_exec_full(), misdn_update_caller_id(), and ring_entry().
02163 { 02164 ast_party_id_set_init(&init->id, &guide->id); 02165 ast_party_id_set_init(&init->ani, &guide->ani); 02166 init->ani2 = guide->ani2; 02167 }
| void ast_party_connected_line_collect_caller | ( | struct ast_party_connected_line * | connected, | |
| struct ast_party_caller * | caller | |||
| ) |
Collect the caller party information into a connected line structure.
| connected | Collected caller information for the connected line | |
| caller | Caller information. |
DO NOT call ast_party_connected_line_free() on the filled in connected line structure!
Definition at line 2219 of file channel.c.
References ast_party_caller::ani, ast_party_connected_line::ani, ast_party_caller::ani2, ast_party_connected_line::ani2, AST_CONNECTED_LINE_UPDATE_SOURCE_UNKNOWN, ast_party_caller::id, ast_party_connected_line::id, and ast_party_connected_line::source.
Referenced by ast_pickup_call().
02220 { 02221 connected->id = caller->id; 02222 connected->ani = caller->ani; 02223 connected->ani2 = caller->ani2; 02224 connected->source = AST_CONNECTED_LINE_UPDATE_SOURCE_UNKNOWN; 02225 }
| void ast_party_connected_line_copy | ( | struct ast_party_connected_line * | dest, | |
| const struct ast_party_connected_line * | src | |||
| ) |
Copy the source connected line information to the destination connected line.
| dest | Destination connected line | |
| src | Source connected line |
Definition at line 2190 of file channel.c.
References ast_party_connected_line::ani, ast_party_connected_line::ani2, ast_party_id_copy(), ast_party_connected_line::id, and ast_party_connected_line::source.
Referenced by __ast_read(), ast_call_forward(), ast_channel_connected_line_macro(), builtin_atxfer(), dial_exec_full(), do_forward(), local_attended_transfer(), pickup_do(), try_calling(), and wait_for_answer().
02191 { 02192 if (dest == src) { 02193 /* Don't copy to self */ 02194 return; 02195 } 02196 02197 ast_party_id_copy(&dest->id, &src->id); 02198 ast_party_id_copy(&dest->ani, &src->ani); 02199 dest->ani2 = src->ani2; 02200 dest->source = src->source; 02201 }
| void ast_party_connected_line_free | ( | struct ast_party_connected_line * | doomed | ) |
Destroy the connected line information contents.
| doomed | The connected line information to destroy. |
Definition at line 2227 of file channel.c.
References ast_party_connected_line::ani, ast_party_id_free(), and ast_party_connected_line::id.
Referenced by __ast_read(), ast_channel_destructor(), ast_dummy_channel_destructor(), ast_indicate_data(), builtin_atxfer(), callattempt_free(), chanlist_free(), connectedline_write(), local_attended_transfer(), pickup_do(), sig_pri_handle_subcmds(), socket_process(), and wait_for_answer().
02228 { 02229 ast_party_id_free(&doomed->id); 02230 ast_party_id_free(&doomed->ani); 02231 }
| void ast_party_connected_line_init | ( | struct ast_party_connected_line * | init | ) |
Initialize the given connected line structure.
| init | Connected line structure to initialize. |
Definition at line 2182 of file channel.c.
References ast_party_connected_line::ani, ast_party_connected_line::ani2, AST_CONNECTED_LINE_UPDATE_SOURCE_UNKNOWN, ast_party_id_init(), ast_party_connected_line::id, and ast_party_connected_line::source.
Referenced by __ast_channel_alloc_ap(), __ast_read(), builtin_atxfer(), handle_request_invite(), handle_request_update(), handle_response_invite(), local_attended_transfer(), misdn_queue_connected_line_update(), pickup_do(), sig_pri_handle_subcmds(), socket_process(), and wait_for_answer().
02183 { 02184 ast_party_id_init(&init->id); 02185 ast_party_id_init(&init->ani); 02186 init->ani2 = 0; 02187 init->source = AST_CONNECTED_LINE_UPDATE_SOURCE_UNKNOWN; 02188 }
| void ast_party_connected_line_set | ( | struct ast_party_connected_line * | dest, | |
| const struct ast_party_connected_line * | src, | |||
| const struct ast_set_party_connected_line * | update | |||
| ) |
Set the connected line information based on another connected line source.
| dest | The connected line one wishes to update | |
| src | The new connected line values to update the dest | |
| update | What connected line information to update. NULL if all. |
Definition at line 2211 of file channel.c.
References ast_set_party_connected_line::ani, ast_party_connected_line::ani, ast_party_connected_line::ani2, ast_party_id_set(), ast_set_party_connected_line::id, ast_party_connected_line::id, and ast_party_connected_line::source.
Referenced by ast_channel_set_connected_line(), and wait_for_answer().
02212 { 02213 ast_party_id_set(&dest->id, &src->id, update ? &update->id : NULL); 02214 ast_party_id_set(&dest->ani, &src->ani, update ? &update->ani : NULL); 02215 dest->ani2 = src->ani2; 02216 dest->source = src->source; 02217 }
| void ast_party_connected_line_set_init | ( | struct ast_party_connected_line * | init, | |
| const struct ast_party_connected_line * | guide | |||
| ) |
Initialize the given connected line structure using the given guide for a set update operation.
| init | Connected line structure to initialize. | |
| guide | Source connected line to use as a guide in initializing. |
Definition at line 2203 of file channel.c.
References ast_party_connected_line::ani, ast_party_connected_line::ani2, ast_party_id_set_init(), ast_party_connected_line::id, and ast_party_connected_line::source.
Referenced by __ast_request_and_dial(), ast_indicate_data(), connectedline_write(), dial_exec_full(), and wait_for_answer().
02204 { 02205 ast_party_id_set_init(&init->id, &guide->id); 02206 ast_party_id_set_init(&init->ani, &guide->ani); 02207 init->ani2 = guide->ani2; 02208 init->source = guide->source; 02209 }
| void ast_party_dialed_copy | ( | struct ast_party_dialed * | dest, | |
| const struct ast_party_dialed * | src | |||
| ) |
Copy the source dialed party information to the destination dialed party.
| dest | Destination dialed party | |
| src | Source dialed party |
Definition at line 2101 of file channel.c.
References ast_free, ast_party_subaddress_copy(), ast_strdup, ast_party_dialed::number, ast_party_dialed::plan, ast_party_dialed::str, ast_party_dialed::subaddress, and ast_party_dialed::transit_network_select.
Referenced by local_call().
02102 { 02103 if (dest == src) { 02104 /* Don't copy to self */ 02105 return; 02106 } 02107 02108 ast_free(dest->number.str); 02109 dest->number.str = ast_strdup(src->number.str); 02110 dest->number.plan = src->number.plan; 02111 ast_party_subaddress_copy(&dest->subaddress, &src->subaddress); 02112 dest->transit_network_select = src->transit_network_select; 02113 }
| void ast_party_dialed_free | ( | struct ast_party_dialed * | doomed | ) |
Destroy the dialed party contents.
| doomed | The dialed party to destroy. |
Definition at line 2136 of file channel.c.
References ast_free, ast_party_subaddress_free(), ast_party_dialed::number, ast_party_dialed::str, and ast_party_dialed::subaddress.
Referenced by ast_channel_destructor(), ast_dummy_channel_destructor(), and callerid_write().
02137 { 02138 ast_free(doomed->number.str); 02139 doomed->number.str = NULL; 02140 ast_party_subaddress_free(&doomed->subaddress); 02141 }
| void ast_party_dialed_init | ( | struct ast_party_dialed * | init | ) |
Initialize the given dialed structure.
| init | Dialed structure to initialize. |
Definition at line 2093 of file channel.c.
References ast_party_subaddress_init(), ast_party_dialed::number, ast_party_dialed::plan, ast_party_dialed::str, ast_party_dialed::subaddress, and ast_party_dialed::transit_network_select.
Referenced by __ast_channel_alloc_ap().
02094 { 02095 init->number.str = NULL; 02096 init->number.plan = 0;/* Unknown */ 02097 ast_party_subaddress_init(&init->subaddress); 02098 init->transit_network_select = 0; 02099 }
| void ast_party_dialed_set | ( | struct ast_party_dialed * | dest, | |
| const struct ast_party_dialed * | src | |||
| ) |
Set the dialed information based on another dialed source.
| dest | The dialed one wishes to update | |
| src | The new dialed values to update the dest |
Definition at line 2123 of file channel.c.
References ast_free, ast_party_subaddress_set(), ast_strdup, ast_party_dialed::number, ast_party_dialed::plan, ast_party_dialed::str, ast_party_dialed::subaddress, and ast_party_dialed::transit_network_select.
Referenced by callerid_write().
02124 { 02125 if (src->number.str && src->number.str != dest->number.str) { 02126 ast_free(dest->number.str); 02127 dest->number.str = ast_strdup(src->number.str); 02128 } 02129 dest->number.plan = src->number.plan; 02130 02131 ast_party_subaddress_set(&dest->subaddress, &src->subaddress); 02132 02133 dest->transit_network_select = src->transit_network_select; 02134 }
| void ast_party_dialed_set_init | ( | struct ast_party_dialed * | init, | |
| const struct ast_party_dialed * | guide | |||
| ) |
Initialize the given dialed structure using the given guide for a set update operation.
| init | Caller structure to initialize. | |
| guide | Source dialed to use as a guide in initializing. |
Definition at line 2115 of file channel.c.
References ast_party_subaddress_set_init(), ast_party_dialed::number, ast_party_dialed::plan, ast_party_dialed::str, ast_party_dialed::subaddress, and ast_party_dialed::transit_network_select.
Referenced by callerid_write().
02116 { 02117 init->number.str = NULL; 02118 init->number.plan = guide->number.plan; 02119 ast_party_subaddress_set_init(&init->subaddress, &guide->subaddress); 02120 init->transit_network_select = guide->transit_network_select; 02121 }
| void ast_party_id_copy | ( | struct ast_party_id * | dest, | |
| const struct ast_party_id * | src | |||
| ) |
Copy the source party id information to the destination party id.
| dest | Destination party id | |
| src | Source party id |
Definition at line 1972 of file channel.c.
References ast_free, ast_party_name_copy(), ast_party_number_copy(), ast_party_subaddress_copy(), ast_strdup, ast_party_id::name, ast_party_id::number, ast_party_id::subaddress, and ast_party_id::tag.
Referenced by ast_connected_line_copy_from_caller(), ast_connected_line_copy_to_caller(), ast_party_caller_copy(), ast_party_connected_line_copy(), and ast_party_redirecting_copy().
01973 { 01974 if (dest == src) { 01975 /* Don't copy to self */ 01976 return; 01977 } 01978 01979 ast_party_name_copy(&dest->name, &src->name); 01980 ast_party_number_copy(&dest->number, &src->number); 01981 ast_party_subaddress_copy(&dest->subaddress, &src->subaddress); 01982 01983 ast_free(dest->tag); 01984 dest->tag = ast_strdup(src->tag); 01985 }
| void ast_party_id_free | ( | struct ast_party_id * | doomed | ) |
Destroy the party id contents.
| doomed | The party id to destroy. |
Definition at line 2018 of file channel.c.
References ast_free, ast_party_name_free(), ast_party_number_free(), ast_party_subaddress_free(), ast_party_id::name, ast_party_id::number, ast_party_id::subaddress, and ast_party_id::tag.
Referenced by ast_party_caller_free(), ast_party_connected_line_free(), ast_party_redirecting_free(), and do_forward().
02019 { 02020 ast_party_name_free(&doomed->name); 02021 ast_party_number_free(&doomed->number); 02022 ast_party_subaddress_free(&doomed->subaddress); 02023 02024 ast_free(doomed->tag); 02025 doomed->tag = NULL; 02026 }
| void ast_party_id_init | ( | struct ast_party_id * | init | ) |
Initialize the given party id structure.
| init | Party id structure to initialize. |
Definition at line 1964 of file channel.c.
References ast_party_name_init(), ast_party_number_init(), ast_party_subaddress_init(), ast_party_id::name, ast_party_id::number, ast_party_id::subaddress, and ast_party_id::tag.
Referenced by ast_party_caller_init(), ast_party_connected_line_init(), ast_party_redirecting_init(), and do_forward().
01965 { 01966 ast_party_name_init(&init->name); 01967 ast_party_number_init(&init->number); 01968 ast_party_subaddress_init(&init->subaddress); 01969 init->tag = NULL; 01970 }
| int ast_party_id_presentation | ( | const struct ast_party_id * | id | ) |
Determine the overall presentation value for the given party.
| id | Party to determine the overall presentation value. |
Definition at line 2028 of file channel.c.
References AST_PRES_ALLOWED, AST_PRES_NUMBER_TYPE, AST_PRES_RESTRICTED, AST_PRES_RESTRICTION, AST_PRES_UNAVAILABLE, AST_PRES_USER_NUMBER_UNSCREENED, ast_party_id::name, ast_party_id::number, ast_party_number::valid, and ast_party_name::valid.
Referenced by add_rpid(), ast_str_retrieve_variable(), ast_var_channels_table(), callerpres_read(), iax2_call(), initreqprep(), my_set_callerid(), oh323_call(), party_id_build_data(), party_id_read(), redirecting_read(), report_new_callerid(), setup_env(), sig_pri_handle_subcmds(), sip_call(), and socket_process().
02029 { 02030 int number_priority; 02031 int number_value; 02032 int number_screening; 02033 int name_priority; 02034 int name_value; 02035 02036 /* Determine name presentation priority. */ 02037 if (!id->name.valid) { 02038 name_value = AST_PRES_UNAVAILABLE; 02039 name_priority = 3; 02040 } else { 02041 name_value = id->name.presentation & AST_PRES_RESTRICTION; 02042 switch (name_value) { 02043 case AST_PRES_RESTRICTED: 02044 name_priority = 0; 02045 break; 02046 case AST_PRES_ALLOWED: 02047 name_priority = 1; 02048 break; 02049 case AST_PRES_UNAVAILABLE: 02050 name_priority = 2; 02051 break; 02052 default: 02053 name_value = AST_PRES_UNAVAILABLE; 02054 name_priority = 3; 02055 break; 02056 } 02057 } 02058 02059 /* Determine number presentation priority. */ 02060 if (!id->number.valid) { 02061 number_screening = AST_PRES_USER_NUMBER_UNSCREENED; 02062 number_value = AST_PRES_UNAVAILABLE; 02063 number_priority = 3; 02064 } else { 02065 number_screening = id->number.presentation & AST_PRES_NUMBER_TYPE; 02066 number_value = id->number.presentation & AST_PRES_RESTRICTION; 02067 switch (number_value) { 02068 case AST_PRES_RESTRICTED: 02069 number_priority = 0; 02070 break; 02071 case AST_PRES_ALLOWED: 02072 number_priority = 1; 02073 break; 02074 case AST_PRES_UNAVAILABLE: 02075 number_priority = 2; 02076 break; 02077 default: 02078 number_screening = AST_PRES_USER_NUMBER_UNSCREENED; 02079 number_value = AST_PRES_UNAVAILABLE; 02080 number_priority = 3; 02081 break; 02082 } 02083 } 02084 02085 /* Select the wining presentation value. */ 02086 if (name_priority < number_priority) { 02087 number_value = name_value; 02088 } 02089 02090 return number_value | number_screening; 02091 }
| void ast_party_id_set | ( | struct ast_party_id * | dest, | |
| const struct ast_party_id * | src, | |||
| const struct ast_set_party_id * | update | |||
| ) |
Set the source party id information into the destination party id.
| dest | The id one wishes to update | |
| src | The new id values to update the dest | |
| update | What id information to update. NULL if all. |
Definition at line 1995 of file channel.c.
References ast_free, ast_party_name_set(), ast_party_number_set(), ast_party_subaddress_set(), ast_strdup, ast_party_id::name, ast_set_party_id::name, ast_party_id::number, ast_set_party_id::number, ast_party_id::subaddress, ast_set_party_id::subaddress, and ast_party_id::tag.
Referenced by ast_party_caller_set(), ast_party_connected_line_set(), and ast_party_redirecting_set().
01996 { 01997 if (dest == src) { 01998 /* Don't set to self */ 01999 return; 02000 } 02001 02002 if (!update || update->name) { 02003 ast_party_name_set(&dest->name, &src->name); 02004 } 02005 if (!update || update->number) { 02006 ast_party_number_set(&dest->number, &src->number); 02007 } 02008 if (!update || update->subaddress) { 02009 ast_party_subaddress_set(&dest->subaddress, &src->subaddress); 02010 } 02011 02012 if (src->tag && src->tag != dest->tag) { 02013 ast_free(dest->tag); 02014 dest->tag = ast_strdup(src->tag); 02015 } 02016 }
| void ast_party_id_set_init | ( | struct ast_party_id * | init, | |
| const struct ast_party_id * | guide | |||
| ) |
Initialize the given party id structure using the given guide for a set update operation.
| init | Party id structure to initialize. | |
| guide | Source party id to use as a guide in initializing. |
Definition at line 1987 of file channel.c.
References ast_party_name_set_init(), ast_party_number_set_init(), ast_party_subaddress_set_init(), ast_party_id::name, ast_party_id::number, ast_party_id::subaddress, and ast_party_id::tag.
Referenced by ast_party_caller_set_init(), ast_party_connected_line_set_init(), and ast_party_redirecting_set_init().
01988 { 01989 ast_party_name_set_init(&init->name, &guide->name); 01990 ast_party_number_set_init(&init->number, &guide->number); 01991 ast_party_subaddress_set_init(&init->subaddress, &guide->subaddress); 01992 init->tag = NULL; 01993 }
| void ast_party_name_copy | ( | struct ast_party_name * | dest, | |
| const struct ast_party_name * | src | |||
| ) |
Copy the source party name information to the destination party name.
| dest | Destination party name | |
| src | Source party name |
Definition at line 1813 of file channel.c.
References ast_free, ast_strdup, ast_party_name::char_set, ast_party_name::presentation, ast_party_name::str, and ast_party_name::valid.
Referenced by ast_party_id_copy().
01814 { 01815 if (dest == src) { 01816 /* Don't copy to self */ 01817 return; 01818 } 01819 01820 ast_free(dest->str); 01821 dest->str = ast_strdup(src->str); 01822 dest->char_set = src->char_set; 01823 dest->presentation = src->presentation; 01824 dest->valid = src->valid; 01825 }
| void ast_party_name_free | ( | struct ast_party_name * | doomed | ) |
Destroy the party name contents.
| doomed | The party name to destroy. |
Definition at line 1852 of file channel.c.
References ast_free, and ast_party_name::str.
Referenced by __analog_ss_thread(), analog_ss_thread(), ast_party_id_free(), and skinny_newcall().
| void ast_party_name_init | ( | struct ast_party_name * | init | ) |
Initialize the given name structure.
| init | Name structure to initialize. |
Definition at line 1805 of file channel.c.
References AST_PARTY_CHAR_SET_ISO8859_1, AST_PRES_ALLOWED_USER_NUMBER_NOT_SCREENED, ast_party_name::char_set, ast_party_name::presentation, ast_party_name::str, and ast_party_name::valid.
Referenced by __analog_ss_thread(), analog_ss_thread(), ast_party_id_init(), and skinny_newcall().
01806 { 01807 init->str = NULL; 01808 init->char_set = AST_PARTY_CHAR_SET_ISO8859_1; 01809 init->presentation = AST_PRES_ALLOWED_USER_NUMBER_NOT_SCREENED; 01810 init->valid = 0; 01811 }
| void ast_party_name_set | ( | struct ast_party_name * | dest, | |
| const struct ast_party_name * | src | |||
| ) |
Set the source party name information into the destination party name.
| dest | The name one wishes to update | |
| src | The new name values to update the dest |
Definition at line 1835 of file channel.c.
References ast_free, ast_strdup, ast_party_name::char_set, ast_party_name::presentation, ast_party_name::str, and ast_party_name::valid.
Referenced by ast_party_id_set().
01836 { 01837 if (dest == src) { 01838 /* Don't set to self */ 01839 return; 01840 } 01841 01842 if (src->str && src->str != dest->str) { 01843 ast_free(dest->str); 01844 dest->str = ast_strdup(src->str); 01845 } 01846 01847 dest->char_set = src->char_set; 01848 dest->presentation = src->presentation; 01849 dest->valid = src->valid; 01850 }
| void ast_party_name_set_init | ( | struct ast_party_name * | init, | |
| const struct ast_party_name * | guide | |||
| ) |
Initialize the given party name structure using the given guide for a set update operation.
| init | Party name structure to initialize. | |
| guide | Source party name to use as a guide in initializing. |
Definition at line 1827 of file channel.c.
References ast_party_name::char_set, ast_party_name::presentation, ast_party_name::str, and ast_party_name::valid.
Referenced by ast_party_id_set_init().
01828 { 01829 init->str = NULL; 01830 init->char_set = guide->char_set; 01831 init->presentation = guide->presentation; 01832 init->valid = guide->valid; 01833 }
| void ast_party_number_copy | ( | struct ast_party_number * | dest, | |
| const struct ast_party_number * | src | |||
| ) |
Copy the source party number information to the destination party number.
Definition at line 1866 of file channel.c.
References ast_free, ast_strdup, ast_party_number::plan, ast_party_number::presentation, ast_party_number::str, and ast_party_number::valid.
Referenced by ast_party_id_copy().
01867 { 01868 if (dest == src) { 01869 /* Don't copy to self */ 01870 return; 01871 } 01872 01873 ast_free(dest->str); 01874 dest->str = ast_strdup(src->str); 01875 dest->plan = src->plan; 01876 dest->presentation = src->presentation; 01877 dest->valid = src->valid; 01878 }
| void ast_party_number_free | ( | struct ast_party_number * | doomed | ) |
Destroy the party number contents.
| doomed | The party number to destroy. |
Definition at line 1905 of file channel.c.
References ast_free, and ast_party_number::str.
Referenced by __analog_ss_thread(), analog_ss_thread(), ast_party_id_free(), do_forward(), skinny_newcall(), and wait_for_answer().
| void ast_party_number_init | ( | struct ast_party_number * | init | ) |
Initialize the given number structure.
| init | Number structure to initialize. |
Definition at line 1858 of file channel.c.
References AST_PRES_ALLOWED_USER_NUMBER_NOT_SCREENED, ast_party_number::plan, ast_party_number::presentation, ast_party_number::str, and ast_party_number::valid.
Referenced by __analog_ss_thread(), analog_ss_thread(), ast_party_id_init(), do_forward(), skinny_newcall(), and wait_for_answer().
01859 { 01860 init->str = NULL; 01861 init->plan = 0;/* Unknown */ 01862 init->presentation = AST_PRES_ALLOWED_USER_NUMBER_NOT_SCREENED; 01863 init->valid = 0; 01864 }
| void ast_party_number_set | ( | struct ast_party_number * | dest, | |
| const struct ast_party_number * | src | |||
| ) |
Set the source party number information into the destination party number.
Definition at line 1888 of file channel.c.
References ast_free, ast_strdup, ast_party_number::plan, ast_party_number::presentation, ast_party_number::str, and ast_party_number::valid.
Referenced by ast_party_id_set().
01889 { 01890 if (dest == src) { 01891 /* Don't set to self */ 01892 return; 01893 } 01894 01895 if (src->str && src->str != dest->str) { 01896 ast_free(dest->str); 01897 dest->str = ast_strdup(src->str); 01898 } 01899 01900 dest->plan = src->plan; 01901 dest->presentation = src->presentation; 01902 dest->valid = src->valid; 01903 }
| void ast_party_number_set_init | ( | struct ast_party_number * | init, | |
| const struct ast_party_number * | guide | |||
| ) |
Initialize the given party number structure using the given guide for a set update operation.
| init | Party number structure to initialize. | |
| guide | Source party number to use as a guide in initializing. |
Definition at line 1880 of file channel.c.
References ast_party_number::plan, ast_party_number::presentation, ast_party_number::str, and ast_party_number::valid.
Referenced by ast_party_id_set_init().
01881 { 01882 init->str = NULL; 01883 init->plan = guide->plan; 01884 init->presentation = guide->presentation; 01885 init->valid = guide->valid; 01886 }
| void ast_party_redirecting_copy | ( | struct ast_party_redirecting * | dest, | |
| const struct ast_party_redirecting * | src | |||
| ) |
Copy the source redirecting information to the destination redirecting.
| dest | Destination redirecting | |
| src | Source redirecting |
Definition at line 2241 of file channel.c.
References ast_party_id_copy(), ast_party_redirecting::count, ast_party_redirecting::from, ast_party_redirecting::reason, and ast_party_redirecting::to.
Referenced by ast_channel_redirecting_macro(), begin_dial_channel(), dial_exec_full(), do_forward(), local_call(), ring_entry(), and wait_for_answer().
02242 { 02243 if (dest == src) { 02244 /* Don't copy to self */ 02245 return; 02246 } 02247 02248 ast_party_id_copy(&dest->from, &src->from); 02249 ast_party_id_copy(&dest->to, &src->to); 02250 dest->count = src->count; 02251 dest->reason = src->reason; 02252 }
| void ast_party_redirecting_free | ( | struct ast_party_redirecting * | doomed | ) |
Destroy the redirecting information contents.
| doomed | The redirecting information to destroy. |
Definition at line 2270 of file channel.c.
References ast_party_id_free(), ast_party_redirecting::from, and ast_party_redirecting::to.
Referenced by ast_channel_destructor(), ast_dummy_channel_destructor(), ast_indicate_data(), do_forward(), handle_request_invite(), handle_response(), handle_response_invite(), redirecting_write(), sig_pri_handle_subcmds(), and wait_for_answer().
02271 { 02272 ast_party_id_free(&doomed->from); 02273 ast_party_id_free(&doomed->to); 02274 }
| void ast_party_redirecting_init | ( | struct ast_party_redirecting * | init | ) |
Initialize the given redirecting structure.
| init | Redirecting structure to initialize. |
Definition at line 2233 of file channel.c.
References ast_party_id_init(), AST_REDIRECTING_REASON_UNKNOWN, ast_party_redirecting::count, ast_party_redirecting::from, ast_party_redirecting::reason, and ast_party_redirecting::to.
Referenced by __ast_channel_alloc_ap(), do_forward(), handle_request_invite(), handle_response(), handle_response_invite(), and wait_for_answer().
02234 { 02235 ast_party_id_init(&init->from); 02236 ast_party_id_init(&init->to); 02237 init->count = 0; 02238 init->reason = AST_REDIRECTING_REASON_UNKNOWN; 02239 }
| void ast_party_redirecting_set | ( | struct ast_party_redirecting * | dest, | |
| const struct ast_party_redirecting * | src, | |||
| const struct ast_set_party_redirecting * | update | |||
| ) |
Set the redirecting information based on another redirecting source.
| dest | The redirecting one wishes to update | |
| src | The new redirecting values to update the dest | |
| update | What redirecting information to update. NULL if all. |
Definition at line 2262 of file channel.c.
References ast_party_id_set(), ast_party_redirecting::count, ast_set_party_redirecting::from, ast_party_redirecting::from, ast_party_redirecting::reason, ast_set_party_redirecting::to, and ast_party_redirecting::to.
Referenced by ast_channel_set_redirecting().
02263 { 02264 ast_party_id_set(&dest->from, &src->from, update ? &update->from : NULL); 02265 ast_party_id_set(&dest->to, &src->to, update ? &update->to : NULL); 02266 dest->reason = src->reason; 02267 dest->count = src->count; 02268 }
| void ast_party_redirecting_set_init | ( | struct ast_party_redirecting * | init, | |
| const struct ast_party_redirecting * | guide | |||
| ) |
Initialize the given redirecting id structure using the given guide for a set update operation.
| init | Redirecting id structure to initialize. | |
| guide | Source redirecting id to use as a guide in initializing. |
Definition at line 2254 of file channel.c.
References ast_party_id_set_init(), ast_party_redirecting::count, ast_party_redirecting::from, ast_party_redirecting::reason, and ast_party_redirecting::to.
Referenced by ast_indicate_data(), misdn_copy_redirecting_to_ast(), redirecting_write(), and sig_pri_redirecting_convert().
02255 { 02256 ast_party_id_set_init(&init->from, &guide->from); 02257 ast_party_id_set_init(&init->to, &guide->to); 02258 init->count = guide->count; 02259 init->reason = guide->reason; 02260 }
| void ast_party_subaddress_copy | ( | struct ast_party_subaddress * | dest, | |
| const struct ast_party_subaddress * | src | |||
| ) |
Copy the source party subaddress information to the destination party subaddress.
| dest | Destination party subaddress | |
| src | Source party subaddress |
Definition at line 1919 of file channel.c.
References ast_free, ast_strdup, ast_party_subaddress::odd_even_indicator, ast_party_subaddress::str, ast_party_subaddress::type, and ast_party_subaddress::valid.
Referenced by ast_party_dialed_copy(), and ast_party_id_copy().
01920 { 01921 if (dest == src) { 01922 /* Don't copy to self */ 01923 return; 01924 } 01925 01926 ast_free(dest->str); 01927 dest->str = ast_strdup(src->str); 01928 dest->type = src->type; 01929 dest->odd_even_indicator = src->odd_even_indicator; 01930 dest->valid = src->valid; 01931 }
| void ast_party_subaddress_free | ( | struct ast_party_subaddress * | doomed | ) |
Destroy the party subaddress contents.
| doomed | The party subaddress to destroy. |
Definition at line 1958 of file channel.c.
References ast_free, and ast_party_subaddress::str.
Referenced by ast_party_dialed_free(), ast_party_id_free(), and pri_dchannel().
| void ast_party_subaddress_init | ( | struct ast_party_subaddress * | init | ) |
Initialize the given subaddress structure.
| init | Subaddress structure to initialize. |
Definition at line 1911 of file channel.c.
References ast_party_subaddress::odd_even_indicator, ast_party_subaddress::str, ast_party_subaddress::type, and ast_party_subaddress::valid.
Referenced by ast_party_dialed_init(), ast_party_id_init(), pri_dchannel(), sig_pri_call(), and sig_pri_set_subaddress().
01912 { 01913 init->str = NULL; 01914 init->type = 0; 01915 init->odd_even_indicator = 0; 01916 init->valid = 0; 01917 }
| void ast_party_subaddress_set | ( | struct ast_party_subaddress * | dest, | |
| const struct ast_party_subaddress * | src | |||
| ) |
Set the source party subaddress information into the destination party subaddress.
| dest | The subaddress one wishes to update | |
| src | The new subaddress values to update the dest |
Definition at line 1941 of file channel.c.
References ast_free, ast_strdup, ast_party_subaddress::odd_even_indicator, ast_party_subaddress::str, ast_party_subaddress::type, and ast_party_subaddress::valid.
Referenced by ast_party_dialed_set(), ast_party_id_set(), and sig_pri_handle_subcmds().
01942 { 01943 if (dest == src) { 01944 /* Don't set to self */ 01945 return; 01946 } 01947 01948 if (src->str && src->str != dest->str) { 01949 ast_free(dest->str); 01950 dest->str = ast_strdup(src->str); 01951 } 01952 01953 dest->type = src->type; 01954 dest->odd_even_indicator = src->odd_even_indicator; 01955 dest->valid = src->valid; 01956 }
| void ast_party_subaddress_set_init | ( | struct ast_party_subaddress * | init, | |
| const struct ast_party_subaddress * | guide | |||
| ) |
Initialize the given party subaddress structure using the given guide for a set update operation.
| init | Party subaddress structure to initialize. | |
| guide | Source party subaddress to use as a guide in initializing. |
Definition at line 1933 of file channel.c.
References ast_party_subaddress::odd_even_indicator, ast_party_subaddress::str, ast_party_subaddress::type, and ast_party_subaddress::valid.
Referenced by ast_party_dialed_set_init(), and ast_party_id_set_init().
01934 { 01935 init->str = NULL; 01936 init->type = guide->type; 01937 init->odd_even_indicator = guide->odd_even_indicator; 01938 init->valid = guide->valid; 01939 }
| int ast_plc_reload | ( | void | ) |
Reload genericplc configuration value from codecs.conf.
Implementation is in main/channel.c
Definition at line 7286 of file channel.c.
References ast_config_destroy(), ast_config_load, AST_OPT_FLAG_GENERIC_PLC, ast_options, ast_set2_flag, ast_true(), ast_variable_browse(), CONFIG_STATUS_FILEINVALID, CONFIG_STATUS_FILEMISSING, CONFIG_STATUS_FILEUNCHANGED, ast_variable::name, ast_variable::next, ast_variable::value, and var.
Referenced by ast_channels_init().
07287 { 07288 struct ast_variable *var; 07289 struct ast_flags config_flags = { 0 }; 07290 struct ast_config *cfg = ast_config_load("codecs.conf", config_flags); 07291 if (cfg == CONFIG_STATUS_FILEMISSING || cfg == CONFIG_STATUS_FILEUNCHANGED || cfg == CONFIG_STATUS_FILEINVALID) 07292 return 0; 07293 for (var = ast_variable_browse(cfg, "plc"); var; var = var->next) { 07294 if (!strcasecmp(var->name, "genericplc")) { 07295 ast_set2_flag(&ast_options, ast_true(var->value), AST_OPT_FLAG_GENERIC_PLC); 07296 } 07297 } 07298 ast_config_destroy(cfg); 07299 return 0; 07300 }
| void ast_poll_channel_add | ( | struct ast_channel * | chan0, | |
| struct ast_channel * | chan1 | |||
| ) |
Add a channel to an optimized waitfor
Definition at line 2531 of file channel.c.
References AST_MAX_FDS, and ast_channel::fds.
Referenced by ast_generic_bridge(), begin_dial_channel(), feature_request_and_dial(), local_bridge_loop(), remote_bridge_loop(), and wait_for_answer().
02532 { 02533 #ifdef HAVE_EPOLL 02534 struct epoll_event ev; 02535 int i = 0; 02536 02537 if (chan0->epfd == -1) 02538 return; 02539 02540 /* Iterate through the file descriptors on chan1, adding them to chan0 */ 02541 for (i = 0; i < AST_MAX_FDS; i++) { 02542 if (chan1->fds[i] == -1) 02543 continue; 02544 ev.events = EPOLLIN | EPOLLPRI | EPOLLERR | EPOLLHUP; 02545 ev.data.ptr = chan1->epfd_data[i]; 02546 epoll_ctl(chan0->epfd, EPOLL_CTL_ADD, chan1->fds[i], &ev); 02547 } 02548 02549 #endif 02550 return; 02551 }
| void ast_poll_channel_del | ( | struct ast_channel * | chan0, | |
| struct ast_channel * | chan1 | |||
| ) |
Delete a channel from an optimized waitfor
Definition at line 2554 of file channel.c.
References AST_MAX_FDS, and ast_channel::fds.
Referenced by ast_generic_bridge(), feature_request_and_dial(), local_bridge_loop(), monitor_dial(), remote_bridge_loop(), and wait_for_answer().
02555 { 02556 #ifdef HAVE_EPOLL 02557 struct epoll_event ev; 02558 int i = 0; 02559 02560 if (chan0->epfd == -1) 02561 return; 02562 02563 for (i = 0; i < AST_MAX_FDS; i++) { 02564 if (chan1->fds[i] == -1) 02565 continue; 02566 epoll_ctl(chan0->epfd, EPOLL_CTL_DEL, chan1->fds[i], &ev); 02567 } 02568 02569 #endif 02570 return; 02571 }
| char* ast_print_group | ( | char * | buf, | |
| int | buflen, | |||
| ast_group_t | group | |||
| ) |
Print call group and pickup group ---.
print call- and pickup groups into buffer
Definition at line 7434 of file channel.c.
References first.
Referenced by _sip_show_peer(), _skinny_show_line(), func_channel_read(), function_sippeer(), misdn_cfg_get_config_string(), print_group(), read_config(), and serialize_showchan().
07435 { 07436 unsigned int i; 07437 int first = 1; 07438 char num[3]; 07439 07440 buf[0] = '\0'; 07441 07442 if (!group) /* Return empty string if no group */ 07443 return buf; 07444 07445 for (i = 0; i <= 63; i++) { /* Max group is 63 */ 07446 if (group & ((ast_group_t) 1 << i)) { 07447 if (!first) { 07448 strncat(buf, ", ", buflen - strlen(buf) - 1); 07449 } else { 07450 first = 0; 07451 } 07452 snprintf(num, sizeof(num), "%u", i); 07453 strncat(buf, num, buflen - strlen(buf) - 1); 07454 } 07455 } 07456 return buf; 07457 }
| int ast_prod | ( | struct ast_channel * | chan | ) |
Send empty audio to prime a channel driver.
Definition at line 4473 of file channel.c.
References ast_channel::_state, ast_debug, AST_FRAME_VOICE, AST_FRIENDLY_OFFSET, ast_log(), AST_STATE_UP, ast_write(), ast_frame_subclass::codec, ast_frame::data, LOG_WARNING, ast_channel::name, ast_frame::ptr, ast_channel::rawwriteformat, ast_frame::src, and ast_frame::subclass.
Referenced by ast_activate_generator().
04474 { 04475 struct ast_frame a = { AST_FRAME_VOICE }; 04476 char nothing[128]; 04477 04478 /* Send an empty audio frame to get things moving */ 04479 if (chan->_state != AST_STATE_UP) { 04480 ast_debug(1, "Prodding channel '%s'\n", chan->name); 04481 a.subclass.codec = chan->rawwriteformat; 04482 a.data.ptr = nothing + AST_FRIENDLY_OFFSET; 04483 a.src = "ast_prod"; /* this better match check in ast_write */ 04484 if (ast_write(chan, &a)) 04485 ast_log(LOG_WARNING, "Prodding channel '%s' failed\n", chan->name); 04486 } 04487 return 0; 04488 }
| int ast_queue_control | ( | struct ast_channel * | chan, | |
| enum ast_control_frame_type | control | |||
| ) |
Queue a control frame.
Queue a control frame with payload.
Definition at line 1482 of file channel.c.
References AST_FRAME_CONTROL, and ast_queue_frame().
Referenced by __analog_handle_event(), __analog_ss_thread(), __ast_read(), __dahdi_exception(), __oh323_update_info(), analog_attempt_transfer(), analog_call(), analog_exception(), analog_hangup(), analog_ss_thread(), ast_pickup_call(), attempt_transfer(), auto_congest(), cb_events(), cli_console_answer(), cli_console_flash(), console_answer(), console_call(), console_sendtext(), dahdi_handle_event(), dahdi_hangup(), gtalk_is_answered(), gtalk_ringing_ack(), handle_hd_hf(), handle_offhook_message(), handle_request(), handle_request_bye(), handle_request_info(), handle_request_invite(), handle_request_refer(), handle_response(), handle_response_invite(), handle_response_refer(), handle_soft_key_event_message(), handle_stimulus_message(), HandleCallIncoming(), jingle_is_answered(), jingle_ringing_ack(), misdn_attempt_transfer(), misdn_facility_ie_handler(), multicast_rtp_call(), nbs_call(), phone_call(), pickup_do(), process_sdp(), receive_digit(), remote_hold(), send_cause2ast(), setup_rtp_connection(), sig_pri_attempt_transfer(), sig_pri_handle_subcmds(), skinny_call(), skinny_transfer(), skinny_unhold(), unistim_call(), and update_state().
01483 { 01484 struct ast_frame f = { AST_FRAME_CONTROL, .subclass.integer = control }; 01485 return ast_queue_frame(chan, &f); 01486 }
| int ast_queue_control_data | ( | struct ast_channel * | chan, | |
| enum ast_control_frame_type | control, | |||
| const void * | data, | |||
| size_t | datalen | |||
| ) |
Queue a control frame with payload.
| chan | channel to queue frame onto | |
| control | type of control frame | |
| data | pointer to payload data to be included in frame | |
| datalen | number of bytes of payload data |
| 0 | success | |
| non-zero | failure |
The channel does not need to be locked before calling this function.
Definition at line 1489 of file channel.c.
References AST_FRAME_CONTROL, and ast_queue_frame().
Referenced by __analog_handle_event(), analog_hangup(), ast_channel_queue_connected_line_update(), ast_channel_queue_redirecting_update(), change_t38_state(), dahdi_handle_event(), dahdi_hangup(), handle_request_notify(), handle_response_refer(), iax2_queue_control_data(), iax2_transfer(), interpret_t38_parameters(), local_attended_transfer(), process_sdp(), sip_sipredirect(), and skinny_hold().
01491 { 01492 struct ast_frame f = { AST_FRAME_CONTROL, .subclass.integer = control, .data.ptr = (void *) data, .datalen = datalen }; 01493 return ast_queue_frame(chan, &f); 01494 }
| int ast_queue_frame | ( | struct ast_channel * | chan, | |
| struct ast_frame * | f | |||
| ) |
Queue one or more frames to a channel's frame queue.
| chan | the channel to queue the frame(s) on | |
| f | the frame(s) to queue. Note that the frame(s) will be duplicated by this function. It is the responsibility of the caller to handle freeing the memory associated with the frame(s) being passed if necessary. |
| 0 | success | |
| non-zero | failure |
Definition at line 1439 of file channel.c.
References __ast_queue_frame().
Referenced by __ast_read(), __oh323_rtp_create(), __oh323_update_info(), action_atxfer(), agent_new(), alsa_call(), ast_channel_masquerade(), ast_channel_setwhentohangup_tv(), ast_do_masquerade(), ast_dsp_process(), ast_queue_cc_frame(), ast_queue_control(), ast_queue_control_data(), ast_queue_hangup(), ast_queue_hangup_with_cause(), ast_softhangup_nolock(), bridge_write(), cb_events(), cli_console_dial(), cli_console_sendtext(), console_dial(), console_do_answer(), console_flash(), console_sendtext(), dahdi_queue_frame(), dictate_exec(), do_immediate_setup(), gtalk_handle_dtmf(), handle_keypad_button_message(), handle_request_info(), handle_request_invite(), handle_response_invite(), iax2_queue_frame(), jingle_handle_dtmf(), keypad_digit(), local_queue_frame(), mgcp_queue_frame(), oh323_simulate_dtmf_end(), oss_call(), pri_queue_frame(), process_sdp(), queue_dtmf_readq(), receive_digit(), receive_message(), rpt_call(), sig_pri_handle_hold(), sig_ss7_queue_frame(), stream_monitor(), unistim_do_senddigit(), unistim_senddigit_end(), usbradio_read(), and wakeup_sub().
01440 { 01441 return __ast_queue_frame(chan, fin, 0, NULL); 01442 }
| int ast_queue_frame_head | ( | struct ast_channel * | chan, | |
| struct ast_frame * | f | |||
| ) |
Queue one or more frames to the head of a channel's frame queue.
| chan | the channel to queue the frame(s) on | |
| f | the frame(s) to queue. Note that the frame(s) will be duplicated by this function. It is the responsibility of the caller to handle freeing the memory associated with the frame(s) being passed if necessary. |
| 0 | success | |
| non-zero | failure |
Definition at line 1444 of file channel.c.
References __ast_queue_frame().
Referenced by __ast_answer(), __ast_read(), ast_autoservice_stop(), and ast_safe_sleep_conditional().
01445 { 01446 return __ast_queue_frame(chan, fin, 1, NULL); 01447 }
| int ast_queue_hangup | ( | struct ast_channel * | chan | ) |
Queue a hangup frame for channel.
Queue a hangup frame.
Definition at line 1450 of file channel.c.
References ast_channel::_softhangup, ast_channel_trylock, ast_channel_unlock, AST_CONTROL_HANGUP, AST_FRAME_CONTROL, ast_queue_frame(), and AST_SOFTHANGUP_DEV.
Referenced by bridge_queue_hangup(), cleanup_connection(), cli_console_hangup(), close_call(), gtalk_hangup_farend(), gtalk_is_answered(), handle_onhook_message(), handle_request_bye(), handle_request_cancel(), handle_soft_key_event_message(), iax2_destroy(), iax2_queue_hangup(), jingle_hangup_farend(), local_fixup(), local_hangup(), and mgcp_queue_hangup().
01451 { 01452 struct ast_frame f = { AST_FRAME_CONTROL, .subclass.integer = AST_CONTROL_HANGUP }; 01453 /* Yeah, let's not change a lock-critical value without locking */ 01454 if (!ast_channel_trylock(chan)) { 01455 chan->_softhangup |= AST_SOFTHANGUP_DEV; 01456 ast_channel_unlock(chan); 01457 } 01458 return ast_queue_frame(chan, &f); 01459 }
| int ast_queue_hangup_with_cause | ( | struct ast_channel * | chan, | |
| int | cause | |||
| ) |
Queue a hangup frame for channel.
Queue a hangup frame with hangupcause set.
Definition at line 1462 of file channel.c.
References ast_channel::_softhangup, ast_channel_trylock, ast_channel_unlock, AST_CONTROL_HANGUP, AST_FRAME_CONTROL, ast_queue_frame(), AST_SOFTHANGUP_DEV, ast_frame::data, ast_channel::hangupcause, and ast_frame::uint32.
Referenced by __analog_handle_event(), __oh323_update_info(), __sip_autodestruct(), close_call(), close_client(), console_hangup(), dahdi_handle_event(), dahdi_r2_on_call_disconnect(), handle_request_bye(), handle_response(), handle_response_invite(), handle_response_notify(), HandleCallOutgoing(), hangup_chan(), hangup_connection(), misdn_answer(), retrans_pkt(), and TransferCallStep1().
01463 { 01464 struct ast_frame f = { AST_FRAME_CONTROL, .subclass.integer = AST_CONTROL_HANGUP }; 01465 01466 if (cause >= 0) 01467 f.data.uint32 = cause; 01468 01469 /* Yeah, let's not change a lock-critical value without locking */ 01470 if (!ast_channel_trylock(chan)) { 01471 chan->_softhangup |= AST_SOFTHANGUP_DEV; 01472 if (cause < 0) 01473 f.data.uint32 = chan->hangupcause; 01474 01475 ast_channel_unlock(chan); 01476 } 01477 01478 return ast_queue_frame(chan, &f); 01479 }
| int ast_raw_answer | ( | struct ast_channel * | chan, | |
| int | cdr_answer | |||
| ) |
Answer a channel.
| chan | channel to answer | |
| cdr_answer | flag to control whether any associated CDR should be marked as 'answered' |
Unlike ast_answer(), this function will not wait for media flow to begin. The caller should be careful before sending media to the channel before incoming media arrives, as the outgoing media may be lost.
| 0 | on success | |
| non-zero | on failure |
Definition at line 2744 of file channel.c.
References ast_channel::_state, ast_channel_tech::answer, ast_cdr_answer(), AST_CEL_ANSWER, ast_cel_report_event(), ast_channel_lock, ast_channel_unlock, ast_check_hangup(), AST_FLAG_OUTGOING, AST_FLAG_ZOMBIE, ast_indicate(), ast_setstate(), AST_STATE_RING, AST_STATE_RINGING, AST_STATE_UP, ast_test_flag, ast_channel::cdr, ast_channel::tech, and ast_channel::visible_indication.
Referenced by __ast_answer(), and ast_bridge_call().
02745 { 02746 int res = 0; 02747 02748 ast_channel_lock(chan); 02749 02750 /* You can't answer an outbound call */ 02751 if (ast_test_flag(chan, AST_FLAG_OUTGOING)) { 02752 ast_channel_unlock(chan); 02753 return 0; 02754 } 02755 02756 /* Stop if we're a zombie or need a soft hangup */ 02757 if (ast_test_flag(chan, AST_FLAG_ZOMBIE) || ast_check_hangup(chan)) { 02758 ast_channel_unlock(chan); 02759 return -1; 02760 } 02761 02762 ast_channel_unlock(chan); 02763 02764 switch (chan->_state) { 02765 case AST_STATE_RINGING: 02766 case AST_STATE_RING: 02767 ast_channel_lock(chan); 02768 if (chan->tech->answer) { 02769 res = chan->tech->answer(chan); 02770 } 02771 ast_setstate(chan, AST_STATE_UP); 02772 if (cdr_answer) { 02773 ast_cdr_answer(chan->cdr); 02774 } 02775 ast_cel_report_event(chan, AST_CEL_ANSWER, NULL, NULL, NULL); 02776 ast_channel_unlock(chan); 02777 break; 02778 case AST_STATE_UP: 02779 ast_cel_report_event(chan, AST_CEL_ANSWER, NULL, NULL, NULL); 02780 /* Calling ast_cdr_answer when it it has previously been called 02781 * is essentially a no-op, so it is safe. 02782 */ 02783 if (cdr_answer) { 02784 ast_cdr_answer(chan->cdr); 02785 } 02786 break; 02787 default: 02788 break; 02789 } 02790 02791 ast_indicate(chan, -1); 02792 chan->visible_indication = 0; 02793 02794 return res; 02795 }
| struct ast_frame* ast_read | ( | struct ast_channel * | chan | ) | [read] |
Reads a frame.
| chan | channel to read a frame from |
Definition at line 4107 of file channel.c.
References __ast_read().
Referenced by __adsi_transmit_messages(), __analog_ss_thread(), __ast_answer(), __ast_play_and_record(), __ast_request_and_dial(), adsi_careful_send(), agent_ack_sleep(), agent_read(), analog_ss_thread(), ast_bridge_handle_trip(), ast_generic_bridge(), ast_recvtext(), ast_safe_sleep_conditional(), ast_tonepair(), ast_transfer(), ast_udptl_bridge(), ast_waitfordigit_full(), async_wait(), autoservice_run(), background_detect_exec(), builtin_atxfer(), channel_spy(), check_goto_on_transfer(), conf_flush(), conf_run(), dahdi_accept_r2_call_exec(), dahdi_bridge(), dial_exec_full(), dictate_exec(), disa_exec(), disable_t38(), do_idle_thread(), do_waiting(), echo_exec(), eivr_comm(), feature_request_and_dial(), find_cache(), generic_fax_exec(), handle_recordfile(), handle_speechrecognize(), iax2_bridge(), iax_park_thread(), ices_exec(), isAnsweringMachine(), jack_exec(), launch_asyncagi(), local_bridge_loop(), manage_parkinglot(), masq_park_call(), measurenoise(), misdn_bridge(), monitor_dial(), mp3_exec(), NBScat_exec(), receive_dtmf_digits(), receivefax_t38_init(), record_exec(), recordthread(), remote_bridge_loop(), rpt(), rpt_exec(), run_agi(), send_tone_burst(), send_waveform_to_channel(), sendfax_t38_init(), sendurl_exec(), speech_background(), transmit_audio(), transmit_t38(), wait_for_answer(), wait_for_hangup(), wait_for_winner(), waitforring_exec(), and waitstream_core().
04108 { 04109 return __ast_read(chan, 0); 04110 }
| static void ast_read_generator_actions | ( | struct ast_channel * | chan, | |
| struct ast_frame * | f | |||
| ) | [static] |
Definition at line 3482 of file channel.c.
References ast_channel_lock, ast_channel_unlock, ast_deactivate_generator(), ast_debug, ast_format_rate(), AST_FRAME_CNG, ast_internal_timing_enabled(), ast_settimeout(), ast_frame_subclass::codec, ast_frame::datalen, ast_frame::frametype, ast_generator::generate, ast_channel::generator, generator_force(), ast_channel::generatordata, ast_frame::samples, ast_frame::subclass, ast_channel::timingfd, ast_channel::timingfunc, and ast_channel::writeformat.
Referenced by __ast_read().
03483 { 03484 if (chan->generator && chan->generator->generate && chan->generatordata && !ast_internal_timing_enabled(chan)) { 03485 void *tmp = chan->generatordata; 03486 int (*generate)(struct ast_channel *chan, void *tmp, int datalen, int samples) = chan->generator->generate; 03487 int res; 03488 int samples; 03489 03490 if (chan->timingfunc) { 03491 ast_debug(1, "Generator got voice, switching to phase locked mode\n"); 03492 ast_settimeout(chan, 0, NULL, NULL); 03493 } 03494 03495 chan->generatordata = NULL; /* reset, to let writes go through */ 03496 03497 if (f->subclass.codec != chan->writeformat) { 03498 float factor; 03499 factor = ((float) ast_format_rate(chan->writeformat)) / ((float) ast_format_rate(f->subclass.codec)); 03500 samples = (int) ( ((float) f->samples) * factor ); 03501 } else { 03502 samples = f->samples; 03503 } 03504 03505 /* This unlock is here based on two assumptions that hold true at this point in the 03506 * code. 1) this function is only called from within __ast_read() and 2) all generators 03507 * call ast_write() in their generate callback. 03508 * 03509 * The reason this is added is so that when ast_write is called, the lock that occurs 03510 * there will not recursively lock the channel. Doing this will cause intended deadlock 03511 * avoidance not to work in deeper functions 03512 */ 03513 ast_channel_unlock(chan); 03514 res = generate(chan, tmp, f->datalen, samples); 03515 ast_channel_lock(chan); 03516 chan->generatordata = tmp; 03517 if (res) { 03518 ast_debug(1, "Auto-deactivating generator\n"); 03519 ast_deactivate_generator(chan); 03520 } 03521 03522 } else if (f->frametype == AST_FRAME_CNG) { 03523 if (chan->generator && !chan->timingfunc && (chan->timingfd > -1)) { 03524 ast_debug(1, "Generator got CNG, switching to timed mode\n"); 03525 ast_settimeout(chan, 50, generator_force, chan); 03526 } 03527 } 03528 }
| struct ast_frame* ast_read_noaudio | ( | struct ast_channel * | chan | ) | [read] |
Reads a frame, returning AST_FRAME_NULL frame if audio.
| chan | channel to read a frame from |
Definition at line 4112 of file channel.c.
References __ast_read().
Referenced by ast_bridge_handle_trip(), and conf_run().
04113 { 04114 return __ast_read(chan, 1); 04115 }
| int ast_readstring | ( | struct ast_channel * | c, | |
| char * | s, | |||
| int | len, | |||
| int | timeout, | |||
| int | rtimeout, | |||
| char * | enders | |||
| ) |
Reads multiple digits.
| c | channel to read from | |
| s | string to read in to. Must be at least the size of your length | |
| len | how many digits to read (maximum) | |
| timeout | how long to timeout between digits | |
| rtimeout | timeout to wait on the first digit | |
| enders | digits to end the string |
Definition at line 5436 of file channel.c.
References ast_readstring_full().
Referenced by __adsi_transmit_messages(), ast_adsi_begin_download(), ast_adsi_get_cpeinfo(), ast_adsi_load_session(), ast_app_getdata(), dialout(), do_directory(), forward_message(), privacy_exec(), vm_authenticate(), vm_newuser(), and vm_options().
05437 { 05438 return ast_readstring_full(c, s, len, timeout, ftimeout, enders, -1, -1); 05439 }
| int ast_readstring_full | ( | struct ast_channel * | c, | |
| char * | s, | |||
| int | len, | |||
| int | timeout, | |||
| int | ftimeout, | |||
| char * | enders, | |||
| int | audiofd, | |||
| int | ctrlfd | |||
| ) |
Definition at line 5441 of file channel.c.
References ast_channel_start_silence_generator(), ast_channel_stop_silence_generator(), ast_check_hangup(), AST_DIGIT_ANY, AST_FLAG_ZOMBIE, AST_GETDATA_COMPLETE, AST_GETDATA_EMPTY_END_TERMINATED, AST_GETDATA_FAILED, AST_GETDATA_INTERRUPTED, AST_GETDATA_TIMEOUT, ast_opt_transmit_silence, ast_stopstream(), ast_test_flag, ast_waitfordigit_full(), ast_waitstream_full(), and ast_channel::stream.
Referenced by ast_app_getdata_full(), and ast_readstring().
05442 { 05443 int pos = 0; /* index in the buffer where we accumulate digits */ 05444 int to = ftimeout; 05445 05446 struct ast_silence_generator *silgen = NULL; 05447 05448 /* Stop if we're a zombie or need a soft hangup */ 05449 if (ast_test_flag(c, AST_FLAG_ZOMBIE) || ast_check_hangup(c)) 05450 return -1; 05451 if (!len) 05452 return -1; 05453 for (;;) { 05454 int d; 05455 if (c->stream) { 05456 d = ast_waitstream_full(c, AST_DIGIT_ANY, audiofd, ctrlfd); 05457 ast_stopstream(c); 05458 if (!silgen && ast_opt_transmit_silence) 05459 silgen = ast_channel_start_silence_generator(c); 05460 usleep(1000); 05461 if (!d) 05462 d = ast_waitfordigit_full(c, to, audiofd, ctrlfd); 05463 } else { 05464 if (!silgen && ast_opt_transmit_silence) 05465 silgen = ast_channel_start_silence_generator(c); 05466 d = ast_waitfordigit_full(c, to, audiofd, ctrlfd); 05467 } 05468 if (d < 0) { 05469 ast_channel_stop_silence_generator(c, silgen); 05470 return AST_GETDATA_FAILED; 05471 } 05472 if (d == 0) { 05473 s[pos] = '\0'; 05474 ast_channel_stop_silence_generator(c, silgen); 05475 return AST_GETDATA_TIMEOUT; 05476 } 05477 if (d == 1) { 05478 s[pos] = '\0'; 05479 ast_channel_stop_silence_generator(c, silgen); 05480 return AST_GETDATA_INTERRUPTED; 05481 } 05482 if (strchr(enders, d) && (pos == 0)) { 05483 s[pos] = '\0'; 05484 ast_channel_stop_silence_generator(c, silgen); 05485 return AST_GETDATA_EMPTY_END_TERMINATED; 05486 } 05487 if (!strchr(enders, d)) { 05488 s[pos++] = d; 05489 } 05490 if (strchr(enders, d) || (pos >= len)) { 05491 s[pos] = '\0'; 05492 ast_channel_stop_silence_generator(c, silgen); 05493 return AST_GETDATA_COMPLETE; 05494 } 05495 to = timeout; 05496 } 05497 /* Never reached */ 05498 return 0; 05499 }
| int ast_recvchar | ( | struct ast_channel * | chan, | |
| int | timeout | |||
| ) |
Receives a text character from a channel.
| chan | channel to act upon | |
| timeout | timeout in milliseconds (0 for infinite wait) |
Definition at line 4354 of file channel.c.
References ast_free, and ast_recvtext().
Referenced by handle_recvchar().
04355 { 04356 int c; 04357 char *buf = ast_recvtext(chan, timeout); 04358 if (buf == NULL) 04359 return -1; /* error or timeout */ 04360 c = *(unsigned char *)buf; 04361 ast_free(buf); 04362 return c; 04363 }
| char* ast_recvtext | ( | struct ast_channel * | chan, | |
| int | timeout | |||
| ) |
Receives a text string from a channel Read a string of text from a channel.
| chan | channel to act upon | |
| timeout | timeout in milliseconds (0 for infinite wait) |
Definition at line 4365 of file channel.c.
References ast_check_hangup(), AST_CONTROL_HANGUP, AST_FRAME_CONTROL, AST_FRAME_TEXT, ast_frfree, ast_read(), ast_strndup, ast_waitfor(), ast_frame::data, ast_frame::datalen, ast_frame::frametype, ast_frame_subclass::integer, ast_frame::ptr, and ast_frame::subclass.
Referenced by ast_recvchar(), and handle_recvtext().
04366 { 04367 int res, done = 0; 04368 char *buf = NULL; 04369 04370 while (!done) { 04371 struct ast_frame *f; 04372 if (ast_check_hangup(chan)) 04373 break; 04374 res = ast_waitfor(chan, timeout); 04375 if (res <= 0) /* timeout or error */ 04376 break; 04377 timeout = res; /* update timeout */ 04378 f = ast_read(chan); 04379 if (f == NULL) 04380 break; /* no frame */ 04381 if (f->frametype == AST_FRAME_CONTROL && f->subclass.integer == AST_CONTROL_HANGUP) 04382 done = 1; /* force a break */ 04383 else if (f->frametype == AST_FRAME_TEXT) { /* what we want */ 04384 buf = ast_strndup((char *) f->data.ptr, f->datalen); /* dup and break */ 04385 done = 1; 04386 } 04387 ast_frfree(f); 04388 } 04389 return buf; 04390 }
| int ast_redirecting_build_data | ( | unsigned char * | data, | |
| size_t | datalen, | |||
| const struct ast_party_redirecting * | redirecting, | |||
| const struct ast_set_party_redirecting * | update | |||
| ) |
Build the redirecting id data frame.
| data | Buffer to fill with the frame data | |
| datalen | Size of the buffer to fill | |
| redirecting | Redirecting id information | |
| update | What redirecting information to build. NULL if all. |
| -1 | if error | |
| Amount | of data buffer used |
Definition at line 8336 of file channel.c.
References ast_log(), AST_REDIRECTING_COUNT, AST_REDIRECTING_FROM_ID_PRESENTATION, AST_REDIRECTING_FROM_NAME, AST_REDIRECTING_FROM_NAME_CHAR_SET, AST_REDIRECTING_FROM_NAME_PRESENTATION, AST_REDIRECTING_FROM_NAME_VALID, AST_REDIRECTING_FROM_NUMBER, AST_REDIRECTING_FROM_NUMBER_PLAN, AST_REDIRECTING_FROM_NUMBER_PRESENTATION, AST_REDIRECTING_FROM_NUMBER_VALID, AST_REDIRECTING_FROM_SUBADDRESS, AST_REDIRECTING_FROM_SUBADDRESS_ODD_EVEN, AST_REDIRECTING_FROM_SUBADDRESS_TYPE, AST_REDIRECTING_FROM_SUBADDRESS_VALID, AST_REDIRECTING_FROM_TAG, AST_REDIRECTING_TO_ID_PRESENTATION, AST_REDIRECTING_TO_NAME, AST_REDIRECTING_TO_NAME_CHAR_SET, AST_REDIRECTING_TO_NAME_PRESENTATION, AST_REDIRECTING_TO_NAME_VALID, AST_REDIRECTING_TO_NUMBER, AST_REDIRECTING_TO_NUMBER_PLAN, AST_REDIRECTING_TO_NUMBER_PRESENTATION, AST_REDIRECTING_TO_NUMBER_VALID, AST_REDIRECTING_TO_SUBADDRESS, AST_REDIRECTING_TO_SUBADDRESS_ODD_EVEN, AST_REDIRECTING_TO_SUBADDRESS_TYPE, AST_REDIRECTING_TO_SUBADDRESS_VALID, AST_REDIRECTING_TO_TAG, AST_REDIRECTING_VERSION, ast_party_redirecting::count, ast_set_party_redirecting::from, ast_party_redirecting::from, LOG_WARNING, ast_party_id_ies::name, party_id_build_data(), ast_party_redirecting::reason, ast_party_name_ies::str, ast_set_party_redirecting::to, ast_party_redirecting::to, and value.
Referenced by ast_channel_queue_redirecting_update(), ast_channel_update_redirecting(), and local_indicate().
08337 { 08338 int32_t value; 08339 size_t pos = 0; 08340 int res; 08341 08342 static const struct ast_party_id_ies from_ies = { 08343 .name.str = AST_REDIRECTING_FROM_NAME, 08344 .name.char_set = AST_REDIRECTING_FROM_NAME_CHAR_SET, 08345 .name.presentation = AST_REDIRECTING_FROM_NAME_PRESENTATION, 08346 .name.valid = AST_REDIRECTING_FROM_NAME_VALID, 08347 08348 .number.str = AST_REDIRECTING_FROM_NUMBER, 08349 .number.plan = AST_REDIRECTING_FROM_NUMBER_PLAN, 08350 .number.presentation = AST_REDIRECTING_FROM_NUMBER_PRESENTATION, 08351 .number.valid = AST_REDIRECTING_FROM_NUMBER_VALID, 08352 08353 .subaddress.str = AST_REDIRECTING_FROM_SUBADDRESS, 08354 .subaddress.type = AST_REDIRECTING_FROM_SUBADDRESS_TYPE, 08355 .subaddress.odd_even_indicator = AST_REDIRECTING_FROM_SUBADDRESS_ODD_EVEN, 08356 .subaddress.valid = AST_REDIRECTING_FROM_SUBADDRESS_VALID, 08357 08358 .tag = AST_REDIRECTING_FROM_TAG, 08359 .combined_presentation = AST_REDIRECTING_FROM_ID_PRESENTATION, 08360 }; 08361 static const struct ast_party_id_ies to_ies = { 08362 .name.str = AST_REDIRECTING_TO_NAME, 08363 .name.char_set = AST_REDIRECTING_TO_NAME_CHAR_SET, 08364 .name.presentation = AST_REDIRECTING_TO_NAME_PRESENTATION, 08365 .name.valid = AST_REDIRECTING_TO_NAME_VALID, 08366 08367 .number.str = AST_REDIRECTING_TO_NUMBER, 08368 .number.plan = AST_REDIRECTING_TO_NUMBER_PLAN, 08369 .number.presentation = AST_REDIRECTING_TO_NUMBER_PRESENTATION, 08370 .number.valid = AST_REDIRECTING_TO_NUMBER_VALID, 08371 08372 .subaddress.str = AST_REDIRECTING_TO_SUBADDRESS, 08373 .subaddress.type = AST_REDIRECTING_TO_SUBADDRESS_TYPE, 08374 .subaddress.odd_even_indicator = AST_REDIRECTING_TO_SUBADDRESS_ODD_EVEN, 08375 .subaddress.valid = AST_REDIRECTING_TO_SUBADDRESS_VALID, 08376 08377 .tag = AST_REDIRECTING_TO_TAG, 08378 .combined_presentation = AST_REDIRECTING_TO_ID_PRESENTATION, 08379 }; 08380 08381 /* Redirecting frame version */ 08382 if (datalen < pos + (sizeof(data[0]) * 2) + 1) { 08383 ast_log(LOG_WARNING, "No space left for redirecting frame version\n"); 08384 return -1; 08385 } 08386 data[pos++] = AST_REDIRECTING_VERSION; 08387 data[pos++] = 1; 08388 data[pos++] = 2;/* Version 1 did not have a version ie */ 08389 08390 res = party_id_build_data(data + pos, datalen - pos, &redirecting->from, 08391 "redirecting-from", &from_ies, update ? &update->from : NULL); 08392 if (res < 0) { 08393 return -1; 08394 } 08395 pos += res; 08396 08397 res = party_id_build_data(data + pos, datalen - pos, &redirecting->to, 08398 "redirecting-to", &to_ies, update ? &update->to : NULL); 08399 if (res < 0) { 08400 return -1; 08401 } 08402 pos += res; 08403 08404 /* Redirecting reason */ 08405 if (datalen < pos + (sizeof(data[0]) * 2) + sizeof(value)) { 08406 ast_log(LOG_WARNING, "No space left for redirecting reason\n"); 08407 return -1; 08408 } 08409 data[pos++] = AST_REDIRECTING_REASON; 08410 data[pos++] = sizeof(value); 08411 value = htonl(redirecting->reason); 08412 memcpy(data + pos, &value, sizeof(value)); 08413 pos += sizeof(value); 08414 08415 /* Redirecting count */ 08416 if (datalen < pos + (sizeof(data[0]) * 2) + sizeof(value)) { 08417 ast_log(LOG_WARNING, "No space left for redirecting count\n"); 08418 return -1; 08419 } 08420 data[pos++] = AST_REDIRECTING_COUNT; 08421 data[pos++] = sizeof(value); 08422 value = htonl(redirecting->count); 08423 memcpy(data + pos, &value, sizeof(value)); 08424 pos += sizeof(value); 08425 08426 return pos; 08427 }
| int ast_redirecting_parse_data | ( | const unsigned char * | data, | |
| size_t | datalen, | |||
| struct ast_party_redirecting * | redirecting | |||
| ) |
Parse redirecting indication frame data.
| data | Buffer with the frame data to parse | |
| datalen | Size of the buffer | |
| redirecting | Extracted redirecting id information |
| 0 | on success. | |
| -1 | on error. |
The filled in id structure needs to be destroyed by ast_party_redirecting_free() when it is no longer needed.
Definition at line 8429 of file channel.c.
References ast_free, ast_log(), ast_malloc, AST_PARTY_CHAR_SET_ISO8859_1, AST_REDIRECTING_COUNT, AST_REDIRECTING_FROM_ID_PRESENTATION, AST_REDIRECTING_FROM_NAME, AST_REDIRECTING_FROM_NAME_CHAR_SET, AST_REDIRECTING_FROM_NAME_PRESENTATION, AST_REDIRECTING_FROM_NAME_VALID, AST_REDIRECTING_FROM_NUMBER, AST_REDIRECTING_FROM_NUMBER_PLAN, AST_REDIRECTING_FROM_NUMBER_PRESENTATION, AST_REDIRECTING_FROM_NUMBER_VALID, AST_REDIRECTING_FROM_SUBADDRESS, AST_REDIRECTING_FROM_SUBADDRESS_ODD_EVEN, AST_REDIRECTING_FROM_SUBADDRESS_TYPE, AST_REDIRECTING_FROM_SUBADDRESS_VALID, AST_REDIRECTING_FROM_TAG, AST_REDIRECTING_TO_ID_PRESENTATION, AST_REDIRECTING_TO_NAME, AST_REDIRECTING_TO_NAME_CHAR_SET, AST_REDIRECTING_TO_NAME_PRESENTATION, AST_REDIRECTING_TO_NAME_VALID, AST_REDIRECTING_TO_NUMBER, AST_REDIRECTING_TO_NUMBER_PLAN, AST_REDIRECTING_TO_NUMBER_PRESENTATION, AST_REDIRECTING_TO_NUMBER_VALID, AST_REDIRECTING_TO_SUBADDRESS, AST_REDIRECTING_TO_SUBADDRESS_ODD_EVEN, AST_REDIRECTING_TO_SUBADDRESS_TYPE, AST_REDIRECTING_TO_SUBADDRESS_VALID, AST_REDIRECTING_TO_TAG, AST_REDIRECTING_VERSION, ast_party_name::char_set, ast_party_redirecting::count, ast_party_redirecting::from, LOG_DEBUG, LOG_WARNING, ast_party_id::name, ast_party_id::number, ast_party_subaddress::odd_even_indicator, ast_party_number::plan, ast_party_number::presentation, ast_party_name::presentation, ast_party_redirecting::reason, ast_party_subaddress::str, ast_party_number::str, ast_party_name::str, ast_party_id::subaddress, ast_party_id::tag, ast_party_redirecting::to, ast_party_subaddress::type, ast_party_subaddress::valid, ast_party_number::valid, ast_party_name::valid, and value.
Referenced by ast_channel_redirecting_macro(), and ast_indicate_data().
08430 { 08431 size_t pos; 08432 unsigned char ie_len; 08433 unsigned char ie_id; 08434 int32_t value; 08435 int frame_version = 1; 08436 int from_combined_presentation = 0; 08437 int got_from_combined_presentation = 0;/* TRUE if got a combined name and number presentation value. */ 08438 int to_combined_presentation = 0; 08439 int got_to_combined_presentation = 0;/* TRUE if got a combined name and number presentation value. */ 08440 08441 for (pos = 0; pos < datalen; pos += ie_len) { 08442 if (datalen < pos + sizeof(ie_id) + sizeof(ie_len)) { 08443 ast_log(LOG_WARNING, "Invalid redirecting update\n"); 08444 return -1; 08445 } 08446 ie_id = data[pos++]; 08447 ie_len = data[pos++]; 08448 if (datalen < pos + ie_len) { 08449 ast_log(LOG_WARNING, "Invalid redirecting update\n"); 08450 return -1; 08451 } 08452 08453 switch (ie_id) { 08454 /* Redirecting frame version */ 08455 case AST_REDIRECTING_VERSION: 08456 if (ie_len != 1) { 08457 ast_log(LOG_WARNING, "Invalid redirecting frame version (%u)\n", 08458 (unsigned) ie_len); 08459 break; 08460 } 08461 frame_version = data[pos]; 08462 break; 08463 /* Redirecting-from party id name */ 08464 case AST_REDIRECTING_FROM_NAME: 08465 ast_free(redirecting->from.name.str); 08466 redirecting->from.name.str = ast_malloc(ie_len + 1); 08467 if (redirecting->from.name.str) { 08468 memcpy(redirecting->from.name.str, data + pos, ie_len); 08469 redirecting->from.name.str[ie_len] = 0; 08470 } 08471 break; 08472 case AST_REDIRECTING_FROM_NAME_CHAR_SET: 08473 if (ie_len != 1) { 08474 ast_log(LOG_WARNING, "Invalid redirecting-from name char set (%u)\n", 08475 (unsigned) ie_len); 08476 break; 08477 } 08478 redirecting->from.name.char_set = data[pos]; 08479 break; 08480 case AST_REDIRECTING_FROM_NAME_PRESENTATION: 08481 if (ie_len != 1) { 08482 ast_log(LOG_WARNING, "Invalid redirecting-from name presentation (%u)\n", 08483 (unsigned) ie_len); 08484 break; 08485 } 08486 redirecting->from.name.presentation = data[pos]; 08487 break; 08488 case AST_REDIRECTING_FROM_NAME_VALID: 08489 if (ie_len != 1) { 08490 ast_log(LOG_WARNING, "Invalid redirecting-from name valid (%u)\n", 08491 (unsigned) ie_len); 08492 break; 08493 } 08494 redirecting->from.name.valid = data[pos]; 08495 break; 08496 /* Redirecting-from party id number */ 08497 case AST_REDIRECTING_FROM_NUMBER: 08498 ast_free(redirecting->from.number.str); 08499 redirecting->from.number.str = ast_malloc(ie_len + 1); 08500 if (redirecting->from.number.str) { 08501 memcpy(redirecting->from.number.str, data + pos, ie_len); 08502 redirecting->from.number.str[ie_len] = 0; 08503 } 08504 break; 08505 case AST_REDIRECTING_FROM_NUMBER_PLAN: 08506 if (ie_len != 1) { 08507 ast_log(LOG_WARNING, "Invalid redirecting-from numbering plan (%u)\n", 08508 (unsigned) ie_len); 08509 break; 08510 } 08511 redirecting->from.number.plan = data[pos]; 08512 break; 08513 case AST_REDIRECTING_FROM_NUMBER_PRESENTATION: 08514 if (ie_len != 1) { 08515 ast_log(LOG_WARNING, "Invalid redirecting-from number presentation (%u)\n", 08516 (unsigned) ie_len); 08517 break; 08518 } 08519 redirecting->from.number.presentation = data[pos]; 08520 break; 08521 case AST_REDIRECTING_FROM_NUMBER_VALID: 08522 if (ie_len != 1) { 08523 ast_log(LOG_WARNING, "Invalid redirecting-from number valid (%u)\n", 08524 (unsigned) ie_len); 08525 break; 08526 } 08527 redirecting->from.number.valid = data[pos]; 08528 break; 08529 /* Redirecting-from party id combined presentation */ 08530 case AST_REDIRECTING_FROM_ID_PRESENTATION: 08531 if (ie_len != 1) { 08532 ast_log(LOG_WARNING, "Invalid redirecting-from combined presentation (%u)\n", 08533 (unsigned) ie_len); 08534 break; 08535 } 08536 from_combined_presentation = data[pos]; 08537 got_from_combined_presentation = 1; 08538 break; 08539 /* Redirecting-from party id subaddress */ 08540 case AST_REDIRECTING_FROM_SUBADDRESS: 08541 ast_free(redirecting->from.subaddress.str); 08542 redirecting->from.subaddress.str = ast_malloc(ie_len + 1); 08543 if (redirecting->from.subaddress.str) { 08544 memcpy(redirecting->from.subaddress.str, data + pos, ie_len); 08545 redirecting->from.subaddress.str[ie_len] = 0; 08546 } 08547 break; 08548 case AST_REDIRECTING_FROM_SUBADDRESS_TYPE: 08549 if (ie_len != 1) { 08550 ast_log(LOG_WARNING, "Invalid redirecting-from type of subaddress (%u)\n", 08551 (unsigned) ie_len); 08552 break; 08553 } 08554 redirecting->from.subaddress.type = data[pos]; 08555 break; 08556 case AST_REDIRECTING_FROM_SUBADDRESS_ODD_EVEN: 08557 if (ie_len != 1) { 08558 ast_log(LOG_WARNING, 08559 "Invalid redirecting-from subaddress odd-even indicator (%u)\n", 08560 (unsigned) ie_len); 08561 break; 08562 } 08563 redirecting->from.subaddress.odd_even_indicator = data[pos]; 08564 break; 08565 case AST_REDIRECTING_FROM_SUBADDRESS_VALID: 08566 if (ie_len != 1) { 08567 ast_log(LOG_WARNING, "Invalid redirecting-from subaddress valid (%u)\n", 08568 (unsigned) ie_len); 08569 break; 08570 } 08571 redirecting->from.subaddress.valid = data[pos]; 08572 break; 08573 /* Redirecting-from party id tag */ 08574 case AST_REDIRECTING_FROM_TAG: 08575 ast_free(redirecting->from.tag); 08576 redirecting->from.tag = ast_malloc(ie_len + 1); 08577 if (redirecting->from.tag) { 08578 memcpy(redirecting->from.tag, data + pos, ie_len); 08579 redirecting->from.tag[ie_len] = 0; 08580 } 08581 break; 08582 /* Redirecting-to party id name */ 08583 case AST_REDIRECTING_TO_NAME: 08584 ast_free(redirecting->to.name.str); 08585 redirecting->to.name.str = ast_malloc(ie_len + 1); 08586 if (redirecting->to.name.str) { 08587 memcpy(redirecting->to.name.str, data + pos, ie_len); 08588 redirecting->to.name.str[ie_len] = 0; 08589 } 08590 break; 08591 case AST_REDIRECTING_TO_NAME_CHAR_SET: 08592 if (ie_len != 1) { 08593 ast_log(LOG_WARNING, "Invalid redirecting-to name char set (%u)\n", 08594 (unsigned) ie_len); 08595 break; 08596 } 08597 redirecting->to.name.char_set = data[pos]; 08598 break; 08599 case AST_REDIRECTING_TO_NAME_PRESENTATION: 08600 if (ie_len != 1) { 08601 ast_log(LOG_WARNING, "Invalid redirecting-to name presentation (%u)\n", 08602 (unsigned) ie_len); 08603 break; 08604 } 08605 redirecting->to.name.presentation = data[pos]; 08606 break; 08607 case AST_REDIRECTING_TO_NAME_VALID: 08608 if (ie_len != 1) { 08609 ast_log(LOG_WARNING, "Invalid redirecting-to name valid (%u)\n", 08610 (unsigned) ie_len); 08611 break; 08612 } 08613 redirecting->to.name.valid = data[pos]; 08614 break; 08615 /* Redirecting-to party id number */ 08616 case AST_REDIRECTING_TO_NUMBER: 08617 ast_free(redirecting->to.number.str); 08618 redirecting->to.number.str = ast_malloc(ie_len + 1); 08619 if (redirecting->to.number.str) { 08620 memcpy(redirecting->to.number.str, data + pos, ie_len); 08621 redirecting->to.number.str[ie_len] = 0; 08622 } 08623 break; 08624 case AST_REDIRECTING_TO_NUMBER_PLAN: 08625 if (ie_len != 1) { 08626 ast_log(LOG_WARNING, "Invalid redirecting-to numbering plan (%u)\n", 08627 (unsigned) ie_len); 08628 break; 08629 } 08630 redirecting->to.number.plan = data[pos]; 08631 break; 08632 case AST_REDIRECTING_TO_NUMBER_PRESENTATION: 08633 if (ie_len != 1) { 08634 ast_log(LOG_WARNING, "Invalid redirecting-to number presentation (%u)\n", 08635 (unsigned) ie_len); 08636 break; 08637 } 08638 redirecting->to.number.presentation = data[pos]; 08639 break; 08640 case AST_REDIRECTING_TO_NUMBER_VALID: 08641 if (ie_len != 1) { 08642 ast_log(LOG_WARNING, "Invalid redirecting-to number valid (%u)\n", 08643 (unsigned) ie_len); 08644 break; 08645 } 08646 redirecting->to.number.valid = data[pos]; 08647 break; 08648 /* Redirecting-to party id combined presentation */ 08649 case AST_REDIRECTING_TO_ID_PRESENTATION: 08650 if (ie_len != 1) { 08651 ast_log(LOG_WARNING, "Invalid redirecting-to combined presentation (%u)\n", 08652 (unsigned) ie_len); 08653 break; 08654 } 08655 to_combined_presentation = data[pos]; 08656 got_to_combined_presentation = 1; 08657 break; 08658 /* Redirecting-to party id subaddress */ 08659 case AST_REDIRECTING_TO_SUBADDRESS: 08660 ast_free(redirecting->to.subaddress.str); 08661 redirecting->to.subaddress.str = ast_malloc(ie_len + 1); 08662 if (redirecting->to.subaddress.str) { 08663 memcpy(redirecting->to.subaddress.str, data + pos, ie_len); 08664 redirecting->to.subaddress.str[ie_len] = 0; 08665 } 08666 break; 08667 case AST_REDIRECTING_TO_SUBADDRESS_TYPE: 08668 if (ie_len != 1) { 08669 ast_log(LOG_WARNING, "Invalid redirecting-to type of subaddress (%u)\n", 08670 (unsigned) ie_len); 08671 break; 08672 } 08673 redirecting->to.subaddress.type = data[pos]; 08674 break; 08675 case AST_REDIRECTING_TO_SUBADDRESS_ODD_EVEN: 08676 if (ie_len != 1) { 08677 ast_log(LOG_WARNING, 08678 "Invalid redirecting-to subaddress odd-even indicator (%u)\n", 08679 (unsigned) ie_len); 08680 break; 08681 } 08682 redirecting->to.subaddress.odd_even_indicator = data[pos]; 08683 break; 08684 case AST_REDIRECTING_TO_SUBADDRESS_VALID: 08685 if (ie_len != 1) { 08686 ast_log(LOG_WARNING, "Invalid redirecting-to subaddress valid (%u)\n", 08687 (unsigned) ie_len); 08688 break; 08689 } 08690 redirecting->to.subaddress.valid = data[pos]; 08691 break; 08692 /* Redirecting-to party id tag */ 08693 case AST_REDIRECTING_TO_TAG: 08694 ast_free(redirecting->to.tag); 08695 redirecting->to.tag = ast_malloc(ie_len + 1); 08696 if (redirecting->to.tag) { 08697 memcpy(redirecting->to.tag, data + pos, ie_len); 08698 redirecting->to.tag[ie_len] = 0; 08699 } 08700 break; 08701 /* Redirecting reason */ 08702 case AST_REDIRECTING_REASON: 08703 if (ie_len != sizeof(value)) { 08704 ast_log(LOG_WARNING, "Invalid redirecting reason (%u)\n", 08705 (unsigned) ie_len); 08706 break; 08707 } 08708 memcpy(&value, data + pos, sizeof(value)); 08709 redirecting->reason = ntohl(value); 08710 break; 08711 /* Redirecting count */ 08712 case AST_REDIRECTING_COUNT: 08713 if (ie_len != sizeof(value)) { 08714 ast_log(LOG_WARNING, "Invalid redirecting count (%u)\n", 08715 (unsigned) ie_len); 08716 break; 08717 } 08718 memcpy(&value, data + pos, sizeof(value)); 08719 redirecting->count = ntohl(value); 08720 break; 08721 /* Redirecting unknown element */ 08722 default: 08723 ast_log(LOG_DEBUG, "Unknown redirecting element: %u (%u)\n", 08724 (unsigned) ie_id, (unsigned) ie_len); 08725 break; 08726 } 08727 } 08728 08729 switch (frame_version) { 08730 case 1: 08731 /* 08732 * The other end is an earlier version that we need to adjust 08733 * for compatibility. 08734 */ 08735 redirecting->from.name.valid = 1; 08736 redirecting->from.name.char_set = AST_PARTY_CHAR_SET_ISO8859_1; 08737 redirecting->from.number.valid = 1; 08738 if (got_from_combined_presentation) { 08739 redirecting->from.name.presentation = from_combined_presentation; 08740 redirecting->from.number.presentation = from_combined_presentation; 08741 } 08742 08743 redirecting->to.name.valid = 1; 08744 redirecting->to.name.char_set = AST_PARTY_CHAR_SET_ISO8859_1; 08745 redirecting->to.number.valid = 1; 08746 if (got_to_combined_presentation) { 08747 redirecting->to.name.presentation = to_combined_presentation; 08748 redirecting->to.number.presentation = to_combined_presentation; 08749 } 08750 break; 08751 case 2: 08752 /* The other end is at the same level as we are. */ 08753 break; 08754 default: 08755 /* 08756 * The other end is newer than we are. 08757 * We need to assume that they are compatible with us. 08758 */ 08759 ast_log(LOG_DEBUG, "Redirecting frame has newer version: %u\n", 08760 (unsigned) frame_version); 08761 break; 08762 } 08763 08764 return 0; 08765 }
| struct ast_channel* ast_request | ( | const char * | type, | |
| format_t | format, | |||
| const struct ast_channel * | requestor, | |||
| void * | data, | |||
| int * | status | |||
| ) | [read] |
Requests a channel.
| type | type of channel to request | |
| format | requested channel format (codec) | |
| requestor | channel asking for data | |
| data | data to pass to the channel requester | |
| status | status |
| NULL | failure | |
| non-NULL | channel on success |
Definition at line 5294 of file channel.c.
References AST_CAUSE_BEARERCAPABILITY_NOTAVAIL, AST_CAUSE_NOSUCHDRIVER, AST_CAUSE_NOTDEFINED, ast_channel_release(), AST_FORMAT_AUDIO_MASK, AST_FORMAT_TEXT_MASK, AST_FORMAT_VIDEO_MASK, ast_getformatname_multiple(), ast_log(), AST_RWLIST_RDLOCK, AST_RWLIST_TRAVERSE, AST_RWLIST_UNLOCK, ast_translator_best_choice(), ast_channel_tech::capabilities, capabilities, LOG_WARNING, ast_channel_tech::requester, set_security_requirements(), chanlist::tech, and ast_channel_tech::type.
Referenced by __ast_request_and_dial(), ast_call_forward(), attempt_reconnect(), begin_dial_channel(), build_conf(), chanavail_exec(), conf_run(), connect_link(), dial_exec_full(), dial_transfer(), do_forward(), feature_request_and_dial(), findmeexec(), play_sound_file(), ring_entry(), rpt(), rpt_call(), rpt_exec(), rpt_tele_thread(), and wait_for_answer().
05295 { 05296 struct chanlist *chan; 05297 struct ast_channel *c; 05298 format_t capabilities; 05299 format_t fmt; 05300 int res; 05301 int foo; 05302 format_t videoformat = format & AST_FORMAT_VIDEO_MASK; 05303 format_t textformat = format & AST_FORMAT_TEXT_MASK; 05304 05305 if (!cause) 05306 cause = &foo; 05307 *cause = AST_CAUSE_NOTDEFINED; 05308 05309 if (AST_RWLIST_RDLOCK(&backends)) { 05310 ast_log(LOG_WARNING, "Unable to lock technology backend list\n"); 05311 return NULL; 05312 } 05313 05314 AST_RWLIST_TRAVERSE(&backends, chan, list) { 05315 if (strcasecmp(type, chan->tech->type)) 05316 continue; 05317 05318 capabilities = chan->tech->capabilities; 05319 fmt = format & AST_FORMAT_AUDIO_MASK; 05320 if (fmt) { 05321 /* We have audio - is it possible to connect the various calls to each other? 05322 (Avoid this check for calls without audio, like text+video calls) 05323 */ 05324 res = ast_translator_best_choice(&fmt, &capabilities); 05325 if (res < 0) { 05326 char tmp1[256], tmp2[256]; 05327 ast_log(LOG_WARNING, "No translator path exists for channel type %s (native %s) to %s\n", type, 05328 ast_getformatname_multiple(tmp1, sizeof(tmp1), chan->tech->capabilities), 05329 ast_getformatname_multiple(tmp2, sizeof(tmp2), format)); 05330 *cause = AST_CAUSE_BEARERCAPABILITY_NOTAVAIL; 05331 AST_RWLIST_UNLOCK(&backends); 05332 return NULL; 05333 } 05334 } 05335 AST_RWLIST_UNLOCK(&backends); 05336 if (!chan->tech->requester) 05337 return NULL; 05338 05339 if (!(c = chan->tech->requester(type, capabilities | videoformat | textformat, requestor, data, cause))) 05340 return NULL; 05341 05342 if (set_security_requirements(requestor, c)) { 05343 ast_log(LOG_WARNING, "Setting security requirements failed\n"); 05344 c = ast_channel_release(c); 05345 *cause = AST_CAUSE_BEARERCAPABILITY_NOTAVAIL; 05346 return NULL; 05347 } 05348 05349 /* no need to generate a Newchannel event here; it is done in the channel_alloc call */ 05350 return c; 05351 } 05352 05353 ast_log(LOG_WARNING, "No channel type registered for '%s'\n", type); 05354 *cause = AST_CAUSE_NOSUCHDRIVER; 05355 AST_RWLIST_UNLOCK(&backends); 05356 05357 return NULL; 05358 }
| struct ast_channel* ast_request_and_dial | ( | const char * | type, | |
| format_t | format, | |||
| const struct ast_channel * | requestor, | |||
| void * | data, | |||
| int | timeout, | |||
| int * | reason, | |||
| const char * | cid_num, | |||
| const char * | cid_name | |||
| ) | [read] |
Request a channel of a given type, with data as optional information used by the low level module and attempt to place a call on it.
| type | type of channel to request | |
| format | requested channel format | |
| requestor | channel asking for data | |
| data | data to pass to the channel requester | |
| timeout | maximum amount of time to wait for an answer | |
| reason | why unsuccessful (if unsuccessful) | |
| cid_num | Caller-ID Number | |
| cid_name | Caller-ID Name (ascii) |
Definition at line 5249 of file channel.c.
References __ast_request_and_dial().
Referenced by ast_pbx_outgoing_exten(), and generic_recall().
05250 { 05251 return __ast_request_and_dial(type, format, requestor, data, timeout, outstate, cidnum, cidname, NULL); 05252 }
| int ast_safe_sleep | ( | struct ast_channel * | chan, | |
| int | ms | |||
| ) |
Wait, look for hangups.
Wait for a specified amount of time, looking for hangups.
Definition at line 1793 of file channel.c.
References ast_safe_sleep_conditional().
Referenced by __analog_ss_thread(), alarmreceiver_exec(), analog_ss_thread(), ast_adsi_transmit_message_full(), ast_dtmf_stream(), ast_senddigit(), builtin_atxfer(), conf_run(), dictate_exec(), disa_exec(), flash_exec(), function_ilink(), handle_callforward_button(), login_exec(), mgcp_ss(), milliwatt_exec(), misdn_check_l2l1(), old_milliwatt_exec(), park_call_exec(), parkcall_helper(), pbx_builtin_wait(), play_moh_exec(), play_tone_pair(), playtone(), privacy_exec(), receive_ademco_contact_id(), rpt_call(), rpt_exec(), rpt_tele_thread(), send_morse(), send_tone_telemetry(), skinny_ss(), testclient_exec(), testserver_exec(), try_calling(), wait_for_hangup(), wait_interval(), wait_moh_exec(), waituntil_exec(), and zapateller_exec().
01794 { 01795 return ast_safe_sleep_conditional(chan, ms, NULL, NULL); 01796 }
| int ast_safe_sleep_conditional | ( | struct ast_channel * | chan, | |
| int | ms, | |||
| int(*)(void *) | cond, | |||
| void * | data | |||
| ) |
Wait, look for hangups and condition arg.
Wait for a specified amount of time, looking for hangups and a condition argument.
Definition at line 1726 of file channel.c.
References ast_channel_lock, ast_channel_start_silence_generator(), ast_channel_stop_silence_generator(), ast_channel_unlock, ast_frfree, ast_frisolate(), ast_is_deferrable_frame(), AST_LIST_HEAD_INIT_NOLOCK, AST_LIST_HEAD_NOLOCK, AST_LIST_INSERT_HEAD, AST_LIST_REMOVE_HEAD, ast_opt_transmit_silence, ast_queue_frame_head(), ast_read(), ast_waitfor(), cond, and ast_channel::generatordata.
Referenced by ast_safe_sleep(), and login_exec().
01727 { 01728 struct ast_frame *f; 01729 struct ast_silence_generator *silgen = NULL; 01730 int res = 0; 01731 AST_LIST_HEAD_NOLOCK(, ast_frame) deferred_frames; 01732 01733 AST_LIST_HEAD_INIT_NOLOCK(&deferred_frames); 01734 01735 /* If no other generator is present, start silencegen while waiting */ 01736 if (ast_opt_transmit_silence && !chan->generatordata) { 01737 silgen = ast_channel_start_silence_generator(chan); 01738 } 01739 01740 while (ms > 0) { 01741 struct ast_frame *dup_f = NULL; 01742 if (cond && ((*cond)(data) == 0)) { 01743 break; 01744 } 01745 ms = ast_waitfor(chan, ms); 01746 if (ms < 0) { 01747 res = -1; 01748 break; 01749 } 01750 if (ms > 0) { 01751 f = ast_read(chan); 01752 if (!f) { 01753 res = -1; 01754 break; 01755 } 01756 01757 if (!ast_is_deferrable_frame(f)) { 01758 ast_frfree(f); 01759 continue; 01760 } 01761 01762 if ((dup_f = ast_frisolate(f))) { 01763 if (dup_f != f) { 01764 ast_frfree(f); 01765 } 01766 AST_LIST_INSERT_HEAD(&deferred_frames, dup_f, frame_list); 01767 } 01768 } 01769 } 01770 01771 /* stop silgen if present */ 01772 if (silgen) { 01773 ast_channel_stop_silence_generator(chan, silgen); 01774 } 01775 01776 /* We need to free all the deferred frames, but we only need to 01777 * queue the deferred frames if there was no error and no 01778 * hangup was received 01779 */ 01780 ast_channel_lock(chan); 01781 while ((f = AST_LIST_REMOVE_HEAD(&deferred_frames, frame_list))) { 01782 if (!res) { 01783 ast_queue_frame_head(chan, f); 01784 } 01785 ast_frfree(f); 01786 } 01787 ast_channel_unlock(chan); 01788 01789 return res; 01790 }
| int ast_say_character_str | ( | struct ast_channel * | chan, | |
| const char * | str, | |||
| const char * | ints, | |||
| const char * | lang | |||
| ) |
Definition at line 7596 of file channel.c.
References ast_say_character_str_full.
Referenced by common_exec(), pbx_builtin_saycharacters(), play_mailbox_owner(), rpt_tele_thread(), saycharstr(), saynode(), and vmsayname_exec().
07598 { 07599 return ast_say_character_str_full(chan, str, ints, lang, -1, -1); 07600 }
| int ast_say_digit_str | ( | struct ast_channel * | chan, | |
| const char * | num, | |||
| const char * | ints, | |||
| const char * | lang | |||
| ) |
says digits of a string
| chan | channel to act upon | |
| num | string to speak | |
| ints | which dtmf to interrupt on | |
| lang | language to speak in |
| 0 | on succes | |
| DTMF | if interrupted | |
| -1 | on failure |
Definition at line 7590 of file channel.c.
References ast_say_digit_str_full.
Referenced by __analog_ss_thread(), forward_message(), invent_message(), mgcp_ss(), pbx_builtin_saydigits(), and play_message_callerid().
07592 { 07593 return ast_say_digit_str_full(chan, str, ints, lang, -1, -1); 07594 }
| int ast_say_digits | ( | struct ast_channel * | chan, | |
| int | num, | |||
| const char * | ints, | |||
| const char * | lang | |||
| ) |
says digits
| chan | channel to act upon | |
| num | number to speak | |
| ints | which dtmf to interrupt on | |
| lang | language to speak |
| 0 | on success | |
| DTMF | if interrupted | |
| -1 | on failure |
Definition at line 7584 of file channel.c.
References ast_say_digits_full().
Referenced by common_exec(), conf_exec(), conf_run(), park_call_full(), parkandannounce_exec(), and rpt_tele_thread().
07586 { 07587 return ast_say_digits_full(chan, num, ints, lang, -1, -1); 07588 }
| int ast_say_digits_full | ( | struct ast_channel * | chan, | |
| int | num, | |||
| const char * | ints, | |||
| const char * | lang, | |||
| int | audiofd, | |||
| int | ctrlfd | |||
| ) |
Definition at line 7608 of file channel.c.
References ast_say_digit_str_full.
Referenced by ast_say_digits(), ast_say_enumeration_full_da(), ast_say_enumeration_full_de(), ast_say_number_full_cs(), ast_say_number_full_da(), ast_say_number_full_de(), ast_say_number_full_en(), ast_say_number_full_en_GB(), ast_say_number_full_es(), ast_say_number_full_fr(), ast_say_number_full_he(), ast_say_number_full_hu(), ast_say_number_full_it(), ast_say_number_full_ka(), ast_say_number_full_nl(), ast_say_number_full_no(), ast_say_number_full_pt(), ast_say_number_full_ru(), ast_say_number_full_se(), ast_say_number_full_th(), ast_say_number_full_ur(), ast_say_number_full_vi(), ast_say_number_full_zh(), and say_init_mode().
07610 { 07611 char buf[256]; 07612 07613 snprintf(buf, sizeof(buf), "%d", num); 07614 07615 return ast_say_digit_str_full(chan, buf, ints, lang, audiofd, ctrlfd); 07616 }
| int ast_say_enumeration | ( | struct ast_channel * | chan, | |
| int | num, | |||
| const char * | ints, | |||
| const char * | lang, | |||
| const char * | options | |||
| ) |
says an enumeration
| chan | channel to say them enumeration on | |
| num | number to say on the channel | |
| ints | which dtmf to interrupt on | |
| lang | language to speak the enumeration | |
| options | set to 'f' for female, 'm' for male, 'c' for commune, 'n' for neuter, 'p' for plural |
| 0 | on success | |
| DTMF | digit on interrupt | |
| -1 | on failure |
Definition at line 7578 of file channel.c.
References ast_say_enumeration_full.
Referenced by ast_say_date_da(), ast_say_date_de(), ast_say_date_with_format_da(), ast_say_date_with_format_de(), ast_say_date_with_format_en(), ast_say_date_with_format_pl(), and ast_say_date_with_format_vi().
07580 { 07581 return ast_say_enumeration_full(chan, num, ints, language, options, -1, -1); 07582 }
| int ast_say_number | ( | struct ast_channel * | chan, | |
| int | num, | |||
| const char * | ints, | |||
| const char * | lang, | |||
| const char * | options | |||
| ) |
says a number
| chan | channel to say them number on | |
| num | number to say on the channel | |
| ints | which dtmf to interrupt on | |
| lang | language to speak the number | |
| options | set to 'f' for female, 'm' for male, 'c' for commune, 'n' for neuter, 'p' for plural |
| 0 | on success | |
| DTMF | digit on interrupt | |
| -1 | on failure |
Definition at line 7572 of file channel.c.
References ast_say_number_full.
Referenced by announce_user_count(), ast_say_date_da(), ast_say_date_de(), ast_say_date_en(), ast_say_date_fr(), ast_say_date_gr(), ast_say_date_he(), ast_say_date_hu(), ast_say_date_ka(), ast_say_date_nl(), ast_say_date_pt(), ast_say_date_th(), ast_say_date_with_format_da(), ast_say_date_with_format_de(), ast_say_date_with_format_en(), ast_say_date_with_format_es(), ast_say_date_with_format_fr(), ast_say_date_with_format_it(), ast_say_date_with_format_nl(), ast_say_date_with_format_pl(), ast_say_date_with_format_pt(), ast_say_date_with_format_th(), ast_say_date_with_format_vi(), ast_say_datetime_en(), ast_say_datetime_fr(), ast_say_datetime_from_now_en(), ast_say_datetime_from_now_fr(), ast_say_datetime_from_now_he(), ast_say_datetime_from_now_ka(), ast_say_datetime_from_now_pt(), ast_say_datetime_he(), ast_say_datetime_pt(), ast_say_datetime_th(), ast_say_datetime_zh(), ast_say_time_de(), ast_say_time_en(), ast_say_time_fr(), ast_say_time_gr(), ast_say_time_hu(), ast_say_time_ka(), ast_say_time_nl(), ast_say_time_pt(), ast_say_time_pt_BR(), ast_say_time_th(), ast_say_time_zh(), bridge_playfile(), conf_run(), count_exec(), dictate_exec(), get_folder(), gr_say_number_female(), pbx_builtin_saynumber(), play_message(), play_message_duration(), rpt_tele_thread(), say_and_wait(), say_position(), saynum(), try_calling(), vm_intro_gr(), vm_intro_he(), vm_intro_multilang(), vm_intro_pt(), and vm_intro_pt_BR().
07574 { 07575 return ast_say_number_full(chan, num, ints, language, options, -1, -1); 07576 }
| int ast_say_phonetic_str | ( | struct ast_channel * | chan, | |
| const char * | str, | |||
| const char * | ints, | |||
| const char * | lang | |||
| ) |
Definition at line 7602 of file channel.c.
References ast_say_phonetic_str_full.
Referenced by pbx_builtin_sayphonetic().
07604 { 07605 return ast_say_phonetic_str_full(chan, str, ints, lang, -1, -1); 07606 }
| int ast_senddigit | ( | struct ast_channel * | chan, | |
| char | digit, | |||
| unsigned int | duration | |||
| ) |
Send a DTMF digit to a channel.
| chan | channel to act upon | |
| digit | the DTMF digit to send, encoded in ASCII | |
| duration | the duration of the digit ending in ms |
Definition at line 4463 of file channel.c.
References AST_DEFAULT_EMULATE_DTMF_DURATION, ast_safe_sleep(), ast_senddigit_begin(), ast_senddigit_end(), ast_channel_tech::send_digit_begin, and ast_channel::tech.
Referenced by ast_dtmf_stream(), dial_exec_full(), do_dtmf_phone(), manager_play_dtmf(), and rpt_call().
04464 { 04465 if (chan->tech->send_digit_begin) { 04466 ast_senddigit_begin(chan, digit); 04467 ast_safe_sleep(chan, (duration >= AST_DEFAULT_EMULATE_DTMF_DURATION ? duration : AST_DEFAULT_EMULATE_DTMF_DURATION)); 04468 } 04469 04470 return ast_senddigit_end(chan, digit, (duration >= AST_DEFAULT_EMULATE_DTMF_DURATION ? duration : AST_DEFAULT_EMULATE_DTMF_DURATION)); 04471 }
| int ast_senddigit_begin | ( | struct ast_channel * | chan, | |
| char | digit | |||
| ) |
Send a DTMF digit to a channel.
| chan | channel to act upon | |
| digit | the DTMF digit to send, encoded in ASCII |
Definition at line 4405 of file channel.c.
References ast_debug, ast_playtones_start(), ast_channel::name, ast_channel_tech::send_digit_begin, and ast_channel::tech.
Referenced by agent_digit_begin(), ast_senddigit(), and ast_write().
04406 { 04407 /* Device does not support DTMF tones, lets fake 04408 * it by doing our own generation. */ 04409 static const char * const dtmf_tones[] = { 04410 "941+1336", /* 0 */ 04411 "697+1209", /* 1 */ 04412 "697+1336", /* 2 */ 04413 "697+1477", /* 3 */ 04414 "770+1209", /* 4 */ 04415 "770+1336", /* 5 */ 04416 "770+1477", /* 6 */ 04417 "852+1209", /* 7 */ 04418 "852+1336", /* 8 */ 04419 "852+1477", /* 9 */ 04420 "697+1633", /* A */ 04421 "770+1633", /* B */ 04422 "852+1633", /* C */ 04423 "941+1633", /* D */ 04424 "941+1209", /* * */ 04425 "941+1477" /* # */ 04426 }; 04427 04428 if (!chan->tech->send_digit_begin) 04429 return 0; 04430 04431 if (!chan->tech->send_digit_begin(chan, digit)) 04432 return 0; 04433 04434 if (digit >= '0' && digit <='9') 04435 ast_playtones_start(chan, 0, dtmf_tones[digit-'0'], 0); 04436 else if (digit >= 'A' && digit <= 'D') 04437 ast_playtones_start(chan, 0, dtmf_tones[digit-'A'+10], 0); 04438 else if (digit == '*') 04439 ast_playtones_start(chan, 0, dtmf_tones[14], 0); 04440 else if (digit == '#') 04441 ast_playtones_start(chan, 0, dtmf_tones[15], 0); 04442 else { 04443 /* not handled */ 04444 ast_debug(1, "Unable to generate DTMF tone '%c' for '%s'\n", digit, chan->name); 04445 } 04446 04447 return 0; 04448 }
| int ast_senddigit_end | ( | struct ast_channel * | chan, | |
| char | digit, | |||
| unsigned int | duration | |||
| ) |
Send a DTMF digit to a channel.
| chan | channel to act upon | |
| digit | the DTMF digit to send, encoded in ASCII | |
| duration | the duration of the digit ending in ms |
Definition at line 4450 of file channel.c.
References ast_playtones_stop(), ast_channel::generator, ast_channel_tech::send_digit_end, and ast_channel::tech.
Referenced by agent_digit_end(), ast_senddigit(), and ast_write().
04451 { 04452 int res = -1; 04453 04454 if (chan->tech->send_digit_end) 04455 res = chan->tech->send_digit_end(chan, digit, duration); 04456 04457 if (res && chan->generator) 04458 ast_playtones_stop(chan); 04459 04460 return 0; 04461 }
| int ast_sendtext | ( | struct ast_channel * | chan, | |
| const char * | text | |||
| ) |
Sends text to a channel.
| chan | channel to act upon | |
| text | string of text to send on the channel |
| 0 | on success | |
| -1 | on failure |
Definition at line 4392 of file channel.c.
References ast_check_hangup(), ast_clear_flag, AST_FLAG_BLOCKING, AST_FLAG_ZOMBIE, ast_test_flag, CHECK_BLOCKING, ast_channel_tech::send_text, and ast_channel::tech.
Referenced by action_sendtext(), agent_sendtext(), handle_sendtext(), send_newkey(), and sendtext_exec().
04393 { 04394 int res = 0; 04395 /* Stop if we're a zombie or need a soft hangup */ 04396 if (ast_test_flag(chan, AST_FLAG_ZOMBIE) || ast_check_hangup(chan)) 04397 return -1; 04398 CHECK_BLOCKING(chan); 04399 if (chan->tech->send_text) 04400 res = chan->tech->send_text(chan, text); 04401 ast_clear_flag(chan, AST_FLAG_BLOCKING); 04402 return res; 04403 }
| void ast_set_callerid | ( | struct ast_channel * | chan, | |
| const char * | cid_num, | |||
| const char * | cid_name, | |||
| const char * | cid_ani | |||
| ) |
Set caller ID number, name and ANI and generate AMI event.
The channel does not need to be locked before calling this function.
Definition at line 6306 of file channel.c.
References ast_party_caller::ani, ast_cdr_setcid(), ast_channel_lock, ast_channel_unlock, ast_free, ast_strdup, ast_channel::caller, ast_channel::cdr, ast_party_caller::id, ast_party_id::name, ast_party_id::number, report_new_callerid(), ast_party_name::str, ast_party_number::str, ast_party_name::valid, and ast_party_number::valid.
Referenced by __analog_ss_thread(), __ast_request_and_dial(), analog_ss_thread(), ast_call_forward(), cb_events(), dial_exec_full(), disa_exec(), do_forward(), feature_request_and_dial(), findmeexec(), get_pai(), get_rpid(), handle_setcallerid(), mgcp_ss(), privacy_exec(), ring_entry(), rpt_exec(), sig_pri_handle_subcmds(), skinny_newcall(), and socket_process().
06307 { 06308 ast_channel_lock(chan); 06309 06310 if (cid_num) { 06311 chan->caller.id.number.valid = 1; 06312 ast_free(chan->caller.id.number.str); 06313 chan->caller.id.number.str = ast_strdup(cid_num); 06314 } 06315 if (cid_name) { 06316 chan->caller.id.name.valid = 1; 06317 ast_free(chan->caller.id.name.str); 06318 chan->caller.id.name.str = ast_strdup(cid_name); 06319 } 06320 if (cid_ani) { 06321 chan->caller.ani.number.valid = 1; 06322 ast_free(chan->caller.ani.number.str); 06323 chan->caller.ani.number.str = ast_strdup(cid_ani); 06324 } 06325 if (chan->cdr) { 06326 ast_cdr_setcid(chan->cdr, chan); 06327 } 06328 06329 report_new_callerid(chan); 06330 06331 ast_channel_unlock(chan); 06332 }
| void ast_set_hangupsource | ( | struct ast_channel * | chan, | |
| const char * | source, | |||
| int | force | |||
| ) |
Set the source of the hangup in this channel and it's bridge.
| chan | channel to set the field on | |
| source | a string describing the source of the hangup for this channel | |
| force |
Definition at line 2610 of file channel.c.
References ast_bridged_channel(), ast_channel_lock, ast_channel_unlock, ast_string_field_set, ast_strlen_zero(), ast_channel::bridge, and ast_channel::hangupsource.
Referenced by __dahdi_exception(), func_channel_write_real(), handle_hangup(), handle_request_bye(), handle_request_cancel(), handle_response_invite(), pbx_builtin_hangup(), and set_hangup_source_and_cause().
02611 { 02612 struct ast_channel *bridge; 02613 02614 ast_channel_lock(chan); 02615 if (force || ast_strlen_zero(chan->hangupsource)) { 02616 ast_string_field_set(chan, hangupsource, source); 02617 } 02618 bridge = ast_bridged_channel(chan); 02619 ast_channel_unlock(chan); 02620 02621 if (bridge && (force || ast_strlen_zero(bridge->hangupsource))) { 02622 ast_channel_lock(bridge); 02623 ast_string_field_set(chan, hangupsource, source); 02624 ast_channel_unlock(bridge); 02625 } 02626 }
| static void ast_set_owners_and_peers | ( | struct ast_channel * | chan1, | |
| struct ast_channel * | chan2 | |||
| ) | [static] |
Definition at line 5880 of file channel.c.
References accountcode, ast_channel::accountcode, ast_log(), ast_string_field_set, ast_strlen_zero(), LOG_DEBUG, ast_channel::name, and ast_channel::peeraccount.
Referenced by ast_channel_bridge().
05882 { 05883 if (!ast_strlen_zero(chan1->accountcode) && ast_strlen_zero(chan2->peeraccount)) { 05884 ast_log(LOG_DEBUG, "setting peeraccount to %s for %s from data on channel %s\n", 05885 chan1->accountcode, chan2->name, chan1->name); 05886 ast_string_field_set(chan2, peeraccount, chan1->accountcode); 05887 } 05888 if (!ast_strlen_zero(chan2->accountcode) && ast_strlen_zero(chan1->peeraccount)) { 05889 ast_log(LOG_DEBUG, "setting peeraccount to %s for %s from data on channel %s\n", 05890 chan2->accountcode, chan1->name, chan2->name); 05891 ast_string_field_set(chan1, peeraccount, chan2->accountcode); 05892 } 05893 if (!ast_strlen_zero(chan1->peeraccount) && ast_strlen_zero(chan2->accountcode)) { 05894 ast_log(LOG_DEBUG, "setting accountcode to %s for %s from data on channel %s\n", 05895 chan1->peeraccount, chan2->name, chan1->name); 05896 ast_string_field_set(chan2, accountcode, chan1->peeraccount); 05897 } 05898 if (!ast_strlen_zero(chan2->peeraccount) && ast_strlen_zero(chan1->accountcode)) { 05899 ast_log(LOG_DEBUG, "setting accountcode to %s for %s from data on channel %s\n", 05900 chan2->peeraccount, chan1->name, chan2->name); 05901 ast_string_field_set(chan1, accountcode, chan2->peeraccount); 05902 } 05903 if (0 != strcmp(chan1->accountcode, chan2->peeraccount)) { 05904 ast_log(LOG_DEBUG, "changing peeraccount from %s to %s on %s to match channel %s\n", 05905 chan2->peeraccount, chan1->peeraccount, chan2->name, chan1->name); 05906 ast_string_field_set(chan2, peeraccount, chan1->accountcode); 05907 } 05908 if (0 != strcmp(chan2->accountcode, chan1->peeraccount)) { 05909 ast_log(LOG_DEBUG, "changing peeraccount from %s to %s on %s to match channel %s\n", 05910 chan1->peeraccount, chan2->peeraccount, chan1->name, chan2->name); 05911 ast_string_field_set(chan1, peeraccount, chan2->accountcode); 05912 } 05913 }
| int ast_set_read_format | ( | struct ast_channel * | chan, | |
| format_t | format | |||
| ) |
Sets read format on channel chan Set read format for channel to whichever component of "format" is best.
| chan | channel to change | |
| format | format to change to |
Definition at line 4961 of file channel.c.
References ast_channel::rawreadformat, ast_channel::readformat, ast_channel::readtrans, and set_format().
Referenced by __ast_play_and_record(), __oh323_update_info(), agent_call(), alarmreceiver_exec(), ast_adsi_transmit_message_full(), ast_channel_make_compatible_helper(), ast_do_masquerade(), attempt_reconnect(), background_detect_exec(), bridge_channel_join(), bridge_make_compatible(), build_conf(), conf_run(), connect_link(), dictate_exec(), do_waiting(), eagi_exec(), echo_exec(), generic_fax_exec(), gtalk_rtp_read(), handle_recordfile(), handle_speechrecognize(), ices_exec(), isAnsweringMachine(), jack_exec(), jingle_rtp_read(), login_exec(), measurenoise(), mgcp_rtp_read(), oh323_rtp_read(), old_milliwatt_exec(), process_sdp(), record_exec(), rpt(), rpt_exec(), setup_rtp_connection(), sip_rtp_read(), skinny_rtp_read(), socket_process(), speech_background(), transmit_audio(), and unistim_rtp_read().
04962 { 04963 return set_format(chan, fmt, &chan->rawreadformat, &chan->readformat, 04964 &chan->readtrans, 0); 04965 }
| void ast_set_variables | ( | struct ast_channel * | chan, | |
| struct ast_variable * | vars | |||
| ) |
adds a list of channel variables to a channel
| chan | the channel | |
| vars | a linked list of variables |
Definition at line 7459 of file channel.c.
References ast_variable::name, ast_variable::next, pbx_builtin_setvar_helper(), and ast_variable::value.
Referenced by __ast_request_and_dial(), ast_call_forward(), ast_pbx_outgoing_app(), and ast_pbx_outgoing_exten().
07460 { 07461 struct ast_variable *cur; 07462 07463 for (cur = vars; cur; cur = cur->next) 07464 pbx_builtin_setvar_helper(chan, cur->name, cur->value); 07465 }
| int ast_set_write_format | ( | struct ast_channel * | chan, | |
| format_t | format | |||
| ) |
Sets write format on channel chan Set write format for channel to whichever component of "format" is best.
| chan | channel to change | |
| format | new format for writing |
Definition at line 4967 of file channel.c.
References ast_channel::rawwriteformat, set_format(), ast_channel::writeformat, and ast_channel::writetrans.
Referenced by __oh323_update_info(), agent_call(), alarmreceiver_exec(), ast_adsi_transmit_message_full(), ast_channel_make_compatible_helper(), ast_channel_start_silence_generator(), ast_channel_stop_silence_generator(), ast_do_masquerade(), ast_openstream_full(), ast_stopstream(), attempt_reconnect(), bridge_channel_join(), bridge_make_compatible(), build_conf(), chanspy_exec(), conf_run(), connect_link(), dahdiscan_exec(), echo_exec(), extenspy_exec(), generic_fax_exec(), gtalk_rtp_read(), jack_exec(), jingle_rtp_read(), linear_alloc(), linear_release(), login_exec(), mgcp_rtp_read(), moh_alloc(), moh_files_release(), moh_release(), mp3_exec(), NBScat_exec(), oh323_rtp_read(), old_milliwatt_exec(), playtones_alloc(), playtones_release(), process_sdp(), rpt(), rpt_exec(), send_waveform_to_channel(), setup_rtp_connection(), sip_rtp_read(), skinny_rtp_read(), socket_process(), tonepair_alloc(), tonepair_release(), transmit_audio(), and unistim_rtp_read().
04968 { 04969 return set_format(chan, fmt, &chan->rawwriteformat, &chan->writeformat, 04970 &chan->writetrans, 1); 04971 }
| int ast_setstate | ( | struct ast_channel * | chan, | |
| enum ast_channel_state | state | |||
| ) |
Change the state of a channel.
Definition at line 6371 of file channel.c.
References ast_channel::_state, AST_CHANNEL_NAME, ast_copy_string(), AST_DEVICE_UNKNOWN, ast_devstate_changed_literal(), ast_manager_event, ast_state2str(), ast_channel::caller, EVENT_FLAG_CALL, ast_party_caller::id, ast_party_id::name, ast_channel::name, name, ast_party_id::number, S_COR, ast_party_name::str, ast_party_number::str, ast_channel::uniqueid, ast_party_name::valid, and ast_party_number::valid.
Referenced by __analog_handle_event(), __analog_ss_thread(), __ast_read(), __dahdi_exception(), __oh323_update_info(), agent_call(), alsa_answer(), analog_answer(), analog_call(), analog_exception(), analog_ss_thread(), ast_raw_answer(), cb_events(), check_availability(), console_answer(), dahdi_answer(), dahdi_call(), dahdi_handle_event(), dahdi_indicate(), dahdi_read(), do_bridge_masquerade(), gtalk_call(), gtalk_newcall(), handle_invite_replaces(), handle_offhook_message(), handle_request_invite(), handle_response_invite(), handle_soft_key_event_message(), handle_stimulus_message(), iax2_call(), jingle_call(), jingle_newcall(), local_queue_frame(), mgcp_answer(), mgcp_call(), mgcp_ss(), misdn_call(), misdn_indication(), my_set_waitingfordt(), nbs_call(), nbs_hangup(), oh323_answer(), oss_answer(), pbx_builtin_busy(), pbx_builtin_congestion(), phone_answer(), phone_call(), phone_exception(), phone_hangup(), phone_write(), pri_ss_thread(), release_chan(), release_chan_early(), sig_pri_answer(), sig_pri_call(), sig_pri_indicate(), sig_ss7_call(), sig_ss7_indicate(), sip_answer(), skinny_answer(), skinny_call(), skinny_newcall(), unistim_answer(), unistim_call(), unistim_new(), unistim_ss(), update_state(), usbradio_answer(), and usbradio_call().
06372 { 06373 int oldstate = chan->_state; 06374 char name[AST_CHANNEL_NAME], *dashptr; 06375 06376 if (oldstate == state) 06377 return 0; 06378 06379 ast_copy_string(name, chan->name, sizeof(name)); 06380 if ((dashptr = strrchr(name, '-'))) { 06381 *dashptr = '\0'; 06382 } 06383 06384 chan->_state = state; 06385 06386 /* We have to pass AST_DEVICE_UNKNOWN here because it is entirely possible that the channel driver 06387 * for this channel is using the callback method for device state. If we pass in an actual state here 06388 * we override what they are saying the state is and things go amuck. */ 06389 ast_devstate_changed_literal(AST_DEVICE_UNKNOWN, name); 06390 06391 /* setstate used to conditionally report Newchannel; this is no more */ 06392 ast_manager_event(chan, EVENT_FLAG_CALL, "Newstate", 06393 "Channel: %s\r\n" 06394 "ChannelState: %d\r\n" 06395 "ChannelStateDesc: %s\r\n" 06396 "CallerIDNum: %s\r\n" 06397 "CallerIDName: %s\r\n" 06398 "Uniqueid: %s\r\n", 06399 chan->name, chan->_state, ast_state2str(chan->_state), 06400 S_COR(chan->caller.id.number.valid, chan->caller.id.number.str, ""), 06401 S_COR(chan->caller.id.name.valid, chan->caller.id.name.str, ""), 06402 chan->uniqueid); 06403 06404 return 0; 06405 }
| int ast_settimeout | ( | struct ast_channel * | c, | |
| unsigned int | rate, | |||
| int(*)(const void *data) | func, | |||
| void * | data | |||
| ) |
Enable or disable timer ticks for a channel.
| c | channel | |
| rate | number of timer ticks per second | |
| func | callback function | |
| data |
Definition at line 3353 of file channel.c.
References ast_channel_lock, ast_channel_unlock, ast_debug, ast_timer_get_max_rate(), ast_timer_set_rate(), ast_channel::timer, ast_channel::timingdata, ast_channel::timingfd, and ast_channel::timingfunc.
Referenced by ast_activate_generator(), ast_closestream(), ast_deactivate_generator(), ast_read_generator_actions(), ast_readaudio_callback(), and filestream_destructor().
03354 { 03355 int res; 03356 unsigned int real_rate = rate, max_rate; 03357 03358 ast_channel_lock(c); 03359 03360 if (c->timingfd == -1) { 03361 ast_channel_unlock(c); 03362 return -1; 03363 } 03364 03365 if (!func) { 03366 rate = 0; 03367 data = NULL; 03368 } 03369 03370 if (rate && rate > (max_rate = ast_timer_get_max_rate(c->timer))) { 03371 real_rate = max_rate; 03372 } 03373 03374 ast_debug(1, "Scheduling timer at (%u requested / %u actual) timer ticks per second\n", rate, real_rate); 03375 03376 res = ast_timer_set_rate(c->timer, real_rate); 03377 03378 c->timingfunc = func; 03379 c->timingdata = data; 03380 03381 ast_channel_unlock(c); 03382 03383 return res; 03384 }
| int ast_shutting_down | ( | void | ) |
Returns non-zero if Asterisk is being shut down.
Definition at line 795 of file channel.c.
Referenced by handle_request_options().
00796 { 00797 return shutting_down; 00798 }
| int ast_softhangup | ( | struct ast_channel * | chan, | |
| int | cause | |||
| ) |
Softly hangup a channel, lock.
Softly hangup up a channel.
Definition at line 2587 of file channel.c.
References ast_channel_lock, ast_channel_unlock, and ast_softhangup_nolock().
Referenced by __analog_handle_event(), __ast_module_user_hangup_all(), __ast_pbx_run(), __unload_module(), agent_hangup(), agent_logoff(), agent_read(), ast_channel_softhangup_cb(), ast_dial_join(), birdbath(), cc_generic_agent_stop_ringing(), conf_free(), connect_link(), dahdi_handle_event(), flush_telem(), function_ilink(), handle_hangup(), handle_link_data(), handle_softhangup(), login_exec(), manager_park(), mgcp_pktcgate_remove(), read_agent_config(), rpt(), rpt_call(), rpt_do_restart(), rpt_exec(), sla_handle_hold_event(), softhangup_exec(), start_spying(), startmon(), and unload_module().
02588 { 02589 int res; 02590 02591 ast_channel_lock(chan); 02592 res = ast_softhangup_nolock(chan, cause); 02593 ast_channel_unlock(chan); 02594 02595 return res; 02596 }
| int ast_softhangup_nolock | ( | struct ast_channel * | chan, | |
| int | cause | |||
| ) |
Softly hangup a channel, don't lock.
Softly hangup up a channel (no channel lock).
Definition at line 2574 of file channel.c.
References ast_channel::_softhangup, ast_debug, AST_FLAG_BLOCKING, ast_null_frame, ast_queue_frame(), ast_test_flag, ast_channel::blocker, and ast_channel::name.
Referenced by __analog_handle_event(), action_hangup(), ast_async_goto(), ast_softhangup(), attempt_transfer(), check_pendings(), check_rtp_timeout(), dahdi_softhangup_all(), oh323_indicate(), pri_dchannel(), proc_session_timer(), sig_pri_indicate(), sip_indicate(), and skinny_indicate().
02575 { 02576 ast_debug(1, "Soft-Hanging up channel '%s'\n", chan->name); 02577 /* Inform channel driver that we need to be hung up, if it cares */ 02578 chan->_softhangup |= cause; 02579 ast_queue_frame(chan, &ast_null_frame); 02580 /* Interrupt any poll call or such */ 02581 if (ast_test_flag(chan, AST_FLAG_BLOCKING)) 02582 pthread_kill(chan->blocker, SIGURG); 02583 return 0; 02584 }
| const char* ast_state2str | ( | enum ast_channel_state | state | ) |
Gives the string form of a given channel state.
Definition at line 937 of file channel.c.
References AST_STATE_BUSY, AST_STATE_DIALING, AST_STATE_DIALING_OFFHOOK, AST_STATE_DOWN, AST_STATE_OFFHOOK, AST_STATE_PRERING, AST_STATE_RESERVED, AST_STATE_RING, AST_STATE_RINGING, AST_STATE_UP, ast_threadstorage_get(), STATE2STR_BUFSIZE, and state2str_threadbuf.
Referenced by __ast_channel_alloc_ap(), action_coreshowchannels(), action_status(), agent_hangup(), ast_channel_data_add_structure(), ast_do_masquerade(), ast_setstate(), attempt_transfer(), func_channel_read(), handle_chanlist(), handle_showchan(), local_attended_transfer(), mgcp_new(), serialize_showchan(), sip_hangup(), and update_connectedline().
00938 { 00939 char *buf; 00940 00941 switch (state) { 00942 case AST_STATE_DOWN: 00943 return "Down"; 00944 case AST_STATE_RESERVED: 00945 return "Rsrvd"; 00946 case AST_STATE_OFFHOOK: 00947 return "OffHook"; 00948 case AST_STATE_DIALING: 00949 return "Dialing"; 00950 case AST_STATE_RING: 00951 return "Ring"; 00952 case AST_STATE_RINGING: 00953 return "Ringing"; 00954 case AST_STATE_UP: 00955 return "Up"; 00956 case AST_STATE_BUSY: 00957 return "Busy"; 00958 case AST_STATE_DIALING_OFFHOOK: 00959 return "Dialing Offhook"; 00960 case AST_STATE_PRERING: 00961 return "Pre-ring"; 00962 default: 00963 if (!(buf = ast_threadstorage_get(&state2str_threadbuf, STATE2STR_BUFSIZE))) 00964 return "Unknown"; 00965 snprintf(buf, STATE2STR_BUFSIZE, "Unknown (%d)", state); 00966 return buf; 00967 } 00968 }
| int ast_str2cause | ( | const char * | name | ) |
Convert a symbolic hangup cause to number.
Convert the string form of a cause code to a number.
Definition at line 923 of file channel.c.
References ARRAY_LEN, cause, and causes.
Referenced by pbx_builtin_hangup().
00924 { 00925 int x; 00926 00927 for (x = 0; x < ARRAY_LEN(causes); x++) 00928 if (!strncasecmp(causes[x].name, name, strlen(causes[x].name))) 00929 return causes[x].cause; 00930 00931 return -1; 00932 }
| int ast_tonepair | ( | struct ast_channel * | chan, | |
| int | freq1, | |||
| int | freq2, | |||
| int | duration, | |||
| int | vol | |||
| ) |
Play a tone pair for a given amount of time
Definition at line 7179 of file channel.c.
References ast_frfree, ast_read(), ast_tonepair_start(), ast_waitfor(), and ast_channel::generatordata.
Referenced by zapateller_exec().
07180 { 07181 int res; 07182 07183 if ((res = ast_tonepair_start(chan, freq1, freq2, duration, vol))) 07184 return res; 07185 07186 /* Give us some wiggle room */ 07187 while (chan->generatordata && ast_waitfor(chan, 100) >= 0) { 07188 struct ast_frame *f = ast_read(chan); 07189 if (f) 07190 ast_frfree(f); 07191 else 07192 return -1; 07193 } 07194 return 0; 07195 }
| int ast_tonepair_start | ( | struct ast_channel * | chan, | |
| int | freq1, | |||
| int | freq2, | |||
| int | duration, | |||
| int | vol | |||
| ) |
Start a tone going
Definition at line 7161 of file channel.c.
References ast_activate_generator(), tonepair_def::duration, tonepair_def::freq1, tonepair_def::freq2, and tonepair_def::vol.
Referenced by ast_tonepair(), pbx_builtin_waitexten(), play_dialtone(), play_tone_pair(), rpt_tele_thread(), and sendnoise().
07162 { 07163 struct tonepair_def d = { 0, }; 07164 07165 d.freq1 = freq1; 07166 d.freq2 = freq2; 07167 d.duration = duration; 07168 d.vol = (vol < 1) ? 8192 : vol; /* force invalid to 8192 */ 07169 if (ast_activate_generator(chan, &tonepair, &d)) 07170 return -1; 07171 return 0; 07172 }
| void ast_tonepair_stop | ( | struct ast_channel * | chan | ) |
Stop a tone from playing
Definition at line 7174 of file channel.c.
References ast_deactivate_generator().
Referenced by sendnoise().
07175 { 07176 ast_deactivate_generator(chan); 07177 }
| int ast_transfer | ( | struct ast_channel * | chan, | |
| char * | dest | |||
| ) |
Transfer a call to dest, if the channel supports transfer.
Transfer a channel (if supported).
Called by:
Definition at line 5387 of file channel.c.
References ast_channel_lock, ast_channel_unlock, ast_check_hangup(), AST_CONTROL_TRANSFER, AST_FLAG_ZOMBIE, AST_FRAME_CONTROL, ast_frfree, ast_read(), ast_test_flag, AST_TRANSFER_SUCCESS, ast_waitfor(), ast_frame::data, ast_frame::frametype, ast_frame_subclass::integer, ast_frame::ptr, ast_frame::subclass, ast_channel::tech, and ast_channel_tech::transfer.
Referenced by transfer_exec().
05388 { 05389 int res = -1; 05390 05391 /* Stop if we're a zombie or need a soft hangup */ 05392 ast_channel_lock(chan); 05393 if (!ast_test_flag(chan, AST_FLAG_ZOMBIE) && !ast_check_hangup(chan)) { 05394 if (chan->tech->transfer) { 05395 res = chan->tech->transfer(chan, dest); 05396 if (!res) 05397 res = 1; 05398 } else 05399 res = 0; 05400 } 05401 ast_channel_unlock(chan); 05402 05403 if (res <= 0) { 05404 return res; 05405 } 05406 05407 for (;;) { 05408 struct ast_frame *fr; 05409 05410 res = ast_waitfor(chan, -1); 05411 05412 if (res < 0 || !(fr = ast_read(chan))) { 05413 res = -1; 05414 break; 05415 } 05416 05417 if (fr->frametype == AST_FRAME_CONTROL && fr->subclass.integer == AST_CONTROL_TRANSFER) { 05418 enum ast_control_transfer *message = fr->data.ptr; 05419 05420 if (*message == AST_TRANSFER_SUCCESS) { 05421 res = 1; 05422 } else { 05423 res = -1; 05424 } 05425 05426 ast_frfree(fr); 05427 break; 05428 } 05429 05430 ast_frfree(fr); 05431 } 05432 05433 return res; 05434 }
| char* ast_transfercapability2str | ( | int | transfercapability | ) | const |
Gives the string form of a given transfer capability.
| transfercapability | transfer capability to get the name of |
Definition at line 971 of file channel.c.
References AST_TRANS_CAP_3_1K_AUDIO, AST_TRANS_CAP_DIGITAL, AST_TRANS_CAP_DIGITAL_W_TONES, AST_TRANS_CAP_RESTRICTED_DIGITAL, AST_TRANS_CAP_SPEECH, and AST_TRANS_CAP_VIDEO.
Referenced by ast_channel_data_add_structure(), cb_events(), misdn_call(), oh323_call(), sig_pri_call(), sig_pri_new_ast_channel(), and sig_ss7_new_ast_channel().
00972 { 00973 switch (transfercapability) { 00974 case AST_TRANS_CAP_SPEECH: 00975 return "SPEECH"; 00976 case AST_TRANS_CAP_DIGITAL: 00977 return "DIGITAL"; 00978 case AST_TRANS_CAP_RESTRICTED_DIGITAL: 00979 return "RESTRICTED_DIGITAL"; 00980 case AST_TRANS_CAP_3_1K_AUDIO: 00981 return "3K1AUDIO"; 00982 case AST_TRANS_CAP_DIGITAL_W_TONES: 00983 return "DIGITAL_W_TONES"; 00984 case AST_TRANS_CAP_VIDEO: 00985 return "VIDEO"; 00986 default: 00987 return "UNKNOWN"; 00988 } 00989 }
| void ast_uninstall_music_functions | ( | void | ) |
Definition at line 7242 of file channel.c.
References ast_moh_cleanup_ptr, ast_moh_start_ptr, and ast_moh_stop_ptr.
Referenced by unload_module().
07243 { 07244 ast_moh_start_ptr = NULL; 07245 ast_moh_stop_ptr = NULL; 07246 ast_moh_cleanup_ptr = NULL; 07247 }
| int ast_waitfor | ( | struct ast_channel * | chan, | |
| int | ms | |||
| ) |
Wait for input on a channel.
| chan | channel to wait on | |
| ms | length of time to wait on the channel |
| < | 0 on failure | |
| 0 | if nothing ever arrived | |
| the | # of ms remaining otherwise |
Definition at line 3337 of file channel.c.
References ast_waitfor_nandfds().
Referenced by __adsi_transmit_messages(), __analog_ss_thread(), __ast_answer(), __ast_play_and_record(), __ast_request_and_dial(), adsi_careful_send(), agent_ack_sleep(), analog_ss_thread(), ast_dtmf_stream(), ast_recvtext(), ast_safe_sleep_conditional(), ast_tonepair(), ast_transfer(), async_wait(), background_detect_exec(), channel_spy(), conf_flush(), dahdi_accept_r2_call_exec(), dictate_exec(), disa_exec(), disable_t38(), do_idle_thread(), do_waiting(), echo_exec(), handle_recordfile(), handle_speechrecognize(), ices_exec(), isAnsweringMachine(), jack_exec(), launch_asyncagi(), measurenoise(), mp3_exec(), NBScat_exec(), receive_dtmf_digits(), receivefax_t38_init(), record_exec(), recordthread(), send_tone_burst(), send_waveform_to_channel(), sendfax_t38_init(), sendurl_exec(), speech_background(), transmit_audio(), transmit_t38(), wait_for_hangup(), waitforring_exec(), and waitstream_core().
03338 { 03339 int oldms = ms; /* -1 if no timeout */ 03340 03341 ast_waitfor_nandfds(&c, 1, NULL, 0, NULL, NULL, &ms); 03342 if ((ms < 0) && (oldms < 0)) 03343 ms = 0; 03344 return ms; 03345 }
| struct ast_channel* ast_waitfor_n | ( | struct ast_channel ** | chan, | |
| int | n, | |||
| int * | ms | |||
| ) | [read] |
Waits for input on a group of channels Wait for input on an array of channels for a given # of milliseconds.
| chan | an array of pointers to channels | |
| n | number of channels that are to be waited upon | |
| ms | time "ms" is modified in-place, if applicable |
Definition at line 3332 of file channel.c.
References ast_waitfor_nandfds().
Referenced by ast_generic_bridge(), ast_udptl_bridge(), autoservice_run(), dahdi_bridge(), dial_exec_full(), feature_request_and_dial(), generic_thread_loop(), iax2_bridge(), local_bridge_loop(), misdn_bridge(), monitor_dial(), remote_bridge_loop(), rpt(), rpt_exec(), wait_for_answer(), and wait_for_winner().
03333 { 03334 return ast_waitfor_nandfds(c, n, NULL, 0, NULL, NULL, ms); 03335 }
| int ast_waitfor_n_fd | ( | int * | fds, | |
| int | n, | |||
| int * | ms, | |||
| int * | exception | |||
| ) |
Wait for x amount of time on a file descriptor to have input.
Waits for input on an fd.
Definition at line 2973 of file channel.c.
References ast_waitfor_nandfds().
Referenced by dundi_lookup_internal(), dundi_precache_internal(), and softmix_bridge_thread().
02974 { 02975 int winner = -1; 02976 ast_waitfor_nandfds(NULL, 0, fds, n, exception, &winner, ms); 02977 return winner; 02978 }
| struct ast_channel* ast_waitfor_nandfds | ( | struct ast_channel ** | c, | |
| int | n, | |||
| int * | fds, | |||
| int | nfds, | |||
| int * | exception, | |||
| int * | outfd, | |||
| int * | ms | |||
| ) | [read] |
Wait for x amount of time on a file descriptor to have input.
Waits for activity on a group of channels.
Definition at line 2985 of file channel.c.
References ast_channel::_softhangup, ast_add_fd(), ast_channel_lock, ast_channel_unlock, ast_clear_flag, ast_do_masquerade(), AST_FLAG_BLOCKING, AST_FLAG_EXCEPTION, ast_log(), AST_MAX_FDS, ast_poll, ast_set_flag, AST_SOFTHANGUP_TIMEOUT, ast_tvcmp(), ast_tvdiff_ms(), ast_tvnow(), ast_tvsub(), ast_tvzero(), CHECK_BLOCKING, errno, ast_channel::fdno, and LOG_WARNING.
Referenced by ast_waitfor(), ast_waitfor_n(), ast_waitfor_n_fd(), ast_waitfordigit_full(), bridge_channel_join_multithreaded(), conf_run(), eivr_comm(), find_cache(), generic_fax_exec(), multiplexed_thread_function(), run_agi(), and waitstream_core().
02988 { 02989 struct timeval start = { 0 , 0 }; 02990 struct pollfd *pfds = NULL; 02991 int res; 02992 long rms; 02993 int x, y, max; 02994 int sz; 02995 struct timeval now = { 0, 0 }; 02996 struct timeval whentohangup = { 0, 0 }, diff; 02997 struct ast_channel *winner = NULL; 02998 struct fdmap { 02999 int chan; 03000 int fdno; 03001 } *fdmap = NULL; 03002 03003 if ((sz = n * AST_MAX_FDS + nfds)) { 03004 pfds = alloca(sizeof(*pfds) * sz); 03005 fdmap = alloca(sizeof(*fdmap) * sz); 03006 } 03007 03008 if (outfd) 03009 *outfd = -99999; 03010 if (exception) 03011 *exception = 0; 03012 03013 /* Perform any pending masquerades */ 03014 for (x = 0; x < n; x++) { 03015 if (c[x]->masq && ast_do_masquerade(c[x])) { 03016 ast_log(LOG_WARNING, "Masquerade failed\n"); 03017 *ms = -1; 03018 return NULL; 03019 } 03020 03021 ast_channel_lock(c[x]); 03022 if (!ast_tvzero(c[x]->whentohangup)) { 03023 if (ast_tvzero(whentohangup)) 03024 now = ast_tvnow(); 03025 diff = ast_tvsub(c[x]->whentohangup, now); 03026 if (diff.tv_sec < 0 || ast_tvzero(diff)) { 03027 /* Should already be hungup */ 03028 c[x]->_softhangup |= AST_SOFTHANGUP_TIMEOUT; 03029 ast_channel_unlock(c[x]); 03030 return c[x]; 03031 } 03032 if (ast_tvzero(whentohangup) || ast_tvcmp(diff, whentohangup) < 0) 03033 whentohangup = diff; 03034 } 03035 ast_channel_unlock(c[x]); 03036 } 03037 /* Wait full interval */ 03038 rms = *ms; 03039 /* INT_MAX, not LONG_MAX, because it matters on 64-bit */ 03040 if (!ast_tvzero(whentohangup) && whentohangup.tv_sec < INT_MAX / 1000) { 03041 rms = whentohangup.tv_sec * 1000 + whentohangup.tv_usec / 1000; /* timeout in milliseconds */ 03042 if (*ms >= 0 && *ms < rms) { /* original *ms still smaller */ 03043 rms = *ms; 03044 } 03045 } else if (!ast_tvzero(whentohangup) && rms < 0) { 03046 /* Tiny corner case... call would need to last >24 days */ 03047 rms = INT_MAX; 03048 } 03049 /* 03050 * Build the pollfd array, putting the channels' fds first, 03051 * followed by individual fds. Order is important because 03052 * individual fd's must have priority over channel fds. 03053 */ 03054 max = 0; 03055 for (x = 0; x < n; x++) { 03056 for (y = 0; y < AST_MAX_FDS; y++) { 03057 fdmap[max].fdno = y; /* fd y is linked to this pfds */ 03058 fdmap[max].chan = x; /* channel x is linked to this pfds */ 03059 max += ast_add_fd(&pfds[max], c[x]->fds[y]); 03060 } 03061 CHECK_BLOCKING(c[x]); 03062 } 03063 /* Add the individual fds */ 03064 for (x = 0; x < nfds; x++) { 03065 fdmap[max].chan = -1; 03066 max += ast_add_fd(&pfds[max], fds[x]); 03067 } 03068 03069 if (*ms > 0) 03070 start = ast_tvnow(); 03071 03072 if (sizeof(int) == 4) { /* XXX fix timeout > 600000 on linux x86-32 */ 03073 do { 03074 int kbrms = rms; 03075 if (kbrms > 600000) 03076 kbrms = 600000; 03077 res = ast_poll(pfds, max, kbrms); 03078 if (!res) 03079 rms -= kbrms; 03080 } while (!res && (rms > 0)); 03081 } else { 03082 res = ast_poll(pfds, max, rms); 03083 } 03084 for (x = 0; x < n; x++) 03085 ast_clear_flag(c[x], AST_FLAG_BLOCKING); 03086 if (res < 0) { /* Simulate a timeout if we were interrupted */ 03087 if (errno != EINTR) 03088 *ms = -1; 03089 return NULL; 03090 } 03091 if (!ast_tvzero(whentohangup)) { /* if we have a timeout, check who expired */ 03092 now = ast_tvnow(); 03093 for (x = 0; x < n; x++) { 03094 if (!ast_tvzero(c[x]->whentohangup) && ast_tvcmp(c[x]->whentohangup, now) <= 0) { 03095 c[x]->_softhangup |= AST_SOFTHANGUP_TIMEOUT; 03096 if (winner == NULL) 03097 winner = c[x]; 03098 } 03099 } 03100 } 03101 if (res == 0) { /* no fd ready, reset timeout and done */ 03102 *ms = 0; /* XXX use 0 since we may not have an exact timeout. */ 03103 return winner; 03104 } 03105 /* 03106 * Then check if any channel or fd has a pending event. 03107 * Remember to check channels first and fds last, as they 03108 * must have priority on setting 'winner' 03109 */ 03110 for (x = 0; x < max; x++) { 03111 res = pfds[x].revents; 03112 if (res == 0) 03113 continue; 03114 if (fdmap[x].chan >= 0) { /* this is a channel */ 03115 winner = c[fdmap[x].chan]; /* override previous winners */ 03116 if (res & POLLPRI) 03117 ast_set_flag(winner, AST_FLAG_EXCEPTION); 03118 else 03119 ast_clear_flag(winner, AST_FLAG_EXCEPTION); 03120 winner->fdno = fdmap[x].fdno; 03121 } else { /* this is an fd */ 03122 if (outfd) 03123 *outfd = pfds[x].fd; 03124 if (exception) 03125 *exception = (res & POLLPRI) ? -1 : 0; 03126 winner = NULL; 03127 } 03128 } 03129 if (*ms > 0) { 03130 *ms -= ast_tvdiff_ms(ast_tvnow(), start); 03131 if (*ms < 0) 03132 *ms = 0; 03133 } 03134 return winner; 03135 }
| int ast_waitfordigit | ( | struct ast_channel * | c, | |
| int | ms | |||
| ) |
Waits for a digit.
| c | channel to wait for a digit on | |
| ms | how many milliseconds to wait |
Definition at line 3348 of file channel.c.
References ast_waitfordigit_full().
Referenced by __analog_ss_thread(), _while_exec(), advanced_options(), analog_my_getsigstr(), analog_ss_thread(), ast_adsi_get_cpeid(), ast_adsi_get_cpeinfo(), ast_adsi_print(), ast_adsi_read_encoded_dtmf(), ast_adsi_transmit_message_full(), ast_app_dtget(), ast_control_streamfile(), ast_record_review(), bridge_channel_feature(), builtin_atxfer(), collect_digits(), common_exec(), cpeid_exec(), dialout(), directory_exec(), forward_message(), get_folder(), ivr_dispatch(), mgcp_ss(), my_getsigstr(), pbx_builtin_waitexten(), play_record_review(), pri_ss_thread(), read_exec(), read_newoption(), readexten_exec(), retrydial_exec(), select_item_menu(), select_item_pause(), select_item_seq(), sendnoise(), testclient_exec(), testserver_exec(), vm_execmain(), vm_forwardoptions(), vm_instructions_en(), vm_options(), vm_tempgreeting(), wait_a_bit(), and wait_our_turn().
03349 { 03350 return ast_waitfordigit_full(c, ms, -1, -1); 03351 }
| int ast_waitfordigit_full | ( | struct ast_channel * | c, | |
| int | ms, | |||
| int | audiofd, | |||
| int | ctrlfd | |||
| ) |
Wait for a digit Same as ast_waitfordigit() with audio fd for outputting read audio and ctrlfd to monitor for reading.
| c | channel to wait for a digit on | |
| ms | how many milliseconds to wait | |
| audiofd | audio file descriptor to write to if audio frames are received | |
| ctrlfd | control file descriptor to monitor for reading |
Definition at line 3386 of file channel.c.
References ast_check_hangup(), ast_clear_flag, AST_CONTROL_ANSWER, AST_CONTROL_CONNECTED_LINE, AST_CONTROL_HANGUP, AST_CONTROL_REDIRECTING, AST_CONTROL_RINGING, AST_CONTROL_SRCCHANGE, AST_CONTROL_SRCUPDATE, AST_FLAG_END_DTMF_ONLY, AST_FLAG_ZOMBIE, AST_FRAME_CONTROL, AST_FRAME_DTMF_BEGIN, AST_FRAME_DTMF_END, AST_FRAME_VOICE, ast_frfree, ast_log(), ast_read(), ast_set_flag, ast_test_flag, ast_waitfor_nandfds(), ast_frame::data, ast_frame::datalen, errno, ast_frame::frametype, ast_frame_subclass::integer, LOG_WARNING, ast_frame::ptr, and ast_frame::subclass.
Referenced by ast_readstring_full(), ast_waitfordigit(), handle_getoption(), and handle_waitfordigit().
03387 { 03388 /* Stop if we're a zombie or need a soft hangup */ 03389 if (ast_test_flag(c, AST_FLAG_ZOMBIE) || ast_check_hangup(c)) 03390 return -1; 03391 03392 /* Only look for the end of DTMF, don't bother with the beginning and don't emulate things */ 03393 ast_set_flag(c, AST_FLAG_END_DTMF_ONLY); 03394 03395 /* Wait for a digit, no more than ms milliseconds total. */ 03396 03397 while (ms) { 03398 struct ast_channel *rchan; 03399 int outfd=-1; 03400 03401 errno = 0; 03402 rchan = ast_waitfor_nandfds(&c, 1, &cmdfd, (cmdfd > -1) ? 1 : 0, NULL, &outfd, &ms); 03403 03404 if (!rchan && outfd < 0 && ms) { 03405 if (errno == 0 || errno == EINTR) 03406 continue; 03407 ast_log(LOG_WARNING, "Wait failed (%s)\n", strerror(errno)); 03408 ast_clear_flag(c, AST_FLAG_END_DTMF_ONLY); 03409 return -1; 03410 } else if (outfd > -1) { 03411 /* The FD we were watching has something waiting */ 03412 ast_log(LOG_WARNING, "The FD we were waiting for has something waiting. Waitfordigit returning numeric 1\n"); 03413 ast_clear_flag(c, AST_FLAG_END_DTMF_ONLY); 03414 return 1; 03415 } else if (rchan) { 03416 int res; 03417 struct ast_frame *f = ast_read(c); 03418 if (!f) 03419 return -1; 03420 03421 switch (f->frametype) { 03422 case AST_FRAME_DTMF_BEGIN: 03423 break; 03424 case AST_FRAME_DTMF_END: 03425 res = f->subclass.integer; 03426 ast_frfree(f); 03427 ast_clear_flag(c, AST_FLAG_END_DTMF_ONLY); 03428 return res; 03429 case AST_FRAME_CONTROL: 03430 switch (f->subclass.integer) { 03431 case AST_CONTROL_HANGUP: 03432 ast_frfree(f); 03433 ast_clear_flag(c, AST_FLAG_END_DTMF_ONLY); 03434 return -1; 03435 case AST_CONTROL_RINGING: 03436 case AST_CONTROL_ANSWER: 03437 case AST_CONTROL_SRCUPDATE: 03438 case AST_CONTROL_SRCCHANGE: 03439 case AST_CONTROL_CONNECTED_LINE: 03440 case AST_CONTROL_REDIRECTING: 03441 case -1: 03442 /* Unimportant */ 03443 break; 03444 default: 03445 ast_log(LOG_WARNING, "Unexpected control subclass '%d'\n", f->subclass.integer); 03446 break; 03447 } 03448 break; 03449 case AST_FRAME_VOICE: 03450 /* Write audio if appropriate */ 03451 if (audiofd > -1) { 03452 if (write(audiofd, f->data.ptr, f->datalen) < 0) { 03453 ast_log(LOG_WARNING, "write() failed: %s\n", strerror(errno)); 03454 } 03455 } 03456 default: 03457 /* Ignore */ 03458 break; 03459 } 03460 ast_frfree(f); 03461 } 03462 } 03463 03464 ast_clear_flag(c, AST_FLAG_END_DTMF_ONLY); 03465 03466 return 0; /* Time is up */ 03467 }
| int ast_write | ( | struct ast_channel * | chan, | |
| struct ast_frame * | frame | |||
| ) |
Write a frame to a channel This function writes the given frame to the indicated channel.
| chan | destination channel of the frame | |
| frame | frame that will be written |
Definition at line 4605 of file channel.c.
References ast_channel::_softhangup, apply_plc(), ast_audiohook_detach_list(), AST_AUDIOHOOK_DIRECTION_WRITE, ast_audiohook_write_list(), ast_audiohook_write_list_empty(), ast_channel_lock, ast_channel_trylock, ast_channel_unlock, ast_check_hangup(), ast_clear_flag, AST_CONTROL_UNHOLD, ast_deactivate_generator(), ast_debug, ast_do_masquerade(), AST_FLAG_BLOCKING, AST_FLAG_WRITE_INT, AST_FLAG_ZOMBIE, ast_format_rate(), AST_FORMAT_SLINEAR, AST_FORMAT_T140, AST_FRAME_CONTROL, AST_FRAME_DTMF_BEGIN, AST_FRAME_DTMF_END, ast_frame_dump(), AST_FRAME_HTML, AST_FRAME_IAX, AST_FRAME_MODEM, AST_FRAME_NULL, AST_FRAME_TEXT, AST_FRAME_VIDEO, AST_FRAME_VOICE, ast_framehook_list_write_event(), ast_frfree, ast_frisolate(), AST_LIST_NEXT, ast_log(), AST_MONITOR_RUNNING, ast_opt_generic_plc, ast_seekstream(), ast_senddigit_begin(), ast_senddigit_end(), AST_SOFTHANGUP_DEV, ast_test_flag, ast_translate(), ast_writestream(), ast_channel::audiohooks, calc_monitor_jump(), CHECK_BLOCKING, ast_frame_subclass::codec, ast_frame::data, ast_frame::datalen, DEBUGCHAN_FLAG, ast_filestream::fmt, ast_format::format, ast_channel::fout, FRAMECOUNT_INC, ast_channel::framehooks, ast_frame::frametype, ast_channel::generatordata, ast_channel_tech::indicate, ast_channel::insmpl, ast_frame_subclass::integer, ast_frame::len, LOG_WARNING, ast_channel::masq, ast_channel::masqr, ast_channel::monitor, ast_channel::name, chanlist::next, ast_channel::outsmpl, ast_frame::ptr, ast_channel::rawwriteformat, ast_channel_monitor::read_stream, ast_frame::samples, SEEK_FORCECUR, send_dtmf_event(), ast_channel_tech::send_html, ast_channel_tech::send_text, ast_frame::src, ast_channel_monitor::state, ast_frame::subclass, ast_channel::tech, ast_channel_tech::write, ast_channel_monitor::write_stream, ast_channel_tech::write_text, ast_channel_tech::write_video, and ast_channel::writetrans.
Referenced by adsi_careful_send(), agent_write(), ast_generic_bridge(), ast_prod(), ast_readaudio_callback(), ast_readvideo_callback(), ast_udptl_bridge(), ast_write_video(), conf_queue_dtmf(), conf_run(), dahdi_bridge(), dictate_exec(), echo_exec(), fax_generator_generate(), feature_request_and_dial(), function_ilink(), gen_generate(), generic_fax_exec(), handle_jack_audio(), handle_link_data(), iax2_bridge(), jb_get_and_deliver(), linear_generator(), local_bridge_loop(), milliwatt_generate(), misdn_bridge(), moh_files_generator(), moh_generate(), mp3_exec(), multiplexed_bridge_write(), NBScat_exec(), playtones_generator(), remote_bridge_loop(), rpt(), rpt_exec(), send_link_dtmf(), send_link_keyquery(), send_tone_burst(), send_usb_txt(), send_waveform_to_channel(), silence_generator_generate(), simple_bridge_write(), sms_generate(), softmix_bridge_poke(), softmix_bridge_write(), spy_generate(), t38_tx_packet_handler(), tonepair_generator(), and wait_for_answer().
04606 { 04607 int res = -1; 04608 struct ast_frame *f = NULL; 04609 int count = 0; 04610 04611 /*Deadlock avoidance*/ 04612 while(ast_channel_trylock(chan)) { 04613 /*cannot goto done since the channel is not locked*/ 04614 if(count++ > 10) { 04615 ast_debug(1, "Deadlock avoided for write to channel '%s'\n", chan->name); 04616 return 0; 04617 } 04618 usleep(1); 04619 } 04620 /* Stop if we're a zombie or need a soft hangup */ 04621 if (ast_test_flag(chan, AST_FLAG_ZOMBIE) || ast_check_hangup(chan)) 04622 goto done; 04623 04624 /* Handle any pending masquerades */ 04625 if (chan->masq) { 04626 ast_channel_unlock(chan); 04627 if (ast_do_masquerade(chan)) { 04628 ast_log(LOG_WARNING, "Failed to perform masquerade\n"); 04629 return res; /* no need to goto done: chan is already unlocked for masq */ 04630 } 04631 ast_channel_lock(chan); 04632 } 04633 if (chan->masqr) { 04634 res = 0; /* XXX explain, why 0 ? */ 04635 goto done; 04636 } 04637 04638 /* Perform the framehook write event here. After the frame enters the framehook list 04639 * there is no telling what will happen, how awesome is that!!! */ 04640 if (!(fr = ast_framehook_list_write_event(chan->framehooks, fr))) { 04641 res = 0; 04642 goto done; 04643 } 04644 04645 if (chan->generatordata && (!fr->src || strcasecmp(fr->src, "ast_prod"))) { 04646 if (ast_test_flag(chan, AST_FLAG_WRITE_INT)) { 04647 ast_deactivate_generator(chan); 04648 } else { 04649 if (fr->frametype == AST_FRAME_DTMF_END) { 04650 /* There is a generator running while we're in the middle of a digit. 04651 * It's probably inband DTMF, so go ahead and pass it so it can 04652 * stop the generator */ 04653 ast_clear_flag(chan, AST_FLAG_BLOCKING); 04654 ast_channel_unlock(chan); 04655 res = ast_senddigit_end(chan, fr->subclass.integer, fr->len); 04656 ast_channel_lock(chan); 04657 CHECK_BLOCKING(chan); 04658 } else if (fr->frametype == AST_FRAME_CONTROL && fr->subclass.integer == AST_CONTROL_UNHOLD) { 04659 /* This is a side case where Echo is basically being called and the person put themselves on hold and took themselves off hold */ 04660 res = (chan->tech->indicate == NULL) ? 0 : 04661 chan->tech->indicate(chan, fr->subclass.integer, fr->data.ptr, fr->datalen); 04662 } 04663 res = 0; /* XXX explain, why 0 ? */ 04664 goto done; 04665 } 04666 } 04667 /* High bit prints debugging */ 04668 if (chan->fout & DEBUGCHAN_FLAG) 04669 ast_frame_dump(chan->name, fr, ">>"); 04670 CHECK_BLOCKING(chan); 04671 switch (fr->frametype) { 04672 case AST_FRAME_CONTROL: 04673 res = (chan->tech->indicate == NULL) ? 0 : 04674 chan->tech->indicate(chan, fr->subclass.integer, fr->data.ptr, fr->datalen); 04675 break; 04676 case AST_FRAME_DTMF_BEGIN: 04677 if (chan->audiohooks) { 04678 struct ast_frame *old_frame = fr; 04679 fr = ast_audiohook_write_list(chan, chan->audiohooks, AST_AUDIOHOOK_DIRECTION_WRITE, fr); 04680 if (old_frame != fr) 04681 f = fr; 04682 } 04683 send_dtmf_event(chan, "Sent", fr->subclass.integer, "Yes", "No"); 04684 ast_clear_flag(chan, AST_FLAG_BLOCKING); 04685 ast_channel_unlock(chan); 04686 res = ast_senddigit_begin(chan, fr->subclass.integer); 04687 ast_channel_lock(chan); 04688 CHECK_BLOCKING(chan); 04689 break; 04690 case AST_FRAME_DTMF_END: 04691 if (chan->audiohooks) { 04692 struct ast_frame *new_frame = fr; 04693 04694 new_frame = ast_audiohook_write_list(chan, chan->audiohooks, AST_AUDIOHOOK_DIRECTION_WRITE, fr); 04695 if (new_frame != fr) { 04696 ast_frfree(new_frame); 04697 } 04698 } 04699 send_dtmf_event(chan, "Sent", fr->subclass.integer, "No", "Yes"); 04700 ast_clear_flag(chan, AST_FLAG_BLOCKING); 04701 ast_channel_unlock(chan); 04702 res = ast_senddigit_end(chan, fr->subclass.integer, fr->len); 04703 ast_channel_lock(chan); 04704 CHECK_BLOCKING(chan); 04705 break; 04706 case AST_FRAME_TEXT: 04707 if (fr->subclass.integer == AST_FORMAT_T140) { 04708 res = (chan->tech->write_text == NULL) ? 0 : 04709 chan->tech->write_text(chan, fr); 04710 } else { 04711 res = (chan->tech->send_text == NULL) ? 0 : 04712 chan->tech->send_text(chan, (char *) fr->data.ptr); 04713 } 04714 break; 04715 case AST_FRAME_HTML: 04716 res = (chan->tech->send_html == NULL) ? 0 : 04717 chan->tech->send_html(chan, fr->subclass.integer, (char *) fr->data.ptr, fr->datalen); 04718 break; 04719 case AST_FRAME_VIDEO: 04720 /* XXX Handle translation of video codecs one day XXX */ 04721 res = (chan->tech->write_video == NULL) ? 0 : 04722 chan->tech->write_video(chan, fr); 04723 break; 04724 case AST_FRAME_MODEM: 04725 res = (chan->tech->write == NULL) ? 0 : 04726 chan->tech->write(chan, fr); 04727 break; 04728 case AST_FRAME_VOICE: 04729 if (chan->tech->write == NULL) 04730 break; /*! \todo XXX should return 0 maybe ? */ 04731 04732 if (ast_opt_generic_plc && fr->subclass.codec == AST_FORMAT_SLINEAR) { 04733 apply_plc(chan, fr); 04734 } 04735 04736 /* If the frame is in the raw write format, then it's easy... just use the frame - otherwise we will have to translate */ 04737 if (fr->subclass.codec == chan->rawwriteformat) 04738 f = fr; 04739 else 04740 f = (chan->writetrans) ? ast_translate(chan->writetrans, fr, 0) : fr; 04741 04742 if (!f) { 04743 res = 0; 04744 break; 04745 } 04746 04747 if (chan->audiohooks) { 04748 struct ast_frame *prev = NULL, *new_frame, *cur, *dup; 04749 int freeoldlist = 0; 04750 04751 if (f != fr) { 04752 freeoldlist = 1; 04753 } 04754 04755 /* Since ast_audiohook_write may return a new frame, and the cur frame is 04756 * an item in a list of frames, create a new list adding each cur frame back to it 04757 * regardless if the cur frame changes or not. */ 04758 for (cur = f; cur; cur = AST_LIST_NEXT(cur, frame_list)) { 04759 new_frame = ast_audiohook_write_list(chan, chan->audiohooks, AST_AUDIOHOOK_DIRECTION_WRITE, cur); 04760 04761 /* if this frame is different than cur, preserve the end of the list, 04762 * free the old frames, and set cur to be the new frame */ 04763 if (new_frame != cur) { 04764 04765 /* doing an ast_frisolate here seems silly, but we are not guaranteed the new_frame 04766 * isn't part of local storage, meaning if ast_audiohook_write is called multiple 04767 * times it may override the previous frame we got from it unless we dup it */ 04768 if ((dup = ast_frisolate(new_frame))) { 04769 AST_LIST_NEXT(dup, frame_list) = AST_LIST_NEXT(cur, frame_list); 04770 if (freeoldlist) { 04771 AST_LIST_NEXT(cur, frame_list) = NULL; 04772 ast_frfree(cur); 04773 } 04774 if (new_frame != dup) { 04775 ast_frfree(new_frame); 04776 } 04777 cur = dup; 04778 } 04779 } 04780 04781 /* now, regardless if cur is new or not, add it to the new list, 04782 * if the new list has not started, cur will become the first item. */ 04783 if (prev) { 04784 AST_LIST_NEXT(prev, frame_list) = cur; 04785 } else { 04786 f = cur; /* set f to be the beginning of our new list */ 04787 } 04788 prev = cur; 04789 } 04790 } 04791 04792 /* If Monitor is running on this channel, then we have to write frames out there too */ 04793 /* the translator on chan->writetrans may have returned multiple frames 04794 from the single frame we passed in; if so, feed each one of them to the 04795 monitor */ 04796 if (chan->monitor && chan->monitor->write_stream) { 04797 struct ast_frame *cur; 04798 04799 for (cur = f; cur; cur = AST_LIST_NEXT(cur, frame_list)) { 04800 /* XXX must explain this code */ 04801 #ifndef MONITOR_CONSTANT_DELAY 04802 int jump = chan->insmpl - chan->outsmpl - 4 * cur->samples; 04803 if (jump >= 0) { 04804 jump = calc_monitor_jump((chan->insmpl - chan->outsmpl), ast_format_rate(f->subclass.codec), ast_format_rate(chan->monitor->read_stream->fmt->format)); 04805 if (ast_seekstream(chan->monitor->write_stream, jump, SEEK_FORCECUR) == -1) 04806 ast_log(LOG_WARNING, "Failed to perform seek in monitoring write stream, synchronization between the files may be broken\n"); 04807 chan->outsmpl += (chan->insmpl - chan->outsmpl) + cur->samples; 04808 } else { 04809 chan->outsmpl += cur->samples; 04810 } 04811 #else 04812 int jump = calc_monitor_jump((chan->insmpl - chan->outsmpl), ast_format_rate(f->subclass.codec), ast_format_rate(chan->monitor->read_stream->fmt->format)); 04813 if (jump - MONITOR_DELAY >= 0) { 04814 if (ast_seekstream(chan->monitor->write_stream, jump - cur->samples, SEEK_FORCECUR) == -1) 04815 ast_log(LOG_WARNING, "Failed to perform seek in monitoring write stream, synchronization between the files may be broken\n"); 04816 chan->outsmpl += chan->insmpl - chan->outsmpl; 04817 } else { 04818 chan->outsmpl += cur->samples; 04819 } 04820 #endif 04821 if (chan->monitor->state == AST_MONITOR_RUNNING) { 04822 if (ast_writestream(chan->monitor->write_stream, cur) < 0) 04823 ast_log(LOG_WARNING, "Failed to write data to channel monitor write stream\n"); 04824 } 04825 } 04826 } 04827 04828 /* the translator on chan->writetrans may have returned multiple frames 04829 from the single frame we passed in; if so, feed each one of them to the 04830 channel, freeing each one after it has been written */ 04831 if ((f != fr) && AST_LIST_NEXT(f, frame_list)) { 04832 struct ast_frame *cur, *next; 04833 unsigned int skip = 0; 04834 04835 for (cur = f, next = AST_LIST_NEXT(cur, frame_list); 04836 cur; 04837 cur = next, next = cur ? AST_LIST_NEXT(cur, frame_list) : NULL) { 04838 if (!skip) { 04839 if ((res = chan->tech->write(chan, cur)) < 0) { 04840 chan->_softhangup |= AST_SOFTHANGUP_DEV; 04841 skip = 1; 04842 } else if (next) { 04843 /* don't do this for the last frame in the list, 04844 as the code outside the loop will do it once 04845 */ 04846 chan->fout = FRAMECOUNT_INC(chan->fout); 04847 } 04848 } 04849 ast_frfree(cur); 04850 } 04851 04852 /* reset f so the code below doesn't attempt to free it */ 04853 f = NULL; 04854 } else { 04855 res = chan->tech->write(chan, f); 04856 } 04857 break; 04858 case AST_FRAME_NULL: 04859 case AST_FRAME_IAX: 04860 /* Ignore these */ 04861 res = 0; 04862 break; 04863 default: 04864 /* At this point, fr is the incoming frame and f is NULL. Channels do 04865 * not expect to get NULL as a frame pointer and will segfault. Hence, 04866 * we output the original frame passed in. */ 04867 res = chan->tech->write(chan, fr); 04868 break; 04869 } 04870 04871 if (f && f != fr) 04872 ast_frfree(f); 04873 ast_clear_flag(chan, AST_FLAG_BLOCKING); 04874 04875 /* Consider a write failure to force a soft hangup */ 04876 if (res < 0) { 04877 chan->_softhangup |= AST_SOFTHANGUP_DEV; 04878 } else { 04879 chan->fout = FRAMECOUNT_INC(chan->fout); 04880 } 04881 done: 04882 if (chan->audiohooks && ast_audiohook_write_list_empty(chan->audiohooks)) { 04883 /* The list gets recreated if audiohooks are added again later */ 04884 ast_audiohook_detach_list(chan->audiohooks); 04885 chan->audiohooks = NULL; 04886 } 04887 ast_channel_unlock(chan); 04888 return res; 04889 }
| int ast_write_video | ( | struct ast_channel * | chan, | |
| struct ast_frame * | frame | |||
| ) |
Write video frame to a channel This function writes the given frame to the indicated channel.
| chan | destination channel of the frame | |
| frame | frame that will be written |
Definition at line 4490 of file channel.c.
References ast_write(), ast_channel::tech, and ast_channel_tech::write_video.
04491 { 04492 int res; 04493 if (!chan->tech->write_video) 04494 return 0; 04495 res = ast_write(chan, fr); 04496 if (!res) 04497 res = 1; 04498 return res; 04499 }
| static void bridge_play_sounds | ( | struct ast_channel * | c0, | |
| struct ast_channel * | c1 | |||
| ) | [static] |
Definition at line 6721 of file channel.c.
References ast_channel_lock, ast_channel_unlock, ast_strdupa, bridge_playfile(), pbx_builtin_getvar_helper(), and pbx_builtin_setvar_helper().
Referenced by ast_channel_bridge().
06722 { 06723 const char *s, *sound; 06724 06725 /* See if we need to play an audio file to any side of the bridge */ 06726 06727 ast_channel_lock(c0); 06728 if ((s = pbx_builtin_getvar_helper(c0, "BRIDGE_PLAY_SOUND"))) { 06729 sound = ast_strdupa(s); 06730 ast_channel_unlock(c0); 06731 bridge_playfile(c0, c1, sound, 0); 06732 pbx_builtin_setvar_helper(c0, "BRIDGE_PLAY_SOUND", NULL); 06733 } else { 06734 ast_channel_unlock(c0); 06735 } 06736 06737 ast_channel_lock(c1); 06738 if ((s = pbx_builtin_getvar_helper(c1, "BRIDGE_PLAY_SOUND"))) { 06739 sound = ast_strdupa(s); 06740 ast_channel_unlock(c1); 06741 bridge_playfile(c1, c0, sound, 0); 06742 pbx_builtin_setvar_helper(c1, "BRIDGE_PLAY_SOUND", NULL); 06743 } else { 06744 ast_channel_unlock(c1); 06745 } 06746 }
| static void bridge_playfile | ( | struct ast_channel * | chan, | |
| struct ast_channel * | peer, | |||
| const char * | sound, | |||
| int | remain | |||
| ) | [static] |
Definition at line 6417 of file channel.c.
References ast_autoservice_start(), ast_autoservice_stop(), AST_DIGIT_ANY, ast_say_number(), ast_stream_and_wait(), and ast_channel::language.
Referenced by ast_channel_bridge(), and bridge_play_sounds().
06418 { 06419 int min = 0, sec = 0, check; 06420 06421 check = ast_autoservice_start(peer); 06422 if (check) 06423 return; 06424 06425 if (remain > 0) { 06426 if (remain / 60 > 1) { 06427 min = remain / 60; 06428 sec = remain % 60; 06429 } else { 06430 sec = remain; 06431 } 06432 } 06433 06434 if (!strcmp(sound,"timeleft")) { /* Queue support */ 06435 ast_stream_and_wait(chan, "vm-youhave", ""); 06436 if (min) { 06437 ast_say_number(chan, min, AST_DIGIT_ANY, chan->language, NULL); 06438 ast_stream_and_wait(chan, "queue-minutes", ""); 06439 } 06440 if (sec) { 06441 ast_say_number(chan, sec, AST_DIGIT_ANY, chan->language, NULL); 06442 ast_stream_and_wait(chan, "queue-seconds", ""); 06443 } 06444 } else { 06445 ast_stream_and_wait(chan, sound, ""); 06446 } 06447 06448 ast_autoservice_stop(peer); 06449 }
| static int calc_monitor_jump | ( | int | samples, | |
| int | sample_rate, | |||
| int | seek_rate | |||
| ) | [inline, static] |
calculates the number of samples to jump forward with in a monitor stream.
| number | of samples to seek forward after rate conversion. |
Definition at line 3575 of file channel.c.
Referenced by __ast_read(), and ast_write().
03576 { 03577 int diff = sample_rate - seek_rate; 03578 03579 if (diff > 0) { 03580 samples = samples / (float) (sample_rate / seek_rate); 03581 } else if (diff < 0) { 03582 samples = samples * (float) (seek_rate / sample_rate); 03583 } 03584 03585 return samples; 03586 }
| static void* channel_cc_params_copy | ( | void * | data | ) | [static] |
Definition at line 8872 of file channel.c.
References ast_cc_config_params_init, and ast_cc_copy_config_params().
08873 { 08874 const struct ast_cc_config_params *src = data; 08875 struct ast_cc_config_params *dest = ast_cc_config_params_init(); 08876 if (!dest) { 08877 return NULL; 08878 } 08879 ast_cc_copy_config_params(dest, src); 08880 return dest; 08881 }
| static void channel_cc_params_destroy | ( | void * | data | ) | [static] |
Definition at line 8883 of file channel.c.
References ast_cc_config_params_destroy().
08884 { 08885 struct ast_cc_config_params *cc_params = data; 08886 ast_cc_config_params_destroy(cc_params); 08887 }
| static void channel_data_add_flags | ( | struct ast_data * | tree, | |
| struct ast_channel * | chan | |||
| ) | [static] |
Definition at line 268 of file channel.c.
References ast_data_add_bool(), AST_FLAG_ANSWERED_ELSEWHERE, AST_FLAG_BLOCKING, AST_FLAG_BRIDGE_HANGUP_DONT, AST_FLAG_BRIDGE_HANGUP_RUN, AST_FLAG_DEFER_DTMF, AST_FLAG_DISABLE_WORKAROUNDS, AST_FLAG_EMULATE_DTMF, AST_FLAG_END_DTMF_ONLY, AST_FLAG_EXCEPTION, AST_FLAG_IN_AUTOLOOP, AST_FLAG_IN_DTMF, AST_FLAG_MASQ_NOSTREAM, AST_FLAG_MOH, AST_FLAG_NBRIDGE, AST_FLAG_OUTGOING, AST_FLAG_SPYING, AST_FLAG_WRITE_INT, AST_FLAG_ZOMBIE, and ast_test_flag.
Referenced by ast_channel_data_add_structure().
00270 { 00271 ast_data_add_bool(tree, "DEFER_DTMF", ast_test_flag(chan, AST_FLAG_DEFER_DTMF)); 00272 ast_data_add_bool(tree, "WRITE_INT", ast_test_flag(chan, AST_FLAG_WRITE_INT)); 00273 ast_data_add_bool(tree, "BLOCKING", ast_test_flag(chan, AST_FLAG_BLOCKING)); 00274 ast_data_add_bool(tree, "ZOMBIE", ast_test_flag(chan, AST_FLAG_ZOMBIE)); 00275 ast_data_add_bool(tree, "EXCEPTION", ast_test_flag(chan, AST_FLAG_EXCEPTION)); 00276 ast_data_add_bool(tree, "MOH", ast_test_flag(chan, AST_FLAG_MOH)); 00277 ast_data_add_bool(tree, "SPYING", ast_test_flag(chan, AST_FLAG_SPYING)); 00278 ast_data_add_bool(tree, "NBRIDGE", ast_test_flag(chan, AST_FLAG_NBRIDGE)); 00279 ast_data_add_bool(tree, "IN_AUTOLOOP", ast_test_flag(chan, AST_FLAG_IN_AUTOLOOP)); 00280 ast_data_add_bool(tree, "OUTGOING", ast_test_flag(chan, AST_FLAG_OUTGOING)); 00281 ast_data_add_bool(tree, "IN_DTMF", ast_test_flag(chan, AST_FLAG_IN_DTMF)); 00282 ast_data_add_bool(tree, "EMULATE_DTMF", ast_test_flag(chan, AST_FLAG_EMULATE_DTMF)); 00283 ast_data_add_bool(tree, "END_DTMF_ONLY", ast_test_flag(chan, AST_FLAG_END_DTMF_ONLY)); 00284 ast_data_add_bool(tree, "ANSWERED_ELSEWHERE", ast_test_flag(chan, AST_FLAG_ANSWERED_ELSEWHERE)); 00285 ast_data_add_bool(tree, "MASQ_NOSTREAM", ast_test_flag(chan, AST_FLAG_MASQ_NOSTREAM)); 00286 ast_data_add_bool(tree, "BRIDGE_HANGUP_RUN", ast_test_flag(chan, AST_FLAG_BRIDGE_HANGUP_RUN)); 00287 ast_data_add_bool(tree, "BRIDGE_HANGUP_DONT", ast_test_flag(chan, AST_FLAG_BRIDGE_HANGUP_DONT)); 00288 ast_data_add_bool(tree, "DISABLE_WORKAROUNDS", ast_test_flag(chan, AST_FLAG_DISABLE_WORKAROUNDS)); 00289 }
| static struct ast_channel_iterator* channel_iterator_search | ( | const char * | name, | |
| size_t | name_len, | |||
| const char * | exten, | |||
| const char * | context | |||
| ) | [static, read] |
Definition at line 1538 of file channel.c.
References ast_channel_iterator::active_iterator, ao2_find, ast_calloc, ast_copy_string(), ast_free, ast_strlen_zero(), channels, ast_channel::context, ast_channel::exten, ast_channel::name, OBJ_MULTIPLE, and OBJ_POINTER.
Referenced by ast_channel_iterator_by_exten_new(), and ast_channel_iterator_by_name_new().
01541 { 01542 struct ast_channel_iterator *i; 01543 struct ast_channel tmp_chan = { 01544 .name = name, 01545 /* This is sort of a hack. Basically, we're using an arbitrary field 01546 * in ast_channel to pass the name_len for a prefix match. If this 01547 * gets changed, then the compare callback must be changed, too. */ 01548 .rings = name_len, 01549 }; 01550 01551 if (!(i = ast_calloc(1, sizeof(*i)))) { 01552 return NULL; 01553 } 01554 01555 if (exten) { 01556 ast_copy_string(tmp_chan.exten, exten, sizeof(tmp_chan.exten)); 01557 } 01558 01559 if (context) { 01560 ast_copy_string(tmp_chan.context, context, sizeof(tmp_chan.context)); 01561 } 01562 01563 if (!(i->active_iterator = ao2_find(channels, &tmp_chan, 01564 OBJ_MULTIPLE | ((!ast_strlen_zero(name) && (name_len == 0)) ? OBJ_POINTER : 0)))) { 01565 ast_free(i); 01566 return NULL; 01567 } 01568 01569 return i; 01570 }
| const char* channelreloadreason2txt | ( | enum channelreloadreason | reason | ) |
Convert enum channelreloadreason to text string for manager event.
\ brief Convert channel reloadreason (ENUM) to text string for manager event
Definition at line 7547 of file channel.c.
References CHANNEL_CLI_RELOAD, CHANNEL_MODULE_LOAD, and CHANNEL_MODULE_RELOAD.
Referenced by reload_config().
07548 { 07549 switch (reason) { 07550 case CHANNEL_MODULE_LOAD: 07551 return "LOAD (Channel module load)"; 07552 07553 case CHANNEL_MODULE_RELOAD: 07554 return "RELOAD (Channel module reload)"; 07555 07556 case CHANNEL_CLI_RELOAD: 07557 return "CLIRELOAD (Channel module reload by CLI command)"; 07558 07559 default: 07560 return "MANAGERRELOAD (Channel module reload by manager)"; 07561 } 07562 };
| static void clone_variables | ( | struct ast_channel * | original, | |
| struct ast_channel * | clonechan | |||
| ) | [static] |
Clone channel variables from 'clone' channel into 'original' channel.
All variables except those related to app_groupcount are cloned. Variables are actually _removed_ from 'clone' channel, presumably because it will subsequently be destroyed.
Definition at line 5742 of file channel.c.
References AST_LIST_APPEND_LIST, AST_LIST_FIRST, AST_LIST_INSERT_TAIL, AST_LIST_TRAVERSE, ast_var_assign(), ast_var_t::entries, ast_var_t::name, ast_var_t::value, and ast_channel::varshead.
Referenced by ast_do_masquerade().
05743 { 05744 struct ast_var_t *current, *newvar; 05745 /* Append variables from clone channel into original channel */ 05746 /* XXX Is this always correct? We have to in order to keep MACROS working XXX */ 05747 if (AST_LIST_FIRST(&clonechan->varshead)) 05748 AST_LIST_APPEND_LIST(&original->varshead, &clonechan->varshead, entries); 05749 05750 /* then, dup the varshead list into the clone */ 05751 05752 AST_LIST_TRAVERSE(&original->varshead, current, entries) { 05753 newvar = ast_var_assign(current->name, current->value); 05754 if (newvar) 05755 AST_LIST_INSERT_TAIL(&clonechan->varshead, newvar, entries); 05756 } 05757 }
| static char* complete_channeltypes | ( | struct ast_cli_args * | a | ) | [static] |
Definition at line 523 of file channel.c.
References AST_RWLIST_RDLOCK, AST_RWLIST_TRAVERSE, AST_RWLIST_UNLOCK, ast_strdup, ast_cli_args::n, ast_cli_args::pos, chanlist::tech, ast_channel_tech::type, and ast_cli_args::word.
Referenced by handle_cli_core_show_channeltype().
00524 { 00525 struct chanlist *cl; 00526 int which = 0; 00527 int wordlen; 00528 char *ret = NULL; 00529 00530 if (a->pos != 3) 00531 return NULL; 00532 00533 wordlen = strlen(a->word); 00534 00535 AST_RWLIST_RDLOCK(&backends); 00536 AST_RWLIST_TRAVERSE(&backends, cl, list) { 00537 if (!strncasecmp(a->word, cl->tech->type, wordlen) && ++which > a->n) { 00538 ret = ast_strdup(cl->tech->type); 00539 break; 00540 } 00541 } 00542 AST_RWLIST_UNLOCK(&backends); 00543 00544 return ret; 00545 }
| static int data_channels_provider_handler | ( | const struct ast_data_search * | search, | |
| struct ast_data * | root | |||
| ) | [static] |
Definition at line 7306 of file channel.c.
References ast_channel_data_add_structure(), ast_channel_iterator_all_new(), ast_channel_iterator_destroy(), ast_channel_iterator_next(), ast_channel_lock, ast_channel_unlock, ast_channel_unref, ast_data_add_node(), ast_data_remove_node(), ast_data_search_match(), ast_log(), and LOG_ERROR.
07308 { 07309 struct ast_channel *c; 07310 struct ast_channel_iterator *iter = NULL; 07311 struct ast_data *data_channel; 07312 07313 for (iter = ast_channel_iterator_all_new(); 07314 iter && (c = ast_channel_iterator_next(iter)); ast_channel_unref(c)) { 07315 ast_channel_lock(c); 07316 07317 data_channel = ast_data_add_node(root, "channel"); 07318 if (!data_channel) { 07319 ast_channel_unlock(c); 07320 continue; 07321 } 07322 07323 if (ast_channel_data_add_structure(data_channel, c, 1) < 0) { 07324 ast_log(LOG_ERROR, "Unable to add channel structure for channel: %s\n", c->name); 07325 } 07326 07327 ast_channel_unlock(c); 07328 07329 if (!ast_data_search_match(search, data_channel)) { 07330 ast_data_remove_node(root, data_channel); 07331 } 07332 } 07333 if (iter) { 07334 ast_channel_iterator_destroy(iter); 07335 } 07336 07337 return 0; 07338 }
| static int data_channeltypes_provider_handler | ( | const struct ast_data_search * | search, | |
| struct ast_data * | data_root | |||
| ) | [static] |
Definition at line 7344 of file channel.c.
References ast_channel_tech::answer, ast_data_add_bool(), ast_data_add_codecs(), ast_data_add_node(), ast_data_add_str(), ast_data_remove_node(), ast_data_search_match(), AST_RWLIST_RDLOCK, AST_RWLIST_TRAVERSE, AST_RWLIST_UNLOCK, ast_channel_tech::bridge, ast_channel_tech::bridged_channel, ast_channel_tech::call, ast_channel_tech::capabilities, ast_channel_tech::cc_callback, ast_channel_tech::description, ast_channel_tech::devicestate, ast_channel_tech::early_bridge, ast_channel_tech::exception, ast_channel_tech::fixup, ast_channel_tech::func_channel_read, ast_channel_tech::func_channel_write, ast_channel_tech::get_base_channel, ast_channel_tech::get_pvt_uniqueid, ast_channel_tech::hangup, ast_channel_tech::indicate, ast_channel_tech::queryoption, ast_channel_tech::read, ast_channel_tech::send_digit_begin, ast_channel_tech::send_digit_end, ast_channel_tech::send_html, ast_channel_tech::send_image, ast_channel_tech::send_text, ast_channel_tech::set_base_channel, ast_channel_tech::setoption, chanlist::tech, ast_channel_tech::transfer, ast_channel_tech::type, ast_channel_tech::write, ast_channel_tech::write_text, and ast_channel_tech::write_video.
07346 { 07347 struct chanlist *cl; 07348 struct ast_data *data_type; 07349 07350 AST_RWLIST_RDLOCK(&backends); 07351 AST_RWLIST_TRAVERSE(&backends, cl, list) { 07352 data_type = ast_data_add_node(data_root, "type"); 07353 if (!data_type) { 07354 continue; 07355 } 07356 ast_data_add_str(data_type, "name", cl->tech->type); 07357 ast_data_add_str(data_type, "description", cl->tech->description); 07358 ast_data_add_bool(data_type, "devicestate", cl->tech->devicestate ? 1 : 0); 07359 ast_data_add_bool(data_type, "indications", cl->tech->indicate ? 1 : 0); 07360 ast_data_add_bool(data_type, "transfer", cl->tech->transfer ? 1 : 0); 07361 ast_data_add_bool(data_type, "send_digit_begin", cl->tech->send_digit_begin ? 1 : 0); 07362 ast_data_add_bool(data_type, "send_digit_end", cl->tech->send_digit_end ? 1 : 0); 07363 ast_data_add_bool(data_type, "call", cl->tech->call ? 1 : 0); 07364 ast_data_add_bool(data_type, "hangup", cl->tech->hangup ? 1 : 0); 07365 ast_data_add_bool(data_type, "answer", cl->tech->answer ? 1 : 0); 07366 ast_data_add_bool(data_type, "read", cl->tech->read ? 1 : 0); 07367 ast_data_add_bool(data_type, "write", cl->tech->write ? 1 : 0); 07368 ast_data_add_bool(data_type, "send_text", cl->tech->send_text ? 1 : 0); 07369 ast_data_add_bool(data_type, "send_image", cl->tech->send_image ? 1 : 0); 07370 ast_data_add_bool(data_type, "send_html", cl->tech->send_html ? 1 : 0); 07371 ast_data_add_bool(data_type, "exception", cl->tech->exception ? 1 : 0); 07372 ast_data_add_bool(data_type, "bridge", cl->tech->bridge ? 1 : 0); 07373 ast_data_add_bool(data_type, "early_bridge", cl->tech->early_bridge ? 1 : 0); 07374 ast_data_add_bool(data_type, "fixup", cl->tech->fixup ? 1 : 0); 07375 ast_data_add_bool(data_type, "setoption", cl->tech->setoption ? 1 : 0); 07376 ast_data_add_bool(data_type, "queryoption", cl->tech->queryoption ? 1 : 0); 07377 ast_data_add_bool(data_type, "write_video", cl->tech->write_video ? 1 : 0); 07378 ast_data_add_bool(data_type, "write_text", cl->tech->write_text ? 1 : 0); 07379 ast_data_add_bool(data_type, "bridged_channel", cl->tech->bridged_channel ? 1 : 0); 07380 ast_data_add_bool(data_type, "func_channel_read", cl->tech->func_channel_read ? 1 : 0); 07381 ast_data_add_bool(data_type, "func_channel_write", cl->tech->func_channel_write ? 1 : 0); 07382 ast_data_add_bool(data_type, "get_base_channel", cl->tech->get_base_channel ? 1 : 0); 07383 ast_data_add_bool(data_type, "set_base_channel", cl->tech->set_base_channel ? 1 : 0); 07384 ast_data_add_bool(data_type, "get_pvt_uniqueid", cl->tech->get_pvt_uniqueid ? 1 : 0); 07385 ast_data_add_bool(data_type, "cc_callback", cl->tech->cc_callback ? 1 : 0); 07386 07387 ast_data_add_codecs(data_type, "capabilities", cl->tech->capabilities); 07388 07389 if (!ast_data_search_match(search, data_type)) { 07390 ast_data_remove_node(data_root, data_type); 07391 } 07392 } 07393 AST_RWLIST_UNLOCK(&backends); 07394 07395 return 0; 07396 }
| static void free_translation | ( | struct ast_channel * | clonechan | ) | [static] |
Definition at line 2598 of file channel.c.
References ast_translator_free_path(), ast_channel::nativeformats, ast_channel::rawreadformat, ast_channel::rawwriteformat, ast_channel::readtrans, and ast_channel::writetrans.
Referenced by ast_do_masquerade(), and ast_hangup().
02599 { 02600 if (clonechan->writetrans) 02601 ast_translator_free_path(clonechan->writetrans); 02602 if (clonechan->readtrans) 02603 ast_translator_free_path(clonechan->readtrans); 02604 clonechan->writetrans = NULL; 02605 clonechan->readtrans = NULL; 02606 clonechan->rawwriteformat = clonechan->nativeformats; 02607 clonechan->rawreadformat = clonechan->nativeformats; 02608 }
| static int generator_force | ( | const void * | data | ) | [static] |
Definition at line 2918 of file channel.c.
References ast_channel_lock, ast_channel_unlock, ast_deactivate_generator(), ast_debug, AST_FORMAT_AUDIO_MASK, ast_format_rate(), ast_generator::generate, ast_channel::generator, ast_channel::generatordata, and ast_channel::writeformat.
Referenced by ast_activate_generator(), and ast_read_generator_actions().
02919 { 02920 /* Called if generator doesn't have data */ 02921 void *tmp; 02922 int res; 02923 int (*generate)(struct ast_channel *chan, void *tmp, int datalen, int samples) = NULL; 02924 struct ast_channel *chan = (struct ast_channel *)data; 02925 02926 ast_channel_lock(chan); 02927 tmp = chan->generatordata; 02928 chan->generatordata = NULL; 02929 if (chan->generator) 02930 generate = chan->generator->generate; 02931 ast_channel_unlock(chan); 02932 02933 if (!tmp || !generate) 02934 return 0; 02935 02936 res = generate(chan, tmp, 0, ast_format_rate(chan->writeformat & AST_FORMAT_AUDIO_MASK) / 50); 02937 02938 chan->generatordata = tmp; 02939 02940 if (res) { 02941 ast_debug(1, "Auto-deactivating generator\n"); 02942 ast_deactivate_generator(chan); 02943 } 02944 02945 return 0; 02946 }
| static void handle_cause | ( | int | cause, | |
| int * | outstate | |||
| ) | [static] |
Definition at line 4996 of file channel.c.
References AST_CAUSE_BUSY, AST_CAUSE_CONGESTION, AST_CONTROL_BUSY, and AST_CONTROL_CONGESTION.
Referenced by __ast_request_and_dial(), and ast_call_forward().
04997 { 04998 if (outstate) { 04999 /* compute error and return */ 05000 if (cause == AST_CAUSE_BUSY) 05001 *outstate = AST_CONTROL_BUSY; 05002 else if (cause == AST_CAUSE_CONGESTION) 05003 *outstate = AST_CONTROL_CONGESTION; 05004 else 05005 *outstate = 0; 05006 } 05007 }
| static char* handle_cli_core_show_channeltype | ( | struct ast_cli_entry * | e, | |
| int | cmd, | |||
| struct ast_cli_args * | a | |||
| ) | [static] |
Show details about a channel driver - CLI command.
Definition at line 548 of file channel.c.
References ast_cli_args::argc, ast_cli_args::argv, ast_cli(), ast_getformatname_multiple(), AST_RWLIST_RDLOCK, AST_RWLIST_TRAVERSE, AST_RWLIST_UNLOCK, ast_channel_tech::capabilities, CLI_FAILURE, CLI_GENERATE, CLI_INIT, CLI_SHOWUSAGE, CLI_SUCCESS, ast_cli_entry::command, complete_channeltypes(), ast_channel_tech::devicestate, ast_cli_args::fd, ast_channel_tech::indicate, ast_channel_tech::send_digit_begin, ast_channel_tech::send_digit_end, ast_channel_tech::send_html, ast_channel_tech::send_image, ast_channel_tech::send_text, chanlist::tech, ast_channel_tech::transfer, ast_channel_tech::type, and ast_cli_entry::usage.
00549 { 00550 struct chanlist *cl = NULL; 00551 char buf[512]; 00552 00553 switch (cmd) { 00554 case CLI_INIT: 00555 e->command = "core show channeltype"; 00556 e->usage = 00557 "Usage: core show channeltype <name>\n" 00558 " Show details about the specified channel type, <name>.\n"; 00559 return NULL; 00560 case CLI_GENERATE: 00561 return complete_channeltypes(a); 00562 } 00563 00564 if (a->argc != 4) 00565 return CLI_SHOWUSAGE; 00566 00567 AST_RWLIST_RDLOCK(&backends); 00568 00569 AST_RWLIST_TRAVERSE(&backends, cl, list) { 00570 if (!strncasecmp(cl->tech->type, a->argv[3], strlen(cl->tech->type))) 00571 break; 00572 } 00573 00574 00575 if (!cl) { 00576 ast_cli(a->fd, "\n%s is not a registered channel driver.\n", a->argv[3]); 00577 AST_RWLIST_UNLOCK(&backends); 00578 return CLI_FAILURE; 00579 } 00580 00581 ast_cli(a->fd, 00582 "-- Info about channel driver: %s --\n" 00583 " Device State: %s\n" 00584 " Indication: %s\n" 00585 " Transfer : %s\n" 00586 " Capabilities: %s\n" 00587 " Digit Begin: %s\n" 00588 " Digit End: %s\n" 00589 " Send HTML : %s\n" 00590 " Image Support: %s\n" 00591 " Text Support: %s\n", 00592 cl->tech->type, 00593 (cl->tech->devicestate) ? "yes" : "no", 00594 (cl->tech->indicate) ? "yes" : "no", 00595 (cl->tech->transfer) ? "yes" : "no", 00596 ast_getformatname_multiple(buf, sizeof(buf), (cl->tech->capabilities) ? cl->tech->capabilities : -1), 00597 (cl->tech->send_digit_begin) ? "yes" : "no", 00598 (cl->tech->send_digit_end) ? "yes" : "no", 00599 (cl->tech->send_html) ? "yes" : "no", 00600 (cl->tech->send_image) ? "yes" : "no", 00601 (cl->tech->send_text) ? "yes" : "no" 00602 00603 ); 00604 00605 AST_RWLIST_UNLOCK(&backends); 00606 00607 return CLI_SUCCESS; 00608 }
| static char* handle_cli_core_show_channeltypes | ( | struct ast_cli_entry * | e, | |
| int | cmd, | |||
| struct ast_cli_args * | a | |||
| ) | [static] |
Show channel types - CLI command.
Definition at line 482 of file channel.c.
References ast_cli_args::argc, ast_cli(), AST_RWLIST_RDLOCK, AST_RWLIST_TRAVERSE, AST_RWLIST_UNLOCK, CLI_GENERATE, CLI_INIT, CLI_SHOWUSAGE, CLI_SUCCESS, ast_cli_entry::command, ast_channel_tech::description, ast_channel_tech::devicestate, ast_cli_args::fd, FORMAT, ast_channel_tech::indicate, chanlist::tech, ast_channel_tech::transfer, ast_channel_tech::type, and ast_cli_entry::usage.
00483 { 00484 #define FORMAT "%-10.10s %-40.40s %-12.12s %-12.12s %-12.12s\n" 00485 struct chanlist *cl; 00486 int count_chan = 0; 00487 00488 switch (cmd) { 00489 case CLI_INIT: 00490 e->command = "core show channeltypes"; 00491 e->usage = 00492 "Usage: core show channeltypes\n" 00493 " Lists available channel types registered in your\n" 00494 " Asterisk server.\n"; 00495 return NULL; 00496 case CLI_GENERATE: 00497 return NULL; 00498 } 00499 00500 if (a->argc != 3) 00501 return CLI_SHOWUSAGE; 00502 00503 ast_cli(a->fd, FORMAT, "Type", "Description", "Devicestate", "Indications", "Transfer"); 00504 ast_cli(a->fd, FORMAT, "----------", "-----------", "-----------", "-----------", "--------"); 00505 00506 AST_RWLIST_RDLOCK(&backends); 00507 AST_RWLIST_TRAVERSE(&backends, cl, list) { 00508 ast_cli(a->fd, FORMAT, cl->tech->type, cl->tech->description, 00509 (cl->tech->devicestate) ? "yes" : "no", 00510 (cl->tech->indicate) ? "yes" : "no", 00511 (cl->tech->transfer) ? "yes" : "no"); 00512 count_chan++; 00513 } 00514 AST_RWLIST_UNLOCK(&backends); 00515 00516 ast_cli(a->fd, "----------\n%d channel drivers registered.\n", count_chan); 00517 00518 return CLI_SUCCESS; 00519 00520 #undef FORMAT 00521 }
| static int attribute_const is_visible_indication | ( | enum ast_control_frame_type | condition | ) | [static] |
Definition at line 4122 of file channel.c.
References _XXX_AST_CONTROL_T38, AST_CONTROL_ANSWER, AST_CONTROL_AOC, AST_CONTROL_BUSY, AST_CONTROL_CC, AST_CONTROL_CONGESTION, AST_CONTROL_CONNECTED_LINE, AST_CONTROL_FLASH, AST_CONTROL_HANGUP, AST_CONTROL_HOLD, AST_CONTROL_OFFHOOK, AST_CONTROL_OPTION, AST_CONTROL_PROCEEDING, AST_CONTROL_PROGRESS, AST_CONTROL_RADIO_KEY, AST_CONTROL_RADIO_UNKEY, AST_CONTROL_READ_ACTION, AST_CONTROL_REDIRECTING, AST_CONTROL_RING, AST_CONTROL_RINGING, AST_CONTROL_SRCCHANGE, AST_CONTROL_SRCUPDATE, AST_CONTROL_T38_PARAMETERS, AST_CONTROL_TAKEOFFHOOK, AST_CONTROL_TRANSFER, AST_CONTROL_UNHOLD, AST_CONTROL_VIDUPDATE, and AST_CONTROL_WINK.
Referenced by ast_indicate_data().
04123 { 04124 /* Don't include a default case here so that we get compiler warnings 04125 * when a new type is added. */ 04126 04127 switch (condition) { 04128 case AST_CONTROL_PROGRESS: 04129 case AST_CONTROL_PROCEEDING: 04130 case AST_CONTROL_VIDUPDATE: 04131 case AST_CONTROL_SRCUPDATE: 04132 case AST_CONTROL_SRCCHANGE: 04133 case AST_CONTROL_RADIO_KEY: 04134 case AST_CONTROL_RADIO_UNKEY: 04135 case AST_CONTROL_OPTION: 04136 case AST_CONTROL_WINK: 04137 case AST_CONTROL_FLASH: 04138 case AST_CONTROL_OFFHOOK: 04139 case AST_CONTROL_TAKEOFFHOOK: 04140 case AST_CONTROL_ANSWER: 04141 case AST_CONTROL_HANGUP: 04142 case AST_CONTROL_CONNECTED_LINE: 04143 case AST_CONTROL_REDIRECTING: 04144 case AST_CONTROL_TRANSFER: 04145 case AST_CONTROL_T38_PARAMETERS: 04146 case _XXX_AST_CONTROL_T38: 04147 case AST_CONTROL_CC: 04148 case AST_CONTROL_READ_ACTION: 04149 case AST_CONTROL_AOC: 04150 break; 04151 04152 case AST_CONTROL_CONGESTION: 04153 case AST_CONTROL_BUSY: 04154 case AST_CONTROL_RINGING: 04155 case AST_CONTROL_RING: 04156 case AST_CONTROL_HOLD: 04157 case AST_CONTROL_UNHOLD: 04158 return 1; 04159 } 04160 04161 return 0; 04162 }
| static void manager_bridge_event | ( | int | onoff, | |
| int | type, | |||
| struct ast_channel * | c0, | |||
| struct ast_channel * | c1 | |||
| ) | [static] |
Send manager event for bridge link and unlink events.
| onoff | Link/Unlinked | |
| type | 1 for core, 2 for native | |
| c0 | first channel in bridge | |
| c1 | second channel in bridge |
Definition at line 6664 of file channel.c.
References ast_manager_event_multichan, ast_channel::caller, EVENT_FLAG_CALL, ast_party_caller::id, ast_channel::name, ast_party_id::number, S_COR, ast_party_number::str, ast_channel::uniqueid, and ast_party_number::valid.
Referenced by ast_channel_bridge().
06665 { 06666 struct ast_channel *chans[2] = { c0, c1 }; 06667 ast_manager_event_multichan(EVENT_FLAG_CALL, "Bridge", 2, chans, 06668 "Bridgestate: %s\r\n" 06669 "Bridgetype: %s\r\n" 06670 "Channel1: %s\r\n" 06671 "Channel2: %s\r\n" 06672 "Uniqueid1: %s\r\n" 06673 "Uniqueid2: %s\r\n" 06674 "CallerID1: %s\r\n" 06675 "CallerID2: %s\r\n", 06676 onoff ? "Link" : "Unlink", 06677 type == 1 ? "core" : "native", 06678 c0->name, c1->name, 06679 c0->uniqueid, c1->uniqueid, 06680 S_COR(c0->caller.id.number.valid, c0->caller.id.number.str, ""), 06681 S_COR(c1->caller.id.number.valid, c1->caller.id.number.str, "")); 06682 }
| static const char* oldest_linkedid | ( | const char * | a, | |
| const char * | b | |||
| ) | [static] |
Definition at line 5772 of file channel.c.
References ast_strlen_zero().
Referenced by ast_channel_set_linkgroup().
05773 { 05774 const char *satime, *saseq; 05775 const char *sbtime, *sbseq; 05776 const char *dash; 05777 05778 unsigned int atime, aseq, btime, bseq; 05779 05780 if (ast_strlen_zero(a)) 05781 return b; 05782 05783 if (ast_strlen_zero(b)) 05784 return a; 05785 05786 satime = a; 05787 sbtime = b; 05788 05789 /* jump over the system name */ 05790 if ((dash = strrchr(satime, '-'))) { 05791 satime = dash+1; 05792 } 05793 if ((dash = strrchr(sbtime, '-'))) { 05794 sbtime = dash+1; 05795 } 05796 05797 /* the sequence comes after the '.' */ 05798 saseq = strchr(satime, '.'); 05799 sbseq = strchr(sbtime, '.'); 05800 if (!saseq || !sbseq) 05801 return NULL; 05802 saseq++; 05803 sbseq++; 05804 05805 /* convert it all to integers */ 05806 atime = atoi(satime); /* note that atoi is ignoring the '.' after the time string */ 05807 btime = atoi(sbtime); /* note that atoi is ignoring the '.' after the time string */ 05808 aseq = atoi(saseq); 05809 bseq = atoi(sbseq); 05810 05811 /* and finally compare */ 05812 if (atime == btime) { 05813 return (aseq < bseq) ? a : b; 05814 } 05815 else { 05816 return (atime < btime) ? a : b; 05817 } 05818 }
| static int party_id_build_data | ( | unsigned char * | data, | |
| size_t | datalen, | |||
| const struct ast_party_id * | id, | |||
| const char * | label, | |||
| const struct ast_party_id_ies * | ies, | |||
| const struct ast_set_party_id * | update | |||
| ) | [static] |
Definition at line 7897 of file channel.c.
References ast_log(), ast_party_id_presentation(), ast_party_id_ies::combined_presentation, LOG_WARNING, ast_party_id_ies::name, ast_party_id::name, ast_set_party_id::name, ast_party_id_ies::number, ast_party_id::number, ast_set_party_id::number, party_name_build_data(), party_number_build_data(), party_subaddress_build_data(), ast_party_id_ies::subaddress, ast_party_id::subaddress, ast_set_party_id::subaddress, ast_party_id_ies::tag, and ast_party_id::tag.
Referenced by ast_connected_line_build_data(), and ast_redirecting_build_data().
07900 { 07901 size_t length; 07902 size_t pos = 0; 07903 int res; 07904 07905 /* 07906 * The size of integer values must be fixed in case the frame is 07907 * shipped to another machine. 07908 */ 07909 07910 if (!update || update->name) { 07911 res = party_name_build_data(data + pos, datalen - pos, &id->name, label, 07912 &ies->name); 07913 if (res < 0) { 07914 return -1; 07915 } 07916 pos += res; 07917 } 07918 07919 if (!update || update->number) { 07920 res = party_number_build_data(data + pos, datalen - pos, &id->number, label, 07921 &ies->number); 07922 if (res < 0) { 07923 return -1; 07924 } 07925 pos += res; 07926 } 07927 07928 if (!update || update->subaddress) { 07929 res = party_subaddress_build_data(data + pos, datalen - pos, &id->subaddress, 07930 label, &ies->subaddress); 07931 if (res < 0) { 07932 return -1; 07933 } 07934 pos += res; 07935 } 07936 07937 /* *************** Party id user tag **************************** */ 07938 if (id->tag) { 07939 length = strlen(id->tag); 07940 if (datalen < pos + (sizeof(data[0]) * 2) + length) { 07941 ast_log(LOG_WARNING, "No space left for %s tag\n", label); 07942 return -1; 07943 } 07944 data[pos++] = ies->tag; 07945 data[pos++] = length; 07946 memcpy(data + pos, id->tag, length); 07947 pos += length; 07948 } 07949 07950 /* *************** Party id combined presentation *************** */ 07951 if (!update || update->number) { 07952 int presentation; 07953 07954 if (!update || update->name) { 07955 presentation = ast_party_id_presentation(id); 07956 } else { 07957 /* 07958 * We must compromise because not all the information is available 07959 * to determine a combined presentation value. 07960 * We will only send the number presentation instead. 07961 */ 07962 presentation = id->number.presentation; 07963 } 07964 07965 if (datalen < pos + (sizeof(data[0]) * 2) + 1) { 07966 ast_log(LOG_WARNING, "No space left for %s combined presentation\n", label); 07967 return -1; 07968 } 07969 data[pos++] = ies->combined_presentation; 07970 data[pos++] = 1; 07971 data[pos++] = presentation; 07972 } 07973 07974 return pos; 07975 }
| static int party_name_build_data | ( | unsigned char * | data, | |
| size_t | datalen, | |||
| const struct ast_party_name * | name, | |||
| const char * | label, | |||
| const struct ast_party_name_ies * | ies | |||
| ) | [static] |
Definition at line 7671 of file channel.c.
References ast_log(), ast_party_name::char_set, ast_party_name_ies::char_set, LOG_WARNING, ast_party_name::presentation, ast_party_name_ies::presentation, ast_party_name_ies::str, ast_party_name::str, ast_party_name::valid, and ast_party_name_ies::valid.
Referenced by party_id_build_data().
07672 { 07673 size_t length; 07674 size_t pos = 0; 07675 07676 /* 07677 * The size of integer values must be fixed in case the frame is 07678 * shipped to another machine. 07679 */ 07680 if (name->str) { 07681 length = strlen(name->str); 07682 if (datalen < pos + (sizeof(data[0]) * 2) + length) { 07683 ast_log(LOG_WARNING, "No space left for %s name\n", label); 07684 return -1; 07685 } 07686 data[pos++] = ies->str; 07687 data[pos++] = length; 07688 memcpy(data + pos, name->str, length); 07689 pos += length; 07690 } 07691 07692 if (datalen < pos + (sizeof(data[0]) * 2) + 1) { 07693 ast_log(LOG_WARNING, "No space left for %s name char set\n", label); 07694 return -1; 07695 } 07696 data[pos++] = ies->char_set; 07697 data[pos++] = 1; 07698 data[pos++] = name->char_set; 07699 07700 if (datalen < pos + (sizeof(data[0]) * 2) + 1) { 07701 ast_log(LOG_WARNING, "No space left for %s name presentation\n", label); 07702 return -1; 07703 } 07704 data[pos++] = ies->presentation; 07705 data[pos++] = 1; 07706 data[pos++] = name->presentation; 07707 07708 if (datalen < pos + (sizeof(data[0]) * 2) + 1) { 07709 ast_log(LOG_WARNING, "No space left for %s name valid\n", label); 07710 return -1; 07711 } 07712 data[pos++] = ies->valid; 07713 data[pos++] = 1; 07714 data[pos++] = name->valid; 07715 07716 return pos; 07717 }
| static int party_number_build_data | ( | unsigned char * | data, | |
| size_t | datalen, | |||
| const struct ast_party_number * | number, | |||
| const char * | label, | |||
| const struct ast_party_number_ies * | ies | |||
| ) | [static] |
Definition at line 7745 of file channel.c.
References ast_log(), LOG_WARNING, ast_party_number::plan, ast_party_number_ies::plan, ast_party_number::presentation, ast_party_number_ies::presentation, ast_party_number_ies::str, ast_party_number::str, ast_party_number::valid, and ast_party_number_ies::valid.
Referenced by party_id_build_data().
07746 { 07747 size_t length; 07748 size_t pos = 0; 07749 07750 /* 07751 * The size of integer values must be fixed in case the frame is 07752 * shipped to another machine. 07753 */ 07754 if (number->str) { 07755 length = strlen(number->str); 07756 if (datalen < pos + (sizeof(data[0]) * 2) + length) { 07757 ast_log(LOG_WARNING, "No space left for %s number\n", label); 07758 return -1; 07759 } 07760 data[pos++] = ies->str; 07761 data[pos++] = length; 07762 memcpy(data + pos, number->str, length); 07763 pos += length; 07764 } 07765 07766 if (datalen < pos + (sizeof(data[0]) * 2) + 1) { 07767 ast_log(LOG_WARNING, "No space left for %s numbering plan\n", label); 07768 return -1; 07769 } 07770 data[pos++] = ies->plan; 07771 data[pos++] = 1; 07772 data[pos++] = number->plan; 07773 07774 if (datalen < pos + (sizeof(data[0]) * 2) + 1) { 07775 ast_log(LOG_WARNING, "No space left for %s number presentation\n", label); 07776 return -1; 07777 } 07778 data[pos++] = ies->presentation; 07779 data[pos++] = 1; 07780 data[pos++] = number->presentation; 07781 07782 if (datalen < pos + (sizeof(data[0]) * 2) + 1) { 07783 ast_log(LOG_WARNING, "No space left for %s number valid\n", label); 07784 return -1; 07785 } 07786 data[pos++] = ies->valid; 07787 data[pos++] = 1; 07788 data[pos++] = number->valid; 07789 07790 return pos; 07791 }
| static int party_subaddress_build_data | ( | unsigned char * | data, | |
| size_t | datalen, | |||
| const struct ast_party_subaddress * | subaddress, | |||
| const char * | label, | |||
| const struct ast_party_subaddress_ies * | ies | |||
| ) | [static] |
Definition at line 7819 of file channel.c.
References ast_log(), LOG_WARNING, ast_party_subaddress::odd_even_indicator, ast_party_subaddress_ies::odd_even_indicator, ast_party_subaddress_ies::str, ast_party_subaddress::str, ast_party_subaddress::type, ast_party_subaddress_ies::type, ast_party_subaddress::valid, and ast_party_subaddress_ies::valid.
Referenced by party_id_build_data().
07820 { 07821 size_t length; 07822 size_t pos = 0; 07823 07824 /* 07825 * The size of integer values must be fixed in case the frame is 07826 * shipped to another machine. 07827 */ 07828 if (subaddress->str) { 07829 length = strlen(subaddress->str); 07830 if (datalen < pos + (sizeof(data[0]) * 2) + length) { 07831 ast_log(LOG_WARNING, "No space left for %s subaddress\n", label); 07832 return -1; 07833 } 07834 data[pos++] = ies->str; 07835 data[pos++] = length; 07836 memcpy(data + pos, subaddress->str, length); 07837 pos += length; 07838 } 07839 07840 if (datalen < pos + (sizeof(data[0]) * 2) + 1) { 07841 ast_log(LOG_WARNING, "No space left for %s type of subaddress\n", label); 07842 return -1; 07843 } 07844 data[pos++] = ies->type; 07845 data[pos++] = 1; 07846 data[pos++] = subaddress->type; 07847 07848 if (datalen < pos + (sizeof(data[0]) * 2) + 1) { 07849 ast_log(LOG_WARNING, 07850 "No space left for %s subaddress odd-even indicator\n", label); 07851 return -1; 07852 } 07853 data[pos++] = ies->odd_even_indicator; 07854 data[pos++] = 1; 07855 data[pos++] = subaddress->odd_even_indicator; 07856 07857 if (datalen < pos + (sizeof(data[0]) * 2) + 1) { 07858 ast_log(LOG_WARNING, "No space left for %s subaddress valid\n", label); 07859 return -1; 07860 } 07861 data[pos++] = ies->valid; 07862 data[pos++] = 1; 07863 data[pos++] = subaddress->valid; 07864 07865 return pos; 07866 }
| static void plc_ds_destroy | ( | void * | data | ) | [static] |
Definition at line 4514 of file channel.c.
References ast_free, and plc_ds::samples_buf.
04515 { 04516 struct plc_ds *plc = data; 04517 ast_free(plc->samples_buf); 04518 ast_free(plc); 04519 }
| static void queue_dtmf_readq | ( | struct ast_channel * | chan, | |
| struct ast_frame * | f | |||
| ) | [inline, static] |
Definition at line 3530 of file channel.c.
References AST_FRAME_DTMF_END, ast_queue_frame(), ast_channel::dtmff, ast_frame::frametype, ast_frame_subclass::integer, ast_frame::len, and ast_frame::subclass.
Referenced by __ast_read().
03531 { 03532 struct ast_frame *fr = &chan->dtmff; 03533 03534 fr->frametype = AST_FRAME_DTMF_END; 03535 fr->subclass.integer = f->subclass.integer; 03536 fr->len = f->len; 03537 03538 /* The only time this function will be called is for a frame that just came 03539 * out of the channel driver. So, we want to stick it on the tail of the 03540 * readq. */ 03541 03542 ast_queue_frame(chan, fr); 03543 }
| static void report_new_callerid | ( | struct ast_channel * | chan | ) | [static] |
Definition at line 5918 of file channel.c.
References ast_describe_caller_presentation(), ast_manager_event, ast_party_id_presentation(), ast_channel::caller, EVENT_FLAG_CALL, ast_party_caller::id, ast_party_id::name, ast_channel::name, ast_party_id::number, S_COR, ast_party_name::str, ast_party_number::str, ast_channel::uniqueid, ast_party_name::valid, and ast_party_number::valid.
Referenced by ast_channel_set_caller_event(), ast_do_masquerade(), and ast_set_callerid().
05919 { 05920 int pres; 05921 05922 pres = ast_party_id_presentation(&chan->caller.id); 05923 ast_manager_event(chan, EVENT_FLAG_CALL, "NewCallerid", 05924 "Channel: %s\r\n" 05925 "CallerIDNum: %s\r\n" 05926 "CallerIDName: %s\r\n" 05927 "Uniqueid: %s\r\n" 05928 "CID-CallingPres: %d (%s)\r\n", 05929 chan->name, 05930 S_COR(chan->caller.id.number.valid, chan->caller.id.number.str, ""), 05931 S_COR(chan->caller.id.name.valid, chan->caller.id.name.str, ""), 05932 chan->uniqueid, 05933 pres, 05934 ast_describe_caller_presentation(pres) 05935 ); 05936 }
| static void send_dtmf_event | ( | struct ast_channel * | chan, | |
| const char * | direction, | |||
| const char | digit, | |||
| const char * | begin, | |||
| const char * | end | |||
| ) | [static] |
Definition at line 3469 of file channel.c.
References ast_manager_event, EVENT_FLAG_DTMF, ast_channel::name, and ast_channel::uniqueid.
Referenced by __ast_read(), and ast_write().
03470 { 03471 ast_manager_event(chan, EVENT_FLAG_DTMF, 03472 "DTMF", 03473 "Channel: %s\r\n" 03474 "Uniqueid: %s\r\n" 03475 "Digit: %c\r\n" 03476 "Direction: %s\r\n" 03477 "Begin: %s\r\n" 03478 "End: %s\r\n", 03479 chan->name, chan->uniqueid, digit, direction, begin, end); 03480 }
| static int set_format | ( | struct ast_channel * | chan, | |
| format_t | fmt, | |||
| format_t * | rawformat, | |||
| format_t * | format, | |||
| struct ast_trans_pvt ** | trans, | |||
| const int | direction | |||
| ) | [static] |
Definition at line 4891 of file channel.c.
References ast_best_codec(), ast_channel_lock, ast_channel_setoption(), ast_channel_unlock, ast_debug, AST_FORMAT_AUDIO_MASK, ast_getformatname(), ast_getformatname_multiple(), ast_log(), AST_OPTION_FORMAT_READ, AST_OPTION_FORMAT_WRITE, ast_translator_best_choice(), ast_translator_build_path(), ast_translator_free_path(), LOG_WARNING, ast_channel::name, and ast_channel::nativeformats.
Referenced by ast_set_read_format(), and ast_set_write_format().
04893 { 04894 format_t native, native_fmt = ast_best_codec(fmt); 04895 int res; 04896 char from[200], to[200]; 04897 04898 /* Make sure we only consider audio */ 04899 fmt &= AST_FORMAT_AUDIO_MASK; 04900 04901 native = chan->nativeformats; 04902 04903 if (!fmt || !native) /* No audio requested */ 04904 return 0; /* Let's try a call without any sounds (video, text) */ 04905 04906 /* See if the underlying channel driver is capable of performing transcoding for us */ 04907 if (!ast_channel_setoption(chan, direction ? AST_OPTION_FORMAT_WRITE : AST_OPTION_FORMAT_READ, &native_fmt, sizeof(int*), 0)) { 04908 ast_debug(1, "Channel driver natively set channel %s to %s format %s\n", chan->name, 04909 direction ? "write" : "read", ast_getformatname(native_fmt)); 04910 chan->nativeformats = *rawformat = *format = native_fmt; 04911 if (*trans) { 04912 ast_translator_free_path(*trans); 04913 } 04914 *trans = NULL; 04915 return 0; 04916 } 04917 04918 /* Find a translation path from the native format to one of the desired formats */ 04919 if (!direction) 04920 /* reading */ 04921 res = ast_translator_best_choice(&fmt, &native); 04922 else 04923 /* writing */ 04924 res = ast_translator_best_choice(&native, &fmt); 04925 04926 if (res < 0) { 04927 ast_log(LOG_WARNING, "Unable to find a codec translation path from %s to %s\n", 04928 ast_getformatname_multiple(from, sizeof(from), native), 04929 ast_getformatname_multiple(to, sizeof(to), fmt)); 04930 return -1; 04931 } 04932 04933 /* Now we have a good choice for both. */ 04934 ast_channel_lock(chan); 04935 04936 if ((*rawformat == native) && (*format == fmt) && ((*rawformat == *format) || (*trans))) { 04937 /* the channel is already in these formats, so nothing to do */ 04938 ast_channel_unlock(chan); 04939 return 0; 04940 } 04941 04942 *rawformat = native; 04943 /* User perspective is fmt */ 04944 *format = fmt; 04945 /* Free any read translation we have right now */ 04946 if (*trans) 04947 ast_translator_free_path(*trans); 04948 /* Build a translation path from the raw format to the desired format */ 04949 if (!direction) 04950 /* reading */ 04951 *trans = ast_translator_build_path(*format, *rawformat); 04952 else 04953 /* writing */ 04954 *trans = ast_translator_build_path(*rawformat, *format); 04955 ast_channel_unlock(chan); 04956 ast_debug(1, "Set channel %s to %s format %s\n", chan->name, 04957 direction ? "write" : "read", ast_getformatname(fmt)); 04958 return 0; 04959 }
| static int set_security_requirements | ( | const struct ast_channel * | requestor, | |
| struct ast_channel * | out | |||
| ) | [static] |
Definition at line 5254 of file channel.c.
References ast_channel_datastore_find(), ast_channel_lock, ast_channel_setoption(), ast_channel_unlock, AST_OPTION_SECURE_MEDIA, AST_OPTION_SECURE_SIGNALING, ast_datastore::data, ast_secure_call_store::media, secure_call_info, and ast_secure_call_store::signaling.
Referenced by ast_request().
05255 { 05256 int ops[2][2] = { 05257 {AST_OPTION_SECURE_SIGNALING, 0}, 05258 {AST_OPTION_SECURE_MEDIA, 0}, 05259 }; 05260 int i; 05261 struct ast_channel *r = (struct ast_channel *) requestor; /* UGLY */ 05262 struct ast_datastore *ds; 05263 05264 if (!requestor || !out) { 05265 return 0; 05266 } 05267 05268 ast_channel_lock(r); 05269 if ((ds = ast_channel_datastore_find(r, &secure_call_info, NULL))) { 05270 struct ast_secure_call_store *encrypt = ds->data; 05271 ops[0][1] = encrypt->signaling; 05272 ops[1][1] = encrypt->media; 05273 } else { 05274 ast_channel_unlock(r); 05275 return 0; 05276 } 05277 ast_channel_unlock(r); 05278 05279 for (i = 0; i < 2; i++) { 05280 if (ops[i][1]) { 05281 if (ast_channel_setoption(out, ops[i][0], &ops[i][1], sizeof(ops[i][1]), 0)) { 05282 /* We require a security feature, but the channel won't provide it */ 05283 return -1; 05284 } 05285 } else { 05286 /* We don't care if we can't clear the option on a channel that doesn't support it */ 05287 ast_channel_setoption(out, ops[i][0], &ops[i][1], sizeof(ops[i][1]), 0); 05288 } 05289 } 05290 05291 return 0; 05292 }
| static int should_skip_dtmf | ( | struct ast_channel * | chan | ) | [inline, static] |
Determine whether or not we should ignore DTMF in the readq.
Definition at line 3548 of file channel.c.
References AST_FLAG_DEFER_DTMF, AST_FLAG_EMULATE_DTMF, AST_MIN_DTMF_GAP, ast_test_flag, ast_tvdiff_ms(), ast_tvnow(), ast_tvzero(), and ast_channel::dtmf_tv.
Referenced by __ast_read().
03549 { 03550 if (ast_test_flag(chan, AST_FLAG_DEFER_DTMF | AST_FLAG_EMULATE_DTMF)) { 03551 /* We're in the middle of emulating a digit, or DTMF has been 03552 * explicitly deferred. Skip this digit, then. */ 03553 return 1; 03554 } 03555 03556 if (!ast_tvzero(chan->dtmf_tv) && 03557 ast_tvdiff_ms(ast_tvnow(), chan->dtmf_tv) < AST_MIN_DTMF_GAP) { 03558 /* We're not in the middle of a digit, but it hasn't been long enough 03559 * since the last digit, so we'll have to skip DTMF for now. */ 03560 return 1; 03561 } 03562 03563 return 0; 03564 }
| static void* silence_generator_alloc | ( | struct ast_channel * | chan, | |
| void * | data | |||
| ) | [static] |
| static int silence_generator_generate | ( | struct ast_channel * | chan, | |
| void * | data, | |||
| int | len, | |||
| int | samples | |||
| ) | [static] |
Definition at line 7478 of file channel.c.
References AST_FORMAT_SLINEAR, AST_FRAME_VOICE, ast_write(), and ast_frame::frametype.
07479 { 07480 short buf[samples]; 07481 struct ast_frame frame = { 07482 .frametype = AST_FRAME_VOICE, 07483 .subclass.codec = AST_FORMAT_SLINEAR, 07484 .data.ptr = buf, 07485 .samples = samples, 07486 .datalen = sizeof(buf), 07487 }; 07488 07489 memset(buf, 0, sizeof(buf)); 07490 07491 if (ast_write(chan, &frame)) 07492 return -1; 07493 07494 return 0; 07495 }
| static void silence_generator_release | ( | struct ast_channel * | chan, | |
| void * | data | |||
| ) | [static] |
| static void* tonepair_alloc | ( | struct ast_channel * | chan, | |
| void * | params | |||
| ) | [static] |
Definition at line 7079 of file channel.c.
References ast_calloc, AST_FLAG_WRITE_INT, AST_FORMAT_SLINEAR, ast_log(), ast_set_flag, ast_set_write_format(), cos, tonepair_def::duration, tonepair_state::duration, tonepair_state::fac1, tonepair_state::fac2, tonepair_def::freq1, tonepair_def::freq2, LOG_WARNING, M_PI, tonepair_state::modulate, ast_channel::name, tonepair_state::origwfmt, tonepair_release(), tonepair_state::v1_1, tonepair_state::v2_1, tonepair_state::v2_2, tonepair_state::v3_1, tonepair_state::v3_2, tonepair_def::vol, and ast_channel::writeformat.
07080 { 07081 struct tonepair_state *ts; 07082 struct tonepair_def *td = params; 07083 07084 if (!(ts = ast_calloc(1, sizeof(*ts)))) 07085 return NULL; 07086 ts->origwfmt = chan->writeformat; 07087 if (ast_set_write_format(chan, AST_FORMAT_SLINEAR)) { 07088 ast_log(LOG_WARNING, "Unable to set '%s' to signed linear format (write)\n", chan->name); 07089 tonepair_release(NULL, ts); 07090 ts = NULL; 07091 } else { 07092 ts->fac1 = 2.0 * cos(2.0 * M_PI * (td->freq1 / 8000.0)) * 32768.0; 07093 ts->v1_1 = 0; 07094 ts->v2_1 = sin(-4.0 * M_PI * (td->freq1 / 8000.0)) * td->vol; 07095 ts->v3_1 = sin(-2.0 * M_PI * (td->freq1 / 8000.0)) * td->vol; 07096 ts->v2_1 = 0; 07097 ts->fac2 = 2.0 * cos(2.0 * M_PI * (td->freq2 / 8000.0)) * 32768.0; 07098 ts->v2_2 = sin(-4.0 * M_PI * (td->freq2 / 8000.0)) * td->vol; 07099 ts->v3_2 = sin(-2.0 * M_PI * (td->freq2 / 8000.0)) * td->vol; 07100 ts->duration = td->duration; 07101 ts->modulate = 0; 07102 } 07103 /* Let interrupts interrupt :) */ 07104 ast_set_flag(chan, AST_FLAG_WRITE_INT); 07105 return ts; 07106 }
| static int tonepair_generator | ( | struct ast_channel * | chan, | |
| void * | data, | |||
| int | len, | |||
| int | samples | |||
| ) | [static] |
Definition at line 7108 of file channel.c.
References AST_FORMAT_SLINEAR, AST_FRAME_VOICE, AST_FRIENDLY_OFFSET, ast_log(), ast_write(), ast_frame_subclass::codec, ast_frame::data, tonepair_state::data, ast_frame::datalen, tonepair_state::duration, tonepair_state::f, tonepair_state::fac1, tonepair_state::fac2, ast_frame::frametype, LOG_WARNING, tonepair_state::modulate, ast_frame::offset, tonepair_state::pos, ast_frame::ptr, ast_frame::samples, ast_frame::subclass, tonepair_state::v1_1, tonepair_state::v1_2, tonepair_state::v2_1, tonepair_state::v2_2, tonepair_state::v3_1, and tonepair_state::v3_2.
07109 { 07110 struct tonepair_state *ts = data; 07111 int x; 07112 07113 /* we need to prepare a frame with 16 * timelen samples as we're 07114 * generating SLIN audio 07115 */ 07116 len = samples * 2; 07117 07118 if (len > sizeof(ts->data) / 2 - 1) { 07119 ast_log(LOG_WARNING, "Can't generate that much data!\n"); 07120 return -1; 07121 } 07122 memset(&ts->f, 0, sizeof(ts->f)); 07123 for (x=0;x<len/2;x++) { 07124 ts->v1_1 = ts->v2_1; 07125 ts->v2_1 = ts->v3_1; 07126 ts->v3_1 = (ts->fac1 * ts->v2_1 >> 15) - ts->v1_1; 07127 07128 ts->v1_2 = ts->v2_2; 07129 ts->v2_2 = ts->v3_2; 07130 ts->v3_2 = (ts->fac2 * ts->v2_2 >> 15) - ts->v1_2; 07131 if (ts->modulate) { 07132 int p; 07133 p = ts->v3_2 - 32768; 07134 if (p < 0) p = -p; 07135 p = ((p * 9) / 10) + 1; 07136 ts->data[x] = (ts->v3_1 * p) >> 15; 07137 } else 07138 ts->data[x] = ts->v3_1 + ts->v3_2; 07139 } 07140 ts->f.frametype = AST_FRAME_VOICE; 07141 ts->f.subclass.codec = AST_FORMAT_SLINEAR; 07142 ts->f.datalen = len; 07143 ts->f.samples = samples; 07144 ts->f.offset = AST_FRIENDLY_OFFSET; 07145 ts->f.data.ptr = ts->data; 07146 ast_write(chan, &ts->f); 07147 ts->pos += x; 07148 if (ts->duration > 0) { 07149 if (ts->pos >= ts->duration * 8) 07150 return -1; 07151 } 07152 return 0; 07153 }
| static void tonepair_release | ( | struct ast_channel * | chan, | |
| void * | params | |||
| ) | [static] |
Definition at line 7070 of file channel.c.
References ast_free, ast_set_write_format(), and tonepair_state::origwfmt.
Referenced by tonepair_alloc().
07071 { 07072 struct tonepair_state *ts = params; 07073 07074 if (chan) 07075 ast_set_write_format(chan, ts->origwfmt); 07076 ast_free(ts); 07077 }
| static void update_bridge_vars | ( | struct ast_channel * | c0, | |
| struct ast_channel * | c1 | |||
| ) | [static] |
Definition at line 6684 of file channel.c.
References ast_channel_lock, ast_channel_unlock, ast_strdupa, ast_strlen_zero(), ast_channel_tech::get_pvt_uniqueid, ast_channel::name, pbx_builtin_getvar_helper(), pbx_builtin_setvar_helper(), and ast_channel::tech.
Referenced by ast_channel_bridge().
06685 { 06686 const char *c0_name; 06687 const char *c1_name; 06688 const char *c0_pvtid = NULL; 06689 const char *c1_pvtid = NULL; 06690 06691 ast_channel_lock(c1); 06692 c1_name = ast_strdupa(c1->name); 06693 if (c1->tech->get_pvt_uniqueid) { 06694 c1_pvtid = ast_strdupa(c1->tech->get_pvt_uniqueid(c1)); 06695 } 06696 ast_channel_unlock(c1); 06697 06698 ast_channel_lock(c0); 06699 if (!ast_strlen_zero(pbx_builtin_getvar_helper(c0, "BRIDGEPEER"))) { 06700 pbx_builtin_setvar_helper(c0, "BRIDGEPEER", c1_name); 06701 } 06702 if (c1_pvtid) { 06703 pbx_builtin_setvar_helper(c0, "BRIDGEPVTCALLID", c1_pvtid); 06704 } 06705 c0_name = ast_strdupa(c0->name); 06706 if (c0->tech->get_pvt_uniqueid) { 06707 c0_pvtid = ast_strdupa(c0->tech->get_pvt_uniqueid(c0)); 06708 } 06709 ast_channel_unlock(c0); 06710 06711 ast_channel_lock(c1); 06712 if (!ast_strlen_zero(pbx_builtin_getvar_helper(c1, "BRIDGEPEER"))) { 06713 pbx_builtin_setvar_helper(c1, "BRIDGEPEER", c0_name); 06714 } 06715 if (c0_pvtid) { 06716 pbx_builtin_setvar_helper(c1, "BRIDGEPVTCALLID", c0_pvtid); 06717 } 06718 ast_channel_unlock(c1); 06719 }
void(* ast_moh_cleanup_ptr)(struct ast_channel *) = NULL [static] |
Referenced by ast_install_music_functions(), ast_moh_cleanup(), and ast_uninstall_music_functions().
int(* ast_moh_start_ptr)(struct ast_channel *, const char *, const char *) = NULL [static] |
Referenced by ast_install_music_functions(), ast_moh_start(), and ast_uninstall_music_functions().
void(* ast_moh_stop_ptr)(struct ast_channel *) = NULL [static] |
Referenced by ast_install_music_functions(), ast_moh_stop(), and ast_uninstall_music_functions().
| int cause |
Definition at line 198 of file channel.c.
Referenced by __ast_read(), __ast_request_and_dial(), action_hangup(), ast_call_forward(), ast_str2cause(), cb_events(), dial_exec_full(), dial_transfer(), do_forward(), dump_cause(), feature_request_and_dial(), oh323_hangup(), ospfinished_exec(), ospnext_exec(), parse_disconnect(), parse_release(), parse_release_complete(), parse_status(), pbx_builtin_hangup(), play_sound_file(), sig_pri_hangup(), sig_ss7_hangup(), sms_messagerx(), and sms_messagerx2().
struct { ... } causes[] [static] |
map AST_CAUSE's to readable string representations
Referenced by ast_cause2str(), ast_str2cause(), and dump_cause().
struct ast_datastore_info cc_channel_datastore_info [static] |
Initial value:
{
.type = "Call Completion",
.duplicate = channel_cc_params_copy,
.destroy = channel_cc_params_destroy,
}
struct ast_data_entry channel_providers[] [static] |
Initial value:
{
AST_DATA_ENTRY("/asterisk/core/channels", &channels_provider),
AST_DATA_ENTRY("/asterisk/core/channeltypes", &channeltypes_provider),
}
struct ao2_container* channels [static] |
All active channels on the system.
Definition at line 191 of file channel.c.
Referenced by __ast_channel_alloc_ap(), ast_active_channels(), ast_begin_shutdown(), ast_change_name(), ast_channel_callback(), ast_channel_get_full(), ast_channel_iterator_all_new(), ast_channel_release(), ast_channels_init(), ast_do_masquerade(), ast_hangup(), and channel_iterator_search().
struct ast_data_handler channels_provider [static] |
Initial value:
{
.version = AST_DATA_HANDLER_VERSION,
.get = data_channels_provider_handler
}
struct ast_data_handler channeltypes_provider [static] |
Initial value:
{
.version = AST_DATA_HANDLER_VERSION,
.get = data_channeltypes_provider_handler
}
struct ast_cli_entry cli_channel[] [static] |
Initial value:
{
AST_CLI_DEFINE(handle_cli_core_show_channeltypes, "List available channel types"),
AST_CLI_DEFINE(handle_cli_core_show_channeltype, "Give more details on that channel type")
}
Definition at line 610 of file channel.c.
Referenced by ast_channels_init().
| const char* desc |
Definition at line 200 of file channel.c.
Referenced by acf_retrieve_docs(), ast_data_add_codecs(), ast_tcptls_client_start(), ast_tcptls_server_root(), dump_cause(), handle_cli_ulimit(), init_acf_query(), load_rpt_vars(), misdn_cfg_get_desc(), show_config_description(), and str2desc().
| unsigned long global_fin |
The current value of the debug flags is stored in the two variables global_fin and global_fout (declared in main/channel.c)
Definition at line 98 of file channel.c.
Referenced by handle_core_set_debug_channel().
| unsigned long global_fout |
struct ast_channel_tech null_tech [static] |
Initial value:
{
.type = "NULL",
.description = "Null channel (should not see this)",
}
Definition at line 1050 of file channel.c.
Referenced by __ast_channel_alloc_ap().
struct ast_datastore_info plc_ds_info [static] |
Initial value:
{
.type = "plc",
.destroy = plc_ds_destroy,
}
int shutting_down [static] |
struct ast_generator silence_generator [static] |
Initial value:
{
.alloc = silence_generator_alloc,
.release = silence_generator_release,
.generate = silence_generator_generate,
}
struct ast_threadstorage state2str_threadbuf = { .once = PTHREAD_ONCE_INIT , .key_init = __init_state2str_threadbuf , .custom_init = NULL , } [static] |
struct ast_generator tonepair [static] |
Initial value:
{
alloc: tonepair_alloc,
release: tonepair_release,
generate: tonepair_generator,
}
1.5.9