#include "asterisk/abstract_jb.h"
#include <unistd.h>
#include <sys/poll.h>
#include "asterisk/compat.h"
#include "asterisk/frame.h"
#include "asterisk/sched.h"
#include "asterisk/chanvars.h"
#include "asterisk/config.h"
#include "asterisk/lock.h"
#include "asterisk/cdr.h"
#include "asterisk/utils.h"
#include "asterisk/linkedlists.h"
#include "asterisk/stringfields.h"
#include "asterisk/options.h"
#include "asterisk/strings.h"
#include "asterisk/compiler.h"

Go to the source code of this file.
Data Structures | |
| struct | ast_bridge_config |
| struct | ast_callerid |
| Structure for all kinds of caller ID identifications. More... | |
| struct | ast_channel |
| Main Channel structure associated with a channel. This is the side of it mostly used by the pbx and call management. More... | |
| struct | ast_channel_tech |
| Structure to describe a channel "technology", ie a channel driver See for examples:. More... | |
| struct | ast_datastore |
| Structure for a channel data store. More... | |
| struct | ast_datastore_info |
| Structure for a data store type. More... | |
| struct | ast_generator |
| struct | datastores |
| Data stores on the channel. More... | |
| struct | outgoing_helper |
Defines | |
| #define | AST_AGENT_FD (AST_MAX_FDS-3) |
| #define | AST_ALERT_FD (AST_MAX_FDS-1) |
| #define | AST_BRIDGE_DTMF_CHANNEL_0 (1 << 0) |
| Report DTMF on channel 0. | |
| #define | AST_BRIDGE_DTMF_CHANNEL_1 (1 << 1) |
| Report DTMF on channel 1. | |
| #define | AST_BRIDGE_IGNORE_SIGS (1 << 4) |
| Ignore all signal frames except NULL. | |
| #define | AST_BRIDGE_REC_CHANNEL_0 (1 << 2) |
| Return all voice frames on channel 0. | |
| #define | AST_BRIDGE_REC_CHANNEL_1 (1 << 3) |
| Return all voice frames on channel 1. | |
| #define | AST_CHANNEL_NAME 80 |
| #define | AST_GENERATOR_FD (AST_MAX_FDS-4) |
| #define | AST_MAX_CONTEXT 80 |
| #define | AST_MAX_EXTENSION 80 |
| #define | AST_MAX_FDS 8 |
| #define | AST_TIMING_FD (AST_MAX_FDS-2) |
| #define | CHECK_BLOCKING(c) |
| #define | DATASTORE_INHERIT_FOREVER INT_MAX |
| #define | DEBUGCHAN_FLAG 0x80000000 |
| #define | FRAMECOUNT_INC(x) ( ((x) & DEBUGCHAN_FLAG) | (((x)+1) & ~DEBUGCHAN_FLAG) ) |
| #define | LOAD_OH(oh) |
| #define | MAX_LANGUAGE 20 |
| #define | MAX_MUSICCLASS 80 |
Typedefs | |
| typedef unsigned long long | ast_group_t |
Enumerations | |
| enum | { AST_CHAN_TP_WANTSJITTER = (1 << 0), AST_CHAN_TP_CREATESJITTER = (1 << 1) } |
| ast_channel_tech Properties More... | |
| enum | { AST_FLAG_DEFER_DTMF = (1 << 1), AST_FLAG_WRITE_INT = (1 << 2), AST_FLAG_BLOCKING = (1 << 3), AST_FLAG_ZOMBIE = (1 << 4), AST_FLAG_EXCEPTION = (1 << 5), AST_FLAG_MOH = (1 << 6), AST_FLAG_SPYING = (1 << 7), AST_FLAG_NBRIDGE = (1 << 8), AST_FLAG_IN_AUTOLOOP = (1 << 9), AST_FLAG_OUTGOING = (1 << 10), AST_FLAG_WHISPER = (1 << 11), AST_FLAG_IN_DTMF = (1 << 12), AST_FLAG_EMULATE_DTMF = (1 << 13), AST_FLAG_END_DTMF_ONLY = (1 << 14), AST_FLAG_MASQ_NOSTREAM = (1 << 15), AST_FLAG_BRIDGE_HANGUP_RUN = (1 << 16) } |
| ast_channel flags More... | |
| enum | { AST_FEATURE_PLAY_WARNING = (1 << 0), AST_FEATURE_REDIRECT = (1 << 1), AST_FEATURE_DISCONNECT = (1 << 2), AST_FEATURE_ATXFER = (1 << 3), AST_FEATURE_AUTOMON = (1 << 4), AST_FEATURE_PARKCALL = (1 << 5), AST_FEATURE_NO_H_EXTEN = (1 << 6) } |
| ast_bridge_config flags More... | |
| enum | { AST_CDR_TRANSFER = (1 << 0), AST_CDR_FORWARD = (1 << 1), AST_CDR_CALLWAIT = (1 << 2), AST_CDR_CONFERENCE = (1 << 3) } |
| enum | { AST_SOFTHANGUP_DEV = (1 << 0), AST_SOFTHANGUP_ASYNCGOTO = (1 << 1), AST_SOFTHANGUP_SHUTDOWN = (1 << 2), AST_SOFTHANGUP_TIMEOUT = (1 << 3), AST_SOFTHANGUP_APPUNLOAD = (1 << 4), AST_SOFTHANGUP_EXPLICIT = (1 << 5), AST_SOFTHANGUP_UNBRIDGE = (1 << 6) } |
| enum | ast_bridge_result { AST_BRIDGE_COMPLETE = 0, AST_BRIDGE_FAILED = -1, AST_BRIDGE_FAILED_NOWARN = -2, AST_BRIDGE_RETRY = -3 } |
| enum | ast_channel_adsicpe { AST_ADSI_UNKNOWN, AST_ADSI_AVAILABLE, AST_ADSI_UNAVAILABLE, AST_ADSI_OFFHOOKONLY } |
| enum | ast_channel_state { AST_STATE_DOWN, AST_STATE_RESERVED, AST_STATE_OFFHOOK, AST_STATE_DIALING, AST_STATE_RING, AST_STATE_RINGING, AST_STATE_UP, AST_STATE_BUSY, AST_STATE_DIALING_OFFHOOK, AST_STATE_PRERING, AST_STATE_MUTE = (1 << 16) } |
| ast_channel states More... | |
| enum | channelreloadreason { CHANNEL_MODULE_LOAD, CHANNEL_MODULE_RELOAD, CHANNEL_CLI_RELOAD, CHANNEL_MANAGER_RELOAD } |
| Channel reload reasons for manager events at load or reload of configuration. More... | |
Functions | |
| struct ast_channel * | __ast_request_and_dial (const char *type, int format, void *data, int timeout, int *reason, const char *cidnum, const char *cidname, struct outgoing_helper *oh) |
| 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 | |
| static int | ast_add_fd (struct pollfd *pfd, int fd) |
| if fd is a valid descriptor, set *pfd with the descriptor | |
| int | ast_answer (struct ast_channel *chan) |
| Answer a ringing call. | |
| int | ast_autoservice_start (struct ast_channel *chan) |
| Automatically service a channel for us... | |
| int | ast_autoservice_stop (struct ast_channel *chan) |
| Stop servicing a channel for us... | |
| void | ast_begin_shutdown (int hangup) |
| Initiate system shutdown. | |
| int | ast_best_codec (int 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. | |
| void | ast_cancel_shutdown (void) |
| Cancel a shutdown in progress. | |
| const char * | ast_cause2str (int state) attribute_pure |
| Gives the string form of a given hangup cause. | |
| void | ast_change_name (struct ast_channel *chan, 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 int amaflag, const char *name_fmt,...) |
| Create a channel structure. | |
| static int | ast_channel_best_codec (struct ast_channel *channel) |
| Pick the best codec from channel nativeformats. | |
| int | 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. | |
| 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_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, char *uid) |
| Create a channel datastore structure. | |
| struct ast_datastore * | ast_channel_datastore_find (struct ast_channel *chan, const struct ast_datastore_info *info, char *uid) |
| Find a datastore on a channel. | |
| int | ast_channel_datastore_free (struct ast_datastore *datastore) |
| Free a channel datastore structure. | |
| 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_formats_reset (struct ast_channel *channel) |
| void | ast_channel_free (struct ast_channel *) |
| Free a channel structure. | |
| static const char * | ast_channel_getformatname (struct ast_channel *chan) |
| static char * | ast_channel_getformatname_multiple (char *buf, size_t size, struct ast_channel *chan) |
| Get the names of a set of formats. | |
| void | ast_channel_inherit_variables (const struct ast_channel *parent, struct ast_channel *child) |
| Inherits channel variable from parent to child channel. | |
| int | ast_channel_make_compatible (struct ast_channel *c0, struct ast_channel *c1) |
| Makes two channel formats compatible. | |
| int | ast_channel_masquerade (struct ast_channel *original, struct ast_channel *clone) |
| Weird function made for call transfers. | |
| struct ast_frame * | ast_channel_queryoption (struct ast_channel *channel, int option, void *data, int *datalen, int block) |
| 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_register (const struct ast_channel_tech *tech) |
| Register a channel technology (a new channel driver) Called by a channel module to register the kind of channels it supports. | |
| int | ast_channel_sendhtml (struct ast_channel *channel, int subclass, const char *data, int datalen) |
| int | ast_channel_sendurl (struct ast_channel *channel, const char *url) |
| int | ast_channel_setoption (struct ast_channel *channel, 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. | |
| 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 *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 a channel technology. | |
| struct ast_channel * | ast_channel_walk_locked (const struct ast_channel *prev) |
| Browse channels in use Browse the channels currently in use. | |
| int | ast_channel_whisper_feed (struct ast_channel *chan, struct ast_frame *f) |
| Feed an audio frame into the whisper buffer on a channel. | |
| int | ast_channel_whisper_start (struct ast_channel *chan) |
| Begin 'whispering' onto a channel. | |
| void | ast_channel_whisper_stop (struct ast_channel *chan) |
| Stop 'whispering' onto a channel. | |
| struct ast_variable * | ast_channeltype_list (void) |
| return an ast_variable list of channeltypes | |
| int | ast_check_hangup (struct ast_channel *chan) |
| Check to see if a channel is needing hang up. | |
| void | ast_deactivate_generator (struct ast_channel *chan) |
| int | ast_do_masquerade (struct ast_channel *chan) |
| Start masquerading a channel XXX This is a seriously wacked out operation. We're essentially putting the guts of the clone channel into the original channel. Start by killing off the original channel's backend. I'm not sure we're going to keep this function, because while the features are nice, the cost is very high in terms of pure nastiness. XXX. | |
| static int | ast_fdisset (struct pollfd *pfds, int fd, int max, int *start) |
| Helper function for migrating select to poll. | |
| struct ast_channel * | ast_get_channel_by_exten_locked (const char *exten, const char *context) |
| Get channel by exten (and optionally context) and lock it. | |
| struct ast_channel * | ast_get_channel_by_name_locked (const char *chan) |
| Get channel by name (locks channel). | |
| struct ast_channel * | ast_get_channel_by_name_prefix_locked (const char *name, const int namelen) |
| Get channel by name prefix (locks channel). | |
| struct ast_channel_tech * | ast_get_channel_tech (const char *name) |
| Get a channel technology structure by name. | |
| ast_group_t | ast_get_group (const char *s) |
| static int | ast_get_read_format (struct ast_channel *chan) |
| Gets read format from channel chan. | |
| static int | ast_get_write_format (struct ast_channel *chan) |
| int | ast_hangup (struct ast_channel *chan) |
| Hang up 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. | |
| int | ast_internal_timing_enabled (struct ast_channel *chan) |
| Check if the channel can run in internal timing mode. | |
| char * | ast_print_group (char *buf, int buflen, ast_group_t group) |
| print call- and pickup groups into buffer | |
| 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 with payload. | |
| 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 *f) |
| Queue an outgoing frame. | |
| int | ast_queue_frame_head (struct ast_channel *chan, struct ast_frame *f) |
| Queue an outgoing frame to the head of the frame queue. | |
| int | ast_queue_hangup (struct ast_channel *chan) |
| Queue a hangup frame. | |
| struct ast_frame * | ast_read (struct ast_channel *chan) |
| Reads a frame. | |
| struct ast_frame * | ast_read_noaudio (struct ast_channel *chan) |
| Reads a frame, returning AST_FRAME_NULL frame if audio. Read a frame. | |
| int | ast_readstring (struct ast_channel *c, char *s, int len, int timeout, int rtimeout, char *enders) |
| int | ast_readstring_full (struct ast_channel *c, char *s, int len, int timeout, int rtimeout, 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. | |
| struct ast_channel * | ast_request (const char *type, int format, void *data, int *status) |
| Requests a channel. | |
| struct ast_channel * | ast_request_and_dial (const char *type, int format, void *data, int timeout, int *reason, 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. | |
| static struct ast_channel * | ast_request_inherit (struct ast_channel *chan, const char *type, void *data, int *status) |
| call ast_request with format/type of parent channel | |
| int | ast_safe_sleep (struct ast_channel *chan, int ms) |
| Wait for a specied amount of time, looking for hangups. | |
| int | ast_safe_sleep_conditional (struct ast_channel *chan, int ms, int(*cond)(void *), void *data) |
| Wait for a specied amount of time, looking for hangups and a condition argument. | |
| char * | ast_safe_string_alloc (const char *fmt,...) |
| printf the string into a correctly sized mallocd buffer, and return the buffer | |
| static int | ast_select (int nfds, fd_set *rfds, fd_set *wfds, fd_set *efds, struct timeval *tvp) |
| Waits for activity on a group of channels. | |
| int | ast_senddigit (struct ast_channel *chan, char digit) |
| Send a DTMF digit to a channel Send a DTMF digit to a channel. | |
| int | ast_senddigit_begin (struct ast_channel *chan, char digit) |
| int | ast_senddigit_end (struct ast_channel *chan, char digit, unsigned int duration) |
| int | ast_sendtext (struct ast_channel *chan, const char *text) |
| Sends text to a channel Write text to a display on a channel. | |
| static void | ast_set_best_format (struct ast_channel *channel) |
| Set best format, identical to read/write. | |
| void | ast_set_callerid (struct ast_channel *chan, const char *cidnum, const char *cidname, const char *ani) |
| int | ast_set_read_format (struct ast_channel *chan, int format) |
| 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, int format) |
| Sets write format on channel chan Set write format for channel to whichever compoent of "format" is best. | |
| int | ast_setstate (struct ast_channel *chan, enum ast_channel_state) |
| Change the state of a channel. | |
| int | ast_settimeout (struct ast_channel *c, int samples, int(*func)(const void *data), void *data) |
| 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 up a channel. | |
| int | ast_softhangup_nolock (struct ast_channel *chan, int cause) |
| Softly hangup up a channel (no channel lock). | |
| char * | ast_state2str (enum ast_channel_state) |
| Gives the string form of a given channel state. | |
| int | ast_str2cause (const char *name) attribute_pure |
| 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 channel (if supported). Returns -1 on error, 0 if not supported and 1 if supported and requested. | |
| char * | ast_transfercapability2str (int transfercapability) attribute_const |
| Gives the string form of a given transfer capability. | |
| int | ast_waitfor (struct ast_channel *chan, int ms) |
| Wait for input on a channel. | |
| struct ast_channel * | ast_waitfor_n (struct ast_channel **chan, 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) |
| Waits for input on an fd This version works on fd's only. Be careful with it. | |
| struct ast_channel * | ast_waitfor_nandfds (struct ast_channel **chan, int n, int *fds, int nfds, int *exception, int *outfd, int *ms) |
| Waits for activity on a group of channels. | |
| 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 ctrlfd) |
| Wait for a digit Same as ast_waitfordigit() with audio fd for outputting read audio and ctrlfd to monitor for reading. | |
| struct ast_channel * | ast_walk_channel_by_exten_locked (const struct ast_channel *chan, const char *exten, const char *context) |
| Get next channel by exten (and optionally context) and lock it. | |
| struct ast_channel * | ast_walk_channel_by_name_prefix_locked (const struct ast_channel *chan, const char *name, const int namelen) |
| Get channel by name prefix (locks channel). | |
| 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. | |
| 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. | |
| const char * | channelreloadreason2txt (enum channelreloadreason reason) |
| Convert enum channelreloadreason to text string for manager event. | |
Definition in file channel.h.
| #define AST_AGENT_FD (AST_MAX_FDS-3) |
used by agents for pass through
Definition at line 132 of file channel.h.
Referenced by agent_read().
| #define AST_ALERT_FD (AST_MAX_FDS-1) |
used for alertpipe
Definition at line 130 of file channel.h.
Referenced by ast_channel_alloc(), and restore_channel().
| #define AST_BRIDGE_DTMF_CHANNEL_0 (1 << 0) |
Report DTMF on channel 0.
Definition at line 1051 of file channel.h.
Referenced by ast_generic_bridge(), ast_rtp_bridge(), bridge_native_loop(), bridge_p2p_loop(), dahdi_bridge(), iax2_bridge(), misdn_bridge(), and set_config_flags().
| #define AST_BRIDGE_DTMF_CHANNEL_1 (1 << 1) |
Report DTMF on channel 1.
Definition at line 1053 of file channel.h.
Referenced by ast_generic_bridge(), ast_rtp_bridge(), bridge_native_loop(), bridge_p2p_loop(), dahdi_bridge(), iax2_bridge(), misdn_bridge(), and set_config_flags().
| #define AST_BRIDGE_IGNORE_SIGS (1 << 4) |
Ignore all signal frames except NULL.
Definition at line 1059 of file channel.h.
Referenced by ast_generic_bridge(), bridge_native_loop(), bridge_p2p_loop(), and iax2_bridge().
| #define AST_BRIDGE_REC_CHANNEL_0 (1 << 2) |
| #define AST_BRIDGE_REC_CHANNEL_1 (1 << 3) |
| #define AST_CHANNEL_NAME 80 |
Max length of an ast_channel name
Definition at line 105 of file channel.h.
Referenced by agent_devicestate_cb(), ast_channel_free(), ast_parse_device_state(), ast_setstate(), create_jb(), fast_originate(), next_channel(), page_exec(), park_call_full(), and softhangup_exec().
| #define AST_GENERATOR_FD (AST_MAX_FDS-4) |
used by generator
Definition at line 133 of file channel.h.
Referenced by __ast_read(), ast_deactivate_generator(), and ast_do_masquerade().
| #define AST_MAX_CONTEXT 80 |
Max length of a context
Definition at line 104 of file channel.h.
Referenced by _macro_exec(), cleanup_stale_contexts(), conf_run(), gosub_exec(), gtalk_load_config(), reload_config(), and try_calling().
| #define AST_MAX_EXTENSION 80 |
Max length of an extension
Definition at line 103 of file channel.h.
Referenced by add_extensions(), advanced_options(), ast_bridge_call(), ast_device_state_changed(), ast_extension_state2(), ast_hint_state_changed(), ast_ivr_menu_run_internal(), begin_dial(), conf_run(), destroy_station(), disa_exec(), do_parking_thread(), dundi_lookup_local(), forward_message(), function_enum(), get_destination(), gosub_exec(), load_config(), log_exec(), mgcp_ss(), ooh323_call(), park_add_hints(), park_call_exec(), phone_check_exception(), realtime_switch_common(), show_dialplan_helper(), skinny_answer(), skinny_indicate(), skinny_ss(), sla_build_station(), speech_background(), ss_thread(), transmit_state_notify(), try_calling(), vm_authenticate(), vmauthenticate(), and wait_for_answer().
| #define AST_MAX_FDS 8 |
Definition at line 125 of file channel.h.
Referenced by ast_channel_alloc(), ast_do_masquerade(), ast_waitfor_nandfds(), do_parking_thread(), and update_features().
| #define AST_TIMING_FD (AST_MAX_FDS-2) |
used for timingfd
Definition at line 131 of file channel.h.
Referenced by __ast_read(), agent_read(), ast_channel_alloc(), ast_do_masquerade(), and restore_channel().
| #define CHECK_BLOCKING | ( | c | ) |
Definition at line 1463 of file channel.h.
Referenced by ast_sendtext(), ast_waitfor_nandfds(), ast_write(), dahdi_read(), and phone_read().
| #define DATASTORE_INHERIT_FOREVER INT_MAX |
Definition at line 123 of file channel.h.
Referenced by _macro_exec(), ast_channel_datastore_inherit(), and try_calling().
| #define DEBUGCHAN_FLAG 0x80000000 |
Definition at line 299 of file channel.h.
Referenced by __ast_read(), ast_write(), handle_core_set_debug_channel(), handle_debugchan_deprecated(), handle_nodebugchan_deprecated(), handle_showchan(), handle_showchan_deprecated(), and serialize_showchan().
| #define FRAMECOUNT_INC | ( | x | ) | ( ((x) & DEBUGCHAN_FLAG) | (((x)+1) & ~DEBUGCHAN_FLAG) ) |
| #define LOAD_OH | ( | oh | ) |
| #define MAX_LANGUAGE 20 |
| #define MAX_MUSICCLASS 80 |
| typedef unsigned long long ast_group_t |
| anonymous enum |
ast_channel_tech Properties
| AST_CHAN_TP_WANTSJITTER | Channels have this property if they can accept input with jitter; i.e. most VoIP channels. |
| AST_CHAN_TP_CREATESJITTER | Channels have this property if they can create jitter; i.e. most VoIP channels. |
Definition at line 469 of file channel.h.
00469 { 00470 /*! \brief Channels have this property if they can accept input with jitter; 00471 * i.e. most VoIP channels */ 00472 AST_CHAN_TP_WANTSJITTER = (1 << 0), 00473 /*! \brief Channels have this property if they can create jitter; 00474 * i.e. most VoIP channels */ 00475 AST_CHAN_TP_CREATESJITTER = (1 << 1), 00476 };
| anonymous enum |
ast_channel flags
| AST_FLAG_DEFER_DTMF | Queue incoming dtmf, to be released when this flag is turned off |
| AST_FLAG_WRITE_INT | write should be interrupt generator |
| AST_FLAG_BLOCKING | a thread is blocking on this channel |
| AST_FLAG_ZOMBIE | This is a zombie channel |
| AST_FLAG_EXCEPTION | There is an exception pending |
| AST_FLAG_MOH | Listening to moh XXX anthm promises me this will disappear XXX |
| AST_FLAG_SPYING | This channel is spying on another channel |
| AST_FLAG_NBRIDGE | This channel is in a native bridge |
| AST_FLAG_IN_AUTOLOOP | the channel is in an auto-incrementing dialplan processor, so when ->priority is set, it will get incremented before finding the next priority to run |
| AST_FLAG_OUTGOING | This is an outgoing call |
| AST_FLAG_WHISPER | This channel is being whispered on |
| AST_FLAG_IN_DTMF | A DTMF_BEGIN frame has been read from this channel, but not yet an END |
| AST_FLAG_EMULATE_DTMF | A DTMF_END was received when not IN_DTMF, so the length of the digit is currently being emulated |
| AST_FLAG_END_DTMF_ONLY | This is set to tell the channel not to generate DTMF begin frames, and to instead only generate END frames. |
| AST_FLAG_MASQ_NOSTREAM | This flag indicates that on a masquerade, an active stream should not be carried over |
| AST_FLAG_BRIDGE_HANGUP_RUN | This flag indicates that the hangup exten was run when the bridge terminated, a message aimed at preventing a subsequent hangup exten being run at the pbx_run level |
Definition at line 479 of file channel.h.
00479 { 00480 /*! Queue incoming dtmf, to be released when this flag is turned off */ 00481 AST_FLAG_DEFER_DTMF = (1 << 1), 00482 /*! write should be interrupt generator */ 00483 AST_FLAG_WRITE_INT = (1 << 2), 00484 /*! a thread is blocking on this channel */ 00485 AST_FLAG_BLOCKING = (1 << 3), 00486 /*! This is a zombie channel */ 00487 AST_FLAG_ZOMBIE = (1 << 4), 00488 /*! There is an exception pending */ 00489 AST_FLAG_EXCEPTION = (1 << 5), 00490 /*! Listening to moh XXX anthm promises me this will disappear XXX */ 00491 AST_FLAG_MOH = (1 << 6), 00492 /*! This channel is spying on another channel */ 00493 AST_FLAG_SPYING = (1 << 7), 00494 /*! This channel is in a native bridge */ 00495 AST_FLAG_NBRIDGE = (1 << 8), 00496 /*! the channel is in an auto-incrementing dialplan processor, 00497 * so when ->priority is set, it will get incremented before 00498 * finding the next priority to run */ 00499 AST_FLAG_IN_AUTOLOOP = (1 << 9), 00500 /*! This is an outgoing call */ 00501 AST_FLAG_OUTGOING = (1 << 10), 00502 /*! This channel is being whispered on */ 00503 AST_FLAG_WHISPER = (1 << 11), 00504 /*! A DTMF_BEGIN frame has been read from this channel, but not yet an END */ 00505 AST_FLAG_IN_DTMF = (1 << 12), 00506 /*! A DTMF_END was received when not IN_DTMF, so the length of the digit is 00507 * currently being emulated */ 00508 AST_FLAG_EMULATE_DTMF = (1 << 13), 00509 /*! This is set to tell the channel not to generate DTMF begin frames, and 00510 * to instead only generate END frames. */ 00511 AST_FLAG_END_DTMF_ONLY = (1 << 14), 00512 /*! This flag indicates that on a masquerade, an active stream should not 00513 * be carried over */ 00514 AST_FLAG_MASQ_NOSTREAM = (1 << 15), 00515 /*! This flag indicates that the hangup exten was run when the bridge terminated, 00516 * a message aimed at preventing a subsequent hangup exten being run at the pbx_run 00517 * level */ 00518 AST_FLAG_BRIDGE_HANGUP_RUN = (1 << 16), 00519 };
| anonymous enum |
ast_bridge_config flags
| AST_FEATURE_PLAY_WARNING | |
| AST_FEATURE_REDIRECT | |
| AST_FEATURE_DISCONNECT | |
| AST_FEATURE_ATXFER | |
| AST_FEATURE_AUTOMON | |
| AST_FEATURE_PARKCALL | |
| AST_FEATURE_NO_H_EXTEN |
Definition at line 522 of file channel.h.
00522 { 00523 AST_FEATURE_PLAY_WARNING = (1 << 0), 00524 AST_FEATURE_REDIRECT = (1 << 1), 00525 AST_FEATURE_DISCONNECT = (1 << 2), 00526 AST_FEATURE_ATXFER = (1 << 3), 00527 AST_FEATURE_AUTOMON = (1 << 4), 00528 AST_FEATURE_PARKCALL = (1 << 5), 00529 AST_FEATURE_NO_H_EXTEN = (1 << 6), 00530 };
| anonymous enum |
Definition at line 577 of file channel.h.
00577 { 00578 AST_CDR_TRANSFER = (1 << 0), 00579 AST_CDR_FORWARD = (1 << 1), 00580 AST_CDR_CALLWAIT = (1 << 2), 00581 AST_CDR_CONFERENCE = (1 << 3), 00582 };
| anonymous enum |
Definition at line 584 of file channel.h.
00584 { 00585 /*! Soft hangup by device */ 00586 AST_SOFTHANGUP_DEV = (1 << 0), 00587 /*! Soft hangup for async goto */ 00588 AST_SOFTHANGUP_ASYNCGOTO = (1 << 1), 00589 AST_SOFTHANGUP_SHUTDOWN = (1 << 2), 00590 AST_SOFTHANGUP_TIMEOUT = (1 << 3), 00591 AST_SOFTHANGUP_APPUNLOAD = (1 << 4), 00592 AST_SOFTHANGUP_EXPLICIT = (1 << 5), 00593 AST_SOFTHANGUP_UNBRIDGE = (1 << 6), 00594 };
| enum ast_bridge_result |
Definition at line 135 of file channel.h.
00135 { 00136 AST_BRIDGE_COMPLETE = 0, 00137 AST_BRIDGE_FAILED = -1, 00138 AST_BRIDGE_FAILED_NOWARN = -2, 00139 AST_BRIDGE_RETRY = -3, 00140 };
| enum ast_channel_adsicpe |
Definition at line 302 of file channel.h.
00302 { 00303 AST_ADSI_UNKNOWN, 00304 AST_ADSI_AVAILABLE, 00305 AST_ADSI_UNAVAILABLE, 00306 AST_ADSI_OFFHOOKONLY, 00307 };
| enum ast_channel_state |
ast_channel states
Definition at line 315 of file channel.h.
00315 { 00316 /*! Channel is down and available */ 00317 AST_STATE_DOWN, 00318 /*! Channel is down, but reserved */ 00319 AST_STATE_RESERVED, 00320 /*! Channel is off hook */ 00321 AST_STATE_OFFHOOK, 00322 /*! Digits (or equivalent) have been dialed */ 00323 AST_STATE_DIALING, 00324 /*! Line is ringing */ 00325 AST_STATE_RING, 00326 /*! Remote end is ringing */ 00327 AST_STATE_RINGING, 00328 /*! Line is up */ 00329 AST_STATE_UP, 00330 /*! Line is busy */ 00331 AST_STATE_BUSY, 00332 /*! Digits (or equivalent) have been dialed while offhook */ 00333 AST_STATE_DIALING_OFFHOOK, 00334 /*! Channel has detected an incoming call and is waiting for ring */ 00335 AST_STATE_PRERING, 00336 00337 /*! Do not transmit voice data */ 00338 AST_STATE_MUTE = (1 << 16), 00339 };
| enum channelreloadreason |
Channel reload reasons for manager events at load or reload of configuration.
Definition at line 598 of file channel.h.
00598 { 00599 CHANNEL_MODULE_LOAD, 00600 CHANNEL_MODULE_RELOAD, 00601 CHANNEL_CLI_RELOAD, 00602 CHANNEL_MANAGER_RELOAD, 00603 };
| struct ast_channel* __ast_request_and_dial | ( | const char * | type, | |
| int | format, | |||
| void * | data, | |||
| int | timeout, | |||
| int * | reason, | |||
| const char * | cidnum, | |||
| const char * | cidname, | |||
| struct outgoing_helper * | oh | |||
| ) | [read] |
Definition at line 3000 of file channel.c.
References ast_channel::_state, outgoing_helper::account, ast_call(), AST_CAUSE_BUSY, AST_CAUSE_CONGESTION, AST_CAUSE_NO_ANSWER, ast_cdr_alloc(), ast_cdr_disposition(), ast_cdr_end(), ast_cdr_failed(), ast_cdr_init(), ast_cdr_setaccount(), ast_cdr_setapp(), ast_cdr_start(), ast_cdr_update(), ast_channel_inherit_variables(), AST_CONTROL_ANSWER, AST_CONTROL_BUSY, AST_CONTROL_CONGESTION, AST_CONTROL_HANGUP, AST_CONTROL_HOLD, AST_CONTROL_PROCEEDING, AST_CONTROL_PROGRESS, AST_CONTROL_RINGING, AST_CONTROL_SRCUPDATE, AST_CONTROL_UNHOLD, AST_CONTROL_VIDUPDATE, ast_copy_string(), AST_FRAME_CONTROL, ast_frfree, ast_hangup(), ast_log(), ast_read(), ast_request(), ast_set_callerid(), ast_set_variables(), AST_STATE_UP, ast_strlen_zero(), ast_waitfor(), ast_channel::cdr, outgoing_helper::cid_name, outgoing_helper::cid_num, ast_channel::context, outgoing_helper::context, ast_channel::exten, outgoing_helper::exten, f, ast_frame::frametype, ast_channel::hangupcause, LOG_NOTICE, outgoing_helper::parent_channel, ast_channel::priority, outgoing_helper::priority, ast_frame::subclass, and outgoing_helper::vars.
Referenced by ast_pbx_outgoing_app(), ast_pbx_outgoing_exten(), ast_request_and_dial(), and parkandannounce_exec().
03001 { 03002 int dummy_outstate; 03003 int cause = 0; 03004 struct ast_channel *chan; 03005 int res = 0; 03006 int last_subclass = 0; 03007 03008 if (outstate) 03009 *outstate = 0; 03010 else 03011 outstate = &dummy_outstate; /* make outstate always a valid pointer */ 03012 03013 chan = ast_request(type, format, data, &cause); 03014 if (!chan) { 03015 ast_log(LOG_NOTICE, "Unable to request channel %s/%s\n", type, (char *)data); 03016 /* compute error and return */ 03017 if (cause == AST_CAUSE_BUSY) 03018 *outstate = AST_CONTROL_BUSY; 03019 else if (cause == AST_CAUSE_CONGESTION) 03020 *outstate = AST_CONTROL_CONGESTION; 03021 return NULL; 03022 } 03023 03024 if (oh) { 03025 if (oh->vars) 03026 ast_set_variables(chan, oh->vars); 03027 /* XXX why is this necessary, for the parent_channel perhaps ? */ 03028 if (!ast_strlen_zero(oh->cid_num) && !ast_strlen_zero(oh->cid_name)) 03029 ast_set_callerid(chan, oh->cid_num, oh->cid_name, oh->cid_num); 03030 if (oh->parent_channel) 03031 ast_channel_inherit_variables(oh->parent_channel, chan); 03032 if (oh->account) 03033 ast_cdr_setaccount(chan, oh->account); 03034 } 03035 ast_set_callerid(chan, cid_num, cid_name, cid_num); 03036 03037 if (ast_call(chan, data, 0)) { /* ast_call failed... */ 03038 ast_log(LOG_NOTICE, "Unable to call channel %s/%s\n", type, (char *)data); 03039 } else { 03040 res = 1; /* mark success in case chan->_state is already AST_STATE_UP */ 03041 while (timeout && chan->_state != AST_STATE_UP) { 03042 struct ast_frame *f; 03043 res = ast_waitfor(chan, timeout); 03044 if (res <= 0) /* error, timeout, or done */ 03045 break; 03046 if (timeout > -1) 03047 timeout = res; 03048 f = ast_read(chan); 03049 if (!f) { 03050 *outstate = AST_CONTROL_HANGUP; 03051 res = 0; 03052 break; 03053 } 03054 if (f->frametype == AST_FRAME_CONTROL) { 03055 switch (f->subclass) { 03056 case AST_CONTROL_RINGING: /* record but keep going */ 03057 *outstate = f->subclass; 03058 break; 03059 03060 case AST_CONTROL_BUSY: 03061 case AST_CONTROL_CONGESTION: 03062 case AST_CONTROL_ANSWER: 03063 *outstate = f->subclass; 03064 timeout = 0; /* trick to force exit from the while() */ 03065 break; 03066 03067 /* Ignore these */ 03068 case AST_CONTROL_PROGRESS: 03069 case AST_CONTROL_PROCEEDING: 03070 case AST_CONTROL_HOLD: 03071 case AST_CONTROL_UNHOLD: 03072 case AST_CONTROL_VIDUPDATE: 03073 case AST_CONTROL_SRCUPDATE: 03074 case -1: /* Ignore -- just stopping indications */ 03075 break; 03076 03077 default: 03078 ast_log(LOG_NOTICE, "Don't know what to do with control frame %d\n", f->subclass); 03079 } 03080 last_subclass = f->subclass; 03081 } 03082 ast_frfree(f); 03083 } 03084 } 03085 03086 /* Final fixups */ 03087 if (oh) { 03088 if (!ast_strlen_zero(oh->context)) 03089 ast_copy_string(chan->context, oh->context, sizeof(chan->context)); 03090 if (!ast_strlen_zero(oh->exten)) 03091 ast_copy_string(chan->exten, oh->exten, sizeof(chan->exten)); 03092 if (oh->priority) 03093 chan->priority = oh->priority; 03094 } 03095 if (chan->_state == AST_STATE_UP) 03096 *outstate = AST_CONTROL_ANSWER; 03097 03098 if (res <= 0) { 03099 if ( AST_CONTROL_RINGING == last_subclass ) 03100 chan->hangupcause = AST_CAUSE_NO_ANSWER; 03101 if (!chan->cdr && (chan->cdr = ast_cdr_alloc())) 03102 ast_cdr_init(chan->cdr, chan); 03103 if (chan->cdr) { 03104 char tmp[256]; 03105 snprintf(tmp, sizeof(tmp), "%s/%s", type, (char *)data); 03106 ast_cdr_setapp(chan->cdr,"Dial",tmp); 03107 ast_cdr_update(chan); 03108 ast_cdr_start(chan->cdr); 03109 ast_cdr_end(chan->cdr); 03110 /* If the cause wasn't handled properly */ 03111 if (ast_cdr_disposition(chan->cdr,chan->hangupcause)) 03112 ast_cdr_failed(chan->cdr); 03113 } 03114 ast_hangup(chan); 03115 chan = NULL; 03116 } 03117 return chan; 03118 }
| int ast_activate_generator | ( | struct ast_channel * | chan, | |
| struct ast_generator * | gen, | |||
| void * | params | |||
| ) |
Activate a given generator
Definition at line 1634 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(), local_ast_moh_start(), old_milliwatt_exec(), sms_exec(), and transmit_audio().
01635 { 01636 int res = 0; 01637 01638 ast_channel_lock(chan); 01639 01640 if (chan->generatordata) { 01641 if (chan->generator && chan->generator->release) 01642 chan->generator->release(chan, chan->generatordata); 01643 chan->generatordata = NULL; 01644 } 01645 01646 ast_prod(chan); 01647 if (gen->alloc && !(chan->generatordata = gen->alloc(chan, params))) { 01648 res = -1; 01649 } 01650 01651 if (!res) { 01652 ast_settimeout(chan, 160, generator_force, chan); 01653 chan->generator = gen; 01654 } 01655 01656 ast_channel_unlock(chan); 01657 01658 return res; 01659 }
| int ast_active_channels | ( | void | ) |
returns number of active/allocated channels
Returns number of active/allocated channels
Definition at line 442 of file channel.c.
References AST_LIST_LOCK, AST_LIST_TRAVERSE, and AST_LIST_UNLOCK.
Referenced by dahdi_restart(), and quit_handler().
00443 { 00444 struct ast_channel *c; 00445 int cnt = 0; 00446 AST_LIST_LOCK(&channels); 00447 AST_LIST_TRAVERSE(&channels, c, chan_list) 00448 cnt++; 00449 AST_LIST_UNLOCK(&channels); 00450 return cnt; 00451 }
| static int ast_add_fd | ( | struct pollfd * | pfd, | |
| int | fd | |||
| ) | [inline, static] |
if fd is a valid descriptor, set *pfd with the descriptor
Definition at line 1388 of file channel.h.
References pollfd::events, pollfd::fd, POLLIN, and POLLPRI.
Referenced by ast_waitfor_nandfds().
| int ast_answer | ( | struct ast_channel * | chan | ) |
Answer a ringing call.
| chan | channel to answer This function answers a channel and handles all necessary call setup functions. |
Definition at line 1556 of file channel.c.
References ast_channel::_state, ast_channel_tech::answer, ast_cdr_answer(), ast_channel_lock, ast_channel_unlock, ast_check_hangup(), AST_FLAG_OUTGOING, AST_FLAG_ZOMBIE, 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 __login_exec(), action_bridge(), agi_exec_full(), alarmreceiver_exec(), answer_trunk_chan(), app_exec(), ast_bridge_call(), ast_control_streamfile(), ast_pickup_call(), auth_exec(), background_detect_exec(), bridge_exec(), builtin_parkcall(), common_exec(), conf_exec(), count_exec(), dictate_exec(), directory_exec(), disa_exec(), exec(), features_answer(), handle_answer(), ices_exec(), mwanalyze_exec(), nv_background_detect_exec(), nv_detectfax_exec(), old_milliwatt_exec(), park_call_exec(), park_exec(), pbx_builtin_answer(), pbx_builtin_background(), pickup_channel(), pickup_do(), playback_exec(), privacy_exec(), read_exec(), record_exec(), rpt_exec(), sayunixtime_exec(), send_waveform_to_channel(), skel_exec(), sla_station_exec(), sms_exec(), speech_background(), steal_channel(), testclient_exec(), testserver_exec(), transmit(), vm_exec(), vm_execmain(), waitforsilence_exec(), and zapateller_exec().
01557 { 01558 int res = 0; 01559 ast_channel_lock(chan); 01560 /* You can't answer an outbound call */ 01561 if (ast_test_flag(chan, AST_FLAG_OUTGOING)) { 01562 ast_channel_unlock(chan); 01563 return 0; 01564 } 01565 /* Stop if we're a zombie or need a soft hangup */ 01566 if (ast_test_flag(chan, AST_FLAG_ZOMBIE) || ast_check_hangup(chan)) { 01567 ast_channel_unlock(chan); 01568 return -1; 01569 } 01570 switch(chan->_state) { 01571 case AST_STATE_RINGING: 01572 case AST_STATE_RING: 01573 if (chan->tech->answer) 01574 res = chan->tech->answer(chan); 01575 ast_setstate(chan, AST_STATE_UP); 01576 ast_cdr_answer(chan->cdr); 01577 break; 01578 case AST_STATE_UP: 01579 break; 01580 default: 01581 break; 01582 } 01583 chan->visible_indication = 0; 01584 ast_channel_unlock(chan); 01585 return res; 01586 }
| int ast_autoservice_start | ( | struct ast_channel * | chan | ) |
Automatically service a channel for us...
| 0 | success | |
| -1 | failure, or the channel is already being autoserviced |
Definition at line 189 of file autoservice.c.
References as_cond, ast_calloc, ast_channel_lock, ast_channel_unlock, ast_cond_signal(), AST_FLAG_END_DTMF_ONLY, AST_LIST_EMPTY, AST_LIST_INSERT_HEAD, AST_LIST_LOCK, AST_LIST_REMOVE, AST_LIST_TRAVERSE, AST_LIST_UNLOCK, ast_log(), ast_pthread_create_background, AST_PTHREADT_NULL, ast_set_flag, ast_test_flag, asthread, autoservice_run(), asent::chan, free, asent::list, LOG_WARNING, asent::orig_end_dtmf_flag, and asent::use_count.
Referenced by _macro_exec(), acf_curl_exec(), acf_odbc_read(), acf_odbc_write(), ast_dtmf_stream(), ast_get_enum(), ast_get_srv(), ast_get_txt(), bridge_playfile(), builtin_atxfer(), builtin_automonitor(), builtin_blindtransfer(), conf_play(), feature_exec_app(), function_realtime_read(), function_realtime_write(), osplookup_exec(), pbx_find_extension(), sla_station_exec(), smdi_msg_retrieve_read(), system_exec_helper(), and try_calling().
00190 { 00191 int res = 0; 00192 struct asent *as; 00193 00194 /* Check if the channel already has autoservice */ 00195 AST_LIST_LOCK(&aslist); 00196 AST_LIST_TRAVERSE(&aslist, as, list) { 00197 if (as->chan == chan) { 00198 as->use_count++; 00199 break; 00200 } 00201 } 00202 AST_LIST_UNLOCK(&aslist); 00203 00204 if (as) { 00205 /* Entry exists, autoservice is already handling this channel */ 00206 return 0; 00207 } 00208 00209 if (!(as = ast_calloc(1, sizeof(*as)))) 00210 return -1; 00211 00212 /* New entry created */ 00213 as->chan = chan; 00214 as->use_count = 1; 00215 00216 ast_channel_lock(chan); 00217 as->orig_end_dtmf_flag = ast_test_flag(chan, AST_FLAG_END_DTMF_ONLY) ? 1 : 0; 00218 if (!as->orig_end_dtmf_flag) 00219 ast_set_flag(chan, AST_FLAG_END_DTMF_ONLY); 00220 ast_channel_unlock(chan); 00221 00222 AST_LIST_LOCK(&aslist); 00223 00224 if (AST_LIST_EMPTY(&aslist) && asthread != AST_PTHREADT_NULL) { 00225 ast_cond_signal(&as_cond); 00226 } 00227 00228 AST_LIST_INSERT_HEAD(&aslist, as, list); 00229 00230 if (asthread == AST_PTHREADT_NULL) { /* need start the thread */ 00231 if (ast_pthread_create_background(&asthread, NULL, autoservice_run, NULL)) { 00232 ast_log(LOG_WARNING, "Unable to create autoservice thread :(\n"); 00233 /* There will only be a single member in the list at this point, 00234 the one we just added. */ 00235 AST_LIST_REMOVE(&aslist, as, list); 00236 free(as); 00237 asthread = AST_PTHREADT_NULL; 00238 res = -1; 00239 } else { 00240 pthread_kill(asthread, SIGURG); 00241 } 00242 } 00243 00244 AST_LIST_UNLOCK(&aslist); 00245 00246 return res; 00247 }
| int ast_autoservice_stop | ( | struct ast_channel * | chan | ) |
Stop servicing a channel for us...
| 0 | success | |
| -1 | error, or the channel has been hungup |
Definition at line 249 of file autoservice.c.
References ast_channel::_softhangup, as_chan_list_state, ast_channel_lock, ast_channel_unlock, ast_clear_flag, AST_FLAG_END_DTMF_ONLY, ast_frfree, AST_LIST_LOCK, AST_LIST_REMOVE_CURRENT, AST_LIST_REMOVE_HEAD, AST_LIST_TRAVERSE_SAFE_BEGIN, AST_LIST_TRAVERSE_SAFE_END, AST_LIST_UNLOCK, AST_PTHREADT_NULL, ast_queue_frame_head(), asthread, asent::chan, asent::deferred_frames, f, ast_frame::frame_list, free, asent::list, asent::orig_end_dtmf_flag, and asent::use_count.
Referenced by _macro_exec(), acf_curl_exec(), acf_odbc_read(), acf_odbc_write(), ast_dtmf_stream(), ast_get_enum(), ast_get_srv(), ast_get_txt(), ast_hangup(), bridge_playfile(), builtin_atxfer(), builtin_automonitor(), conf_play(), feature_exec_app(), finishup(), function_realtime_read(), function_realtime_write(), osplookup_exec(), pbx_find_extension(), sla_station_exec(), smdi_msg_retrieve_read(), system_exec_helper(), and try_calling().
00250 { 00251 int res = -1; 00252 struct asent *as, *removed = NULL; 00253 struct ast_frame *f; 00254 int chan_list_state; 00255 00256 AST_LIST_LOCK(&aslist); 00257 00258 /* Save the autoservice channel list state. We _must_ verify that the channel 00259 * list has been rebuilt before we return. Because, after we return, the channel 00260 * could get destroyed and we don't want our poor autoservice thread to step on 00261 * it after its gone! */ 00262 chan_list_state = as_chan_list_state; 00263 00264 /* Find the entry, but do not free it because it still can be in the 00265 autoservice thread array */ 00266 AST_LIST_TRAVERSE_SAFE_BEGIN(&aslist, as, list) { 00267 if (as->chan == chan) { 00268 as->use_count--; 00269 if (as->use_count < 1) { 00270 AST_LIST_REMOVE_CURRENT(&aslist, list); 00271 removed = as; 00272 } 00273 break; 00274 } 00275 } 00276 AST_LIST_TRAVERSE_SAFE_END 00277 00278 if (removed && asthread != AST_PTHREADT_NULL) { 00279 pthread_kill(asthread, SIGURG); 00280 } 00281 00282 AST_LIST_UNLOCK(&aslist); 00283 00284 if (!removed) { 00285 return 0; 00286 } 00287 00288 /* Wait while autoservice thread rebuilds its list. */ 00289 while (chan_list_state == as_chan_list_state) { 00290 usleep(1000); 00291 } 00292 00293 /* Now autoservice thread should have no references to our entry 00294 and we can safely destroy it */ 00295 00296 if (!chan->_softhangup) { 00297 res = 0; 00298 } 00299 00300 if (!as->orig_end_dtmf_flag) { 00301 ast_clear_flag(chan, AST_FLAG_END_DTMF_ONLY); 00302 } 00303 00304 ast_channel_lock(chan); 00305 while ((f = AST_LIST_REMOVE_HEAD(&as->deferred_frames, frame_list))) { 00306 ast_queue_frame_head(chan, f); 00307 ast_frfree(f); 00308 } 00309 ast_channel_unlock(chan); 00310 00311 free(as); 00312 00313 return res; 00314 }
| void ast_begin_shutdown | ( | int | hangup | ) |
Initiate system shutdown.
Initiate system shutdown -- prevents new channels from being allocated. If "hangup" is non-zero, all existing channels will receive soft hangups
Definition at line 429 of file channel.c.
References AST_LIST_LOCK, AST_LIST_TRAVERSE, AST_LIST_UNLOCK, ast_softhangup(), and AST_SOFTHANGUP_SHUTDOWN.
Referenced by quit_handler().
00430 { 00431 struct ast_channel *c; 00432 shutting_down = 1; 00433 if (hangup) { 00434 AST_LIST_LOCK(&channels); 00435 AST_LIST_TRAVERSE(&channels, c, chan_list) 00436 ast_softhangup(c, AST_SOFTHANGUP_SHUTDOWN); 00437 AST_LIST_UNLOCK(&channels); 00438 } 00439 }
| int ast_best_codec | ( | int | fmts | ) |
Pick the best audio codec.
Pick the best codec
G.722 is better then all codecs in this list
alaw used by all telephone equipment at Russia
Okay, well, signed linear is easy to translate into other stuff! slinear<->alaw recoding very fast
ulaw standart for USA and Japan
Speex is free, but computationally more expensive than GSM
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
G.729a is faster than 723 and slightly less expensive
Down to G.723.1 which is proprietary but at least designed for voice
Ick, LPC10 sounds terrible, but at least we have code for it, if you're tacky enough to use it
Definition at line 654 of file channel.c.
References AST_FORMAT_ADPCM, AST_FORMAT_ALAW, AST_FORMAT_AUDIO_MASK, 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_SLINEAR, AST_FORMAT_SPEEX, AST_FORMAT_ULAW, ast_log(), LOG_WARNING, and prefs.
Referenced by __login_exec(), __oh323_new(), agent_call(), ast_channel_best_codec(), ast_codec_choose(), ast_iax2_new(), builtin_atxfer(), echo_exec(), findmeexec(), gtalk_new(), handle_open_receive_channel_ack_message(), iax2_request(), local_new(), mgcp_new(), ooh323_new(), sip_new(), skinny_new(), socket_process(), and transmit_connect().
00655 { 00656 /* This just our opinion, expressed in code. We are asked to choose 00657 the best codec to use, given no information */ 00658 int x; 00659 static int prefs[] = 00660 { 00661 /*! G.722 is better then all codecs in this list */ 00662 AST_FORMAT_G722, 00663 /*! alaw used by all telephone equipment at Russia */ 00664 AST_FORMAT_ALAW, 00665 /*! Okay, well, signed linear is easy to translate into other stuff! slinear<->alaw recoding very fast */ 00666 AST_FORMAT_SLINEAR, 00667 /*! ulaw standart for USA and Japan */ 00668 AST_FORMAT_ULAW, 00669 /*! Speex is free, but computationally more expensive than GSM */ 00670 AST_FORMAT_SPEEX, 00671 /*! G.726 is standard ADPCM, in RFC3551 packing order */ 00672 AST_FORMAT_G726, 00673 /*! G.726 is standard ADPCM, in AAL2 packing order */ 00674 AST_FORMAT_G726_AAL2, 00675 /*! ADPCM has great sound quality and is still pretty easy to translate */ 00676 AST_FORMAT_ADPCM, 00677 /*! Okay, we're down to vocoders now, so pick GSM because it's small and easier to 00678 translate and sounds pretty good */ 00679 AST_FORMAT_GSM, 00680 /*! iLBC is not too bad */ 00681 AST_FORMAT_ILBC, 00682 /*! G.729a is faster than 723 and slightly less expensive */ 00683 AST_FORMAT_G729A, 00684 /*! Down to G.723.1 which is proprietary but at least designed for voice */ 00685 AST_FORMAT_G723_1, 00686 /*! Ick, LPC10 sounds terrible, but at least we have code for it, if you're tacky enough 00687 to use it */ 00688 AST_FORMAT_LPC10, 00689 }; 00690 00691 /* Strip out video */ 00692 fmts &= AST_FORMAT_AUDIO_MASK; 00693 00694 /* Find the first preferred codec in the format given */ 00695 for (x=0; x < (sizeof(prefs) / sizeof(prefs[0]) ); x++) 00696 if (fmts & prefs[x]) 00697 return prefs[x]; 00698 ast_log(LOG_WARNING, "Don't know any of 0x%x formats\n", fmts); 00699 return 0; 00700 }
| struct ast_channel* ast_bridged_channel | ( | struct ast_channel * | chan | ) | [read] |
Find bridged channel.
| chan | Current channel |
Definition at line 3847 of file channel.c.
References ast_channel::_bridge, ast_channel_tech::bridged_channel, and ast_channel::tech.
Referenced by __dahdi_exception(), action_agents(), agents_show(), agents_show_online(), ast_bridge_call(), ast_channel_masquerade(), attempt_transfer(), cb_events(), check_bridge(), common_exec(), console_transfer(), console_transfer_deprecated(), create_jb(), dahdi_handle_event(), dahdi_hangup(), export_aoc_vars(), handle_chanlist(), handle_chanlist_deprecated(), handle_hd_hf(), handle_invite_replaces(), handle_request(), handle_request_bye(), handle_request_info(), handle_request_invite(), handle_request_refer(), handle_response_invite(), handle_showchan(), handle_showchan_deprecated(), local_attended_transfer(), mgcp_hangup(), mgcp_ss(), misdn_transfer_bc(), mixmonitor_thread(), park_call_full(), schedule_delivery(), sip_read(), socket_process(), ss_thread(), start_spying(), and startmon().
03848 { 03849 struct ast_channel *bridged; 03850 bridged = chan->_bridge; 03851 if (bridged && bridged->tech->bridged_channel) 03852 bridged = bridged->tech->bridged_channel(chan, bridged); 03853 return bridged; 03854 }
| 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 Place a call, take no longer than timeout ms. |
Definition at line 3175 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(), agent_call(), ast_feature_request_and_dial(), attempt_reconnect(), begin_dial(), connect_link(), features_call(), findmeexec(), ring_entry(), rpt(), rpt_exec(), and wait_for_answer().
03176 { 03177 /* Place an outgoing call, but don't wait any longer than timeout ms before returning. 03178 If the remote end does not answer within the timeout, then do NOT hang up, but 03179 return anyway. */ 03180 int res = -1; 03181 /* Stop if we're a zombie or need a soft hangup */ 03182 ast_channel_lock(chan); 03183 if (!ast_test_flag(chan, AST_FLAG_ZOMBIE) && !ast_check_hangup(chan)) { 03184 if (chan->cdr) 03185 ast_set_flag(chan->cdr, AST_CDR_FLAG_DIALED); 03186 if (chan->tech->call) 03187 res = chan->tech->call(chan, addr, timeout); 03188 ast_set_flag(chan, AST_FLAG_OUTGOING); 03189 } 03190 ast_channel_unlock(chan); 03191 return res; 03192 }
| void ast_cancel_shutdown | ( | void | ) |
Cancel a shutdown in progress.
Cancels an existing shutdown and returns to normal operation
Definition at line 454 of file channel.c.
Referenced by handle_abort_halt().
00455 { 00456 shutting_down = 0; 00457 }
| const char* ast_cause2str | ( | int | state | ) |
Gives the string form of a given hangup cause.
Gives the string form of a given cause code
| state | cause to get the description of Give a name to a cause code Returns the text form of the binary cause code given |
Definition at line 574 of file channel.c.
References causes, and ast_cause::desc.
Referenced by __transmit_response(), ast_do_masquerade(), ast_hangup(), findmeexec(), sip_hangup(), and transmit_request_with_auth().
00575 { 00576 int x; 00577 00578 for (x=0; x < sizeof(causes) / sizeof(causes[0]); x++) { 00579 if (causes[x].cause == cause) 00580 return causes[x].desc; 00581 } 00582 00583 return "Unknown"; 00584 }
| void ast_change_name | ( | struct ast_channel * | chan, | |
| char * | newname | |||
| ) |
Change channel name.
Definition at line 3425 of file channel.c.
References ast_string_field_set, EVENT_FLAG_CALL, manager_event(), name, ast_channel::name, and ast_channel::uniqueid.
03426 { 03427 manager_event(EVENT_FLAG_CALL, "Rename", "Oldname: %s\r\nNewname: %s\r\nUniqueid: %s\r\n", chan->name, newname, chan->uniqueid); 03428 ast_string_field_set(chan, name, newname); 03429 }
| 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 int | amaflag, | |||
| const char * | name_fmt, | |||
| ... | ||||
| ) | [read] |
Create a channel structure.
Definition at line 708 of file channel.c.
References ast_channel::_state, accountcode, ast_channel::alertpipe, ast_channel::amaflags, AST_ALERT_FD, ast_atomic_fetchadd_int(), ast_calloc, ast_cdr_alloc(), ast_cdr_init(), ast_cdr_start(), ast_config_AST_SYSTEM_NAME, ast_copy_string(), ast_default_accountcode, ast_default_amaflags, AST_LIST_HEAD_INIT_NOLOCK, AST_LIST_INSERT_HEAD, AST_LIST_LOCK, AST_LIST_UNLOCK, ast_log(), AST_MAX_FDS, ast_mutex_init(), ast_state2str(), ast_strdup, ast_string_field_build, ast_string_field_build_va, ast_string_field_free_memory, ast_string_field_init, ast_string_field_set, ast_strlen_zero(), AST_TIMING_FD, ast_channel::cdr, ast_channel::cid, ast_callerid::cid_name, ast_callerid::cid_num, ast_channel::context, ast_channel::datastores, defaultlanguage, errno, EVENT_FLAG_CALL, ast_channel::exten, ast_channel::fds, ast_channel::fin, ast_channel::flags, ast_channel::fout, free, HAVE_ZAPTEL, language, ast_channel::lock, LOG_WARNING, manager_event(), ast_channel::name, name, null_tech, ast_channel::priority, S_OR, ast_channel::sched, sched_context_create(), sched_context_destroy(), ast_channel::streamid, ast_channel::tech, ast_channel::timingfd, ast_channel::uniqueid, and ast_channel::varshead.
Referenced by __oh323_new(), acf_odbc_read(), acf_odbc_write(), action_bridge(), action_getvar(), agent_new(), alsa_new(), ast_async_goto(), ast_iax2_new(), ast_pbx_outgoing_cdr_failed(), ast_pbx_outgoing_exten(), bridge_exec(), builtin_atxfer(), check_goto_on_transfer(), dahdi_new(), features_new(), gtalk_new(), iax_park(), local_new(), make_email_file(), masq_park_call(), mgcp_new(), misdn_new(), nbs_new(), ooh323_new(), oss_new(), pbx_substitute_variables_helper_full(), phone_new(), sendpage(), sip_new(), sip_park(), and skinny_new().
00709 { 00710 struct ast_channel *tmp; 00711 int x; 00712 int flags; 00713 struct varshead *headp; 00714 va_list ap1, ap2; 00715 00716 /* If shutting down, don't allocate any new channels */ 00717 if (shutting_down) { 00718 ast_log(LOG_WARNING, "Channel allocation failed: Refusing due to active shutdown\n"); 00719 return NULL; 00720 } 00721 00722 if (!(tmp = ast_calloc(1, sizeof(*tmp)))) 00723 return NULL; 00724 00725 if (!(tmp->sched = sched_context_create())) { 00726 ast_log(LOG_WARNING, "Channel allocation failed: Unable to create schedule context\n"); 00727 free(tmp); 00728 return NULL; 00729 } 00730 00731 if ((ast_string_field_init(tmp, 128))) { 00732 sched_context_destroy(tmp->sched); 00733 free(tmp); 00734 return NULL; 00735 } 00736 00737 /* Don't bother initializing the last two FD here, because they 00738 will *always* be set just a few lines down (AST_TIMING_FD, 00739 AST_ALERT_FD). */ 00740 for (x = 0; x < AST_MAX_FDS - 2; x++) 00741 tmp->fds[x] = -1; 00742 00743 #ifdef HAVE_DAHDI 00744 00745 #ifdef HAVE_ZAPTEL 00746 tmp->timingfd = open("/dev/zap/timer", O_RDWR); 00747 #else 00748 tmp->timingfd = open("/dev/dahdi/timer", O_RDWR); 00749 #endif 00750 00751 if (tmp->timingfd > -1) { 00752 /* Check if timing interface supports new 00753 ping/pong scheme */ 00754 flags = 1; 00755 if (!ioctl(tmp->timingfd, DAHDI_TIMERPONG, &flags)) 00756 needqueue = 0; 00757 } 00758 #else 00759 tmp->timingfd = -1; 00760 #endif 00761 00762 if (needqueue) { 00763 if (pipe(tmp->alertpipe)) { 00764 ast_log(LOG_WARNING, "Channel allocation failed: Can't create alert pipe!\n"); 00765 alertpipe_failed: 00766 #ifdef HAVE_DAHDI 00767 if (tmp->timingfd > -1) 00768 close(tmp->timingfd); 00769 #endif 00770 sched_context_destroy(tmp->sched); 00771 ast_string_field_free_memory(tmp); 00772 free(tmp); 00773 return NULL; 00774 } else { 00775 flags = fcntl(tmp->alertpipe[0], F_GETFL); 00776 if (fcntl(tmp->alertpipe[0], F_SETFL, flags | O_NONBLOCK) < 0) { 00777 ast_log(LOG_WARNING, "Channel allocation failed: Unable to set alertpipe nonblocking! (%d: %s)\n", errno, strerror(errno)); 00778 close(tmp->alertpipe[0]); 00779 close(tmp->alertpipe[1]); 00780 goto alertpipe_failed; 00781 } 00782 flags = fcntl(tmp->alertpipe[1], F_GETFL); 00783 if (fcntl(tmp->alertpipe[1], F_SETFL, flags | O_NONBLOCK) < 0) { 00784 ast_log(LOG_WARNING, "Channel allocation failed: Unable to set alertpipe nonblocking! (%d: %s)\n", errno, strerror(errno)); 00785 close(tmp->alertpipe[0]); 00786 close(tmp->alertpipe[1]); 00787 goto alertpipe_failed; 00788 } 00789 } 00790 } else /* Make sure we've got it done right if they don't */ 00791 tmp->alertpipe[0] = tmp->alertpipe[1] = -1; 00792 00793 /* Always watch the alertpipe */ 00794 tmp->fds[AST_ALERT_FD] = tmp->alertpipe[0]; 00795 /* And timing pipe */ 00796 tmp->fds[AST_TIMING_FD] = tmp->timingfd; 00797 ast_string_field_set(tmp, name, "**Unknown**"); 00798 00799 /* Initial state */ 00800 tmp->_state = state; 00801 00802 tmp->streamid = -1; 00803 00804 tmp->fin = global_fin; 00805 tmp->fout = global_fout; 00806 00807 if (ast_strlen_zero(ast_config_AST_SYSTEM_NAME)) { 00808 ast_string_field_build(tmp, uniqueid, "%li.%d", (long) time(NULL), 00809 ast_atomic_fetchadd_int(&uniqueint, 1)); 00810 } else { 00811 ast_string_field_build(tmp, uniqueid, "%s-%li.%d", ast_config_AST_SYSTEM_NAME, 00812 (long) time(NULL), ast_atomic_fetchadd_int(&uniqueint, 1)); 00813 } 00814 00815 tmp->cid.cid_name = ast_strdup(cid_name); 00816 tmp->cid.cid_num = ast_strdup(cid_num); 00817 00818 if (!ast_strlen_zero(name_fmt)) { 00819 /* Almost every channel is calling this function, and setting the name via the ast_string_field_build() call. 00820 * And they all use slightly different formats for their name string. 00821 * This means, to set the name here, we have to accept variable args, and call the string_field_build from here. 00822 * This means, that the stringfields must have a routine that takes the va_lists directly, and 00823 * uses them to build the string, instead of forming the va_lists internally from the vararg ... list. 00824 * This new function was written so this can be accomplished. 00825 */ 00826 va_start(ap1, name_fmt); 00827 va_start(ap2, name_fmt); 00828 ast_string_field_build_va(tmp, name, name_fmt, ap1, ap2); 00829 va_end(ap1); 00830 va_end(ap2); 00831 } 00832 00833 /* Reminder for the future: under what conditions do we NOT want to track cdrs on channels? */ 00834 00835 /* These 4 variables need to be set up for the cdr_init() to work right */ 00836 if (amaflag) 00837 tmp->amaflags = amaflag; 00838 else 00839 tmp->amaflags = ast_default_amaflags; 00840 00841 if (!ast_strlen_zero(acctcode)) 00842 ast_string_field_set(tmp, accountcode, acctcode); 00843 else 00844 ast_string_field_set(tmp, accountcode, ast_default_accountcode); 00845 00846 if (!ast_strlen_zero(context)) 00847 ast_copy_string(tmp->context, context, sizeof(tmp->context)); 00848 else 00849 strcpy(tmp->context, "default"); 00850 00851 if (!ast_strlen_zero(exten)) 00852 ast_copy_string(tmp->exten, exten, sizeof(tmp->exten)); 00853 else 00854 strcpy(tmp->exten, "s"); 00855 00856 tmp->priority = 1; 00857 00858 tmp->cdr = ast_cdr_alloc(); 00859 ast_cdr_init(tmp->cdr, tmp); 00860 ast_cdr_start(tmp->cdr); 00861 00862 headp = &tmp->varshead; 00863 AST_LIST_HEAD_INIT_NOLOCK(headp); 00864 00865 ast_mutex_init(&tmp->lock); 00866 00867 AST_LIST_HEAD_INIT_NOLOCK(&tmp->datastores); 00868 00869 ast_string_field_set(tmp, language, defaultlanguage); 00870 00871 tmp->tech = &null_tech; 00872 00873 AST_LIST_LOCK(&channels); 00874 AST_LIST_INSERT_HEAD(&channels, tmp, chan_list); 00875 AST_LIST_UNLOCK(&channels); 00876 00877 /*\!note 00878 * and now, since the channel structure is built, and has its name, let's 00879 * call the manager event generator with this Newchannel event. This is the 00880 * proper and correct place to make this call, but you sure do have to pass 00881 * a lot of data into this func to do it here! 00882 */ 00883 if (!ast_strlen_zero(name_fmt)) { 00884 manager_event(EVENT_FLAG_CALL, "Newchannel", 00885 "Channel: %s\r\n" 00886 "State: %s\r\n" 00887 "CallerIDNum: %s\r\n" 00888 "CallerIDName: %s\r\n" 00889 "Uniqueid: %s\r\n", 00890 tmp->name, ast_state2str(state), 00891 S_OR(cid_num, "<unknown>"), 00892 S_OR(cid_name, "<unknown>"), 00893 tmp->uniqueid); 00894 } 00895 00896 return tmp; 00897 }
| static int ast_channel_best_codec | ( | struct ast_channel * | channel | ) | [inline, static] |
Pick the best codec from channel nativeformats.
| channel | channel, from that nativeformats used |
Definition at line 1148 of file channel.h.
References ast_best_codec(), and ast_channel::nativeformats.
Referenced by ast_set_best_format().
01149 { 01150 #ifndef BUG_4825 01151 return ast_best_codec(channel->nativeformats); 01152 #else 01153 return ast_best_codec(channel->nativeformats.audio_bits); 01154 #endif 01155 }
| int 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.
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(?) Bridge two channels (c0 and c1) together. If an important frame occurs, we return that frame in rf (remember, it could be NULL) and which channel (0 or 1) in rc |
Definition at line 4042 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_SRCUPDATE, AST_FEATURE_PLAY_WARNING, AST_FEATURE_REDIRECT, AST_FLAG_END_DTMF_ONLY, AST_FLAG_NBRIDGE, AST_FLAG_ZOMBIE, ast_generic_bridge(), ast_indicate(), ast_log(), ast_samp2tv(), ast_set_flag, AST_SOFTHANGUP_UNBRIDGE, ast_strlen_zero(), ast_test_flag, ast_tvadd(), ast_tvdiff_ms(), ast_tvnow(), ast_tvsub(), ast_tvzero(), ast_verbose(), ast_channel::audiohooks, ast_channel_tech::bridge, bridge_playfile(), ast_channel::cid, ast_callerid::cid_num, ast_bridge_config::end_sound, EVENT_FLAG_CALL, ast_bridge_config::feature_timer, ast_bridge_config::features_callee, ast_bridge_config::features_caller, ast_bridge_config::firstpass, ast_bridge_config::flags, ast_channel::generator, LOG_DEBUG, LOG_WARNING, manager_event(), ast_channel::masq, ast_channel::masqr, ast_channel::monitor, ast_channel::name, ast_channel::nativeformats, option_debug, option_verbose, pbx_builtin_getvar_helper(), pbx_builtin_setvar_helper(), ast_bridge_config::play_warning, ast_channel::readformat, ast_channel_tech::send_digit_begin, ast_bridge_config::start_sound, ast_bridge_config::start_time, t, ast_channel::tech, ast_bridge_config::timelimit, ast_channel::uniqueid, VERBOSE_PREFIX_3, ast_bridge_config::warning_freq, ast_bridge_config::warning_sound, and ast_channel::writeformat.
Referenced by ast_bridge_call().
04044 { 04045 struct ast_channel *who = NULL; 04046 enum ast_bridge_result res = AST_BRIDGE_COMPLETE; 04047 int nativefailed=0; 04048 int firstpass; 04049 int o0nativeformats; 04050 int o1nativeformats; 04051 long time_left_ms=0; 04052 struct timeval nexteventts = { 0, }; 04053 char caller_warning = 0; 04054 char callee_warning = 0; 04055 04056 if (c0->_bridge) { 04057 ast_log(LOG_WARNING, "%s is already in a bridge with %s\n", 04058 c0->name, c0->_bridge->name); 04059 return -1; 04060 } 04061 if (c1->_bridge) { 04062 ast_log(LOG_WARNING, "%s is already in a bridge with %s\n", 04063 c1->name, c1->_bridge->name); 04064 return -1; 04065 } 04066 04067 /* Stop if we're a zombie or need a soft hangup */ 04068 if (ast_test_flag(c0, AST_FLAG_ZOMBIE) || ast_check_hangup_locked(c0) || 04069 ast_test_flag(c1, AST_FLAG_ZOMBIE) || ast_check_hangup_locked(c1)) 04070 return -1; 04071 04072 *fo = NULL; 04073 firstpass = config->firstpass; 04074 config->firstpass = 0; 04075 04076 if (ast_tvzero(config->start_time)) 04077 config->start_time = ast_tvnow(); 04078 time_left_ms = config->timelimit; 04079 04080 caller_warning = ast_test_flag(&config->features_caller, AST_FEATURE_PLAY_WARNING); 04081 callee_warning = ast_test_flag(&config->features_callee, AST_FEATURE_PLAY_WARNING); 04082 04083 if (config->start_sound && firstpass) { 04084 if (caller_warning) 04085 bridge_playfile(c0, c1, config->start_sound, time_left_ms / 1000); 04086 if (callee_warning) 04087 bridge_playfile(c1, c0, config->start_sound, time_left_ms / 1000); 04088 } 04089 04090 /* Keep track of bridge */ 04091 c0->_bridge = c1; 04092 c1->_bridge = c0; 04093 04094 /* \todo XXX here should check that cid_num is not NULL */ 04095 manager_event(EVENT_FLAG_CALL, "Link", 04096 "Channel1: %s\r\n" 04097 "Channel2: %s\r\n" 04098 "Uniqueid1: %s\r\n" 04099 "Uniqueid2: %s\r\n" 04100 "CallerID1: %s\r\n" 04101 "CallerID2: %s\r\n", 04102 c0->name, c1->name, c0->uniqueid, c1->uniqueid, c0->cid.cid_num, c1->cid.cid_num); 04103 04104 o0nativeformats = c0->nativeformats; 04105 o1nativeformats = c1->nativeformats; 04106 04107 if (config->feature_timer) { 04108 nexteventts = ast_tvadd(config->start_time, ast_samp2tv(config->feature_timer, 1000)); 04109 } else if (config->timelimit) { 04110 nexteventts = ast_tvadd(config->start_time, ast_samp2tv(config->timelimit, 1000)); 04111 if (caller_warning || callee_warning) 04112 nexteventts = ast_tvsub(nexteventts, ast_samp2tv(config->play_warning, 1000)); 04113 } 04114 04115 if (!c0->tech->send_digit_begin) 04116 ast_set_flag(c1, AST_FLAG_END_DTMF_ONLY); 04117 if (!c1->tech->send_digit_begin) 04118 ast_set_flag(c0, AST_FLAG_END_DTMF_ONLY); 04119 04120 /* Before we enter in and bridge these two together tell them both the source of audio has changed */ 04121 ast_indicate(c0, AST_CONTROL_SRCUPDATE); 04122 ast_indicate(c1, AST_CONTROL_SRCUPDATE); 04123 04124 for (/* ever */;;) { 04125 struct timeval now = { 0, }; 04126 int to; 04127 04128 to = -1; 04129 04130 if (!ast_tvzero(nexteventts)) { 04131 now = ast_tvnow(); 04132 to = ast_tvdiff_ms(nexteventts, now); 04133 if (to <= 0) { 04134 if (!config->timelimit) { 04135 res = AST_BRIDGE_COMPLETE; 04136 break; 04137 } 04138 to = 0; 04139 } 04140 } 04141 04142 if (config->timelimit) { 04143 time_left_ms = config->timelimit - ast_tvdiff_ms(now, config->start_time); 04144 if (time_left_ms < to) 04145 to = time_left_ms; 04146 04147 if (time_left_ms <= 0) { 04148 if (caller_warning && config->end_sound) 04149 bridge_playfile(c0, c1, config->end_sound, 0); 04150 if (callee_warning && config->end_sound) 04151 bridge_playfile(c1, c0, config->end_sound, 0); 04152 *fo = NULL; 04153 if (who) 04154 *rc = who; 04155 res = 0; 04156 break; 04157 } 04158 04159 if (!to) { 04160 if (time_left_ms >= 5000 && config->warning_sound && config->play_warning) { 04161 int t = (time_left_ms + 500) / 1000; /* round to nearest second */ 04162 if (caller_warning) 04163 bridge_playfile(c0, c1, config->warning_sound, t); 04164 if (callee_warning) 04165 bridge_playfile(c1, c0, config->warning_sound, t); 04166 } 04167 if (config->warning_freq && (time_left_ms > (config->warning_freq + 5000))) 04168 nexteventts = ast_tvadd(nexteventts, ast_samp2tv(config->warning_freq, 1000)); 04169 else 04170 nexteventts = ast_tvadd(config->start_time, ast_samp2tv(config->timelimit, 1000)); 04171 } 04172 } 04173 04174 if (c0->_softhangup == AST_SOFTHANGUP_UNBRIDGE || c1->_softhangup == AST_SOFTHANGUP_UNBRIDGE) { 04175 if (c0->_softhangup == AST_SOFTHANGUP_UNBRIDGE) 04176 c0->_softhangup = 0; 04177 if (c1->_softhangup == AST_SOFTHANGUP_UNBRIDGE) 04178 c1->_softhangup = 0; 04179 c0->_bridge = c1; 04180 c1->_bridge = c0; 04181 if (option_debug) 04182 ast_log(LOG_DEBUG, "Unbridge signal received. Ending native bridge.\n"); 04183 continue; 04184 } 04185 04186 /* Stop if we're a zombie or need a soft hangup */ 04187 if (ast_test_flag(c0, AST_FLAG_ZOMBIE) || ast_check_hangup_locked(c0) || 04188 ast_test_flag(c1, AST_FLAG_ZOMBIE) || ast_check_hangup_locked(c1)) { 04189 *fo = NULL; 04190 if (who) 04191 *rc = who; 04192 res = 0; 04193 if (option_debug) 04194 ast_log(LOG_DEBUG, "Bridge stops because we're zombie or need a soft hangup: c0=%s, c1=%s, flags: %s,%s,%s,%s\n", 04195 c0->name, c1->name, 04196 ast_test_flag(c0, AST_FLAG_ZOMBIE) ? "Yes" : "No", 04197 ast_check_hangup(c0) ? "Yes" : "No", 04198 ast_test_flag(c1, AST_FLAG_ZOMBIE) ? "Yes" : "No", 04199 ast_check_hangup(c1) ? "Yes" : "No"); 04200 break; 04201 } 04202 04203 /* See if the BRIDGEPEER variable needs to be updated */ 04204 if (!ast_strlen_zero(pbx_builtin_getvar_helper(c0, "BRIDGEPEER"))) 04205 pbx_builtin_setvar_helper(c0, "BRIDGEPEER", c1->name); 04206 if (!ast_strlen_zero(pbx_builtin_getvar_helper(c1, "BRIDGEPEER"))) 04207 pbx_builtin_setvar_helper(c1, "BRIDGEPEER", c0->name); 04208 04209 if (c0->tech->bridge && 04210 (config->timelimit == 0) && 04211 (c0->tech->bridge == c1->tech->bridge) && 04212 !nativefailed && !c0->monitor && !c1->monitor && 04213 !c0->audiohooks && !c1->audiohooks && !ast_test_flag(&(config->features_callee),AST_FEATURE_REDIRECT) && 04214 !ast_test_flag(&(config->features_caller),AST_FEATURE_REDIRECT) && 04215 !c0->masq && !c0->masqr && !c1->masq && !c1->masqr) { 04216 /* Looks like they share a bridge method and nothing else is in the way */ 04217 ast_set_flag(c0, AST_FLAG_NBRIDGE); 04218 ast_set_flag(c1, AST_FLAG_NBRIDGE); 04219 if ((res = c0->tech->bridge(c0, c1, config->flags, fo, rc, to)) == AST_BRIDGE_COMPLETE) { 04220 /* \todo XXX here should check that cid_num is not NULL */ 04221 manager_event(EVENT_FLAG_CALL, "Unlink", 04222 "Channel1: %s\r\n" 04223 "Channel2: %s\r\n" 04224 "Uniqueid1: %s\r\n" 04225 "Uniqueid2: %s\r\n" 04226 "CallerID1: %s\r\n" 04227 "CallerID2: %s\r\n", 04228 c0->name, c1->name, c0->uniqueid, c1->uniqueid, c0->cid.cid_num, c1->cid.cid_num); 04229 if (option_debug) 04230 ast_log(LOG_DEBUG, "Returning from native bridge, channels: %s, %s\n", c0->name, c1->name); 04231 04232 ast_clear_flag(c0, AST_FLAG_NBRIDGE); 04233 ast_clear_flag(c1, AST_FLAG_NBRIDGE); 04234 04235 if (c0->_softhangup == AST_SOFTHANGUP_UNBRIDGE || c1->_softhangup == AST_SOFTHANGUP_UNBRIDGE) 04236 continue; 04237 04238 c0->_bridge = NULL; 04239 c1->_bridge = NULL; 04240 04241 return res; 04242 } else { 04243 ast_clear_flag(c0, AST_FLAG_NBRIDGE); 04244 ast_clear_flag(c1, AST_FLAG_NBRIDGE); 04245 } 04246 switch (res) { 04247 case AST_BRIDGE_RETRY: 04248 continue; 04249 default: 04250 if (option_verbose > 2) 04251 ast_verbose(VERBOSE_PREFIX_3 "Native bridging %s and %s ended\n", 04252 c0->name, c1->name); 04253 /* fallthrough */ 04254 case AST_BRIDGE_FAILED_NOWARN: 04255 nativefailed++; 04256 break; 04257 } 04258 } 04259 04260 if (((c0->writeformat != c1->readformat) || (c0->readformat != c1->writeformat) || 04261 (c0->nativeformats != o0nativeformats) || (c1->nativeformats != o1nativeformats)) && 04262 !(c0->generator || c1->generator)) { 04263 if (ast_channel_make_compatible(c0, c1)) { 04264 ast_log(LOG_WARNING, "Can't make %s and %s compatible\n", c0->name, c1->name); 04265 /* \todo XXX here should check that cid_num is not NULL */ 04266 manager_event(EVENT_FLAG_CALL, "Unlink", 04267 "Channel1: %s\r\n" 04268 "Channel2: %s\r\n" 04269 "Uniqueid1: %s\r\n" 04270 "Uniqueid2: %s\r\n" 04271 "CallerID1: %s\r\n" 04272 "CallerID2: %s\r\n", 04273 c0->name, c1->name, c0->uniqueid, c1->uniqueid, c0->cid.cid_num, c1->cid.cid_num); 04274 return AST_BRIDGE_FAILED; 04275 } 04276 o0nativeformats = c0->nativeformats; 04277 o1nativeformats = c1->nativeformats; 04278 } 04279 04280 if (!ast_strlen_zero(pbx_builtin_getvar_helper(c0, "BRIDGEPEER"))) 04281 pbx_builtin_setvar_helper(c0, "BRIDGEPEER", c1->name); 04282 if (!ast_strlen_zero(pbx_builtin_getvar_helper(c1, "BRIDGEPEER"))) 04283 pbx_builtin_setvar_helper(c1, "BRIDGEPEER", c0->name); 04284 04285 res = ast_generic_bridge(c0, c1, config, fo, rc, nexteventts); 04286 if (res != AST_BRIDGE_RETRY) 04287 break; 04288 } 04289 04290 ast_clear_flag(c0, AST_FLAG_END_DTMF_ONLY); 04291 ast_clear_flag(c1, AST_FLAG_END_DTMF_ONLY); 04292 04293 /* Now that we have broken the bridge the source will change yet again */ 04294 ast_indicate(c0, AST_CONTROL_SRCUPDATE); 04295 ast_indicate(c1, AST_CONTROL_SRCUPDATE); 04296 04297 c0->_bridge = NULL; 04298 c1->_bridge = NULL; 04299 04300 /* \todo XXX here should check that cid_num is not NULL */ 04301 manager_event(EVENT_FLAG_CALL, "Unlink", 04302 "Channel1: %s\r\n" 04303 "Channel2: %s\r\n" 04304 "Uniqueid1: %s\r\n" 04305 "Uniqueid2: %s\r\n" 04306 "CallerID1: %s\r\n" 04307 "CallerID2: %s\r\n", 04308 c0->name, c1->name, c0->uniqueid, c1->uniqueid, c0->cid.cid_num, c1->cid.cid_num); 04309 if (option_debug) 04310 ast_log(LOG_DEBUG, "Bridge stops bridging channels %s and %s\n", c0->name, c1->name); 04311 04312 return res; 04313 }
| 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 474 of file channel.c.
References ast_channel::whentohangup.
00475 { 00476 time_t whentohangup; 00477 00478 if (chan->whentohangup == 0) { 00479 return (offset == 0) ? 0 : -1; 00480 } else { 00481 if (offset == 0) /* XXX why is this special ? */ 00482 return (1); 00483 else { 00484 whentohangup = offset + time (NULL); 00485 if (chan->whentohangup < whentohangup) 00486 return (1); 00487 else if (chan->whentohangup == whentohangup) 00488 return (0); 00489 else 00490 return (-1); 00491 } 00492 } 00493 }
| int ast_channel_datastore_add | ( | struct ast_channel * | chan, | |
| struct ast_datastore * | datastore | |||
| ) |
Add a datastore to a channel.
Definition at line 1373 of file channel.c.
References AST_LIST_INSERT_HEAD, ast_channel::datastores, and ast_datastore::entry.
Referenced by _macro_exec(), setup_chanspy_ds(), setup_transfer_datastore(), smdi_msg_retrieve_read(), speech_create(), and try_calling().
01374 { 01375 int res = 0; 01376 01377 AST_LIST_INSERT_HEAD(&chan->datastores, datastore, entry); 01378 01379 return res; 01380 }
| struct ast_datastore* ast_channel_datastore_alloc | ( | const struct ast_datastore_info * | info, | |
| char * | uid | |||
| ) | [read] |
Create a channel datastore structure.
Definition at line 1312 of file channel.c.
References ast_calloc, ast_strdup, ast_datastore::info, and ast_datastore::uid.
Referenced by _macro_exec(), ast_channel_datastore_inherit(), setup_chanspy_ds(), setup_transfer_datastore(), smdi_msg_retrieve_read(), speech_create(), and try_calling().
01313 { 01314 struct ast_datastore *datastore = NULL; 01315 01316 /* Make sure we at least have type so we can identify this */ 01317 if (info == NULL) { 01318 return NULL; 01319 } 01320 01321 /* Allocate memory for datastore and clear it */ 01322 datastore = ast_calloc(1, sizeof(*datastore)); 01323 if (datastore == NULL) { 01324 return NULL; 01325 } 01326 01327 datastore->info = info; 01328 01329 datastore->uid = ast_strdup(uid); 01330 01331 return datastore; 01332 }
| struct ast_datastore* ast_channel_datastore_find | ( | struct ast_channel * | chan, | |
| const struct ast_datastore_info * | info, | |||
| char * | uid | |||
| ) | [read] |
Find a datastore on a channel.
Definition at line 1400 of file channel.c.
References AST_LIST_TRAVERSE_SAFE_BEGIN, AST_LIST_TRAVERSE_SAFE_END, ast_channel::datastores, ast_datastore::entry, ast_datastore::info, and ast_datastore::uid.
Referenced by _macro_exec(), attended_transfer_occurred(), builtin_atxfer(), chanspy_ds_free(), do_parking_thread(), find_speech(), queue_transfer_fixup(), smdi_msg_read(), speech_background(), speech_destroy(), and try_calling().
01401 { 01402 struct ast_datastore *datastore = NULL; 01403 01404 if (info == NULL) 01405 return NULL; 01406 01407 AST_LIST_TRAVERSE_SAFE_BEGIN(&chan->datastores, datastore, entry) { 01408 if (datastore->info == info) { 01409 if (uid != NULL && datastore->uid != NULL) { 01410 if (!strcasecmp(uid, datastore->uid)) { 01411 /* Matched by type AND uid */ 01412 break; 01413 } 01414 } else { 01415 /* Matched by type at least */ 01416 break; 01417 } 01418 } 01419 } 01420 AST_LIST_TRAVERSE_SAFE_END 01421 01422 return datastore; 01423 }
| int ast_channel_datastore_free | ( | struct ast_datastore * | datastore | ) |
Free a channel datastore structure.
Definition at line 1334 of file channel.c.
References ast_datastore::data, ast_datastore_info::destroy, free, ast_datastore::info, and ast_datastore::uid.
Referenced by ast_channel_free(), chanspy_ds_free(), and try_calling().
01335 { 01336 int res = 0; 01337 01338 /* Using the destroy function (if present) destroy the data */ 01339 if (datastore->info->destroy != NULL && datastore->data != NULL) { 01340 datastore->info->destroy(datastore->data); 01341 datastore->data = NULL; 01342 } 01343 01344 /* Free allocated UID memory */ 01345 if (datastore->uid != NULL) { 01346 free(datastore->uid); 01347 datastore->uid = NULL; 01348 } 01349 01350 /* Finally free memory used by ourselves */ 01351 free(datastore); 01352 01353 return res; 01354 }
| int ast_channel_datastore_inherit | ( | struct ast_channel * | from, | |
| struct ast_channel * | to | |||
| ) |
Inherit datastores from a parent to a child.
Definition at line 1356 of file channel.c.
References ast_channel_datastore_alloc(), AST_LIST_INSERT_TAIL, AST_LIST_TRAVERSE, ast_datastore::data, DATASTORE_INHERIT_FOREVER, ast_channel::datastores, ast_datastore_info::duplicate, ast_datastore::entry, ast_datastore::info, ast_datastore::inheritance, and ast_datastore::uid.
Referenced by local_call(), and wait_for_answer().
01357 { 01358 struct ast_datastore *datastore = NULL, *datastore2; 01359 01360 AST_LIST_TRAVERSE(&from->datastores, datastore, entry) { 01361 if (datastore->inheritance > 0) { 01362 datastore2 = ast_channel_datastore_alloc(datastore->info, datastore->uid); 01363 if (datastore2) { 01364 datastore2->data = datastore->info->duplicate(datastore->data); 01365 datastore2->inheritance = datastore->inheritance == DATASTORE_INHERIT_FOREVER ? DATASTORE_INHERIT_FOREVER : datastore->inheritance - 1; 01366 AST_LIST_INSERT_TAIL(&to->datastores, datastore2, entry); 01367 } 01368 } 01369 } 01370 return 0; 01371 }
| int ast_channel_datastore_remove | ( | struct ast_channel * | chan, | |
| struct ast_datastore * | datastore | |||
| ) |
Remove a datastore from a channel.
Definition at line 1382 of file channel.c.
References AST_LIST_REMOVE_CURRENT, AST_LIST_TRAVERSE_SAFE_BEGIN, AST_LIST_TRAVERSE_SAFE_END, ast_channel::datastores, and ast_datastore::entry.
Referenced by chanspy_ds_free(), queue_transfer_fixup(), speech_background(), speech_destroy(), and try_calling().
01383 { 01384 struct ast_datastore *datastore2 = NULL; 01385 int res = -1; 01386 01387 /* Find our position and remove ourselves */ 01388 AST_LIST_TRAVERSE_SAFE_BEGIN(&chan->datastores, datastore2, entry) { 01389 if (datastore2 == datastore) { 01390 AST_LIST_REMOVE_CURRENT(&chan->datastores, entry); 01391 res = 0; 01392 break; 01393 } 01394 } 01395 AST_LIST_TRAVERSE_SAFE_END 01396 01397 return res; 01398 }
| int ast_channel_defer_dtmf | ( | struct ast_channel * | chan | ) |
Set defer DTMF flag on channel.
Defers DTMF
Defer DTMF so that you only read things like hangups and audio. Returns non-zero if channel was already DTMF-deferred or 0 if channel is just now being DTMF-deferred
Definition at line 1010 of file channel.c.
References AST_FLAG_DEFER_DTMF, ast_set_flag, and ast_test_flag.
Referenced by __adsi_transmit_messages(), and find_cache().
01011 { 01012 int pre = 0; 01013 01014 if (chan) { 01015 pre = ast_test_flag(chan, AST_FLAG_DEFER_DTMF); 01016 ast_set_flag(chan, AST_FLAG_DEFER_DTMF); 01017 } 01018 return pre; 01019 }
| static void ast_channel_formats_reset | ( | struct ast_channel * | channel | ) | [inline, static] |
Definition at line 1179 of file channel.h.
References ast_get_read_format(), ast_get_write_format(), ast_log(), ast_set_read_format(), ast_set_write_format(), LOG_DEBUG, ast_channel::name, and option_debug.
01180 { 01181 int r, w; 01182 r = ast_get_read_format(channel); 01183 w = ast_get_write_format(channel); 01184 01185 if (option_debug) 01186 ast_log(LOG_DEBUG, "Resetting read to %d and write to %d on channel %s\n", r, w, channel->name); 01187 if (r) 01188 ast_set_read_format(channel, r); 01189 if (w) 01190 ast_set_write_format(channel, w); 01191 }
| void ast_channel_free | ( | struct ast_channel * | ) |
Free a channel structure.
Definition at line 1217 of file channel.c.
References ast_channel::alertpipe, ast_app_group_discard(), ast_cdr_discard(), ast_channel_datastore_free(), ast_channel_lock, AST_CHANNEL_NAME, ast_channel_unlock, ast_copy_string(), ast_device_state_changed_literal(), ast_frfree, ast_jb_destroy(), AST_LIST_LOCK, AST_LIST_REMOVE, AST_LIST_REMOVE_HEAD, AST_LIST_UNLOCK, ast_log(), ast_moh_cleanup(), ast_mutex_destroy(), ast_string_field_free_memory, ast_translator_free_path(), ast_var_delete(), ast_channel::cdr, ast_channel::cid, ast_channel::datastores, ast_datastore::entry, f, free, free_cid(), ast_channel::lock, LOG_ERROR, LOG_WARNING, ast_channel::monitor, ast_channel::music_state, ast_channel::name, name, ast_channel::pbx, ast_channel::readq, ast_channel::readtrans, ast_channel::sched, sched_context_destroy(), ast_channel_monitor::stop, ast_channel::tech_pvt, ast_channel::timingfd, ast_channel::varshead, and ast_channel::writetrans.
Referenced by acf_odbc_read(), acf_odbc_write(), action_bridge(), action_getvar(), agent_cleanup(), agent_new(), ast_do_masquerade(), ast_hangup(), ast_iax2_new(), ast_pbx_outgoing_cdr_failed(), gtalk_newcall(), local_new(), make_email_file(), pbx_substitute_variables_helper_full(), and sendpage().
01218 { 01219 int fd; 01220 struct ast_var_t *vardata; 01221 struct ast_frame *f; 01222 struct varshead *headp; 01223 struct ast_datastore *datastore = NULL; 01224 char name[AST_CHANNEL_NAME], *dashptr; 01225 01226 headp=&chan->varshead; 01227 01228 AST_LIST_LOCK(&channels); 01229 if (!AST_LIST_REMOVE(&channels, chan, chan_list)) { 01230 AST_LIST_UNLOCK(&channels); 01231 ast_log(LOG_ERROR, "Unable to find channel in list to free. Assuming it has already been done.\n"); 01232 } 01233 /* Lock and unlock the channel just to be sure nobody has it locked still 01234 due to a reference retrieved from the channel list. */ 01235 ast_channel_lock(chan); 01236 ast_channel_unlock(chan); 01237 01238 /* Get rid of each of the data stores on the channel */ 01239 while ((datastore = AST_LIST_REMOVE_HEAD(&chan->datastores, entry))) 01240 /* Free the data store */ 01241 ast_channel_datastore_free(datastore); 01242 01243 /* Lock and unlock the channel just to be sure nobody has it locked still 01244 due to a reference that was stored in a datastore. (i.e. app_chanspy) */ 01245 ast_channel_lock(chan); 01246 ast_channel_unlock(chan); 01247 01248 if (chan->tech_pvt) { 01249 ast_log(LOG_WARNING, "Channel '%s' may not have been hung up properly\n", chan->name); 01250 free(chan->tech_pvt); 01251 } 01252 01253 if (chan->sched) 01254 sched_context_destroy(chan->sched); 01255 01256 ast_copy_string(name, chan->name, sizeof(name)); 01257 if ((dashptr = strrchr(name, '-'))) { 01258 *dashptr = '\0'; 01259 } 01260 01261 /* Stop monitoring */ 01262 if (chan->monitor) 01263 chan->monitor->stop( chan, 0 ); 01264 01265 /* If there is native format music-on-hold state, free it */ 01266 if (chan->music_state) 01267 ast_moh_cleanup(chan); 01268 01269 /* Free translators */ 01270 if (chan->readtrans) 01271 ast_translator_free_path(chan->readtrans); 01272 if (chan->writetrans) 01273 ast_translator_free_path(chan->writetrans); 01274 if (chan->pbx) 01275 ast_log(LOG_WARNING, "PBX may not have been terminated properly on '%s'\n", chan->name); 01276 free_cid(&chan->cid); 01277 /* Close pipes if appropriate */ 01278 if ((fd = chan->alertpipe[0]) > -1) 01279 close(fd); 01280 if ((fd = chan->alertpipe[1]) > -1) 01281 close(fd); 01282 if ((fd = chan->timingfd) > -1) 01283 close(fd); 01284 while ((f = AST_LIST_REMOVE_HEAD(&chan->readq, frame_list))) 01285 ast_frfree(f); 01286 01287 /* loop over the variables list, freeing all data and deleting list items */ 01288 /* no need to lock the list, as the channel is already locked */ 01289 01290 while ((vardata = AST_LIST_REMOVE_HEAD(headp, entries))) 01291 ast_var_delete(vardata); 01292 01293 ast_app_group_discard(chan); 01294 01295 /* Destroy the jitterbuffer */ 01296 ast_jb_destroy(chan); 01297 01298 if (chan->cdr) { 01299 ast_cdr_discard(chan->cdr); 01300 chan->cdr = NULL; 01301 } 01302 01303 ast_mutex_destroy(&chan->lock); 01304 01305 ast_string_field_free_memory(chan); 01306 free(chan); 01307 AST_LIST_UNLOCK(&channels); 01308 01309 ast_device_state_changed_literal(name); 01310 }
| static const char* ast_channel_getformatname | ( | struct ast_channel * | chan | ) | [inline, static] |
Definition at line 1170 of file channel.h.
References ast_getformatname(), and ast_channel::nativeformats.
01171 { 01172 #ifndef BUG_4825 01173 return chan ? ast_getformatname(chan->nativeformats) : "undefined"; 01174 #else 01175 return chan ? ast_getformatname(chan->nativeformats.audio_bits) : "undefined"; 01176 #endif 01177 }
| static char* ast_channel_getformatname_multiple | ( | char * | buf, | |
| size_t | size, | |||
| struct ast_channel * | chan | |||
| ) | [inline, static] |
Get the names of a set of formats.
| buf | a buffer for the output string | |
| size | size of buf (bytes) | |
| channel | the channel Prints a list of readable codec names corresponding to "format". ex: for format=AST_FORMAT_GSM|AST_FORMAT_SPEEX|AST_FORMAT_ILBC it will return "0x602 (GSM|SPEEX|ILBC)" |
Definition at line 1164 of file channel.h.
References ast_getformatname_multiple(), and ast_channel::nativeformats.
01165 { 01166 return ast_getformatname_multiple(buf, size, chan->nativeformats); 01167 }
| 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 3431 of file channel.c.
References AST_LIST_INSERT_TAIL, AST_LIST_TRAVERSE, ast_log(), ast_var_assign(), ast_var_full_name(), ast_var_name(), ast_var_value(), ast_var_t::entries, LOG_DEBUG, option_debug, and ast_channel::varshead.
Referenced by __ast_request_and_dial(), agent_call(), ast_feature_request_and_dial(), begin_dial(), findmeexec(), ring_entry(), and wait_for_answer().
03432 { 03433 struct ast_var_t *current, *newvar; 03434 const char *varname; 03435 03436 AST_LIST_TRAVERSE(&parent->varshead, current, entries) { 03437 int vartype = 0; 03438 03439 varname = ast_var_full_name(current); 03440 if (!varname) 03441 continue; 03442 03443 if (varname[0] == '_') { 03444 vartype = 1; 03445 if (varname[1] == '_') 03446 vartype = 2; 03447 } 03448 03449 switch (vartype) { 03450 case 1: 03451 newvar = ast_var_assign(&varname[1], ast_var_value(current)); 03452 if (newvar) { 03453 AST_LIST_INSERT_TAIL(&child->varshead, newvar, entries); 03454 if (option_debug) 03455 ast_log(LOG_DEBUG, "Copying soft-transferable variable %s.\n", ast_var_name(newvar)); 03456 } 03457 break; 03458 case 2: 03459 newvar = ast_var_assign(ast_var_full_name(current), ast_var_value(current)); 03460 if (newvar) { 03461 AST_LIST_INSERT_TAIL(&child->varshead, newvar, entries); 03462 if (option_debug) 03463 ast_log(LOG_DEBUG, "Copying hard-transferable variable %s.\n", ast_var_name(newvar)); 03464 } 03465 break; 03466 default: 03467 if (option_debug) 03468 ast_log(LOG_DEBUG, "Not copying variable %s.\n", ast_var_name(current)); 03469 break; 03470 } 03471 } 03472 }
| 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 Set two channels to compatible formats -- call before ast_channel_bridge in general . |
Definition at line 3284 of file channel.c.
References AST_FORMAT_SLINEAR, ast_log(), ast_opt_transcode_via_slin, ast_set_read_format(), ast_set_write_format(), ast_translate_path_steps(), ast_translator_best_choice(), LOG_WARNING, ast_channel::name, ast_channel::nativeformats, ast_channel::readformat, and ast_channel::writeformat.
Referenced by action_bridge(), app_exec(), ast_channel_bridge(), bridge_exec(), check_compat(), park_exec(), try_calling(), and wait_for_answer().
03285 { 03286 int src; 03287 int dst; 03288 03289 if (chan->readformat == peer->writeformat && chan->writeformat == peer->readformat) { 03290 /* Already compatible! Moving on ... */ 03291 return 0; 03292 } 03293 03294 /* Set up translation from the chan to the peer */ 03295 src = chan->nativeformats; 03296 dst = peer->nativeformats; 03297 if (ast_translator_best_choice(&dst, &src) < 0) { 03298 ast_log(LOG_WARNING, "No path to translate from %s(%d) to %s(%d)\n", chan->name, src, peer->name, dst); 03299 return -1; 03300 } 03301 03302 /* if the best path is not 'pass through', then 03303 transcoding is needed; if desired, force transcode path 03304 to use SLINEAR between channels, but only if there is 03305 no direct conversion available */ 03306 if ((src != dst) && ast_opt_transcode_via_slin && 03307 (ast_translate_path_steps(dst, src) != 1)) 03308 dst = AST_FORMAT_SLINEAR; 03309 if (ast_set_read_format(chan, dst) < 0) { 03310 ast_log(LOG_WARNING, "Unable to set read format on channel %s to %d\n", chan->name, dst); 03311 return -1; 03312 } 03313 if (ast_set_write_format(peer, dst) < 0) { 03314 ast_log(LOG_WARNING, "Unable to set write format on channel %s to %d\n", peer->name, dst); 03315 return -1; 03316 } 03317 03318 /* Set up translation from the peer to the chan */ 03319 src = peer->nativeformats; 03320 dst = chan->nativeformats; 03321 if (ast_translator_best_choice(&dst, &src) < 0) { 03322 ast_log(LOG_WARNING, "No path to translate from %s(%d) to %s(%d)\n", peer->name, src, chan->name, dst); 03323 return -1; 03324 } 03325 03326 /* if the best path is not 'pass through', then 03327 transcoding is needed; if desired, force transcode path 03328 to use SLINEAR between channels, but only if there is 03329 no direct conversion available */ 03330 if ((src != dst) && ast_opt_transcode_via_slin && 03331 (ast_translate_path_steps(dst, src) != 1)) 03332 dst = AST_FORMAT_SLINEAR; 03333 if (ast_set_read_format(peer, dst) < 0) { 03334 ast_log(LOG_WARNING, "Unable to set read format on channel %s to %d\n", peer->name, dst); 03335 return -1; 03336 } 03337 if (ast_set_write_format(chan, dst) < 0) { 03338 ast_log(LOG_WARNING, "Unable to set write format on channel %s to %d\n", chan->name, dst); 03339 return -1; 03340 } 03341 return 0; 03342 }
| 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 This is a very strange and freaky function used primarily for transfer. Suppose that "original" and "clone" are two channels in random situations. This function takes the guts out of "clone" and puts them into the "original" channel, then alerts the channel driver of the change, asking it to fixup any private information (like the p->owner pointer) that is affected by the change. The physical layer of the original channel is hung up. |
Definition at line 3344 of file channel.c.
References ast_channel::_bridge, ast_bridged_channel(), ast_channel_lock, ast_channel_trylock, ast_channel_unlock, ast_log(), ast_null_frame, ast_queue_frame(), ast_channel_tech::get_base_channel, LOG_DEBUG, LOG_WARNING, ast_channel::masq, ast_channel::masqr, ast_channel::name, option_debug, and ast_channel::tech.
Referenced by 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_transfer_bc(), pickup_channel(), pickup_do(), sip_park(), and steal_channel().
03345 { 03346 int res = -1; 03347 struct ast_channel *final_orig, *final_clone, *base; 03348 03349 retrymasq: 03350 final_orig = original; 03351 final_clone = clone; 03352 03353 ast_channel_lock(original); 03354 while (ast_channel_trylock(clone)) { 03355 ast_channel_unlock(original); 03356 usleep(1); 03357 ast_channel_lock(original); 03358 } 03359 03360 /* each of these channels may be sitting behind a channel proxy (i.e. chan_agent) 03361 and if so, we don't really want to masquerade it, but its proxy */ 03362 if (original->_bridge && (original->_bridge != ast_bridged_channel(original)) && (original->_bridge->_bridge != original)) 03363 final_orig = original->_bridge; 03364 03365 if (clone->_bridge && (clone->_bridge != ast_bridged_channel(clone)) && (clone->_bridge->_bridge != clone)) 03366 final_clone = clone->_bridge; 03367 03368 if (final_clone->tech->get_base_channel && (base = final_clone->tech->get_base_channel(final_clone))) { 03369 final_clone = base; 03370 } 03371 03372 if ((final_orig != original) || (final_clone != clone)) { 03373 /* Lots and lots of deadlock avoidance. The main one we're competing with 03374 * is ast_write(), which locks channels recursively, when working with a 03375 * proxy channel. */ 03376 if (ast_channel_trylock(final_orig)) { 03377 ast_channel_unlock(clone); 03378 ast_channel_unlock(original); 03379 goto retrymasq; 03380 } 03381 if (ast_channel_trylock(final_clone)) { 03382 ast_channel_unlock(final_orig); 03383 ast_channel_unlock(clone); 03384 ast_channel_unlock(original); 03385 goto retrymasq; 03386 } 03387 ast_channel_unlock(clone); 03388 ast_channel_unlock(original); 03389 original = final_orig; 03390 clone = final_clone; 03391 } 03392 03393 if (original == clone) { 03394 ast_log(LOG_WARNING, "Can't masquerade channel '%s' into itself!\n", original->name); 03395 ast_channel_unlock(clone); 03396 ast_channel_unlock(original); 03397 return -1; 03398 } 03399 03400 if (option_debug) 03401 ast_log(LOG_DEBUG, "Planning to masquerade channel %s into the structure of %s\n", 03402 clone->name, original->name); 03403 if (original->masq) { 03404 ast_log(LOG_WARNING, "%s is already going to masquerade as %s\n", 03405 original->masq->name, original->name); 03406 } else if (clone->masqr) { 03407 ast_log(LOG_WARNING, "%s is already going to masquerade as %s\n", 03408 clone->name, clone->masqr->name); 03409 } else { 03410 original->masq = clone; 03411 clone->masqr = original; 03412 ast_queue_frame(original, &ast_null_frame); 03413 ast_queue_frame(clone, &ast_null_frame); 03414 if (option_debug) 03415 ast_log(LOG_DEBUG, "Done planning to masquerade channel %s into the structure of %s\n", clone->name, original->name); 03416 res = 0; 03417 } 03418 03419 ast_channel_unlock(clone); 03420 ast_channel_unlock(original); 03421 03422 return res; 03423 }
| struct ast_frame* ast_channel_queryoption | ( | struct ast_channel * | channel, | |
| int | option, | |||
| void * | data, | |||
| int * | datalen, | |||
| int | block | |||
| ) | [read] |
Checks the value of an option
Query the value of an option, optionally blocking until a reply is received Works similarly to setoption except only reads the options.
| 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 2977 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().
02978 { 02979 switch (reason) /* the following appear to be the only ones actually returned by request_and_dial */ 02980 { 02981 case 0: 02982 return "Call Failure (not BUSY, and not NO_ANSWER, maybe Circuit busy or down?)"; 02983 case AST_CONTROL_HANGUP: 02984 return "Hangup"; 02985 case AST_CONTROL_RING: 02986 return "Local Ring"; 02987 case AST_CONTROL_RINGING: 02988 return "Remote end Ringing"; 02989 case AST_CONTROL_ANSWER: 02990 return "Remote end has Answered"; 02991 case AST_CONTROL_BUSY: 02992 return "Remote end is Busy"; 02993 case AST_CONTROL_CONGESTION: 02994 return "Congestion (circuits busy)"; 02995 default: 02996 return "Unknown Reason!!"; 02997 } 02998 }
| int ast_channel_register | ( | const struct ast_channel_tech * | tech | ) |
Register a channel technology (a new channel driver) Called by a channel module to register the kind of channels it supports.
| tech | Structure defining channel technology or "type" |
Definition at line 496 of file channel.c.
References ast_calloc, AST_LIST_INSERT_HEAD, AST_LIST_LOCK, AST_LIST_TRAVERSE, AST_LIST_UNLOCK, ast_log(), ast_verbose(), ast_channel_tech::description, chanlist::list, LOG_DEBUG, LOG_WARNING, option_debug, option_verbose, chanlist::tech, ast_channel_tech::type, and VERBOSE_PREFIX_2.
Referenced by load_module(), and unload_module().
00497 { 00498 struct chanlist *chan; 00499 00500 AST_LIST_LOCK(&channels); 00501 00502 AST_LIST_TRAVERSE(&backends, chan, list) { 00503 if (!strcasecmp(tech->type, chan->tech->type)) { 00504 ast_log(LOG_WARNING, "Already have a handler for type '%s'\n", tech->type); 00505 AST_LIST_UNLOCK(&channels); 00506 return -1; 00507 } 00508 } 00509 00510 if (!(chan = ast_calloc(1, sizeof(*chan)))) { 00511 AST_LIST_UNLOCK(&channels); 00512 return -1; 00513 } 00514 chan->tech = tech; 00515 AST_LIST_INSERT_HEAD(&backends, chan, list); 00516 00517 if (option_debug) 00518 ast_log(LOG_DEBUG, "Registered handler for '%s' (%s)\n", chan->tech->type, chan->tech->description); 00519 00520 if (option_verbose > 1) 00521 ast_verbose(VERBOSE_PREFIX_2 "Registered channel type '%s' (%s)\n", chan->tech->type, 00522 chan->tech->description); 00523 00524 AST_LIST_UNLOCK(&channels); 00525 return 0; 00526 }
| 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. Returns 0 on success or -1 on failure
Definition at line 3272 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().
03273 { 03274 if (chan->tech->send_html) 03275 return chan->tech->send_html(chan, subclass, data, datalen); 03276 return -1; 03277 }
| int ast_channel_sendurl | ( | struct ast_channel * | channel, | |
| const char * | url | |||
| ) |
Sends a URL on a given link
Send URL on link. Returns 0 on success or -1 on failure
Definition at line 3279 of file channel.c.
References ast_channel_sendhtml(), and AST_HTML_URL.
Referenced by sendurl_exec(), and try_calling().
03280 { 03281 return ast_channel_sendhtml(chan, AST_HTML_URL, url, strlen(url) + 1); 03282 }
| int ast_channel_setoption | ( | struct ast_channel * | channel, | |
| int | option, | |||
| void * | data, | |||
| int | datalen, | |||
| int | block | |||
| ) |
Sets an option on a channel.
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 Set an option on a channel (see frame.h), optionally blocking awaiting the reply Returns 0 on success and -1 on failure |
Definition at line 4316 of file channel.c.
References ast_log(), errno, LOG_ERROR, ast_channel_tech::setoption, and ast_channel::tech.
Referenced by ast_bridge_call(), common_exec(), conf_run(), dahdi_hangup(), func_channel_write(), handle_tddmode(), play_record_review(), reset_volumes(), rpt(), rpt_exec(), set_listen_volume(), set_talk_volume(), try_calling(), and vm_forwardoptions().
04317 { 04318 int res; 04319 04320 if (chan->tech->setoption) { 04321 res = chan->tech->setoption(chan, option, data, datalen); 04322 if (res < 0) 04323 return res; 04324 } else { 04325 errno = ENOSYS; 04326 return -1; 04327 } 04328 if (block) { 04329 /* XXX Implement blocking -- just wait for our option frame reply, discarding 04330 intermediate packets. XXX */ 04331 ast_log(LOG_ERROR, "XXX Blocking not implemented yet XXX\n"); 04332 return -1; 04333 } 04334 return 0; 04335 }
| 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 from current time of when to hang up This function sets the absolute time out on a channel (when to hang up). |
Definition at line 466 of file channel.c.
References ast_null_frame, ast_queue_frame(), and ast_channel::whentohangup.
Referenced by action_timeout(), and timeout_write().
00467 { 00468 chan->whentohangup = offset ? time(NULL) + offset : 0; 00469 ast_queue_frame(chan, &ast_null_frame); 00470 return; 00471 }
| 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 |
The pointer returned by this function must be preserved and passed to ast_channel_stop_silence_generator when you wish to stop the silence generation.
Definition at line 4644 of file channel.c.
References ast_activate_generator(), ast_calloc, AST_FORMAT_SLINEAR, ast_log(), ast_set_write_format(), free, LOG_DEBUG, LOG_ERROR, ast_channel::name, ast_silence_generator::old_write_format, option_debug, and ast_channel::writeformat.
Referenced by __ast_play_and_record(), ast_dtmf_stream(), channel_spy(), and record_exec().
04645 { 04646 struct ast_silence_generator *state; 04647 04648 if (!(state = ast_calloc(1, sizeof(*state)))) { 04649 return NULL; 04650 } 04651 04652 state->old_write_format = chan->writeformat; 04653 04654 if (ast_set_write_format(chan, AST_FORMAT_SLINEAR) < 0) { 04655 ast_log(LOG_ERROR, "Could not set write format to SLINEAR\n"); 04656 free(state); 04657 return NULL; 04658 } 04659 04660 ast_activate_generator(chan, &silence_generator, state); 04661 04662 if (option_debug) 04663 ast_log(LOG_DEBUG, "Started silence generator on '%s'\n", chan->name); 04664 04665 return state; 04666 }
| 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 4668 of file channel.c.
References ast_deactivate_generator(), ast_log(), ast_set_write_format(), free, LOG_DEBUG, LOG_ERROR, ast_channel::name, ast_silence_generator::old_write_format, and option_debug.
Referenced by __ast_play_and_record(), ast_dtmf_stream(), channel_spy(), and record_exec().
04669 { 04670 if (!state) 04671 return; 04672 04673 ast_deactivate_generator(chan); 04674 04675 if (option_debug) 04676 ast_log(LOG_DEBUG, "Stopped silence generator on '%s'\n", chan->name); 04677 04678 if (ast_set_write_format(chan, state->old_write_format) < 0) 04679 ast_log(LOG_ERROR, "Could not return write format to its original state\n"); 04680 04681 free(state); 04682 }
| int ast_channel_supports_html | ( | struct ast_channel * | channel | ) |
Checks for HTML support on a channel
Returns 0 if channel does not support HTML or non-zero if it does
Definition at line 3267 of file channel.c.
References ast_channel_tech::send_html, and ast_channel::tech.
Referenced by sendurl_exec(), and try_calling().
| void ast_channel_undefer_dtmf | ( | struct ast_channel * | chan | ) |
Unset defer DTMF flag on channel.
Undeos a defer
Undo defer. ast_read will return any dtmf characters that were queued
Definition at line 1022 of file channel.c.
References ast_clear_flag, and AST_FLAG_DEFER_DTMF.
Referenced by __adsi_transmit_messages(), find_cache(), and rpt_call().
01023 { 01024 if (chan) 01025 ast_clear_flag(chan, AST_FLAG_DEFER_DTMF); 01026 }
| void ast_channel_unregister | ( | const struct ast_channel_tech * | tech | ) |
Unregister a channel technology.
| tech | Structure defining channel technology or "type" that was previously registered |
Definition at line 528 of file channel.c.
References AST_LIST_LOCK, AST_LIST_REMOVE_CURRENT, AST_LIST_TRAVERSE_SAFE_BEGIN, AST_LIST_TRAVERSE_SAFE_END, AST_LIST_UNLOCK, ast_log(), ast_verbose(), free, chanlist::list, LOG_DEBUG, option_debug, option_verbose, chanlist::tech, ast_channel_tech::type, and VERBOSE_PREFIX_2.
Referenced by __unload_module(), and unload_module().
00529 { 00530 struct chanlist *chan; 00531 00532 if (option_debug) 00533 ast_log(LOG_DEBUG, "Unregistering channel type '%s'\n", tech->type); 00534 00535 AST_LIST_LOCK(&channels); 00536 00537 AST_LIST_TRAVERSE_SAFE_BEGIN(&backends, chan, list) { 00538 if (chan->tech == tech) { 00539 AST_LIST_REMOVE_CURRENT(&backends, list); 00540 free(chan); 00541 if (option_verbose > 1) 00542 ast_verbose(VERBOSE_PREFIX_2 "Unregistered channel type '%s'\n", tech->type); 00543 break; 00544 } 00545 } 00546 AST_LIST_TRAVERSE_SAFE_END 00547 00548 AST_LIST_UNLOCK(&channels); 00549 }
| struct ast_channel* ast_channel_walk_locked | ( | const struct ast_channel * | prev | ) | [read] |
Browse channels in use Browse the channels currently in use.
| prev | where you want to start in the channel list |
Definition at line 1138 of file channel.c.
References channel_find_locked().
Referenced by action_status(), ast_complete_channels(), ast_pickup_call(), complete_ch_helper(), conf_exec(), find_matching_channel(), handle_chanlist(), handle_chanlist_deprecated(), handle_core_set_debug_channel(), handle_debugchan_deprecated(), handle_nodebugchan_deprecated(), next_channel(), pickup_by_exten(), pickup_by_mark(), and softhangup_exec().
01139 { 01140 return channel_find_locked(prev, NULL, 0, NULL, NULL); 01141 }
| int ast_channel_whisper_feed | ( | struct ast_channel * | chan, | |
| struct ast_frame * | f | |||
| ) |
Feed an audio frame into the whisper buffer on a channel.
| chan | The channel to whisper onto | |
| f | The frame to to whisper onto chan |
| int ast_channel_whisper_start | ( | struct ast_channel * | chan | ) |
Begin 'whispering' onto a channel.
| chan | The channel to whisper onto |
Note: This function performs no locking; you must hold the channel's lock before calling this function.
| void ast_channel_whisper_stop | ( | struct ast_channel * | chan | ) |
Stop 'whispering' onto a channel.
| chan | The channel to whisper onto |
| struct ast_variable* ast_channeltype_list | ( | void | ) | [read] |
return an ast_variable list of channeltypes
Definition at line 162 of file channel.c.
References AST_LIST_TRAVERSE, ast_variable_new(), ast_channel_tech::description, chanlist::list, chanlist::tech, ast_channel_tech::type, and var.
00163 { 00164 struct chanlist *cl; 00165 struct ast_variable *var=NULL, *prev = NULL; 00166 AST_LIST_TRAVERSE(&backends, cl, list) { 00167 if (prev) { 00168 if ((prev->next = ast_variable_new(cl->tech->type, cl->tech->description))) 00169 prev = prev->next; 00170 } else { 00171 var = ast_variable_new(cl->tech->type, cl->tech->description); 00172 prev = var; 00173 } 00174 } 00175 return var; 00176 }
| int ast_check_hangup | ( | struct ast_channel * | chan | ) |
Check to see if a channel is needing hang up.
| chan | channel on which to check for hang up This function determines if the channel is being requested to be hung up. |
Definition at line 384 of file channel.c.
References ast_channel::_softhangup, AST_SOFTHANGUP_TIMEOUT, ast_channel::tech_pvt, and ast_channel::whentohangup.
Referenced by __ast_read(), action_redirect(), agent_indicate(), announce_thread(), app_exec(), ast_answer(), ast_bridge_call(), ast_bridge_call_thread(), ast_call(), ast_channel_bridge(), ast_check_hangup_locked(), ast_feature_request_and_dial(), ast_indicate_data(), ast_readstring_full(), ast_recvtext(), ast_rtp_bridge(), ast_sendtext(), ast_transfer(), ast_udptl_bridge(), ast_waitfordigit_full(), ast_write(), bridge_exec(), bridge_native_loop(), bridge_p2p_loop(), builtin_atxfer(), channel_spy(), common_exec(), conf_run(), dahdi_sendtext(), dahdi_setoption(), deadagi_exec(), handle_request_invite(), handle_sendimage(), iax2_bridge(), pbx_exec(), rpt(), rpt_exec(), and wait_for_answer().
00385 { 00386 if (chan->_softhangup) /* yes if soft hangup flag set */ 00387 return 1; 00388 if (!chan->tech_pvt) /* yes if no technology private data */ 00389 return 1; 00390 if (!chan->whentohangup) /* no if no hangup scheduled */ 00391 return 0; 00392 if (chan->whentohangup > time(NULL)) /* no if hangup time has not come yet. */ 00393 return 0; 00394 chan->_softhangup |= AST_SOFTHANGUP_TIMEOUT; /* record event */ 00395 return 1; 00396 }
| void ast_deactivate_generator | ( | struct ast_channel * | chan | ) |
Deactive an active generator
Definition at line 1588 of file channel.c.
References ast_channel_lock, ast_channel_unlock, ast_clear_flag, AST_FLAG_WRITE_INT, AST_GENERATOR_FD, ast_settimeout(), ast_channel::fds, 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(), generator_force(), local_ast_moh_stop(), old_milliwatt_exec(), transmit_audio(), and wait_for_answer().
01589 { 01590 ast_channel_lock(chan); 01591 if (chan->generatordata) { 01592 if (chan->generator && chan->generator->release) 01593 chan->generator->release(chan, chan->generatordata); 01594 chan->generatordata = NULL; 01595 chan->generator = NULL; 01596 chan->fds[AST_GENERATOR_FD] = -1; 01597 ast_clear_flag(chan, AST_FLAG_WRITE_INT); 01598 ast_settimeout(chan, 0, NULL, NULL); 01599 } 01600 ast_channel_unlock(chan); 01601 }
| int ast_do_masquerade | ( | struct ast_channel * | original | ) |
Start masquerading a channel XXX This is a seriously wacked out operation. We're essentially putting the guts of the clone channel into the original channel. Start by killing off the original channel's backend. I'm not sure we're going to keep this function, because while the features are nice, the cost is very high in terms of pure nastiness. XXX.
| chan | Channel to masquerade |
Definition at line 3505 of file channel.c.
References ast_channel::_softhangup, ast_channel::_state, ast_channel::adsicpe, ast_channel::alertpipe, ast_app_group_update(), ast_cause2str(), ast_channel_free(), ast_channel_lock, ast_channel_unlock, ast_copy_flags, ast_copy_string(), AST_FLAG_BLOCKING, AST_FLAG_EXCEPTION, AST_FLAG_OUTGOING, AST_FLAG_ZOMBIE, AST_GENERATOR_FD, 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, ast_log(), AST_MAX_FDS, ast_null_frame, ast_queue_frame(), ast_set_flag, ast_set_read_format(), ast_set_write_format(), AST_SOFTHANGUP_DEV, ast_string_field_set, ast_test_flag, AST_TIMING_FD, ast_channel::blocker, ast_channel::cdr, ast_datastore_info::chan_fixup, ast_channel::cid, clone_variables(), ast_datastore::data, ast_channel::datastores, ast_datastore::entry, 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, ast_channel::lock, LOG_DEBUG, LOG_WARNING, manager_event(), ast_channel::masq, ast_channel::masqr, ast_channel::monitor, ast_channel::musicclass, musicclass, name, ast_channel::name, ast_channel::nativeformats, option_debug, ast_channel::rawreadformat, ast_channel::rawwriteformat, ast_channel::readformat, ast_channel::readq, t, 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(), iax_park(), sip_park(), and sip_park_thread().
03506 { 03507 int x,i; 03508 int res=0; 03509 int origstate; 03510 struct ast_frame *cur; 03511 const struct ast_channel_tech *t; 03512 void *t_pvt; 03513 struct ast_callerid tmpcid; 03514 struct ast_channel *clone = original->masq; 03515 struct ast_cdr *cdr; 03516 int rformat = original->readformat; 03517 int wformat = original->writeformat; 03518 char newn[100]; 03519 char orig[100]; 03520 char masqn[100]; 03521 char zombn[100]; 03522 03523 if (option_debug > 3) 03524 ast_log(LOG_DEBUG, "Actually Masquerading %s(%d) into the structure of %s(%d)\n", 03525 clone->name, clone->_state, original->name, original->_state); 03526 03527 /* XXX This is a seriously wacked out operation. We're essentially putting the guts of 03528 the clone channel into the original channel. Start by killing off the original 03529 channel's backend. I'm not sure we're going to keep this function, because 03530 while the features are nice, the cost is very high in terms of pure nastiness. XXX */ 03531 03532 /* We need the clone's lock, too */ 03533 ast_channel_lock(clone); 03534 03535 if (option_debug > 1) 03536 ast_log(LOG_DEBUG, "Got clone lock for masquerade on '%s' at %p\n", clone->name, &clone->lock); 03537 03538 /* Having remembered the original read/write formats, we turn off any translation on either 03539 one */ 03540 free_translation(clone); 03541 free_translation(original); 03542 03543 03544 /* Unlink the masquerade */ 03545 original->masq = NULL; 03546 clone->masqr = NULL; 03547 03548 /* Save the original name */ 03549 ast_copy_string(orig, original->name, sizeof(orig)); 03550 /* Save the new name */ 03551 ast_copy_string(newn, clone->name, sizeof(newn)); 03552 /* Create the masq name */ 03553 snprintf(masqn, sizeof(masqn), "%s<MASQ>", newn); 03554 03555 /* Copy the name from the clone channel */ 03556 ast_string_field_set(original, name, newn); 03557 03558 /* Mangle the name of the clone channel */ 03559 ast_string_field_set(clone, name, masqn); 03560 03561 /* Notify any managers of the change, first the masq then the other */ 03562 manager_event(EVENT_FLAG_CALL, "Rename", "Oldname: %s\r\nNewname: %s\r\nUniqueid: %s\r\n", newn, masqn, clone->uniqueid); 03563 manager_event(EVENT_FLAG_CALL, "Rename", "Oldname: %s\r\nNewname: %s\r\nUniqueid: %s\r\n", orig, newn, original->uniqueid); 03564 03565 /* Swap the technologies */ 03566 t = original->tech; 03567 original->tech = clone->tech; 03568 clone->tech = t; 03569 03570 /* Swap the cdrs */ 03571 cdr = original->cdr; 03572 original->cdr = clone->cdr; 03573 clone->cdr = cdr; 03574 03575 t_pvt = original->tech_pvt; 03576 original->tech_pvt = clone->tech_pvt; 03577 clone->tech_pvt = t_pvt; 03578 03579 /* Swap the alertpipes */ 03580 for (i = 0; i < 2; i++) { 03581 x = original->alertpipe[i]; 03582 original->alertpipe[i] = clone->alertpipe[i]; 03583 clone->alertpipe[i] = x; 03584 } 03585 03586 /* 03587 * Swap the readq's. The end result should be this: 03588 * 03589 * 1) All frames should be on the new (original) channel. 03590 * 2) Any frames that were already on the new channel before this 03591 * masquerade need to be at the end of the readq, after all of the 03592 * frames on the old (clone) channel. 03593 * 3) The alertpipe needs to get poked for every frame that was already 03594 * on the new channel, since we are now using the alert pipe from the 03595 * old (clone) channel. 03596 */ 03597 { 03598 AST_LIST_HEAD_NOLOCK(, ast_frame) tmp_readq; 03599 AST_LIST_HEAD_SET_NOLOCK(&tmp_readq, NULL); 03600 03601 AST_LIST_APPEND_LIST(&tmp_readq, &original->readq, frame_list); 03602 AST_LIST_APPEND_LIST(&original->readq, &clone->readq, frame_list); 03603 03604 while ((cur = AST_LIST_REMOVE_HEAD(&tmp_readq, frame_list))) { 03605 AST_LIST_INSERT_TAIL(&original->readq, cur, frame_list); 03606 if (original->alertpipe[1] > -1) { 03607 int poke = 0; 03608 03609 if (write(original->alertpipe[1], &poke, sizeof(poke)) < 0) { 03610 ast_log(LOG_WARNING, "write() failed: %s\n", strerror(errno)); 03611 } 03612 } 03613 } 03614 } 03615 03616 /* Swap the raw formats */ 03617 x = original->rawreadformat; 03618 original->rawreadformat = clone->rawreadformat; 03619 clone->rawreadformat = x; 03620 x = original->rawwriteformat; 03621 original->rawwriteformat = clone->rawwriteformat; 03622 clone->rawwriteformat = x; 03623 03624 clone->_softhangup = AST_SOFTHANGUP_DEV; 03625 03626 /* And of course, so does our current state. Note we need not 03627 call ast_setstate since the event manager doesn't really consider 03628 these separate. We do this early so that the clone has the proper 03629 state of the original channel. */ 03630 origstate = original->_state; 03631 original->_state = clone->_state; 03632 clone->_state = origstate; 03633 03634 if (clone->tech->fixup){ 03635 res = clone->tech->fixup(original, clone); 03636 if (res) 03637 ast_log(LOG_WARNING, "Fixup failed on channel %s, strange things may happen.\n", clone->name); 03638 } 03639 03640 /* Start by disconnecting the original's physical side */ 03641 if (clone->tech->hangup) 03642 res = clone->tech->hangup(clone); 03643 if (res) { 03644 ast_log(LOG_WARNING, "Hangup failed! Strange things may happen!\n"); 03645 ast_channel_unlock(clone); 03646 return -1; 03647 } 03648 03649 snprintf(zombn, sizeof(zombn), "%s<ZOMBIE>", orig); 03650 /* Mangle the name of the clone channel */ 03651 ast_string_field_set(clone, name, zombn); 03652 manager_event(EVENT_FLAG_CALL, "Rename", "Oldname: %s\r\nNewname: %s\r\nUniqueid: %s\r\n", masqn, zombn, clone->uniqueid); 03653 03654 /* Update the type. */ 03655 t_pvt = original->monitor; 03656 original->monitor = clone->monitor; 03657 clone->monitor = t_pvt; 03658 03659 /* Keep the same language. */ 03660 ast_string_field_set(original, language, clone->language); 03661 /* Copy the FD's other than the generator fd */ 03662 for (x = 0; x < AST_MAX_FDS; x++) { 03663 if (x != AST_GENERATOR_FD) 03664 original->fds[x] = clone->fds[x]; 03665 } 03666 03667 ast_app_group_update(clone, original); 03668 /* Move data stores over */ 03669 if (AST_LIST_FIRST(&clone->datastores)) { 03670 struct ast_datastore *ds; 03671 AST_LIST_APPEND_LIST(&original->datastores, &clone->datastores, entry); 03672 AST_LIST_TRAVERSE(&original->datastores, ds, entry) { 03673 if (ds->info->chan_fixup) 03674 ds->info->chan_fixup(ds->data, clone, original); 03675 } 03676 } 03677 03678 clone_variables(original, clone); 03679 /* Presense of ADSI capable CPE follows clone */ 03680 original->adsicpe = clone->adsicpe; 03681 /* Bridge remains the same */ 03682 /* CDR fields remain the same */ 03683 /* XXX What about blocking, softhangup, blocker, and lock and blockproc? XXX */ 03684 /* Application and data remain the same */ 03685 /* Clone exception becomes real one, as with fdno */ 03686 ast_copy_flags(original, clone, AST_FLAG_EXCEPTION | AST_FLAG_OUTGOING); 03687 original->fdno = clone->fdno; 03688 /* Schedule context remains the same */ 03689 /* Stream stuff stays the same */ 03690 /* Keep the original state. The fixup code will need to work with it most likely */ 03691 03692 /* Just swap the whole structures, nevermind the allocations, they'll work themselves 03693 out. */ 03694 tmpcid = original->cid; 03695 original->cid = clone->cid; 03696 clone->cid = tmpcid; 03697 03698 /* Restore original timing file descriptor */ 03699 original->fds[AST_TIMING_FD] = original->timingfd; 03700 03701 /* Our native formats are different now */ 03702 original->nativeformats = clone->nativeformats; 03703 03704 /* Context, extension, priority, app data, jump table, remain the same */ 03705 /* pvt switches. pbx stays the same, as does next */ 03706 03707 /* Set the write format */ 03708 ast_set_write_format(original, wformat); 03709 03710 /* Set the read format */ 03711 ast_set_read_format(original, rformat); 03712 03713 /* Copy the music class */ 03714 ast_string_field_set(original, musicclass, clone->musicclass); 03715 03716 if (option_debug) 03717 ast_log(LOG_DEBUG, "Putting channel %s in %d/%d formats\n", original->name, wformat, rformat); 03718 03719 /* Okay. Last thing is to let the channel driver know about all this mess, so he 03720 can fix up everything as best as possible */ 03721 if (original->tech->fixup) { 03722 res = original->tech->fixup(clone, original); 03723 if (res) { 03724 ast_log(LOG_WARNING, "Channel for type '%s' could not fixup channel %s\n", 03725 original->tech->type, original->name); 03726 ast_channel_unlock(clone); 03727 return -1; 03728 } 03729 } else 03730 ast_log(LOG_WARNING, "Channel type '%s' does not have a fixup routine (for %s)! Bad things may happen.\n", 03731 original->tech->type, original->name); 03732 03733 /* 03734 * If an indication is currently playing, maintain it on the channel 03735 * that is taking the place of original 03736 * 03737 * This is needed because the masquerade is swapping out in the internals 03738 * of this channel, and the new channel private data needs to be made 03739 * aware of the current visible indication (RINGING, CONGESTION, etc.) 03740 */ 03741 if (original->visible_indication) { 03742 ast_indicate(original, original->visible_indication); 03743 } 03744 03745 /* Now, at this point, the "clone" channel is totally F'd up. We mark it as 03746 a zombie so nothing tries to touch it. If it's already been marked as a 03747 zombie, then free it now (since it already is considered invalid). */ 03748 if (ast_test_flag(clone, AST_FLAG_ZOMBIE)) { 03749 if (option_debug) 03750 ast_log(LOG_DEBUG, "Destroying channel clone '%s'\n", clone->name); 03751 ast_channel_unlock(clone); 03752 manager_event(EVENT_FLAG_CALL, "Hangup", 03753 "Channel: %s\r\n" 03754 "Uniqueid: %s\r\n" 03755 "Cause: %d\r\n" 03756 "Cause-txt: %s\r\n", 03757 clone->name, 03758 clone->uniqueid, 03759 clone->hangupcause, 03760 ast_cause2str(clone->hangupcause) 03761 ); 03762 ast_channel_free(clone); 03763 } else { 03764 if (option_debug) 03765 ast_log(LOG_DEBUG, "Released clone lock on '%s'\n", clone->name); 03766 ast_set_flag(clone, AST_FLAG_ZOMBIE); 03767 ast_queue_frame(clone, &ast_null_frame); 03768 ast_channel_unlock(clone); 03769 } 03770 03771 /* Signal any blocker */ 03772 if (ast_test_flag(original, AST_FLAG_BLOCKING)) 03773 pthread_kill(original->blocker, SIGURG); 03774 if (option_debug) 03775 ast_log(LOG_DEBUG, "Done Masquerading %s (%d)\n", original->name, original->_state); 03776 return 0; 03777 }
| static int ast_fdisset | ( | struct pollfd * | pfds, | |
| int | fd, | |||
| int | max, | |||
| int * | start | |||
| ) | [inline, static] |
Helper function for migrating select to poll.
Definition at line 1396 of file channel.h.
References pollfd::revents.
Referenced by do_monitor().
01397 { 01398 int x; 01399 int dummy=0; 01400 01401 if (fd < 0) 01402 return 0; 01403 if (!start) 01404 start = &dummy; 01405 for (x = *start; x<max; x++) 01406 if (pfds[x].fd == fd) { 01407 if (x == *start) 01408 (*start)++; 01409 return pfds[x].revents; 01410 } 01411 return 0; 01412 }
| struct ast_channel* ast_get_channel_by_exten_locked | ( | const char * | exten, | |
| const char * | context | |||
| ) | [read] |
Get channel by exten (and optionally context) and lock it.
Definition at line 1163 of file channel.c.
References channel_find_locked().
01164 { 01165 return channel_find_locked(NULL, NULL, 0, context, exten); 01166 }
| struct ast_channel* ast_get_channel_by_name_locked | ( | const char * | name | ) | [read] |
Get channel by name (locks channel).
Definition at line 1144 of file channel.c.
References channel_find_locked().
Referenced by action_getvar(), action_hangup(), action_redirect(), action_setcdruserfield(), action_setvar(), action_status(), action_timeout(), ast_async_goto_by_name(), ast_bridge_call(), asyncgoto_exec(), change_monitor_action(), do_pause_or_unpause(), get_zap_channel_locked(), handle_channelstatus(), handle_core_set_debug_channel(), handle_debugchan_deprecated(), handle_getvariablefull(), handle_hangup(), handle_nodebugchan_deprecated(), handle_showchan(), handle_showchan_deprecated(), handle_softhangup(), manager_park(), manager_play_dtmf(), park_call_full(), pbx_builtin_importvar(), start_monitor_action(), and stop_monitor_action().
01145 { 01146 return channel_find_locked(NULL, name, 0, NULL, NULL); 01147 }
| struct ast_channel* ast_get_channel_by_name_prefix_locked | ( | const char * | name, | |
| const int | namelen | |||
| ) | [read] |
Get channel by name prefix (locks channel).
Definition at line 1150 of file channel.c.
References channel_find_locked().
Referenced by action_bridge(), ast_parse_device_state(), bridge_exec(), common_exec(), and mixmonitor_cli().
01151 { 01152 return channel_find_locked(NULL, name, namelen, NULL, NULL); 01153 }
| struct ast_channel_tech* ast_get_channel_tech | ( | const char * | name | ) | [read] |
Get a channel technology structure by name.
| name | name of technology to find |
Definition at line 551 of file channel.c.
References AST_LIST_LOCK, AST_LIST_TRAVERSE, AST_LIST_UNLOCK, ast_log(), chanlist::list, LOG_WARNING, chanlist::tech, and ast_channel_tech::type.
Referenced by ast_device_state().
00552 { 00553 struct chanlist *chanls; 00554 const struct ast_channel_tech *ret = NULL; 00555 00556 if (AST_LIST_LOCK(&channels)) { 00557 ast_log(LOG_WARNING, "Unable to lock channel tech list\n"); 00558 return NULL; 00559 } 00560 00561 AST_LIST_TRAVERSE(&backends, chanls, list) { 00562 if (!strcasecmp(name, chanls->tech->type)) { 00563 ret = chanls->tech; 00564 break; 00565 } 00566 } 00567 00568 AST_LIST_UNLOCK(&channels); 00569 00570 return ret; 00571 }
| ast_group_t ast_get_group | ( | const char * | s | ) |
Definition at line 4489 of file channel.c.
References ast_log(), ast_strdupa, ast_strlen_zero(), group, LOG_ERROR, and LOG_WARNING.
Referenced by _parse(), build_device(), build_gateway(), build_peer(), build_user(), func_channel_write(), process_dahdi(), and read_agent_config().
04490 { 04491 char *piece; 04492 char *c; 04493 int start=0, finish=0, x; 04494 ast_group_t group = 0; 04495 04496 if (ast_strlen_zero(s)) 04497 return 0; 04498 04499 c = ast_strdupa(s); 04500 04501 while ((piece = strsep(&c, ","))) { 04502 if (sscanf(piece, "%d-%d", &start, &finish) == 2) { 04503 /* Range */ 04504 } else if (sscanf(piece, "%d", &start)) { 04505 /* Just one */ 04506 finish = start; 04507 } else { 04508 ast_log(LOG_ERROR, "Syntax error parsing group configuration '%s' at '%s'. Ignoring.\n", s, piece); 04509 continue; 04510 } 04511 for (x = start; x <= finish; x++) { 04512 if ((x > 63) || (x < 0)) { 04513 ast_log(LOG_WARNING, "Ignoring invalid group %d (maximum group is 63)\n", x); 04514 } else 04515 group |= ((ast_group_t) 1 << x); 04516 } 04517 } 04518 return group; 04519 }
| static int ast_get_read_format | ( | struct ast_channel * | chan | ) | [inline, static] |
Gets read format from channel chan.
| chan | channel to get info Get read format for channel Returns read format |
Definition at line 936 of file channel.h.
References ast_channel::readformat.
Referenced by ast_channel_formats_reset().
00937 { 00938 return chan->readformat; 00939 }
| static int ast_get_write_format | ( | struct ast_channel * | chan | ) | [inline, static] |
Gets write format from channel chan
| chan | channel to get info Get write format for channel Returns write format |
Definition at line 947 of file channel.h.
References ast_channel::writeformat.
Referenced by ast_channel_formats_reset().
00948 { 00949 return chan->writeformat; 00950 }
| int ast_hangup | ( | struct ast_channel * | chan | ) |
Hang up a channel.
| chan | channel to hang up |
Definition at line 1462 of file channel.c.
References ast_assert, ast_audiohook_detach_list(), ast_autoservice_stop(), ast_cause2str(), ast_cdr_detach(), ast_cdr_end(), AST_CDR_FLAG_BRIDGED, AST_CDR_FLAG_DIALED, AST_CDR_FLAG_POST_DISABLED, AST_CDR_NULL, ast_channel_free(), ast_channel_lock, ast_channel_unlock, ast_closestream(), ast_do_masquerade(), AST_FLAG_BLOCKING, AST_FLAG_ZOMBIE, ast_log(), ast_set_flag, ast_test_flag, ast_channel::audiohooks, ast_channel::blocker, ast_channel::blockproc, ast_channel::cdr, ast_cdr::disposition, EVENT_FLAG_CALL, free_translation(), ast_channel::generator, ast_channel::generatordata, ast_channel_tech::hangup, ast_channel::hangupcause, LOG_DEBUG, LOG_WARNING, manager_event(), ast_channel::masq, ast_channel::masqr, ast_channel::name, option_debug, ast_generator::release, ast_channel::sched, sched_context_destroy(), ast_channel::stream, ast_channel::tech, ast_channel::uniqueid, and ast_channel::vstream.
Referenced by __ast_pbx_run(), __ast_request_and_dial(), __oh323_new(), action_bridge(), agent_hangup(), agent_read(), alsa_new(), answer_exec_run(), app_exec(), ast_async_goto(), ast_bridge_call_thread(), ast_dial_destroy(), ast_dial_hangup(), ast_feature_request_and_dial(), ast_iax2_new(), ast_pbx_outgoing_app(), ast_pbx_outgoing_exten(), ast_pbx_run_app(), async_wait(), begin_dial(), bridge_exec(), build_conf(), builtin_atxfer(), chanavail_exec(), check_compat(), check_goto_on_transfer(), clear_caller(), conf_free(), conf_run(), connect_link(), dahdi_handle_event(), dahdi_new(), do_hang(), do_parking_thread(), features_hangup(), findmeexec(), gtalk_new(), 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(), hangup_chan(), hangupcalls(), hanguptree(), iax2_request(), iax_park(), iax_park_thread(), local_attended_transfer(), local_hangup(), masq_park_call(), mgcp_new(), mgcp_ss(), monitor_dial(), nbs_new(), ooh323_new(), oss_new(), park_exec(), parkandannounce_exec(), phone_new(), rpt(), rpt_call(), rpt_exec(), rpt_tele_thread(), sip_new(), sip_park(), sip_park_thread(), skinny_new(), skinny_ss(), ss_thread(), try_calling(), wait_for_answer(), and wait_for_winner().
01463 { 01464 int res = 0; 01465 01466 /* Don't actually hang up a channel that will masquerade as someone else, or 01467 if someone is going to masquerade as us */ 01468 ast_channel_lock(chan); 01469 01470 if (chan->audiohooks) { 01471 ast_audiohook_detach_list(chan->audiohooks); 01472 chan->audiohooks = NULL; 01473 } 01474 01475 ast_autoservice_stop(chan); 01476 01477 if (chan->masq) { 01478 if (ast_do_masquerade(chan)) 01479 ast_log(LOG_WARNING, "Failed to perform masquerade\n"); 01480 } 01481 01482 if (chan->masq) { 01483 ast_log(LOG_WARNING, "%s getting hung up, but someone is trying to masq into us?!?\n", chan->name); 01484 ast_channel_unlock(chan); 01485 return 0; 01486 } 01487 /* If this channel is one which will be masqueraded into something, 01488 mark it as a zombie already, so we know to free it later */ 01489 if (chan->masqr) { 01490 ast_set_flag(chan, AST_FLAG_ZOMBIE); 01491 ast_channel_unlock(chan); 01492 return 0; 01493 } 01494 free_translation(chan); 01495 /* Close audio stream */ 01496 if (chan->stream) { 01497 ast_closestream(chan->stream); 01498 chan->stream = NULL; 01499 } 01500 /* Close video stream */ 01501 if (chan->vstream) { 01502 ast_closestream(chan->vstream); 01503 chan->vstream = NULL; 01504 } 01505 if (chan->sched) { 01506 sched_context_destroy(chan->sched); 01507 chan->sched = NULL; 01508 } 01509 01510 if (chan->generatordata) /* Clear any tone stuff remaining */ 01511 chan->generator->release(chan, chan->generatordata); 01512 chan->generatordata = NULL; 01513 chan->generator = NULL; 01514 if (ast_test_flag(chan, AST_FLAG_BLOCKING)) { 01515 ast_log(LOG_WARNING, "Hard hangup called by thread %ld on %s, while fd " 01516 "is blocked by thread %ld in procedure %s! Expect a failure\n", 01517 (long)pthread_self(), chan->name, (long)chan->blocker, chan->blockproc); 01518 ast_assert(ast_test_flag(chan, AST_FLAG_BLOCKING) == 0); 01519 } 01520 if (!ast_test_flag(chan, AST_FLAG_ZOMBIE)) { 01521 if (option_debug) 01522 ast_log(LOG_DEBUG, "Hanging up channel '%s'\n", chan->name); 01523 if (chan->tech->hangup) 01524 res = chan->tech->hangup(chan); 01525 } else { 01526 if (option_debug) 01527 ast_log(LOG_DEBUG, "Hanging up zombie '%s'\n", chan->name); 01528 } 01529 01530 ast_channel_unlock(chan); 01531 manager_event(EVENT_FLAG_CALL, "Hangup", 01532 "Channel: %s\r\n" 01533 "Uniqueid: %s\r\n" 01534 "Cause: %d\r\n" 01535 "Cause-txt: %s\r\n", 01536 chan->name, 01537 chan->uniqueid, 01538 chan->hangupcause, 01539 ast_cause2str(chan->hangupcause) 01540 ); 01541 01542 if (chan->cdr && !ast_test_flag(chan->cdr, AST_CDR_FLAG_BRIDGED) && 01543 !ast_test_flag(chan->cdr, AST_CDR_FLAG_POST_DISABLED) && 01544 (chan->cdr->disposition != AST_CDR_NULL || ast_test_flag(chan->cdr, AST_CDR_FLAG_DIALED))) { 01545 01546 ast_cdr_end(chan->cdr); 01547 ast_cdr_detach(chan->cdr); 01548 chan->cdr = NULL; 01549 } 01550 01551 ast_channel_free(chan); 01552 01553 return res; 01554 }
| 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 2445 of file channel.c.
References ast_indicate_data().
Referenced by __ast_play_and_record(), agent_new(), answer_trunk_chan(), ast_bridge_call(), ast_channel_bridge(), ast_do_masquerade(), ast_dtmf_stream(), ast_feature_request_and_dial(), attempt_transfer(), builtin_atxfer(), builtin_blindtransfer(), conf_run(), disa_exec(), do_parking_thread(), features_indicate(), finishup(), function_remote(), handle_frame(), handle_recordfile(), mgcp_ss(), monitor_dial(), park_exec(), pbx_builtin_busy(), pbx_builtin_congestion(), pbx_builtin_progress(), pbx_builtin_ringing(), pbx_builtin_waitexten(), queue_exec(), record_exec(), rpt(), rpt_exec(), send_waveform_to_channel(), skinny_ss(), sla_handle_hold_event(), sla_station_exec(), sla_trunk_exec(), and wait_for_answer().
02446 { 02447 return ast_indicate_data(chan, condition, NULL, 0); 02448 }
| 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 2483 of file channel.c.
References ast_channel_lock, ast_channel_unlock, ast_check_hangup(), AST_CONTROL_ANSWER, AST_CONTROL_BUSY, AST_CONTROL_CONGESTION, 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_RING, AST_CONTROL_RINGING, AST_CONTROL_SRCUPDATE, AST_CONTROL_TAKEOFFHOOK, AST_CONTROL_UNHOLD, AST_CONTROL_VIDUPDATE, AST_CONTROL_WINK, AST_FLAG_ZOMBIE, ast_get_indication_tone(), ast_log(), ast_playtones_start(), ast_playtones_stop(), ast_test_flag, ind_tone_zone_sound::data, ast_channel_tech::indicate, is_visible_indication(), LOG_DEBUG, LOG_WARNING, ast_channel::name, option_debug, ast_channel::tech, ast_channel::visible_indication, and ast_channel::zone.
Referenced by __login_exec(), agent_hangup(), ast_bridge_call(), ast_generic_bridge(), ast_indicate(), bridge_native_loop(), bridge_p2p_loop(), do_parking_thread(), park_call_full(), pbx_builtin_waitexten(), transmit_audio(), and wait_for_answer().
02485 { 02486 /* By using an enum, we'll get compiler warnings for values not handled 02487 * in switch statements. */ 02488 enum ast_control_frame_type condition = _condition; 02489 const struct ind_tone_zone_sound *ts = NULL; 02490 int res = -1; 02491 02492 ast_channel_lock(chan); 02493 02494 /* Don't bother if the channel is about to go away, anyway. */ 02495 if (ast_test_flag(chan, AST_FLAG_ZOMBIE) || ast_check_hangup(chan)) { 02496 ast_channel_unlock(chan); 02497 return -1; 02498 } 02499 02500 if (chan->tech->indicate) { 02501 /* See if the channel driver can handle this condition. */ 02502 res = chan->tech->indicate(chan, condition, data, datalen); 02503 } 02504 02505 ast_channel_unlock(chan); 02506 02507 if (chan->tech->indicate && !res) { 02508 /* The channel driver successfully handled this indication */ 02509 if (is_visible_indication(condition)) { 02510 chan->visible_indication = condition; 02511 } 02512 return 0; 02513 } 02514 02515 /* The channel driver does not support this indication, let's fake 02516 * it by doing our own tone generation if applicable. */ 02517 02518 if (condition < 0) { 02519 /* Stop any tones that are playing */ 02520 ast_playtones_stop(chan); 02521 return 0; 02522 } 02523 02524 /* Handle conditions that we have tones for. */ 02525 switch (condition) { 02526 case AST_CONTROL_RINGING: 02527 ts = ast_get_indication_tone(chan->zone, "ring"); 02528 break; 02529 case AST_CONTROL_BUSY: 02530 ts = ast_get_indication_tone(chan->zone, "busy"); 02531 break; 02532 case AST_CONTROL_CONGESTION: 02533 ts = ast_get_indication_tone(chan->zone, "congestion"); 02534 break; 02535 case AST_CONTROL_PROGRESS: 02536 case AST_CONTROL_PROCEEDING: 02537 case AST_CONTROL_VIDUPDATE: 02538 case AST_CONTROL_SRCUPDATE: 02539 case AST_CONTROL_RADIO_KEY: 02540 case AST_CONTROL_RADIO_UNKEY: 02541 case AST_CONTROL_OPTION: 02542 case AST_CONTROL_WINK: 02543 case AST_CONTROL_FLASH: 02544 case AST_CONTROL_OFFHOOK: 02545 case AST_CONTROL_TAKEOFFHOOK: 02546 case AST_CONTROL_ANSWER: 02547 case AST_CONTROL_HANGUP: 02548 case AST_CONTROL_RING: 02549 case AST_CONTROL_HOLD: 02550 case AST_CONTROL_UNHOLD: 02551 /* Nothing left to do for these. */ 02552 res = 0; 02553 break; 02554 } 02555 02556 if (ts && ts->data[0]) { 02557 /* We have a tone to play, yay. */ 02558 if (option_debug) { 02559 ast_log(LOG_DEBUG, "Driver for channel '%s' does not support indication %d, emulating it\n", chan->name, condition); 02560 } 02561 ast_playtones_start(chan, 0, ts->data, 1); 02562 res = 0; 02563 chan->visible_indication = condition; 02564 } 02565 02566 if (res) { 02567 /* not handled */ 02568 ast_log(LOG_WARNING, "Unable to handle indication %d for '%s'\n", condition, chan->name); 02569 } 02570 02571 return res; 02572 }
| 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 2427 of file channel.c.
References ast_log(), ast_opt_internal_timing, LOG_DEBUG, option_debug, and ast_channel::timingfd.
Referenced by add_sdp(), and ast_read_generator_actions().
02428 { 02429 int ret = ast_opt_internal_timing && chan->timingfd > -1; 02430 if (option_debug > 4) 02431 ast_log(LOG_DEBUG, "Internal timing is %s (option_internal_timing=%d chan->timingfd=%d)\n", ret? "enabled": "disabled", ast_opt_internal_timing, chan->timingfd); 02432 return ret; 02433 }
| char* ast_print_group | ( | char * | buf, | |
| int | buflen, | |||
| ast_group_t | group | |||
| ) |
print call- and pickup groups into buffer
Definition at line 4574 of file channel.c.
References first.
Referenced by _sip_show_peer(), func_channel_read(), misdn_cfg_get_config_string(), print_group(), read_config(), and serialize_showchan().
04575 { 04576 unsigned int i; 04577 int first=1; 04578 char num[3]; 04579 04580 buf[0] = '\0'; 04581 04582 if (!group) /* Return empty string if no group */ 04583 return buf; 04584 04585 for (i = 0; i <= 63; i++) { /* Max group is 63 */ 04586 if (group & ((ast_group_t) 1 << i)) { 04587 if (!first) { 04588 strncat(buf, ", ", buflen - strlen(buf) - 1); 04589 } else { 04590 first=0; 04591 } 04592 snprintf(num, sizeof(num), "%u", i); 04593 strncat(buf, num, buflen - strlen(buf) - 1); 04594 } 04595 } 04596 return buf; 04597 }
| int ast_prod | ( | struct ast_channel * | chan | ) |
Send empty audio to prime a channel driver.
Definition at line 2694 of file channel.c.
References ast_channel::_state, AST_FRAME_VOICE, AST_FRIENDLY_OFFSET, ast_log(), AST_STATE_UP, ast_write(), ast_frame::data, LOG_DEBUG, LOG_WARNING, ast_channel::name, option_debug, ast_channel::rawwriteformat, ast_frame::src, and ast_frame::subclass.
Referenced by ast_activate_generator().
02695 { 02696 struct ast_frame a = { AST_FRAME_VOICE }; 02697 char nothing[128]; 02698 02699 /* Send an empty audio frame to get things moving */ 02700 if (chan->_state != AST_STATE_UP) { 02701 if (option_debug) 02702 ast_log(LOG_DEBUG, "Prodding channel '%s'\n", chan->name); 02703 a.subclass = chan->rawwriteformat; 02704 a.data = nothing + AST_FRIENDLY_OFFSET; 02705 a.src = "ast_prod"; 02706 if (ast_write(chan, &a)) 02707 ast_log(LOG_WARNING, "Prodding channel '%s' failed\n", chan->name); 02708 } 02709 return 0; 02710 }
| int ast_queue_control | ( | struct ast_channel * | chan, | |
| enum ast_control_frame_type | control | |||
| ) |
Queue a control frame with payload.
| chan | channel to queue frame onto | |
| control | type of control frame |
Definition at line 987 of file channel.c.
References AST_FRAME_CONTROL, ast_queue_frame(), and ast_frame::subclass.
Referenced by __dahdi_exception(), __oh323_update_info(), ast_pickup_call(), attempt_transfer(), auto_congest(), cb_events(), 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_refer(), handle_response(), handle_response_invite(), handle_response_refer(), handle_soft_key_event_message(), handle_stimulus_message(), mgcp_call(), nbs_call(), onAlerting(), onCallEstablished(), phone_call(), pickup_do(), process_sdp(), receive_digit(), send_cause2ast(), setup_rtp_connection(), skinny_call(), skinny_unhold(), ss_thread(), and update_state().
00988 { 00989 struct ast_frame f = { AST_FRAME_CONTROL, }; 00990 00991 f.subclass = control; 00992 00993 return ast_queue_frame(chan, &f); 00994 }
| 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 |
Definition at line 997 of file channel.c.
References AST_FRAME_CONTROL, ast_queue_frame(), ast_frame::data, ast_frame::datalen, and ast_frame::subclass.
Referenced by dahdi_handle_event(), dahdi_hangup(), iax2_queue_control_data(), process_sdp(), and skinny_hold().
00999 { 01000 struct ast_frame f = { AST_FRAME_CONTROL, }; 01001 01002 f.subclass = control; 01003 f.data = (void *) data; 01004 f.datalen = datalen; 01005 01006 return ast_queue_frame(chan, &f); 01007 }
| int ast_queue_frame | ( | struct ast_channel * | chan, | |
| struct ast_frame * | f | |||
| ) |
Queue an outgoing frame.
Definition at line 964 of file channel.c.
References __ast_queue_frame().
Referenced by __oh323_rtp_create(), __oh323_update_info(), agent_new(), alsa_call(), ast_channel_masquerade(), ast_channel_setwhentohangup(), ast_do_masquerade(), ast_dsp_process(), ast_queue_control(), ast_queue_control_data(), ast_queue_hangup(), ast_softhangup_nolock(), cb_events(), console_answer(), console_answer_deprecated(), console_dial(), console_dial_deprecated(), console_flash(), console_flash_deprecated(), console_sendtext(), console_sendtext_deprecated(), 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(), local_queue_frame(), mgcp_queue_frame(), oh323_simulate_dtmf_end(), ooh323_onReceivedDigit(), oss_call(), process_sdp(), queue_dtmf_readq(), receive_digit(), receive_message(), rpt_call(), and wakeup_sub().
00965 { 00966 return __ast_queue_frame(chan, fin, 0); 00967 }
| int ast_queue_frame_head | ( | struct ast_channel * | chan, | |
| struct ast_frame * | f | |||
| ) |
Queue an outgoing frame to the head of the frame queue.
| chan | the channel to queue the frame on | |
| f | the frame to queue. Note that this frame will be duplicated by this function. It is the responsibility of the caller to handle freeing the memory associated with the frame being passed if necessary. |
| 0 | success | |
| non-zero | failure |
Definition at line 969 of file channel.c.
References __ast_queue_frame().
Referenced by ast_autoservice_stop().
00970 { 00971 return __ast_queue_frame(chan, fin, 1); 00972 }
| int ast_queue_hangup | ( | struct ast_channel * | chan | ) |
Queue a hangup frame.
Definition at line 975 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 __oh323_update_info(), __sip_autodestruct(), cleanup_connection(), console_hangup(), console_hangup_deprecated(), dahdi_handle_event(), gtalk_hangup_farend(), gtalk_is_answered(), handle_onhook_message(), handle_request_bye(), handle_request_cancel(), handle_response(), handle_response_invite(), handle_soft_key_event_message(), hangup_chan(), hangup_connection(), iax2_destroy(), iax2_queue_hangup(), local_hangup(), mgcp_queue_hangup(), misdn_answer(), onCallCleared(), and retrans_pkt().
00976 { 00977 struct ast_frame f = { AST_FRAME_CONTROL, AST_CONTROL_HANGUP }; 00978 /* Yeah, let's not change a lock-critical value without locking */ 00979 if (!ast_channel_trylock(chan)) { 00980 chan->_softhangup |= AST_SOFTHANGUP_DEV; 00981 ast_channel_unlock(chan); 00982 } 00983 return ast_queue_frame(chan, &f); 00984 }
| struct ast_frame* ast_read | ( | struct ast_channel * | chan | ) | [read] |
Reads a frame.
| chan | channel to read a frame from Read a frame. |
Definition at line 2435 of file channel.c.
References __ast_read().
Referenced by __adsi_transmit_messages(), __ast_play_and_record(), __ast_request_and_dial(), adsi_careful_send(), agent_ack_sleep(), agent_read(), app_exec(), ast_feature_request_and_dial(), ast_generic_bridge(), ast_recvtext(), ast_safe_sleep_conditional(), ast_tonepair(), ast_udptl_bridge(), ast_waitfordigit_full(), async_wait(), autoservice_run(), background_detect_exec(), bridge_native_loop(), bridge_p2p_loop(), builtin_atxfer(), channel_spy(), check_goto_on_transfer(), conf_exec(), conf_flush(), conf_run(), dahdi_bridge(), dictate_exec(), disa_exec(), do_parking_thread(), do_waiting(), echo_exec(), features_read(), find_cache(), handle_invite_replaces(), handle_recordfile(), iax2_bridge(), iax_park_thread(), ices_exec(), isAnsweringMachine(), masq_park_call(), measurenoise(), misdn_bridge(), monitor_dial(), mp3_exec(), mwanalyze_exec(), NBScat_exec(), nv_background_detect_exec(), nv_detectfax_exec(), receive_dtmf_digits(), record_exec(), recordthread(), rpt(), rpt_exec(), run_agi(), send_tone_burst(), send_waveform_to_channel(), sendurl_exec(), sms_exec(), speech_background(), ss_thread(), transmit_audio(), transmit_t38(), wait_for_answer(), wait_for_hangup(), wait_for_winner(), waitforring_exec(), and waitstream_core().
02436 { 02437 return __ast_read(chan, 0); 02438 }
| struct ast_frame* ast_read_noaudio | ( | struct ast_channel * | chan | ) | [read] |
Reads a frame, returning AST_FRAME_NULL frame if audio. Read a frame.
| chan | channel to read a frame from |
Definition at line 2440 of file channel.c.
References __ast_read().
Referenced by conf_run().
02441 { 02442 return __ast_read(chan, 1); 02443 }
| 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 Read in a digit string "s", max length "len", maximum timeout between digits "timeout" (-1 for none), terminated by anything in "enders". Give them rtimeout for the first digit. Returns 0 on normal return, or 1 on a timeout. In the case of a timeout, any digits that were read before the timeout will still be available in s. RETURNS 2 in full version when ctrlfd is available, NOT 1 |
Definition at line 3219 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().
03220 { 03221 return ast_readstring_full(c, s, len, timeout, ftimeout, enders, -1, -1); 03222 }
| int ast_readstring_full | ( | struct ast_channel * | c, | |
| char * | s, | |||
| int | len, | |||
| int | timeout, | |||
| int | rtimeout, | |||
| char * | enders, | |||
| int | audiofd, | |||
| int | ctrlfd | |||
| ) |
Definition at line 3224 of file channel.c.
References ast_check_hangup(), AST_DIGIT_ANY, AST_FLAG_ZOMBIE, ast_stopstream(), ast_test_flag, ast_waitfordigit_full(), ast_waitstream_full(), and ast_channel::stream.
Referenced by ast_app_getdata_full(), and ast_readstring().
03225 { 03226 int pos = 0; /* index in the buffer where we accumulate digits */ 03227 int to = ftimeout; 03228 03229 /* Stop if we're a zombie or need a soft hangup */ 03230 if (ast_test_flag(c, AST_FLAG_ZOMBIE) || ast_check_hangup(c)) 03231 return -1; 03232 if (!len) 03233 return -1; 03234 for (;;) { 03235 int d; 03236 if (c->stream) { 03237 d = ast_waitstream_full(c, AST_DIGIT_ANY, audiofd, ctrlfd); 03238 ast_stopstream(c); 03239 usleep(1000); 03240 if (!d) 03241 d = ast_waitfordigit_full(c, to, audiofd, ctrlfd); 03242 } else { 03243 d = ast_waitfordigit_full(c, to, audiofd, ctrlfd); 03244 } 03245 if (d < 0) 03246 return -1; 03247 if (d == 0) { 03248 s[pos]='\0'; 03249 return 1; 03250 } 03251 if (d == 1) { 03252 s[pos]='\0'; 03253 return 2; 03254 } 03255 if (!strchr(enders, d)) 03256 s[pos++] = d; 03257 if (strchr(enders, d) || (pos >= len)) { 03258 s[pos]='\0'; 03259 return 0; 03260 } 03261 to = timeout; 03262 } 03263 /* Never reached */ 03264 return 0; 03265 }
| 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) Read a char of text from a channel Returns 0 on success, -1 on failure |
Definition at line 2574 of file channel.c.
References ast_recvtext(), and free.
Referenced by handle_recvchar().
02575 { 02576 int c; 02577 char *buf = ast_recvtext(chan, timeout); 02578 if (buf == NULL) 02579 return -1; /* error or timeout */ 02580 c = *(unsigned char *)buf; 02581 free(buf); 02582 return c; 02583 }
| 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 2585 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, f, ast_frame::frametype, and ast_frame::subclass.
Referenced by ast_recvchar(), and handle_recvtext().
02586 { 02587 int res, done = 0; 02588 char *buf = NULL; 02589 02590 while (!done) { 02591 struct ast_frame *f; 02592 if (ast_check_hangup(chan)) 02593 break; 02594 res = ast_waitfor(chan, timeout); 02595 if (res <= 0) /* timeout or error */ 02596 break; 02597 timeout = res; /* update timeout */ 02598 f = ast_read(chan); 02599 if (f == NULL) 02600 break; /* no frame */ 02601 if (f->frametype == AST_FRAME_CONTROL && f->subclass == AST_CONTROL_HANGUP) 02602 done = 1; /* force a break */ 02603 else if (f->frametype == AST_FRAME_TEXT) { /* what we want */ 02604 buf = ast_strndup((char *) f->data, f->datalen); /* dup and break */ 02605 done = 1; 02606 } 02607 ast_frfree(f); 02608 } 02609 return buf; 02610 }
| struct ast_channel* ast_request | ( | const char * | type, | |
| int | format, | |||
| void * | data, | |||
| int * | status | |||
| ) | [read] |
Requests a channel.
| type | type of channel to request | |
| format | requested channel format (codec) | |
| data | data to pass to the channel requester | |
| status | status Request a channel of a given type, with data as optional information used by the low level module |
Definition at line 3125 of file channel.c.
References AST_CAUSE_BEARERCAPABILITY_NOTAVAIL, AST_CAUSE_NOSUCHDRIVER, AST_CAUSE_NOTDEFINED, AST_FORMAT_AUDIO_MASK, AST_FORMAT_VIDEO_MASK, AST_LIST_LOCK, AST_LIST_TRAVERSE, AST_LIST_UNLOCK, ast_log(), ast_translator_best_choice(), ast_channel_tech::capabilities, capabilities, chanlist::list, LOG_WARNING, ast_channel_tech::requester, chanlist::tech, and ast_channel_tech::type.
Referenced by __ast_request_and_dial(), agent_request(), ast_feature_request_and_dial(), ast_request_inherit(), attempt_reconnect(), begin_dial(), build_conf(), chanavail_exec(), conf_run(), connect_link(), features_alloc(), findmeexec(), ring_entry(), rpt(), rpt_call(), rpt_exec(), rpt_tele_thread(), and wait_for_answer().
03126 { 03127 struct chanlist *chan; 03128 struct ast_channel *c; 03129 int capabilities; 03130 int fmt; 03131 int res; 03132 int foo; 03133 int videoformat = format & AST_FORMAT_VIDEO_MASK; 03134 03135 if (!cause) 03136 cause = &foo; 03137 *cause = AST_CAUSE_NOTDEFINED; 03138 03139 if (AST_LIST_LOCK(&channels)) { 03140 ast_log(LOG_WARNING, "Unable to lock channel list\n"); 03141 return NULL; 03142 } 03143 03144 AST_LIST_TRAVERSE(&backends, chan, list) { 03145 if (strcasecmp(type, chan->tech->type)) 03146 continue; 03147 03148 capabilities = chan->tech->capabilities; 03149 fmt = format & AST_FORMAT_AUDIO_MASK; 03150 res = ast_translator_best_choice(&fmt, &capabilities); 03151 if (res < 0) { 03152 ast_log(LOG_WARNING, "No translator path exists for channel type %s (native %d) to %d\n", type, chan->tech->capabilities, format); 03153 *cause = AST_CAUSE_BEARERCAPABILITY_NOTAVAIL; 03154 AST_LIST_UNLOCK(&channels); 03155 return NULL; 03156 } 03157 AST_LIST_UNLOCK(&channels); 03158 if (!chan->tech->requester) 03159 return NULL; 03160 03161 if (!(c = chan->tech->requester(type, capabilities | videoformat, data, cause))) 03162 return NULL; 03163 03164 /* no need to generate a Newchannel event here; it is done in the channel_alloc call */ 03165 return c; 03166 } 03167 03168 ast_log(LOG_WARNING, "No channel type registered for '%s'\n", type); 03169 *cause = AST_CAUSE_NOSUCHDRIVER; 03170 AST_LIST_UNLOCK(&channels); 03171 03172 return NULL; 03173 }
| struct ast_channel* ast_request_and_dial | ( | const char * | type, | |
| int | format, | |||
| void * | data, | |||
| int | timeout, | |||
| int * | reason, | |||
| const char * | cidnum, | |||
| const char * | cidname | |||
| ) | [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 | |
| data | data to pass to the channel requester | |
| timeout | maximum amount of time to wait for an answer | |
| reason | why unsuccessful (if unsuceessful) | |
| cidnum | Caller-ID Number | |
| cidname | Caller-ID Name |
Definition at line 3120 of file channel.c.
References __ast_request_and_dial().
Referenced by ast_pbx_outgoing_exten().
03121 { 03122 return __ast_request_and_dial(type, format, data, timeout, outstate, cidnum, cidname, NULL); 03123 }
| static struct ast_channel* ast_request_inherit | ( | struct ast_channel * | chan, | |
| const char * | type, | |||
| void * | data, | |||
| int * | status | |||
| ) | [static, read] |
call ast_request with format/type of parent channel
Definition at line 704 of file channel.h.
References ast_request(), and S_OR.
00705 { 00706 return ast_request(S_OR(type, chan->tech->type), chan->nativeformats, data, status); 00707 }
| int ast_safe_sleep | ( | struct ast_channel * | chan, | |
| int | ms | |||
| ) |
Wait for a specied amount of time, looking for hangups.
| chan | channel to wait for | |
| ms | length of time in milliseconds to sleep Waits for a specified amount of time, servicing the channel as required. |
Definition at line 1197 of file channel.c.
References ast_safe_sleep_conditional().
Referenced by __login_exec(), alarmreceiver_exec(), ast_adsi_transmit_message_full(), ast_dtmf_stream(), ast_senddigit(), builtin_parkcall(), conf_run(), dictate_exec(), flash_exec(), function_ilink(), mgcp_ss(), milliwatt_exec(), moh0_exec(), moh1_exec(), old_milliwatt_exec(), park_call_exec(), pbx_builtin_answer(), pbx_builtin_wait(), play_tone_pair(), playtone(), privacy_exec(), receive_ademco_contact_id(), rpt_call(), rpt_exec(), rpt_tele_thread(), send_morse(), send_tone_telemetry(), skinny_ss(), ss_thread(), test1_client(), test1_server(), testclient_exec(), testserver_exec(), try_calling(), wait_for_hangup(), wait_interval(), and zapateller_exec().
01198 { 01199 return ast_safe_sleep_conditional(chan, ms, NULL, NULL); 01200 }
| int ast_safe_sleep_conditional | ( | struct ast_channel * | chan, | |
| int | ms, | |||
| int(*)(void *) | cond, | |||
| void * | data | |||
| ) |
Wait for a specied amount of time, looking for hangups and a condition argument.
| chan | channel to wait for | |
| ms | length of time in milliseconds to sleep | |
| cond | a function pointer for testing continue condition | |
| data | argument to be passed to the condition test function |
Definition at line 1176 of file channel.c.
References ast_frfree, ast_read(), ast_waitfor(), cond, and f.
Referenced by __login_exec(), and ast_safe_sleep().
01177 { 01178 struct ast_frame *f; 01179 01180 while (ms > 0) { 01181 if (cond && ((*cond)(data) == 0)) 01182 return 0; 01183 ms = ast_waitfor(chan, ms); 01184 if (ms < 0) 01185 return -1; 01186 if (ms > 0) { 01187 f = ast_read(chan); 01188 if (!f) 01189 return -1; 01190 ast_frfree(f); 01191 } 01192 } 01193 return 0; 01194 }
| char* ast_safe_string_alloc | ( | const char * | fmt, | |
| ... | ||||
| ) |
printf the string into a correctly sized mallocd buffer, and return the buffer
return a mallocd string with the result of sprintf of the fmt and following args
Definition at line 408 of file channel.c.
References ast_malloc, and len().
Referenced by dahdi_new(), and features_new().
00409 { 00410 char *b2, buf[1]; 00411 int len; 00412 va_list args; 00413 00414 va_start(args, fmt); 00415 len = vsnprintf(buf, 1, fmt, args); 00416 va_end(args); 00417 00418 if (!(b2 = ast_malloc(len + 1))) 00419 return NULL; 00420 00421 va_start(args, fmt); 00422 vsnprintf(b2, len + 1, fmt, args); 00423 va_end(args); 00424 00425 return b2; 00426 }
| static int ast_select | ( | int | nfds, | |
| fd_set * | rfds, | |||
| fd_set * | wfds, | |||
| fd_set * | efds, | |||
| struct timeval * | tvp | |||
| ) | [inline, static] |
Waits for activity on a group of channels.
| nfds | the maximum number of file descriptors in the sets | |
| rfds | file descriptors to check for read availability | |
| wfds | file descriptors to check for write availability | |
| efds | file descriptors to check for exceptions (OOB data) | |
| tvp | timeout while waiting for events This is the same as a standard select(), except it guarantees the behaviour where the passed struct timeval is updated with how much time was not slept while waiting for the specified events |
Definition at line 1437 of file channel.h.
Referenced by do_monitor(), do_parking_thread(), and sound_thread().
01438 { 01439 #ifdef __linux__ 01440 return select(nfds, rfds, wfds, efds, tvp); 01441 #else 01442 if (tvp) { 01443 struct timeval tv, tvstart, tvend, tvlen; 01444 int res; 01445 01446 tv = *tvp; 01447 gettimeofday(&tvstart, NULL); 01448 res = select(nfds, rfds, wfds, efds, tvp); 01449 gettimeofday(&tvend, NULL); 01450 timersub(&tvend, &tvstart, &tvlen); 01451 timersub(&tv, &tvlen, tvp); 01452 if (tvp->tv_sec < 0 || (tvp->tv_sec == 0 && tvp->tv_usec < 0)) { 01453 tvp->tv_sec = 0; 01454 tvp->tv_usec = 0; 01455 } 01456 return res; 01457 } 01458 else 01459 return select(nfds, rfds, wfds, efds, NULL); 01460 #endif 01461 }
| int ast_senddigit | ( | struct ast_channel * | chan, | |
| char | digit | |||
| ) |
Send a DTMF digit to a channel Send a DTMF digit to a channel.
| chan | channel to act upon | |
| digit | the DTMF digit to send, encoded in ASCII |
Definition at line 2684 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(), do_dtmf_phone(), manager_play_dtmf(), and rpt_call().
02685 { 02686 if (chan->tech->send_digit_begin) { 02687 ast_senddigit_begin(chan, digit); 02688 ast_safe_sleep(chan, AST_DEFAULT_EMULATE_DTMF_DURATION); 02689 } 02690 02691 return ast_senddigit_end(chan, digit, AST_DEFAULT_EMULATE_DTMF_DURATION); 02692 }
| int ast_senddigit_begin | ( | struct ast_channel * | chan, | |
| char | digit | |||
| ) |
Definition at line 2625 of file channel.c.
References ast_log(), ast_playtones_start(), LOG_DEBUG, ast_channel::name, option_debug, ast_channel_tech::send_digit_begin, and ast_channel::tech.
Referenced by agent_digit_begin(), ast_senddigit(), ast_write(), and features_digit_begin().
02626 { 02627 /* Device does not support DTMF tones, lets fake 02628 * it by doing our own generation. */ 02629 static const char* dtmf_tones[] = { 02630 "941+1336", /* 0 */ 02631 "697+1209", /* 1 */ 02632 "697+1336", /* 2 */ 02633 "697+1477", /* 3 */ 02634 "770+1209", /* 4 */ 02635 "770+1336", /* 5 */ 02636 "770+1477", /* 6 */ 02637 "852+1209", /* 7 */ 02638 "852+1336", /* 8 */ 02639 "852+1477", /* 9 */ 02640 "697+1633", /* A */ 02641 "770+1633", /* B */ 02642 "852+1633", /* C */ 02643 "941+1633", /* D */ 02644 "941+1209", /* * */ 02645 "941+1477" /* # */ 02646 }; 02647 02648 if (!chan->tech->send_digit_begin) 02649 return 0; 02650 02651 if (!chan->tech->send_digit_begin(chan, digit)) 02652 return 0; 02653 02654 if (digit >= '0' && digit <='9') 02655 ast_playtones_start(chan, 0, dtmf_tones[digit-'0'], 0); 02656 else if (digit >= 'A' && digit <= 'D') 02657 ast_playtones_start(chan, 0, dtmf_tones[digit-'A'+10], 0); 02658 else if (digit == '*') 02659 ast_playtones_start(chan, 0, dtmf_tones[14], 0); 02660 else if (digit == '#') 02661 ast_playtones_start(chan, 0, dtmf_tones[15], 0); 02662 else { 02663 /* not handled */ 02664 if (option_debug) 02665 ast_log(LOG_DEBUG, "Unable to generate DTMF tone '%c' for '%s'\n", digit, chan->name); 02666 } 02667 02668 return 0; 02669 }
| int ast_senddigit_end | ( | struct ast_channel * | chan, | |
| char | digit, | |||
| unsigned int | duration | |||
| ) |
Definition at line 2671 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(), ast_write(), and features_digit_end().
02672 { 02673 int res = -1; 02674 02675 if (chan->tech->send_digit_end) 02676 res = chan->tech->send_digit_end(chan, digit, duration); 02677 02678 if (res && chan->generator) 02679 ast_playtones_stop(chan); 02680 02681 return 0; 02682 }
| int ast_sendtext | ( | struct ast_channel * | chan, | |
| const char * | text | |||
| ) |
Sends text to a channel Write text to a display on a channel.
| chan | channel to act upon | |
| text | string of text to send on the channel |
Definition at line 2612 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 agent_sendtext(), handle_sendtext(), and sendtext_exec().
02613 { 02614 int res = 0; 02615 /* Stop if we're a zombie or need a soft hangup */ 02616 if (ast_test_flag(chan, AST_FLAG_ZOMBIE) || ast_check_hangup(chan)) 02617 return -1; 02618 CHECK_BLOCKING(chan); 02619 if (chan->tech->send_text) 02620 res = chan->tech->send_text(chan, text); 02621 ast_clear_flag(chan, AST_FLAG_BLOCKING); 02622 return res; 02623 }
| static void ast_set_best_format | ( | struct ast_channel * | channel | ) | [inline, static] |
Set best format, identical to read/write.
| channel | channel, from that nativeformats used and formats set |
Definition at line 1197 of file channel.h.
References ast_channel_best_codec(), ast_set_read_format(), and ast_set_write_format().
01198 { 01199 int format = ast_channel_best_codec(channel); 01200 ast_set_read_format(channel, format); 01201 ast_set_write_format(channel, format); 01202 }
| void ast_set_callerid | ( | struct ast_channel * | chan, | |
| const char * | cidnum, | |||
| const char * | cidname, | |||
| const char * | ani | |||
| ) |
Definition at line 3779 of file channel.c.
References ast_channel_lock, ast_channel_unlock, ast_describe_caller_presentation(), ast_strdup, ast_channel::cid, ast_callerid::cid_ani, ast_callerid::cid_name, ast_callerid::cid_num, ast_callerid::cid_pres, EVENT_FLAG_CALL, free, manager_event(), ast_channel::name, S_OR, and ast_channel::uniqueid.
Referenced by __ast_request_and_dial(), agent_call(), ast_feature_request_and_dial(), callerid_write(), dahdi_read(), disa_exec(), findmeexec(), handle_setcallerid(), lookupcidname_exec(), mgcp_ss(), privacy_exec(), read_config(), rpt_exec(), setcallerid_exec(), skinny_newcall(), ss_thread(), and wait_for_answer().
03780 { 03781 ast_channel_lock(chan); 03782 03783 if (callerid) { 03784 if (chan->cid.cid_num) 03785 free(chan->cid.cid_num); 03786 chan->cid.cid_num = ast_strdup(callerid); 03787 } 03788 if (calleridname) { 03789 if (chan->cid.cid_name) 03790 free(chan->cid.cid_name); 03791 chan->cid.cid_name = ast_strdup(calleridname); 03792 } 03793 if (ani) { 03794 if (chan->cid.cid_ani) 03795 free(chan->cid.cid_ani); 03796 chan->cid.cid_ani = ast_strdup(ani); 03797 } 03798 manager_event(EVENT_FLAG_CALL, "Newcallerid", 03799 "Channel: %s\r\n" 03800 "CallerID: %s\r\n" 03801 "CallerIDName: %s\r\n" 03802 "Uniqueid: %s\r\n" 03803 "CID-CallingPres: %d (%s)\r\n", 03804 chan->name, 03805 S_OR(chan->cid.cid_num, "<Unknown>"), 03806 S_OR(chan->cid.cid_name, "<Unknown>"), 03807 chan->uniqueid, 03808 chan->cid.cid_pres, 03809 ast_describe_caller_presentation(chan->cid.cid_pres) 03810 ); 03811 03812 ast_channel_unlock(chan); 03813 }
| int ast_set_read_format | ( | struct ast_channel * | chan, | |
| int | 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 2965 of file channel.c.
References ast_channel::rawreadformat, ast_channel::readformat, ast_channel::readtrans, and set_format().
Referenced by __ast_play_and_record(), __login_exec(), __oh323_update_info(), agent_call(), alarmreceiver_exec(), ast_adsi_transmit_message_full(), ast_channel_formats_reset(), ast_channel_make_compatible(), ast_do_masquerade(), ast_set_best_format(), attempt_reconnect(), background_detect_exec(), build_conf(), conf_run(), connect_link(), dictate_exec(), disa_exec(), do_waiting(), eagi_exec(), echo_exec(), gtalk_rtp_read(), handle_recordfile(), ices_exec(), isAnsweringMachine(), measurenoise(), mgcp_rtp_read(), mwanalyze_exec(), nv_background_detect_exec(), nv_detectfax_exec(), oh323_rtp_read(), old_milliwatt_exec(), ooh323_rtp_read(), ooh323_set_read_format(), process_sdp(), record_exec(), rpt(), rpt_exec(), setup_rtp_connection(), sip_rtp_read(), skinny_rtp_read(), sms_exec(), socket_process(), speech_background(), transmit_audio(), and update_features().
02966 { 02967 return set_format(chan, fmt, &chan->rawreadformat, &chan->readformat, 02968 &chan->readtrans, 0); 02969 }
| 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 4599 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_pbx_outgoing_app(), and ast_pbx_outgoing_exten().
04600 { 04601 struct ast_variable *cur; 04602 04603 for (cur = vars; cur; cur = cur->next) 04604 pbx_builtin_setvar_helper(chan, cur->name, cur->value); 04605 }
| int ast_set_write_format | ( | struct ast_channel * | chan, | |
| int | format | |||
| ) |
Sets write format on channel chan Set write format for channel to whichever compoent of "format" is best.
| chan | channel to change | |
| format | new format for writing |
Definition at line 2971 of file channel.c.
References ast_channel::rawwriteformat, set_format(), ast_channel::writeformat, and ast_channel::writetrans.
Referenced by __login_exec(), __oh323_update_info(), agent_call(), alarmreceiver_exec(), ast_adsi_transmit_message_full(), ast_channel_formats_reset(), ast_channel_make_compatible(), ast_channel_start_silence_generator(), ast_channel_stop_silence_generator(), ast_do_masquerade(), ast_openstream_full(), ast_set_best_format(), ast_stopstream(), attempt_reconnect(), build_conf(), chanspy_exec(), conf_run(), connect_link(), disa_exec(), echo_exec(), extenspy_exec(), gtalk_rtp_read(), linear_alloc(), linear_release(), mgcp_rtp_read(), moh_alloc(), moh_files_release(), moh_release(), mp3_exec(), mwanalyze_exec(), NBScat_exec(), oh323_rtp_read(), old_milliwatt_exec(), ooh323_rtp_read(), ooh323_set_write_format(), playtones_alloc(), playtones_release(), process_sdp(), rpt(), rpt_exec(), send_waveform_to_channel(), setup_rtp_connection(), sip_rtp_read(), skinny_rtp_read(), sms_exec(), socket_process(), tonepair_alloc(), tonepair_release(), transmit_audio(), and update_features().
02972 { 02973 return set_format(chan, fmt, &chan->rawwriteformat, &chan->writeformat, 02974 &chan->writetrans, 1); 02975 }
| int ast_setstate | ( | struct ast_channel * | chan, | |
| enum | ast_channel_state | |||
| ) |
Change the state of a channel.
Definition at line 3815 of file channel.c.
References ast_channel::_state, AST_CHANNEL_NAME, ast_copy_string(), ast_device_state_changed_literal(), ast_state2str(), ast_channel::cid, ast_callerid::cid_name, ast_callerid::cid_num, EVENT_FLAG_CALL, manager_event(), ast_channel::name, name, S_OR, and ast_channel::uniqueid.
Referenced by __ast_read(), __dahdi_exception(), __oh323_update_info(), agent_call(), alsa_answer(), ast_answer(), cb_events(), check_availability(), 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(), mgcp_answer(), mgcp_call(), mgcp_ss(), misdn_call(), misdn_indication(), nbs_call(), nbs_hangup(), oh323_answer(), onAlerting(), onCallEstablished(), ooh323_answer(), ooh323_new(), oss_answer(), pbx_builtin_busy(), pbx_builtin_congestion(), phone_answer(), phone_call(), phone_exception(), phone_hangup(), phone_write(), release_chan(), sip_answer(), skinny_answer(), skinny_call(), skinny_newcall(), ss_thread(), and update_state().
03816 { 03817 char name[AST_CHANNEL_NAME], *dashptr; 03818 int oldstate = chan->_state; 03819 03820 if (oldstate == state) 03821 return 0; 03822 03823 ast_copy_string(name, chan->name, sizeof(name)); 03824 if ((dashptr = strrchr(name, '-'))) { 03825 *dashptr = '\0'; 03826 } 03827 03828 chan->_state = state; 03829 ast_device_state_changed_literal(name); 03830 /* setstate used to conditionally report Newchannel; this is no more */ 03831 manager_event(EVENT_FLAG_CALL, 03832 "Newstate", 03833 "Channel: %s\r\n" 03834 "State: %s\r\n" 03835 "CallerID: %s\r\n" 03836 "CallerIDName: %s\r\n" 03837 "Uniqueid: %s\r\n", 03838 chan->name, ast_state2str(chan->_state), 03839 S_OR(chan->cid.cid_num, "<unknown>"), 03840 S_OR(chan->cid.cid_name, "<unknown>"), 03841 chan->uniqueid); 03842 03843 return 0; 03844 }
| int ast_settimeout | ( | struct ast_channel * | c, | |
| int | samples, | |||
| int(*)(const void *data) | func, | |||
| void * | data | |||
| ) |
Definition at line 1839 of file channel.c.
References ast_log(), LOG_DEBUG, option_debug, ast_channel::timingdata, ast_channel::timingfd, and ast_channel::timingfunc.
Referenced by ast_activate_generator(), ast_deactivate_generator(), ast_read_generator_actions(), ast_readaudio_callback(), and filestream_destructor().
01840 { 01841 int res = -1; 01842 #ifdef HAVE_DAHDI 01843 if (c->timingfd > -1) { 01844 if (!func) { 01845 samples = 0; 01846 data = 0; 01847 } 01848 if (option_debug) 01849 ast_log(LOG_DEBUG, "Scheduling timer at %d sample intervals\n", samples); 01850 res = ioctl(c->timingfd, DAHDI_TIMERCONFIG, &samples); 01851 c->timingfunc = func; 01852 c->timingdata = data; 01853 } 01854 #endif 01855 return res; 01856 }
| int ast_shutting_down | ( | void | ) |
Returns non-zero if Asterisk is being shut down.
Returns non-zero if Asterisk is being shut down
Definition at line 460 of file channel.c.
Referenced by handle_request_options().
00461 { 00462 return shutting_down; 00463 }
| int ast_softhangup | ( | struct ast_channel * | chan, | |
| int | cause | |||
| ) |
Softly hangup up a channel.
| chan | channel to be soft-hung-up Call the protocol layer, but don't destroy the channel structure (use this if you are trying to safely hangup a channel managed by another thread. | |
| cause | Ast hangupcause for hangup |
Definition at line 1440 of file channel.c.
References ast_channel_lock, ast_channel_unlock, and ast_softhangup_nolock().
Referenced by __ast_module_user_hangup_all(), __ast_pbx_run(), __login_exec(), __unload_module(), action_hangup(), agent_hangup(), agent_logoff(), ast_begin_shutdown(), ast_dial_join(), conf_free(), connect_link(), dahdi_handle_event(), function_ilink(), handle_hangup(), handle_link_data(), handle_softhangup(), manager_park(), read_agent_config(), rpt(), rpt_call(), rpt_do_restart(), sla_handle_hold_event(), softhangup_exec(), start_spying(), startmon(), and unload_module().
01441 { 01442 int res; 01443 ast_channel_lock(chan); 01444 res = ast_softhangup_nolock(chan, cause); 01445 ast_channel_unlock(chan); 01446 return res; 01447 }
| int ast_softhangup_nolock | ( | struct ast_channel * | chan, | |
| int | cause | |||
| ) |
Softly hangup up a channel (no channel lock).
| chan | channel to be soft-hung-up | |
| cause | Ast hangupcause for hangup (see cause.h) |
Definition at line 1426 of file channel.c.
References ast_channel::_softhangup, AST_FLAG_BLOCKING, ast_log(), ast_null_frame, ast_queue_frame(), ast_test_flag, ast_channel::blocker, LOG_DEBUG, ast_channel::name, and option_debug.
Referenced by ast_async_goto(), ast_softhangup(), attempt_transfer(), dahdi_softhangup_all(), do_monitor(), oh323_indicate(), pickdown_channel(), sip_indicate(), and skinny_indicate().
01427 { 01428 if (option_debug) 01429 ast_log(LOG_DEBUG, "Soft-Hanging up channel '%s'\n", chan->name); 01430 /* Inform channel driver that we need to be hung up, if it cares */ 01431 chan->_softhangup |= cause; 01432 ast_queue_frame(chan, &ast_null_frame); 01433 /* Interrupt any poll call or such */ 01434 if (ast_test_flag(chan, AST_FLAG_BLOCKING)) 01435 pthread_kill(chan->blocker, SIGURG); 01436 return 0; 01437 }
| char* ast_state2str | ( | enum | ast_channel_state | ) |
Gives the string form of a given channel state.
Gives the string form of a given channel state
| ast_channel_state | state to get the name of Give a name to a state Returns the text form of the binary state given |
Definition at line 599 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 action_status(), agent_hangup(), ast_channel_alloc(), ast_setstate(), attempt_transfer(), func_channel_read(), handle_chanlist(), handle_chanlist_deprecated(), handle_invite_replaces(), handle_showchan(), handle_showchan_deprecated(), local_attended_transfer(), mgcp_new(), serialize_showchan(), and sip_hangup().
00600 { 00601 char *buf; 00602 00603 switch(state) { 00604 case AST_STATE_DOWN: 00605 return "Down"; 00606 case AST_STATE_RESERVED: 00607 return "Rsrvd"; 00608 case AST_STATE_OFFHOOK: 00609 return "OffHook"; 00610 case AST_STATE_DIALING: 00611 return "Dialing"; 00612 case AST_STATE_RING: 00613 return "Ring"; 00614 case AST_STATE_RINGING: 00615 return "Ringing"; 00616 case AST_STATE_UP: 00617 return "Up"; 00618 case AST_STATE_BUSY: 00619 return "Busy"; 00620 case AST_STATE_DIALING_OFFHOOK: 00621 return "Dialing Offhook"; 00622 case AST_STATE_PRERING: 00623 return "Pre-ring"; 00624 default: 00625 if (!(buf = ast_threadstorage_get(&state2str_threadbuf, STATE2STR_BUFSIZE))) 00626 return "Unknown"; 00627 snprintf(buf, STATE2STR_BUFSIZE, "Unknown (%d)", state); 00628 return buf; 00629 } 00630 }
| int ast_str2cause | ( | const char * | name | ) |
Convert a symbolic hangup cause to number.
Convert the string form of a cause code to a number
| name | string form of the cause Returns the cause code |
Definition at line 587 of file channel.c.
References causes.
Referenced by pbx_builtin_hangup().
00588 { 00589 int x; 00590 00591 for (x = 0; x < sizeof(causes) / sizeof(causes[0]); x++) 00592 if (strncasecmp(causes[x].name, name, strlen(causes[x].name)) == 0) 00593 return causes[x].cause; 00594 00595 return -1; 00596 }
| 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 4471 of file channel.c.
References ast_frfree, ast_read(), ast_tonepair_start(), ast_waitfor(), f, and ast_channel::generatordata.
Referenced by zapateller_exec().
04472 { 04473 int res; 04474 04475 if ((res = ast_tonepair_start(chan, freq1, freq2, duration, vol))) 04476 return res; 04477 04478 /* Give us some wiggle room */ 04479 while (chan->generatordata && ast_waitfor(chan, 100) >= 0) { 04480 struct ast_frame *f = ast_read(chan); 04481 if (f) 04482 ast_frfree(f); 04483 else 04484 return -1; 04485 } 04486 return 0; 04487 }
| int ast_tonepair_start | ( | struct ast_channel * | chan, | |
| int | freq1, | |||
| int | freq2, | |||
| int | duration, | |||
| int | vol | |||
| ) |
Start a tone going
Definition at line 4453 of file channel.c.
References ast_activate_generator(), tonepair_def::duration, tonepair_def::freq1, tonepair_def::freq2, tonepair, and tonepair_def::vol.
Referenced by ast_tonepair(), play_dialtone(), play_tone_pair(), rpt_tele_thread(), and sendnoise().
04454 { 04455 struct tonepair_def d = { 0, }; 04456 04457 d.freq1 = freq1; 04458 d.freq2 = freq2; 04459 d.duration = duration; 04460 d.vol = (vol < 1) ? 8192 : vol; /* force invalid to 8192 */ 04461 if (ast_activate_generator(chan, &tonepair, &d)) 04462 return -1; 04463 return 0; 04464 }
| void ast_tonepair_stop | ( | struct ast_channel * | chan | ) |
Stop a tone from playing
Definition at line 4466 of file channel.c.
References ast_deactivate_generator().
Referenced by sendnoise().
04467 { 04468 ast_deactivate_generator(chan); 04469 }
| int ast_transfer | ( | struct ast_channel * | chan, | |
| char * | dest | |||
| ) |
Transfer a channel (if supported). Returns -1 on error, 0 if not supported and 1 if supported and requested.
| chan | current channel | |
| dest | destination extension for transfer |
Called by:
Definition at line 3201 of file channel.c.
References ast_channel_lock, ast_channel_unlock, ast_check_hangup(), AST_FLAG_ZOMBIE, ast_test_flag, ast_channel::tech, and ast_channel_tech::transfer.
Referenced by transfer_exec().
03202 { 03203 int res = -1; 03204 03205 /* Stop if we're a zombie or need a soft hangup */ 03206 ast_channel_lock(chan); 03207 if (!ast_test_flag(chan, AST_FLAG_ZOMBIE) && !ast_check_hangup(chan)) { 03208 if (chan->tech->transfer) { 03209 res = chan->tech->transfer(chan, dest); 03210 if (!res) 03211 res = 1; 03212 } else 03213 res = 0; 03214 } 03215 ast_channel_unlock(chan); 03216 return res; 03217 }
| char* ast_transfercapability2str | ( | int | transfercapability | ) | const |
Gives the string form of a given transfer capability.
Gives the string form of a given transfer capability
| transfercapability | transfercapabilty to get the name of Give a name to a transfercapbility See above Returns the text form of the binary transfer capbility |
Definition at line 633 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 cb_events(), dahdi_call(), dahdi_new(), misdn_call(), and oh323_call().
00634 { 00635 switch(transfercapability) { 00636 case AST_TRANS_CAP_SPEECH: 00637 return "SPEECH"; 00638 case AST_TRANS_CAP_DIGITAL: 00639 return "DIGITAL"; 00640 case AST_TRANS_CAP_RESTRICTED_DIGITAL: 00641 return "RESTRICTED_DIGITAL"; 00642 case AST_TRANS_CAP_3_1K_AUDIO: 00643 return "3K1AUDIO"; 00644 case AST_TRANS_CAP_DIGITAL_W_TONES: 00645 return "DIGITAL_W_TONES"; 00646 case AST_TRANS_CAP_VIDEO: 00647 return "VIDEO"; 00648 default: 00649 return "UNKNOWN"; 00650 } 00651 }
| 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 Wait for input on a channel for a given # of milliseconds (<0 for indefinite). |
Definition at line 1823 of file channel.c.
References ast_waitfor_nandfds().
Referenced by __adsi_transmit_messages(), __ast_play_and_record(), __ast_request_and_dial(), adsi_careful_send(), agent_ack_sleep(), ast_dtmf_stream(), ast_recvtext(), ast_safe_sleep_conditional(), ast_tonepair(), async_wait(), background_detect_exec(), channel_spy(), conf_exec(), conf_flush(), dictate_exec(), disa_exec(), do_waiting(), echo_exec(), handle_recordfile(), ices_exec(), isAnsweringMachine(), measurenoise(), mp3_exec(), mwanalyze_exec(), NBScat_exec(), nv_background_detect_exec(), nv_detectfax_exec(), receive_dtmf_digits(), record_exec(), recordthread(), send_tone_burst(), send_waveform_to_channel(), sendurl_exec(), sms_exec(), speech_background(), ss_thread(), transmit_audio(), transmit_t38(), wait_for_hangup(), waitforring_exec(), and waitstream_core().
01824 { 01825 int oldms = ms; /* -1 if no timeout */ 01826 01827 ast_waitfor_nandfds(&c, 1, NULL, 0, NULL, NULL, &ms); 01828 if ((ms < 0) && (oldms < 0)) 01829 ms = 0; 01830 return ms; 01831 }
| 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 1818 of file channel.c.
References ast_waitfor_nandfds().
Referenced by ast_feature_request_and_dial(), ast_generic_bridge(), ast_udptl_bridge(), autoservice_run(), bridge_native_loop(), bridge_p2p_loop(), dahdi_bridge(), iax2_bridge(), misdn_bridge(), monitor_dial(), rpt(), rpt_exec(), wait_for_answer(), and wait_for_winner().
01819 { 01820 return ast_waitfor_nandfds(c, n, NULL, 0, NULL, NULL, ms); 01821 }
| int ast_waitfor_n_fd | ( | int * | fds, | |
| int | n, | |||
| int * | ms, | |||
| int * | exception | |||
| ) |
Waits for input on an fd This version works on fd's only. Be careful with it.
Definition at line 1662 of file channel.c.
References ast_waitfor_nandfds().
Referenced by dundi_lookup_internal(), and dundi_precache_internal().
01663 { 01664 int winner = -1; 01665 ast_waitfor_nandfds(NULL, 0, fds, n, exception, &winner, ms); 01666 return winner; 01667 }
| struct ast_channel* ast_waitfor_nandfds | ( | struct ast_channel ** | c, | |
| int | n, | |||
| int * | fds, | |||
| int | nfds, | |||
| int * | exception, | |||
| int * | outfd, | |||
| int * | ms | |||
| ) | [read] |
Waits for activity on a group of channels.
| chan | an array of pointers to channels | |
| n | number of channels that are to be waited upon | |
| fds | an array of fds to wait upon | |
| nfds | the number of fds to wait upon | |
| exception | exception flag | |
| outfd | fd that had activity on it | |
| ms | how long the wait was Big momma function here. Wait for activity on any of the n channels, or any of the nfds file descriptors. |
Definition at line 1670 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_set_flag, AST_SOFTHANGUP_TIMEOUT, ast_tvdiff_ms(), ast_tvnow(), CHECK_BLOCKING, errno, pollfd::fd, ast_channel::fdno, LOG_WARNING, poll(), POLLPRI, pollfd::revents, and ast_channel::whentohangup.
Referenced by app_exec(), ast_waitfor(), ast_waitfor_n(), ast_waitfor_n_fd(), ast_waitfordigit_full(), conf_run(), find_cache(), run_agi(), and waitstream_core().
01672 { 01673 struct timeval start = { 0 , 0 }; 01674 struct pollfd *pfds = NULL; 01675 int res; 01676 long rms; 01677 int x, y, max; 01678 int sz; 01679 time_t now = 0; 01680 long whentohangup = 0, diff; 01681 struct ast_channel *winner = NULL; 01682 struct fdmap { 01683 int chan; 01684 int fdno; 01685 } *fdmap = NULL; 01686 01687 if ((sz = n * AST_MAX_FDS + nfds)) { 01688 pfds = alloca(sizeof(*pfds) * sz); 01689 fdmap = alloca(sizeof(*fdmap) * sz); 01690 } 01691 01692 if (outfd) 01693 *outfd = -99999; 01694 if (exception) 01695 *exception = 0; 01696 01697 /* Perform any pending masquerades */ 01698 for (x=0; x < n; x++) { 01699 ast_channel_lock(c[x]); 01700 if (c[x]->masq) { 01701 if (ast_do_masquerade(c[x])) { 01702 ast_log(LOG_WARNING, "Masquerade failed\n"); 01703 *ms = -1; 01704 ast_channel_unlock(c[x]); 01705 return NULL; 01706 } 01707 } 01708 if (c[x]->whentohangup) { 01709 if (!whentohangup) 01710 time(&now); 01711 diff = c[x]->whentohangup - now; 01712 if (diff < 1) { 01713 /* Should already be hungup */ 01714 c[x]->_softhangup |= AST_SOFTHANGUP_TIMEOUT; 01715 ast_channel_unlock(c[x]); 01716 return c[x]; 01717 } 01718 if (!whentohangup || (diff < whentohangup)) 01719 whentohangup = diff; 01720 } 01721 ast_channel_unlock(c[x]); 01722 } 01723 /* Wait full interval */ 01724 rms = *ms; 01725 if (whentohangup) { 01726 rms = whentohangup * 1000; /* timeout in milliseconds */ 01727 if (*ms >= 0 && *ms < rms) /* original *ms still smaller */ 01728 rms = *ms; 01729 } 01730 /* 01731 * Build the pollfd array, putting the channels' fds first, 01732 * followed by individual fds. Order is important because 01733 * individual fd's must have priority over channel fds. 01734 */ 01735 max = 0; 01736 for (x=0; x<n; x++) { 01737 for (y=0; y<AST_MAX_FDS; y++) { 01738 fdmap[max].fdno = y; /* fd y is linked to this pfds */ 01739 fdmap[max].chan = x; /* channel x is linked to this pfds */ 01740 max += ast_add_fd(&pfds[max], c[x]->fds[y]); 01741 } 01742 CHECK_BLOCKING(c[x]); 01743 } 01744 /* Add the individual fds */ 01745 for (x=0; x<nfds; x++) { 01746 fdmap[max].chan = -1; 01747 max += ast_add_fd(&pfds[max], fds[x]); 01748 } 01749 01750 if (*ms > 0) 01751 start = ast_tvnow(); 01752 01753 if (sizeof(int) == 4) { /* XXX fix timeout > 600000 on linux x86-32 */ 01754 do { 01755 int kbrms = rms; 01756 if (kbrms > 600000) 01757 kbrms = 600000; 01758 res = poll(pfds, max, kbrms); 01759 if (!res) 01760 rms -= kbrms; 01761 } while (!res && (rms > 0)); 01762 } else { 01763 res = poll(pfds, max, rms); 01764 } 01765 for (x=0; x<n; x++) 01766 ast_clear_flag(c[x], AST_FLAG_BLOCKING); 01767 if (res < 0) { /* Simulate a timeout if we were interrupted */ 01768 if (errno != EINTR) 01769 *ms = -1; 01770 return NULL; 01771 } 01772 if (whentohangup) { /* if we have a timeout, check who expired */ 01773 time(&now); 01774 for (x=0; x<n; x++) { 01775 if (c[x]->whentohangup && now >= c[x]->whentohangup) { 01776 c[x]->_softhangup |= AST_SOFTHANGUP_TIMEOUT; 01777 if (winner == NULL) 01778 winner = c[x]; 01779 } 01780 } 01781 } 01782 if (res == 0) { /* no fd ready, reset timeout and done */ 01783 *ms = 0; /* XXX use 0 since we may not have an exact timeout. */ 01784 return winner; 01785 } 01786 /* 01787 * Then check if any channel or fd has a pending event. 01788 * Remember to check channels first and fds last, as they 01789 * must have priority on setting 'winner' 01790 */ 01791 for (x = 0; x < max; x++) { 01792 res = pfds[x].revents; 01793 if (res == 0) 01794 continue; 01795 if (fdmap[x].chan >= 0) { /* this is a channel */ 01796 winner = c[fdmap[x].chan]; /* override previous winners */ 01797 if (res & POLLPRI) 01798 ast_set_flag(winner, AST_FLAG_EXCEPTION); 01799 else 01800 ast_clear_flag(winner, AST_FLAG_EXCEPTION); 01801 winner->fdno = fdmap[x].fdno; 01802 } else { /* this is an fd */ 01803 if (outfd) 01804 *outfd = pfds[x].fd; 01805 if (exception) 01806 *exception = (res & POLLPRI) ? -1 : 0; 01807 winner = NULL; 01808 } 01809 } 01810 if (*ms > 0) { 01811 *ms -= ast_tvdiff_ms(ast_tvnow(), start); 01812 if (*ms < 0) 01813 *ms = 0; 01814 } 01815 return winner; 01816 }
| 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 1834 of file channel.c.
References ast_waitfordigit_full().
Referenced by _while_exec(), advanced_options(), 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(), 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_mailbox_owner(), play_record_review(), read_exec(), read_newoption(), retrydial_exec(), sendnoise(), ss_thread(), test1_client(), test1_server(), vm_execmain(), vm_forwardoptions(), vm_instructions(), vm_options(), vm_tempgreeting(), wait_a_bit(), and wait_our_turn().
01835 { 01836 return ast_waitfordigit_full(c, ms, -1, -1); 01837 }
| 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 1858 of file channel.c.
References ast_check_hangup(), ast_clear_flag, AST_CONTROL_ANSWER, AST_CONTROL_HANGUP, AST_CONTROL_RINGING, 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, f, ast_frame::frametype, LOG_WARNING, and ast_frame::subclass.
Referenced by ast_readstring_full(), ast_waitfordigit(), handle_getoption(), and handle_waitfordigit().
01859 { 01860 /* Stop if we're a zombie or need a soft hangup */ 01861 if (ast_test_flag(c, AST_FLAG_ZOMBIE) || ast_check_hangup(c)) 01862 return -1; 01863 01864 /* Only look for the end of DTMF, don't bother with the beginning and don't emulate things */ 01865 ast_set_flag(c, AST_FLAG_END_DTMF_ONLY); 01866 01867 /* Wait for a digit, no more than ms milliseconds total. */ 01868 while (ms) { 01869 struct ast_channel *rchan; 01870 int outfd; 01871 01872 errno = 0; 01873 rchan = ast_waitfor_nandfds(&c, 1, &cmdfd, (cmdfd > -1) ? 1 : 0, NULL, &outfd, &ms); 01874 if (!rchan && outfd < 0 && ms) { 01875 if (errno == 0 || errno == EINTR) 01876 continue; 01877 ast_log(LOG_WARNING, "Wait failed (%s)\n", strerror(errno)); 01878 ast_clear_flag(c, AST_FLAG_END_DTMF_ONLY); 01879 return -1; 01880 } else if (outfd > -1) { 01881 /* The FD we were watching has something waiting */ 01882 ast_clear_flag(c, AST_FLAG_END_DTMF_ONLY); 01883 return 1; 01884 } else if (rchan) { 01885 int res; 01886 struct ast_frame *f = ast_read(c); 01887 if (!f) 01888 return -1; 01889 01890 switch(f->frametype) { 01891 case AST_FRAME_DTMF_BEGIN: 01892 break; 01893 case AST_FRAME_DTMF_END: 01894 res = f->subclass; 01895 ast_frfree(f); 01896 ast_clear_flag(c, AST_FLAG_END_DTMF_ONLY); 01897 return res; 01898 case AST_FRAME_CONTROL: 01899 switch(f->subclass) { 01900 case AST_CONTROL_HANGUP: 01901 ast_frfree(f); 01902 ast_clear_flag(c, AST_FLAG_END_DTMF_ONLY); 01903 return -1; 01904 case AST_CONTROL_RINGING: 01905 case AST_CONTROL_ANSWER: 01906 case AST_CONTROL_SRCUPDATE: 01907 /* Unimportant */ 01908 break; 01909 default: 01910 ast_log(LOG_WARNING, "Unexpected control subclass '%d'\n", f->subclass); 01911 break; 01912 } 01913 break; 01914 case AST_FRAME_VOICE: 01915 /* Write audio if appropriate */ 01916 if (audiofd > -1) { 01917 if (write(audiofd, f->data, f->datalen) < 0) { 01918 ast_log(LOG_WARNING, "write() failed: %s\n", strerror(errno)); 01919 } 01920 } 01921 default: 01922 /* Ignore */ 01923 break; 01924 } 01925 ast_frfree(f); 01926 } 01927 } 01928 01929 ast_clear_flag(c, AST_FLAG_END_DTMF_ONLY); 01930 01931 return 0; /* Time is up */ 01932 }
| struct ast_channel* ast_walk_channel_by_exten_locked | ( | const struct ast_channel * | chan, | |
| const char * | exten, | |||
| const char * | context | |||
| ) | [read] |
Get next channel by exten (and optionally context) and lock it.
Definition at line 1169 of file channel.c.
References channel_find_locked().
Referenced by next_channel().
01171 { 01172 return channel_find_locked(chan, NULL, 0, context, exten); 01173 }
| struct ast_channel* ast_walk_channel_by_name_prefix_locked | ( | const struct ast_channel * | chan, | |
| const char * | name, | |||
| const int | namelen | |||
| ) | [read] |
Get channel by name prefix (locks channel).
Definition at line 1156 of file channel.c.
References channel_find_locked().
Referenced by next_channel().
01158 { 01159 return channel_find_locked(chan, name, namelen, NULL, NULL); 01160 }
| 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 2723 of file channel.c.
References ast_channel::_softhangup, AST_AUDIOHOOK_DIRECTION_WRITE, ast_audiohook_write_list(), ast_channel_lock, ast_channel_trylock, ast_channel_unlock, ast_check_hangup(), ast_clear_flag, AST_CONTROL_UNHOLD, ast_deactivate_generator(), ast_do_masquerade(), AST_FLAG_BLOCKING, AST_FLAG_WRITE_INT, AST_FLAG_ZOMBIE, 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_frfree, ast_log(), AST_MONITOR_RUNNING, ast_seekstream(), ast_senddigit_begin(), ast_senddigit_end(), AST_SOFTHANGUP_DEV, ast_test_flag, ast_translate(), ast_writestream(), ast_channel::audiohooks, CHECK_BLOCKING, ast_frame::data, ast_frame::datalen, DEBUGCHAN_FLAG, f, ast_channel::fout, FRAMECOUNT_INC, ast_frame::frametype, ast_channel::generatordata, ast_channel_tech::indicate, ast_channel::insmpl, ast_frame::len, LOG_DEBUG, LOG_WARNING, ast_channel::masq, ast_channel::masqr, ast_channel::monitor, MONITOR_DELAY, ast_channel::name, option_debug, ast_channel::outsmpl, ast_channel::rawwriteformat, ast_frame::samples, SEEK_FORCECUR, ast_channel_tech::send_html, ast_channel_tech::send_text, ast_channel_monitor::state, ast_frame::subclass, ast_channel::tech, ast_channel_tech::write, ast_channel_monitor::write_stream, 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(), bridge_native_loop(), bridge_p2p_loop(), conf_queue_dtmf(), conf_run(), dahdi_bridge(), dictate_exec(), echo_exec(), fax_generator_generate(), features_write(), function_ilink(), gen_generate(), handle_link_data(), iax2_bridge(), jb_get_and_deliver(), linear_generator(), milliwatt_generate(), misdn_bridge(), moh_files_generator(), moh_generate(), mp3_exec(), mwanalyze_exec(), NBScat_exec(), playtones_generator(), rpt(), rpt_exec(), send_link_dtmf(), send_tone_burst(), send_waveform_to_channel(), silence_generator_generate(), sms_generate(), spy_generate(), t38_tx_packet_handler(), tonepair_generator(), and wait_for_answer().
02724 { 02725 int res = -1; 02726 int count = 0; 02727 struct ast_frame *f = NULL, *f2 = NULL; 02728 02729 /*Deadlock avoidance*/ 02730 while(ast_channel_trylock(chan)) { 02731 /*cannot goto done since the channel is not locked*/ 02732 if(count++ > 10) { 02733 if(option_debug) 02734 ast_log(LOG_DEBUG, "Deadlock avoided for write to channel '%s'\n", chan->name); 02735 return 0; 02736 } 02737 usleep(1); 02738 } 02739 /* Stop if we're a zombie or need a soft hangup */ 02740 if (ast_test_flag(chan, AST_FLAG_ZOMBIE) || ast_check_hangup(chan)) 02741 goto done; 02742 02743 /* Handle any pending masquerades */ 02744 if (chan->masq && ast_do_masquerade(chan)) { 02745 ast_log(LOG_WARNING, "Failed to perform masquerade\n"); 02746 goto done; 02747 } 02748 if (chan->masqr) { 02749 res = 0; /* XXX explain, why 0 ? */ 02750 goto done; 02751 } 02752 if (chan->generatordata) { 02753 if (ast_test_flag(chan, AST_FLAG_WRITE_INT)) 02754 ast_deactivate_generator(chan); 02755 else { 02756 if (fr->frametype == AST_FRAME_DTMF_END) { 02757 /* There is a generator running while we're in the middle of a digit. 02758 * It's probably inband DTMF, so go ahead and pass it so it can 02759 * stop the generator */ 02760 ast_clear_flag(chan, AST_FLAG_BLOCKING); 02761 ast_channel_unlock(chan); 02762 res = ast_senddigit_end(chan, fr->subclass, fr->len); 02763 ast_channel_lock(chan); 02764 CHECK_BLOCKING(chan); 02765 } else if (fr->frametype == AST_FRAME_CONTROL && fr->subclass == AST_CONTROL_UNHOLD) { 02766 /* This is a side case where Echo is basically being called and the person put themselves on hold and took themselves off hold */ 02767 res = (chan->tech->indicate == NULL) ? 0 : 02768 chan->tech->indicate(chan, fr->subclass, fr->data, fr->datalen); 02769 } 02770 res = 0; /* XXX explain, why 0 ? */ 02771 goto done; 02772 } 02773 } 02774 /* High bit prints debugging */ 02775 if (chan->fout & DEBUGCHAN_FLAG) 02776 ast_frame_dump(chan->name, fr, ">>"); 02777 CHECK_BLOCKING(chan); 02778 switch(fr->frametype) { 02779 case AST_FRAME_CONTROL: 02780 res = (chan->tech->indicate == NULL) ? 0 : 02781 chan->tech->indicate(chan, fr->subclass, fr->data, fr->datalen); 02782 break; 02783 case AST_FRAME_DTMF_BEGIN: 02784 if (chan->audiohooks) { 02785 struct ast_frame *old_frame = fr; 02786 fr = ast_audiohook_write_list(chan, chan->audiohooks, AST_AUDIOHOOK_DIRECTION_WRITE, fr); 02787 if (old_frame != fr) 02788 f = fr; 02789 } 02790 ast_clear_flag(chan, AST_FLAG_BLOCKING); 02791 ast_channel_unlock(chan); 02792 res = ast_senddigit_begin(chan, fr->subclass); 02793 ast_channel_lock(chan); 02794 CHECK_BLOCKING(chan); 02795 break; 02796 case AST_FRAME_DTMF_END: 02797 if (chan->audiohooks) { 02798 struct ast_frame *old_frame = fr; 02799 fr = ast_audiohook_write_list(chan, chan->audiohooks, AST_AUDIOHOOK_DIRECTION_WRITE, fr); 02800 if (old_frame != fr) 02801 f = fr; 02802 } 02803 ast_clear_flag(chan, AST_FLAG_BLOCKING); 02804 ast_channel_unlock(chan); 02805 res = ast_senddigit_end(chan, fr->subclass, fr->len); 02806 ast_channel_lock(chan); 02807 CHECK_BLOCKING(chan); 02808 break; 02809 case AST_FRAME_TEXT: 02810 res = (chan->tech->send_text == NULL) ? 0 : 02811 chan->tech->send_text(chan, (char *) fr->data); 02812 break; 02813 case AST_FRAME_HTML: 02814 res = (chan->tech->send_html == NULL) ? 0 : 02815 chan->tech->send_html(chan, fr->subclass, (char *) fr->data, fr->datalen); 02816 break; 02817 case AST_FRAME_VIDEO: 02818 /* XXX Handle translation of video codecs one day XXX */ 02819 res = (chan->tech->write_video == NULL) ? 0 : 02820 chan->tech->write_video(chan, fr); 02821 break; 02822 case AST_FRAME_MODEM: 02823 res = (chan->tech->write == NULL) ? 0 : 02824 chan->tech->write(chan, fr); 02825 break; 02826 case AST_FRAME_VOICE: 02827 if (chan->tech->write == NULL) 02828 break; /*! \todo XXX should return 0 maybe ? */ 02829 02830 if (chan->audiohooks) { 02831 struct ast_frame *old_frame = fr; 02832 fr = ast_audiohook_write_list(chan, chan->audiohooks, AST_AUDIOHOOK_DIRECTION_WRITE, fr); 02833 if (old_frame != fr) 02834 f2 = fr; 02835 } 02836 02837 /* If the frame is in the raw write format, then it's easy... just use the frame - otherwise we will have to translate */ 02838 if (fr->subclass == chan->rawwriteformat) 02839 f = fr; 02840 else 02841 f = (chan->writetrans) ? ast_translate(chan->writetrans, fr, 0) : fr; 02842 02843 /* If we have no frame of audio, then we have to bail out */ 02844 if (!f) { 02845 res = 0; 02846 break; 02847 } 02848 02849 /* If Monitor is running on this channel, then we have to write frames out there too */ 02850 if (chan->monitor && chan->monitor->write_stream) { 02851 /* XXX must explain this code */ 02852 #ifndef MONITOR_CONSTANT_DELAY 02853 int jump = chan->insmpl - chan->outsmpl - 4 * f->samples; 02854 if (jump >= 0) { 02855 jump = chan->insmpl - chan->outsmpl; 02856 if (ast_seekstream(chan->monitor->write_stream, jump, SEEK_FORCECUR) == -1) 02857 ast_log(LOG_WARNING, "Failed to perform seek in monitoring write stream, synchronization between the files may be broken\n"); 02858 chan->outsmpl += jump + f->samples; 02859 } else 02860 chan->outsmpl += f->samples; 02861 #else 02862 int jump = chan->insmpl - chan->outsmpl; 02863 if (jump - MONITOR_DELAY >= 0) { 02864 if (ast_seekstream(chan->monitor->write_stream, jump - f->samples, SEEK_FORCECUR) == -1) 02865 ast_log(LOG_WARNING, "Failed to perform seek in monitoring write stream, synchronization between the files may be broken\n"); 02866 chan->outsmpl += jump; 02867 } else 02868 chan->outsmpl += f->samples; 02869 #endif 02870 if (chan->monitor->state == AST_MONITOR_RUNNING) { 02871 if (ast_writestream(chan->monitor->write_stream, f) < 0) 02872 ast_log(LOG_WARNING, "Failed to write data to channel monitor write stream\n"); 02873 } 02874 } 02875 02876 if (f) 02877 res = chan->tech->write(chan,f); 02878 else 02879 res = 0; 02880 break; 02881 case AST_FRAME_NULL: 02882 case AST_FRAME_IAX: 02883 /* Ignore these */ 02884 res = 0; 02885 break; 02886 default: 02887 /* At this point, fr is the incoming frame and f is NULL. Channels do 02888 * not expect to get NULL as a frame pointer and will segfault. Hence, 02889 * we output the original frame passed in. */ 02890 res = chan->tech->write(chan, fr); 02891 break; 02892 } 02893 02894 if (f && f != fr) 02895 ast_frfree(f); 02896 if (f2) 02897 ast_frfree(f2); 02898 ast_clear_flag(chan, AST_FLAG_BLOCKING); 02899 /* Consider a write failure to force a soft hangup */ 02900 if (res < 0) 02901 chan->_softhangup |= AST_SOFTHANGUP_DEV; 02902 else { 02903 chan->fout = FRAMECOUNT_INC(chan->fout); 02904 } 02905 done: 02906 ast_channel_unlock(chan); 02907 return res; 02908 }
| 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 2712 of file channel.c.
References ast_write(), ast_channel::tech, and ast_channel_tech::write_video.
02713 { 02714 int res; 02715 if (!chan->tech->write_video) 02716 return 0; 02717 res = ast_write(chan, fr); 02718 if (!res) 02719 res = 1; 02720 return res; 02721 }
| const char* channelreloadreason2txt | ( | enum channelreloadreason | reason | ) |
Convert enum channelreloadreason to text string for manager event.
| reason | Enum channelreloadreason - reason for reload (manager, cli, start etc) |
Definition at line 4686 of file channel.c.
References CHANNEL_CLI_RELOAD, CHANNEL_MODULE_LOAD, and CHANNEL_MODULE_RELOAD.
Referenced by reload_config().
04687 { 04688 switch (reason) { 04689 case CHANNEL_MODULE_LOAD: 04690 return "LOAD (Channel module load)"; 04691 04692 case CHANNEL_MODULE_RELOAD: 04693 return "RELOAD (Channel module reload)"; 04694 04695 case CHANNEL_CLI_RELOAD: 04696 return "CLIRELOAD (Channel module reload by CLI command)"; 04697 04698 default: 04699 return "MANAGERRELOAD (Channel module reload by manager)"; 04700 } 04701 };
1.5.9