#include "asterisk/abstract_jb.h"
#include "asterisk/poll-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/datastore.h"
Go to the source code of this file.
Data Structures | |
struct | ast_bridge_config |
bridge configuration More... | |
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::datastores |
struct | ast_channel_tech |
Structure to describe a channel "technology", ie a channel driver See for examples:. More... | |
struct | ast_generator |
struct | ast_group_info |
channel group info 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 10 |
#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 | 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_IN_DTMF = (1 << 12), AST_FLAG_EMULATE_DTMF = (1 << 13), AST_FLAG_END_DTMF_ONLY = (1 << 14), AST_FLAG_ANSWERED_ELSEWHERE = (1 << 15), AST_FLAG_MASQ_NOSTREAM = (1 << 16), AST_FLAG_BRIDGE_HANGUP_RUN = (1 << 17), AST_FLAG_BRIDGE_HANGUP_DONT = (1 << 18) } |
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_AUTOMIXMON = (1 << 6), AST_FEATURE_NO_H_EXTEN = (1 << 7), AST_FEATURE_WARNING_ACTIVE = (1 << 8) } |
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 | ast_t38_state { T38_STATE_UNAVAILABLE, T38_STATE_UNKNOWN, T38_STATE_NEGOTIATING, T38_STATE_REJECTED, T38_STATE_NEGOTIATED } |
Possible T38 states on channels. 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 | |
int | __ast_answer (struct ast_channel *chan, unsigned int delay, int cdr_answer) |
Answer a channel, with a selectable delay before returning. | |
ast_channel * | __ast_request_and_dial (const char *type, int format, void *data, int timeout, int *reason, const char *cid_num, const char *cid_name, struct outgoing_helper *oh) |
Request a channel of a given type, with data as optional information used by the low level module and attempt to place a call on it. | |
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 channel. | |
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. | |
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. | |
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. | |
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_cmpwhentohangup_tv (struct ast_channel *chan, struct timeval 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. | |
ast_datastore * | ast_channel_datastore_alloc (const struct ast_datastore_info *info, const char *uid) |
Create a channel data store object. | |
ast_datastore * | ast_channel_datastore_find (struct ast_channel *chan, const struct ast_datastore_info *info, const char *uid) |
Find a datastore on a channel. | |
int | ast_channel_datastore_free (struct ast_datastore *datastore) |
Free a channel data store object. | |
int | ast_channel_datastore_inherit (struct ast_channel *from, struct ast_channel *to) |
Inherit datastores from a parent to a child. | |
int | ast_channel_datastore_remove (struct ast_channel *chan, struct ast_datastore *datastore) |
Remove a datastore from a channel. | |
int | ast_channel_defer_dtmf (struct ast_channel *chan) |
Set defer DTMF flag on channel. | |
int | ast_channel_early_bridge (struct ast_channel *c0, struct ast_channel *c1) |
Bridge two channels together (early). | |
void | ast_channel_free (struct ast_channel *) |
Free a channel structure. | |
static enum ast_t38_state | ast_channel_get_t38_state (struct ast_channel *chan) |
Retrieves the current T38 state of a channel. | |
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. | |
int | ast_channel_queryoption (struct ast_channel *channel, int option, void *data, int *datalen, int block) |
const char * | ast_channel_reason2str (int reason) |
return an english explanation of the code returned thru __ast_request_and_dial's 'outstate' argument | |
int | ast_channel_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) |
void | ast_channel_set_fd (struct ast_channel *chan, int which, int fd) |
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. | |
void | ast_channel_setwhentohangup_tv (struct ast_channel *chan, struct timeval offset) |
Set when to hang a channel up. | |
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. | |
ast_channel * | ast_channel_walk_locked (const struct ast_channel *prev) |
Browse channels in use Browse the channels currently in use. | |
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 whacked 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 maximum, int *start) |
Helper function for migrating select to poll. | |
ast_channel * | ast_get_channel_by_exten_locked (const char *exten, const char *context) |
Get channel by exten (and optionally context) and lock it. | |
ast_channel * | ast_get_channel_by_name_locked (const char *chan) |
Get channel by name or uniqueid (locks channel). | |
ast_channel * | ast_get_channel_by_name_prefix_locked (const char *name, const int namelen) |
Get channel by name or uniqueid prefix (locks channel). | |
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) |
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. | |
void | ast_poll_channel_add (struct ast_channel *chan0, struct ast_channel *chan1) |
void | ast_poll_channel_del (struct ast_channel *chan0, struct ast_channel *chan1) |
char * | ast_print_group (char *buf, int buflen, ast_group_t group) |
print call- 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. | |
int | ast_queue_hangup_with_cause (struct ast_channel *chan, int cause) |
Queue a hangup frame with hangupcause set. | |
int | ast_raw_answer (struct ast_channel *chan, int cdr_answer) |
Answer a channel. | |
ast_frame * | ast_read (struct ast_channel *chan) |
Reads a frame. | |
ast_frame * | ast_read_noaudio (struct ast_channel *chan) |
Reads a frame, returning AST_FRAME_NULL frame if audio. | |
int | ast_readstring (struct ast_channel *c, char *s, int len, int timeout, int 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. | |
ast_channel * | ast_request (const char *type, int format, void *data, int *status) |
Requests a channel. | |
ast_channel * | ast_request_and_dial (const char *type, int format, void *data, int timeout, int *reason, const char *cid_num, const char *cid_name) |
Request a channel of a given type, with data as optional information used by the low level module and attempt to place a call on it. | |
int | ast_safe_sleep (struct ast_channel *chan, int ms) |
Wait for a specified 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 specified amount of time, looking for hangups and a condition argument. | |
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, unsigned int duration) |
Send a DTMF digit to a channel Send a DTMF digit to a channel. | |
int | ast_senddigit_begin (struct ast_channel *chan, char digit) |
Send a DTMF digit to a channel Send a DTMF digit to a channel. | |
int | ast_senddigit_end (struct ast_channel *chan, char digit, unsigned int duration) |
Send a DTMF digit to a channel. | |
int | ast_sendtext (struct ast_channel *chan, const char *text) |
Sends text to a channel. | |
void | ast_set_callerid (struct ast_channel *chan, const char *cid_num, const char *cid_name, const char *cid_ani) |
Set caller ID number, name and ANI. | |
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 component 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, unsigned int rate, int(*func)(const void *data), void *data) |
Enable or disable timer ticks for a channel. | |
int | ast_shutting_down (void) |
Returns non-zero if Asterisk is being shut down. | |
int | ast_softhangup (struct ast_channel *chan, int cause) |
Softly hangup up a channel. | |
int | ast_softhangup_nolock (struct ast_channel *chan, int cause) |
Softly hangup up a channel (no channel lock). | |
const 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. | |
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. | |
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. | |
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. | |
ast_channel * | ast_walk_channel_by_name_prefix_locked (const struct ast_channel *chan, const char *name, const int namelen) |
Get channel by name or uniqueid 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_text (struct ast_channel *chan, struct ast_frame *frame) |
Write text 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. | |
static void | timersub (struct timeval *tvend, struct timeval *tvstart, struct timeval *tvdiff) |
Variables | |
unsigned long | global_fin |
unsigned long | global_fout |
Definition in file channel.h.
#define AST_AGENT_FD (AST_MAX_FDS-3) |
used by agents for pass through
Definition at line 160 of file channel.h.
Referenced by agent_read().
#define AST_ALERT_FD (AST_MAX_FDS-1) |
#define AST_BRIDGE_DTMF_CHANNEL_0 (1 << 0) |
Report DTMF on channel 0.
Definition at line 1322 of file channel.h.
Referenced by ast_generic_bridge(), bridge_native_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 1324 of file channel.h.
Referenced by ast_generic_bridge(), bridge_native_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 1330 of file channel.h.
Referenced by bridge_native_loop().
#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 136 of file channel.h.
Referenced by ast_channel_free(), ast_do_masquerade(), ast_park_call_full(), ast_parse_device_state(), ast_setstate(), common_exec(), create_jb(), fast_originate(), page_exec(), and softhangup_exec().
#define AST_GENERATOR_FD (AST_MAX_FDS-4) |
used by generator
Definition at line 161 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 135 of file channel.h.
Referenced by _macro_exec(), cleanup_stale_contexts(), common_exec(), conf_run(), gtalk_load_config(), handle_gosub(), reload_config(), and try_calling().
#define AST_MAX_EXTENSION 80 |
Max length of an extension
Definition at line 134 of file channel.h.
Referenced by advanced_options(), ast_device_state_changed(), ast_devstate_changed(), ast_extension_state2(), ast_ivr_menu_run_internal(), begin_dial_channel(), build_device(), conf_run(), destroy_station(), dial_exec_full(), disa_exec(), do_forward(), dundi_lookup_local(), forward_message(), function_enum(), get_destination(), handle_gosub(), handle_statechange(), load_module(), log_exec(), manager_show_dialplan_helper(), mgcp_ss(), phone_check_exception(), realtime_switch_common(), search_directory(), show_dialplan_helper(), skinny_extensionstate_cb(), skinny_ss(), speech_background(), ss_thread(), transmit_state_notify(), try_calling(), vm_authenticate(), and vmauthenticate().
#define AST_MAX_FDS 10 |
Definition at line 153 of file channel.h.
Referenced by ast_channel_alloc(), ast_channel_free(), ast_do_masquerade(), ast_poll_channel_add(), ast_poll_channel_del(), ast_waitfor_nandfds(), and manage_parkinglot().
#define AST_TIMING_FD (AST_MAX_FDS-2) |
used for timingfd
Definition at line 159 of file channel.h.
Referenced by __ast_read(), agent_read(), ast_channel_alloc(), and ast_do_masquerade().
#define CHECK_BLOCKING | ( | c | ) |
Definition at line 1715 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 151 of file channel.h.
Referenced by _macro_exec(), acf_iaxvar_write(), add_features_datastores(), ast_channel_datastore_inherit(), ast_iax2_new(), authenticate_reply(), dial_exec_full(), socket_process(), and try_calling().
#define DEBUGCHAN_FLAG 0x80000000 |
The high bit of the frame count is used as a debug marker, so increments of the counters must be done with care. Please use c->fin = FRAMECOUNT_INC(c->fin) and the same for c->fout.
Definition at line 334 of file channel.h.
Referenced by __ast_read(), ast_write(), handle_core_set_debug_channel(), handle_showchan(), and serialize_showchan().
#define FRAMECOUNT_INC | ( | x | ) | ( ((x) & DEBUGCHAN_FLAG) | (((x)+1) & ~DEBUGCHAN_FLAG) ) |
#define MAX_LANGUAGE 20 |
#define MAX_MUSICCLASS 80 |
typedef unsigned long long ast_group_t |
anonymous enum |
ast_channel_tech Properties
Definition at line 510 of file channel.h.
00510 { 00511 /*! \brief Channels have this property if they can accept input with jitter; 00512 * i.e. most VoIP channels */ 00513 AST_CHAN_TP_WANTSJITTER = (1 << 0), 00514 /*! \brief Channels have this property if they can create jitter; 00515 * i.e. most VoIP channels */ 00516 AST_CHAN_TP_CREATESJITTER = (1 << 1), 00517 };
anonymous enum |
ast_channel flags
Definition at line 520 of file channel.h.
00520 { 00521 /*! Queue incoming dtmf, to be released when this flag is turned off */ 00522 AST_FLAG_DEFER_DTMF = (1 << 1), 00523 /*! write should be interrupt generator */ 00524 AST_FLAG_WRITE_INT = (1 << 2), 00525 /*! a thread is blocking on this channel */ 00526 AST_FLAG_BLOCKING = (1 << 3), 00527 /*! This is a zombie channel */ 00528 AST_FLAG_ZOMBIE = (1 << 4), 00529 /*! There is an exception pending */ 00530 AST_FLAG_EXCEPTION = (1 << 5), 00531 /*! Listening to moh XXX anthm promises me this will disappear XXX */ 00532 AST_FLAG_MOH = (1 << 6), 00533 /*! This channel is spying on another channel */ 00534 AST_FLAG_SPYING = (1 << 7), 00535 /*! This channel is in a native bridge */ 00536 AST_FLAG_NBRIDGE = (1 << 8), 00537 /*! the channel is in an auto-incrementing dialplan processor, 00538 * so when ->priority is set, it will get incremented before 00539 * finding the next priority to run */ 00540 AST_FLAG_IN_AUTOLOOP = (1 << 9), 00541 /*! This is an outgoing call */ 00542 AST_FLAG_OUTGOING = (1 << 10), 00543 /*! A DTMF_BEGIN frame has been read from this channel, but not yet an END */ 00544 AST_FLAG_IN_DTMF = (1 << 12), 00545 /*! A DTMF_END was received when not IN_DTMF, so the length of the digit is 00546 * currently being emulated */ 00547 AST_FLAG_EMULATE_DTMF = (1 << 13), 00548 /*! This is set to tell the channel not to generate DTMF begin frames, and 00549 * to instead only generate END frames. */ 00550 AST_FLAG_END_DTMF_ONLY = (1 << 14), 00551 /*! Flag to show channels that this call is hangup due to the fact that the call 00552 was indeed anwered, but in another channel */ 00553 AST_FLAG_ANSWERED_ELSEWHERE = (1 << 15), 00554 /*! This flag indicates that on a masquerade, an active stream should not 00555 * be carried over */ 00556 AST_FLAG_MASQ_NOSTREAM = (1 << 16), 00557 /*! This flag indicates that the hangup exten was run when the bridge terminated, 00558 * a message aimed at preventing a subsequent hangup exten being run at the pbx_run 00559 * level */ 00560 AST_FLAG_BRIDGE_HANGUP_RUN = (1 << 17), 00561 /*! This flag indicates that the hangup exten should NOT be run when the 00562 * bridge terminates, this will allow the hangup in the pbx loop to be run instead. 00563 * */ 00564 AST_FLAG_BRIDGE_HANGUP_DONT = (1 << 18), 00565 };
anonymous enum |
ast_bridge_config flags
Definition at line 568 of file channel.h.
00568 { 00569 AST_FEATURE_PLAY_WARNING = (1 << 0), 00570 AST_FEATURE_REDIRECT = (1 << 1), 00571 AST_FEATURE_DISCONNECT = (1 << 2), 00572 AST_FEATURE_ATXFER = (1 << 3), 00573 AST_FEATURE_AUTOMON = (1 << 4), 00574 AST_FEATURE_PARKCALL = (1 << 5), 00575 AST_FEATURE_AUTOMIXMON = (1 << 6), 00576 AST_FEATURE_NO_H_EXTEN = (1 << 7), 00577 AST_FEATURE_WARNING_ACTIVE = (1 << 8), 00578 };
anonymous enum |
Definition at line 616 of file channel.h.
00616 { 00617 AST_CDR_TRANSFER = (1 << 0), 00618 AST_CDR_FORWARD = (1 << 1), 00619 AST_CDR_CALLWAIT = (1 << 2), 00620 AST_CDR_CONFERENCE = (1 << 3), 00621 };
anonymous enum |
Definition at line 623 of file channel.h.
00623 { 00624 /*! Soft hangup by device */ 00625 AST_SOFTHANGUP_DEV = (1 << 0), 00626 /*! Soft hangup for async goto */ 00627 AST_SOFTHANGUP_ASYNCGOTO = (1 << 1), 00628 AST_SOFTHANGUP_SHUTDOWN = (1 << 2), 00629 AST_SOFTHANGUP_TIMEOUT = (1 << 3), 00630 AST_SOFTHANGUP_APPUNLOAD = (1 << 4), 00631 AST_SOFTHANGUP_EXPLICIT = (1 << 5), 00632 AST_SOFTHANGUP_UNBRIDGE = (1 << 6), 00633 };
enum ast_bridge_result |
Definition at line 163 of file channel.h.
00163 { 00164 AST_BRIDGE_COMPLETE = 0, 00165 AST_BRIDGE_FAILED = -1, 00166 AST_BRIDGE_FAILED_NOWARN = -2, 00167 AST_BRIDGE_RETRY = -3, 00168 };
enum ast_channel_adsicpe |
Definition at line 345 of file channel.h.
00345 { 00346 AST_ADSI_UNKNOWN, 00347 AST_ADSI_AVAILABLE, 00348 AST_ADSI_UNAVAILABLE, 00349 AST_ADSI_OFFHOOKONLY, 00350 };
enum ast_channel_state |
ast_channel states
Definition at line 358 of file channel.h.
00358 { 00359 AST_STATE_DOWN, /*!< Channel is down and available */ 00360 AST_STATE_RESERVED, /*!< Channel is down, but reserved */ 00361 AST_STATE_OFFHOOK, /*!< Channel is off hook */ 00362 AST_STATE_DIALING, /*!< Digits (or equivalent) have been dialed */ 00363 AST_STATE_RING, /*!< Line is ringing */ 00364 AST_STATE_RINGING, /*!< Remote end is ringing */ 00365 AST_STATE_UP, /*!< Line is up */ 00366 AST_STATE_BUSY, /*!< Line is busy */ 00367 AST_STATE_DIALING_OFFHOOK, /*!< Digits (or equivalent) have been dialed while offhook */ 00368 AST_STATE_PRERING, /*!< Channel has detected an incoming call and is waiting for ring */ 00369 00370 AST_STATE_MUTE = (1 << 16), /*!< Do not transmit voice data */ 00371 };
enum ast_t38_state |
Possible T38 states on channels.
Definition at line 376 of file channel.h.
00376 { 00377 T38_STATE_UNAVAILABLE, /*!< T38 is unavailable on this channel or disabled by configuration */ 00378 T38_STATE_UNKNOWN, /*!< The channel supports T38 but the current status is unknown */ 00379 T38_STATE_NEGOTIATING, /*!< T38 is being negotiated */ 00380 T38_STATE_REJECTED, /*!< Remote side has rejected our offer */ 00381 T38_STATE_NEGOTIATED, /*!< T38 established */ 00382 };
enum channelreloadreason |
Channel reload reasons for manager events at load or reload of configuration.
Definition at line 637 of file channel.h.
00637 { 00638 CHANNEL_MODULE_LOAD, 00639 CHANNEL_MODULE_RELOAD, 00640 CHANNEL_CLI_RELOAD, 00641 CHANNEL_MANAGER_RELOAD, 00642 };
int __ast_answer | ( | struct ast_channel * | chan, | |
unsigned int | delay, | |||
int | cdr_answer | |||
) |
Answer a channel, with a selectable delay before returning.
chan | channel to answer | |
delay | maximum amount of time to wait for incoming media | |
cdr_answer | flag to control whether any associated CDR should be marked as 'answered' |
This function will wait up to 'delay' milliseconds for media to arrive on the channel before returning to the caller, so that the caller can properly assume the channel is 'ready' for media flow. If 'delay' is less than 500, the function will wait up to 500 milliseconds.
0 | on success | |
non-zero | on failure |
Definition at line 1732 of file channel.c.
References ast_channel::_state, ast_channel_lock, ast_channel_unlock, AST_CONTROL_HANGUP, ast_debug, AST_FRAME_CNG, AST_FRAME_CONTROL, AST_FRAME_DTMF_BEGIN, AST_FRAME_DTMF_END, AST_FRAME_HTML, AST_FRAME_IAX, AST_FRAME_IMAGE, AST_FRAME_MODEM, AST_FRAME_NULL, AST_FRAME_TEXT, AST_FRAME_VIDEO, AST_FRAME_VOICE, ast_frfree, ast_frisolate(), AST_LIST_HEAD_INIT_NOLOCK, AST_LIST_HEAD_NOLOCK, AST_LIST_INSERT_HEAD, AST_LIST_REMOVE_HEAD, ast_log(), ast_queue_frame_head(), ast_raw_answer(), ast_read(), AST_STATE_RING, AST_STATE_RINGING, ast_waitfor(), chanlist::chan, errno, ast_frame::frame_list, frames, ast_frame::frametype, LOG_WARNING, MAX, ast_channel::name, and ast_frame::subclass.
Referenced by ast_answer(), dial_exec_full(), pbx_builtin_answer(), and pbx_builtin_incomplete().
01733 { 01734 int res = 0; 01735 enum ast_channel_state old_state; 01736 01737 old_state = chan->_state; 01738 if ((res = ast_raw_answer(chan, cdr_answer))) { 01739 return res; 01740 } 01741 01742 switch (old_state) { 01743 case AST_STATE_RINGING: 01744 case AST_STATE_RING: 01745 /* wait for media to start flowing, but don't wait any longer 01746 * than 'delay' or 500 milliseconds, whichever is longer 01747 */ 01748 do { 01749 AST_LIST_HEAD_NOLOCK(, ast_frame) frames; 01750 struct ast_frame *cur, *new; 01751 int ms = MAX(delay, 500); 01752 unsigned int done = 0; 01753 01754 AST_LIST_HEAD_INIT_NOLOCK(&frames); 01755 01756 for (;;) { 01757 ms = ast_waitfor(chan, ms); 01758 if (ms < 0) { 01759 ast_log(LOG_WARNING, "Error condition occurred when polling channel %s for a voice frame: %s\n", chan->name, strerror(errno)); 01760 res = -1; 01761 break; 01762 } 01763 if (ms == 0) { 01764 ast_debug(2, "Didn't receive a media frame from %s within %d ms of answering. Continuing anyway\n", chan->name, MAX(delay, 500)); 01765 break; 01766 } 01767 cur = ast_read(chan); 01768 if (!cur || ((cur->frametype == AST_FRAME_CONTROL) && 01769 (cur->subclass == AST_CONTROL_HANGUP))) { 01770 if (cur) { 01771 ast_frfree(cur); 01772 } 01773 res = -1; 01774 ast_debug(2, "Hangup of channel %s detected in answer routine\n", chan->name); 01775 break; 01776 } 01777 01778 if ((new = ast_frisolate(cur)) != cur) { 01779 ast_frfree(cur); 01780 } 01781 01782 AST_LIST_INSERT_HEAD(&frames, new, frame_list); 01783 01784 /* if a specific delay period was requested, continue 01785 * until that delay has passed. don't stop just because 01786 * incoming media has arrived. 01787 */ 01788 if (delay) { 01789 continue; 01790 } 01791 01792 switch (new->frametype) { 01793 /* all of these frametypes qualify as 'media' */ 01794 case AST_FRAME_VOICE: 01795 case AST_FRAME_VIDEO: 01796 case AST_FRAME_TEXT: 01797 case AST_FRAME_DTMF_BEGIN: 01798 case AST_FRAME_DTMF_END: 01799 case AST_FRAME_IMAGE: 01800 case AST_FRAME_HTML: 01801 case AST_FRAME_MODEM: 01802 done = 1; 01803 break; 01804 case AST_FRAME_CONTROL: 01805 case AST_FRAME_IAX: 01806 case AST_FRAME_NULL: 01807 case AST_FRAME_CNG: 01808 break; 01809 } 01810 01811 if (done) { 01812 break; 01813 } 01814 } 01815 01816 if (res == 0) { 01817 ast_channel_lock(chan); 01818 while ((cur = AST_LIST_REMOVE_HEAD(&frames, frame_list))) { 01819 ast_queue_frame_head(chan, cur); 01820 ast_frfree(cur); 01821 } 01822 ast_channel_unlock(chan); 01823 } 01824 } while (0); 01825 break; 01826 default: 01827 break; 01828 } 01829 01830 return res; 01831 }
struct ast_channel* __ast_request_and_dial | ( | const char * | type, | |
int | format, | |||
void * | data, | |||
int | timeout, | |||
int * | reason, | |||
const char * | cid_num, | |||
const char * | cid_name, | |||
struct outgoing_helper * | oh | |||
) |
Request a channel of a given type, with data as optional information used by the low level module and attempt to place a call on it.
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 unsuccessful) | |
cid_num | Caller-ID Number | |
cid_name | Caller-ID Name (ascii) | |
oh | Outgoing helper |
Definition at line 3514 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_datastore_inherit(), 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, chanlist::chan, outgoing_helper::cid_name, outgoing_helper::cid_num, ast_channel::context, outgoing_helper::context, ast_channel::exten, outgoing_helper::exten, f, ast_channel::hangupcause, LOG_NOTICE, outgoing_helper::parent_channel, ast_channel::priority, outgoing_helper::priority, and outgoing_helper::vars.
Referenced by ast_pbx_outgoing_app(), ast_pbx_outgoing_exten(), ast_request_and_dial(), and parkandannounce_exec().
03515 { 03516 int dummy_outstate; 03517 int cause = 0; 03518 struct ast_channel *chan; 03519 int res = 0; 03520 int last_subclass = 0; 03521 03522 if (outstate) 03523 *outstate = 0; 03524 else 03525 outstate = &dummy_outstate; /* make outstate always a valid pointer */ 03526 03527 chan = ast_request(type, format, data, &cause); 03528 if (!chan) { 03529 ast_log(LOG_NOTICE, "Unable to request channel %s/%s\n", type, (char *)data); 03530 /* compute error and return */ 03531 if (cause == AST_CAUSE_BUSY) 03532 *outstate = AST_CONTROL_BUSY; 03533 else if (cause == AST_CAUSE_CONGESTION) 03534 *outstate = AST_CONTROL_CONGESTION; 03535 return NULL; 03536 } 03537 03538 if (oh) { 03539 if (oh->vars) 03540 ast_set_variables(chan, oh->vars); 03541 /* XXX why is this necessary, for the parent_channel perhaps ? */ 03542 if (!ast_strlen_zero(oh->cid_num) && !ast_strlen_zero(oh->cid_name)) 03543 ast_set_callerid(chan, oh->cid_num, oh->cid_name, oh->cid_num); 03544 if (oh->parent_channel) { 03545 ast_channel_inherit_variables(oh->parent_channel, chan); 03546 ast_channel_datastore_inherit(oh->parent_channel, chan); 03547 } 03548 if (oh->account) 03549 ast_cdr_setaccount(chan, oh->account); 03550 } 03551 ast_set_callerid(chan, cid_num, cid_name, cid_num); 03552 03553 if (ast_call(chan, data, 0)) { /* ast_call failed... */ 03554 ast_log(LOG_NOTICE, "Unable to call channel %s/%s\n", type, (char *)data); 03555 } else { 03556 res = 1; /* mark success in case chan->_state is already AST_STATE_UP */ 03557 while (timeout && chan->_state != AST_STATE_UP) { 03558 struct ast_frame *f; 03559 res = ast_waitfor(chan, timeout); 03560 if (res <= 0) /* error, timeout, or done */ 03561 break; 03562 if (timeout > -1) 03563 timeout = res; 03564 f = ast_read(chan); 03565 if (!f) { 03566 *outstate = AST_CONTROL_HANGUP; 03567 res = 0; 03568 break; 03569 } 03570 if (f->frametype == AST_FRAME_CONTROL) { 03571 switch (f->subclass) { 03572 case AST_CONTROL_RINGING: /* record but keep going */ 03573 *outstate = f->subclass; 03574 break; 03575 03576 case AST_CONTROL_BUSY: 03577 case AST_CONTROL_CONGESTION: 03578 case AST_CONTROL_ANSWER: 03579 *outstate = f->subclass; 03580 timeout = 0; /* trick to force exit from the while() */ 03581 break; 03582 03583 /* Ignore these */ 03584 case AST_CONTROL_PROGRESS: 03585 case AST_CONTROL_PROCEEDING: 03586 case AST_CONTROL_HOLD: 03587 case AST_CONTROL_UNHOLD: 03588 case AST_CONTROL_VIDUPDATE: 03589 case AST_CONTROL_SRCUPDATE: 03590 case -1: /* Ignore -- just stopping indications */ 03591 break; 03592 03593 default: 03594 ast_log(LOG_NOTICE, "Don't know what to do with control frame %d\n", f->subclass); 03595 } 03596 last_subclass = f->subclass; 03597 } 03598 ast_frfree(f); 03599 } 03600 } 03601 03602 /* Final fixups */ 03603 if (oh) { 03604 if (!ast_strlen_zero(oh->context)) 03605 ast_copy_string(chan->context, oh->context, sizeof(chan->context)); 03606 if (!ast_strlen_zero(oh->exten)) 03607 ast_copy_string(chan->exten, oh->exten, sizeof(chan->exten)); 03608 if (oh->priority) 03609 chan->priority = oh->priority; 03610 } 03611 if (chan->_state == AST_STATE_UP) 03612 *outstate = AST_CONTROL_ANSWER; 03613 03614 if (res <= 0) { 03615 if ( AST_CONTROL_RINGING == last_subclass ) 03616 chan->hangupcause = AST_CAUSE_NO_ANSWER; 03617 if (!chan->cdr && (chan->cdr = ast_cdr_alloc())) 03618 ast_cdr_init(chan->cdr, chan); 03619 if (chan->cdr) { 03620 char tmp[256]; 03621 snprintf(tmp, sizeof(tmp), "%s/%s", type, (char *)data); 03622 ast_cdr_setapp(chan->cdr,"Dial",tmp); 03623 ast_cdr_update(chan); 03624 ast_cdr_start(chan->cdr); 03625 ast_cdr_end(chan->cdr); 03626 /* If the cause wasn't handled properly */ 03627 if (ast_cdr_disposition(chan->cdr,chan->hangupcause)) 03628 ast_cdr_failed(chan->cdr); 03629 } 03630 ast_hangup(chan); 03631 chan = NULL; 03632 } 03633 return chan; 03634 }
int ast_activate_generator | ( | struct ast_channel * | chan, | |
struct ast_generator * | gen, | |||
void * | params | |||
) |
Activate a given generator
Definition at line 1883 of file channel.c.
References ast_generator::alloc, ast_channel_lock, ast_channel_unlock, ast_prod(), ast_settimeout(), chanlist::chan, gen, ast_channel::generator, generator_force(), ast_channel::generatordata, and ast_generator::release.
Referenced by app_exec(), ast_channel_start_silence_generator(), ast_linear_stream(), ast_playtones_start(), ast_tonepair_start(), channel_spy(), eivr_comm(), old_milliwatt_exec(), and transmit_audio().
01884 { 01885 int res = 0; 01886 01887 ast_channel_lock(chan); 01888 01889 if (chan->generatordata) { 01890 if (chan->generator && chan->generator->release) 01891 chan->generator->release(chan, chan->generatordata); 01892 chan->generatordata = NULL; 01893 } 01894 01895 ast_prod(chan); 01896 if (gen->alloc && !(chan->generatordata = gen->alloc(chan, params))) { 01897 res = -1; 01898 } 01899 01900 if (!res) { 01901 ast_settimeout(chan, 50, generator_force, chan); 01902 chan->generator = gen; 01903 } 01904 01905 ast_channel_unlock(chan); 01906 01907 return res; 01908 }
int ast_active_channels | ( | void | ) |
returns number of active/allocated channels
Returns number of active/allocated channels
Definition at line 497 of file channel.c.
References AST_RWLIST_RDLOCK, AST_RWLIST_TRAVERSE, and AST_RWLIST_UNLOCK.
Referenced by action_corestatus(), dahdi_restart(), handle_show_settings(), and quit_handler().
00498 { 00499 struct ast_channel *c; 00500 int cnt = 0; 00501 AST_RWLIST_RDLOCK(&channels); 00502 AST_RWLIST_TRAVERSE(&channels, c, chan_list) 00503 cnt++; 00504 AST_RWLIST_UNLOCK(&channels); 00505 return cnt; 00506 }
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 1629 of file channel.h.
Referenced by ast_waitfor_nandfds().
int ast_answer | ( | struct ast_channel * | chan | ) |
Answer a channel.
chan | channel to answer |
This function will wait up to 500 milliseconds for media to arrive on the channel before returning to the caller, so that the caller can properly assume the channel is 'ready' for media flow.
0 | on success | |
non-zero | on failure |
Definition at line 1833 of file channel.c.
References __ast_answer(), and chanlist::chan.
Referenced by action_bridge(), agi_exec_full(), alarmreceiver_exec(), answer_trunk_chan(), app_exec(), ast_control_streamfile(), ast_pickup_call(), auth_exec(), background_detect_exec(), bridge_exec(), builtin_parkcall(), common_exec(), conf_exec(), count_exec(), dahdiras_exec(), dictate_exec(), directory_exec(), disa_exec(), eivr_comm(), handle_answer(), ices_exec(), login_exec(), minivm_accmess_exec(), minivm_greet_exec(), minivm_record_exec(), old_milliwatt_exec(), park_call_exec(), park_exec_full(), pbx_builtin_background(), pickup_do(), playback_exec(), privacy_exec(), read_exec(), readexten_exec(), rpt_exec(), sayunixtime_exec(), send_waveform_to_channel(), setup_privacy_args(), skel_exec(), sla_station_exec(), speech_background(), testclient_exec(), testserver_exec(), transmit(), vm_exec(), vm_execmain(), waitfor_exec(), and zapateller_exec().
01834 { 01835 return __ast_answer(chan, 0, 1); 01836 }
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 184 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, 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_automixmonitor(), builtin_blindtransfer(), conf_play(), dial_exec_full(), feature_exec_app(), function_realtime_read(), function_realtime_readdestroy(), function_realtime_store(), function_realtime_write(), lock_read(), lua_autoservice_start(), lua_get_variable_value(), lua_pbx_exec(), lua_set_variable(), lua_set_variable_value(), osplookup_exec(), pbx_find_extension(), play_message_in_bridged_call(), shell_helper(), sla_station_exec(), smdi_msg_retrieve_read(), system_exec_helper(), try_calling(), and trylock_read().
00185 { 00186 int res = 0; 00187 struct asent *as; 00188 00189 AST_LIST_LOCK(&aslist); 00190 AST_LIST_TRAVERSE(&aslist, as, list) { 00191 if (as->chan == chan) { 00192 as->use_count++; 00193 break; 00194 } 00195 } 00196 AST_LIST_UNLOCK(&aslist); 00197 00198 if (as) { 00199 /* Entry exists, autoservice is already handling this channel */ 00200 return 0; 00201 } 00202 00203 if (!(as = ast_calloc(1, sizeof(*as)))) 00204 return -1; 00205 00206 /* New entry created */ 00207 as->chan = chan; 00208 as->use_count = 1; 00209 00210 ast_channel_lock(chan); 00211 as->orig_end_dtmf_flag = ast_test_flag(chan, AST_FLAG_END_DTMF_ONLY) ? 1 : 0; 00212 if (!as->orig_end_dtmf_flag) 00213 ast_set_flag(chan, AST_FLAG_END_DTMF_ONLY); 00214 ast_channel_unlock(chan); 00215 00216 AST_LIST_LOCK(&aslist); 00217 00218 if (AST_LIST_EMPTY(&aslist) && asthread != AST_PTHREADT_NULL) { 00219 ast_cond_signal(&as_cond); 00220 } 00221 00222 AST_LIST_INSERT_HEAD(&aslist, as, list); 00223 00224 if (asthread == AST_PTHREADT_NULL) { /* need start the thread */ 00225 if (ast_pthread_create_background(&asthread, NULL, autoservice_run, NULL)) { 00226 ast_log(LOG_WARNING, "Unable to create autoservice thread :(\n"); 00227 /* There will only be a single member in the list at this point, 00228 the one we just added. */ 00229 AST_LIST_REMOVE(&aslist, as, list); 00230 free(as); 00231 asthread = AST_PTHREADT_NULL; 00232 res = -1; 00233 } else { 00234 pthread_kill(asthread, SIGURG); 00235 } 00236 } 00237 00238 AST_LIST_UNLOCK(&aslist); 00239 00240 return res; 00241 }
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 243 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_write(), array(), ast_dtmf_stream(), ast_get_srv(), ast_get_txt(), ast_hangup(), bridge_playfile(), builtin_atxfer(), builtin_automixmonitor(), conf_play(), dial_exec_full(), feature_exec_app(), finishup(), function_realtime_read(), function_realtime_readdestroy(), function_realtime_store(), function_realtime_write(), lock_read(), lua_autoservice_stop(), lua_get_variable_value(), lua_pbx_exec(), lua_set_variable(), lua_set_variable_value(), osplookup_exec(), pbx_find_extension(), play_message_in_bridged_call(), shell_helper(), sla_station_exec(), smdi_msg_retrieve_read(), system_exec_helper(), try_calling(), and trylock_read().
00244 { 00245 int res = -1; 00246 struct asent *as, *removed = NULL; 00247 struct ast_frame *f; 00248 int chan_list_state; 00249 00250 AST_LIST_LOCK(&aslist); 00251 00252 /* Save the autoservice channel list state. We _must_ verify that the channel 00253 * list has been rebuilt before we return. Because, after we return, the channel 00254 * could get destroyed and we don't want our poor autoservice thread to step on 00255 * it after its gone! */ 00256 chan_list_state = as_chan_list_state; 00257 00258 /* Find the entry, but do not free it because it still can be in the 00259 autoservice thread array */ 00260 AST_LIST_TRAVERSE_SAFE_BEGIN(&aslist, as, list) { 00261 if (as->chan == chan) { 00262 as->use_count--; 00263 if (as->use_count < 1) { 00264 AST_LIST_REMOVE_CURRENT(list); 00265 removed = as; 00266 } 00267 break; 00268 } 00269 } 00270 AST_LIST_TRAVERSE_SAFE_END; 00271 00272 if (removed && asthread != AST_PTHREADT_NULL) { 00273 pthread_kill(asthread, SIGURG); 00274 } 00275 00276 AST_LIST_UNLOCK(&aslist); 00277 00278 if (!removed) { 00279 return 0; 00280 } 00281 00282 /* Wait while autoservice thread rebuilds its list. */ 00283 while (chan_list_state == as_chan_list_state) { 00284 usleep(1000); 00285 } 00286 00287 /* Now autoservice thread should have no references to our entry 00288 and we can safely destroy it */ 00289 00290 if (!chan->_softhangup) { 00291 res = 0; 00292 } 00293 00294 if (!as->orig_end_dtmf_flag) { 00295 ast_clear_flag(chan, AST_FLAG_END_DTMF_ONLY); 00296 } 00297 00298 ast_channel_lock(chan); 00299 while ((f = AST_LIST_REMOVE_HEAD(&as->deferred_frames, frame_list))) { 00300 ast_queue_frame_head(chan, f); 00301 ast_frfree(f); 00302 } 00303 ast_channel_unlock(chan); 00304 00305 free(as); 00306 00307 return res; 00308 }
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 483 of file channel.c.
References AST_RWLIST_RDLOCK, AST_RWLIST_TRAVERSE, AST_RWLIST_UNLOCK, ast_softhangup(), and AST_SOFTHANGUP_SHUTDOWN.
Referenced by quit_handler().
00484 { 00485 struct ast_channel *c; 00486 shutting_down = 1; 00487 if (hangup) { 00488 AST_RWLIST_RDLOCK(&channels); 00489 AST_RWLIST_TRAVERSE(&channels, c, chan_list) { 00490 ast_softhangup(c, AST_SOFTHANGUP_SHUTDOWN); 00491 } 00492 AST_RWLIST_UNLOCK(&channels); 00493 } 00494 }
int ast_best_codec | ( | int | fmts | ) |
Pick the best audio codec.
Pick the best codec
Okay, ulaw is used by all telephony equipment, so start with it
Unless of course, you're a silly European, so then prefer ALAW
G.722 is better then all below, but not as common as the above... so give ulaw and alaw priority
Okay, well, signed linear is easy to translate into other stuff
G.726 is standard ADPCM, in RFC3551 packing order
G.726 is standard ADPCM, in AAL2 packing order
ADPCM has great sound quality and is still pretty easy to translate
Okay, we're down to vocoders now, so pick GSM because it's small and easier to translate and sounds pretty good
iLBC is not too bad
Speex is free, but computationally more expensive than GSM
Ick, LPC10 sounds terrible, but at least we have code for it, if you're tacky enough to use it
G.729a is faster than 723 and slightly less expensive
Down to G.723.1 which is proprietary but at least designed for voice
Definition at line 711 of file channel.c.
References ARRAY_LEN, 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_SLINEAR16, AST_FORMAT_SPEEX, AST_FORMAT_ULAW, ast_log(), LOG_WARNING, and prefs.
Referenced by __oh323_new(), agent_call(), ast_codec_choose(), ast_iax2_new(), ast_speech_new(), builtin_atxfer(), echo_exec(), findmeexec(), gtalk_new(), handle_open_receive_channel_ack_message(), iax2_request(), jingle_new(), local_new(), login_exec(), mgcp_new(), sip_new(), skinny_new(), skinny_set_rtp_peer(), socket_process(), start_rtp(), transmit_connect(), and unistim_new().
00712 { 00713 /* This just our opinion, expressed in code. We are asked to choose 00714 the best codec to use, given no information */ 00715 int x; 00716 static const int prefs[] = 00717 { 00718 /*! Okay, ulaw is used by all telephony equipment, so start with it */ 00719 AST_FORMAT_ULAW, 00720 /*! Unless of course, you're a silly European, so then prefer ALAW */ 00721 AST_FORMAT_ALAW, 00722 /*! G.722 is better then all below, but not as common as the above... so give ulaw and alaw priority */ 00723 AST_FORMAT_G722, 00724 /*! Okay, well, signed linear is easy to translate into other stuff */ 00725 AST_FORMAT_SLINEAR16, 00726 AST_FORMAT_SLINEAR, 00727 /*! G.726 is standard ADPCM, in RFC3551 packing order */ 00728 AST_FORMAT_G726, 00729 /*! G.726 is standard ADPCM, in AAL2 packing order */ 00730 AST_FORMAT_G726_AAL2, 00731 /*! ADPCM has great sound quality and is still pretty easy to translate */ 00732 AST_FORMAT_ADPCM, 00733 /*! Okay, we're down to vocoders now, so pick GSM because it's small and easier to 00734 translate and sounds pretty good */ 00735 AST_FORMAT_GSM, 00736 /*! iLBC is not too bad */ 00737 AST_FORMAT_ILBC, 00738 /*! Speex is free, but computationally more expensive than GSM */ 00739 AST_FORMAT_SPEEX, 00740 /*! Ick, LPC10 sounds terrible, but at least we have code for it, if you're tacky enough 00741 to use it */ 00742 AST_FORMAT_LPC10, 00743 /*! G.729a is faster than 723 and slightly less expensive */ 00744 AST_FORMAT_G729A, 00745 /*! Down to G.723.1 which is proprietary but at least designed for voice */ 00746 AST_FORMAT_G723_1, 00747 }; 00748 00749 /* Strip out video */ 00750 fmts &= AST_FORMAT_AUDIO_MASK; 00751 00752 /* Find the first preferred codec in the format given */ 00753 for (x = 0; x < ARRAY_LEN(prefs); x++) { 00754 if (fmts & prefs[x]) 00755 return prefs[x]; 00756 } 00757 00758 ast_log(LOG_WARNING, "Don't know any of 0x%x formats\n", fmts); 00759 00760 return 0; 00761 }
struct ast_channel* ast_bridged_channel | ( | struct ast_channel * | chan | ) |
Find bridged channel.
chan | Current channel |
Definition at line 4372 of file channel.c.
References ast_channel::_bridge, ast_channel_tech::bridged_channel, chanlist::chan, and ast_channel::tech.
Referenced by __dahdi_exception(), action_agents(), action_coreshowchannels(), agents_show(), agents_show_online(), ast_bridge_call(), ast_channel_masquerade(), ast_park_call_full(), ast_rtp_set_vars(), attempt_transfer(), cb_events(), channel_spy(), check_bridge(), common_exec(), console_transfer(), create_jb(), dahdi_handle_event(), dahdi_hangup(), export_aoc_vars(), get_refer_info(), handle_chanlist(), handle_hd_hf(), handle_invite_replaces(), handle_request(), handle_request_bye(), handle_request_info(), handle_request_refer(), handle_showchan(), handle_soft_key_event_message(), handle_stimulus_message(), key_call(), key_dial_page(), local_attended_transfer(), mgcp_hangup(), mgcp_ss(), misdn_transfer_bc(), mixmonitor_thread(), schedule_delivery(), sip_hangup(), sip_read(), skinny_transfer(), socket_process(), ss_thread(), start_spying(), startmon(), TransferCallStep1(), and unistim_hangup().
04373 { 04374 struct ast_channel *bridged; 04375 bridged = chan->_bridge; 04376 if (bridged && bridged->tech->bridged_channel) 04377 bridged = bridged->tech->bridged_channel(chan, bridged); 04378 return bridged; 04379 }
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 3697 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, chanlist::chan, and ast_channel::tech.
Referenced by __ast_request_and_dial(), agent_call(), ast_feature_request_and_dial(), attempt_reconnect(), begin_dial_channel(), connect_link(), dial_exec_full(), do_forward(), do_idle_thread(), findmeexec(), ring_entry(), and rpt().
03698 { 03699 /* Place an outgoing call, but don't wait any longer than timeout ms before returning. 03700 If the remote end does not answer within the timeout, then do NOT hang up, but 03701 return anyway. */ 03702 int res = -1; 03703 /* Stop if we're a zombie or need a soft hangup */ 03704 ast_channel_lock(chan); 03705 if (!ast_test_flag(chan, AST_FLAG_ZOMBIE) && !ast_check_hangup(chan)) { 03706 if (chan->cdr) 03707 ast_set_flag(chan->cdr, AST_CDR_FLAG_DIALED); 03708 if (chan->tech->call) 03709 res = chan->tech->call(chan, addr, timeout); 03710 ast_set_flag(chan, AST_FLAG_OUTGOING); 03711 } 03712 ast_channel_unlock(chan); 03713 return res; 03714 }
void ast_cancel_shutdown | ( | void | ) |
Cancel a shutdown in progress.
Cancels an existing shutdown and returns to normal operation
Definition at line 509 of file channel.c.
Referenced by handle_abort_shutdown().
00510 { 00511 shutting_down = 0; 00512 }
const char* ast_cause2str | ( | int | state | ) |
Gives the string form of a given hangup cause.
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 629 of file channel.c.
References ARRAY_LEN, causes, and ast_cause::desc.
Referenced by __transmit_response(), ast_do_masquerade(), ast_hangup(), dial_exec_full(), findmeexec(), sip_hangup(), and transmit_request_with_auth().
00630 { 00631 int x; 00632 00633 for (x = 0; x < ARRAY_LEN(causes); x++) { 00634 if (causes[x].cause == cause) 00635 return causes[x].desc; 00636 } 00637 00638 return "Unknown"; 00639 }
void ast_change_name | ( | struct ast_channel * | chan, | |
char * | newname | |||
) |
Change channel name.
Definition at line 3949 of file channel.c.
References ast_string_field_set, chanlist::chan, EVENT_FLAG_CALL, manager_event, name, ast_channel::name, and ast_channel::uniqueid.
Referenced by update_name().
03950 { 03951 manager_event(EVENT_FLAG_CALL, "Rename", "Channel: %s\r\nNewname: %s\r\nUniqueid: %s\r\n", chan->name, newname, chan->uniqueid); 03952 ast_string_field_set(chan, name, newname); 03953 }
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.
NULL | failure | |
non-NULL | successfully allocated channel |
Definition at line 769 of file channel.c.
References accountcode, AST_ALERT_FD, ast_atomic_fetchadd_int(), ast_calloc, ast_cdr_alloc(), ast_cdr_init(), ast_cdr_start(), ast_channel_set_fd(), ast_config_AST_SYSTEM_NAME, ast_copy_string(), ast_default_accountcode, ast_default_amaflags, ast_free, AST_LIST_HEAD_INIT_NOLOCK, ast_log(), AST_MAX_FDS, ast_mutex_init(), AST_RWLIST_INSERT_HEAD, AST_RWLIST_UNLOCK, AST_RWLIST_WRLOCK, 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_timer_close(), ast_timer_fd(), ast_timer_open(), AST_TIMING_FD, defaultlanguage, errno, EVENT_FLAG_CALL, chanlist::flags, language, LOG_WARNING, manager_event, name, null_tech, S_OR, sched_context_create(), and sched_context_destroy().
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(), console_new(), dahdi_new(), gtalk_new(), iax_park(), jingle_new(), local_new(), make_email_file(), masq_park_call(), mgcp_new(), misdn_new(), nbs_new(), oss_new(), pbx_substitute_variables_helper_full(), phone_new(), rotate_file(), sendmail(), sendpage(), sip_new(), sip_park(), skinny_new(), unistim_new(), and usbradio_new().
00770 { 00771 struct ast_channel *tmp; 00772 int x; 00773 int flags; 00774 struct varshead *headp; 00775 va_list ap1, ap2; 00776 00777 /* If shutting down, don't allocate any new channels */ 00778 if (shutting_down) { 00779 ast_log(LOG_WARNING, "Channel allocation failed: Refusing due to active shutdown\n"); 00780 return NULL; 00781 } 00782 00783 if (!(tmp = ast_calloc(1, sizeof(*tmp)))) 00784 return NULL; 00785 00786 if (!(tmp->sched = sched_context_create())) { 00787 ast_log(LOG_WARNING, "Channel allocation failed: Unable to create schedule context\n"); 00788 ast_free(tmp); 00789 return NULL; 00790 } 00791 00792 if ((ast_string_field_init(tmp, 128))) { 00793 sched_context_destroy(tmp->sched); 00794 ast_free(tmp); 00795 return NULL; 00796 } 00797 00798 #ifdef HAVE_EPOLL 00799 tmp->epfd = epoll_create(25); 00800 #endif 00801 00802 for (x = 0; x < AST_MAX_FDS; x++) { 00803 tmp->fds[x] = -1; 00804 #ifdef HAVE_EPOLL 00805 tmp->epfd_data[x] = NULL; 00806 #endif 00807 } 00808 00809 if ((tmp->timer = ast_timer_open())) { 00810 needqueue = 0; 00811 tmp->timingfd = ast_timer_fd(tmp->timer); 00812 } else { 00813 tmp->timingfd = -1; 00814 } 00815 00816 if (needqueue) { 00817 if (pipe(tmp->alertpipe)) { 00818 ast_log(LOG_WARNING, "Channel allocation failed: Can't create alert pipe!\n"); 00819 alertpipe_failed: 00820 if (tmp->timer) { 00821 ast_timer_close(tmp->timer); 00822 } 00823 00824 sched_context_destroy(tmp->sched); 00825 ast_string_field_free_memory(tmp); 00826 ast_free(tmp); 00827 return NULL; 00828 } else { 00829 flags = fcntl(tmp->alertpipe[0], F_GETFL); 00830 if (fcntl(tmp->alertpipe[0], F_SETFL, flags | O_NONBLOCK) < 0) { 00831 ast_log(LOG_WARNING, "Channel allocation failed: Unable to set alertpipe nonblocking! (%d: %s)\n", errno, strerror(errno)); 00832 close(tmp->alertpipe[0]); 00833 close(tmp->alertpipe[1]); 00834 goto alertpipe_failed; 00835 } 00836 flags = fcntl(tmp->alertpipe[1], F_GETFL); 00837 if (fcntl(tmp->alertpipe[1], F_SETFL, flags | O_NONBLOCK) < 0) { 00838 ast_log(LOG_WARNING, "Channel allocation failed: Unable to set alertpipe nonblocking! (%d: %s)\n", errno, strerror(errno)); 00839 close(tmp->alertpipe[0]); 00840 close(tmp->alertpipe[1]); 00841 goto alertpipe_failed; 00842 } 00843 } 00844 } else /* Make sure we've got it done right if they don't */ 00845 tmp->alertpipe[0] = tmp->alertpipe[1] = -1; 00846 00847 /* Always watch the alertpipe */ 00848 ast_channel_set_fd(tmp, AST_ALERT_FD, tmp->alertpipe[0]); 00849 /* And timing pipe */ 00850 ast_channel_set_fd(tmp, AST_TIMING_FD, tmp->timingfd); 00851 ast_string_field_set(tmp, name, "**Unknown**"); 00852 00853 /* Initial state */ 00854 tmp->_state = state; 00855 00856 tmp->streamid = -1; 00857 00858 tmp->fin = global_fin; 00859 tmp->fout = global_fout; 00860 00861 if (ast_strlen_zero(ast_config_AST_SYSTEM_NAME)) { 00862 ast_string_field_build(tmp, uniqueid, "%li.%d", (long) time(NULL), 00863 ast_atomic_fetchadd_int(&uniqueint, 1)); 00864 } else { 00865 ast_string_field_build(tmp, uniqueid, "%s-%li.%d", ast_config_AST_SYSTEM_NAME, 00866 (long) time(NULL), ast_atomic_fetchadd_int(&uniqueint, 1)); 00867 } 00868 00869 tmp->cid.cid_name = ast_strdup(cid_name); 00870 tmp->cid.cid_num = ast_strdup(cid_num); 00871 00872 if (!ast_strlen_zero(name_fmt)) { 00873 /* Almost every channel is calling this function, and setting the name via the ast_string_field_build() call. 00874 * And they all use slightly different formats for their name string. 00875 * This means, to set the name here, we have to accept variable args, and call the string_field_build from here. 00876 * This means, that the stringfields must have a routine that takes the va_lists directly, and 00877 * uses them to build the string, instead of forming the va_lists internally from the vararg ... list. 00878 * This new function was written so this can be accomplished. 00879 */ 00880 va_start(ap1, name_fmt); 00881 va_start(ap2, name_fmt); 00882 ast_string_field_build_va(tmp, name, name_fmt, ap1, ap2); 00883 va_end(ap1); 00884 va_end(ap2); 00885 } 00886 00887 /* Reminder for the future: under what conditions do we NOT want to track cdrs on channels? */ 00888 00889 /* These 4 variables need to be set up for the cdr_init() to work right */ 00890 if (amaflag) 00891 tmp->amaflags = amaflag; 00892 else 00893 tmp->amaflags = ast_default_amaflags; 00894 00895 if (!ast_strlen_zero(acctcode)) 00896 ast_string_field_set(tmp, accountcode, acctcode); 00897 else 00898 ast_string_field_set(tmp, accountcode, ast_default_accountcode); 00899 00900 if (!ast_strlen_zero(context)) 00901 ast_copy_string(tmp->context, context, sizeof(tmp->context)); 00902 else 00903 strcpy(tmp->context, "default"); 00904 00905 if (!ast_strlen_zero(exten)) 00906 ast_copy_string(tmp->exten, exten, sizeof(tmp->exten)); 00907 else 00908 strcpy(tmp->exten, "s"); 00909 00910 tmp->priority = 1; 00911 00912 tmp->cdr = ast_cdr_alloc(); 00913 ast_cdr_init(tmp->cdr, tmp); 00914 ast_cdr_start(tmp->cdr); 00915 00916 headp = &tmp->varshead; 00917 AST_LIST_HEAD_INIT_NOLOCK(headp); 00918 00919 ast_mutex_init(&tmp->lock_dont_use); 00920 00921 AST_LIST_HEAD_INIT_NOLOCK(&tmp->datastores); 00922 00923 ast_string_field_set(tmp, language, defaultlanguage); 00924 00925 tmp->tech = &null_tech; 00926 00927 AST_RWLIST_WRLOCK(&channels); 00928 AST_RWLIST_INSERT_HEAD(&channels, tmp, chan_list); 00929 AST_RWLIST_UNLOCK(&channels); 00930 00931 /*\!note 00932 * and now, since the channel structure is built, and has its name, let's 00933 * call the manager event generator with this Newchannel event. This is the 00934 * proper and correct place to make this call, but you sure do have to pass 00935 * a lot of data into this func to do it here! 00936 */ 00937 if (!ast_strlen_zero(name_fmt)) { 00938 manager_event(EVENT_FLAG_CALL, "Newchannel", 00939 "Channel: %s\r\n" 00940 "ChannelState: %d\r\n" 00941 "ChannelStateDesc: %s\r\n" 00942 "CallerIDNum: %s\r\n" 00943 "CallerIDName: %s\r\n" 00944 "AccountCode: %s\r\n" 00945 "Uniqueid: %s\r\n", 00946 tmp->name, 00947 state, 00948 ast_state2str(state), 00949 S_OR(cid_num, ""), 00950 S_OR(cid_name, ""), 00951 tmp->accountcode, 00952 tmp->uniqueid); 00953 } 00954 00955 return tmp; 00956 }
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 4674 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_debug, AST_FEATURE_PLAY_WARNING, AST_FEATURE_WARNING_ACTIVE, AST_FLAG_END_DTMF_ONLY, AST_FLAG_NBRIDGE, AST_FLAG_ZOMBIE, ast_generic_bridge(), ast_indicate(), ast_log(), ast_samp2tv(), ast_set_flag, AST_SOFTHANGUP_UNBRIDGE, ast_test_flag, ast_tvadd(), ast_tvdiff_ms(), ast_tvnow(), ast_tvsub(), ast_tvzero(), ast_verb, ast_channel::audiohooks, ast_channel_tech::bridge, bridge_play_sounds(), bridge_playfile(), ast_channel::cid, ast_callerid::cid_num, config, EVENT_FLAG_CALL, ast_channel::generator, LOG_WARNING, manager_bridge_event(), manager_event, ast_channel::masq, ast_channel::masqr, ast_channel::monitor, ast_channel::name, ast_channel::nativeformats, ast_channel::readformat, ast_channel_tech::send_digit_begin, ast_channel::tech, ast_channel::uniqueid, update_bridge_vars(), and ast_channel::writeformat.
Referenced by ast_bridge_call().
04676 { 04677 struct ast_channel *who = NULL; 04678 enum ast_bridge_result res = AST_BRIDGE_COMPLETE; 04679 int nativefailed=0; 04680 int firstpass; 04681 int o0nativeformats; 04682 int o1nativeformats; 04683 long time_left_ms=0; 04684 char caller_warning = 0; 04685 char callee_warning = 0; 04686 04687 if (c0->_bridge) { 04688 ast_log(LOG_WARNING, "%s is already in a bridge with %s\n", 04689 c0->name, c0->_bridge->name); 04690 return -1; 04691 } 04692 if (c1->_bridge) { 04693 ast_log(LOG_WARNING, "%s is already in a bridge with %s\n", 04694 c1->name, c1->_bridge->name); 04695 return -1; 04696 } 04697 04698 /* Stop if we're a zombie or need a soft hangup */ 04699 if (ast_test_flag(c0, AST_FLAG_ZOMBIE) || ast_check_hangup_locked(c0) || 04700 ast_test_flag(c1, AST_FLAG_ZOMBIE) || ast_check_hangup_locked(c1)) 04701 return -1; 04702 04703 *fo = NULL; 04704 firstpass = config->firstpass; 04705 config->firstpass = 0; 04706 04707 if (ast_tvzero(config->start_time)) 04708 config->start_time = ast_tvnow(); 04709 time_left_ms = config->timelimit; 04710 04711 caller_warning = ast_test_flag(&config->features_caller, AST_FEATURE_PLAY_WARNING); 04712 callee_warning = ast_test_flag(&config->features_callee, AST_FEATURE_PLAY_WARNING); 04713 04714 if (config->start_sound && firstpass) { 04715 if (caller_warning) 04716 bridge_playfile(c0, c1, config->start_sound, time_left_ms / 1000); 04717 if (callee_warning) 04718 bridge_playfile(c1, c0, config->start_sound, time_left_ms / 1000); 04719 } 04720 04721 /* Keep track of bridge */ 04722 c0->_bridge = c1; 04723 c1->_bridge = c0; 04724 04725 04726 o0nativeformats = c0->nativeformats; 04727 o1nativeformats = c1->nativeformats; 04728 04729 if (config->feature_timer && !ast_tvzero(config->nexteventts)) { 04730 config->nexteventts = ast_tvadd(config->start_time, ast_samp2tv(config->feature_timer, 1000)); 04731 } else if (config->timelimit && firstpass) { 04732 config->nexteventts = ast_tvadd(config->start_time, ast_samp2tv(config->timelimit, 1000)); 04733 if (caller_warning || callee_warning) 04734 config->nexteventts = ast_tvsub(config->nexteventts, ast_samp2tv(config->play_warning, 1000)); 04735 } 04736 04737 if (!c0->tech->send_digit_begin) 04738 ast_set_flag(c1, AST_FLAG_END_DTMF_ONLY); 04739 if (!c1->tech->send_digit_begin) 04740 ast_set_flag(c0, AST_FLAG_END_DTMF_ONLY); 04741 manager_bridge_event(1, 1, c0, c1); 04742 04743 /* Before we enter in and bridge these two together tell them both the source of audio has changed */ 04744 ast_indicate(c0, AST_CONTROL_SRCUPDATE); 04745 ast_indicate(c1, AST_CONTROL_SRCUPDATE); 04746 04747 for (/* ever */;;) { 04748 struct timeval now = { 0, }; 04749 int to; 04750 04751 to = -1; 04752 04753 if (!ast_tvzero(config->nexteventts)) { 04754 now = ast_tvnow(); 04755 to = ast_tvdiff_ms(config->nexteventts, now); 04756 if (to <= 0) { 04757 if (!config->timelimit) { 04758 res = AST_BRIDGE_COMPLETE; 04759 break; 04760 } 04761 to = 0; 04762 } 04763 } 04764 04765 if (config->timelimit) { 04766 time_left_ms = config->timelimit - ast_tvdiff_ms(now, config->start_time); 04767 if (time_left_ms < to) 04768 to = time_left_ms; 04769 04770 if (time_left_ms <= 0) { 04771 if (caller_warning && config->end_sound) 04772 bridge_playfile(c0, c1, config->end_sound, 0); 04773 if (callee_warning && config->end_sound) 04774 bridge_playfile(c1, c0, config->end_sound, 0); 04775 *fo = NULL; 04776 if (who) 04777 *rc = who; 04778 res = 0; 04779 break; 04780 } 04781 04782 if (!to) { 04783 if (time_left_ms >= 5000 && config->warning_sound && config->play_warning && ast_test_flag(config, AST_FEATURE_WARNING_ACTIVE)) { 04784 int t = (time_left_ms + 500) / 1000; /* round to nearest second */ 04785 if (caller_warning) 04786 bridge_playfile(c0, c1, config->warning_sound, t); 04787 if (callee_warning) 04788 bridge_playfile(c1, c0, config->warning_sound, t); 04789 } 04790 if (config->warning_freq && (time_left_ms > (config->warning_freq + 5000))) 04791 config->nexteventts = ast_tvadd(config->nexteventts, ast_samp2tv(config->warning_freq, 1000)); 04792 else 04793 config->nexteventts = ast_tvadd(config->start_time, ast_samp2tv(config->timelimit, 1000)); 04794 } 04795 ast_clear_flag(config, AST_FEATURE_WARNING_ACTIVE); 04796 } 04797 04798 if (c0->_softhangup == AST_SOFTHANGUP_UNBRIDGE || c1->_softhangup == AST_SOFTHANGUP_UNBRIDGE) { 04799 if (c0->_softhangup == AST_SOFTHANGUP_UNBRIDGE) 04800 c0->_softhangup = 0; 04801 if (c1->_softhangup == AST_SOFTHANGUP_UNBRIDGE) 04802 c1->_softhangup = 0; 04803 c0->_bridge = c1; 04804 c1->_bridge = c0; 04805 ast_debug(1, "Unbridge signal received. Ending native bridge.\n"); 04806 continue; 04807 } 04808 04809 /* Stop if we're a zombie or need a soft hangup */ 04810 if (ast_test_flag(c0, AST_FLAG_ZOMBIE) || ast_check_hangup_locked(c0) || 04811 ast_test_flag(c1, AST_FLAG_ZOMBIE) || ast_check_hangup_locked(c1)) { 04812 *fo = NULL; 04813 if (who) 04814 *rc = who; 04815 res = 0; 04816 ast_debug(1, "Bridge stops because we're zombie or need a soft hangup: c0=%s, c1=%s, flags: %s,%s,%s,%s\n", 04817 c0->name, c1->name, 04818 ast_test_flag(c0, AST_FLAG_ZOMBIE) ? "Yes" : "No", 04819 ast_check_hangup(c0) ? "Yes" : "No", 04820 ast_test_flag(c1, AST_FLAG_ZOMBIE) ? "Yes" : "No", 04821 ast_check_hangup(c1) ? "Yes" : "No"); 04822 break; 04823 } 04824 04825 update_bridge_vars(c0, c1); 04826 04827 bridge_play_sounds(c0, c1); 04828 04829 if (c0->tech->bridge && 04830 (c0->tech->bridge == c1->tech->bridge) && 04831 !nativefailed && !c0->monitor && !c1->monitor && 04832 !c0->audiohooks && !c1->audiohooks && 04833 !c0->masq && !c0->masqr && !c1->masq && !c1->masqr) { 04834 /* Looks like they share a bridge method and nothing else is in the way */ 04835 ast_set_flag(c0, AST_FLAG_NBRIDGE); 04836 ast_set_flag(c1, AST_FLAG_NBRIDGE); 04837 if ((res = c0->tech->bridge(c0, c1, config->flags, fo, rc, to)) == AST_BRIDGE_COMPLETE) { 04838 /* \todo XXX here should check that cid_num is not NULL */ 04839 manager_event(EVENT_FLAG_CALL, "Unlink", 04840 "Channel1: %s\r\n" 04841 "Channel2: %s\r\n" 04842 "Uniqueid1: %s\r\n" 04843 "Uniqueid2: %s\r\n" 04844 "CallerID1: %s\r\n" 04845 "CallerID2: %s\r\n", 04846 c0->name, c1->name, c0->uniqueid, c1->uniqueid, c0->cid.cid_num, c1->cid.cid_num); 04847 ast_debug(1, "Returning from native bridge, channels: %s, %s\n", c0->name, c1->name); 04848 04849 ast_clear_flag(c0, AST_FLAG_NBRIDGE); 04850 ast_clear_flag(c1, AST_FLAG_NBRIDGE); 04851 04852 if (c0->_softhangup == AST_SOFTHANGUP_UNBRIDGE || c1->_softhangup == AST_SOFTHANGUP_UNBRIDGE) 04853 continue; 04854 04855 c0->_bridge = NULL; 04856 c1->_bridge = NULL; 04857 04858 return res; 04859 } else { 04860 ast_clear_flag(c0, AST_FLAG_NBRIDGE); 04861 ast_clear_flag(c1, AST_FLAG_NBRIDGE); 04862 } 04863 switch (res) { 04864 case AST_BRIDGE_RETRY: 04865 if (config->play_warning) { 04866 ast_set_flag(config, AST_FEATURE_WARNING_ACTIVE); 04867 } 04868 continue; 04869 default: 04870 ast_verb(3, "Native bridging %s and %s ended\n", c0->name, c1->name); 04871 /* fallthrough */ 04872 case AST_BRIDGE_FAILED_NOWARN: 04873 nativefailed++; 04874 break; 04875 } 04876 } 04877 04878 if (((c0->writeformat != c1->readformat) || (c0->readformat != c1->writeformat) || 04879 (c0->nativeformats != o0nativeformats) || (c1->nativeformats != o1nativeformats)) && 04880 !(c0->generator || c1->generator)) { 04881 if (ast_channel_make_compatible(c0, c1)) { 04882 ast_log(LOG_WARNING, "Can't make %s and %s compatible\n", c0->name, c1->name); 04883 manager_bridge_event(0, 1, c0, c1); 04884 return AST_BRIDGE_FAILED; 04885 } 04886 o0nativeformats = c0->nativeformats; 04887 o1nativeformats = c1->nativeformats; 04888 } 04889 04890 update_bridge_vars(c0, c1); 04891 04892 res = ast_generic_bridge(c0, c1, config, fo, rc, config->nexteventts); 04893 if (res != AST_BRIDGE_RETRY) { 04894 break; 04895 } else if (config->feature_timer) { 04896 /* feature timer expired but has not been updated, sending to ast_bridge_call to do so */ 04897 break; 04898 } 04899 } 04900 04901 ast_clear_flag(c0, AST_FLAG_END_DTMF_ONLY); 04902 ast_clear_flag(c1, AST_FLAG_END_DTMF_ONLY); 04903 04904 /* Now that we have broken the bridge the source will change yet again */ 04905 ast_indicate(c0, AST_CONTROL_SRCUPDATE); 04906 ast_indicate(c1, AST_CONTROL_SRCUPDATE); 04907 04908 c0->_bridge = NULL; 04909 c1->_bridge = NULL; 04910 04911 /* \todo XXX here should check that cid_num is not NULL */ 04912 manager_event(EVENT_FLAG_CALL, "Unlink", 04913 "Channel1: %s\r\n" 04914 "Channel2: %s\r\n" 04915 "Uniqueid1: %s\r\n" 04916 "Uniqueid2: %s\r\n" 04917 "CallerID1: %s\r\n" 04918 "CallerID2: %s\r\n", 04919 c0->name, c1->name, c0->uniqueid, c1->uniqueid, c0->cid.cid_num, c1->cid.cid_num); 04920 ast_debug(1, "Bridge stops bridging channels %s and %s\n", c0->name, c1->name); 04921 04922 return res; 04923 }
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 550 of file channel.c.
References ast_channel_cmpwhentohangup_tv(), and chanlist::chan.
00551 { 00552 struct timeval when = { offset, }; 00553 return ast_channel_cmpwhentohangup_tv(chan, when); 00554 }
int ast_channel_cmpwhentohangup_tv | ( | struct ast_channel * | chan, | |
struct timeval | offset | |||
) |
Compare a offset with the settings of when to hang a channel up.
chan | channel on which to check for hangup | |
offset | offset in seconds and microseconds from current time |
Definition at line 535 of file channel.c.
References ast_tvadd(), ast_tvdiff_ms(), ast_tvnow(), ast_tvzero(), chanlist::chan, and ast_channel::whentohangup.
Referenced by ast_channel_cmpwhentohangup().
00536 { 00537 struct timeval whentohangup; 00538 00539 if (ast_tvzero(chan->whentohangup)) 00540 return ast_tvzero(offset) ? 0 : -1; 00541 00542 if (ast_tvzero(offset)) 00543 return 1; 00544 00545 whentohangup = ast_tvadd(offset, ast_tvnow()); 00546 00547 return ast_tvdiff_ms(whentohangup, chan->whentohangup); 00548 }
int ast_channel_datastore_add | ( | struct ast_channel * | chan, | |
struct ast_datastore * | datastore | |||
) |
Add a datastore to a channel.
0 | success | |
non-zero | failure |
Definition at line 1428 of file channel.c.
References AST_LIST_INSERT_HEAD, chanlist::chan, ast_channel::datastores, and ast_datastore::entry.
Referenced by _macro_exec(), acf_iaxvar_write(), add_features_datastores(), add_to_agi(), ast_iax2_new(), audiohook_volume_get(), authenticate_reply(), dial_exec_full(), dundi_query_read(), enable_jack_hook(), enum_query_read(), get_lock(), gosub_exec(), lua_get_state(), pbx_builtin_raise_exception(), setup_chanspy_ds(), setup_inheritance_datastore(), setup_mixmonitor_ds(), setup_transfer_datastore(), shared_write(), smdi_msg_retrieve_read(), socket_process(), speech_create(), speex_write(), try_calling(), and volume_write().
01429 { 01430 int res = 0; 01431 01432 AST_LIST_INSERT_HEAD(&chan->datastores, datastore, entry); 01433 01434 return res; 01435 }
struct ast_datastore* ast_channel_datastore_alloc | ( | const struct ast_datastore_info * | info, | |
const char * | uid | |||
) |
Create a channel data store object.
Definition at line 1401 of file channel.c.
References ast_datastore_alloc(), and ast_datastore::info.
01402 { 01403 return ast_datastore_alloc(info, uid); 01404 }
struct ast_datastore* ast_channel_datastore_find | ( | struct ast_channel * | chan, | |
const struct ast_datastore_info * | info, | |||
const char * | uid | |||
) |
Find a datastore on a channel.
The datastore returned from this function must not be used if the reference to the channel is released.
pointer | to the datastore if found | |
NULL | if not found |
Definition at line 1442 of file channel.c.
References AST_LIST_TRAVERSE_SAFE_BEGIN, AST_LIST_TRAVERSE_SAFE_END, chanlist::chan, ast_channel::datastores, ast_datastore::entry, ast_datastore::info, and ast_datastore::uid.
Referenced by _macro_exec(), acf_exception_read(), acf_fetch(), acf_iaxvar_read(), acf_iaxvar_write(), add_agi_cmd(), add_features_datastores(), add_to_agi(), attended_transfer_occurred(), audiohook_volume_callback(), audiohook_volume_get(), builtin_atxfer(), chanspy_ds_free(), dial_exec_full(), disable_jack_hook(), dundi_result_read(), enable_jack_hook(), enum_result_read(), exec_odbcfinish(), find_speech(), func_inheritance_write(), get_agi_cmd(), get_lock(), gosub_exec(), iax2_call(), jack_hook_callback(), local_read(), local_write(), lua_get_state(), manage_parkinglot(), park_exec_full(), pbx_builtin_raise_exception(), pop_exec(), queue_transfer_fixup(), return_exec(), shared_read(), shared_write(), smdi_msg_read(), speech_background(), speech_destroy(), speex_callback(), speex_read(), speex_write(), try_calling(), unlock_read(), volume_callback(), and volume_write().
01443 { 01444 struct ast_datastore *datastore = NULL; 01445 01446 if (info == NULL) 01447 return NULL; 01448 01449 AST_LIST_TRAVERSE_SAFE_BEGIN(&chan->datastores, datastore, entry) { 01450 if (datastore->info != info) { 01451 continue; 01452 } 01453 01454 if (uid == NULL) { 01455 /* matched by type only */ 01456 break; 01457 } 01458 01459 if ((datastore->uid != NULL) && !strcasecmp(uid, datastore->uid)) { 01460 /* Matched by type AND uid */ 01461 break; 01462 } 01463 } 01464 AST_LIST_TRAVERSE_SAFE_END; 01465 01466 return datastore; 01467 }
int ast_channel_datastore_free | ( | struct ast_datastore * | datastore | ) |
Free a channel data store object.
Definition at line 1406 of file channel.c.
References ast_datastore_free().
01407 { 01408 return ast_datastore_free(datastore); 01409 }
int ast_channel_datastore_inherit | ( | struct ast_channel * | from, | |
struct ast_channel * | to | |||
) |
Inherit datastores from a parent to a child.
Definition at line 1411 of file channel.c.
References ast_datastore_alloc(), AST_LIST_INSERT_TAIL, AST_LIST_TRAVERSE, ast_datastore::data, DATASTORE_INHERIT_FOREVER, ast_channel::datastores, ast_datastore_info::duplicate, ast_datastore::entry, ast_datastore::info, ast_datastore::inheritance, and ast_datastore::uid.
Referenced by __ast_request_and_dial(), dial_exec_full(), do_forward(), and local_call().
01412 { 01413 struct ast_datastore *datastore = NULL, *datastore2; 01414 01415 AST_LIST_TRAVERSE(&from->datastores, datastore, entry) { 01416 if (datastore->inheritance > 0) { 01417 datastore2 = ast_datastore_alloc(datastore->info, datastore->uid); 01418 if (datastore2) { 01419 datastore2->data = datastore->info->duplicate ? datastore->info->duplicate(datastore->data) : NULL; 01420 datastore2->inheritance = datastore->inheritance == DATASTORE_INHERIT_FOREVER ? DATASTORE_INHERIT_FOREVER : datastore->inheritance - 1; 01421 AST_LIST_INSERT_TAIL(&to->datastores, datastore2, entry); 01422 } 01423 } 01424 } 01425 return 0; 01426 }
int ast_channel_datastore_remove | ( | struct ast_channel * | chan, | |
struct ast_datastore * | datastore | |||
) |
Remove a datastore from a channel.
0 | success | |
non-zero | failure |
Definition at line 1437 of file channel.c.
References AST_LIST_REMOVE, chanlist::chan, ast_channel::datastores, and ast_datastore::entry.
Referenced by acf_fetch(), chanspy_ds_free(), dial_exec_full(), disable_jack_hook(), exec_odbcfinish(), lua_get_state(), queue_transfer_fixup(), speech_background(), speech_destroy(), speex_write(), and try_calling().
01438 { 01439 return AST_LIST_REMOVE(&chan->datastores, datastore, entry) ? 0 : -1; 01440 }
int ast_channel_defer_dtmf | ( | struct ast_channel * | chan | ) |
Set defer DTMF flag on channel.
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 1086 of file channel.c.
References AST_FLAG_DEFER_DTMF, ast_set_flag, ast_test_flag, and chanlist::chan.
Referenced by find_cache().
01087 { 01088 int pre = 0; 01089 01090 if (chan) { 01091 pre = ast_test_flag(chan, AST_FLAG_DEFER_DTMF); 01092 ast_set_flag(chan, AST_FLAG_DEFER_DTMF); 01093 } 01094 return pre; 01095 }
int ast_channel_early_bridge | ( | struct ast_channel * | c0, | |
struct ast_channel * | c1 | |||
) |
Bridge two channels together (early).
Bridge two channels together (early)
c0 | first channel to bridge | |
c1 | second channel to bridge Bridge two channels (c0 and c1) together early. This implies either side may not be answered yet. |
Definition at line 4576 of file channel.c.
References ast_channel_tech::early_bridge, and ast_channel::tech.
Referenced by dial_exec_full(), and wait_for_answer().
04577 { 04578 /* Make sure we can early bridge, if not error out */ 04579 if (!c0->tech->early_bridge || (c1 && (!c1->tech->early_bridge || c0->tech->early_bridge != c1->tech->early_bridge))) 04580 return -1; 04581 04582 return c0->tech->early_bridge(c0, c1); 04583 }
void ast_channel_free | ( | struct ast_channel * | ) |
Free a channel structure.
Definition at line 1292 of file channel.c.
References ast_channel::alertpipe, ast_app_group_discard(), ast_cdr_discard(), ast_channel_lock, AST_CHANNEL_NAME, ast_channel_unlock, ast_copy_string(), ast_datastore_free(), AST_DEVICE_UNKNOWN, ast_devstate_changed_literal(), ast_free, ast_frfree, ast_jb_destroy(), AST_LIST_REMOVE_HEAD, ast_log(), AST_MAX_FDS, ast_moh_cleanup(), ast_mutex_destroy(), AST_RWLIST_REMOVE, AST_RWLIST_UNLOCK, AST_RWLIST_WRLOCK, ast_string_field_free_memory, ast_timer_close(), ast_translator_free_path(), ast_var_delete(), ast_channel::cdr, chanlist::chan, ast_channel::cid, ast_channel::datastores, ast_datastore::entry, f, free, free_cid(), ast_channel::lock_dont_use, 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::timer, ast_channel::varshead, and ast_channel::writetrans.
Referenced by acf_odbc_write(), 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(), rotate_file(), sendmail(), and sendpage().
01293 { 01294 int fd; 01295 #ifdef HAVE_EPOLL 01296 int i; 01297 #endif 01298 struct ast_var_t *vardata; 01299 struct ast_frame *f; 01300 struct varshead *headp; 01301 struct ast_datastore *datastore = NULL; 01302 char name[AST_CHANNEL_NAME], *dashptr; 01303 01304 headp=&chan->varshead; 01305 01306 AST_RWLIST_WRLOCK(&channels); 01307 if (!AST_RWLIST_REMOVE(&channels, chan, chan_list)) { 01308 AST_RWLIST_UNLOCK(&channels); 01309 ast_log(LOG_ERROR, "Unable to find channel in list to free. Assuming it has already been done.\n"); 01310 } 01311 /* Lock and unlock the channel just to be sure nobody has it locked still 01312 due to a reference retrieved from the channel list. */ 01313 ast_channel_lock(chan); 01314 ast_channel_unlock(chan); 01315 01316 /* Get rid of each of the data stores on the channel */ 01317 while ((datastore = AST_LIST_REMOVE_HEAD(&chan->datastores, entry))) 01318 /* Free the data store */ 01319 ast_datastore_free(datastore); 01320 01321 /* Lock and unlock the channel just to be sure nobody has it locked still 01322 due to a reference that was stored in a datastore. (i.e. app_chanspy) */ 01323 ast_channel_lock(chan); 01324 ast_channel_unlock(chan); 01325 01326 if (chan->tech_pvt) { 01327 ast_log(LOG_WARNING, "Channel '%s' may not have been hung up properly\n", chan->name); 01328 ast_free(chan->tech_pvt); 01329 } 01330 01331 if (chan->sched) 01332 sched_context_destroy(chan->sched); 01333 01334 ast_copy_string(name, chan->name, sizeof(name)); 01335 if ((dashptr = strrchr(name, '-'))) { 01336 *dashptr = '\0'; 01337 } 01338 01339 /* Stop monitoring */ 01340 if (chan->monitor) 01341 chan->monitor->stop( chan, 0 ); 01342 01343 /* If there is native format music-on-hold state, free it */ 01344 if (chan->music_state) 01345 ast_moh_cleanup(chan); 01346 01347 /* Free translators */ 01348 if (chan->readtrans) 01349 ast_translator_free_path(chan->readtrans); 01350 if (chan->writetrans) 01351 ast_translator_free_path(chan->writetrans); 01352 if (chan->pbx) 01353 ast_log(LOG_WARNING, "PBX may not have been terminated properly on '%s'\n", chan->name); 01354 free_cid(&chan->cid); 01355 /* Close pipes if appropriate */ 01356 if ((fd = chan->alertpipe[0]) > -1) 01357 close(fd); 01358 if ((fd = chan->alertpipe[1]) > -1) 01359 close(fd); 01360 if (chan->timer) { 01361 ast_timer_close(chan->timer); 01362 } 01363 #ifdef HAVE_EPOLL 01364 for (i = 0; i < AST_MAX_FDS; i++) { 01365 if (chan->epfd_data[i]) 01366 free(chan->epfd_data[i]); 01367 } 01368 close(chan->epfd); 01369 #endif 01370 while ((f = AST_LIST_REMOVE_HEAD(&chan->readq, frame_list))) 01371 ast_frfree(f); 01372 01373 /* loop over the variables list, freeing all data and deleting list items */ 01374 /* no need to lock the list, as the channel is already locked */ 01375 01376 while ((vardata = AST_LIST_REMOVE_HEAD(headp, entries))) 01377 ast_var_delete(vardata); 01378 01379 ast_app_group_discard(chan); 01380 01381 /* Destroy the jitterbuffer */ 01382 ast_jb_destroy(chan); 01383 01384 if (chan->cdr) { 01385 ast_cdr_discard(chan->cdr); 01386 chan->cdr = NULL; 01387 } 01388 01389 ast_mutex_destroy(&chan->lock_dont_use); 01390 01391 ast_string_field_free_memory(chan); 01392 ast_free(chan); 01393 AST_RWLIST_UNLOCK(&channels); 01394 01395 /* Queue an unknown state, because, while we know that this particular 01396 * instance is dead, we don't know the state of all other possible 01397 * instances. */ 01398 ast_devstate_changed_literal(AST_DEVICE_UNKNOWN, name); 01399 }
static enum ast_t38_state ast_channel_get_t38_state | ( | struct ast_channel * | chan | ) | [inline, static] |
Retrieves the current T38 state of a channel.
Definition at line 1705 of file channel.h.
References ast_channel_queryoption(), AST_OPTION_T38_STATE, chan, and T38_STATE_UNAVAILABLE.
Referenced by transmit().
01706 { 01707 enum ast_t38_state state = T38_STATE_UNAVAILABLE; 01708 int datalen = sizeof(state); 01709 01710 ast_channel_queryoption(chan, AST_OPTION_T38_STATE, &state, &datalen, 0); 01711 01712 return state; 01713 }
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 3955 of file channel.c.
References ast_debug, AST_LIST_INSERT_TAIL, AST_LIST_TRAVERSE, ast_var_assign(), ast_var_full_name(), ast_var_name(), ast_var_value(), ast_var_t::entries, and ast_channel::varshead.
Referenced by __ast_request_and_dial(), agent_call(), ast_feature_request_and_dial(), begin_dial_channel(), dial_exec_full(), do_forward(), findmeexec(), and ring_entry().
03956 { 03957 struct ast_var_t *current, *newvar; 03958 const char *varname; 03959 03960 AST_LIST_TRAVERSE(&parent->varshead, current, entries) { 03961 int vartype = 0; 03962 03963 varname = ast_var_full_name(current); 03964 if (!varname) 03965 continue; 03966 03967 if (varname[0] == '_') { 03968 vartype = 1; 03969 if (varname[1] == '_') 03970 vartype = 2; 03971 } 03972 03973 switch (vartype) { 03974 case 1: 03975 newvar = ast_var_assign(&varname[1], ast_var_value(current)); 03976 if (newvar) { 03977 AST_LIST_INSERT_TAIL(&child->varshead, newvar, entries); 03978 ast_debug(1, "Copying soft-transferable variable %s.\n", ast_var_name(newvar)); 03979 } 03980 break; 03981 case 2: 03982 newvar = ast_var_assign(varname, ast_var_value(current)); 03983 if (newvar) { 03984 AST_LIST_INSERT_TAIL(&child->varshead, newvar, entries); 03985 ast_debug(1, "Copying hard-transferable variable %s.\n", ast_var_name(newvar)); 03986 } 03987 break; 03988 default: 03989 ast_debug(1, "Not copying variable %s.\n", ast_var_name(current)); 03990 break; 03991 } 03992 } 03993 }
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 3853 of file channel.c.
References ast_channel_make_compatible_helper(), and chanlist::chan.
Referenced by action_bridge(), app_exec(), ast_channel_bridge(), bridge_exec(), check_compat(), dial_exec_full(), do_forward(), park_exec_full(), try_calling(), and wait_for_answer().
03854 { 03855 /* Some callers do not check return code, and we must try to set all call legs correctly */ 03856 int rc = 0; 03857 03858 /* Set up translation from the chan to the peer */ 03859 rc = ast_channel_make_compatible_helper(chan, peer); 03860 03861 if (rc < 0) 03862 return rc; 03863 03864 /* Set up translation from the peer to the chan */ 03865 rc = ast_channel_make_compatible_helper(peer, chan); 03866 03867 return rc; 03868 }
int ast_channel_masquerade | ( | struct ast_channel * | original, | |
struct ast_channel * | clone | |||
) |
Weird function made for call transfers.
original | channel to make a copy of | |
clone | copy of the original channel |
Definition at line 3870 of file channel.c.
References ast_channel::_bridge, ast_bridged_channel(), ast_channel_lock, ast_channel_trylock, ast_channel_unlock, ast_debug, ast_log(), ast_null_frame, ast_queue_frame(), ast_channel_tech::get_base_channel, LOG_WARNING, ast_channel::masq, ast_channel::masqr, ast_channel::name, and ast_channel::tech.
Referenced by 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_do(), sip_park(), and skinny_transfer().
03871 { 03872 int res = -1; 03873 struct ast_channel *final_orig, *final_clone, *base; 03874 03875 retrymasq: 03876 final_orig = original; 03877 final_clone = clonechan; 03878 03879 ast_channel_lock(original); 03880 while (ast_channel_trylock(clonechan)) { 03881 ast_channel_unlock(original); 03882 usleep(1); 03883 ast_channel_lock(original); 03884 } 03885 03886 /* each of these channels may be sitting behind a channel proxy (i.e. chan_agent) 03887 and if so, we don't really want to masquerade it, but its proxy */ 03888 if (original->_bridge && (original->_bridge != ast_bridged_channel(original)) && (original->_bridge->_bridge != original)) 03889 final_orig = original->_bridge; 03890 03891 if (clonechan->_bridge && (clonechan->_bridge != ast_bridged_channel(clonechan)) && (clonechan->_bridge->_bridge != clonechan)) 03892 final_clone = clonechan->_bridge; 03893 03894 if (final_clone->tech->get_base_channel && (base = final_clone->tech->get_base_channel(final_clone))) { 03895 final_clone = base; 03896 } 03897 03898 if ((final_orig != original) || (final_clone != clonechan)) { 03899 /* Lots and lots of deadlock avoidance. The main one we're competing with 03900 * is ast_write(), which locks channels recursively, when working with a 03901 * proxy channel. */ 03902 if (ast_channel_trylock(final_orig)) { 03903 ast_channel_unlock(clonechan); 03904 ast_channel_unlock(original); 03905 goto retrymasq; 03906 } 03907 if (ast_channel_trylock(final_clone)) { 03908 ast_channel_unlock(final_orig); 03909 ast_channel_unlock(clonechan); 03910 ast_channel_unlock(original); 03911 goto retrymasq; 03912 } 03913 ast_channel_unlock(clonechan); 03914 ast_channel_unlock(original); 03915 original = final_orig; 03916 clonechan = final_clone; 03917 } 03918 03919 if (original == clonechan) { 03920 ast_log(LOG_WARNING, "Can't masquerade channel '%s' into itself!\n", original->name); 03921 ast_channel_unlock(clonechan); 03922 ast_channel_unlock(original); 03923 return -1; 03924 } 03925 03926 ast_debug(1, "Planning to masquerade channel %s into the structure of %s\n", 03927 clonechan->name, original->name); 03928 if (original->masq) { 03929 ast_log(LOG_WARNING, "%s is already going to masquerade as %s\n", 03930 original->masq->name, original->name); 03931 } else if (clonechan->masqr) { 03932 ast_log(LOG_WARNING, "%s is already going to masquerade as %s\n", 03933 clonechan->name, clonechan->masqr->name); 03934 } else { 03935 original->masq = clonechan; 03936 clonechan->masqr = original; 03937 ast_queue_frame(original, &ast_null_frame); 03938 ast_queue_frame(clonechan, &ast_null_frame); 03939 ast_debug(1, "Done planning to masquerade channel %s into the structure of %s\n", clonechan->name, original->name); 03940 res = 0; 03941 } 03942 03943 ast_channel_unlock(clonechan); 03944 ast_channel_unlock(original); 03945 03946 return res; 03947 }
int ast_channel_queryoption | ( | struct ast_channel * | channel, | |
int | option, | |||
void * | data, | |||
int * | datalen, | |||
int | block | |||
) |
Query the value of an option Works similarly to setoption except only reads the options.
Definition at line 4939 of file channel.c.
References ast_log(), chan, errno, LOG_ERROR, ast_channel_tech::queryoption, and ast_channel::tech.
Referenced by ast_channel_get_t38_state().
04940 { 04941 if (!chan->tech->queryoption) { 04942 errno = ENOSYS; 04943 return -1; 04944 } 04945 04946 if (block) 04947 ast_log(LOG_ERROR, "XXX Blocking not implemented yet XXX\n"); 04948 04949 return chan->tech->queryoption(chan, option, data, datalen); 04950 }
const char* ast_channel_reason2str | ( | int | reason | ) |
return an english explanation of the code returned thru __ast_request_and_dial's 'outstate' argument
reason | The integer argument, usually taken from AST_CONTROL_ macros |
Definition at line 3491 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().
03492 { 03493 switch (reason) /* the following appear to be the only ones actually returned by request_and_dial */ 03494 { 03495 case 0: 03496 return "Call Failure (not BUSY, and not NO_ANSWER, maybe Circuit busy or down?)"; 03497 case AST_CONTROL_HANGUP: 03498 return "Hangup"; 03499 case AST_CONTROL_RING: 03500 return "Local Ring"; 03501 case AST_CONTROL_RINGING: 03502 return "Remote end Ringing"; 03503 case AST_CONTROL_ANSWER: 03504 return "Remote end has Answered"; 03505 case AST_CONTROL_BUSY: 03506 return "Remote end is Busy"; 03507 case AST_CONTROL_CONGESTION: 03508 return "Congestion (circuits busy)"; 03509 default: 03510 return "Unknown Reason!!"; 03511 } 03512 }
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 557 of file channel.c.
References ast_calloc, ast_debug, AST_LIST_INSERT_HEAD, AST_LIST_TRAVERSE, ast_log(), AST_RWLIST_UNLOCK, AST_RWLIST_WRLOCK, ast_verb, chanlist::chan, chanlist::list, LOG_WARNING, ast_channel::tech, chanlist::tech, and ast_channel_tech::type.
Referenced by load_module(), and unload_module().
00558 { 00559 struct chanlist *chan; 00560 00561 AST_RWLIST_WRLOCK(&channels); 00562 00563 AST_LIST_TRAVERSE(&backends, chan, list) { 00564 if (!strcasecmp(tech->type, chan->tech->type)) { 00565 ast_log(LOG_WARNING, "Already have a handler for type '%s'\n", tech->type); 00566 AST_RWLIST_UNLOCK(&channels); 00567 return -1; 00568 } 00569 } 00570 00571 if (!(chan = ast_calloc(1, sizeof(*chan)))) { 00572 AST_RWLIST_UNLOCK(&channels); 00573 return -1; 00574 } 00575 chan->tech = tech; 00576 AST_LIST_INSERT_HEAD(&backends, chan, list); 00577 00578 ast_debug(1, "Registered handler for '%s' (%s)\n", chan->tech->type, chan->tech->description); 00579 00580 ast_verb(2, "Registered channel type '%s' (%s)\n", chan->tech->type, chan->tech->description); 00581 00582 AST_RWLIST_UNLOCK(&channels); 00583 return 0; 00584 }
int ast_channel_sendhtml | ( | struct ast_channel * | channel, | |
int | subclass, | |||
const char * | data, | |||
int | datalen | |||
) |
Send HTML or URL on link. Returns 0 on success or -1 on failure
Definition at line 3799 of file channel.c.
References chanlist::chan, ast_channel_tech::send_html, and ast_channel::tech.
Referenced by agent_sendhtml(), ast_channel_sendurl(), and wait_for_answer().
03800 { 03801 if (chan->tech->send_html) 03802 return chan->tech->send_html(chan, subclass, data, datalen); 03803 return -1; 03804 }
int ast_channel_sendurl | ( | struct ast_channel * | channel, | |
const char * | url | |||
) |
Send URL on link. Returns 0 on success or -1 on failure
Definition at line 3806 of file channel.c.
References ast_channel_sendhtml(), AST_HTML_URL, and chanlist::chan.
Referenced by dial_exec_full(), sendurl_exec(), and try_calling().
03807 { 03808 return ast_channel_sendhtml(chan, AST_HTML_URL, url, strlen(url) + 1); 03809 }
void ast_channel_set_fd | ( | struct ast_channel * | chan, | |
int | which, | |||
int | fd | |||
) |
Set the file descriptor on the channel
Definition at line 1470 of file channel.c.
References ast_calloc, chanlist::chan, ast_channel::data, ast_channel::fds, and free.
Referenced by __oh323_new(), __oh323_rtp_create(), __oh323_update_info(), alsa_new(), ast_channel_alloc(), ast_deactivate_generator(), ast_do_masquerade(), dahdi_new(), gtalk_new(), jingle_new(), mgcp_new(), misdn_new(), nbs_new(), oss_new(), phone_new(), pri_assign_bearer(), pri_fixup_principle(), setformat(), sip_new(), skinny_new(), start_rtp(), and swap_subs().
01471 { 01472 #ifdef HAVE_EPOLL 01473 struct epoll_event ev; 01474 struct ast_epoll_data *aed = NULL; 01475 01476 if (chan->fds[which] > -1) { 01477 epoll_ctl(chan->epfd, EPOLL_CTL_DEL, chan->fds[which], &ev); 01478 aed = chan->epfd_data[which]; 01479 } 01480 01481 /* If this new fd is valid, add it to the epoll */ 01482 if (fd > -1) { 01483 if (!aed && (!(aed = ast_calloc(1, sizeof(*aed))))) 01484 return; 01485 01486 chan->epfd_data[which] = aed; 01487 aed->chan = chan; 01488 aed->which = which; 01489 01490 ev.events = EPOLLIN | EPOLLPRI | EPOLLERR | EPOLLHUP; 01491 ev.data.ptr = aed; 01492 epoll_ctl(chan->epfd, EPOLL_CTL_ADD, fd, &ev); 01493 } else if (aed) { 01494 /* We don't have to keep around this epoll data structure now */ 01495 free(aed); 01496 chan->epfd_data[which] = NULL; 01497 } 01498 #endif 01499 chan->fds[which] = fd; 01500 return; 01501 }
int ast_channel_setoption | ( | struct ast_channel * | channel, | |
int | option, | |||
void * | data, | |||
int | datalen, | |||
int | block | |||
) |
Sets an option on a channel.
channel | channel to set options on | |
option | option to change | |
data | data specific to option | |
datalen | length of the data | |
block | blocking or not 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 4926 of file channel.c.
References ast_log(), chan, errno, LOG_ERROR, ast_channel_tech::setoption, and ast_channel::tech.
Referenced by ast_bridge_call(), common_exec(), conf_run(), dahdi_hangup(), dial_exec_full(), func_channel_write(), handle_tddmode(), play_record_review(), reset_volumes(), rpt(), rpt_exec(), set_listen_volume(), set_talk_volume(), try_calling(), and vm_forwardoptions().
04927 { 04928 if (!chan->tech->setoption) { 04929 errno = ENOSYS; 04930 return -1; 04931 } 04932 04933 if (block) 04934 ast_log(LOG_ERROR, "XXX Blocking not implemented yet XXX\n"); 04935 04936 return chan->tech->setoption(chan, option, data, datalen); 04937 }
void ast_channel_setwhentohangup | ( | struct ast_channel * | chan, | |
time_t | offset | |||
) |
Set when to hang a channel up.
chan | channel on which to check for hang up | |
offset | offset in seconds relative to the current time of when to hang up |
Definition at line 528 of file channel.c.
References ast_channel_setwhentohangup_tv(), and chanlist::chan.
00529 { 00530 struct timeval when = { offset, }; 00531 ast_channel_setwhentohangup_tv(chan, when); 00532 }
void ast_channel_setwhentohangup_tv | ( | struct ast_channel * | chan, | |
struct timeval | offset | |||
) |
Set when to hang a channel up.
chan | channel on which to check for hang up | |
offset | offset in seconds and useconds relative to the current time of when to hang up |
Definition at line 521 of file channel.c.
References ast_null_frame, ast_queue_frame(), ast_tvadd(), ast_tvnow(), ast_tvzero(), chanlist::chan, and ast_channel::whentohangup.
Referenced by action_timeout(), ast_channel_setwhentohangup(), handle_autohangup(), and timeout_write().
00522 { 00523 chan->whentohangup = ast_tvzero(offset) ? offset : ast_tvadd(offset, ast_tvnow()); 00524 ast_queue_frame(chan, &ast_null_frame); 00525 return; 00526 }
struct ast_silence_generator* ast_channel_start_silence_generator | ( | struct ast_channel * | chan | ) |
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 5259 of file channel.c.
References ast_activate_generator(), ast_calloc, ast_debug, AST_FORMAT_SLINEAR, ast_free, ast_log(), ast_set_write_format(), chan, LOG_ERROR, ast_channel::name, ast_silence_generator::old_write_format, silence_generator, and ast_channel::writeformat.
Referenced by __ast_play_and_record(), ast_dtmf_stream(), channel_spy(), and TransferCallStep1().
05260 { 05261 struct ast_silence_generator *state; 05262 05263 if (!(state = ast_calloc(1, sizeof(*state)))) { 05264 return NULL; 05265 } 05266 05267 state->old_write_format = chan->writeformat; 05268 05269 if (ast_set_write_format(chan, AST_FORMAT_SLINEAR) < 0) { 05270 ast_log(LOG_ERROR, "Could not set write format to SLINEAR\n"); 05271 ast_free(state); 05272 return NULL; 05273 } 05274 05275 ast_activate_generator(chan, &silence_generator, state); 05276 05277 ast_debug(1, "Started silence generator on '%s'\n", chan->name); 05278 05279 return state; 05280 }
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 5282 of file channel.c.
References ast_deactivate_generator(), ast_debug, ast_free, ast_log(), ast_set_write_format(), chan, LOG_ERROR, ast_channel::name, and ast_silence_generator::old_write_format.
Referenced by __ast_play_and_record(), ast_dtmf_stream(), channel_spy(), HandleCallOutgoing(), key_dial_page(), and unistim_hangup().
05283 { 05284 if (!state) 05285 return; 05286 05287 ast_deactivate_generator(chan); 05288 05289 ast_debug(1, "Stopped silence generator on '%s'\n", chan->name); 05290 05291 if (ast_set_write_format(chan, state->old_write_format) < 0) 05292 ast_log(LOG_ERROR, "Could not return write format to its original state\n"); 05293 05294 ast_free(state); 05295 }
int ast_channel_supports_html | ( | struct ast_channel * | channel | ) |
Returns 0 if channel does not support HTML or non-zero if it does
Definition at line 3794 of file channel.c.
References chanlist::chan, ast_channel_tech::send_html, and ast_channel::tech.
Referenced by dial_exec_full(), sendurl_exec(), and try_calling().
void ast_channel_undefer_dtmf | ( | struct ast_channel * | chan | ) |
Unset defer DTMF flag on channel.
Undo defer. ast_read will return any dtmf characters that were queued
Definition at line 1098 of file channel.c.
References ast_clear_flag, AST_FLAG_DEFER_DTMF, and chanlist::chan.
Referenced by find_cache(), and rpt_call().
01099 { 01100 if (chan) 01101 ast_clear_flag(chan, AST_FLAG_DEFER_DTMF); 01102 }
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 587 of file channel.c.
References ast_debug, ast_free, AST_LIST_REMOVE_CURRENT, AST_LIST_TRAVERSE_SAFE_BEGIN, AST_LIST_TRAVERSE_SAFE_END, AST_RWLIST_UNLOCK, AST_RWLIST_WRLOCK, ast_verb, chanlist::chan, chanlist::list, ast_channel::tech, chanlist::tech, and ast_channel_tech::type.
Referenced by __unload_module(), load_module(), and unload_module().
00588 { 00589 struct chanlist *chan; 00590 00591 ast_debug(1, "Unregistering channel type '%s'\n", tech->type); 00592 00593 AST_RWLIST_WRLOCK(&channels); 00594 00595 AST_LIST_TRAVERSE_SAFE_BEGIN(&backends, chan, list) { 00596 if (chan->tech == tech) { 00597 AST_LIST_REMOVE_CURRENT(list); 00598 ast_free(chan); 00599 ast_verb(2, "Unregistered channel type '%s'\n", tech->type); 00600 break; 00601 } 00602 } 00603 AST_LIST_TRAVERSE_SAFE_END; 00604 00605 AST_RWLIST_UNLOCK(&channels); 00606 }
struct ast_channel* ast_channel_walk_locked | ( | const struct ast_channel * | prev | ) |
Browse channels in use Browse the channels currently in use.
prev | where you want to start in the channel list |
Definition at line 1212 of file channel.c.
References channel_find_locked().
Referenced by action_coreshowchannels(), action_status(), ast_complete_channels(), ast_pickup_call(), conf_exec(), func_channels_read(), handle_chanlist(), handle_core_set_debug_channel(), next_channel(), pickup_by_exten(), and pickup_by_mark().
01213 { 01214 return channel_find_locked(prev, NULL, 0, NULL, NULL); 01215 }
struct ast_variable* ast_channeltype_list | ( | void | ) |
return an ast_variable list of channeltypes
Definition at line 185 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.
00186 { 00187 struct chanlist *cl; 00188 struct ast_variable *var=NULL, *prev = NULL; 00189 AST_LIST_TRAVERSE(&backends, cl, list) { 00190 if (prev) { 00191 if ((prev->next = ast_variable_new(cl->tech->type, cl->tech->description, ""))) 00192 prev = prev->next; 00193 } else { 00194 var = ast_variable_new(cl->tech->type, cl->tech->description, ""); 00195 prev = var; 00196 } 00197 } 00198 return var; 00199 }
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 461 of file channel.c.
References ast_channel::_softhangup, AST_SOFTHANGUP_TIMEOUT, ast_tvdiff_ms(), ast_tvnow(), ast_tvzero(), chanlist::chan, and ast_channel::whentohangup.
Referenced by __ast_pbx_run(), __ast_read(), _macro_exec(), action_redirect(), agent_indicate(), agi_exec(), agi_handle_command(), announce_thread(), 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_raw_answer(), ast_readstring_full(), ast_recvtext(), ast_rtp_bridge(), ast_sendtext(), ast_transfer(), ast_udptl_bridge(), ast_waitfordigit_full(), ast_write(), autoservice_run(), bridge_exec(), bridge_native_loop(), builtin_atxfer(), channel_spy(), check_bridge(), common_exec(), conf_play(), conf_run(), dahdi_sendtext(), dahdi_setoption(), dial_exec_full(), dundi_lookup_internal(), eagi_exec(), eivr_comm(), handle_sendimage(), launch_asyncagi(), lua_check_hangup(), ospfinished_exec(), pbx_builtin_incomplete(), pbx_exec(), read_exec(), readexten_exec(), rpt(), run_ras(), and try_calling().
00462 { 00463 if (chan->_softhangup) /* yes if soft hangup flag set */ 00464 return 1; 00465 if (ast_tvzero(chan->whentohangup)) /* no if no hangup scheduled */ 00466 return 0; 00467 if (ast_tvdiff_ms(chan->whentohangup, ast_tvnow()) > 0) /* no if hangup time has not come yet. */ 00468 return 0; 00469 chan->_softhangup |= AST_SOFTHANGUP_TIMEOUT; /* record event */ 00470 return 1; 00471 }
void ast_deactivate_generator | ( | struct ast_channel * | chan | ) |
Deactivate an active generator
Definition at line 1838 of file channel.c.
References ast_channel_lock, ast_channel_set_fd(), ast_channel_unlock, ast_clear_flag, AST_FLAG_WRITE_INT, AST_GENERATOR_FD, ast_settimeout(), chanlist::chan, ast_channel::generator, ast_channel::generatordata, and ast_generator::release.
Referenced by __ast_read(), app_exec(), ast_channel_stop_silence_generator(), ast_openstream_full(), ast_playtones_stop(), ast_quiet_chan(), ast_read_generator_actions(), ast_tonepair_stop(), ast_write(), cb_events(), channel_spy(), dial_exec_full(), generator_force(), local_ast_moh_stop(), old_milliwatt_exec(), transmit_audio(), and wait_for_answer().
01839 { 01840 ast_channel_lock(chan); 01841 if (chan->generatordata) { 01842 if (chan->generator && chan->generator->release) 01843 chan->generator->release(chan, chan->generatordata); 01844 chan->generatordata = NULL; 01845 chan->generator = NULL; 01846 ast_channel_set_fd(chan, AST_GENERATOR_FD, -1); 01847 ast_clear_flag(chan, AST_FLAG_WRITE_INT); 01848 ast_settimeout(chan, 0, NULL, NULL); 01849 } 01850 ast_channel_unlock(chan); 01851 }
int ast_do_masquerade | ( | struct ast_channel * | original | ) |
Start masquerading a channel XXX This is a seriously whacked 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.
Definition at line 4026 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_NAME, ast_channel_set_fd(), ast_channel_unlock, ast_copy_string(), ast_debug, 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_state2str(), 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_datastore::info, ast_channel::language, language, ast_channel::lock_dont_use, LOG_WARNING, manager_event, ast_channel::masq, ast_channel::masqr, ast_channel::monitor, musicclass, name, ast_channel::name, ast_channel::nativeformats, ast_channel::rawreadformat, ast_channel::rawwriteformat, ast_channel::readformat, ast_channel::readq, 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().
04027 { 04028 int x,i; 04029 int res=0; 04030 int origstate; 04031 struct ast_frame *current; 04032 const struct ast_channel_tech *t; 04033 void *t_pvt; 04034 struct ast_callerid tmpcid; 04035 struct ast_channel *clonechan = original->masq; 04036 struct ast_cdr *cdr; 04037 int rformat = original->readformat; 04038 int wformat = original->writeformat; 04039 char newn[AST_CHANNEL_NAME]; 04040 char orig[AST_CHANNEL_NAME]; 04041 char masqn[AST_CHANNEL_NAME]; 04042 char zombn[AST_CHANNEL_NAME]; 04043 04044 ast_debug(4, "Actually Masquerading %s(%d) into the structure of %s(%d)\n", 04045 clonechan->name, clonechan->_state, original->name, original->_state); 04046 04047 manager_event(EVENT_FLAG_CALL, "Masquerade", "Clone: %s\r\nCloneState: %s\r\nOriginal: %s\r\nOriginalState: %s\r\n", 04048 clonechan->name, ast_state2str(clonechan->_state), original->name, ast_state2str(original->_state)); 04049 04050 /* XXX This is a seriously wacked out operation. We're essentially putting the guts of 04051 the clone channel into the original channel. Start by killing off the original 04052 channel's backend. I'm not sure we're going to keep this function, because 04053 while the features are nice, the cost is very high in terms of pure nastiness. XXX */ 04054 04055 /* We need the clone's lock, too */ 04056 ast_channel_lock(clonechan); 04057 04058 ast_debug(2, "Got clone lock for masquerade on '%s' at %p\n", clonechan->name, &clonechan->lock_dont_use); 04059 04060 /* Having remembered the original read/write formats, we turn off any translation on either 04061 one */ 04062 free_translation(clonechan); 04063 free_translation(original); 04064 04065 04066 /* Unlink the masquerade */ 04067 original->masq = NULL; 04068 clonechan->masqr = NULL; 04069 04070 /* Save the original name */ 04071 ast_copy_string(orig, original->name, sizeof(orig)); 04072 /* Save the new name */ 04073 ast_copy_string(newn, clonechan->name, sizeof(newn)); 04074 /* Create the masq name */ 04075 snprintf(masqn, sizeof(masqn), "%s<MASQ>", newn); 04076 04077 /* Copy the name from the clone channel */ 04078 ast_string_field_set(original, name, newn); 04079 04080 /* Mangle the name of the clone channel */ 04081 ast_string_field_set(clonechan, name, masqn); 04082 04083 /* Notify any managers of the change, first the masq then the other */ 04084 manager_event(EVENT_FLAG_CALL, "Rename", "Channel: %s\r\nNewname: %s\r\nUniqueid: %s\r\n", newn, masqn, clonechan->uniqueid); 04085 manager_event(EVENT_FLAG_CALL, "Rename", "Channel: %s\r\nNewname: %s\r\nUniqueid: %s\r\n", orig, newn, original->uniqueid); 04086 04087 /* Swap the technologies */ 04088 t = original->tech; 04089 original->tech = clonechan->tech; 04090 clonechan->tech = t; 04091 04092 /* Swap the cdrs */ 04093 cdr = original->cdr; 04094 original->cdr = clonechan->cdr; 04095 clonechan->cdr = cdr; 04096 04097 t_pvt = original->tech_pvt; 04098 original->tech_pvt = clonechan->tech_pvt; 04099 clonechan->tech_pvt = t_pvt; 04100 04101 /* Swap the alertpipes */ 04102 for (i = 0; i < 2; i++) { 04103 x = original->alertpipe[i]; 04104 original->alertpipe[i] = clonechan->alertpipe[i]; 04105 clonechan->alertpipe[i] = x; 04106 } 04107 04108 /* 04109 * Swap the readq's. The end result should be this: 04110 * 04111 * 1) All frames should be on the new (original) channel. 04112 * 2) Any frames that were already on the new channel before this 04113 * masquerade need to be at the end of the readq, after all of the 04114 * frames on the old (clone) channel. 04115 * 3) The alertpipe needs to get poked for every frame that was already 04116 * on the new channel, since we are now using the alert pipe from the 04117 * old (clone) channel. 04118 */ 04119 { 04120 AST_LIST_HEAD_NOLOCK(, ast_frame) tmp_readq; 04121 AST_LIST_HEAD_SET_NOLOCK(&tmp_readq, NULL); 04122 04123 AST_LIST_APPEND_LIST(&tmp_readq, &original->readq, frame_list); 04124 AST_LIST_APPEND_LIST(&original->readq, &clonechan->readq, frame_list); 04125 04126 while ((current = AST_LIST_REMOVE_HEAD(&tmp_readq, frame_list))) { 04127 AST_LIST_INSERT_TAIL(&original->readq, current, frame_list); 04128 if (original->alertpipe[1] > -1) { 04129 int poke = 0; 04130 04131 if (write(original->alertpipe[1], &poke, sizeof(poke)) < 0) { 04132 ast_log(LOG_WARNING, "write() failed: %s\n", strerror(errno)); 04133 } 04134 } 04135 } 04136 } 04137 04138 /* Swap the raw formats */ 04139 x = original->rawreadformat; 04140 original->rawreadformat = clonechan->rawreadformat; 04141 clonechan->rawreadformat = x; 04142 x = original->rawwriteformat; 04143 original->rawwriteformat = clonechan->rawwriteformat; 04144 clonechan->rawwriteformat = x; 04145 04146 clonechan->_softhangup = AST_SOFTHANGUP_DEV; 04147 04148 /* And of course, so does our current state. Note we need not 04149 call ast_setstate since the event manager doesn't really consider 04150 these separate. We do this early so that the clone has the proper 04151 state of the original channel. */ 04152 origstate = original->_state; 04153 original->_state = clonechan->_state; 04154 clonechan->_state = origstate; 04155 04156 if (clonechan->tech->fixup){ 04157 res = clonechan->tech->fixup(original, clonechan); 04158 if (res) 04159 ast_log(LOG_WARNING, "Fixup failed on channel %s, strange things may happen.\n", clonechan->name); 04160 } 04161 04162 /* Start by disconnecting the original's physical side */ 04163 if (clonechan->tech->hangup) 04164 res = clonechan->tech->hangup(clonechan); 04165 if (res) { 04166 ast_log(LOG_WARNING, "Hangup failed! Strange things may happen!\n"); 04167 ast_channel_unlock(clonechan); 04168 return -1; 04169 } 04170 04171 snprintf(zombn, sizeof(zombn), "%s<ZOMBIE>", orig); 04172 /* Mangle the name of the clone channel */ 04173 ast_string_field_set(clonechan, name, zombn); 04174 manager_event(EVENT_FLAG_CALL, "Rename", "Channel: %s\r\nNewname: %s\r\nUniqueid: %s\r\n", masqn, zombn, clonechan->uniqueid); 04175 04176 /* Update the type. */ 04177 t_pvt = original->monitor; 04178 original->monitor = clonechan->monitor; 04179 clonechan->monitor = t_pvt; 04180 04181 /* Keep the same language. */ 04182 ast_string_field_set(original, language, clonechan->language); 04183 /* Copy the FD's other than the generator fd */ 04184 for (x = 0; x < AST_MAX_FDS; x++) { 04185 if (x != AST_GENERATOR_FD) 04186 ast_channel_set_fd(original, x, clonechan->fds[x]); 04187 } 04188 04189 ast_app_group_update(clonechan, original); 04190 04191 /* Move data stores over */ 04192 if (AST_LIST_FIRST(&clonechan->datastores)) { 04193 struct ast_datastore *ds; 04194 AST_LIST_TRAVERSE(&clonechan->datastores, ds, entry) { 04195 if (ds->info->chan_fixup) 04196 ds->info->chan_fixup(ds->data, clonechan, original); 04197 } 04198 AST_LIST_APPEND_LIST(&original->datastores, &clonechan->datastores, entry); 04199 } 04200 04201 clone_variables(original, clonechan); 04202 /* Presense of ADSI capable CPE follows clone */ 04203 original->adsicpe = clonechan->adsicpe; 04204 /* Bridge remains the same */ 04205 /* CDR fields remain the same */ 04206 /* XXX What about blocking, softhangup, blocker, and lock and blockproc? XXX */ 04207 /* Application and data remain the same */ 04208 /* Clone exception becomes real one, as with fdno */ 04209 ast_set_flag(original, ast_test_flag(clonechan, AST_FLAG_OUTGOING | AST_FLAG_EXCEPTION)); 04210 original->fdno = clonechan->fdno; 04211 /* Schedule context remains the same */ 04212 /* Stream stuff stays the same */ 04213 /* Keep the original state. The fixup code will need to work with it most likely */ 04214 04215 /* Just swap the whole structures, nevermind the allocations, they'll work themselves 04216 out. */ 04217 tmpcid = original->cid; 04218 original->cid = clonechan->cid; 04219 clonechan->cid = tmpcid; 04220 04221 /* Restore original timing file descriptor */ 04222 ast_channel_set_fd(original, AST_TIMING_FD, original->timingfd); 04223 04224 /* Our native formats are different now */ 04225 original->nativeformats = clonechan->nativeformats; 04226 04227 /* Context, extension, priority, app data, jump table, remain the same */ 04228 /* pvt switches. pbx stays the same, as does next */ 04229 04230 /* Set the write format */ 04231 ast_set_write_format(original, wformat); 04232 04233 /* Set the read format */ 04234 ast_set_read_format(original, rformat); 04235 04236 /* Copy the music class */ 04237 ast_string_field_set(original, musicclass, clonechan->musicclass); 04238 04239 ast_debug(1, "Putting channel %s in %d/%d formats\n", original->name, wformat, rformat); 04240 04241 /* Okay. Last thing is to let the channel driver know about all this mess, so he 04242 can fix up everything as best as possible */ 04243 if (original->tech->fixup) { 04244 res = original->tech->fixup(clonechan, original); 04245 if (res) { 04246 ast_log(LOG_WARNING, "Channel for type '%s' could not fixup channel %s\n", 04247 original->tech->type, original->name); 04248 ast_channel_unlock(clonechan); 04249 return -1; 04250 } 04251 } else 04252 ast_log(LOG_WARNING, "Channel type '%s' does not have a fixup routine (for %s)! Bad things may happen.\n", 04253 original->tech->type, original->name); 04254 04255 /* 04256 * If an indication is currently playing, maintain it on the channel 04257 * that is taking the place of original 04258 * 04259 * This is needed because the masquerade is swapping out in the internals 04260 * of this channel, and the new channel private data needs to be made 04261 * aware of the current visible indication (RINGING, CONGESTION, etc.) 04262 */ 04263 if (original->visible_indication) { 04264 ast_indicate(original, original->visible_indication); 04265 } 04266 04267 /* Now, at this point, the "clone" channel is totally F'd up. We mark it as 04268 a zombie so nothing tries to touch it. If it's already been marked as a 04269 zombie, then free it now (since it already is considered invalid). */ 04270 if (ast_test_flag(clonechan, AST_FLAG_ZOMBIE)) { 04271 ast_debug(1, "Destroying channel clone '%s'\n", clonechan->name); 04272 ast_channel_unlock(clonechan); 04273 manager_event(EVENT_FLAG_CALL, "Hangup", 04274 "Channel: %s\r\n" 04275 "Uniqueid: %s\r\n" 04276 "Cause: %d\r\n" 04277 "Cause-txt: %s\r\n", 04278 clonechan->name, 04279 clonechan->uniqueid, 04280 clonechan->hangupcause, 04281 ast_cause2str(clonechan->hangupcause) 04282 ); 04283 ast_channel_free(clonechan); 04284 } else { 04285 ast_debug(1, "Released clone lock on '%s'\n", clonechan->name); 04286 ast_set_flag(clonechan, AST_FLAG_ZOMBIE); 04287 ast_queue_frame(clonechan, &ast_null_frame); 04288 ast_channel_unlock(clonechan); 04289 } 04290 04291 /* Signal any blocker */ 04292 if (ast_test_flag(original, AST_FLAG_BLOCKING)) 04293 pthread_kill(original->blocker, SIGURG); 04294 ast_debug(1, "Done Masquerading %s (%d)\n", original->name, original->_state); 04295 return 0; 04296 }
static int ast_fdisset | ( | struct pollfd * | pfds, | |
int | fd, | |||
int | maximum, | |||
int * | start | |||
) | [inline, static] |
Helper function for migrating select to poll.
Definition at line 1637 of file channel.h.
References dummy().
01638 { 01639 int x; 01640 int dummy = 0; 01641 01642 if (fd < 0) 01643 return 0; 01644 if (!start) 01645 start = &dummy; 01646 for (x = *start; x < maximum; x++) 01647 if (pfds[x].fd == fd) { 01648 if (x == *start) 01649 (*start)++; 01650 return pfds[x].revents; 01651 } 01652 return 0; 01653 }
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.
Definition at line 1237 of file channel.c.
References channel_find_locked().
01238 { 01239 return channel_find_locked(NULL, NULL, 0, context, exten); 01240 }
struct ast_channel* ast_get_channel_by_name_locked | ( | const char * | chan | ) |
Get channel by name or uniqueid (locks channel).
Definition at line 1218 of file channel.c.
References channel_find_locked().
Referenced by acf_import(), action_add_agi_cmd(), action_atxfer(), action_getvar(), action_hangup(), action_redirect(), action_sendtext(), action_setvar(), action_status(), action_timeout(), ast_async_goto_by_name(), ast_bridge_call(), ast_park_call_full(), asyncgoto_exec(), change_monitor_action(), do_pause_or_unpause(), get_dahdi_channel_locked(), handle_channelstatus(), handle_cli_agi_add_cmd(), handle_core_set_debug_channel(), handle_getvariablefull(), handle_hangup(), handle_set_chanvar(), handle_show_chanvar(), handle_showchan(), handle_softhangup(), manager_park(), manager_play_dtmf(), pbx_builtin_importvar(), shared_read(), shared_write(), start_monitor_action(), and stop_monitor_action().
01219 { 01220 return channel_find_locked(NULL, name, 0, NULL, NULL); 01221 }
struct ast_channel* ast_get_channel_by_name_prefix_locked | ( | const char * | name, | |
const int | namelen | |||
) |
Get channel by name or uniqueid prefix (locks channel).
Definition at line 1224 of file channel.c.
References channel_find_locked().
Referenced by action_bridge(), ast_parse_device_state(), bridge_exec(), common_exec(), handle_cli_mixmonitor(), shared_read(), and shared_write().
01225 { 01226 return channel_find_locked(NULL, name, namelen, NULL, NULL); 01227 }
struct ast_channel_tech* ast_get_channel_tech | ( | const char * | name | ) |
Get a channel technology structure by name.
name | name of technology to find |
Definition at line 609 of file channel.c.
References AST_LIST_TRAVERSE, AST_RWLIST_RDLOCK, AST_RWLIST_UNLOCK, chanlist::list, chanlist::tech, and ast_channel_tech::type.
Referenced by _ast_device_state().
00610 { 00611 struct chanlist *chanls; 00612 const struct ast_channel_tech *ret = NULL; 00613 00614 AST_RWLIST_RDLOCK(&channels); 00615 00616 AST_LIST_TRAVERSE(&backends, chanls, list) { 00617 if (!strcasecmp(name, chanls->tech->type)) { 00618 ret = chanls->tech; 00619 break; 00620 } 00621 } 00622 00623 AST_RWLIST_UNLOCK(&channels); 00624 00625 return ret; 00626 }
ast_group_t ast_get_group | ( | const char * | s | ) |
Definition at line 5104 of file channel.c.
References ast_log(), ast_strdupa, ast_strlen_zero(), LOG_ERROR, LOG_WARNING, and strsep().
Referenced by _parse(), build_device(), build_gateway(), build_peer(), func_channel_write(), and read_agent_config().
05105 { 05106 char *piece; 05107 char *c; 05108 int start=0, finish=0, x; 05109 ast_group_t group = 0; 05110 05111 if (ast_strlen_zero(s)) 05112 return 0; 05113 05114 c = ast_strdupa(s); 05115 05116 while ((piece = strsep(&c, ","))) { 05117 if (sscanf(piece, "%d-%d", &start, &finish) == 2) { 05118 /* Range */ 05119 } else if (sscanf(piece, "%d", &start)) { 05120 /* Just one */ 05121 finish = start; 05122 } else { 05123 ast_log(LOG_ERROR, "Syntax error parsing group configuration '%s' at '%s'. Ignoring.\n", s, piece); 05124 continue; 05125 } 05126 for (x = start; x <= finish; x++) { 05127 if ((x > 63) || (x < 0)) { 05128 ast_log(LOG_WARNING, "Ignoring invalid group %d (maximum group is 63)\n", x); 05129 } else 05130 group |= ((ast_group_t) 1 << x); 05131 } 05132 } 05133 return group; 05134 }
int ast_hangup | ( | struct ast_channel * | chan | ) |
Hang up a channel.
chan | channel to hang up |
Definition at line 1584 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_debug, 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, chanlist::chan, ast_channel::cid, ast_callerid::cid_name, ast_callerid::cid_num, ast_cdr::disposition, EVENT_FLAG_CALL, free_translation(), ast_channel::generator, ast_channel::generatordata, ast_channel_tech::hangup, ast_channel::hangupcause, LOG_WARNING, manager_event, ast_channel::masq, ast_channel::masqr, ast_channel::name, ast_generator::release, S_OR, ast_channel::sched, sched_context_destroy(), ast_channel::stream, ast_channel::tech, ast_channel::uniqueid, and ast_channel::vstream.
Referenced by __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_channel(), bridge_exec(), build_conf(), builtin_atxfer(), chanavail_exec(), check_compat(), check_goto_on_transfer(), clear_caller(), conf_run(), connect_link(), console_new(), dahdi_handle_event(), dahdi_new(), dial_exec_full(), do_forward(), do_hang(), do_idle_thread(), findmeexec(), gtalk_new(), handle_call_forward(), handle_callforward_button(), handle_enbloc_call_message(), handle_frame(), handle_frame_ownerless(), handle_hd_hf(), handle_init_event(), handle_invite_replaces(), handle_offhook_message(), handle_request_invite(), handle_soft_key_event_message(), handle_stimulus_message(), handle_timeout_trip(), handle_transfer_button(), HandleCallOutgoing(), hangup_chan(), hangupcalls(), hanguptree(), iax2_request(), iax_park(), iax_park_thread(), jingle_new(), local_hangup(), manage_parkinglot(), masq_park_call(), mgcp_new(), mgcp_ss(), monitor_dial(), mwi_thread(), nbs_new(), oss_new(), park_exec_full(), parkandannounce_exec(), phone_new(), rpt(), rpt_call(), rpt_tele_thread(), sip_new(), sip_park(), sip_park_thread(), skinny_new(), skinny_ss(), ss_thread(), try_calling(), unistim_new(), usbradio_new(), wait_for_answer(), and wait_for_winner().
01585 { 01586 int res = 0; 01587 01588 /* Don't actually hang up a channel that will masquerade as someone else, or 01589 if someone is going to masquerade as us */ 01590 ast_channel_lock(chan); 01591 01592 if (chan->audiohooks) { 01593 ast_audiohook_detach_list(chan->audiohooks); 01594 chan->audiohooks = NULL; 01595 } 01596 01597 ast_autoservice_stop(chan); 01598 01599 if (chan->masq) { 01600 if (ast_do_masquerade(chan)) 01601 ast_log(LOG_WARNING, "Failed to perform masquerade\n"); 01602 } 01603 01604 if (chan->masq) { 01605 ast_log(LOG_WARNING, "%s getting hung up, but someone is trying to masq into us?!?\n", chan->name); 01606 ast_channel_unlock(chan); 01607 return 0; 01608 } 01609 /* If this channel is one which will be masqueraded into something, 01610 mark it as a zombie already, so we know to free it later */ 01611 if (chan->masqr) { 01612 ast_set_flag(chan, AST_FLAG_ZOMBIE); 01613 ast_channel_unlock(chan); 01614 return 0; 01615 } 01616 free_translation(chan); 01617 /* Close audio stream */ 01618 if (chan->stream) { 01619 ast_closestream(chan->stream); 01620 chan->stream = NULL; 01621 } 01622 /* Close video stream */ 01623 if (chan->vstream) { 01624 ast_closestream(chan->vstream); 01625 chan->vstream = NULL; 01626 } 01627 if (chan->sched) { 01628 sched_context_destroy(chan->sched); 01629 chan->sched = NULL; 01630 } 01631 01632 if (chan->generatordata) /* Clear any tone stuff remaining */ 01633 if (chan->generator && chan->generator->release) 01634 chan->generator->release(chan, chan->generatordata); 01635 chan->generatordata = NULL; 01636 chan->generator = NULL; 01637 if (ast_test_flag(chan, AST_FLAG_BLOCKING)) { 01638 ast_log(LOG_WARNING, "Hard hangup called by thread %ld on %s, while fd " 01639 "is blocked by thread %ld in procedure %s! Expect a failure\n", 01640 (long)pthread_self(), chan->name, (long)chan->blocker, chan->blockproc); 01641 ast_assert(ast_test_flag(chan, AST_FLAG_BLOCKING) == 0); 01642 } 01643 if (!ast_test_flag(chan, AST_FLAG_ZOMBIE)) { 01644 ast_debug(1, "Hanging up channel '%s'\n", chan->name); 01645 if (chan->tech->hangup) 01646 res = chan->tech->hangup(chan); 01647 } else { 01648 ast_debug(1, "Hanging up zombie '%s'\n", chan->name); 01649 } 01650 01651 ast_channel_unlock(chan); 01652 manager_event(EVENT_FLAG_CALL, "Hangup", 01653 "Channel: %s\r\n" 01654 "Uniqueid: %s\r\n" 01655 "CallerIDNum: %s\r\n" 01656 "CallerIDName: %s\r\n" 01657 "Cause: %d\r\n" 01658 "Cause-txt: %s\r\n", 01659 chan->name, 01660 chan->uniqueid, 01661 S_OR(chan->cid.cid_num, "<unknown>"), 01662 S_OR(chan->cid.cid_name, "<unknown>"), 01663 chan->hangupcause, 01664 ast_cause2str(chan->hangupcause) 01665 ); 01666 01667 if (chan->cdr && !ast_test_flag(chan->cdr, AST_CDR_FLAG_BRIDGED) && 01668 !ast_test_flag(chan->cdr, AST_CDR_FLAG_POST_DISABLED) && 01669 (chan->cdr->disposition != AST_CDR_NULL || ast_test_flag(chan->cdr, AST_CDR_FLAG_DIALED))) { 01670 01671 ast_cdr_end(chan->cdr); 01672 ast_cdr_detach(chan->cdr); 01673 chan->cdr = NULL; 01674 } 01675 01676 ast_channel_free(chan); 01677 01678 return res; 01679 }
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 2949 of file channel.c.
References ast_indicate_data(), and chanlist::chan.
Referenced by __ast_play_and_record(), agent_new(), alsa_call(), answer_trunk_chan(), ast_bridge_call(), ast_channel_bridge(), ast_do_masquerade(), ast_dtmf_stream(), ast_feature_request_and_dial(), ast_park_call_full(), ast_raw_answer(), attempt_transfer(), builtin_atxfer(), builtin_blindtransfer(), cli_console_answer(), conf_run(), console_call(), dial_exec_full(), do_forward(), finishup(), function_remote(), handle_callforward_button(), handle_frame(), handle_recordfile(), manage_parkinglot(), mgcp_ss(), monitor_dial(), oss_call(), park_exec_full(), pbx_builtin_busy(), pbx_builtin_congestion(), pbx_builtin_proceeding(), pbx_builtin_progress(), pbx_builtin_ringing(), pbx_builtin_waitexten(), queue_exec(), rpt(), rpt_exec(), say_periodic_announcement(), say_position(), send_waveform_to_channel(), skinny_ss(), sla_handle_hold_event(), sla_station_exec(), sla_trunk_exec(), try_calling(), and wait_for_answer().
02950 { 02951 return ast_indicate_data(chan, condition, NULL, 0); 02952 }
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 2988 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_T38, AST_CONTROL_TAKEOFFHOOK, AST_CONTROL_UNHOLD, AST_CONTROL_VIDUPDATE, AST_CONTROL_WINK, ast_debug, AST_FLAG_ZOMBIE, ast_get_indication_tone(), ast_log(), ast_playtones_start(), ast_playtones_stop(), ast_test_flag, chanlist::chan, tone_zone_sound::data, ast_channel_tech::indicate, is_visible_indication(), LOG_WARNING, ast_channel::name, ast_channel::tech, ast_channel::visible_indication, and ast_channel::zone.
Referenced by agent_hangup(), ast_bridge_call(), ast_indicate(), ast_park_call_full(), bridge_native_loop(), login_exec(), manage_parkinglot(), pbx_builtin_waitexten(), and transmit_audio().
02990 { 02991 /* By using an enum, we'll get compiler warnings for values not handled 02992 * in switch statements. */ 02993 enum ast_control_frame_type condition = _condition; 02994 const struct tone_zone_sound *ts = NULL; 02995 int res = -1; 02996 02997 ast_channel_lock(chan); 02998 02999 /* Don't bother if the channel is about to go away, anyway. */ 03000 if (ast_test_flag(chan, AST_FLAG_ZOMBIE) || ast_check_hangup(chan)) { 03001 ast_channel_unlock(chan); 03002 return -1; 03003 } 03004 03005 if (chan->tech->indicate) { 03006 /* See if the channel driver can handle this condition. */ 03007 res = chan->tech->indicate(chan, condition, data, datalen); 03008 } 03009 03010 ast_channel_unlock(chan); 03011 03012 if (chan->tech->indicate && !res) { 03013 /* The channel driver successfully handled this indication */ 03014 if (is_visible_indication(condition)) { 03015 chan->visible_indication = condition; 03016 } 03017 return 0; 03018 } 03019 03020 /* The channel driver does not support this indication, let's fake 03021 * it by doing our own tone generation if applicable. */ 03022 03023 /*!\note If we compare the enumeration type, which does not have any 03024 * negative constants, the compiler may optimize this code away. 03025 * Therefore, we must perform an integer comparison here. */ 03026 if (_condition < 0) { 03027 /* Stop any tones that are playing */ 03028 ast_playtones_stop(chan); 03029 return 0; 03030 } 03031 03032 /* Handle conditions that we have tones for. */ 03033 switch (condition) { 03034 case AST_CONTROL_RINGING: 03035 ts = ast_get_indication_tone(chan->zone, "ring"); 03036 break; 03037 case AST_CONTROL_BUSY: 03038 ts = ast_get_indication_tone(chan->zone, "busy"); 03039 break; 03040 case AST_CONTROL_CONGESTION: 03041 ts = ast_get_indication_tone(chan->zone, "congestion"); 03042 break; 03043 case AST_CONTROL_PROGRESS: 03044 case AST_CONTROL_PROCEEDING: 03045 case AST_CONTROL_VIDUPDATE: 03046 case AST_CONTROL_SRCUPDATE: 03047 case AST_CONTROL_RADIO_KEY: 03048 case AST_CONTROL_RADIO_UNKEY: 03049 case AST_CONTROL_OPTION: 03050 case AST_CONTROL_WINK: 03051 case AST_CONTROL_FLASH: 03052 case AST_CONTROL_OFFHOOK: 03053 case AST_CONTROL_TAKEOFFHOOK: 03054 case AST_CONTROL_ANSWER: 03055 case AST_CONTROL_HANGUP: 03056 case AST_CONTROL_RING: 03057 case AST_CONTROL_HOLD: 03058 case AST_CONTROL_UNHOLD: 03059 case AST_CONTROL_T38: 03060 /* Nothing left to do for these. */ 03061 res = 0; 03062 break; 03063 } 03064 03065 if (ts && ts->data[0]) { 03066 /* We have a tone to play, yay. */ 03067 ast_debug(1, "Driver for channel '%s' does not support indication %d, emulating it\n", chan->name, condition); 03068 ast_playtones_start(chan, 0, ts->data, 1); 03069 res = 0; 03070 chan->visible_indication = condition; 03071 } 03072 03073 if (res) { 03074 /* not handled */ 03075 ast_log(LOG_WARNING, "Unable to handle indication %d for '%s'\n", condition, chan->name); 03076 } 03077 03078 return res; 03079 }
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 2932 of file channel.c.
References ast_debug, ast_opt_internal_timing, chanlist::chan, and ast_channel::timingfd.
Referenced by add_sdp(), and ast_read_generator_actions().
02933 { 02934 int ret = ast_opt_internal_timing && chan->timingfd > -1; 02935 ast_debug(5, "Internal timing is %s (option_internal_timing=%d chan->timingfd=%d)\n", ret? "enabled": "disabled", ast_opt_internal_timing, chan->timingfd); 02936 return ret; 02937 }
void ast_poll_channel_add | ( | struct ast_channel * | chan0, | |
struct ast_channel * | chan1 | |||
) |
Add a channel to an optimized waitfor
Definition at line 1504 of file channel.c.
References AST_MAX_FDS, and ast_channel::fds.
Referenced by ast_feature_request_and_dial(), ast_generic_bridge(), begin_dial_channel(), bridge_native_loop(), bridge_p2p_loop(), and wait_for_answer().
01505 { 01506 #ifdef HAVE_EPOLL 01507 struct epoll_event ev; 01508 int i = 0; 01509 01510 if (chan0->epfd == -1) 01511 return; 01512 01513 /* Iterate through the file descriptors on chan1, adding them to chan0 */ 01514 for (i = 0; i < AST_MAX_FDS; i++) { 01515 if (chan1->fds[i] == -1) 01516 continue; 01517 ev.events = EPOLLIN | EPOLLPRI | EPOLLERR | EPOLLHUP; 01518 ev.data.ptr = chan1->epfd_data[i]; 01519 epoll_ctl(chan0->epfd, EPOLL_CTL_ADD, chan1->fds[i], &ev); 01520 } 01521 01522 #endif 01523 return; 01524 }
void ast_poll_channel_del | ( | struct ast_channel * | chan0, | |
struct ast_channel * | chan1 | |||
) |
Delete a channel from an optimized waitfor
Definition at line 1527 of file channel.c.
References AST_MAX_FDS, and ast_channel::fds.
Referenced by ast_feature_request_and_dial(), bridge_native_loop(), monitor_dial(), and wait_for_answer().
01528 { 01529 #ifdef HAVE_EPOLL 01530 struct epoll_event ev; 01531 int i = 0; 01532 01533 if (chan0->epfd == -1) 01534 return; 01535 01536 for (i = 0; i < AST_MAX_FDS; i++) { 01537 if (chan1->fds[i] == -1) 01538 continue; 01539 epoll_ctl(chan0->epfd, EPOLL_CTL_DEL, chan1->fds[i], &ev); 01540 } 01541 01542 #endif 01543 return; 01544 }
char* ast_print_group | ( | char * | buf, | |
int | buflen, | |||
ast_group_t | group | |||
) |
print call- and pickup groups into buffer
Definition at line 5186 of file channel.c.
Referenced by _sip_show_peer(), func_channel_read(), function_sippeer(), handle_skinny_show_line(), misdn_cfg_get_config_string(), print_group(), read_config(), and serialize_showchan().
05187 { 05188 unsigned int i; 05189 int first = 1; 05190 char num[3]; 05191 05192 buf[0] = '\0'; 05193 05194 if (!group) /* Return empty string if no group */ 05195 return buf; 05196 05197 for (i = 0; i <= 63; i++) { /* Max group is 63 */ 05198 if (group & ((ast_group_t) 1 << i)) { 05199 if (!first) { 05200 strncat(buf, ", ", buflen - strlen(buf) - 1); 05201 } else { 05202 first = 0; 05203 } 05204 snprintf(num, sizeof(num), "%u", i); 05205 strncat(buf, num, buflen - strlen(buf) - 1); 05206 } 05207 } 05208 return buf; 05209 }
int ast_prod | ( | struct ast_channel * | chan | ) |
Send empty audio to prime a channel driver.
Definition at line 3200 of file channel.c.
References ast_channel::_state, ast_debug, AST_FRAME_VOICE, AST_FRIENDLY_OFFSET, ast_log(), AST_STATE_UP, ast_write(), chanlist::chan, ast_frame::data, LOG_WARNING, ast_channel::name, ast_frame::ptr, ast_channel::rawwriteformat, ast_frame::src, and ast_frame::subclass.
Referenced by ast_activate_generator().
03201 { 03202 struct ast_frame a = { AST_FRAME_VOICE }; 03203 char nothing[128]; 03204 03205 /* Send an empty audio frame to get things moving */ 03206 if (chan->_state != AST_STATE_UP) { 03207 ast_debug(1, "Prodding channel '%s'\n", chan->name); 03208 a.subclass = chan->rawwriteformat; 03209 a.data.ptr = nothing + AST_FRIENDLY_OFFSET; 03210 a.src = "ast_prod"; 03211 if (ast_write(chan, &a)) 03212 ast_log(LOG_WARNING, "Prodding channel '%s' failed\n", chan->name); 03213 } 03214 return 0; 03215 }
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 |
zero | on success | |
non-zero | on failure |
Definition at line 1063 of file channel.c.
References AST_FRAME_CONTROL, ast_queue_frame(), chanlist::chan, and f.
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(), HandleCallIncoming(), jingle_is_answered(), jingle_ringing_ack(), mgcp_call(), nbs_call(), phone_call(), pickup_do(), process_sdp(), receive_digit(), remote_hold(), send_cause2ast(), setup_rtp_connection(), skinny_call(), skinny_transfer(), skinny_unhold(), ss_thread(), unistim_call(), and update_state().
01064 { 01065 struct ast_frame f = { AST_FRAME_CONTROL, }; 01066 01067 f.subclass = control; 01068 01069 return ast_queue_frame(chan, &f); 01070 }
int ast_queue_control_data | ( | struct ast_channel * | chan, | |
enum ast_control_frame_type | control, | |||
const void * | data, | |||
size_t | datalen | |||
) |
Queue a control frame with payload.
chan | channel to queue frame onto | |
control | type of control frame | |
data | pointer to payload data to be included in frame | |
datalen | number of bytes of payload data |
0 | success | |
non-zero | failure |
The channel does not need to be locked before calling this function.
Definition at line 1073 of file channel.c.
References AST_FRAME_CONTROL, ast_queue_frame(), chanlist::chan, and f.
Referenced by change_t38_state(), dahdi_handle_event(), dahdi_hangup(), iax2_queue_control_data(), process_sdp(), and skinny_hold().
01075 { 01076 struct ast_frame f = { AST_FRAME_CONTROL, }; 01077 01078 f.subclass = control; 01079 f.data.ptr = (void *) data; 01080 f.datalen = datalen; 01081 01082 return ast_queue_frame(chan, &f); 01083 }
int ast_queue_frame | ( | struct ast_channel * | chan, | |
struct ast_frame * | f | |||
) |
Queue an outgoing frame.
Definition at line 1020 of file channel.c.
References __ast_queue_frame(), and chanlist::chan.
Referenced by __oh323_rtp_create(), __oh323_update_info(), action_atxfer(), agent_new(), alsa_call(), ast_channel_masquerade(), ast_channel_setwhentohangup_tv(), ast_do_masquerade(), ast_dsp_process(), ast_queue_control(), ast_queue_control_data(), ast_queue_hangup(), ast_queue_hangup_with_cause(), ast_softhangup_nolock(), cb_events(), cli_console_answer(), cli_console_dial(), cli_console_flash(), cli_console_sendtext(), console_answer(), console_call(), console_dial(), console_do_answer(), console_flash(), console_sendtext(), dahdi_queue_frame(), dictate_exec(), do_immediate_setup(), gtalk_handle_dtmf(), handle_keypad_button_message(), handle_request_info(), handle_request_invite(), handle_response_invite(), iax2_queue_frame(), jingle_handle_dtmf(), keypad_digit(), local_queue_frame(), mgcp_queue_frame(), oh323_simulate_dtmf_end(), oss_call(), process_sdp(), queue_dtmf_readq(), receive_digit(), receive_message(), rpt_call(), stream_monitor(), unistim_do_senddigit(), unistim_senddigit_end(), usbradio_read(), and wakeup_sub().
01021 { 01022 return __ast_queue_frame(chan, fin, 0); 01023 }
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 1025 of file channel.c.
References __ast_queue_frame(), and chanlist::chan.
Referenced by __ast_answer(), and ast_autoservice_stop().
01026 { 01027 return __ast_queue_frame(chan, fin, 1); 01028 }
int ast_queue_hangup | ( | struct ast_channel * | chan | ) |
Queue a hangup frame.
Definition at line 1031 of file channel.c.
References ast_channel::_softhangup, ast_channel_trylock, ast_channel_unlock, AST_CONTROL_HANGUP, AST_FRAME_CONTROL, ast_queue_frame(), AST_SOFTHANGUP_DEV, chanlist::chan, and f.
Referenced by cleanup_connection(), cli_console_hangup(), close_call(), gtalk_hangup_farend(), gtalk_is_answered(), handle_onhook_message(), handle_request_bye(), handle_request_cancel(), handle_soft_key_event_message(), iax2_destroy(), iax2_queue_hangup(), jingle_hangup_farend(), local_hangup(), and mgcp_queue_hangup().
01032 { 01033 struct ast_frame f = { AST_FRAME_CONTROL, AST_CONTROL_HANGUP }; 01034 /* Yeah, let's not change a lock-critical value without locking */ 01035 if (!ast_channel_trylock(chan)) { 01036 chan->_softhangup |= AST_SOFTHANGUP_DEV; 01037 ast_channel_unlock(chan); 01038 } 01039 return ast_queue_frame(chan, &f); 01040 }
int ast_queue_hangup_with_cause | ( | struct ast_channel * | chan, | |
int | cause | |||
) |
Queue a hangup frame with hangupcause set.
[in] | chan | channel to queue frame onto |
[in] | cause | the hangup cause |
Definition at line 1043 of file channel.c.
References ast_channel::_softhangup, ast_channel_trylock, ast_channel_unlock, AST_CONTROL_HANGUP, AST_FRAME_CONTROL, ast_queue_frame(), AST_SOFTHANGUP_DEV, chanlist::chan, f, and ast_channel::hangupcause.
Referenced by __oh323_update_info(), __sip_autodestruct(), close_call(), close_client(), console_hangup(), dahdi_handle_event(), handle_request_bye(), handle_response(), handle_response_invite(), handle_response_notify(), HandleCallOutgoing(), hangup_chan(), hangup_connection(), misdn_answer(), pri_hangup_all(), retrans_pkt(), and TransferCallStep1().
01044 { 01045 struct ast_frame f = { AST_FRAME_CONTROL, AST_CONTROL_HANGUP }; 01046 01047 if (cause >= 0) 01048 f.data.uint32 = cause; 01049 01050 /* Yeah, let's not change a lock-critical value without locking */ 01051 if (!ast_channel_trylock(chan)) { 01052 chan->_softhangup |= AST_SOFTHANGUP_DEV; 01053 if (cause < 0) 01054 f.data.uint32 = chan->hangupcause; 01055 01056 ast_channel_unlock(chan); 01057 } 01058 01059 return ast_queue_frame(chan, &f); 01060 }
int ast_raw_answer | ( | struct ast_channel * | chan, | |
int | cdr_answer | |||
) |
Answer a channel.
chan | channel to answer | |
cdr_answer | flag to control whether any associated CDR should be marked as 'answered' |
Unlike ast_answer(), this function will not wait for media flow to begin. The caller should be careful before sending media to the channel before incoming media arrives, as the outgoing media may be lost.
0 | on success | |
non-zero | on failure |
Definition at line 1681 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_indicate(), ast_setstate(), AST_STATE_RING, AST_STATE_RINGING, AST_STATE_UP, ast_test_flag, ast_channel::cdr, chanlist::chan, ast_channel::tech, and ast_channel::visible_indication.
Referenced by __ast_answer(), and ast_bridge_call().
01682 { 01683 int res = 0; 01684 01685 ast_channel_lock(chan); 01686 01687 /* You can't answer an outbound call */ 01688 if (ast_test_flag(chan, AST_FLAG_OUTGOING)) { 01689 ast_channel_unlock(chan); 01690 return 0; 01691 } 01692 01693 /* Stop if we're a zombie or need a soft hangup */ 01694 if (ast_test_flag(chan, AST_FLAG_ZOMBIE) || ast_check_hangup(chan)) { 01695 ast_channel_unlock(chan); 01696 return -1; 01697 } 01698 01699 ast_channel_unlock(chan); 01700 01701 switch (chan->_state) { 01702 case AST_STATE_RINGING: 01703 case AST_STATE_RING: 01704 ast_channel_lock(chan); 01705 if (chan->tech->answer) { 01706 res = chan->tech->answer(chan); 01707 } 01708 ast_setstate(chan, AST_STATE_UP); 01709 if (cdr_answer) { 01710 ast_cdr_answer(chan->cdr); 01711 } 01712 ast_channel_unlock(chan); 01713 break; 01714 case AST_STATE_UP: 01715 /* Calling ast_cdr_answer when it it has previously been called 01716 * is essentially a no-op, so it is safe. 01717 */ 01718 if (cdr_answer) { 01719 ast_cdr_answer(chan->cdr); 01720 } 01721 break; 01722 default: 01723 break; 01724 } 01725 01726 ast_indicate(chan, -1); 01727 chan->visible_indication = 0; 01728 01729 return res; 01730 }
struct ast_frame* ast_read | ( | struct ast_channel * | chan | ) |
Reads a frame.
chan | channel to read a frame from |
Definition at line 2939 of file channel.c.
References __ast_read(), and chanlist::chan.
Referenced by __adsi_transmit_messages(), __ast_answer(), __ast_play_and_record(), __ast_request_and_dial(), adsi_careful_send(), agent_ack_sleep(), agent_read(), ast_feature_request_and_dial(), 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_idle_thread(), do_waiting(), echo_exec(), eivr_comm(), find_cache(), handle_invite_replaces(), handle_recordfile(), handle_speechrecognize(), iax_park_thread(), ices_exec(), isAnsweringMachine(), launch_asyncagi(), manage_parkinglot(), masq_park_call(), measurenoise(), misdn_bridge(), monitor_dial(), mp3_exec(), NBScat_exec(), receive_dtmf_digits(), recordthread(), rpt(), run_agi(), send_tone_burst(), send_waveform_to_channel(), sendurl_exec(), speech_background(), ss_thread(), transmit_audio(), transmit_t38(), wait_for_answer(), wait_for_hangup(), wait_for_winner(), waitforring_exec(), and waitstream_core().
02940 { 02941 return __ast_read(chan, 0); 02942 }
struct ast_frame* ast_read_noaudio | ( | struct ast_channel * | chan | ) |
Reads a frame, returning AST_FRAME_NULL frame if audio.
chan | channel to read a frame from |
Definition at line 2944 of file channel.c.
References __ast_read(), and chanlist::chan.
Referenced by conf_run().
02945 { 02946 return __ast_read(chan, 1); 02947 }
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 3741 of file channel.c.
References ast_readstring_full().
Referenced by _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().
03742 { 03743 return ast_readstring_full(c, s, len, timeout, ftimeout, enders, -1, -1); 03744 }
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 3746 of file channel.c.
References ast_check_hangup(), AST_DIGIT_ANY, AST_FLAG_ZOMBIE, AST_GETDATA_COMPLETE, AST_GETDATA_EMPTY_END_TERMINATED, AST_GETDATA_FAILED, AST_GETDATA_INTERRUPTED, AST_GETDATA_TIMEOUT, ast_stopstream(), ast_test_flag, ast_waitfordigit_full(), ast_waitstream_full(), and ast_channel::stream.
Referenced by ast_app_getdata_full(), and ast_readstring().
03747 { 03748 int pos = 0; /* index in the buffer where we accumulate digits */ 03749 int to = ftimeout; 03750 03751 /* Stop if we're a zombie or need a soft hangup */ 03752 if (ast_test_flag(c, AST_FLAG_ZOMBIE) || ast_check_hangup(c)) 03753 return -1; 03754 if (!len) 03755 return -1; 03756 for (;;) { 03757 int d; 03758 if (c->stream) { 03759 d = ast_waitstream_full(c, AST_DIGIT_ANY, audiofd, ctrlfd); 03760 ast_stopstream(c); 03761 usleep(1000); 03762 if (!d) 03763 d = ast_waitfordigit_full(c, to, audiofd, ctrlfd); 03764 } else { 03765 d = ast_waitfordigit_full(c, to, audiofd, ctrlfd); 03766 } 03767 if (d < 0) 03768 return AST_GETDATA_FAILED; 03769 if (d == 0) { 03770 s[pos] = '\0'; 03771 return AST_GETDATA_TIMEOUT; 03772 } 03773 if (d == 1) { 03774 s[pos] = '\0'; 03775 return AST_GETDATA_INTERRUPTED; 03776 } 03777 if (strchr(enders, d) && (pos == 0)) { 03778 s[pos] = '\0'; 03779 return AST_GETDATA_EMPTY_END_TERMINATED; 03780 } 03781 if (!strchr(enders, d)) { 03782 s[pos++] = d; 03783 } 03784 if (strchr(enders, d) || (pos >= len)) { 03785 s[pos] = '\0'; 03786 return AST_GETDATA_COMPLETE; 03787 } 03788 to = timeout; 03789 } 03790 /* Never reached */ 03791 return 0; 03792 }
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 3081 of file channel.c.
References ast_free, ast_recvtext(), buf, and chanlist::chan.
Referenced by handle_recvchar().
03082 { 03083 int c; 03084 char *buf = ast_recvtext(chan, timeout); 03085 if (buf == NULL) 03086 return -1; /* error or timeout */ 03087 c = *(unsigned char *)buf; 03088 ast_free(buf); 03089 return c; 03090 }
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 3092 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(), buf, chanlist::chan, and f.
Referenced by ast_recvchar(), and handle_recvtext().
03093 { 03094 int res, done = 0; 03095 char *buf = NULL; 03096 03097 while (!done) { 03098 struct ast_frame *f; 03099 if (ast_check_hangup(chan)) 03100 break; 03101 res = ast_waitfor(chan, timeout); 03102 if (res <= 0) /* timeout or error */ 03103 break; 03104 timeout = res; /* update timeout */ 03105 f = ast_read(chan); 03106 if (f == NULL) 03107 break; /* no frame */ 03108 if (f->frametype == AST_FRAME_CONTROL && f->subclass == AST_CONTROL_HANGUP) 03109 done = 1; /* force a break */ 03110 else if (f->frametype == AST_FRAME_TEXT) { /* what we want */ 03111 buf = ast_strndup((char *) f->data.ptr, f->datalen); /* dup and break */ 03112 done = 1; 03113 } 03114 ast_frfree(f); 03115 } 03116 return buf; 03117 }
struct ast_channel* ast_request | ( | const char * | type, | |
int | format, | |||
void * | data, | |||
int * | status | |||
) |
Requests a channel.
type | type of channel to request | |
format | requested channel format (codec) | |
data | data to pass to the channel requester | |
status | status |
NULL | failure | |
non-NULL | channel on success |
Definition at line 3641 of file channel.c.
References AST_CAUSE_BEARERCAPABILITY_NOTAVAIL, AST_CAUSE_NOSUCHDRIVER, AST_CAUSE_NOTDEFINED, AST_FORMAT_AUDIO_MASK, AST_FORMAT_TEXT_MASK, AST_FORMAT_VIDEO_MASK, AST_LIST_TRAVERSE, ast_log(), AST_RWLIST_RDLOCK, AST_RWLIST_UNLOCK, ast_translator_best_choice(), ast_channel_tech::capabilities, capabilities, chanlist::chan, chanlist::list, LOG_WARNING, ast_channel_tech::requester, ast_channel::tech, and ast_channel_tech::type.
Referenced by __ast_request_and_dial(), agent_request(), ast_feature_request_and_dial(), attempt_reconnect(), begin_dial_channel(), build_conf(), chanavail_exec(), conf_run(), connect_link(), dial_exec_full(), do_forward(), findmeexec(), ring_entry(), rpt(), rpt_call(), rpt_exec(), and rpt_tele_thread().
03642 { 03643 struct chanlist *chan; 03644 struct ast_channel *c; 03645 int capabilities; 03646 int fmt; 03647 int res; 03648 int foo; 03649 int videoformat = format & AST_FORMAT_VIDEO_MASK; 03650 int textformat = format & AST_FORMAT_TEXT_MASK; 03651 03652 if (!cause) 03653 cause = &foo; 03654 *cause = AST_CAUSE_NOTDEFINED; 03655 03656 if (AST_RWLIST_RDLOCK(&channels)) { 03657 ast_log(LOG_WARNING, "Unable to lock channel list\n"); 03658 return NULL; 03659 } 03660 03661 AST_LIST_TRAVERSE(&backends, chan, list) { 03662 if (strcasecmp(type, chan->tech->type)) 03663 continue; 03664 03665 capabilities = chan->tech->capabilities; 03666 fmt = format & AST_FORMAT_AUDIO_MASK; 03667 if (fmt) { 03668 /* We have audio - is it possible to connect the various calls to each other? 03669 (Avoid this check for calls without audio, like text+video calls) 03670 */ 03671 res = ast_translator_best_choice(&fmt, &capabilities); 03672 if (res < 0) { 03673 ast_log(LOG_WARNING, "No translator path exists for channel type %s (native 0x%x) to 0x%x\n", type, chan->tech->capabilities, format); 03674 *cause = AST_CAUSE_BEARERCAPABILITY_NOTAVAIL; 03675 AST_RWLIST_UNLOCK(&channels); 03676 return NULL; 03677 } 03678 } 03679 AST_RWLIST_UNLOCK(&channels); 03680 if (!chan->tech->requester) 03681 return NULL; 03682 03683 if (!(c = chan->tech->requester(type, capabilities | videoformat | textformat, data, cause))) 03684 return NULL; 03685 03686 /* no need to generate a Newchannel event here; it is done in the channel_alloc call */ 03687 return c; 03688 } 03689 03690 ast_log(LOG_WARNING, "No channel type registered for '%s'\n", type); 03691 *cause = AST_CAUSE_NOSUCHDRIVER; 03692 AST_RWLIST_UNLOCK(&channels); 03693 03694 return NULL; 03695 }
struct ast_channel* ast_request_and_dial | ( | const char * | type, | |
int | format, | |||
void * | data, | |||
int | timeout, | |||
int * | reason, | |||
const char * | cid_num, | |||
const char * | cid_name | |||
) |
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 unsuccessful) | |
cid_num | Caller-ID Number | |
cid_name | Caller-ID Name (ascii) |
Definition at line 3636 of file channel.c.
References __ast_request_and_dial().
Referenced by ast_pbx_outgoing_exten().
03637 { 03638 return __ast_request_and_dial(type, format, data, timeout, outstate, cidnum, cidname, NULL); 03639 }
int ast_safe_sleep | ( | struct ast_channel * | chan, | |
int | ms | |||
) |
Wait for a specified 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 1271 of file channel.c.
References ast_safe_sleep_conditional(), and chanlist::chan.
Referenced by _ast_adsi_transmit_message_full(), alarmreceiver_exec(), ast_dtmf_stream(), ast_senddigit(), builtin_atxfer(), builtin_parkcall(), conf_run(), dictate_exec(), flash_exec(), function_ilink(), handle_callforward_button(), login_exec(), mgcp_ss(), milliwatt_exec(), misdn_check_l2l1(), old_milliwatt_exec(), park_call_exec(), pbx_builtin_wait(), play_moh_exec(), play_tone_pair(), playtone(), privacy_exec(), receive_ademco_contact_id(), rpt_call(), rpt_exec(), rpt_tele_thread(), send_morse(), send_tone_telemetry(), skinny_ss(), ss_thread(), testclient_exec(), testserver_exec(), try_calling(), wait_for_hangup(), wait_interval(), wait_moh_exec(), waituntil_exec(), and zapateller_exec().
01272 { 01273 return ast_safe_sleep_conditional(chan, ms, NULL, NULL); 01274 }
int ast_safe_sleep_conditional | ( | struct ast_channel * | chan, | |
int | ms, | |||
int(*)(void *) | cond, | |||
void * | data | |||
) |
Wait for a specified 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 1250 of file channel.c.
References ast_frfree, ast_read(), ast_waitfor(), chanlist::chan, and f.
Referenced by ast_safe_sleep(), and login_exec().
01251 { 01252 struct ast_frame *f; 01253 01254 while (ms > 0) { 01255 if (cond && ((*cond)(data) == 0)) 01256 return 0; 01257 ms = ast_waitfor(chan, ms); 01258 if (ms < 0) 01259 return -1; 01260 if (ms > 0) { 01261 f = ast_read(chan); 01262 if (!f) 01263 return -1; 01264 ast_frfree(f); 01265 } 01266 } 01267 return 0; 01268 }
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 1678 of file channel.h.
References timersub().
Referenced by aji_io_recv(), ast_stun_request(), dispatch_thread_handler(), do_monitor(), do_parking_thread(), and hidthread().
01679 { 01680 #ifdef __linux__ 01681 return select(nfds, rfds, wfds, efds, tvp); 01682 #else 01683 if (tvp) { 01684 struct timeval tv, tvstart, tvend, tvlen; 01685 int res; 01686 01687 tv = *tvp; 01688 gettimeofday(&tvstart, NULL); 01689 res = select(nfds, rfds, wfds, efds, tvp); 01690 gettimeofday(&tvend, NULL); 01691 timersub(&tvend, &tvstart, &tvlen); 01692 timersub(&tv, &tvlen, tvp); 01693 if (tvp->tv_sec < 0 || (tvp->tv_sec == 0 && tvp->tv_usec < 0)) { 01694 tvp->tv_sec = 0; 01695 tvp->tv_usec = 0; 01696 } 01697 return res; 01698 } 01699 else 01700 return select(nfds, rfds, wfds, efds, NULL); 01701 #endif 01702 }
int ast_senddigit | ( | struct ast_channel * | chan, | |
char | digit, | |||
unsigned int | duration | |||
) |
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 | |
duration | the duration of the digit ending in ms |
Definition at line 3190 of file channel.c.
References AST_DEFAULT_EMULATE_DTMF_DURATION, ast_safe_sleep(), ast_senddigit_begin(), ast_senddigit_end(), chanlist::chan, ast_channel_tech::send_digit_begin, and ast_channel::tech.
Referenced by ast_dtmf_stream(), dial_exec_full(), do_dtmf_phone(), manager_play_dtmf(), and rpt_call().
03191 { 03192 if (chan->tech->send_digit_begin) { 03193 ast_senddigit_begin(chan, digit); 03194 ast_safe_sleep(chan, (duration >= AST_DEFAULT_EMULATE_DTMF_DURATION ? duration : AST_DEFAULT_EMULATE_DTMF_DURATION)); 03195 } 03196 03197 return ast_senddigit_end(chan, digit, (duration >= AST_DEFAULT_EMULATE_DTMF_DURATION ? duration : AST_DEFAULT_EMULATE_DTMF_DURATION)); 03198 }
int ast_senddigit_begin | ( | 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 3132 of file channel.c.
References ast_debug, ast_playtones_start(), chanlist::chan, ast_channel::name, ast_channel_tech::send_digit_begin, and ast_channel::tech.
Referenced by agent_digit_begin(), ast_senddigit(), and ast_write().
03133 { 03134 /* Device does not support DTMF tones, lets fake 03135 * it by doing our own generation. */ 03136 static const char* dtmf_tones[] = { 03137 "941+1336", /* 0 */ 03138 "697+1209", /* 1 */ 03139 "697+1336", /* 2 */ 03140 "697+1477", /* 3 */ 03141 "770+1209", /* 4 */ 03142 "770+1336", /* 5 */ 03143 "770+1477", /* 6 */ 03144 "852+1209", /* 7 */ 03145 "852+1336", /* 8 */ 03146 "852+1477", /* 9 */ 03147 "697+1633", /* A */ 03148 "770+1633", /* B */ 03149 "852+1633", /* C */ 03150 "941+1633", /* D */ 03151 "941+1209", /* * */ 03152 "941+1477" /* # */ 03153 }; 03154 03155 if (!chan->tech->send_digit_begin) 03156 return 0; 03157 03158 if (!chan->tech->send_digit_begin(chan, digit)) 03159 return 0; 03160 03161 if (digit >= '0' && digit <='9') 03162 ast_playtones_start(chan, 0, dtmf_tones[digit-'0'], 0); 03163 else if (digit >= 'A' && digit <= 'D') 03164 ast_playtones_start(chan, 0, dtmf_tones[digit-'A'+10], 0); 03165 else if (digit == '*') 03166 ast_playtones_start(chan, 0, dtmf_tones[14], 0); 03167 else if (digit == '#') 03168 ast_playtones_start(chan, 0, dtmf_tones[15], 0); 03169 else { 03170 /* not handled */ 03171 ast_debug(1, "Unable to generate DTMF tone '%c' for '%s'\n", digit, chan->name); 03172 } 03173 03174 return 0; 03175 }
int ast_senddigit_end | ( | struct ast_channel * | chan, | |
char | digit, | |||
unsigned int | duration | |||
) |
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 | |
duration | the duration of the digit ending in ms |
Definition at line 3177 of file channel.c.
References ast_playtones_stop(), chanlist::chan, ast_channel::generator, ast_channel_tech::send_digit_end, and ast_channel::tech.
Referenced by agent_digit_end(), ast_senddigit(), and ast_write().
03178 { 03179 int res = -1; 03180 03181 if (chan->tech->send_digit_end) 03182 res = chan->tech->send_digit_end(chan, digit, duration); 03183 03184 if (res && chan->generator) 03185 ast_playtones_stop(chan); 03186 03187 return 0; 03188 }
int ast_sendtext | ( | struct ast_channel * | chan, | |
const char * | text | |||
) |
Sends text to a channel.
chan | channel to act upon | |
text | string of text to send on the channel |
0 | on success | |
-1 | on failure |
Definition at line 3119 of file channel.c.
References ast_check_hangup(), ast_clear_flag, AST_FLAG_BLOCKING, AST_FLAG_ZOMBIE, ast_test_flag, chanlist::chan, CHECK_BLOCKING, ast_channel_tech::send_text, and ast_channel::tech.
Referenced by action_sendtext(), agent_sendtext(), handle_sendtext(), send_newkey(), and sendtext_exec().
03120 { 03121 int res = 0; 03122 /* Stop if we're a zombie or need a soft hangup */ 03123 if (ast_test_flag(chan, AST_FLAG_ZOMBIE) || ast_check_hangup(chan)) 03124 return -1; 03125 CHECK_BLOCKING(chan); 03126 if (chan->tech->send_text) 03127 res = chan->tech->send_text(chan, text); 03128 ast_clear_flag(chan, AST_FLAG_BLOCKING); 03129 return res; 03130 }
void ast_set_callerid | ( | struct ast_channel * | chan, | |
const char * | cid_num, | |||
const char * | cid_name, | |||
const char * | cid_ani | |||
) |
Set caller ID number, name and ANI.
Definition at line 4298 of file channel.c.
References ast_channel_lock, ast_channel_unlock, ast_describe_caller_presentation(), ast_free, ast_strdup, chanlist::chan, ast_channel::cid, ast_callerid::cid_ani, ast_callerid::cid_name, ast_callerid::cid_num, ast_callerid::cid_pres, EVENT_FLAG_CALL, 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(), dial_exec_full(), do_forward(), findmeexec(), handle_setcallerid(), mgcp_ss(), read_config(), rpt_exec(), skinny_newcall(), and ss_thread().
04299 { 04300 ast_channel_lock(chan); 04301 04302 if (cid_num) { 04303 if (chan->cid.cid_num) 04304 ast_free(chan->cid.cid_num); 04305 chan->cid.cid_num = ast_strdup(cid_num); 04306 } 04307 if (cid_name) { 04308 if (chan->cid.cid_name) 04309 ast_free(chan->cid.cid_name); 04310 chan->cid.cid_name = ast_strdup(cid_name); 04311 } 04312 if (cid_ani) { 04313 if (chan->cid.cid_ani) 04314 ast_free(chan->cid.cid_ani); 04315 chan->cid.cid_ani = ast_strdup(cid_ani); 04316 } 04317 manager_event(EVENT_FLAG_CALL, "NewCallerid", 04318 "Channel: %s\r\n" 04319 "CallerIDNum: %s\r\n" 04320 "CallerIDName: %s\r\n" 04321 "Uniqueid: %s\r\n" 04322 "CID-CallingPres: %d (%s)\r\n", 04323 chan->name, 04324 S_OR(chan->cid.cid_num, ""), 04325 S_OR(chan->cid.cid_name, ""), 04326 chan->uniqueid, 04327 chan->cid.cid_pres, 04328 ast_describe_caller_presentation(chan->cid.cid_pres) 04329 ); 04330 04331 ast_channel_unlock(chan); 04332 }
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 3479 of file channel.c.
References chanlist::chan, ast_channel::rawreadformat, ast_channel::readformat, ast_channel::readtrans, and set_format().
Referenced by __ast_play_and_record(), __oh323_update_info(), _ast_adsi_transmit_message_full(), agent_call(), alarmreceiver_exec(), ast_channel_make_compatible_helper(), ast_do_masquerade(), attempt_reconnect(), background_detect_exec(), build_conf(), conf_run(), connect_link(), dictate_exec(), do_waiting(), eagi_exec(), echo_exec(), gtalk_rtp_read(), handle_recordfile(), handle_speechrecognize(), ices_exec(), isAnsweringMachine(), jingle_rtp_read(), login_exec(), measurenoise(), mgcp_rtp_read(), oh323_rtp_read(), old_milliwatt_exec(), process_sdp(), rpt(), rpt_exec(), setup_rtp_connection(), sip_rtp_read(), skinny_rtp_read(), socket_process(), speech_background(), transmit_audio(), and unistim_rtp_read().
03480 { 03481 return set_format(chan, fmt, &chan->rawreadformat, &chan->readformat, 03482 &chan->readtrans, 0); 03483 }
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 5211 of file channel.c.
References chan, 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().
05212 { 05213 struct ast_variable *cur; 05214 05215 for (cur = vars; cur; cur = cur->next) 05216 pbx_builtin_setvar_helper(chan, cur->name, cur->value); 05217 }
int ast_set_write_format | ( | struct ast_channel * | chan, | |
int | format | |||
) |
Sets write format on channel chan Set write format for channel to whichever component of "format" is best.
chan | channel to change | |
format | new format for writing |
Definition at line 3485 of file channel.c.
References chanlist::chan, ast_channel::rawwriteformat, set_format(), ast_channel::writeformat, and ast_channel::writetrans.
Referenced by __oh323_update_info(), _ast_adsi_transmit_message_full(), agent_call(), alarmreceiver_exec(), ast_channel_make_compatible_helper(), ast_channel_start_silence_generator(), ast_channel_stop_silence_generator(), ast_do_masquerade(), ast_openstream_full(), ast_stopstream(), attempt_reconnect(), build_conf(), chanspy_exec(), conf_run(), connect_link(), echo_exec(), extenspy_exec(), gtalk_rtp_read(), jingle_rtp_read(), linear_alloc(), linear_release(), login_exec(), mgcp_rtp_read(), moh_alloc(), moh_files_release(), moh_release(), mp3_exec(), NBScat_exec(), oh323_rtp_read(), old_milliwatt_exec(), playtones_alloc(), playtones_release(), process_sdp(), rpt(), rpt_exec(), send_waveform_to_channel(), setup_rtp_connection(), sip_rtp_read(), skinny_rtp_read(), socket_process(), tonepair_alloc(), tonepair_release(), transmit_audio(), and unistim_rtp_read().
03486 { 03487 return set_format(chan, fmt, &chan->rawwriteformat, &chan->writeformat, 03488 &chan->writetrans, 1); 03489 }
int ast_setstate | ( | struct ast_channel * | chan, | |
enum | ast_channel_state | |||
) |
Change the state of a channel.
Definition at line 4334 of file channel.c.
References ast_channel::_state, AST_CHANNEL_NAME, ast_copy_string(), AST_DEVICE_UNKNOWN, ast_devstate_changed_literal(), ast_state2str(), chanlist::chan, 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_raw_answer(), cb_events(), check_availability(), console_answer(), dahdi_answer(), dahdi_call(), dahdi_handle_event(), dahdi_indicate(), dahdi_read(), do_bridge_masquerade(), gtalk_call(), gtalk_newcall(), handle_invite_replaces(), handle_offhook_message(), handle_request_invite(), handle_response_invite(), handle_soft_key_event_message(), handle_stimulus_message(), iax2_call(), jingle_call(), jingle_newcall(), mgcp_answer(), mgcp_call(), mgcp_ss(), misdn_call(), misdn_indication(), nbs_call(), nbs_hangup(), oh323_answer(), 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(), unistim_answer(), unistim_call(), unistim_new(), unistim_ss(), update_state(), usbradio_answer(), and usbradio_call().
04335 { 04336 int oldstate = chan->_state; 04337 char name[AST_CHANNEL_NAME], *dashptr; 04338 04339 if (oldstate == state) 04340 return 0; 04341 04342 ast_copy_string(name, chan->name, sizeof(name)); 04343 if ((dashptr = strrchr(name, '-'))) { 04344 *dashptr = '\0'; 04345 } 04346 04347 chan->_state = state; 04348 04349 /* We have to pass AST_DEVICE_UNKNOWN here because it is entirely possible that the channel driver 04350 * for this channel is using the callback method for device state. If we pass in an actual state here 04351 * we override what they are saying the state is and things go amuck. */ 04352 ast_devstate_changed_literal(AST_DEVICE_UNKNOWN, name); 04353 04354 /* setstate used to conditionally report Newchannel; this is no more */ 04355 manager_event(EVENT_FLAG_CALL, 04356 "Newstate", 04357 "Channel: %s\r\n" 04358 "ChannelState: %d\r\n" 04359 "ChannelStateDesc: %s\r\n" 04360 "CallerIDNum: %s\r\n" 04361 "CallerIDName: %s\r\n" 04362 "Uniqueid: %s\r\n", 04363 chan->name, chan->_state, ast_state2str(chan->_state), 04364 S_OR(chan->cid.cid_num, ""), 04365 S_OR(chan->cid.cid_name, ""), 04366 chan->uniqueid); 04367 04368 return 0; 04369 }
int ast_settimeout | ( | struct ast_channel * | c, | |
unsigned int | rate, | |||
int(*)(const void *data) | func, | |||
void * | data | |||
) |
Enable or disable timer ticks for a channel.
rate | number of timer ticks per second |
Call this function with a rate of 0 to turn off the timer ticks
Definition at line 2287 of file channel.c.
References ast_channel_lock, ast_channel_unlock, ast_debug, ast_timer_get_max_rate(), ast_timer_set_rate(), ast_channel::timer, ast_channel::timingdata, ast_channel::timingfd, and ast_channel::timingfunc.
Referenced by ast_activate_generator(), ast_deactivate_generator(), ast_read_generator_actions(), ast_readaudio_callback(), and filestream_destructor().
02288 { 02289 int res; 02290 unsigned int real_rate = rate, max_rate; 02291 02292 ast_channel_lock(c); 02293 02294 if (c->timingfd == -1) { 02295 ast_channel_unlock(c); 02296 return -1; 02297 } 02298 02299 if (!func) { 02300 rate = 0; 02301 data = NULL; 02302 } 02303 02304 if (rate && rate > (max_rate = ast_timer_get_max_rate(c->timer))) { 02305 real_rate = max_rate; 02306 } 02307 02308 ast_debug(1, "Scheduling timer at (%u requested / %u actual) timer ticks per second\n", rate, real_rate); 02309 02310 res = ast_timer_set_rate(c->timer, real_rate); 02311 02312 c->timingfunc = func; 02313 c->timingdata = data; 02314 02315 ast_channel_unlock(c); 02316 02317 return res; 02318 }
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 515 of file channel.c.
Referenced by handle_request_options().
00516 { 00517 return shutting_down; 00518 }
int ast_softhangup | ( | struct ast_channel * | chan, | |
int | cause | |||
) |
Softly hangup up a channel.
chan | channel to be soft-hung-up | |
cause | Ast hangupcause for hangup |
Definition at line 1560 of file channel.c.
References ast_channel_lock, ast_channel_unlock, ast_softhangup_nolock(), and chanlist::chan.
Referenced by __ast_module_user_hangup_all(), __unload_module(), action_hangup(), agent_hangup(), agent_logoff(), ast_begin_shutdown(), ast_dial_join(), birdbath(), conf_free(), connect_link(), dahdi_handle_event(), flush_telem(), function_ilink(), handle_hangup(), handle_link_data(), handle_softhangup(), login_exec(), manager_park(), read_agent_config(), rpt(), rpt_call(), rpt_do_restart(), rpt_exec(), sla_handle_hold_event(), softhangup_exec(), start_spying(), startmon(), and unload_module().
01561 { 01562 int res; 01563 01564 ast_channel_lock(chan); 01565 res = ast_softhangup_nolock(chan, cause); 01566 ast_channel_unlock(chan); 01567 01568 return res; 01569 }
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 1547 of file channel.c.
References ast_channel::_softhangup, ast_debug, AST_FLAG_BLOCKING, ast_null_frame, ast_queue_frame(), ast_test_flag, ast_channel::blocker, chanlist::chan, and ast_channel::name.
Referenced by ast_async_goto(), ast_softhangup(), attempt_transfer(), check_rtp_timeout(), dahdi_softhangup_all(), oh323_indicate(), proc_session_timer(), sip_indicate(), and skinny_indicate().
01548 { 01549 ast_debug(1, "Soft-Hanging up channel '%s'\n", chan->name); 01550 /* Inform channel driver that we need to be hung up, if it cares */ 01551 chan->_softhangup |= cause; 01552 ast_queue_frame(chan, &ast_null_frame); 01553 /* Interrupt any poll call or such */ 01554 if (ast_test_flag(chan, AST_FLAG_BLOCKING)) 01555 pthread_kill(chan->blocker, SIGURG); 01556 return 0; 01557 }
const char* ast_state2str | ( | enum ast_channel_state | state | ) |
Gives the string form of a given channel state.
Definition at line 656 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(), buf, STATE2STR_BUFSIZE, and state2str_threadbuf.
Referenced by action_coreshowchannels(), agent_hangup(), ast_channel_alloc(), ast_do_masquerade(), ast_setstate(), attempt_transfer(), func_channel_read(), handle_chanlist(), handle_invite_replaces(), handle_showchan(), local_attended_transfer(), mgcp_new(), serialize_showchan(), and sip_hangup().
00657 { 00658 char *buf; 00659 00660 switch (state) { 00661 case AST_STATE_DOWN: 00662 return "Down"; 00663 case AST_STATE_RESERVED: 00664 return "Rsrvd"; 00665 case AST_STATE_OFFHOOK: 00666 return "OffHook"; 00667 case AST_STATE_DIALING: 00668 return "Dialing"; 00669 case AST_STATE_RING: 00670 return "Ring"; 00671 case AST_STATE_RINGING: 00672 return "Ringing"; 00673 case AST_STATE_UP: 00674 return "Up"; 00675 case AST_STATE_BUSY: 00676 return "Busy"; 00677 case AST_STATE_DIALING_OFFHOOK: 00678 return "Dialing Offhook"; 00679 case AST_STATE_PRERING: 00680 return "Pre-ring"; 00681 default: 00682 if (!(buf = ast_threadstorage_get(&state2str_threadbuf, STATE2STR_BUFSIZE))) 00683 return "Unknown"; 00684 snprintf(buf, STATE2STR_BUFSIZE, "Unknown (%d)", state); 00685 return buf; 00686 } 00687 }
int ast_str2cause | ( | const char * | name | ) |
Convert a symbolic hangup cause to number.
name | string form of the cause Returns the cause code |
Definition at line 642 of file channel.c.
References ARRAY_LEN, ast_cause::cause, and causes.
Referenced by pbx_builtin_hangup().
00643 { 00644 int x; 00645 00646 for (x = 0; x < ARRAY_LEN(causes); x++) 00647 if (!strncasecmp(causes[x].name, name, strlen(causes[x].name))) 00648 return causes[x].cause; 00649 00650 return -1; 00651 }
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 5086 of file channel.c.
References ast_frfree, ast_read(), ast_tonepair_start(), ast_waitfor(), chan, f, and ast_channel::generatordata.
Referenced by zapateller_exec().
05087 { 05088 int res; 05089 05090 if ((res = ast_tonepair_start(chan, freq1, freq2, duration, vol))) 05091 return res; 05092 05093 /* Give us some wiggle room */ 05094 while (chan->generatordata && ast_waitfor(chan, 100) >= 0) { 05095 struct ast_frame *f = ast_read(chan); 05096 if (f) 05097 ast_frfree(f); 05098 else 05099 return -1; 05100 } 05101 return 0; 05102 }
int ast_tonepair_start | ( | struct ast_channel * | chan, | |
int | freq1, | |||
int | freq2, | |||
int | duration, | |||
int | vol | |||
) |
Start a tone going
Definition at line 5068 of file channel.c.
References ast_activate_generator(), chan, tonepair_def::duration, tonepair_def::freq1, tonepair_def::freq2, tonepair, and tonepair_def::vol.
Referenced by ast_tonepair(), pbx_builtin_waitexten(), play_dialtone(), play_tone_pair(), rpt_tele_thread(), and sendnoise().
05069 { 05070 struct tonepair_def d = { 0, }; 05071 05072 d.freq1 = freq1; 05073 d.freq2 = freq2; 05074 d.duration = duration; 05075 d.vol = (vol < 1) ? 8192 : vol; /* force invalid to 8192 */ 05076 if (ast_activate_generator(chan, &tonepair, &d)) 05077 return -1; 05078 return 0; 05079 }
void ast_tonepair_stop | ( | struct ast_channel * | chan | ) |
Stop a tone from playing
Definition at line 5081 of file channel.c.
References ast_deactivate_generator(), and chan.
Referenced by sendnoise().
05082 { 05083 ast_deactivate_generator(chan); 05084 }
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.
Called by:
Definition at line 3723 of file channel.c.
References ast_channel_lock, ast_channel_unlock, ast_check_hangup(), AST_FLAG_ZOMBIE, ast_test_flag, chanlist::chan, ast_channel::tech, and ast_channel_tech::transfer.
Referenced by transfer_exec().
03724 { 03725 int res = -1; 03726 03727 /* Stop if we're a zombie or need a soft hangup */ 03728 ast_channel_lock(chan); 03729 if (!ast_test_flag(chan, AST_FLAG_ZOMBIE) && !ast_check_hangup(chan)) { 03730 if (chan->tech->transfer) { 03731 res = chan->tech->transfer(chan, dest); 03732 if (!res) 03733 res = 1; 03734 } else 03735 res = 0; 03736 } 03737 ast_channel_unlock(chan); 03738 return res; 03739 }
char* ast_transfercapability2str | ( | int | transfercapability | ) | const |
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 capability |
Definition at line 690 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().
00691 { 00692 switch (transfercapability) { 00693 case AST_TRANS_CAP_SPEECH: 00694 return "SPEECH"; 00695 case AST_TRANS_CAP_DIGITAL: 00696 return "DIGITAL"; 00697 case AST_TRANS_CAP_RESTRICTED_DIGITAL: 00698 return "RESTRICTED_DIGITAL"; 00699 case AST_TRANS_CAP_3_1K_AUDIO: 00700 return "3K1AUDIO"; 00701 case AST_TRANS_CAP_DIGITAL_W_TONES: 00702 return "DIGITAL_W_TONES"; 00703 case AST_TRANS_CAP_VIDEO: 00704 return "VIDEO"; 00705 default: 00706 return "UNKNOWN"; 00707 } 00708 }
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 2271 of file channel.c.
References ast_waitfor_nandfds().
Referenced by __adsi_transmit_messages(), __ast_answer(), __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_idle_thread(), do_waiting(), echo_exec(), handle_recordfile(), handle_speechrecognize(), ices_exec(), isAnsweringMachine(), launch_asyncagi(), measurenoise(), mp3_exec(), NBScat_exec(), receive_dtmf_digits(), recordthread(), send_tone_burst(), send_waveform_to_channel(), sendurl_exec(), speech_background(), ss_thread(), transmit_audio(), transmit_t38(), wait_for_hangup(), waitforring_exec(), and waitstream_core().
02272 { 02273 int oldms = ms; /* -1 if no timeout */ 02274 02275 ast_waitfor_nandfds(&c, 1, NULL, 0, NULL, NULL, &ms); 02276 if ((ms < 0) && (oldms < 0)) 02277 ms = 0; 02278 return ms; 02279 }
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.
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 2266 of file channel.c.
References ast_waitfor_nandfds().
Referenced by ast_feature_request_and_dial(), ast_udptl_bridge(), autoservice_run(), bridge_native_loop(), dahdi_bridge(), misdn_bridge(), monitor_dial(), rpt(), wait_for_answer(), and wait_for_winner().
02267 { 02268 return ast_waitfor_nandfds(c, n, NULL, 0, NULL, NULL, ms); 02269 }
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 1911 of file channel.c.
References ast_waitfor_nandfds().
Referenced by dundi_lookup_internal(), and dundi_precache_internal().
01912 { 01913 int winner = -1; 01914 ast_waitfor_nandfds(NULL, 0, fds, n, exception, &winner, ms); 01915 return winner; 01916 }
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.
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 1923 of file channel.c.
References ast_channel::_softhangup, ast_add_fd(), ast_channel_lock, ast_channel_unlock, ast_clear_flag, ast_do_masquerade(), AST_FLAG_BLOCKING, AST_FLAG_EXCEPTION, ast_log(), AST_MAX_FDS, ast_poll, ast_set_flag, AST_SOFTHANGUP_TIMEOUT, ast_tvcmp(), ast_tvdiff_ms(), ast_tvnow(), ast_tvsub(), ast_tvzero(), chanlist::chan, CHECK_BLOCKING, errno, and LOG_WARNING.
Referenced by ast_waitfor(), ast_waitfor_n(), ast_waitfor_n_fd(), ast_waitfordigit_full(), conf_run(), eivr_comm(), find_cache(), run_agi(), and waitstream_core().
01926 { 01927 struct timeval start = { 0 , 0 }; 01928 struct pollfd *pfds = NULL; 01929 int res; 01930 long rms; 01931 int x, y, max; 01932 int sz; 01933 struct timeval now = { 0, 0 }; 01934 struct timeval whentohangup = { 0, 0 }, diff; 01935 struct ast_channel *winner = NULL; 01936 struct fdmap { 01937 int chan; 01938 int fdno; 01939 } *fdmap = NULL; 01940 01941 if ((sz = n * AST_MAX_FDS + nfds)) { 01942 pfds = alloca(sizeof(*pfds) * sz); 01943 fdmap = alloca(sizeof(*fdmap) * sz); 01944 } 01945 01946 if (outfd) 01947 *outfd = -99999; 01948 if (exception) 01949 *exception = 0; 01950 01951 /* Perform any pending masquerades */ 01952 for (x = 0; x < n; x++) { 01953 ast_channel_lock(c[x]); 01954 if (c[x]->masq && ast_do_masquerade(c[x])) { 01955 ast_log(LOG_WARNING, "Masquerade failed\n"); 01956 *ms = -1; 01957 ast_channel_unlock(c[x]); 01958 return NULL; 01959 } 01960 if (!ast_tvzero(c[x]->whentohangup)) { 01961 if (ast_tvzero(whentohangup)) 01962 now = ast_tvnow(); 01963 diff = ast_tvsub(c[x]->whentohangup, now); 01964 if (diff.tv_sec < 0 || ast_tvzero(diff)) { 01965 /* Should already be hungup */ 01966 c[x]->_softhangup |= AST_SOFTHANGUP_TIMEOUT; 01967 ast_channel_unlock(c[x]); 01968 return c[x]; 01969 } 01970 if (ast_tvzero(whentohangup) || ast_tvcmp(diff, whentohangup) < 0) 01971 whentohangup = diff; 01972 } 01973 ast_channel_unlock(c[x]); 01974 } 01975 /* Wait full interval */ 01976 rms = *ms; 01977 if (!ast_tvzero(whentohangup)) { 01978 rms = whentohangup.tv_sec * 1000 + whentohangup.tv_usec / 1000; /* timeout in milliseconds */ 01979 if (*ms >= 0 && *ms < rms) /* original *ms still smaller */ 01980 rms = *ms; 01981 } 01982 /* 01983 * Build the pollfd array, putting the channels' fds first, 01984 * followed by individual fds. Order is important because 01985 * individual fd's must have priority over channel fds. 01986 */ 01987 max = 0; 01988 for (x = 0; x < n; x++) { 01989 for (y = 0; y < AST_MAX_FDS; y++) { 01990 fdmap[max].fdno = y; /* fd y is linked to this pfds */ 01991 fdmap[max].chan = x; /* channel x is linked to this pfds */ 01992 max += ast_add_fd(&pfds[max], c[x]->fds[y]); 01993 } 01994 CHECK_BLOCKING(c[x]); 01995 } 01996 /* Add the individual fds */ 01997 for (x = 0; x < nfds; x++) { 01998 fdmap[max].chan = -1; 01999 max += ast_add_fd(&pfds[max], fds[x]); 02000 } 02001 02002 if (*ms > 0) 02003 start = ast_tvnow(); 02004 02005 if (sizeof(int) == 4) { /* XXX fix timeout > 600000 on linux x86-32 */ 02006 do { 02007 int kbrms = rms; 02008 if (kbrms > 600000) 02009 kbrms = 600000; 02010 res = ast_poll(pfds, max, kbrms); 02011 if (!res) 02012 rms -= kbrms; 02013 } while (!res && (rms > 0)); 02014 } else { 02015 res = ast_poll(pfds, max, rms); 02016 } 02017 for (x = 0; x < n; x++) 02018 ast_clear_flag(c[x], AST_FLAG_BLOCKING); 02019 if (res < 0) { /* Simulate a timeout if we were interrupted */ 02020 if (errno != EINTR) 02021 *ms = -1; 02022 return NULL; 02023 } 02024 if (!ast_tvzero(whentohangup)) { /* if we have a timeout, check who expired */ 02025 now = ast_tvnow(); 02026 for (x = 0; x < n; x++) { 02027 if (!ast_tvzero(c[x]->whentohangup) && ast_tvcmp(c[x]->whentohangup, now) <= 0) { 02028 c[x]->_softhangup |= AST_SOFTHANGUP_TIMEOUT; 02029 if (winner == NULL) 02030 winner = c[x]; 02031 } 02032 } 02033 } 02034 if (res == 0) { /* no fd ready, reset timeout and done */ 02035 *ms = 0; /* XXX use 0 since we may not have an exact timeout. */ 02036 return winner; 02037 } 02038 /* 02039 * Then check if any channel or fd has a pending event. 02040 * Remember to check channels first and fds last, as they 02041 * must have priority on setting 'winner' 02042 */ 02043 for (x = 0; x < max; x++) { 02044 res = pfds[x].revents; 02045 if (res == 0) 02046 continue; 02047 if (fdmap[x].chan >= 0) { /* this is a channel */ 02048 winner = c[fdmap[x].chan]; /* override previous winners */ 02049 if (res & POLLPRI) 02050 ast_set_flag(winner, AST_FLAG_EXCEPTION); 02051 else 02052 ast_clear_flag(winner, AST_FLAG_EXCEPTION); 02053 winner->fdno = fdmap[x].fdno; 02054 } else { /* this is an fd */ 02055 if (outfd) 02056 *outfd = pfds[x].fd; 02057 if (exception) 02058 *exception = (res & POLLPRI) ? -1 : 0; 02059 winner = NULL; 02060 } 02061 } 02062 if (*ms > 0) { 02063 *ms -= ast_tvdiff_ms(ast_tvnow(), start); 02064 if (*ms < 0) 02065 *ms = 0; 02066 } 02067 return winner; 02068 }
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 2282 of file channel.c.
References ast_waitfordigit_full().
Referenced by _ast_adsi_get_cpeid(), _ast_adsi_get_cpeinfo(), _ast_adsi_print(), _ast_adsi_read_encoded_dtmf(), _ast_adsi_transmit_message_full(), _while_exec(), advanced_options(), 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_record_review(), read_exec(), read_newoption(), readexten_exec(), retrydial_exec(), select_item_menu(), select_item_seq(), sendnoise(), ss_thread(), testclient_exec(), testserver_exec(), vm_execmain(), vm_forwardoptions(), vm_instructions_en(), vm_options(), vm_tempgreeting(), wait_a_bit(), and wait_our_turn().
02283 { 02284 return ast_waitfordigit_full(c, ms, -1, -1); 02285 }
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 2320 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(), errno, f, and LOG_WARNING.
Referenced by ast_readstring_full(), ast_waitfordigit(), handle_getoption(), and handle_waitfordigit().
02321 { 02322 /* Stop if we're a zombie or need a soft hangup */ 02323 if (ast_test_flag(c, AST_FLAG_ZOMBIE) || ast_check_hangup(c)) 02324 return -1; 02325 02326 /* Only look for the end of DTMF, don't bother with the beginning and don't emulate things */ 02327 ast_set_flag(c, AST_FLAG_END_DTMF_ONLY); 02328 02329 /* Wait for a digit, no more than ms milliseconds total. */ 02330 02331 while (ms) { 02332 struct ast_channel *rchan; 02333 int outfd=-1; 02334 02335 errno = 0; 02336 rchan = ast_waitfor_nandfds(&c, 1, &cmdfd, (cmdfd > -1) ? 1 : 0, NULL, &outfd, &ms); 02337 02338 if (!rchan && outfd < 0 && ms) { 02339 if (errno == 0 || errno == EINTR) 02340 continue; 02341 ast_log(LOG_WARNING, "Wait failed (%s)\n", strerror(errno)); 02342 ast_clear_flag(c, AST_FLAG_END_DTMF_ONLY); 02343 return -1; 02344 } else if (outfd > -1) { 02345 /* The FD we were watching has something waiting */ 02346 ast_log(LOG_WARNING, "The FD we were waiting for has something waiting. Waitfordigit returning numeric 1\n"); 02347 ast_clear_flag(c, AST_FLAG_END_DTMF_ONLY); 02348 return 1; 02349 } else if (rchan) { 02350 int res; 02351 struct ast_frame *f = ast_read(c); 02352 if (!f) 02353 return -1; 02354 02355 switch (f->frametype) { 02356 case AST_FRAME_DTMF_BEGIN: 02357 break; 02358 case AST_FRAME_DTMF_END: 02359 res = f->subclass; 02360 ast_frfree(f); 02361 ast_clear_flag(c, AST_FLAG_END_DTMF_ONLY); 02362 return res; 02363 case AST_FRAME_CONTROL: 02364 switch (f->subclass) { 02365 case AST_CONTROL_HANGUP: 02366 ast_frfree(f); 02367 ast_clear_flag(c, AST_FLAG_END_DTMF_ONLY); 02368 return -1; 02369 case AST_CONTROL_RINGING: 02370 case AST_CONTROL_ANSWER: 02371 case AST_CONTROL_SRCUPDATE: 02372 /* Unimportant */ 02373 break; 02374 default: 02375 ast_log(LOG_WARNING, "Unexpected control subclass '%d'\n", f->subclass); 02376 break; 02377 } 02378 break; 02379 case AST_FRAME_VOICE: 02380 /* Write audio if appropriate */ 02381 if (audiofd > -1) { 02382 if (write(audiofd, f->data.ptr, f->datalen) < 0) { 02383 ast_log(LOG_WARNING, "write() failed: %s\n", strerror(errno)); 02384 } 02385 } 02386 default: 02387 /* Ignore */ 02388 break; 02389 } 02390 ast_frfree(f); 02391 } 02392 } 02393 02394 ast_clear_flag(c, AST_FLAG_END_DTMF_ONLY); 02395 02396 return 0; /* Time is up */ 02397 }
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.
Definition at line 1243 of file channel.c.
References chanlist::chan, and channel_find_locked().
Referenced by next_channel().
01245 { 01246 return channel_find_locked(chan, NULL, 0, context, exten); 01247 }
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 or uniqueid prefix (locks channel).
Definition at line 1230 of file channel.c.
References chanlist::chan, and channel_find_locked().
Referenced by my_ast_get_channel_by_name_locked(), next_channel(), and softhangup_exec().
01232 { 01233 return channel_find_locked(chan, name, namelen, NULL, NULL); 01234 }
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 3228 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_debug, ast_do_masquerade(), AST_FLAG_BLOCKING, AST_FLAG_WRITE_INT, AST_FLAG_ZOMBIE, AST_FORMAT_T140, AST_FRAME_CONTROL, AST_FRAME_DTMF_BEGIN, AST_FRAME_DTMF_END, ast_frame_dump(), AST_FRAME_HTML, AST_FRAME_IAX, AST_FRAME_MODEM, AST_FRAME_NULL, AST_FRAME_TEXT, AST_FRAME_VIDEO, AST_FRAME_VOICE, ast_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, chanlist::chan, 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_WARNING, ast_channel::masq, ast_channel::masqr, ast_channel::monitor, ast_channel::name, ast_channel::outsmpl, ast_frame::ptr, ast_channel::rawwriteformat, SEEK_FORCECUR, send_dtmf_event(), 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_text, ast_channel_tech::write_video, and ast_channel::writetrans.
Referenced by adsi_careful_send(), agent_write(), ast_prod(), ast_readaudio_callback(), ast_readvideo_callback(), ast_udptl_bridge(), ast_write_video(), bridge_native_loop(), conf_queue_dtmf(), conf_run(), dahdi_bridge(), dictate_exec(), echo_exec(), fax_generator_generate(), function_ilink(), gen_generate(), handle_jack_audio(), handle_link_data(), jb_get_and_deliver(), linear_generator(), milliwatt_generate(), misdn_bridge(), moh_files_generator(), moh_generate(), mp3_exec(), NBScat_exec(), rpt(), send_link_dtmf(), send_link_keyquery(), send_tone_burst(), send_usb_txt(), send_waveform_to_channel(), silence_generator_generate(), spy_generate(), t38_tx_packet_handler(), and wait_for_answer().
03229 { 03230 int res = -1; 03231 struct ast_frame *f = NULL, *f2 = NULL; 03232 int count = 0; 03233 03234 /*Deadlock avoidance*/ 03235 while(ast_channel_trylock(chan)) { 03236 /*cannot goto done since the channel is not locked*/ 03237 if(count++ > 10) { 03238 ast_debug(1, "Deadlock avoided for write to channel '%s'\n", chan->name); 03239 return 0; 03240 } 03241 usleep(1); 03242 } 03243 /* Stop if we're a zombie or need a soft hangup */ 03244 if (ast_test_flag(chan, AST_FLAG_ZOMBIE) || ast_check_hangup(chan)) 03245 goto done; 03246 03247 /* Handle any pending masquerades */ 03248 if (chan->masq && ast_do_masquerade(chan)) { 03249 ast_log(LOG_WARNING, "Failed to perform masquerade\n"); 03250 goto done; 03251 } 03252 if (chan->masqr) { 03253 res = 0; /* XXX explain, why 0 ? */ 03254 goto done; 03255 } 03256 if (chan->generatordata) { 03257 if (ast_test_flag(chan, AST_FLAG_WRITE_INT)) 03258 ast_deactivate_generator(chan); 03259 else { 03260 if (fr->frametype == AST_FRAME_DTMF_END) { 03261 /* There is a generator running while we're in the middle of a digit. 03262 * It's probably inband DTMF, so go ahead and pass it so it can 03263 * stop the generator */ 03264 ast_clear_flag(chan, AST_FLAG_BLOCKING); 03265 ast_channel_unlock(chan); 03266 res = ast_senddigit_end(chan, fr->subclass, fr->len); 03267 ast_channel_lock(chan); 03268 CHECK_BLOCKING(chan); 03269 } else if (fr->frametype == AST_FRAME_CONTROL && fr->subclass == AST_CONTROL_UNHOLD) { 03270 /* This is a side case where Echo is basically being called and the person put themselves on hold and took themselves off hold */ 03271 res = (chan->tech->indicate == NULL) ? 0 : 03272 chan->tech->indicate(chan, fr->subclass, fr->data.ptr, fr->datalen); 03273 } 03274 res = 0; /* XXX explain, why 0 ? */ 03275 goto done; 03276 } 03277 } 03278 /* High bit prints debugging */ 03279 if (chan->fout & DEBUGCHAN_FLAG) 03280 ast_frame_dump(chan->name, fr, ">>"); 03281 CHECK_BLOCKING(chan); 03282 switch (fr->frametype) { 03283 case AST_FRAME_CONTROL: 03284 res = (chan->tech->indicate == NULL) ? 0 : 03285 chan->tech->indicate(chan, fr->subclass, fr->data.ptr, fr->datalen); 03286 break; 03287 case AST_FRAME_DTMF_BEGIN: 03288 if (chan->audiohooks) { 03289 struct ast_frame *old_frame = fr; 03290 fr = ast_audiohook_write_list(chan, chan->audiohooks, AST_AUDIOHOOK_DIRECTION_WRITE, fr); 03291 if (old_frame != fr) 03292 f = fr; 03293 } 03294 send_dtmf_event(chan, "Sent", fr->subclass, "Yes", "No"); 03295 ast_clear_flag(chan, AST_FLAG_BLOCKING); 03296 ast_channel_unlock(chan); 03297 res = ast_senddigit_begin(chan, fr->subclass); 03298 ast_channel_lock(chan); 03299 CHECK_BLOCKING(chan); 03300 break; 03301 case AST_FRAME_DTMF_END: 03302 if (chan->audiohooks) { 03303 struct ast_frame *old_frame = fr; 03304 fr = ast_audiohook_write_list(chan, chan->audiohooks, AST_AUDIOHOOK_DIRECTION_WRITE, fr); 03305 if (old_frame != fr) 03306 f = fr; 03307 } 03308 send_dtmf_event(chan, "Sent", fr->subclass, "No", "Yes"); 03309 ast_clear_flag(chan, AST_FLAG_BLOCKING); 03310 ast_channel_unlock(chan); 03311 res = ast_senddigit_end(chan, fr->subclass, fr->len); 03312 ast_channel_lock(chan); 03313 CHECK_BLOCKING(chan); 03314 break; 03315 case AST_FRAME_TEXT: 03316 if (fr->subclass == AST_FORMAT_T140) { 03317 res = (chan->tech->write_text == NULL) ? 0 : 03318 chan->tech->write_text(chan, fr); 03319 } else { 03320 res = (chan->tech->send_text == NULL) ? 0 : 03321 chan->tech->send_text(chan, (char *) fr->data.ptr); 03322 } 03323 break; 03324 case AST_FRAME_HTML: 03325 res = (chan->tech->send_html == NULL) ? 0 : 03326 chan->tech->send_html(chan, fr->subclass, (char *) fr->data.ptr, fr->datalen); 03327 break; 03328 case AST_FRAME_VIDEO: 03329 /* XXX Handle translation of video codecs one day XXX */ 03330 res = (chan->tech->write_video == NULL) ? 0 : 03331 chan->tech->write_video(chan, fr); 03332 break; 03333 case AST_FRAME_MODEM: 03334 res = (chan->tech->write == NULL) ? 0 : 03335 chan->tech->write(chan, fr); 03336 break; 03337 case AST_FRAME_VOICE: 03338 if (chan->tech->write == NULL) 03339 break; /*! \todo XXX should return 0 maybe ? */ 03340 03341 /* If audiohooks are present, write the frame out */ 03342 if (chan->audiohooks) { 03343 struct ast_frame *old_frame = fr; 03344 fr = ast_audiohook_write_list(chan, chan->audiohooks, AST_AUDIOHOOK_DIRECTION_WRITE, fr); 03345 if (old_frame != fr) 03346 f2 = fr; 03347 } 03348 03349 /* If the frame is in the raw write format, then it's easy... just use the frame - otherwise we will have to translate */ 03350 if (fr->subclass == chan->rawwriteformat) 03351 f = fr; 03352 else 03353 f = (chan->writetrans) ? ast_translate(chan->writetrans, fr, 0) : fr; 03354 03355 if (!f) { 03356 res = 0; 03357 break; 03358 } 03359 03360 /* If Monitor is running on this channel, then we have to write frames out there too */ 03361 if (chan->monitor && chan->monitor->write_stream) { 03362 /* XXX must explain this code */ 03363 #ifndef MONITOR_CONSTANT_DELAY 03364 int jump = chan->insmpl - chan->outsmpl - 4 * f->samples; 03365 if (jump >= 0) { 03366 jump = chan->insmpl - chan->outsmpl; 03367 if (ast_seekstream(chan->monitor->write_stream, jump, SEEK_FORCECUR) == -1) 03368 ast_log(LOG_WARNING, "Failed to perform seek in monitoring write stream, synchronization between the files may be broken\n"); 03369 chan->outsmpl += jump + f->samples; 03370 } else 03371 chan->outsmpl += f->samples; 03372 #else 03373 int jump = chan->insmpl - chan->outsmpl; 03374 if (jump - MONITOR_DELAY >= 0) { 03375 if (ast_seekstream(chan->monitor->write_stream, jump - f->samples, SEEK_FORCECUR) == -1) 03376 ast_log(LOG_WARNING, "Failed to perform seek in monitoring write stream, synchronization between the files may be broken\n"); 03377 chan->outsmpl += jump; 03378 } else 03379 chan->outsmpl += f->samples; 03380 #endif 03381 if (chan->monitor->state == AST_MONITOR_RUNNING) { 03382 if (ast_writestream(chan->monitor->write_stream, f) < 0) 03383 ast_log(LOG_WARNING, "Failed to write data to channel monitor write stream\n"); 03384 } 03385 } 03386 03387 if (f) 03388 res = chan->tech->write(chan,f); 03389 else 03390 res = 0; 03391 break; 03392 case AST_FRAME_NULL: 03393 case AST_FRAME_IAX: 03394 /* Ignore these */ 03395 res = 0; 03396 break; 03397 default: 03398 /* At this point, fr is the incoming frame and f is NULL. Channels do 03399 * not expect to get NULL as a frame pointer and will segfault. Hence, 03400 * we output the original frame passed in. */ 03401 res = chan->tech->write(chan, fr); 03402 break; 03403 } 03404 03405 if (f && f != fr) 03406 ast_frfree(f); 03407 if (f2) 03408 ast_frfree(f2); 03409 ast_clear_flag(chan, AST_FLAG_BLOCKING); 03410 /* Consider a write failure to force a soft hangup */ 03411 if (res < 0) 03412 chan->_softhangup |= AST_SOFTHANGUP_DEV; 03413 else { 03414 chan->fout = FRAMECOUNT_INC(chan->fout); 03415 } 03416 done: 03417 ast_channel_unlock(chan); 03418 return res; 03419 }
int ast_write_text | ( | struct ast_channel * | chan, | |
struct ast_frame * | frame | |||
) |
Write text 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 |
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 3217 of file channel.c.
References ast_write(), chanlist::chan, ast_channel::tech, and ast_channel_tech::write_video.
03218 { 03219 int res; 03220 if (!chan->tech->write_video) 03221 return 0; 03222 res = ast_write(chan, fr); 03223 if (!res) 03224 res = 1; 03225 return res; 03226 }
const char* channelreloadreason2txt | ( | enum channelreloadreason | reason | ) |
Convert enum channelreloadreason to text string for manager event.
\ brief Convert channel reloadreason (ENUM) to text string for manager event
Definition at line 5299 of file channel.c.
References CHANNEL_CLI_RELOAD, CHANNEL_MODULE_LOAD, and CHANNEL_MODULE_RELOAD.
05300 { 05301 switch (reason) { 05302 case CHANNEL_MODULE_LOAD: 05303 return "LOAD (Channel module load)"; 05304 05305 case CHANNEL_MODULE_RELOAD: 05306 return "RELOAD (Channel module reload)"; 05307 05308 case CHANNEL_CLI_RELOAD: 05309 return "CLIRELOAD (Channel module reload by CLI command)"; 05310 05311 default: 05312 return "MANAGERRELOAD (Channel module reload by manager)"; 05313 } 05314 };
static void timersub | ( | struct timeval * | tvend, | |
struct timeval * | tvstart, | |||
struct timeval * | tvdiff | |||
) | [inline, static] |
Definition at line 1656 of file channel.h.
Referenced by ast_rtcp_write_rr(), ast_rtcp_write_sr(), and ast_select().
01657 { 01658 tvdiff->tv_sec = tvend->tv_sec - tvstart->tv_sec; 01659 tvdiff->tv_usec = tvend->tv_usec - tvstart->tv_usec; 01660 if (tvdiff->tv_usec < 0) { 01661 tvdiff->tv_sec --; 01662 tvdiff->tv_usec += 1000000; 01663 } 01664 01665 }
unsigned long global_fin |
The current value of the debug flags is stored in the two variables global_fin and global_fout (declared in main/channel.c)
Definition at line 85 of file channel.c.
Referenced by handle_core_set_debug_channel().
unsigned long global_fout |