Asterisk - The Open Source Telephony Project GIT-master-d856a3e
Data Structures | Macros | Enumerations | Functions | Variables
channel.c File Reference

Channel Management. More...

#include "asterisk.h"
#include "asterisk/_private.h"
#include <sys/time.h>
#include <signal.h>
#include <math.h>
#include "asterisk/paths.h"
#include "asterisk/pbx.h"
#include "asterisk/frame.h"
#include "asterisk/mod_format.h"
#include "asterisk/sched.h"
#include "asterisk/channel.h"
#include "asterisk/musiconhold.h"
#include "asterisk/say.h"
#include "asterisk/file.h"
#include "asterisk/cli.h"
#include "asterisk/translate.h"
#include "asterisk/manager.h"
#include "asterisk/chanvars.h"
#include "asterisk/linkedlists.h"
#include "asterisk/indications.h"
#include "asterisk/causes.h"
#include "asterisk/callerid.h"
#include "asterisk/utils.h"
#include "asterisk/lock.h"
#include "asterisk/app.h"
#include "asterisk/transcap.h"
#include "asterisk/devicestate.h"
#include "asterisk/threadstorage.h"
#include "asterisk/slinfactory.h"
#include "asterisk/audiohook.h"
#include "asterisk/framehook.h"
#include "asterisk/timing.h"
#include "asterisk/autochan.h"
#include "asterisk/stringfields.h"
#include "asterisk/global_datastores.h"
#include "asterisk/channel_internal.h"
#include "asterisk/features.h"
#include "asterisk/bridge.h"
#include "asterisk/test.h"
#include "asterisk/stasis_channels.h"
#include "asterisk/max_forwards.h"
#include "asterisk/stream.h"
#include "asterisk/message.h"
Include dependency graph for channel.c:

Go to the source code of this file.

Data Structures

struct  ast_channel_iterator
 
struct  ast_party_id_ies
 
struct  ast_party_name_ies
 
struct  ast_party_number_ies
 
struct  ast_party_redirecting_reason_ies
 
struct  ast_party_subaddress_ies
 
struct  ast_silence_generator
 
struct  backends
 the list of registered channel types More...
 
struct  causes_map
 map AST_CAUSE's to readable string representations More...
 
struct  chanlist
 List of channel drivers. More...
 
struct  external_vars
 
struct  manager_channel_variable
 List of channel variables to append to all channel-related events. More...
 
struct  namedgroup_member
 Named group member structure. More...
 
struct  plc_ds
 
struct  set_format_access
 
struct  suppress_data
 
struct  tonepair_def
 
struct  tonepair_state
 

Macros

#define AST_DEFAULT_EMULATE_DTMF_DURATION   100
 
#define AST_MIN_DTMF_GAP   45
 
#define DEFAULT_AMA_FLAGS   AST_AMA_DOCUMENTATION
 
#define DEFAULT_EMULATE_MF_DURATION   55
 
#define FORMAT   "%-15.15s %-40.40s %-13.13s %-13.13s %-13.13s %-13.13s\n"
 
#define STATE2STR_BUFSIZE   32
 

Enumerations

enum  {
  AST_CONNECTED_LINE_NUMBER , AST_CONNECTED_LINE_NAME , AST_CONNECTED_LINE_NUMBER_PLAN , AST_CONNECTED_LINE_ID_PRESENTATION ,
  AST_CONNECTED_LINE_SOURCE , AST_CONNECTED_LINE_SUBADDRESS , AST_CONNECTED_LINE_SUBADDRESS_TYPE , AST_CONNECTED_LINE_SUBADDRESS_ODD_EVEN ,
  AST_CONNECTED_LINE_SUBADDRESS_VALID , AST_CONNECTED_LINE_TAG , AST_CONNECTED_LINE_VERSION , AST_CONNECTED_LINE_NAME_VALID ,
  AST_CONNECTED_LINE_NAME_CHAR_SET , AST_CONNECTED_LINE_NAME_PRESENTATION , AST_CONNECTED_LINE_NUMBER_VALID , AST_CONNECTED_LINE_NUMBER_PRESENTATION ,
  AST_CONNECTED_LINE_PRIV_NUMBER , AST_CONNECTED_LINE_PRIV_NUMBER_PLAN , AST_CONNECTED_LINE_PRIV_NUMBER_VALID , AST_CONNECTED_LINE_PRIV_NUMBER_PRESENTATION ,
  AST_CONNECTED_LINE_PRIV_NAME , AST_CONNECTED_LINE_PRIV_NAME_VALID , AST_CONNECTED_LINE_PRIV_NAME_CHAR_SET , AST_CONNECTED_LINE_PRIV_NAME_PRESENTATION ,
  AST_CONNECTED_LINE_PRIV_SUBADDRESS , AST_CONNECTED_LINE_PRIV_SUBADDRESS_TYPE , AST_CONNECTED_LINE_PRIV_SUBADDRESS_ODD_EVEN , AST_CONNECTED_LINE_PRIV_SUBADDRESS_VALID ,
  AST_CONNECTED_LINE_PRIV_TAG
}
 Element identifiers for connected line indication frame data. More...
 
enum  {
  AST_REDIRECTING_FROM_NUMBER , AST_REDIRECTING_FROM_NAME , AST_REDIRECTING_FROM_NUMBER_PLAN , AST_REDIRECTING_FROM_ID_PRESENTATION ,
  AST_REDIRECTING_TO_NUMBER , AST_REDIRECTING_TO_NAME , AST_REDIRECTING_TO_NUMBER_PLAN , AST_REDIRECTING_TO_ID_PRESENTATION ,
  AST_REDIRECTING_REASON_CODE , AST_REDIRECTING_COUNT , AST_REDIRECTING_FROM_SUBADDRESS , AST_REDIRECTING_FROM_SUBADDRESS_TYPE ,
  AST_REDIRECTING_FROM_SUBADDRESS_ODD_EVEN , AST_REDIRECTING_FROM_SUBADDRESS_VALID , AST_REDIRECTING_TO_SUBADDRESS , AST_REDIRECTING_TO_SUBADDRESS_TYPE ,
  AST_REDIRECTING_TO_SUBADDRESS_ODD_EVEN , AST_REDIRECTING_TO_SUBADDRESS_VALID , AST_REDIRECTING_FROM_TAG , AST_REDIRECTING_TO_TAG ,
  AST_REDIRECTING_VERSION , AST_REDIRECTING_FROM_NAME_VALID , AST_REDIRECTING_FROM_NAME_CHAR_SET , AST_REDIRECTING_FROM_NAME_PRESENTATION ,
  AST_REDIRECTING_FROM_NUMBER_VALID , AST_REDIRECTING_FROM_NUMBER_PRESENTATION , AST_REDIRECTING_TO_NAME_VALID , AST_REDIRECTING_TO_NAME_CHAR_SET ,
  AST_REDIRECTING_TO_NAME_PRESENTATION , AST_REDIRECTING_TO_NUMBER_VALID , AST_REDIRECTING_TO_NUMBER_PRESENTATION , AST_REDIRECTING_ORIG_NUMBER ,
  AST_REDIRECTING_ORIG_NUMBER_VALID , AST_REDIRECTING_ORIG_NUMBER_PLAN , AST_REDIRECTING_ORIG_NUMBER_PRESENTATION , AST_REDIRECTING_ORIG_NAME ,
  AST_REDIRECTING_ORIG_NAME_VALID , AST_REDIRECTING_ORIG_NAME_CHAR_SET , AST_REDIRECTING_ORIG_NAME_PRESENTATION , AST_REDIRECTING_ORIG_SUBADDRESS ,
  AST_REDIRECTING_ORIG_SUBADDRESS_TYPE , AST_REDIRECTING_ORIG_SUBADDRESS_ODD_EVEN , AST_REDIRECTING_ORIG_SUBADDRESS_VALID , AST_REDIRECTING_ORIG_TAG ,
  AST_REDIRECTING_ORIG_REASON_CODE , AST_REDIRECTING_PRIV_TO_NUMBER , AST_REDIRECTING_PRIV_TO_NUMBER_PLAN , AST_REDIRECTING_PRIV_TO_NUMBER_VALID ,
  AST_REDIRECTING_PRIV_TO_NUMBER_PRESENTATION , AST_REDIRECTING_PRIV_TO_NAME , AST_REDIRECTING_PRIV_TO_NAME_VALID , AST_REDIRECTING_PRIV_TO_NAME_CHAR_SET ,
  AST_REDIRECTING_PRIV_TO_NAME_PRESENTATION , AST_REDIRECTING_PRIV_TO_SUBADDRESS , AST_REDIRECTING_PRIV_TO_SUBADDRESS_TYPE , AST_REDIRECTING_PRIV_TO_SUBADDRESS_ODD_EVEN ,
  AST_REDIRECTING_PRIV_TO_SUBADDRESS_VALID , AST_REDIRECTING_PRIV_TO_TAG , AST_REDIRECTING_PRIV_FROM_NUMBER , AST_REDIRECTING_PRIV_FROM_NUMBER_PLAN ,
  AST_REDIRECTING_PRIV_FROM_NUMBER_VALID , AST_REDIRECTING_PRIV_FROM_NUMBER_PRESENTATION , AST_REDIRECTING_PRIV_FROM_NAME , AST_REDIRECTING_PRIV_FROM_NAME_VALID ,
  AST_REDIRECTING_PRIV_FROM_NAME_CHAR_SET , AST_REDIRECTING_PRIV_FROM_NAME_PRESENTATION , AST_REDIRECTING_PRIV_FROM_SUBADDRESS , AST_REDIRECTING_PRIV_FROM_SUBADDRESS_TYPE ,
  AST_REDIRECTING_PRIV_FROM_SUBADDRESS_ODD_EVEN , AST_REDIRECTING_PRIV_FROM_SUBADDRESS_VALID , AST_REDIRECTING_PRIV_FROM_TAG , AST_REDIRECTING_PRIV_ORIG_NUMBER ,
  AST_REDIRECTING_PRIV_ORIG_NUMBER_VALID , AST_REDIRECTING_PRIV_ORIG_NUMBER_PLAN , AST_REDIRECTING_PRIV_ORIG_NUMBER_PRESENTATION , AST_REDIRECTING_PRIV_ORIG_NAME ,
  AST_REDIRECTING_PRIV_ORIG_NAME_VALID , AST_REDIRECTING_PRIV_ORIG_NAME_CHAR_SET , AST_REDIRECTING_PRIV_ORIG_NAME_PRESENTATION , AST_REDIRECTING_PRIV_ORIG_SUBADDRESS ,
  AST_REDIRECTING_PRIV_ORIG_SUBADDRESS_TYPE , AST_REDIRECTING_PRIV_ORIG_SUBADDRESS_ODD_EVEN , AST_REDIRECTING_PRIV_ORIG_SUBADDRESS_VALID , AST_REDIRECTING_PRIV_ORIG_TAG ,
  AST_REDIRECTING_REASON_STR , AST_REDIRECTING_ORIG_REASON_STR
}
 Element identifiers for redirecting indication frame data. More...
 
enum  DtmfDirection { DTMF_RECEIVED , DTMF_SENT }
 

Functions

int __ast_answer (struct ast_channel *chan, unsigned int delay)
 Answer a channel, with a selectable delay before returning. More...
 
static void __ast_change_name_nolink (struct ast_channel *chan, const char *newname)
 this function simply changes the name of the channel and issues a manager_event with out unlinking and linking the channel from the ao2_container. This should only be used when the channel has already been unlinked from the ao2_container. More...
 
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 struct ast_assigned_ids *assignedids, const struct ast_channel *requestor, enum ama_flags amaflag, struct ast_endpoint *endpoint, const char *file, int line, const char *function, const char *name_fmt,...)
 Create a channel structure. More...
 
static struct ast_channel__ast_channel_alloc_ap (int needqueue, int state, const char *cid_num, const char *cid_name, const char *acctcode, const char *exten, const char *context, const struct ast_assigned_ids *assignedids, const struct ast_channel *requestor, enum ama_flags amaflag, struct ast_endpoint *endpoint, struct ast_channel_initializers *initializers, const char *file, int line, const char *function, const char *name_fmt, va_list ap)
 Create a new channel structure. More...
 
struct ast_channel__ast_channel_alloc_with_initializers (int needqueue, int state, const char *cid_num, const char *cid_name, const char *acctcode, const char *exten, const char *context, const struct ast_assigned_ids *assignedids, const struct ast_channel *requestor, enum ama_flags amaflag, struct ast_endpoint *endpoint, struct ast_channel_initializers *initializers, const char *file, int line, const char *function, const char *name_fmt,...)
 Create a channel structure. More...
 
struct ast_channel__ast_dummy_channel_alloc (const char *file, int line, const char *function)
 
static int __ast_queue_frame (struct ast_channel *chan, struct ast_frame *fin, int head, struct ast_frame *after)
 
static struct ast_frame__ast_read (struct ast_channel *chan, int dropaudio, int dropnondefault)
 
struct ast_channel__ast_request_and_dial (const char *type, struct ast_format_cap *cap, const struct ast_assigned_ids *assignedids, const struct ast_channel *requestor, const char *addr, int timeout, int *outstate, const char *cid_num, const char *cid_name, struct outgoing_helper *oh)
 Request a channel of a given type, with data as optional information used by the low level module and attempt to place a call on it. More...
 
static void __init_state2str_threadbuf (void)
 
static void adjust_frame_for_plc (struct ast_channel *chan, struct ast_frame *frame, struct ast_datastore *datastore)
 
static void apply_plc (struct ast_channel *chan, struct ast_frame *frame)
 
int ast_activate_generator (struct ast_channel *chan, struct ast_generator *gen, void *params)
 
int ast_active_channels (void)
 returns number of active/allocated channels More...
 
int ast_answer (struct ast_channel *chan)
 Answer a channel. More...
 
int ast_auto_answer (struct ast_channel *chan)
 Answer a channel, if it's not already answered. More...
 
int ast_call (struct ast_channel *chan, const char *addr, int timeout)
 Make a call. More...
 
struct ast_channelast_call_forward (struct ast_channel *caller, struct ast_channel *orig, int *timeout, struct ast_format_cap *cap, struct outgoing_helper *oh, int *outstate)
 Forwards a call to a new channel specified by the original channel's call_forward str. If possible, the new forwarded channel is created and returned while the original one is terminated. More...
 
const char * ast_cause2str (int cause)
 Gives the string form of a given hangup cause. More...
 
void ast_change_name (struct ast_channel *chan, const char *newname)
 Change channel name. More...
 
const char * ast_channel_amaflags2string (enum ama_flags flag)
 Convert the enum representation of an AMA flag to a string representation. More...
 
struct ast_channelast_channel_bridge_peer (struct ast_channel *chan)
 Get the channel's bridge peer only if the bridge is two-party. More...
 
static int ast_channel_by_exten_cb (void *obj, void *arg, void *data, int flags)
 
static int ast_channel_by_name_cb (void *obj, void *arg, void *data, int flags)
 
static int ast_channel_by_uniqueid_cb (void *obj, void *arg, void *data, int flags)
 
struct ast_channelast_channel_callback (ao2_callback_data_fn *cb_fn, void *arg, void *data, int ao2_flags)
 Call a function with every active channel. More...
 
int ast_channel_cc_params_init (struct ast_channel *chan, const struct ast_cc_config_params *base_params)
 Set up datastore with CCSS parameters for a channel. More...
 
void ast_channel_clear_flag (struct ast_channel *chan, unsigned int flag)
 Clear a flag on a channel. More...
 
void ast_channel_clear_softhangup (struct ast_channel *chan, int flag)
 Clear a set of softhangup flags from a channel. More...
 
static int ast_channel_cmp_cb (void *obj, void *arg, int flags)
 
int ast_channel_cmpwhentohangup_tv (struct ast_channel *chan, struct timeval offset)
 Compare a offset with when to hangup channel. More...
 
int ast_channel_connected_line_sub (struct ast_channel *autoservice_chan, struct ast_channel *sub_chan, const void *connected_info, int is_frame)
 Run a connected line interception subroutine and update a channel's connected line information. More...
 
int ast_channel_datastore_add (struct ast_channel *chan, struct ast_datastore *datastore)
 Add a datastore to a channel. More...
 
struct ast_datastoreast_channel_datastore_find (struct ast_channel *chan, const struct ast_datastore_info *info, const char *uid)
 Find a datastore on a channel. More...
 
int ast_channel_datastore_inherit (struct ast_channel *from, struct ast_channel *to)
 Inherit datastores from a parent to a child. More...
 
int ast_channel_datastore_remove (struct ast_channel *chan, struct ast_datastore *datastore)
 Remove a datastore from a channel. More...
 
int ast_channel_defer_dtmf (struct ast_channel *chan)
 Set defer DTMF flag on channel. More...
 
static void ast_channel_destructor (void *obj)
 Free a channel structure. More...
 
int ast_channel_early_bridge (struct ast_channel *c0, struct ast_channel *c1)
 Bridge two channels together (early) More...
 
void ast_channel_end_dtmf (struct ast_channel *chan, char digit, struct timeval start, const char *why)
 Simulate a DTMF end on a broken bridge channel. More...
 
enum ast_channel_error ast_channel_errno (void)
 Get error code for latest channel operation. More...
 
int ast_channel_feature_hooks_append (struct ast_channel *chan, struct ast_bridge_features *features)
 Appends to the channel-attached features a channel has access to upon being bridged. More...
 
struct ast_bridge_featuresast_channel_feature_hooks_get (struct ast_channel *chan)
 Gets the channel-attached features a channel has access to upon being bridged. More...
 
int ast_channel_feature_hooks_replace (struct ast_channel *chan, struct ast_bridge_features *features)
 Sets the channel-attached features a channel has access to upon being bridged. More...
 
struct varsheadast_channel_get_ari_vars (struct ast_channel *chan)
 Gets the variables for a given channel, as specified by ast_channel_set_ari_vars(). More...
 
struct ast_bridgeast_channel_get_bridge (const struct ast_channel *chan)
 Get the bridge associated with a channel. More...
 
struct ast_bridge_channelast_channel_get_bridge_channel (struct ast_channel *chan)
 Get a reference to the channel's bridge pointer. More...
 
struct ast_channelast_channel_get_by_exten (const char *exten, const char *context)
 Find a channel by extension and context. More...
 
struct ast_channelast_channel_get_by_name (const char *name)
 Find a channel by name. More...
 
struct ast_channelast_channel_get_by_name_prefix (const char *name, size_t name_len)
 Find a channel by a name prefix. More...
 
int ast_channel_get_cc_agent_type (struct ast_channel *chan, char *agent_type, size_t size)
 Find the appropriate CC agent type to use given a channel. More...
 
struct ast_cc_config_paramsast_channel_get_cc_config_params (struct ast_channel *chan)
 Get the CCSS parameters from a channel. More...
 
int ast_channel_get_device_name (struct ast_channel *chan, char *device_name, size_t name_buffer_length)
 Get a device name given its channel structure. More...
 
int ast_channel_get_duration (struct ast_channel *chan)
 Obtain how long the channel since the channel was created. More...
 
int64_t ast_channel_get_duration_ms (struct ast_channel *chan)
 Obtain how long it's been, in milliseconds, since the channel was created. More...
 
int ast_channel_get_intercept_mode (void)
 Am I currently running an intercept dialplan routine. More...
 
struct varsheadast_channel_get_manager_vars (struct ast_channel *chan)
 Gets the variables for a given channel, as specified by ast_channel_set_manager_vars(). More...
 
int ast_channel_get_up_time (struct ast_channel *chan)
 Obtain how long it has been since the channel was answered. More...
 
int64_t ast_channel_get_up_time_ms (struct ast_channel *chan)
 Obtain how long it has been since the channel was answered in ms. More...
 
struct varsheadast_channel_get_vars (struct ast_channel *chan)
 Gets the variables for a given channel, as set using pbx_builtin_setvar_helper(). More...
 
void ast_channel_hangupcause_hash_set (struct ast_channel *chan, const struct ast_control_pvt_cause_code *cause_code, int datalen)
 Sets the HANGUPCAUSE hash and optionally the SIP_CAUSE hash on the given channel. More...
 
int ast_channel_has_ari_vars (void)
 Return whether or not any ARI variables have been set. More...
 
int ast_channel_has_audio_frame_or_monitor (struct ast_channel *chan)
 Check if the channel has active audiohooks, active framehooks, or a monitor. More...
 
int ast_channel_has_hook_requiring_audio (struct ast_channel *chan)
 Check if the channel has any active hooks that require audio. More...
 
int ast_channel_has_manager_vars (void)
 Return whether or not any manager variables have been set. More...
 
static int ast_channel_hash_cb (const void *obj, const int flags)
 
void ast_channel_inherit_variables (const struct ast_channel *parent, struct ast_channel *child)
 Inherits channel variable from parent to child channel. More...
 
int ast_channel_is_bridged (const struct ast_channel *chan)
 Determine if a channel is in a bridge. More...
 
int ast_channel_is_leaving_bridge (struct ast_channel *chan)
 Determine if a channel is leaving a bridge, but not hung up. More...
 
struct ast_channel_iteratorast_channel_iterator_all_new (void)
 Create a new channel iterator. More...
 
struct ast_channel_iteratorast_channel_iterator_by_exten_new (const char *exten, const char *context)
 Create a new channel iterator based on extension. More...
 
struct ast_channel_iteratorast_channel_iterator_by_name_new (const char *name, size_t name_len)
 Create a new channel iterator based on name. More...
 
struct ast_channel_iteratorast_channel_iterator_destroy (struct ast_channel_iterator *i)
 Destroy a channel iterator. More...
 
struct ast_channelast_channel_iterator_next (struct ast_channel_iterator *i)
 Get the next channel for a channel iterator. More...
 
int ast_channel_make_compatible (struct ast_channel *chan, struct ast_channel *peer)
 Make the frame formats of two channels compatible. More...
 
static int ast_channel_make_compatible_helper (struct ast_channel *from, struct ast_channel *to)
 Set up translation from one channel to another. More...
 
int ast_channel_move (struct ast_channel *dest, struct ast_channel *source)
 Move a channel from its current location to a new location. More...
 
void ast_channel_name_to_dial_string (char *channel_name)
 Removes the trailing identifiers from a channel name string. More...
 
int ast_channel_queryoption (struct ast_channel *chan, int option, void *data, int *datalen, int block)
 Checks the value of an option. More...
 
void ast_channel_queue_connected_line_update (struct ast_channel *chan, const struct ast_party_connected_line *connected, const struct ast_set_party_connected_line *update)
 Queue a connected line update frame on a channel. More...
 
void ast_channel_queue_redirecting_update (struct ast_channel *chan, const struct ast_party_redirecting *redirecting, const struct ast_set_party_redirecting *update)
 Queue a redirecting update frame on a channel. More...
 
const char * ast_channel_reason2str (int reason)
 return an english explanation of the code returned thru __ast_request_and_dial's 'outstate' argument More...
 
int ast_channel_redirecting_sub (struct ast_channel *autoservice_chan, struct ast_channel *sub_chan, const void *redirecting_info, int is_frame)
 Run a redirecting interception subroutine and update a channel's redirecting information. More...
 
int ast_channel_register (const struct ast_channel_tech *tech)
 Register a new telephony channel in Asterisk. More...
 
struct ast_channelast_channel_release (struct ast_channel *chan)
 Unlink and release reference to a channel. More...
 
void ast_channel_req_accountcodes (struct ast_channel *chan, const struct ast_channel *requestor, enum ast_channel_requestor_relationship relationship)
 Setup new channel accountcodes from the requestor channel after ast_request(). More...
 
void ast_channel_req_accountcodes_precious (struct ast_channel *chan, const struct ast_channel *requestor, enum ast_channel_requestor_relationship relationship)
 Setup new channel accountcodes from the requestor channel after ast_request(). More...
 
int ast_channel_request_stream_topology_change (struct ast_channel *chan, struct ast_stream_topology *topology, void *change_source)
 Request that the stream topology of a channel change. More...
 
int ast_channel_sendhtml (struct ast_channel *chan, int subclass, const char *data, int datalen)
 Sends HTML on given channel Send HTML or URL on link. More...
 
int ast_channel_sendurl (struct ast_channel *chan, const char *url)
 Sends a URL on a given link Send URL on link. More...
 
void ast_channel_set_ari_vars (size_t varc, char **vars)
 Sets the variables to be stored in the ari_vars field of all snapshots. More...
 
void ast_channel_set_caller (struct ast_channel *chan, const struct ast_party_caller *caller, const struct ast_set_party_caller *update)
 Set the caller id information in the Asterisk channel. More...
 
void ast_channel_set_caller_event (struct ast_channel *chan, const struct ast_party_caller *caller, const struct ast_set_party_caller *update)
 Set the caller id information in the Asterisk channel and generate an AMI event if the caller id name or number changed. More...
 
void ast_channel_set_connected_line (struct ast_channel *chan, const struct ast_party_connected_line *connected, const struct ast_set_party_connected_line *update)
 Set the connected line information in the Asterisk channel. More...
 
void ast_channel_set_fd (struct ast_channel *chan, int which, int fd)
 
void ast_channel_set_flag (struct ast_channel *chan, unsigned int flag)
 Set a flag on a channel. More...
 
void ast_channel_set_manager_vars (size_t varc, char **vars)
 Sets the variables to be stored in the manager_vars field of all snapshots. More...
 
void ast_channel_set_redirecting (struct ast_channel *chan, const struct ast_party_redirecting *redirecting, const struct ast_set_party_redirecting *update)
 Set the redirecting id information in the Asterisk channel. More...
 
int ast_channel_setoption (struct ast_channel *chan, int option, void *data, int datalen, int block)
 Sets an option on a channel. More...
 
void ast_channel_setwhentohangup_tv (struct ast_channel *chan, struct timeval offset)
 Set when to hangup channel. More...
 
static int ast_channel_softhangup_cb (void *obj, void *arg, int flags)
 
void ast_channel_softhangup_withcause_locked (struct ast_channel *chan, int causecode)
 Lock the given channel, then request softhangup on the channel with the given causecode. More...
 
struct ast_silence_generatorast_channel_start_silence_generator (struct ast_channel *chan)
 Starts a silence generator on the given channel. More...
 
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. More...
 
int ast_channel_stream_topology_changed (struct ast_channel *chan, struct ast_stream_topology *topology)
 Provide notice to a channel that the stream topology has changed. More...
 
int ast_channel_stream_topology_changed_externally (struct ast_channel *chan)
 Provide notice from a channel that the topology has changed on it as a result of the remote party renegotiating. More...
 
enum ama_flags ast_channel_string2amaflag (const char *flag)
 Convert a string to a detail record AMA flag. More...
 
int ast_channel_supports_html (struct ast_channel *chan)
 Checks for HTML support on a channel. More...
 
int ast_channel_suppress (struct ast_channel *chan, unsigned int direction, enum ast_frame_type frametype)
 Suppress passing of a frame type on a channel. More...
 
void ast_channel_undefer_dtmf (struct ast_channel *chan)
 Unset defer DTMF flag on channel. More...
 
void ast_channel_unlink (struct ast_channel *chan)
 Remove a channel from the global channels container. More...
 
void ast_channel_unregister (const struct ast_channel_tech *tech)
 Unregister channel driver. More...
 
int ast_channel_unsuppress (struct ast_channel *chan, unsigned int direction, enum ast_frame_type frametype)
 Stop suppressing of a frame type on a channel. More...
 
void ast_channel_update_connected_line (struct ast_channel *chan, const struct ast_party_connected_line *connected, const struct ast_set_party_connected_line *update)
 Indicate that the connected line information has changed. More...
 
void ast_channel_update_redirecting (struct ast_channel *chan, const struct ast_party_redirecting *redirecting, const struct ast_set_party_redirecting *update)
 Indicate that the redirecting id has changed. More...
 
struct ast_channelast_channel_yank (struct ast_channel *yankee)
 Gain control of a channel in the system. More...
 
int ast_channels_init (void)
 
struct ast_variableast_channeltype_list (void)
 return an ast_variable list of channeltypes More...
 
int ast_check_hangup (struct ast_channel *chan)
 Checks to see if a channel is needing hang up. More...
 
int ast_check_hangup_locked (struct ast_channel *chan)
 
int ast_connected_line_build_data (unsigned char *data, size_t datalen, const struct ast_party_connected_line *connected, const struct ast_set_party_connected_line *update)
 Build the connected line information data frame. More...
 
void ast_connected_line_copy_from_caller (struct ast_party_connected_line *dest, const struct ast_party_caller *src)
 Copy the caller information to the connected line information. More...
 
void ast_connected_line_copy_to_caller (struct ast_party_caller *dest, const struct ast_party_connected_line *src)
 Copy the connected line information to the caller information. More...
 
int ast_connected_line_parse_data (const unsigned char *data, size_t datalen, struct ast_party_connected_line *connected)
 Parse connected line indication frame data. More...
 
void ast_deactivate_generator (struct ast_channel *chan)
 
static void ast_dummy_channel_destructor (void *obj)
 Free a dummy channel structure. More...
 
const struct ast_channel_techast_get_channel_tech (const char *name)
 Get handle to channel driver based on name. More...
 
ast_group_t ast_get_group (const char *s)
 
struct ast_namedgroups * ast_get_namedgroups (const char *s)
 Create an ast_namedgroups set with group names from comma separated string. More...
 
void ast_hangup (struct ast_channel *chan)
 Hangup a channel. More...
 
int ast_indicate (struct ast_channel *chan, int condition)
 Indicates condition of channel. More...
 
int ast_indicate_data (struct ast_channel *chan, int _condition, const void *data, size_t datalen)
 Indicates condition of channel, with payload. More...
 
void ast_install_music_functions (int(*start_ptr)(struct ast_channel *, const char *, const char *), void(*stop_ptr)(struct ast_channel *), void(*cleanup_ptr)(struct ast_channel *))
 
int ast_is_deferrable_frame (const struct ast_frame *frame)
 Should we keep this frame for later? More...
 
void ast_moh_cleanup (struct ast_channel *chan)
 
int ast_moh_start (struct ast_channel *chan, const char *mclass, const char *interpclass)
 Turn on music on hold on a given channel. More...
 
void ast_moh_stop (struct ast_channel *chan)
 Turn off music on hold on a given channel. More...
 
int ast_namedgroups_intersect (struct ast_namedgroups *a, struct ast_namedgroups *b)
 Return TRUE if group a and b contain at least one common groupname. More...
 
void ast_party_caller_copy (struct ast_party_caller *dest, const struct ast_party_caller *src)
 Copy the source caller information to the destination caller. More...
 
void ast_party_caller_free (struct ast_party_caller *doomed)
 Destroy the caller party contents. More...
 
void ast_party_caller_init (struct ast_party_caller *init)
 Initialize the given caller structure. More...
 
void ast_party_caller_set (struct ast_party_caller *dest, const struct ast_party_caller *src, const struct ast_set_party_caller *update)
 Set the caller information based on another caller source. More...
 
void ast_party_caller_set_init (struct ast_party_caller *init, const struct ast_party_caller *guide)
 Initialize the given caller structure using the given guide for a set update operation. More...
 
void ast_party_connected_line_collect_caller (struct ast_party_connected_line *connected, struct ast_party_caller *caller)
 Collect the caller party information into a connected line structure. More...
 
void ast_party_connected_line_copy (struct ast_party_connected_line *dest, const struct ast_party_connected_line *src)
 Copy the source connected line information to the destination connected line. More...
 
void ast_party_connected_line_free (struct ast_party_connected_line *doomed)
 Destroy the connected line information contents. More...
 
void ast_party_connected_line_init (struct ast_party_connected_line *init)
 Initialize the given connected line structure. More...
 
void ast_party_connected_line_set (struct ast_party_connected_line *dest, const struct ast_party_connected_line *src, const struct ast_set_party_connected_line *update)
 Set the connected line information based on another connected line source. More...
 
void ast_party_connected_line_set_init (struct ast_party_connected_line *init, const struct ast_party_connected_line *guide)
 Initialize the given connected line structure using the given guide for a set update operation. More...
 
void ast_party_dialed_copy (struct ast_party_dialed *dest, const struct ast_party_dialed *src)
 Copy the source dialed party information to the destination dialed party. More...
 
void ast_party_dialed_free (struct ast_party_dialed *doomed)
 Destroy the dialed party contents. More...
 
void ast_party_dialed_init (struct ast_party_dialed *init)
 Initialize the given dialed structure. More...
 
void ast_party_dialed_set (struct ast_party_dialed *dest, const struct ast_party_dialed *src)
 Set the dialed information based on another dialed source. More...
 
void ast_party_dialed_set_init (struct ast_party_dialed *init, const struct ast_party_dialed *guide)
 Initialize the given dialed structure using the given guide for a set update operation. More...
 
void ast_party_id_copy (struct ast_party_id *dest, const struct ast_party_id *src)
 Copy the source party id information to the destination party id. More...
 
void ast_party_id_free (struct ast_party_id *doomed)
 Destroy the party id contents. More...
 
void ast_party_id_init (struct ast_party_id *init)
 Initialize the given party id structure. More...
 
void ast_party_id_invalidate (struct ast_party_id *id)
 Invalidate all components of the given party id. More...
 
struct ast_party_id ast_party_id_merge (struct ast_party_id *base, struct ast_party_id *overlay)
 Merge a given party id into another given party id. More...
 
void ast_party_id_merge_copy (struct ast_party_id *dest, struct ast_party_id *base, struct ast_party_id *overlay)
 Copy a merge of a given party id into another given party id to a given destination party id. More...
 
int ast_party_id_presentation (const struct ast_party_id *id)
 Determine the overall presentation value for the given party. More...
 
void ast_party_id_reset (struct ast_party_id *id)
 Destroy and initialize the given party id structure. More...
 
void ast_party_id_set (struct ast_party_id *dest, const struct ast_party_id *src, const struct ast_set_party_id *update)
 Set the source party id information into the destination party id. More...
 
void ast_party_id_set_init (struct ast_party_id *init, const struct ast_party_id *guide)
 Initialize the given party id structure using the given guide for a set update operation. More...
 
void ast_party_name_copy (struct ast_party_name *dest, const struct ast_party_name *src)
 Copy the source party name information to the destination party name. More...
 
void ast_party_name_free (struct ast_party_name *doomed)
 Destroy the party name contents. More...
 
void ast_party_name_init (struct ast_party_name *init)
 Initialize the given name structure. More...
 
void ast_party_name_set (struct ast_party_name *dest, const struct ast_party_name *src)
 Set the source party name information into the destination party name. More...
 
void ast_party_name_set_init (struct ast_party_name *init, const struct ast_party_name *guide)
 Initialize the given party name structure using the given guide for a set update operation. More...
 
void ast_party_number_copy (struct ast_party_number *dest, const struct ast_party_number *src)
 Copy the source party number information to the destination party number. More...
 
void ast_party_number_free (struct ast_party_number *doomed)
 Destroy the party number contents. More...
 
void ast_party_number_init (struct ast_party_number *init)
 Initialize the given number structure. More...
 
void ast_party_number_set (struct ast_party_number *dest, const struct ast_party_number *src)
 Set the source party number information into the destination party number. More...
 
void ast_party_number_set_init (struct ast_party_number *init, const struct ast_party_number *guide)
 Initialize the given party number structure using the given guide for a set update operation. More...
 
void ast_party_redirecting_copy (struct ast_party_redirecting *dest, const struct ast_party_redirecting *src)
 Copy the source redirecting information to the destination redirecting. More...
 
void ast_party_redirecting_free (struct ast_party_redirecting *doomed)
 Destroy the redirecting information contents. More...
 
void ast_party_redirecting_init (struct ast_party_redirecting *init)
 Initialize the given redirecting structure. More...
 
void ast_party_redirecting_reason_copy (struct ast_party_redirecting_reason *dest, const struct ast_party_redirecting_reason *src)
 Copy the source redirecting reason information to the destination redirecting reason. More...
 
void ast_party_redirecting_reason_free (struct ast_party_redirecting_reason *doomed)
 Destroy the redirecting reason contents. More...
 
void ast_party_redirecting_reason_init (struct ast_party_redirecting_reason *init)
 Initialize the given redirecting reason structure. More...
 
void ast_party_redirecting_reason_set (struct ast_party_redirecting_reason *dest, const struct ast_party_redirecting_reason *src)
 Set the redirecting reason information based on another redirecting reason source. More...
 
void ast_party_redirecting_reason_set_init (struct ast_party_redirecting_reason *init, const struct ast_party_redirecting_reason *guide)
 Initialize the given redirecting reason structure using the given guide for a set update operation. More...
 
void ast_party_redirecting_set (struct ast_party_redirecting *dest, const struct ast_party_redirecting *src, const struct ast_set_party_redirecting *update)
 Set the redirecting information based on another redirecting source. More...
 
void ast_party_redirecting_set_init (struct ast_party_redirecting *init, const struct ast_party_redirecting *guide)
 Initialize the given redirecting id structure using the given guide for a set update operation. More...
 
void ast_party_subaddress_copy (struct ast_party_subaddress *dest, const struct ast_party_subaddress *src)
 Copy the source party subaddress information to the destination party subaddress. More...
 
void ast_party_subaddress_free (struct ast_party_subaddress *doomed)
 Destroy the party subaddress contents. More...
 
void ast_party_subaddress_init (struct ast_party_subaddress *init)
 Initialize the given subaddress structure. More...
 
void ast_party_subaddress_set (struct ast_party_subaddress *dest, const struct ast_party_subaddress *src)
 Set the source party subaddress information into the destination party subaddress. More...
 
void ast_party_subaddress_set_init (struct ast_party_subaddress *init, const struct ast_party_subaddress *guide)
 Initialize the given party subaddress structure using the given guide for a set update operation. More...
 
int ast_pre_call (struct ast_channel *chan, const char *sub_args)
 Execute a Gosub call on the channel before a call is placed. More...
 
char * ast_print_group (char *buf, int buflen, ast_group_t group)
 Print call group and pickup group —. More...
 
char * ast_print_namedgroups (struct ast_str **buf, struct ast_namedgroups *group)
 Print named call groups and named pickup groups. More...
 
int ast_prod (struct ast_channel *chan)
 Send empty audio to prime a channel driver. More...
 
int ast_queue_answer (struct ast_channel *chan, const struct ast_stream_topology *topology)
 Queue an ANSWER control frame with topology. More...
 
int ast_queue_control (struct ast_channel *chan, enum ast_control_frame_type control)
 Queue a control frame. More...
 
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. More...
 
int ast_queue_frame (struct ast_channel *chan, struct ast_frame *fin)
 Queue one or more frames to a channel's frame queue. More...
 
int ast_queue_frame_head (struct ast_channel *chan, struct ast_frame *fin)
 Queue one or more frames to the head of a channel's frame queue. More...
 
int ast_queue_hangup (struct ast_channel *chan)
 Queue a hangup frame for channel. More...
 
int ast_queue_hangup_with_cause (struct ast_channel *chan, int cause)
 Queue a hangup frame for channel. More...
 
int ast_queue_hold (struct ast_channel *chan, const char *musicclass)
 Queue a hold frame. More...
 
int ast_queue_unhold (struct ast_channel *chan)
 Queue an unhold frame. More...
 
int ast_raw_answer (struct ast_channel *chan)
 Answer a channel. More...
 
int ast_raw_answer_with_stream_topology (struct ast_channel *chan, struct ast_stream_topology *topology)
 Answer a channel passing in a stream topology. More...
 
struct ast_frameast_read (struct ast_channel *chan)
 Reads a frame. More...
 
static void ast_read_generator_actions (struct ast_channel *chan, struct ast_frame *f)
 
struct ast_frameast_read_noaudio (struct ast_channel *chan)
 Reads a frame, returning AST_FRAME_NULL frame if audio. More...
 
struct ast_frameast_read_stream (struct ast_channel *chan)
 Reads a frame, but does not filter to just the default streams. More...
 
struct ast_frameast_read_stream_noaudio (struct ast_channel *chan)
 Reads a frame, but does not filter to just the default streams, returning AST_FRAME_NULL frame if audio. More...
 
int ast_readstring (struct ast_channel *c, char *s, int len, int timeout, int ftimeout, char *enders)
 Reads multiple digits. More...
 
int ast_readstring_full (struct ast_channel *c, char *s, int len, int timeout, int ftimeout, char *enders, int audiofd, int ctrlfd)
 
int ast_recvchar (struct ast_channel *chan, int timeout)
 Receives a text character from a channel. More...
 
char * ast_recvtext (struct ast_channel *chan, int timeout)
 Receives a text string from a channel Read a string of text from a channel. More...
 
int ast_redirecting_build_data (unsigned char *data, size_t datalen, const struct ast_party_redirecting *redirecting, const struct ast_set_party_redirecting *update)
 Build the redirecting id data frame. More...
 
int ast_redirecting_parse_data (const unsigned char *data, size_t datalen, struct ast_party_redirecting *redirecting)
 Parse redirecting indication frame data. More...
 
struct ast_namedgroups * ast_ref_namedgroups (struct ast_namedgroups *groups)
 
struct ast_channelast_request (const char *type, struct ast_format_cap *request_cap, const struct ast_assigned_ids *assignedids, const struct ast_channel *requestor, const char *addr, int *cause)
 Requests a channel. More...
 
struct ast_channelast_request_and_dial (const char *type, struct ast_format_cap *cap, const struct ast_assigned_ids *assignedids, const struct ast_channel *requestor, const char *addr, int timeout, int *outstate, const char *cidnum, const char *cidname)
 Request a channel of a given type, with data as optional information used by the low level module and attempt to place a call on it. More...
 
struct ast_channelast_request_with_stream_topology (const char *type, struct ast_stream_topology *topology, const struct ast_assigned_ids *assignedids, const struct ast_channel *requestor, const char *addr, int *cause)
 Requests a channel (specifying stream topology) More...
 
int ast_safe_sleep (struct ast_channel *chan, int ms)
 Wait, look for hangups. More...
 
int ast_safe_sleep_conditional (struct ast_channel *chan, int timeout_ms, int(*cond)(void *), void *data)
 Wait for a specified amount of time, looking for hangups and a condition argument. More...
 
int ast_safe_sleep_without_silence (struct ast_channel *chan, int ms)
 Wait for a specified amount of time, looking for hangups, and do not generate silence. More...
 
int ast_say_character_str (struct ast_channel *chan, const char *str, const char *ints, const char *lang, enum ast_say_case_sensitivity sensitivity)
 function to pronounce character and phonetic strings More...
 
int ast_say_digit_str (struct ast_channel *chan, const char *str, const char *ints, const char *lang)
 says digits of a string More...
 
int ast_say_digits (struct ast_channel *chan, int num, const char *ints, const char *lang)
 says digits More...
 
int ast_say_digits_full (struct ast_channel *chan, int num, const char *ints, const char *lang, int audiofd, int ctrlfd)
 Same as ast_say_digits() with audiofd for received audio and returns 1 on ctrlfd being readable. More...
 
int ast_say_enumeration (struct ast_channel *chan, int num, const char *ints, const char *language, const char *options)
 says an enumeration More...
 
int ast_say_money_str (struct ast_channel *chan, const char *str, const char *ints, const char *lang)
 function to pronounce monetary amounts More...
 
int ast_say_number (struct ast_channel *chan, int num, const char *ints, const char *language, const char *options)
 says a number More...
 
int ast_say_ordinal (struct ast_channel *chan, int num, const char *ints, const char *language, const char *options)
 says an ordinal number More...
 
int ast_say_phonetic_str (struct ast_channel *chan, const char *str, const char *ints, const char *lang)
 
int ast_senddigit (struct ast_channel *chan, char digit, unsigned int duration)
 Send a DTMF digit to a channel. More...
 
int ast_senddigit_begin (struct ast_channel *chan, char digit)
 Send a DTMF digit to a channel. More...
 
int ast_senddigit_end (struct ast_channel *chan, char digit, unsigned int duration)
 Send a DTMF digit to a channel. More...
 
int ast_senddigit_external (struct ast_channel *chan, char digit, unsigned int duration)
 Send a DTMF digit to a channel from an external thread. More...
 
int ast_senddigit_mf (struct ast_channel *chan, char digit, unsigned int duration, unsigned int durationkp, unsigned int durationst, int is_external)
 Send an MF digit to a channel. More...
 
int ast_senddigit_mf_begin (struct ast_channel *chan, char digit)
 Send an MF digit to a channel. More...
 
int ast_senddigit_mf_end (struct ast_channel *chan)
 End sending an MF digit to a channel. More...
 
int ast_sendtext (struct ast_channel *chan, const char *text)
 Sends text to a channel. More...
 
int ast_sendtext_data (struct ast_channel *chan, struct ast_msg_data *msg)
 Sends text to a channel in an ast_msg_data structure wrapper with ast_sendtext as fallback. More...
 
void ast_set_callerid (struct ast_channel *chan, const char *cid_num, const char *cid_name, const char *cid_ani)
 Set caller ID number, name and ANI and generate AMI event. More...
 
void ast_set_hangupsource (struct ast_channel *chan, const char *source, int force)
 Set the source of the hangup in this channel and it's bridge. More...
 
void ast_set_party_id_all (struct ast_set_party_id *update_id)
 Set the update marker to update all information of a corresponding party id. More...
 
int ast_set_read_format (struct ast_channel *chan, struct ast_format *format)
 Sets read format on channel chan. More...
 
int ast_set_read_format_from_cap (struct ast_channel *chan, struct ast_format_cap *cap)
 Sets read format on channel chan from capabilities Set read format for channel to whichever component of "format" is best. More...
 
int ast_set_read_format_path (struct ast_channel *chan, struct ast_format *raw_format, struct ast_format *core_format)
 Set specific read path on channel. More...
 
void ast_set_variables (struct ast_channel *chan, struct ast_variable *vars)
 adds a list of channel variables to a channel More...
 
int ast_set_write_format (struct ast_channel *chan, struct ast_format *format)
 Sets write format on channel chan. More...
 
int ast_set_write_format_from_cap (struct ast_channel *chan, struct ast_format_cap *cap)
 Sets write format on channel chan Set write format for channel to whichever component of "format" is best. More...
 
int ast_set_write_format_interleaved_stereo (struct ast_channel *chan, struct ast_format *format)
 Sets write format for a channel. All internal data will than be handled in an interleaved format. (needed by binaural opus) More...
 
int ast_set_write_format_path (struct ast_channel *chan, struct ast_format *core_format, struct ast_format *raw_format)
 Set specific write path on channel. More...
 
int ast_setstate (struct ast_channel *chan, enum ast_channel_state state)
 Change the state of a channel. More...
 
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. More...
 
int ast_settimeout_full (struct ast_channel *c, unsigned int rate, int(*func)(const void *data), void *data, unsigned int is_ao2_obj)
 
int ast_softhangup (struct ast_channel *chan, int cause)
 Softly hangup a channel, lock. More...
 
void ast_softhangup_all (void)
 Soft hangup all active channels. More...
 
int ast_softhangup_nolock (struct ast_channel *chan, int cause)
 Softly hangup a channel, don't lock. More...
 
const char * ast_state2str (enum ast_channel_state state)
 Gives the string form of a given channel state. More...
 
int ast_str2cause (const char *name)
 Convert a symbolic hangup cause to number. More...
 
 AST_THREADSTORAGE_RAW (in_intercept_routine)
 
int ast_tonepair (struct ast_channel *chan, int freq1, int freq2, int duration, int vol)
 
int ast_tonepair_start (struct ast_channel *chan, int freq1, int freq2, int duration, int vol)
 
void ast_tonepair_stop (struct ast_channel *chan)
 
int ast_transfer (struct ast_channel *chan, char *dest)
 Transfer a call to dest, if the channel supports transfer. More...
 
int ast_transfer_protocol (struct ast_channel *chan, char *dest, int *protocol)
 Transfer a call to dest, if the channel supports transfer. More...
 
char * ast_transfercapability2str (int transfercapability)
 Gives the string form of a given transfer capability. More...
 
int ast_undestroyed_channels (void)
 
void ast_uninstall_music_functions (void)
 
struct ast_namedgroups * ast_unref_namedgroups (struct ast_namedgroups *groups)
 
int ast_waitfor (struct ast_channel *c, int ms)
 Wait for input on a channel. More...
 
struct ast_channelast_waitfor_n (struct ast_channel **c, int n, int *ms)
 Waits for input on a group of channels Wait for input on an array of channels for a given # of milliseconds. More...
 
int ast_waitfor_n_fd (int *fds, int n, int *ms, int *exception)
 Wait for x amount of time on a file descriptor to have input.
More...
 
struct ast_channelast_waitfor_nandfds (struct ast_channel **c, int n, int *fds, int nfds, int *exception, int *outfd, int *ms)
 Wait for x amount of time on a file descriptor to have input.
More...
 
int ast_waitfordigit (struct ast_channel *c, int ms)
 Waits for a digit. More...
 
int ast_waitfordigit_full (struct ast_channel *c, int timeout_ms, const char *breakon, int audiofd, int cmdfd)
 Wait for a digit Same as ast_waitfordigit() with audio fd for outputting read audio and ctrlfd to monitor for reading. More...
 
int ast_write (struct ast_channel *chan, struct ast_frame *fr)
 Write a frame to a channel This function writes the given frame to the indicated channel. More...
 
int ast_write_stream (struct ast_channel *chan, int stream_num, struct ast_frame *fr)
 Write a frame to a stream This function writes the given frame to the indicated stream on the channel. More...
 
int ast_write_video (struct ast_channel *chan, struct ast_frame *fr)
 Write video frame to a channel This function writes the given frame to the indicated channel. More...
 
static int calc_monitor_jump (int samples, int sample_rate, int seek_rate)
 calculates the number of samples to jump forward with in a monitor stream. More...
 
static void call_forward_inherit (struct ast_channel *new_chan, struct ast_channel *parent, struct ast_channel *orig)
 
static void * channel_cc_params_copy (void *data)
 
static void channel_cc_params_destroy (void *data)
 
static void channel_do_masquerade (struct ast_channel *original, struct ast_channel *clonechan)
 Masquerade a channel. More...
 
static int channel_feature_hooks_set_full (struct ast_channel *chan, struct ast_bridge_features *features, int replace)
 
static struct varsheadchannel_get_external_vars (struct external_vars *channelvars, struct ast_channel *chan)
 
static int channel_has_external_vars (struct external_vars *channelvars)
 
static void channel_req_accountcodes (struct ast_channel *chan, const struct ast_channel *requestor, enum ast_channel_requestor_relationship relationship, int precious)
 
static void channel_set_external_vars (struct external_vars *channelvars, size_t varc, char **vars)
 
static void channel_set_intercept_mode (int in_intercept_mode)
 
static void channels_shutdown (void)
 
static void clone_variables (struct ast_channel *original, struct ast_channel *clonechan)
 Clone channel variables from 'clone' channel into 'original' channel. More...
 
static char * complete_channeltypes (struct ast_cli_args *a)
 
static void deactivate_generator_nolock (struct ast_channel *chan)
 
static int deactivate_silence_generator (struct ast_channel *chan)
 
static void destroy_hooks (struct ast_channel *chan)
 
static int does_id_conflict (const char *uniqueid)
 
static const char * dtmf_direction_to_string (enum DtmfDirection direction)
 
static void features_destroy (void *obj)
 
static void free_external_channelvars (struct external_vars *channelvars)
 
static void free_translation (struct ast_channel *clonechan)
 
static int generator_force (const void *data)
 
static void generator_write_format_change (struct ast_channel *chan)
 
static void handle_cause (int cause, int *outstate)
 
static char * handle_cli_core_show_channeltype (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 Show details about a channel driver - CLI command. More...
 
static char * handle_cli_core_show_channeltypes (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 Show channel types - CLI command. More...
 
static int indicate_connected_line (struct ast_channel *chan, const void *data, size_t datalen)
 
static int indicate_data_internal (struct ast_channel *chan, int _condition, const void *data, size_t datalen)
 
static int indicate_redirecting (struct ast_channel *chan, const void *data, size_t datalen)
 
static int attribute_const is_visible_indication (enum ast_control_frame_type condition)
 
static struct ast_framekill_exception (struct ast_channel *chan)
 
static int kill_fixup (struct ast_channel *oldchan, struct ast_channel *newchan)
 
static int kill_hangup (struct ast_channel *chan)
 
static struct ast_framekill_read (struct ast_channel *chan)
 
static int kill_write (struct ast_channel *chan, struct ast_frame *frame)
 
static int namedgroup_cmp_cb (void *obj, void *arg, int flags)
 Comparison function used for named group container. More...
 
static int namedgroup_hash_cb (const void *obj, const int flags)
 Hashing function used for named group container. More...
 
static int namedgroup_match (void *obj, void *arg, int flags)
 
static int party_id_build_data (unsigned char *data, size_t datalen, const struct ast_party_id *id, const char *label, const struct ast_party_id_ies *ies, const struct ast_set_party_id *update)
 
static int party_name_build_data (unsigned char *data, size_t datalen, const struct ast_party_name *name, const char *label, const struct ast_party_name_ies *ies)
 
static int party_number_build_data (unsigned char *data, size_t datalen, const struct ast_party_number *number, const char *label, const struct ast_party_number_ies *ies)
 
static int party_subaddress_build_data (unsigned char *data, size_t datalen, const struct ast_party_subaddress *subaddress, const char *label, const struct ast_party_subaddress_ies *ies)
 
static void plc_ds_destroy (void *data)
 
static void prnt_channel_key (void *v_obj, void *where, ao2_prnt_fn *prnt)
 
static void queue_dtmf_readq (struct ast_channel *chan, struct ast_frame *f)
 
static int redirecting_reason_build_data (unsigned char *data, size_t datalen, const struct ast_party_redirecting_reason *reason, const char *label, const struct ast_party_redirecting_reason_ies *ies)
 
static struct ast_channelrequest_channel (const char *type, struct ast_format_cap *request_cap, struct ast_stream_topology *topology, const struct ast_assigned_ids *assignedids, const struct ast_channel *requestor, const char *addr, int *cause)
 
static int safe_sleep_conditional (struct ast_channel *chan, int timeout_ms, int(*cond)(void *), void *data, unsigned int generate_silence)
 Wait, look for hangups and condition arg. More...
 
static void send_dtmf_begin_event (struct ast_channel *chan, enum DtmfDirection direction, const char digit)
 
static void send_dtmf_end_event (struct ast_channel *chan, enum DtmfDirection direction, const char digit, long duration_ms)
 
static void send_flash_event (struct ast_channel *chan)
 
static void send_wink_event (struct ast_channel *chan)
 
static void set_channel_answer_time (struct ast_channel *chan)
 
static int set_format (struct ast_channel *chan, struct ast_format_cap *cap_set, const int direction, int interleaved_stereo)
 
static int set_security_requirements (const struct ast_channel *requestor, struct ast_channel *out)
 
static int should_skip_dtmf (struct ast_channel *chan)
 Determine whether or not we should ignore DTMF in the readq. More...
 
static int should_trigger_dtmf_emulating (struct ast_channel *chan)
 Determine whether or not we have to trigger dtmf emulating using 50 fps timer events especially when no voice frames are received during dtmf processing (direct media or muted sender case using SIP INFO) More...
 
static void * silence_generator_alloc (struct ast_channel *chan, void *data)
 
static int silence_generator_generate (struct ast_channel *chan, void *data, int len, int samples)
 
static void silence_generator_release (struct ast_channel *chan, void *data)
 
static void suppress_datastore_destroy_cb (void *data)
 
static void suppress_framehook_destroy_cb (void *data)
 
static struct ast_framesuppress_framehook_event_cb (struct ast_channel *chan, struct ast_frame *frame, enum ast_framehook_event event, void *data)
 
static void suppress_framehook_fixup_cb (void *data, int framehook_id, struct ast_channel *old_chan, struct ast_channel *new_chan)
 
static const struct ast_datastore_infosuppress_get_datastore_information (enum ast_frame_type frametype)
 
static int tech_write (struct ast_channel *chan, struct ast_stream *stream, struct ast_stream *default_stream, struct ast_frame *frame)
 
static void * tonepair_alloc (struct ast_channel *chan, void *params)
 
static int tonepair_generator (struct ast_channel *chan, void *data, int len, int samples)
 
static void tonepair_release (struct ast_channel *chan, void *params)
 
static void varshead_dtor (void *obj)
 Destructor for lists of variables. More...
 

Variables

static struct external_vars ami_vars
 
static struct external_vars ari_vars
 
const struct ast_channel_tech ast_kill_tech
 Kill the channel channel driver technology descriptor. More...
 
static void(* ast_moh_cleanup_ptr )(struct ast_channel *) = NULL
 
static int(* ast_moh_start_ptr )(struct ast_channel *, const char *, const char *) = NULL
 
static void(* ast_moh_stop_ptr )(struct ast_channel *) = NULL
 
static struct backends backends = { .first = NULL, .last = NULL, .lock = { PTHREAD_RWLOCK_INITIALIZER , NULL, {1, 0} } , }
 
static const struct ast_datastore_info bridge_features_info
 
static const struct causes_map causes []
 
static const struct ast_datastore_info cc_channel_datastore_info
 
static int chancount
 
static ast_mutex_t channel_move_lock = { PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP , NULL, {1, 0} }
 
static struct ao2_containerchannels
 All active channels on the system. More...
 
static struct ast_cli_entry cli_channel []
 
unsigned long global_fin
 
unsigned long global_fout
 
static const struct ast_channel_tech null_tech
 
static const struct ast_datastore_info plc_ds_info
 
static const struct set_format_access set_format_access_read
 
static const struct set_format_access set_format_access_write
 
static struct ast_generator silence_generator
 
static struct ast_threadstorage state2str_threadbuf = { .once = PTHREAD_ONCE_INIT , .key_init = __init_state2str_threadbuf , .custom_init = NULL , }
 
static const struct ast_datastore_info suppress_datastore_voice
 
static const struct ast_channel_tech surrogate_tech
 Channel technology used to extract a channel from a running application. The channel created with this technology will be immediately hung up - most external applications won't ever want to see this. More...
 
static struct ast_generator tonepair
 

Detailed Description

Channel Management.

Author
Mark Spencer marks.nosp@m.ter@.nosp@m.digiu.nosp@m.m.co.nosp@m.m

Definition in file channel.c.

Macro Definition Documentation

◆ AST_DEFAULT_EMULATE_DTMF_DURATION

#define AST_DEFAULT_EMULATE_DTMF_DURATION   100

Default amount of time to use when emulating a DTMF digit as a begin and end 100ms

Definition at line 102 of file channel.c.

◆ AST_MIN_DTMF_GAP

#define AST_MIN_DTMF_GAP   45

Minimum amount of time between the end of the last digit and the beginning of a new one - 45ms

Definition at line 112 of file channel.c.

◆ DEFAULT_AMA_FLAGS

#define DEFAULT_AMA_FLAGS   AST_AMA_DOCUMENTATION

Definition at line 108 of file channel.c.

◆ DEFAULT_EMULATE_MF_DURATION

#define DEFAULT_EMULATE_MF_DURATION   55

Default amount of time to use when emulating an MF digit as a begin and end 55ms

Definition at line 106 of file channel.c.

◆ FORMAT

#define FORMAT   "%-15.15s %-40.40s %-13.13s %-13.13s %-13.13s %-13.13s\n"

◆ STATE2STR_BUFSIZE

#define STATE2STR_BUFSIZE   32

Definition at line 98 of file channel.c.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum

Element identifiers for connected line indication frame data.

Note
Only add to the end of this enum.
Enumerator
AST_CONNECTED_LINE_NUMBER 
AST_CONNECTED_LINE_NAME 
AST_CONNECTED_LINE_NUMBER_PLAN 
AST_CONNECTED_LINE_ID_PRESENTATION 
AST_CONNECTED_LINE_SOURCE 
AST_CONNECTED_LINE_SUBADDRESS 
AST_CONNECTED_LINE_SUBADDRESS_TYPE 
AST_CONNECTED_LINE_SUBADDRESS_ODD_EVEN 
AST_CONNECTED_LINE_SUBADDRESS_VALID 
AST_CONNECTED_LINE_TAG 
AST_CONNECTED_LINE_VERSION 
AST_CONNECTED_LINE_NAME_VALID 
AST_CONNECTED_LINE_NAME_CHAR_SET 
AST_CONNECTED_LINE_NAME_PRESENTATION 
AST_CONNECTED_LINE_NUMBER_VALID 
AST_CONNECTED_LINE_NUMBER_PRESENTATION 
AST_CONNECTED_LINE_PRIV_NUMBER 
AST_CONNECTED_LINE_PRIV_NUMBER_PLAN 
AST_CONNECTED_LINE_PRIV_NUMBER_VALID 
AST_CONNECTED_LINE_PRIV_NUMBER_PRESENTATION 
AST_CONNECTED_LINE_PRIV_NAME 
AST_CONNECTED_LINE_PRIV_NAME_VALID 
AST_CONNECTED_LINE_PRIV_NAME_CHAR_SET 
AST_CONNECTED_LINE_PRIV_NAME_PRESENTATION 
AST_CONNECTED_LINE_PRIV_SUBADDRESS 
AST_CONNECTED_LINE_PRIV_SUBADDRESS_TYPE 
AST_CONNECTED_LINE_PRIV_SUBADDRESS_ODD_EVEN 
AST_CONNECTED_LINE_PRIV_SUBADDRESS_VALID 
AST_CONNECTED_LINE_PRIV_TAG 

Definition at line 8683 of file channel.c.

8683 {
8687 AST_CONNECTED_LINE_ID_PRESENTATION,/* Combined number and name presentation. */
8695 /*
8696 * No more party id combined number and name presentation values
8697 * need to be created.
8698 */
8717};
@ AST_CONNECTED_LINE_NUMBER_VALID
Definition: channel.c:8702
@ AST_CONNECTED_LINE_SOURCE
Definition: channel.c:8688
@ AST_CONNECTED_LINE_PRIV_SUBADDRESS_VALID
Definition: channel.c:8715
@ AST_CONNECTED_LINE_PRIV_SUBADDRESS_ODD_EVEN
Definition: channel.c:8714
@ AST_CONNECTED_LINE_PRIV_NAME_VALID
Definition: channel.c:8709
@ AST_CONNECTED_LINE_PRIV_SUBADDRESS_TYPE
Definition: channel.c:8713
@ AST_CONNECTED_LINE_PRIV_NUMBER_PRESENTATION
Definition: channel.c:8707
@ AST_CONNECTED_LINE_NAME_CHAR_SET
Definition: channel.c:8700
@ AST_CONNECTED_LINE_SUBADDRESS_VALID
Definition: channel.c:8692
@ AST_CONNECTED_LINE_SUBADDRESS_ODD_EVEN
Definition: channel.c:8691
@ AST_CONNECTED_LINE_SUBADDRESS
Definition: channel.c:8689
@ AST_CONNECTED_LINE_PRIV_NUMBER_PLAN
Definition: channel.c:8705
@ AST_CONNECTED_LINE_NUMBER
Definition: channel.c:8684
@ AST_CONNECTED_LINE_ID_PRESENTATION
Definition: channel.c:8687
@ AST_CONNECTED_LINE_PRIV_NAME_PRESENTATION
Definition: channel.c:8711
@ AST_CONNECTED_LINE_PRIV_NAME
Definition: channel.c:8708
@ AST_CONNECTED_LINE_TAG
Definition: channel.c:8693
@ AST_CONNECTED_LINE_PRIV_NUMBER_VALID
Definition: channel.c:8706
@ AST_CONNECTED_LINE_NUMBER_PRESENTATION
Definition: channel.c:8703
@ AST_CONNECTED_LINE_PRIV_NAME_CHAR_SET
Definition: channel.c:8710
@ AST_CONNECTED_LINE_NAME
Definition: channel.c:8685
@ AST_CONNECTED_LINE_NAME_PRESENTATION
Definition: channel.c:8701
@ AST_CONNECTED_LINE_SUBADDRESS_TYPE
Definition: channel.c:8690
@ AST_CONNECTED_LINE_PRIV_SUBADDRESS
Definition: channel.c:8712
@ AST_CONNECTED_LINE_PRIV_TAG
Definition: channel.c:8716
@ AST_CONNECTED_LINE_NAME_VALID
Definition: channel.c:8699
@ AST_CONNECTED_LINE_PRIV_NUMBER
Definition: channel.c:8704
@ AST_CONNECTED_LINE_NUMBER_PLAN
Definition: channel.c:8686
@ AST_CONNECTED_LINE_VERSION
Definition: channel.c:8694

◆ anonymous enum

anonymous enum

Element identifiers for redirecting indication frame data.

Note
Only add to the end of this enum.
Enumerator
AST_REDIRECTING_FROM_NUMBER 
AST_REDIRECTING_FROM_NAME 
AST_REDIRECTING_FROM_NUMBER_PLAN 
AST_REDIRECTING_FROM_ID_PRESENTATION 
AST_REDIRECTING_TO_NUMBER 
AST_REDIRECTING_TO_NAME 
AST_REDIRECTING_TO_NUMBER_PLAN 
AST_REDIRECTING_TO_ID_PRESENTATION 
AST_REDIRECTING_REASON_CODE 
AST_REDIRECTING_COUNT 
AST_REDIRECTING_FROM_SUBADDRESS 
AST_REDIRECTING_FROM_SUBADDRESS_TYPE 
AST_REDIRECTING_FROM_SUBADDRESS_ODD_EVEN 
AST_REDIRECTING_FROM_SUBADDRESS_VALID 
AST_REDIRECTING_TO_SUBADDRESS 
AST_REDIRECTING_TO_SUBADDRESS_TYPE 
AST_REDIRECTING_TO_SUBADDRESS_ODD_EVEN 
AST_REDIRECTING_TO_SUBADDRESS_VALID 
AST_REDIRECTING_FROM_TAG 
AST_REDIRECTING_TO_TAG 
AST_REDIRECTING_VERSION 
AST_REDIRECTING_FROM_NAME_VALID 
AST_REDIRECTING_FROM_NAME_CHAR_SET 
AST_REDIRECTING_FROM_NAME_PRESENTATION 
AST_REDIRECTING_FROM_NUMBER_VALID 
AST_REDIRECTING_FROM_NUMBER_PRESENTATION 
AST_REDIRECTING_TO_NAME_VALID 
AST_REDIRECTING_TO_NAME_CHAR_SET 
AST_REDIRECTING_TO_NAME_PRESENTATION 
AST_REDIRECTING_TO_NUMBER_VALID 
AST_REDIRECTING_TO_NUMBER_PRESENTATION 
AST_REDIRECTING_ORIG_NUMBER 
AST_REDIRECTING_ORIG_NUMBER_VALID 
AST_REDIRECTING_ORIG_NUMBER_PLAN 
AST_REDIRECTING_ORIG_NUMBER_PRESENTATION 
AST_REDIRECTING_ORIG_NAME 
AST_REDIRECTING_ORIG_NAME_VALID 
AST_REDIRECTING_ORIG_NAME_CHAR_SET 
AST_REDIRECTING_ORIG_NAME_PRESENTATION 
AST_REDIRECTING_ORIG_SUBADDRESS 
AST_REDIRECTING_ORIG_SUBADDRESS_TYPE 
AST_REDIRECTING_ORIG_SUBADDRESS_ODD_EVEN 
AST_REDIRECTING_ORIG_SUBADDRESS_VALID 
AST_REDIRECTING_ORIG_TAG 
AST_REDIRECTING_ORIG_REASON_CODE 
AST_REDIRECTING_PRIV_TO_NUMBER 
AST_REDIRECTING_PRIV_TO_NUMBER_PLAN 
AST_REDIRECTING_PRIV_TO_NUMBER_VALID 
AST_REDIRECTING_PRIV_TO_NUMBER_PRESENTATION 
AST_REDIRECTING_PRIV_TO_NAME 
AST_REDIRECTING_PRIV_TO_NAME_VALID 
AST_REDIRECTING_PRIV_TO_NAME_CHAR_SET 
AST_REDIRECTING_PRIV_TO_NAME_PRESENTATION 
AST_REDIRECTING_PRIV_TO_SUBADDRESS 
AST_REDIRECTING_PRIV_TO_SUBADDRESS_TYPE 
AST_REDIRECTING_PRIV_TO_SUBADDRESS_ODD_EVEN 
AST_REDIRECTING_PRIV_TO_SUBADDRESS_VALID 
AST_REDIRECTING_PRIV_TO_TAG 
AST_REDIRECTING_PRIV_FROM_NUMBER 
AST_REDIRECTING_PRIV_FROM_NUMBER_PLAN 
AST_REDIRECTING_PRIV_FROM_NUMBER_VALID 
AST_REDIRECTING_PRIV_FROM_NUMBER_PRESENTATION 
AST_REDIRECTING_PRIV_FROM_NAME 
AST_REDIRECTING_PRIV_FROM_NAME_VALID 
AST_REDIRECTING_PRIV_FROM_NAME_CHAR_SET 
AST_REDIRECTING_PRIV_FROM_NAME_PRESENTATION 
AST_REDIRECTING_PRIV_FROM_SUBADDRESS 
AST_REDIRECTING_PRIV_FROM_SUBADDRESS_TYPE 
AST_REDIRECTING_PRIV_FROM_SUBADDRESS_ODD_EVEN 
AST_REDIRECTING_PRIV_FROM_SUBADDRESS_VALID 
AST_REDIRECTING_PRIV_FROM_TAG 
AST_REDIRECTING_PRIV_ORIG_NUMBER 
AST_REDIRECTING_PRIV_ORIG_NUMBER_VALID 
AST_REDIRECTING_PRIV_ORIG_NUMBER_PLAN 
AST_REDIRECTING_PRIV_ORIG_NUMBER_PRESENTATION 
AST_REDIRECTING_PRIV_ORIG_NAME 
AST_REDIRECTING_PRIV_ORIG_NAME_VALID 
AST_REDIRECTING_PRIV_ORIG_NAME_CHAR_SET 
AST_REDIRECTING_PRIV_ORIG_NAME_PRESENTATION 
AST_REDIRECTING_PRIV_ORIG_SUBADDRESS 
AST_REDIRECTING_PRIV_ORIG_SUBADDRESS_TYPE 
AST_REDIRECTING_PRIV_ORIG_SUBADDRESS_ODD_EVEN 
AST_REDIRECTING_PRIV_ORIG_SUBADDRESS_VALID 
AST_REDIRECTING_PRIV_ORIG_TAG 
AST_REDIRECTING_REASON_STR 
AST_REDIRECTING_ORIG_REASON_STR 

Definition at line 9159 of file channel.c.

9159 {
9163 AST_REDIRECTING_FROM_ID_PRESENTATION,/* Combined number and name presentation. */
9167 AST_REDIRECTING_TO_ID_PRESENTATION,/* Combined number and name presentation. */
9181 /*
9182 * No more party id combined number and name presentation values
9183 * need to be created.
9184 */
9250};
@ AST_REDIRECTING_FROM_NAME_PRESENTATION
Definition: channel.c:9187
@ AST_REDIRECTING_TO_NAME
Definition: channel.c:9165
@ AST_REDIRECTING_VERSION
Definition: channel.c:9180
@ AST_REDIRECTING_PRIV_FROM_NAME_VALID
Definition: channel.c:9227
@ AST_REDIRECTING_PRIV_FROM_SUBADDRESS_ODD_EVEN
Definition: channel.c:9232
@ AST_REDIRECTING_TO_TAG
Definition: channel.c:9179
@ AST_REDIRECTING_FROM_NUMBER_PLAN
Definition: channel.c:9162
@ AST_REDIRECTING_PRIV_TO_NAME_VALID
Definition: channel.c:9214
@ AST_REDIRECTING_ORIG_TAG
Definition: channel.c:9207
@ AST_REDIRECTING_PRIV_ORIG_SUBADDRESS_ODD_EVEN
Definition: channel.c:9245
@ AST_REDIRECTING_REASON_CODE
Definition: channel.c:9168
@ AST_REDIRECTING_PRIV_TO_NUMBER_VALID
Definition: channel.c:9211
@ AST_REDIRECTING_PRIV_TO_NUMBER_PRESENTATION
Definition: channel.c:9212
@ AST_REDIRECTING_ORIG_REASON_CODE
Definition: channel.c:9208
@ AST_REDIRECTING_TO_NAME_PRESENTATION
Definition: channel.c:9192
@ AST_REDIRECTING_PRIV_TO_NAME
Definition: channel.c:9213
@ AST_REDIRECTING_PRIV_ORIG_NAME_VALID
Definition: channel.c:9240
@ AST_REDIRECTING_ORIG_NUMBER_VALID
Definition: channel.c:9196
@ AST_REDIRECTING_FROM_NUMBER_PRESENTATION
Definition: channel.c:9189
@ AST_REDIRECTING_ORIG_SUBADDRESS_VALID
Definition: channel.c:9206
@ AST_REDIRECTING_FROM_NUMBER_VALID
Definition: channel.c:9188
@ AST_REDIRECTING_TO_NAME_VALID
Definition: channel.c:9190
@ AST_REDIRECTING_PRIV_FROM_NAME
Definition: channel.c:9226
@ AST_REDIRECTING_TO_SUBADDRESS_ODD_EVEN
Definition: channel.c:9176
@ AST_REDIRECTING_ORIG_SUBADDRESS_ODD_EVEN
Definition: channel.c:9205
@ AST_REDIRECTING_PRIV_FROM_SUBADDRESS_TYPE
Definition: channel.c:9231
@ AST_REDIRECTING_PRIV_TO_SUBADDRESS_VALID
Definition: channel.c:9220
@ AST_REDIRECTING_PRIV_TO_SUBADDRESS_ODD_EVEN
Definition: channel.c:9219
@ AST_REDIRECTING_ORIG_NAME_CHAR_SET
Definition: channel.c:9201
@ AST_REDIRECTING_PRIV_FROM_SUBADDRESS
Definition: channel.c:9230
@ AST_REDIRECTING_TO_NUMBER_PLAN
Definition: channel.c:9166
@ AST_REDIRECTING_PRIV_TO_NUMBER
Definition: channel.c:9209
@ AST_REDIRECTING_PRIV_FROM_NUMBER_VALID
Definition: channel.c:9224
@ AST_REDIRECTING_ORIG_NAME
Definition: channel.c:9199
@ AST_REDIRECTING_ORIG_SUBADDRESS
Definition: channel.c:9203
@ AST_REDIRECTING_FROM_TAG
Definition: channel.c:9178
@ AST_REDIRECTING_PRIV_ORIG_NUMBER_PLAN
Definition: channel.c:9237
@ AST_REDIRECTING_TO_NUMBER
Definition: channel.c:9164
@ AST_REDIRECTING_ORIG_SUBADDRESS_TYPE
Definition: channel.c:9204
@ AST_REDIRECTING_FROM_NAME_CHAR_SET
Definition: channel.c:9186
@ AST_REDIRECTING_PRIV_FROM_TAG
Definition: channel.c:9234
@ AST_REDIRECTING_FROM_ID_PRESENTATION
Definition: channel.c:9163
@ AST_REDIRECTING_PRIV_FROM_NUMBER
Definition: channel.c:9222
@ AST_REDIRECTING_PRIV_TO_NUMBER_PLAN
Definition: channel.c:9210
@ AST_REDIRECTING_TO_NUMBER_VALID
Definition: channel.c:9193
@ AST_REDIRECTING_FROM_SUBADDRESS_VALID
Definition: channel.c:9173
@ AST_REDIRECTING_FROM_NAME_VALID
Definition: channel.c:9185
@ AST_REDIRECTING_PRIV_TO_NAME_CHAR_SET
Definition: channel.c:9215
@ AST_REDIRECTING_PRIV_ORIG_TAG
Definition: channel.c:9247
@ AST_REDIRECTING_FROM_SUBADDRESS_TYPE
Definition: channel.c:9171
@ AST_REDIRECTING_PRIV_TO_TAG
Definition: channel.c:9221
@ AST_REDIRECTING_COUNT
Definition: channel.c:9169
@ AST_REDIRECTING_FROM_SUBADDRESS
Definition: channel.c:9170
@ AST_REDIRECTING_PRIV_ORIG_NAME_CHAR_SET
Definition: channel.c:9241
@ AST_REDIRECTING_ORIG_NAME_VALID
Definition: channel.c:9200
@ AST_REDIRECTING_TO_ID_PRESENTATION
Definition: channel.c:9167
@ AST_REDIRECTING_PRIV_FROM_NUMBER_PLAN
Definition: channel.c:9223
@ AST_REDIRECTING_PRIV_TO_NAME_PRESENTATION
Definition: channel.c:9216
@ AST_REDIRECTING_PRIV_FROM_NUMBER_PRESENTATION
Definition: channel.c:9225
@ AST_REDIRECTING_PRIV_FROM_NAME_PRESENTATION
Definition: channel.c:9229
@ AST_REDIRECTING_PRIV_ORIG_SUBADDRESS_TYPE
Definition: channel.c:9244
@ AST_REDIRECTING_ORIG_REASON_STR
Definition: channel.c:9249
@ AST_REDIRECTING_ORIG_NAME_PRESENTATION
Definition: channel.c:9202
@ AST_REDIRECTING_PRIV_FROM_NAME_CHAR_SET
Definition: channel.c:9228
@ AST_REDIRECTING_ORIG_NUMBER
Definition: channel.c:9195
@ AST_REDIRECTING_PRIV_ORIG_NAME
Definition: channel.c:9239
@ AST_REDIRECTING_PRIV_TO_SUBADDRESS_TYPE
Definition: channel.c:9218
@ AST_REDIRECTING_PRIV_ORIG_NUMBER_VALID
Definition: channel.c:9236
@ AST_REDIRECTING_PRIV_ORIG_NUMBER_PRESENTATION
Definition: channel.c:9238
@ AST_REDIRECTING_TO_SUBADDRESS_VALID
Definition: channel.c:9177
@ AST_REDIRECTING_PRIV_ORIG_SUBADDRESS_VALID
Definition: channel.c:9246
@ AST_REDIRECTING_TO_SUBADDRESS_TYPE
Definition: channel.c:9175
@ AST_REDIRECTING_REASON_STR
Definition: channel.c:9248
@ AST_REDIRECTING_FROM_NAME
Definition: channel.c:9161
@ AST_REDIRECTING_PRIV_ORIG_NUMBER
Definition: channel.c:9235
@ AST_REDIRECTING_PRIV_FROM_SUBADDRESS_VALID
Definition: channel.c:9233
@ AST_REDIRECTING_ORIG_NUMBER_PRESENTATION
Definition: channel.c:9198
@ AST_REDIRECTING_PRIV_TO_SUBADDRESS
Definition: channel.c:9217
@ AST_REDIRECTING_PRIV_ORIG_NAME_PRESENTATION
Definition: channel.c:9242
@ AST_REDIRECTING_TO_NUMBER_PRESENTATION
Definition: channel.c:9194
@ AST_REDIRECTING_FROM_NUMBER
Definition: channel.c:9160
@ AST_REDIRECTING_ORIG_NUMBER_PLAN
Definition: channel.c:9197
@ AST_REDIRECTING_FROM_SUBADDRESS_ODD_EVEN
Definition: channel.c:9172
@ AST_REDIRECTING_PRIV_ORIG_SUBADDRESS
Definition: channel.c:9243
@ AST_REDIRECTING_TO_SUBADDRESS
Definition: channel.c:9174
@ AST_REDIRECTING_TO_NAME_CHAR_SET
Definition: channel.c:9191

◆ DtmfDirection

Enumerator
DTMF_RECEIVED 
DTMF_SENT 

Definition at line 3372 of file channel.c.

3372 {
3374 DTMF_SENT
3375};
@ DTMF_SENT
Definition: channel.c:3374
@ DTMF_RECEIVED
Definition: channel.c:3373

Function Documentation

◆ __ast_answer()

int __ast_answer ( struct ast_channel chan,
unsigned int  delay 
)

Answer a channel, with a selectable delay before returning.

Parameters
chanchannel to answer
delaymaximum amount of time to wait for incoming media

This function answers a channel and handles all necessary call setup functions.

Note
The channel passed does not need to be locked, but is locked by the function when needed.
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.
Return values
0on success
non-zeroon failure

Definition at line 2714 of file channel.c.

2715{
2716 int res = 0;
2717 enum ast_channel_state old_state;
2718 SCOPE_TRACE(1, "%s\n", ast_channel_name(chan));
2719
2720 old_state = ast_channel_state(chan);
2721 if ((res = ast_raw_answer(chan))) {
2722 return res;
2723 }
2724
2725 switch (old_state) {
2726 case AST_STATE_RINGING:
2727 case AST_STATE_RING:
2728 /* wait for media to start flowing, but don't wait any longer
2729 * than 'delay' or 500 milliseconds, whichever is longer
2730 */
2731 do {
2733 struct ast_frame *cur;
2734 struct ast_frame *new_frame;
2735 int timeout_ms = MAX(delay, 500);
2736 unsigned int done = 0;
2737 struct timeval start;
2738
2740
2741 start = ast_tvnow();
2742 for (;;) {
2743 int ms = ast_remaining_ms(start, timeout_ms);
2744 ms = ast_waitfor(chan, ms);
2745 if (ms < 0) {
2746 ast_log(LOG_WARNING, "Error condition occurred when polling channel %s for a voice frame: %s\n", ast_channel_name(chan), strerror(errno));
2747 res = -1;
2748 break;
2749 }
2750 if (ms == 0) {
2751 ast_debug(2, "Didn't receive a media frame from %s within %u ms of answering. Continuing anyway\n", ast_channel_name(chan), MAX(delay, 500));
2752 break;
2753 }
2754 cur = ast_read(chan);
2755 if (!cur || ((cur->frametype == AST_FRAME_CONTROL) &&
2756 (cur->subclass.integer == AST_CONTROL_HANGUP))) {
2757 if (cur) {
2758 ast_frfree(cur);
2759 }
2760 res = -1;
2761 ast_debug(2, "Hangup of channel %s detected in answer routine\n", ast_channel_name(chan));
2762 break;
2763 }
2764
2765 if ((new_frame = ast_frisolate(cur)) != cur) {
2766 ast_frfree(cur);
2767 }
2768
2770
2771 /* if a specific delay period was requested, continue
2772 * until that delay has passed. don't stop just because
2773 * incoming media has arrived.
2774 */
2775 if (delay) {
2776 continue;
2777 }
2778
2779 switch (new_frame->frametype) {
2780 /* all of these frametypes qualify as 'media' */
2781 case AST_FRAME_VOICE:
2782 case AST_FRAME_VIDEO:
2783 case AST_FRAME_TEXT:
2786 case AST_FRAME_DTMF_END:
2787 case AST_FRAME_IMAGE:
2788 case AST_FRAME_HTML:
2789 case AST_FRAME_MODEM:
2790 case AST_FRAME_RTCP:
2791 done = 1;
2792 break;
2793 case AST_FRAME_CONTROL:
2794 case AST_FRAME_IAX:
2797 case AST_FRAME_NULL:
2798 case AST_FRAME_CNG:
2799 break;
2800 }
2801
2802 if (done) {
2803 break;
2804 }
2805 }
2806
2807 ast_channel_lock(chan);
2808 while ((cur = AST_LIST_REMOVE_HEAD(&frames, frame_list))) {
2809 if (res == 0) {
2810 ast_queue_frame_head(chan, cur);
2811 }
2812 ast_frfree(cur);
2813 }
2814 ast_channel_unlock(chan);
2815 } while (0);
2816 break;
2817 default:
2818 break;
2819 }
2820
2821 return res;
2822}
#define ast_log
Definition: astobj2.c:42
struct ast_frame * ast_read(struct ast_channel *chan)
Reads a frame.
Definition: channel.c:4276
int ast_queue_frame_head(struct ast_channel *chan, struct ast_frame *fin)
Queue one or more frames to the head of a channel's frame queue.
Definition: channel.c:1163
int ast_waitfor(struct ast_channel *c, int ms)
Wait for input on a channel.
Definition: channel.c:3181
int ast_raw_answer(struct ast_channel *chan)
Answer a channel.
Definition: channel.c:2709
const char * ast_channel_name(const struct ast_channel *chan)
#define ast_channel_lock(chan)
Definition: channel.h:2968
#define ast_channel_unlock(chan)
Definition: channel.h:2969
ast_channel_state
ast_channel states
Definition: channelstate.h:35
@ AST_STATE_RING
Definition: channelstate.h:40
@ AST_STATE_RINGING
Definition: channelstate.h:41
#define SCOPE_TRACE(__level,...)
#define ast_frisolate(fr)
Makes a frame independent of any static storage.
#define ast_frfree(fr)
@ AST_FRAME_VIDEO
@ AST_FRAME_NULL
@ AST_FRAME_HTML
@ AST_FRAME_IMAGE
@ AST_FRAME_DTMF_END
@ AST_FRAME_DTMF_BEGIN
@ AST_FRAME_BRIDGE_ACTION_SYNC
@ AST_FRAME_VOICE
@ AST_FRAME_RTCP
@ AST_FRAME_MODEM
@ AST_FRAME_TEXT_DATA
@ AST_FRAME_CONTROL
@ AST_FRAME_BRIDGE_ACTION
@ AST_FRAME_TEXT
@ AST_CONTROL_HANGUP
#define ast_debug(level,...)
Log a DEBUG message.
#define LOG_WARNING
#define AST_LIST_HEAD_INIT_NOLOCK(head)
Initializes a list head structure.
Definition: linkedlists.h:681
#define AST_LIST_HEAD_NOLOCK(name, type)
Defines a structure to be used to hold a list of specified type (with no lock).
Definition: linkedlists.h:225
#define AST_LIST_INSERT_HEAD(head, elm, field)
Inserts a list entry at the head of a list.
Definition: linkedlists.h:711
#define AST_LIST_REMOVE_HEAD(head, field)
Removes and returns the head entry from a list.
Definition: linkedlists.h:833
int errno
static int frames
Definition: parser.c:51
Data structure associated with a single frame of data.
struct ast_frame_subclass subclass
enum ast_frame_type frametype
int done
Definition: test_amihooks.c:48
int ast_remaining_ms(struct timeval start, int max_ms)
Calculate remaining milliseconds given a starting timestamp and upper bound.
Definition: utils.c:2281
struct timeval ast_tvnow(void)
Returns current timeval. Meant to replace calls to gettimeofday().
Definition: time.h:159
#define MAX(a, b)
Definition: utils.h:233

References ast_channel_lock, ast_channel_name(), ast_channel_unlock, AST_CONTROL_HANGUP, ast_debug, AST_FRAME_BRIDGE_ACTION, AST_FRAME_BRIDGE_ACTION_SYNC, 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_RTCP, AST_FRAME_TEXT, AST_FRAME_TEXT_DATA, 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_remaining_ms(), AST_STATE_RING, AST_STATE_RINGING, ast_tvnow(), ast_waitfor(), done, errno, frames, ast_frame::frametype, ast_frame_subclass::integer, LOG_WARNING, MAX, SCOPE_TRACE, and ast_frame::subclass.

Referenced by ast_answer(), pbx_builtin_answer(), and pbx_builtin_incomplete().

◆ __ast_change_name_nolink()

static void __ast_change_name_nolink ( struct ast_channel chan,
const char *  newname 
)
static

this function simply changes the name of the channel and issues a manager_event with out unlinking and linking the channel from the ao2_container. This should only be used when the channel has already been unlinked from the ao2_container.

Definition at line 6761 of file channel.c.

6762{
6763 /*** DOCUMENTATION
6764 <managerEvent language="en_US" name="Rename">
6765 <managerEventInstance class="EVENT_FLAG_CALL">
6766 <synopsis>Raised when the name of a channel is changed.</synopsis>
6767 </managerEventInstance>
6768 </managerEvent>
6769 ***/
6770 ast_manager_event(chan, EVENT_FLAG_CALL, "Rename",
6771 "Channel: %s\r\n"
6772 "Newname: %s\r\n"
6773 "Uniqueid: %s\r\n",
6774 ast_channel_name(chan), newname, ast_channel_uniqueid(chan));
6775 ast_channel_name_set(chan, newname);
6776}
const char * ast_channel_uniqueid(const struct ast_channel *chan)
#define EVENT_FLAG_CALL
Definition: manager.h:76
#define ast_manager_event(chan, category, event, contents,...)
Definition: manager.h:255

References ast_channel_name(), ast_channel_uniqueid(), ast_manager_event, and EVENT_FLAG_CALL.

Referenced by ast_change_name().

◆ __ast_channel_alloc()

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 struct ast_assigned_ids assignedids,
const struct ast_channel requestor,
enum ama_flags  amaflag,
struct ast_endpoint endpoint,
const char *  file,
int  line,
const char *  function,
const char *  name_fmt,
  ... 
)

Create a channel structure.

Since
1.8
Return values
NULLfailure
non-NULLsuccessfully allocated channel
Note
Absolutely NO channel locks should be held before calling this function.
By default, new channels are set to the "s" extension and "default" context.
Since 12.0.0 this function returns with the newly created channel locked.

Definition at line 954 of file channel.c.

961{
962 va_list ap;
963 struct ast_channel *result;
964
965 va_start(ap, name_fmt);
966 result = __ast_channel_alloc_ap(needqueue, state, cid_num, cid_name, acctcode, exten, context,
967 assignedids, requestor, amaflag, endpoint, NULL, file, line, function, name_fmt, ap);
968 va_end(ap);
969
970 return result;
971}
static PGresult * result
Definition: cel_pgsql.c:84
static struct ast_channel * __ast_channel_alloc_ap(int needqueue, int state, const char *cid_num, const char *cid_name, const char *acctcode, const char *exten, const char *context, const struct ast_assigned_ids *assignedids, const struct ast_channel *requestor, enum ama_flags amaflag, struct ast_endpoint *endpoint, struct ast_channel_initializers *initializers, const char *file, int line, const char *function, const char *name_fmt, va_list ap)
Create a new channel structure.
Definition: channel.c:733
#define NULL
Definition: resample.c:96
Main Channel structure associated with a channel.
char exten[AST_MAX_EXTENSION]

References __ast_channel_alloc_ap(), voicemailpwcheck::context, ast_channel::exten, make_ari_stubs::file, NULL, and result.

◆ __ast_channel_alloc_ap()

static struct ast_channel * __ast_channel_alloc_ap ( int  needqueue,
int  state,
const char *  cid_num,
const char *  cid_name,
const char *  acctcode,
const char *  exten,
const char *  context,
const struct ast_assigned_ids assignedids,
const struct ast_channel requestor,
enum ama_flags  amaflag,
struct ast_endpoint endpoint,
struct ast_channel_initializers initializers,
const char *  file,
int  line,
const char *  function,
const char *  name_fmt,
va_list  ap 
)
static

Create a new channel structure.

Definition at line 733 of file channel.c.

738{
739 struct ast_channel *tmp;
740 struct varshead *headp;
741 char *tech = "", *tech2 = NULL;
742 struct ast_format_cap *nativeformats;
743 struct ast_sched_context *schedctx;
744 struct ast_timer *timer;
745 struct timeval now;
746 const struct ast_channel_tech *channel_tech;
747 struct ast_stream_topology *topology;
748
749 /* If shutting down, don't allocate any new channels */
750 if (ast_shutting_down()) {
751 ast_log(LOG_WARNING, "Channel allocation failed: Refusing due to active shutdown\n");
752 return NULL;
753 }
754
755 tmp = __ast_channel_internal_alloc_with_initializers(ast_channel_destructor, assignedids, requestor, initializers,
756 file, line, function);
757 if (!tmp) {
758 /* Channel structure allocation failure. */
759 return NULL;
760 }
761
763
764 /*
765 * Init file descriptors to unopened state so
766 * the destructor can know not to close them.
767 */
771
773 if (!nativeformats) {
774 /*
775 * Aborting the channel creation. We do not need to complete staging
776 * the channel snapshot because the channel has not been finalized or
777 * linked into the channels container yet. Nobody else knows about
778 * this channel nor will anybody ever know about it.
779 */
780 return ast_channel_unref(tmp);
781 }
782 ast_format_cap_append(nativeformats, ast_format_none, 0);
783 ast_channel_nativeformats_set(tmp, nativeformats);
784 ao2_ref(nativeformats, -1);
785
790
791 if (!(schedctx = ast_sched_context_create())) {
792 ast_log(LOG_WARNING, "Channel allocation failed: Unable to create schedule context\n");
793 /* See earlier channel creation abort comment above. */
794 return ast_channel_unref(tmp);
795 }
796 ast_channel_sched_set(tmp, schedctx);
797
803
804 if (cid_name) {
807 if (!ast_channel_caller(tmp)->id.name.str) {
808 /* See earlier channel creation abort comment above. */
809 return ast_channel_unref(tmp);
810 }
811 }
812 if (cid_num) {
815 if (!ast_channel_caller(tmp)->id.number.str) {
816 /* See earlier channel creation abort comment above. */
817 return ast_channel_unref(tmp);
818 }
819 }
820
821 if ((timer = ast_timer_open())) {
823 if (strcmp(ast_timer_get_name(ast_channel_timer(tmp)), "timerfd")) {
824 needqueue = 0;
825 }
827 }
828
829 if (needqueue && ast_channel_internal_alertpipe_init(tmp)) {
830 /* See earlier channel creation abort comment above. */
831 return ast_channel_unref(tmp);
832 }
833
834 if (!(topology = ast_stream_topology_alloc())) {
835 return ast_channel_unref(tmp);
836 }
838
839 /* Always watch the alertpipe */
841 /* And timing pipe */
843
844 /* Initial state */
847
850
853
854 now = ast_tvnow();
856
858
859 if (!ast_strlen_zero(name_fmt)) {
860 char *slash, *slash2;
861 /* Almost every channel is calling this function, and setting the name via the ast_string_field_build() call.
862 * And they all use slightly different formats for their name string.
863 * This means, to set the name here, we have to accept variable args, and call the string_field_build from here.
864 * This means, that the stringfields must have a routine that takes the va_lists directly, and
865 * uses them to build the string, instead of forming the va_lists internally from the vararg ... list.
866 * This new function was written so this can be accomplished.
867 */
868 ast_channel_name_build_va(tmp, name_fmt, ap);
870 if ((slash = strchr(tech, '/'))) {
871 if ((slash2 = strchr(slash + 1, '/'))) {
872 tech2 = slash + 1;
873 *slash2 = '\0';
874 }
875 *slash = '\0';
876 }
877 } else {
878 /*
879 * Start the string with '-' so it becomes an empty string
880 * in the destructor.
881 */
882 ast_channel_name_set(tmp, "-**Unknown**");
883 }
884
885 if (amaflag != AST_AMA_NONE) {
887 } else {
889 }
890
891 if (!ast_strlen_zero(acctcode)) {
892 ast_channel_accountcode_set(tmp, acctcode);
893 }
894 ast_channel_language_set(tmp, ast_defaultlanguage);
895
897 ast_channel_exten_set(tmp, S_OR(exten, "s"));
899
900 headp = ast_channel_varshead(tmp);
902
906
907 channel_tech = ast_get_channel_tech(tech);
908 if (!channel_tech && !ast_strlen_zero(tech2)) {
909 channel_tech = ast_get_channel_tech(tech2);
910 }
911 if (channel_tech) {
912 ast_channel_tech_set(tmp, channel_tech);
913 } else {
915 }
916
917 /* You might scream "locking inversion" at seeing this but it is actually perfectly fine.
918 * Since the channel was just created nothing can know about it yet or even acquire it.
919 */
921
923
924 if (assignedids && (does_id_conflict(assignedids->uniqueid) || does_id_conflict(assignedids->uniqueid2))) {
928 /* See earlier channel creation abort comment above. */
929 return ast_channel_unref(tmp);
930 }
931
932 /* Finalize and link into the channels container. */
936
938
939 if (endpoint) {
940 ast_endpoint_add_channel(endpoint, tmp);
941 }
942
943 /*
944 * And now, since the channel structure is built, and has its name, let
945 * the world know of its existance
946 */
948
949 ast_debug(1, "Channel %p '%s' allocated\n", tmp, ast_channel_name(tmp));
950
951 return tmp;
952}
int ast_shutting_down(void)
Definition: asterisk.c:1877
#define ast_strdup(str)
A wrapper for strdup()
Definition: astmm.h:241
#define ast_strdupa(s)
duplicate a string in memory from the stack
Definition: astmm.h:298
#define ao2_link_flags(container, obj, flags)
Add an object to a container.
Definition: astobj2.h:1554
#define ao2_unlock(a)
Definition: astobj2.h:729
#define ao2_lock(a)
Definition: astobj2.h:717
#define ao2_ref(o, delta)
Reference/unreference an object and return the old refcount.
Definition: astobj2.h:459
@ OBJ_NOLOCK
Assume that the ao2_container is already locked.
Definition: astobj2.h:1063
static int tmp()
Definition: bt_open.c:389
static struct ast_timer * timer
Definition: chan_iax2.c:364
void ast_party_redirecting_init(struct ast_party_redirecting *init)
Initialize the given redirecting structure.
Definition: channel.c:2141
static int does_id_conflict(const char *uniqueid)
Definition: channel.c:711
static const struct ast_channel_tech null_tech
Definition: channel.c:702
static int chancount
Definition: channel.c:93
void ast_party_dialed_init(struct ast_party_dialed *init)
Initialize the given dialed structure.
Definition: channel.c:1947
unsigned long global_fin
Definition: channel.c:95
void ast_party_connected_line_init(struct ast_party_connected_line *init)
Initialize the given connected line structure.
Definition: channel.c:2041
void ast_channel_set_fd(struct ast_channel *chan, int which, int fd)
Definition: channel.c:2445
static void ast_channel_destructor(void *obj)
Free a channel structure.
Definition: channel.c:2211
static struct ao2_container * channels
All active channels on the system.
Definition: channel.c:124
unsigned long global_fout
Definition: channel.c:95
const struct ast_channel_tech * ast_get_channel_tech(const char *name)
Get handle to channel driver based on name.
Definition: channel.c:592
#define DEFAULT_AMA_FLAGS
Definition: channel.c:108
void ast_party_caller_init(struct ast_party_caller *init)
Initialize the given caller structure.
Definition: channel.c:1997
void ast_channel_exten_set(struct ast_channel *chan, const char *value)
struct varshead * ast_channel_varshead(struct ast_channel *chan)
int ast_channel_internal_alert_readfd(struct ast_channel *chan)
void ast_channel_nativeformats_set(struct ast_channel *chan, struct ast_format_cap *value)
void ast_channel_internal_fd_clear_all(struct ast_channel *chan)
void ast_channel_hold_state_set(struct ast_channel *chan, int value)
struct ast_party_redirecting * ast_channel_redirecting(struct ast_channel *chan)
void ast_channel_vstreamid_set(struct ast_channel *chan, int value)
@ AST_CHANNEL_ERROR_ID_EXISTS
Definition: channel.h:4845
void ast_channel_streamid_set(struct ast_channel *chan, int value)
struct ast_party_connected_line * ast_channel_connected(struct ast_channel *chan)
void ast_channel_timingfd_set(struct ast_channel *chan, int value)
@ AST_AMA_NONE
Definition: channel.h:1198
#define AST_ALERT_FD
Definition: channel.h:202
void ast_channel_timer_set(struct ast_channel *chan, struct ast_timer *value)
void ast_channel_fin_set(struct ast_channel *chan, unsigned int value)
void ast_channel_set_rawreadformat(struct ast_channel *chan, struct ast_format *format)
int ast_channel_timingfd(const struct ast_channel *chan)
#define AST_TIMING_FD
Definition: channel.h:203
void ast_channel_set_rawwriteformat(struct ast_channel *chan, struct ast_format *format)
struct ast_party_dialed * ast_channel_dialed(struct ast_channel *chan)
void ast_channel_creationtime_set(struct ast_channel *chan, struct timeval *value)
void ast_channel_set_readformat(struct ast_channel *chan, struct ast_format *format)
#define ast_channel_unref(c)
Decrease channel reference count.
Definition: channel.h:3004
void ast_channel_amaflags_set(struct ast_channel *chan, enum ama_flags value)
struct ast_party_connected_line * ast_channel_connected_indicated(struct ast_channel *chan)
void ast_channel_context_set(struct ast_channel *chan, const char *value)
void ast_channel_state_set(struct ast_channel *chan, enum ast_channel_state)
void ast_channel_fout_set(struct ast_channel *chan, unsigned int value)
struct ast_autochan_list * ast_channel_autochans(struct ast_channel *chan)
struct ast_party_caller * ast_channel_caller(struct ast_channel *chan)
struct ast_timer * ast_channel_timer(const struct ast_channel *chan)
void ast_channel_internal_alertpipe_clear(struct ast_channel *chan)
void ast_channel_priority_set(struct ast_channel *chan, int value)
int ast_channel_internal_alertpipe_init(struct ast_channel *chan)
void ast_channel_sched_set(struct ast_channel *chan, struct ast_sched_context *value)
void ast_channel_tech_set(struct ast_channel *chan, const struct ast_channel_tech *value)
struct ast_datastore_list * ast_channel_datastores(struct ast_channel *chan)
void ast_channel_set_writeformat(struct ast_channel *chan, struct ast_format *format)
void ast_channel_internal_set_stream_topology(struct ast_channel *chan, struct ast_stream_topology *topology)
struct ast_channel * __ast_channel_internal_alloc_with_initializers(void(*destructor)(void *obj), const struct ast_assigned_ids *assignedids, const struct ast_channel *requestor, const struct ast_channel_initializers *initializers, const char *file, int line, const char *function)
int ast_channel_internal_setup_topics(struct ast_channel *chan)
void ast_channel_internal_finalize(struct ast_channel *chan)
void ast_channel_internal_errno_set(enum ast_channel_error error)
int ast_endpoint_add_channel(struct ast_endpoint *endpoint, struct ast_channel *chan)
Adds a channel to the given endpoint.
struct ast_format * ast_format_none
Built-in "null" format.
Definition: format_cache.c:246
@ AST_FORMAT_CAP_FLAG_DEFAULT
Definition: format_cap.h:38
#define ast_format_cap_append(cap, format, framing)
Add format capability to capabilities structure.
Definition: format_cap.h:99
#define ast_format_cap_alloc(flags)
Allocate a new ast_format_cap structure.
Definition: format_cap.h:49
static const char name[]
Definition: format_mp3.c:68
void ast_channel_stage_snapshot_done(struct ast_channel *chan)
Clear flag to indicate channel snapshot is being staged, and publish snapshot.
void ast_channel_stage_snapshot(struct ast_channel *chan)
Set flag to indicate channel snapshot is being staged.
@ AST_CONTROL_UNHOLD
int ast_atomic_fetchadd_int(volatile int *p, int v)
Atomically add v to *p and return the previous value of *p.
Definition: lock.h:757
char ast_defaultlanguage[]
Definition: options.c:98
void ast_pbx_hangup_handler_init(struct ast_channel *chan)
Init the hangup handler container on a channel.
struct ast_sched_context * ast_sched_context_create(void)
Create a scheduler context.
Definition: sched.c:238
struct ast_stream_topology * ast_stream_topology_alloc(void)
Create a stream topology.
Definition: stream.c:650
#define S_OR(a, b)
returns the equivalent of logic or for strings: first one if not empty, otherwise second one.
Definition: strings.h:80
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Definition: strings.h:65
const char * uniqueid2
Definition: channel.h:608
const char * uniqueid
Definition: channel.h:607
Structure to describe a channel "technology", ie a channel driver See for examples:
Definition: channel.h:648
Format capabilities structure, holds formats + preference order + etc.
Definition: format_cap.c:54
struct ast_party_id id
Caller party ID.
Definition: channel.h:422
struct ast_party_name name
Subscriber name.
Definition: channel.h:342
struct ast_party_number number
Subscriber phone number.
Definition: channel.h:344
unsigned char valid
TRUE if the name information is valid/present.
Definition: channel.h:281
char * str
Subscriber name (Malloced)
Definition: channel.h:266
unsigned char valid
TRUE if the number information is valid/present.
Definition: channel.h:299
char * str
Subscriber phone number (Malloced)
Definition: channel.h:293
Number structure.
Definition: app_followme.c:154
const char * ast_timer_get_name(const struct ast_timer *handle)
Get name of timer in use.
Definition: timing.c:196
struct ast_timer * ast_timer_open(void)
Open a timer.
Definition: timing.c:122
int ast_timer_fd(const struct ast_timer *handle)
Get a poll()-able file descriptor for a timer.
Definition: timing.c:161

References __ast_channel_internal_alloc_with_initializers(), ao2_link_flags, ao2_lock, ao2_ref, ao2_unlock, AST_ALERT_FD, AST_AMA_NONE, ast_atomic_fetchadd_int(), ast_channel_amaflags_set(), ast_channel_autochans(), ast_channel_caller(), ast_channel_connected(), ast_channel_connected_indicated(), ast_channel_context_set(), ast_channel_creationtime_set(), ast_channel_datastores(), ast_channel_destructor(), ast_channel_dialed(), AST_CHANNEL_ERROR_ID_EXISTS, ast_channel_exten_set(), ast_channel_fin_set(), ast_channel_fout_set(), ast_channel_hold_state_set(), ast_channel_internal_alert_readfd(), ast_channel_internal_alertpipe_clear(), ast_channel_internal_alertpipe_init(), ast_channel_internal_errno_set(), ast_channel_internal_fd_clear_all(), ast_channel_internal_finalize(), ast_channel_internal_set_stream_topology(), ast_channel_internal_setup_topics(), ast_channel_lock, ast_channel_name(), ast_channel_nativeformats_set(), ast_channel_priority_set(), ast_channel_redirecting(), ast_channel_sched_set(), ast_channel_set_fd(), ast_channel_set_rawreadformat(), ast_channel_set_rawwriteformat(), ast_channel_set_readformat(), ast_channel_set_writeformat(), ast_channel_stage_snapshot(), ast_channel_stage_snapshot_done(), ast_channel_state_set(), ast_channel_streamid_set(), ast_channel_tech_set(), ast_channel_timer(), ast_channel_timer_set(), ast_channel_timingfd(), ast_channel_timingfd_set(), ast_channel_unlock, ast_channel_unref, ast_channel_varshead(), ast_channel_vstreamid_set(), AST_CONTROL_UNHOLD, ast_debug, ast_defaultlanguage, ast_endpoint_add_channel(), ast_format_cap_alloc, ast_format_cap_append, AST_FORMAT_CAP_FLAG_DEFAULT, ast_format_none, ast_get_channel_tech(), AST_LIST_HEAD_INIT_NOLOCK, ast_log, ast_party_caller_init(), ast_party_connected_line_init(), ast_party_dialed_init(), ast_party_redirecting_init(), ast_pbx_hangup_handler_init(), ast_sched_context_create(), ast_shutting_down(), ast_strdup, ast_strdupa, ast_stream_topology_alloc(), ast_strlen_zero(), ast_timer_fd(), ast_timer_get_name(), ast_timer_open(), AST_TIMING_FD, ast_tvnow(), chancount, channels, voicemailpwcheck::context, DEFAULT_AMA_FLAGS, does_id_conflict(), make_ari_stubs::file, global_fin, global_fout, ast_party_caller::id, LOG_WARNING, name, ast_party_id::name, NULL, null_tech, ast_party_id::number, OBJ_NOLOCK, S_OR, ast_party_name::str, ast_party_number::str, timer, tmp(), ast_party_name::valid, and ast_party_number::valid.

Referenced by __ast_channel_alloc(), and __ast_channel_alloc_with_initializers().

◆ __ast_channel_alloc_with_initializers()

struct ast_channel * __ast_channel_alloc_with_initializers ( int  needqueue,
int  state,
const char *  cid_num,
const char *  cid_name,
const char *  acctcode,
const char *  exten,
const char *  context,
const struct ast_assigned_ids assignedids,
const struct ast_channel requestor,
enum ama_flags  amaflag,
struct ast_endpoint endpoint,
struct ast_channel_initializers initializers,
const char *  file,
int  line,
const char *  function,
const char *  name_fmt,
  ... 
)

Create a channel structure.

Since
18.25.0
Return values
NULLfailure
non-NULLsuccessfully allocated channel
Note
Absolutely NO channel locks should be held before calling this function.
By default, new channels are set to the "s" extension and "default" context.
Same as __ast_channel_alloc but with ast_channel_initializers struct.

Definition at line 973 of file channel.c.

980{
981 va_list ap;
982 struct ast_channel *result;
983
984 va_start(ap, name_fmt);
985 result = __ast_channel_alloc_ap(needqueue, state, cid_num, cid_name, acctcode, exten, context,
986 assignedids, requestor, amaflag, endpoint, initializers, file, line, function, name_fmt, ap);
987 va_end(ap);
988
989 return result;
990}

References __ast_channel_alloc_ap(), voicemailpwcheck::context, ast_channel::exten, make_ari_stubs::file, and result.

◆ __ast_dummy_channel_alloc()

struct ast_channel * __ast_dummy_channel_alloc ( const char *  file,
int  line,
const char *  function 
)

Definition at line 994 of file channel.c.

995{
996 struct ast_channel *tmp;
997 struct varshead *headp;
998
1000 file, line, function);
1001 if (!tmp) {
1002 /* Dummy channel structure allocation failure. */
1003 return NULL;
1004 }
1005
1008
1009 /*
1010 * Init file descriptors to unopened state just in case
1011 * autoservice is called on the channel or something tries to
1012 * read a frame from it.
1013 */
1017
1019
1021
1022 headp = ast_channel_varshead(tmp);
1024
1025 return tmp;
1026}
static void ast_dummy_channel_destructor(void *obj)
Free a dummy channel structure.
Definition: channel.c:2352
struct ast_channel * __ast_channel_internal_alloc(void(*destructor)(void *obj), const struct ast_assigned_ids *assignedids, const struct ast_channel *requestor, const char *file, int line, const char *function)

References __ast_channel_internal_alloc(), ast_channel_datastores(), ast_channel_hold_state_set(), ast_channel_internal_alertpipe_clear(), ast_channel_internal_fd_clear_all(), ast_channel_internal_setup_topics(), ast_channel_timingfd_set(), ast_channel_varshead(), AST_CONTROL_UNHOLD, ast_dummy_channel_destructor(), AST_LIST_HEAD_INIT_NOLOCK, ast_pbx_hangup_handler_init(), make_ari_stubs::file, NULL, and tmp().

◆ __ast_queue_frame()

static int __ast_queue_frame ( struct ast_channel chan,
struct ast_frame fin,
int  head,
struct ast_frame after 
)
static

Definition at line 1028 of file channel.c.

1029{
1030 struct ast_frame *f;
1031 struct ast_frame *cur;
1032 unsigned int new_frames = 0;
1033 unsigned int new_voice_frames = 0;
1034 unsigned int queued_frames = 0;
1035 unsigned int queued_voice_frames = 0;
1037
1038 ast_channel_lock(chan);
1039
1040 /*
1041 * Check the last frame on the queue if we are queuing the new
1042 * frames after it.
1043 */
1044 cur = AST_LIST_LAST(ast_channel_readq(chan));
1045 if (cur && cur->frametype == AST_FRAME_CONTROL && !head && (!after || after == cur)) {
1046 switch (cur->subclass.integer) {
1048 if (fin->frametype == AST_FRAME_CONTROL
1049 && fin->subclass.integer == AST_CONTROL_HANGUP) {
1050 /*
1051 * Destroy the end-of-Q marker frame so we can queue the hangup
1052 * frame in its place.
1053 */
1055 ast_frfree(cur);
1056
1057 /*
1058 * This has degenerated to a normal queue append anyway. Since
1059 * we just destroyed the last frame in the queue we must make
1060 * sure that "after" is NULL or bad things will happen.
1061 */
1062 after = NULL;
1063 break;
1064 }
1065 /* Fall through */
1066 case AST_CONTROL_HANGUP:
1067 /* Don't queue anything. */
1068 ast_channel_unlock(chan);
1069 return 0;
1070 default:
1071 break;
1072 }
1073 }
1074
1075 /* Build copies of all the new frames and count them */
1077 for (cur = fin; cur; cur = AST_LIST_NEXT(cur, frame_list)) {
1078 if (!(f = ast_frdup(cur))) {
1079 if (AST_LIST_FIRST(&frames)) {
1081 }
1082 ast_channel_unlock(chan);
1083 return -1;
1084 }
1085
1087 new_frames++;
1088 if (f->frametype == AST_FRAME_VOICE) {
1089 new_voice_frames++;
1090 }
1091 }
1092
1093 /* Count how many frames exist on the queue */
1095 queued_frames++;
1096 if (cur->frametype == AST_FRAME_VOICE) {
1097 queued_voice_frames++;
1098 }
1099 }
1100
1101 if ((queued_frames + new_frames > 128 || queued_voice_frames + new_voice_frames > 96)) {
1102 int total_queued = queued_frames + new_frames;
1103 int total_voice = queued_voice_frames + new_voice_frames;
1104 int count = 0;
1105 ast_log(LOG_WARNING, "Exceptionally long %squeue length (%d voice / %d total) queuing to %s\n",
1106 queued_frames + new_frames > 128 ? "" : "voice ", total_voice, total_queued, ast_channel_name(chan));
1108 /* Save the most recent frame */
1109 if (!AST_LIST_NEXT(cur, frame_list)) {
1110 break;
1111 } else if (cur->frametype == AST_FRAME_VOICE || cur->frametype == AST_FRAME_VIDEO || cur->frametype == AST_FRAME_NULL) {
1112 if (++count > 64) {
1113 break;
1114 }
1116 ast_frfree(cur);
1117
1118 /* Read from the alert pipe for each flushed frame. */
1120 }
1121 }
1123 if (count) {
1124 ast_debug(4, "Discarded %d frame%s due to queue overload on %s\n", count, ESS(count), ast_channel_name(chan));
1125 }
1126 }
1127
1128 if (after) {
1130 } else {
1131 if (head) {
1134 }
1136 }
1137
1138 if (ast_channel_alert_writable(chan)) {
1139 /* Write to the alert pipe for each added frame */
1140 while (new_frames--) {
1141 if (ast_channel_alert_write(chan)) {
1142 ast_log(LOG_WARNING, "Unable to write to alert pipe on %s (qlen = %u): %s!\n",
1143 ast_channel_name(chan), queued_frames, strerror(errno));
1144 break;
1145 }
1146 }
1147 } else if (ast_channel_timingfd(chan) > -1) {
1150 pthread_kill(ast_channel_blocker(chan), SIGURG);
1151 }
1152
1153 ast_channel_unlock(chan);
1154
1155 return 0;
1156}
struct ast_flags * ast_channel_flags(struct ast_channel *chan)
pthread_t ast_channel_blocker(const struct ast_channel *chan)
int ast_channel_alert_write(struct ast_channel *chan)
struct ast_readq_list * ast_channel_readq(struct ast_channel *chan)
ast_alert_status_t ast_channel_internal_alert_read(struct ast_channel *chan)
@ AST_FLAG_BLOCKING
Definition: channel.h:1005
int ast_channel_alert_writable(struct ast_channel *chan)
#define ESS(x)
Definition: cli.h:59
#define ast_frdup(fr)
Copies a frame.
@ AST_CONTROL_END_OF_Q
#define AST_LIST_LAST(head)
Returns the last entry contained in a list.
Definition: linkedlists.h:429
#define AST_LIST_INSERT_LIST_AFTER(head, list, elm, field)
Inserts a whole list after a specific entry in a list.
Definition: linkedlists.h:812
#define AST_LIST_TRAVERSE(head, var, field)
Loops over (traverses) the entries in a list.
Definition: linkedlists.h:491
#define AST_LIST_INSERT_TAIL(head, elm, field)
Appends a list entry to the tail of a list.
Definition: linkedlists.h:731
#define AST_LIST_TRAVERSE_SAFE_END
Closes a safe loop traversal block.
Definition: linkedlists.h:615
#define AST_LIST_REMOVE(head, elm, field)
Removes a specific entry from a list.
Definition: linkedlists.h:856
#define AST_LIST_TRAVERSE_SAFE_BEGIN(head, var, field)
Loops safely over (traverses) the entries in a list.
Definition: linkedlists.h:529
#define AST_LIST_REMOVE_CURRENT(field)
Removes the current entry from a list during a traversal.
Definition: linkedlists.h:557
#define AST_LIST_APPEND_LIST(head, list, field)
Appends a whole list to the tail of a list.
Definition: linkedlists.h:783
#define AST_LIST_FIRST(head)
Returns the first entry contained in a list.
Definition: linkedlists.h:421
#define AST_LIST_NEXT(elm, field)
Returns the next entry in the list after the given entry.
Definition: linkedlists.h:439
int ast_timer_enable_continuous(const struct ast_timer *handle)
Enable continuous mode.
Definition: timing.c:176
#define ast_test_flag(p, flag)
Definition: utils.h:63

References ast_channel_alert_writable(), ast_channel_alert_write(), ast_channel_blocker(), ast_channel_flags(), ast_channel_internal_alert_read(), ast_channel_lock, ast_channel_name(), ast_channel_readq(), ast_channel_timer(), ast_channel_timingfd(), ast_channel_unlock, AST_CONTROL_END_OF_Q, AST_CONTROL_HANGUP, ast_debug, AST_FLAG_BLOCKING, AST_FRAME_CONTROL, AST_FRAME_NULL, AST_FRAME_VIDEO, AST_FRAME_VOICE, ast_frdup, ast_frfree, AST_LIST_APPEND_LIST, AST_LIST_FIRST, AST_LIST_HEAD_INIT_NOLOCK, AST_LIST_HEAD_NOLOCK, AST_LIST_INSERT_LIST_AFTER, AST_LIST_INSERT_TAIL, AST_LIST_LAST, AST_LIST_NEXT, AST_LIST_REMOVE, AST_LIST_REMOVE_CURRENT, AST_LIST_TRAVERSE, AST_LIST_TRAVERSE_SAFE_BEGIN, AST_LIST_TRAVERSE_SAFE_END, ast_log, ast_test_flag, ast_timer_enable_continuous(), errno, ESS, frames, ast_frame::frametype, ast_frame_subclass::integer, LOG_WARNING, NULL, and ast_frame::subclass.

Referenced by __ast_read(), ast_queue_frame(), and ast_queue_frame_head().

◆ __ast_read()

static struct ast_frame * __ast_read ( struct ast_channel chan,
int  dropaudio,
int  dropnondefault 
)
static
Todo:
XXX It is possible to write a digit to the audiohook twice if the digit was originally read while the channel was in autoservice.

Definition at line 3544 of file channel.c.

3545{
3546 struct ast_frame *f = NULL; /* the return value */
3547 int prestate;
3548 int cause = 0;
3549 struct ast_stream *stream = NULL, *default_stream = NULL;
3550
3551 /* this function is very long so make sure there is only one return
3552 * point at the end (there are only two exceptions to this).
3553 */
3554 ast_channel_lock(chan);
3555
3556 /* Stop if we're a zombie or need a soft hangup */
3558 if (ast_channel_generator(chan))
3560
3561 /*
3562 * It is possible for chan->_softhangup to be set and there
3563 * still be control frames that need to be read. Instead of
3564 * just going to 'done' in the case of ast_check_hangup(), we
3565 * need to queue the end-of-Q frame so that it can mark the end
3566 * of the read queue. If there are frames to be read,
3567 * ast_queue_control() will be called repeatedly, but will only
3568 * queue the first end-of-Q frame.
3569 */
3572 } else {
3573 goto done;
3574 }
3575 } else {
3576#ifdef AST_DEVMODE
3577 /*
3578 * The ast_waitfor() code records which of the channel's file
3579 * descriptors reported that data is available. In theory,
3580 * ast_read() should only be called after ast_waitfor() reports
3581 * that a channel has data available for reading. However,
3582 * there still may be some edge cases throughout the code where
3583 * ast_read() is called improperly. This can potentially cause
3584 * problems, so if this is a developer build, make a lot of
3585 * noise if this happens so that it can be addressed.
3586 *
3587 * One of the potential problems is blocking on a dead channel.
3588 */
3589 if (ast_channel_fdno(chan) == -1) {
3591 "ast_read() on chan '%s' called with no recorded file descriptor.\n",
3592 ast_channel_name(chan));
3593 }
3594#endif
3595 }
3596
3597 prestate = ast_channel_state(chan);
3598
3599 if (ast_channel_timingfd(chan) > -1 && ast_channel_fdno(chan) == AST_TIMING_FD) {
3600 enum ast_timer_event res;
3601 int trigger_dtmf_emulating = should_trigger_dtmf_emulating(chan);
3602
3604
3606
3607 switch (res) {
3609 if (ast_timer_ack(ast_channel_timer(chan), 1) < 0) {
3610 ast_log(LOG_ERROR, "Failed to acknowledge timer in ast_read\n");
3611 goto done;
3612 }
3613
3614 if (ast_channel_timingfunc(chan)) {
3615 /* save a copy of func/data before unlocking the channel */
3617 void *data = ast_channel_timingdata(chan);
3618 int got_ref = 0;
3620 ao2_ref(data, 1);
3621 got_ref = 1;
3622 }
3623 ast_channel_fdno_set(chan, -1);
3624 ast_channel_unlock(chan);
3625 func(data);
3626 if (got_ref) {
3627 ao2_ref(data, -1);
3628 }
3629
3630 if (trigger_dtmf_emulating) {
3631 /*
3632 * Since we're breaking out of this switch block and not
3633 * returning, we need to re-lock the channel.
3634 */
3635 ast_channel_lock(chan);
3636 /* generate null frame to trigger dtmf emulating */
3637 f = &ast_null_frame;
3638 break;
3639 }
3640 } else if (trigger_dtmf_emulating) {
3641 /* generate null frame to trigger dtmf emulating */
3642 f = &ast_null_frame;
3643 break;
3644 } else {
3646 /* generate very last null frame to trigger dtmf emulating */
3647 f = &ast_null_frame;
3648 break;
3649 }
3650
3651 /* cannot 'goto done' because the channel is already unlocked */
3652 return &ast_null_frame;
3653
3655 if (AST_LIST_EMPTY(ast_channel_readq(chan)) ||
3658 }
3659 break;
3660 }
3661
3663 /* if the AST_GENERATOR_FD is set, call the generator with args
3664 * set to -1 so it can do whatever it needs to.
3665 */
3666 void *tmp = ast_channel_generatordata(chan);
3667 ast_channel_generatordata_set(chan, NULL); /* reset to let ast_write get through */
3668 ast_channel_generator(chan)->generate(chan, tmp, -1, -1);
3670 f = &ast_null_frame;
3671 ast_channel_fdno_set(chan, -1);
3672 goto done;
3675 }
3676
3677 /* Read and ignore anything on the alertpipe, but read only
3678 one sizeof(blah) per frame that we send from it */
3680 f = &ast_null_frame;
3681 goto done;
3682 }
3683
3684 /* Check for pending read queue */
3685 if (!AST_LIST_EMPTY(ast_channel_readq(chan))) {
3686 int skipped_dtmf_frame = 0;
3687 int skip_dtmf = should_skip_dtmf(chan);
3688
3690 /* We have to be picky about which frame we pull off of the readq because
3691 * there are cases where we want to leave DTMF frames on the queue until
3692 * some later time. */
3693
3694 if ( (f->frametype == AST_FRAME_DTMF_BEGIN || f->frametype == AST_FRAME_DTMF_END) && skip_dtmf) {
3695 skipped_dtmf_frame = 1;
3696 continue;
3697 }
3698
3700 break;
3701 }
3703
3704 if (!f) {
3705 /* There were no acceptable frames on the readq. */
3706 f = &ast_null_frame;
3707 if (!skipped_dtmf_frame) {
3708 /*
3709 * Do not trigger alert pipe if only buffered dtmf begin or end frames
3710 * are left in the readq.
3711 */
3713 } else {
3714 /*
3715 * Safely disable continous timer events if only buffered dtmf begin or end
3716 * frames are left in the readq.
3717 */
3719 }
3720 }
3721
3722 /* Interpret hangup and end-of-Q frames to return NULL */
3723 /* XXX why not the same for frames from the channel ? */
3724 if (f->frametype == AST_FRAME_CONTROL) {
3725 switch (f->subclass.integer) {
3726 case AST_CONTROL_HANGUP:
3728 cause = f->data.uint32;
3729 /* Fall through */
3731 ast_frfree(f);
3732 f = NULL;
3733 break;
3734 default:
3735 break;
3736 }
3737 } else if (f->frametype == AST_FRAME_VOICE || f->frametype == AST_FRAME_VIDEO) {
3738 if (ast_channel_tech(chan) && ast_channel_tech(chan)->read_stream) {
3741 } else {
3742 /* Since this channel driver does not support multistream determine the default stream this frame
3743 * originated from and update the frame to include it.
3744 */
3745 stream = default_stream = ast_channel_get_default_stream(chan, ast_format_get_type(f->subclass.format));
3746 /* In order to allow media to be passed up the underlying media type has to have a format negotiated on
3747 * the channel itself. In cases where this hasn't happened the channel driver is incorrectly passing up
3748 * a frame for a format that has not been negotiated. If this occurs just drop the frame as we have no
3749 * stream that it came from.
3750 */
3751 if (!stream) {
3752 ast_frfree(f);
3753 f = &ast_null_frame;
3754 } else {
3756 }
3757 }
3758 }
3759 } else {
3761 if (ast_channel_tech(chan)->exception)
3762 f = ast_channel_tech(chan)->exception(chan);
3763 else {
3764 ast_log(LOG_WARNING, "Exception flag set on '%s', but no exception handler\n", ast_channel_name(chan));
3765 f = &ast_null_frame;
3766 }
3767 /* Clear the exception flag */
3769 } else if (ast_channel_tech(chan) && ast_channel_tech(chan)->read_stream) {
3770 f = ast_channel_tech(chan)->read_stream(chan);
3771
3772 /* This channel driver supports multistream so the stream_num on the frame is valid, the only
3773 * thing different is that we need to find the default stream so we know whether to invoke the
3774 * default stream logic or not (such as transcoding).
3775 */
3776 if (f && (f->frametype == AST_FRAME_VOICE || f->frametype == AST_FRAME_VIDEO)) {
3779 }
3780 } else if (ast_channel_tech(chan) && ast_channel_tech(chan)->read) {
3781 f = ast_channel_tech(chan)->read(chan);
3782
3783 /* Since this channel driver does not support multistream determine the default stream this frame
3784 * originated from and update the frame to include it.
3785 */
3786 if (f && (f->frametype == AST_FRAME_VOICE || f->frametype == AST_FRAME_VIDEO)) {
3787 stream = default_stream = ast_channel_get_default_stream(chan, ast_format_get_type(f->subclass.format));
3788 if (!stream) {
3789 ast_frfree(f);
3790 f = &ast_null_frame;
3791 } else {
3793 }
3794 }
3795 }
3796 else
3797 ast_log(LOG_WARNING, "No read routine on channel %s\n", ast_channel_name(chan));
3798 }
3799
3800 if (stream == default_stream) {
3801 /* Perform the framehook read event here. After the frame enters the framehook list
3802 * there is no telling what will happen, <insert mad scientist laugh here>!!! */
3804 }
3805
3806 /*
3807 * Reset the recorded file descriptor that triggered this read so that we can
3808 * easily detect when ast_read() is called without properly using ast_waitfor().
3809 */
3810 ast_channel_fdno_set(chan, -1);
3811
3812 if (f) {
3813 struct ast_frame *readq_tail = AST_LIST_LAST(ast_channel_readq(chan));
3814 struct ast_control_read_action_payload *read_action_payload;
3816 int hooked = 0;
3817
3818 /* if the channel driver returned more than one frame, stuff the excess
3819 into the readq for the next ast_read call
3820 */
3821 if (AST_LIST_NEXT(f, frame_list)) {
3825 }
3826
3827 if (dropnondefault && stream != default_stream) {
3828 /* If the frame originates from a non-default stream and the caller can not handle other streams
3829 * absorb the frame and replace it with a null one instead.
3830 */
3831 ast_frfree(f);
3832 f = &ast_null_frame;
3833 }
3834
3835 switch (f->frametype) {
3836 case AST_FRAME_CONTROL:
3838 if (prestate == AST_STATE_UP && ast_channel_is_bridged(chan)) {
3839 ast_debug(1, "Dropping duplicate answer!\n");
3840 ast_frfree(f);
3841 f = &ast_null_frame;
3842 } else {
3843 /*
3844 * Mark when outgoing channel answered so we can know how
3845 * long the channel has been up.
3846 */
3848
3850 }
3851 } else if (f->subclass.integer == AST_CONTROL_READ_ACTION) {
3852 read_action_payload = f->data.ptr;
3853 switch (read_action_payload->action) {
3857 if (ast_connected_line_parse_data(read_action_payload->payload,
3858 read_action_payload->payload_size, &connected)) {
3860 break;
3861 }
3862 ast_channel_unlock(chan);
3865 read_action_payload->payload,
3866 read_action_payload->payload_size);
3867 }
3869 ast_channel_lock(chan);
3870 break;
3872 ast_channel_unlock(chan);
3873 ast_sendtext(chan, (const char *)read_action_payload->payload);
3874 ast_channel_lock(chan);
3875 break;
3877 ast_channel_unlock(chan);
3878 ast_sendtext_data(chan, (struct ast_msg_data *)read_action_payload->payload);
3879 ast_channel_lock(chan);
3880 break;
3881 }
3882 ast_frfree(f);
3883 f = &ast_null_frame;
3884 } else if (f->subclass.integer == AST_CONTROL_STREAM_TOPOLOGY_REQUEST_CHANGE && dropnondefault) {
3885 /* The caller of this function is incapable of handling streams so we don't accept the change request
3886 * and stick to the streams currently on the channel.
3887 */
3889 ast_frfree(f);
3890 f = &ast_null_frame;
3891 } else if (f->subclass.integer == AST_CONTROL_STREAM_TOPOLOGY_CHANGED && dropnondefault) {
3892 /* The caller of this function is incapable of handling streams so we absorb the notification that the
3893 * stream topology has changed.
3894 */
3895 ast_frfree(f);
3896 f = &ast_null_frame;
3897 } else if (f->subclass.integer == AST_CONTROL_FLASH) {
3898 send_flash_event(chan);
3899 } else if (f->subclass.integer == AST_CONTROL_WINK) {
3900 send_wink_event(chan);
3901 }
3902 break;
3903 case AST_FRAME_DTMF_END:
3905 ast_log(LOG_DTMF, "DTMF end '%c' received on %s, duration %ld ms\n", f->subclass.integer, ast_channel_name(chan), f->len);
3906 /* Queue it up if DTMF is deferred, or if DTMF emulation is forced. */
3908 queue_dtmf_readq(chan, f);
3909 ast_frfree(f);
3910 f = &ast_null_frame;
3912 if (!ast_tvzero(*ast_channel_dtmf_tv(chan)) &&
3914 /* If it hasn't been long enough, defer this digit */
3915 queue_dtmf_readq(chan, f);
3916 ast_frfree(f);
3917 f = &ast_null_frame;
3918 } else {
3919 /* There was no begin, turn this into a begin and send the end later */
3920 struct timeval tv = ast_tvnow();
3924 ast_channel_dtmf_tv_set(chan, &tv);
3925 if (f->len) {
3926 if (f->len > option_dtmfminduration)
3928 else
3930 } else
3932 ast_log(LOG_DTMF, "DTMF begin emulation of '%c' with duration %u queued on %s\n", f->subclass.integer, ast_channel_emulate_dtmf_duration(chan), ast_channel_name(chan));
3933
3934 /*
3935 * Start generating 50 fps timer events (null frames) for dtmf emulating
3936 * independently from any existing incoming voice frames.
3937 * If channel generator is already activated in regular mode use these
3938 * timer events to generate null frames.
3939 */
3940 if (!ast_channel_generator(chan)) {
3942 }
3943 }
3944 if (ast_channel_audiohooks(chan)) {
3945 struct ast_frame *old_frame = f;
3946 /*!
3947 * \todo XXX It is possible to write a digit to the audiohook twice
3948 * if the digit was originally read while the channel was in autoservice. */
3950 if (old_frame != f)
3951 ast_frfree(old_frame);
3952 }
3953 } else {
3954 struct timeval now = ast_tvnow();
3956 ast_log(LOG_DTMF, "DTMF end accepted with begin '%c' on %s\n", f->subclass.integer, ast_channel_name(chan));
3958 if (!f->len)
3959 f->len = ast_tvdiff_ms(now, *ast_channel_dtmf_tv(chan));
3960
3961 /* detect tones that were received on
3962 * the wire with durations shorter than
3963 * option_dtmfminduration and set f->len
3964 * to the actual duration of the DTMF
3965 * frames on the wire. This will cause
3966 * dtmf emulation to be triggered later
3967 * on.
3968 */
3970 f->len = ast_tvdiff_ms(now, *ast_channel_dtmf_tv(chan));
3971 ast_log(LOG_DTMF, "DTMF end '%c' detected to have actual duration %ld on the wire, emulation will be triggered on %s\n", f->subclass.integer, f->len, ast_channel_name(chan));
3972 }
3973 } else if (!f->len) {
3974 ast_log(LOG_DTMF, "DTMF end accepted without begin '%c' on %s\n", f->subclass.integer, ast_channel_name(chan));
3976 }
3978 ast_log(LOG_DTMF, "DTMF end '%c' has duration %ld but want minimum %u, emulating on %s\n", f->subclass.integer, f->len, option_dtmfminduration, ast_channel_name(chan));
3982 ast_frfree(f);
3983 f = &ast_null_frame;
3984
3985 /* Start generating 50 fps timer events (null frames) for dtmf emulating
3986 * independently from any existing incoming voice frames.
3987 * If channel generator is already activated in regular mode use these
3988 * timer events to generate null frames.
3989 */
3990 if (!ast_channel_generator(chan)) {
3992 }
3993 } else {
3994 ast_log(LOG_DTMF, "DTMF end passthrough '%c' on %s\n", f->subclass.integer, ast_channel_name(chan));
3995 if (f->len < option_dtmfminduration) {
3997 }
3998 ast_channel_dtmf_tv_set(chan, &now);
3999
4000 /* Start generating 50 fps timer events (null frames) for dtmf emulating
4001 * independently from any existing incoming voice frames.
4002 * If channel generator is already activated in regular mode use these
4003 * timer events to generate null frames.
4004 */
4005 if (!ast_channel_generator(chan)) {
4007 }
4008 }
4009 if (ast_channel_audiohooks(chan)) {
4010 struct ast_frame *old_frame = f;
4012 if (old_frame != f)
4013 ast_frfree(old_frame);
4014 }
4015 }
4016 break;
4019 ast_log(LOG_DTMF, "DTMF begin '%c' received on %s\n", f->subclass.integer, ast_channel_name(chan));
4021 (!ast_tvzero(*ast_channel_dtmf_tv(chan)) &&
4023 ast_log(LOG_DTMF, "DTMF begin ignored '%c' on %s\n", f->subclass.integer, ast_channel_name(chan));
4024 ast_frfree(f);
4025 f = &ast_null_frame;
4026 } else {
4027 struct timeval now = ast_tvnow();
4029 ast_channel_dtmf_tv_set(chan, &now);
4030 ast_log(LOG_DTMF, "DTMF begin passthrough '%c' on %s\n", f->subclass.integer, ast_channel_name(chan));
4031 }
4032 break;
4033 case AST_FRAME_NULL:
4034 /* The EMULATE_DTMF flag must be cleared here as opposed to when the duration
4035 * is reached , because we want to make sure we pass at least one
4036 * voice frame through before starting the next digit, to ensure a gap
4037 * between DTMF digits. */
4039 struct timeval now = ast_tvnow();
4043 } else if (ast_tvdiff_ms(now, *ast_channel_dtmf_tv(chan)) >= ast_channel_emulate_dtmf_duration(chan)) {
4045 ast_frfree(f);
4046 f = ast_channel_dtmff(chan);
4049 f->len = ast_tvdiff_ms(now, *ast_channel_dtmf_tv(chan));
4050 ast_channel_dtmf_tv_set(chan, &now);
4053 ast_log(LOG_DTMF, "DTMF end emulation of '%c' queued on %s\n", f->subclass.integer, ast_channel_name(chan));
4054 if (ast_channel_audiohooks(chan)) {
4055 struct ast_frame *old_frame = f;
4057 if (old_frame != f) {
4058 ast_frfree(old_frame);
4059 }
4060 }
4061
4062 /* Start generating 50 fps timer events (null frames) for dtmf emulating
4063 * independently from any existing incoming voice frames.
4064 * If channel generator is already activated in regular mode use these
4065 * timer events to generate null frames.
4066 */
4067 if (!ast_channel_generator(chan)) {
4069 }
4070 }
4071 }
4072 break;
4073 case AST_FRAME_VOICE:
4074 /* If media was received from a non-default stream don't perform any actions, let it just go through */
4075 if (stream != default_stream) {
4076 break;
4077 }
4078
4079 /* The EMULATE_DTMF flag must be cleared here as opposed to when the duration
4080 * is reached , because we want to make sure we pass at least one
4081 * voice frame through before starting the next digit, to ensure a gap
4082 * between DTMF digits. */
4086 }
4087
4088 if (dropaudio || ast_test_flag(ast_channel_flags(chan), AST_FLAG_IN_DTMF)) {
4089 if (dropaudio)
4091 ast_frfree(f);
4092 f = &ast_null_frame;
4093 }
4094
4096 struct timeval now = ast_tvnow();
4099 ast_frfree(f);
4100 f = ast_channel_dtmff(chan);
4103 f->len = ast_tvdiff_ms(now, *ast_channel_dtmf_tv(chan));
4104 ast_channel_dtmf_tv_set(chan, &now);
4105 if (ast_channel_audiohooks(chan)) {
4106 struct ast_frame *old_frame = f;
4108 if (old_frame != f)
4109 ast_frfree(old_frame);
4110 }
4111 ast_log(LOG_DTMF, "DTMF end emulation of '%c' queued on %s\n", f->subclass.integer, ast_channel_name(chan));
4112 } else {
4113 /* Drop voice frames while we're still in the middle of the digit */
4114 ast_frfree(f);
4115 f = &ast_null_frame;
4116 }
4117 break;
4118 }
4119 if (f->frametype != AST_FRAME_VOICE) {
4120 break;
4121 }
4124 struct ast_format *core_format;
4125
4126 /*
4127 * Note: This frame may not be one of the current native
4128 * formats. We may have gotten it out of the read queue from
4129 * a previous multi-frame translation, from a framehook
4130 * injected frame, or the device we're talking to isn't
4131 * respecting negotiated formats. Regardless we will accept
4132 * all frames.
4133 *
4134 * Update the read translation path to handle the new format
4135 * that just came in. If the core wants slinear we need to
4136 * setup a new translation path because the core is usually
4137 * doing something with the audio itself and may not handle
4138 * any other format. e.g., Softmix bridge, holding bridge
4139 * announcer channel, recording, AMD... Otherwise, we'll
4140 * setup to pass the frame as is to the core. In this case
4141 * the core doesn't care. The channel is likely in
4142 * autoservice, safesleep, or the channel is in a bridge.
4143 * Let the bridge technology deal with format compatibility
4144 * between the channels in the bridge.
4145 *
4146 * Beware of the transcode_via_slin and genericplc options as
4147 * they force any transcoding to go through slin on a bridge.
4148 * Unfortunately transcode_via_slin is enabled by default and
4149 * genericplc is enabled in the codecs.conf.sample file.
4150 *
4151 * XXX Only updating translation to slinear frames has some
4152 * corner cases if slinear is one of the native formats and
4153 * there are different sample rates involved. We might wind
4154 * up with conflicting translation paths between channels
4155 * where the read translation path on this channel reduces
4156 * the sample rate followed by a write translation path on
4157 * the peer channel that increases the sample rate.
4158 */
4159 core_format = ast_channel_readformat(chan);
4160 if (!ast_format_cache_is_slinear(core_format)) {
4161 core_format = f->subclass.format;
4162 }
4163 if (ast_set_read_format_path(chan, f->subclass.format, core_format)) {
4164 /* Drop frame. We couldn't make it compatible with the core. */
4165 ast_frfree(f);
4166 f = &ast_null_frame;
4167 break;
4168 }
4169 }
4170 /*
4171 * Send frame to audiohooks if present, if frametype is linear, to preserve
4172 * functional compatibility with previous behavior. If not linear, hold off
4173 * until transcoding is done where we are more likely to have a linear frame
4174 */
4176 /* Place hooked after declaration */
4177 struct ast_frame *old_frame = f;
4178 hooked = 1;
4179
4181 if (old_frame != f) {
4182 ast_frfree(old_frame);
4183 }
4184 }
4185
4186 if (ast_channel_readtrans(chan)
4188 f = ast_translate(ast_channel_readtrans(chan), f, 1);
4189 if (!f) {
4190 f = &ast_null_frame;
4191 }
4192 }
4193
4194 /* Second chance at hooking a linear frame, also the last chance */
4195 if (ast_channel_audiohooks(chan) && !hooked) {
4196 struct ast_frame *old_frame = f;
4197
4199 if (old_frame != f) {
4200 ast_frfree(old_frame);
4201 }
4202 }
4203
4204 /*
4205 * It is possible for the translation process on the channel to have
4206 * produced multiple frames from the single input frame we passed it; if
4207 * this happens, queue the additional frames *before* the frames we may
4208 * have queued earlier. if the readq was empty, put them at the head of
4209 * the queue, and if it was not, put them just after the frame that was
4210 * at the end of the queue.
4211 */
4212 if (AST_LIST_NEXT(f, frame_list)) {
4213 struct ast_frame *cur, *multi_frame = AST_LIST_NEXT(f, frame_list);
4214
4215 /* Mark these frames as being re-queued */
4216 for (cur = multi_frame; cur; cur = AST_LIST_NEXT(cur, frame_list)) {
4218 }
4219
4220 if (!readq_tail) {
4221 ast_queue_frame_head(chan, multi_frame);
4222 } else {
4223 __ast_queue_frame(chan, multi_frame, 0, readq_tail);
4224 }
4225 ast_frfree(multi_frame);
4227 }
4228
4229 /*
4230 * Run generator sitting on the line if timing device not available
4231 * and synchronous generation of outgoing frames is necessary
4232 */
4234 break;
4235 case AST_FRAME_RTCP:
4236 /* Incoming RTCP feedback needs to get to the translator for
4237 * outgoing media, which means we treat it as an ast_write */
4238 if (ast_channel_writetrans(chan)) {
4240 }
4241 break;
4242 default:
4243 /* Just pass it on! */
4244 break;
4245 }
4246 } else {
4247 /* Make sure we always return NULL in the future */
4250 }
4251 if (cause)
4252 ast_channel_hangupcause_set(chan, cause);
4253 if (ast_channel_generator(chan))
4255 /* We no longer End the CDR here */
4256 }
4257
4258 /* High bit prints debugging */
4259 if (ast_channel_fin(chan) & DEBUGCHAN_FLAG)
4260 ast_frame_dump(ast_channel_name(chan), f, "<<");
4262
4263done:
4266
4268 /* The list gets recreated if audiohooks are added again later */
4271 }
4272 ast_channel_unlock(chan);
4273 return f;
4274}
@ AST_ALERT_READ_FATAL
Definition: alertpipe.h:28
char digit
struct ast_frame * ast_audiohook_write_list(struct ast_channel *chan, struct ast_audiohook_list *audiohook_list, enum ast_audiohook_direction direction, struct ast_frame *frame)
Pass a frame off to be handled by the audiohook core.
Definition: audiohook.c:1079
@ AST_AUDIOHOOK_DIRECTION_READ
Definition: audiohook.h:49
int ast_audiohook_write_list_empty(struct ast_audiohook_list *audiohook_list)
Determine if a audiohook_list is empty or not.
Definition: audiohook.c:1071
void ast_audiohook_detach_list(struct ast_audiohook_list *audiohook_list)
Detach audiohooks from list and destroy said list.
Definition: audiohook.c:565
static void send_dtmf_begin_event(struct ast_channel *chan, enum DtmfDirection direction, const char digit)
Definition: channel.c:3389
int ast_set_read_format_path(struct ast_channel *chan, struct ast_format *raw_format, struct ast_format *core_format)
Set specific read path on channel.
Definition: channel.c:5507
#define AST_MIN_DTMF_GAP
Definition: channel.c:112
static void ast_read_generator_actions(struct ast_channel *chan, struct ast_frame *f)
Definition: channel.c:3432
int ast_queue_frame(struct ast_channel *chan, struct ast_frame *fin)
Queue one or more frames to a channel's frame queue.
Definition: channel.c:1158
void ast_party_connected_line_free(struct ast_party_connected_line *doomed)
Destroy the connected line information contents.
Definition: channel.c:2091
int ast_sendtext_data(struct ast_channel *chan, struct ast_msg_data *msg)
Sends text to a channel in an ast_msg_data structure wrapper with ast_sendtext as fallback.
Definition: channel.c:4770
#define AST_DEFAULT_EMULATE_DTMF_DURATION
Definition: channel.c:102
static void queue_dtmf_readq(struct ast_channel *chan, struct ast_frame *f)
Definition: channel.c:3486
int ast_channel_stream_topology_changed(struct ast_channel *chan, struct ast_stream_topology *topology)
Provide notice to a channel that the stream topology has changed.
Definition: channel.c:11018
void ast_party_connected_line_copy(struct ast_party_connected_line *dest, const struct ast_party_connected_line *src)
Copy the source connected line information to the destination connected line.
Definition: channel.c:2050
int ast_queue_control(struct ast_channel *chan, enum ast_control_frame_type control)
Queue a control frame.
Definition: channel.c:1250
static int should_skip_dtmf(struct ast_channel *chan)
Determine whether or not we should ignore DTMF in the readq.
Definition: channel.c:3504
int ast_setstate(struct ast_channel *chan, enum ast_channel_state state)
Change the state of a channel.
Definition: channel.c:7408
void ast_deactivate_generator(struct ast_channel *chan)
Definition: channel.c:2912
int ast_sendtext(struct ast_channel *chan, const char *text)
Sends text to a channel.
Definition: channel.c:4828
int ast_connected_line_parse_data(const unsigned char *data, size_t datalen, struct ast_party_connected_line *connected)
Parse connected line indication frame data.
Definition: channel.c:8807
int ast_check_hangup(struct ast_channel *chan)
Checks to see if a channel is needing hang up.
Definition: channel.c:445
int ast_channel_is_bridged(const struct ast_channel *chan)
Determine if a channel is in a bridge.
Definition: channel.c:10567
static void send_flash_event(struct ast_channel *chan)
Definition: channel.c:3422
static void send_dtmf_end_event(struct ast_channel *chan, enum DtmfDirection direction, const char digit, long duration_ms)
Definition: channel.c:3405
int ast_channel_connected_line_sub(struct ast_channel *autoservice_chan, struct ast_channel *sub_chan, const void *connected_info, int is_frame)
Run a connected line interception subroutine and update a channel's connected line information.
Definition: channel.c:10360
int ast_indicate_data(struct ast_channel *chan, int _condition, const void *data, size_t datalen)
Indicates condition of channel, with payload.
Definition: channel.c:4672
static void set_channel_answer_time(struct ast_channel *chan)
Definition: channel.c:2647
static int should_trigger_dtmf_emulating(struct ast_channel *chan)
Determine whether or not we have to trigger dtmf emulating using 50 fps timer events especially when ...
Definition: channel.c:2874
static int __ast_queue_frame(struct ast_channel *chan, struct ast_frame *fin, int head, struct ast_frame *after)
Definition: channel.c:1028
static void send_wink_event(struct ast_channel *chan)
Definition: channel.c:3427
int(* ast_timing_func_t)(const void *data)
Definition: channel.h:919
struct ast_format * ast_channel_rawreadformat(struct ast_channel *chan)
#define DEBUGCHAN_FLAG
Definition: channel.h:877
void * ast_channel_music_state(const struct ast_channel *chan)
unsigned int ast_channel_fin(const struct ast_channel *chan)
void * ast_channel_timingdata(const struct ast_channel *chan)
#define AST_GENERATOR_FD
Definition: channel.h:205
void ast_channel_dtmf_tv_set(struct ast_channel *chan, struct timeval *value)
int ast_channel_fdno(const struct ast_channel *chan)
struct ast_trans_pvt * ast_channel_readtrans(const struct ast_channel *chan)
struct ast_trans_pvt * ast_channel_writetrans(const struct ast_channel *chan)
void ast_channel_generatordata_set(struct ast_channel *chan, void *value)
char ast_channel_dtmf_digit_to_emulate(const struct ast_channel *chan)
struct ast_framehook_list * ast_channel_framehooks(const struct ast_channel *chan)
void ast_channel_audiohooks_set(struct ast_channel *chan, struct ast_audiohook_list *value)
struct ast_audiohook_list * ast_channel_audiohooks(const struct ast_channel *chan)
void * ast_channel_generatordata(const struct ast_channel *chan)
struct ast_stream_topology * ast_channel_get_stream_topology(const struct ast_channel *chan)
Retrieve the topology of streams on a channel.
void ast_channel_fdno_set(struct ast_channel *chan, int value)
ast_timing_func_t ast_channel_timingfunc(const struct ast_channel *chan)
void ast_channel_dtmf_digit_to_emulate_set(struct ast_channel *chan, char value)
void ast_channel_softhangup_internal_flag_add(struct ast_channel *chan, int value)
struct ast_stream * ast_channel_get_default_stream(struct ast_channel *chan, enum ast_media_type type)
Retrieve the default stream of a specific media type on a channel.
@ AST_SOFTHANGUP_DEV
Definition: channel.h:1141
struct ast_generator * ast_channel_generator(const struct ast_channel *chan)
void ast_channel_emulate_dtmf_duration_set(struct ast_channel *chan, unsigned int value)
struct ast_frame * ast_channel_dtmff(struct ast_channel *chan)
unsigned int ast_channel_emulate_dtmf_duration(const struct ast_channel *chan)
@ AST_FLAG_ZOMBIE
Definition: channel.h:1007
@ AST_FLAG_END_DTMF_ONLY
Definition: channel.h:1027
@ AST_FLAG_EXCEPTION
Definition: channel.h:1009
@ AST_FLAG_EMULATE_DTMF
Definition: channel.h:1024
@ AST_FLAG_IN_DTMF
Definition: channel.h:1021
@ AST_FLAG_DEFER_DTMF
Definition: channel.h:1001
@ AST_FLAG_TIMINGDATA_IS_AO2_OBJ
Definition: channel.h:1074
#define AST_JITTERBUFFER_FD
Definition: channel.h:206
const struct ast_channel_tech * ast_channel_tech(const struct ast_channel *chan)
int ast_channel_softhangup_internal_flag(struct ast_channel *chan)
struct timeval * ast_channel_dtmf_tv(struct ast_channel *chan)
#define FRAMECOUNT_INC(x)
Definition: channel.h:880
void ast_channel_hangupcause_set(struct ast_channel *chan, int value)
int ast_channel_fd_isset(const struct ast_channel *chan, int which)
struct ast_format * ast_channel_readformat(struct ast_channel *chan)
@ AST_STATE_UP
Definition: channelstate.h:42
char connected
Definition: eagi_proxy.c:82
enum ast_media_type ast_format_get_type(const struct ast_format *format)
Get the media type of a format.
Definition: format.c:354
enum ast_format_cmp_res ast_format_cmp(const struct ast_format *format1, const struct ast_format *format2)
Compare two formats.
Definition: format.c:201
@ AST_FORMAT_CMP_EQUAL
Definition: format.h:36
int ast_format_cache_is_slinear(struct ast_format *format)
Determines if a format is one of the cached slin formats.
Definition: format_cache.c:534
struct ast_frame * ast_framehook_list_read_event(struct ast_framehook_list *framehooks, struct ast_frame *frame)
This is used by the channel API push a frame read event to a channel's framehook list.
Definition: framehook.c:318
unsigned int option_dtmfminduration
Definition: options.c:83
@ AST_FRFLAG_REQUEUED
@ AST_FRAME_READ_ACTION_CONNECTED_LINE_MACRO
@ AST_FRAME_READ_ACTION_SEND_TEXT
@ AST_FRAME_READ_ACTION_SEND_TEXT_DATA
void ast_frame_dump(const char *name, struct ast_frame *f, char *prefix)
Definition: main/frame.c:731
@ AST_CONTROL_WINK
@ AST_CONTROL_STREAM_TOPOLOGY_REQUEST_CHANGE
@ AST_CONTROL_READ_ACTION
@ AST_CONTROL_ANSWER
@ AST_CONTROL_STREAM_TOPOLOGY_CHANGED
@ AST_CONTROL_CONNECTED_LINE
@ AST_CONTROL_FLASH
struct ast_frame ast_null_frame
Definition: main/frame.c:79
#define LOG_ERROR
#define LOG_DTMF
#define AST_LIST_EMPTY(head)
Checks whether the specified list contains any entries.
Definition: linkedlists.h:450
int ast_stream_get_position(const struct ast_stream *stream)
Get the position of the stream in the topology.
Definition: stream.c:500
struct ast_stream * ast_stream_topology_get_stream(const struct ast_stream_topology *topology, unsigned int position)
Get a specific stream from the topology.
Definition: stream.c:788
struct ast_frame *(*const read)(struct ast_channel *chan)
Read a frame (or chain of frames from the same stream), in standard format (see frame....
Definition: channel.h:754
struct ast_frame *(*const read_stream)(struct ast_channel *chan)
Read a frame (or chain of frames from the same stream), in standard format (see frame....
Definition: channel.h:767
struct ast_frame *(*const exception)(struct ast_channel *chan)
Handle an exception, reading a frame.
Definition: channel.h:785
enum ast_frame_read_action action
Definition of a media format.
Definition: format.c:43
struct ast_format * format
union ast_frame::@226 data
void(* digit)(struct ast_channel *chan, char digit)
Definition: channel.h:237
int(* generate)(struct ast_channel *chan, void *data, int len, int samples)
Definition: channel.h:235
Structure used to transport a message through the frame core.
Connected Line/Party information.
Definition: channel.h:458
int ast_tvzero(const struct timeval t)
Returns true if the argument is 0,0.
Definition: time.h:117
int64_t ast_tvdiff_ms(struct timeval end, struct timeval start)
Computes the difference (in milliseconds) between two struct timeval instances.
Definition: time.h:107
int ast_timer_ack(const struct ast_timer *handle, unsigned int quantity)
Acknowledge a timer event.
Definition: timing.c:171
int ast_timer_set_rate(const struct ast_timer *handle, unsigned int rate)
Set the timing tick rate.
Definition: timing.c:166
enum ast_timer_event ast_timer_get_event(const struct ast_timer *handle)
Retrieve timing event.
Definition: timing.c:186
int ast_timer_disable_continuous(const struct ast_timer *handle)
Disable continuous mode.
Definition: timing.c:181
ast_timer_event
Definition: timing.h:57
@ AST_TIMING_EVENT_CONTINUOUS
Definition: timing.h:59
@ AST_TIMING_EVENT_EXPIRED
Definition: timing.h:58
struct ast_frame * ast_translate(struct ast_trans_pvt *tr, struct ast_frame *f, int consume)
translates one or more frames Apply an input frame into the translator and receive zero or one output...
Definition: translate.c:566
#define ast_clear_flag(p, flag)
Definition: utils.h:77
#define ast_set_flag(p, flag)
Definition: utils.h:70

References __ast_queue_frame(), ast_control_read_action_payload::action, ao2_ref, AST_ALERT_READ_FATAL, ast_audiohook_detach_list(), AST_AUDIOHOOK_DIRECTION_READ, ast_audiohook_write_list(), ast_audiohook_write_list_empty(), ast_channel_alert_write(), ast_channel_audiohooks(), ast_channel_audiohooks_set(), ast_channel_connected(), ast_channel_connected_line_sub(), ast_channel_dtmf_digit_to_emulate(), ast_channel_dtmf_digit_to_emulate_set(), ast_channel_dtmf_tv(), ast_channel_dtmf_tv_set(), ast_channel_dtmff(), ast_channel_emulate_dtmf_duration(), ast_channel_emulate_dtmf_duration_set(), ast_channel_fd_isset(), ast_channel_fdno(), ast_channel_fdno_set(), ast_channel_fin(), ast_channel_fin_set(), ast_channel_flags(), ast_channel_framehooks(), ast_channel_generator(), ast_channel_generatordata(), ast_channel_generatordata_set(), ast_channel_get_default_stream(), ast_channel_get_stream_topology(), ast_channel_hangupcause_set(), ast_channel_internal_alert_read(), ast_channel_is_bridged(), ast_channel_lock, ast_channel_music_state(), ast_channel_name(), ast_channel_rawreadformat(), ast_channel_readformat(), ast_channel_readq(), ast_channel_readtrans(), ast_channel_softhangup_internal_flag(), ast_channel_softhangup_internal_flag_add(), ast_channel_stream_topology_changed(), ast_channel_tech(), ast_channel_timer(), ast_channel_timingdata(), ast_channel_timingfd(), ast_channel_timingfunc(), ast_channel_unlock, ast_channel_writetrans(), ast_check_hangup(), ast_clear_flag, ast_connected_line_parse_data(), AST_CONTROL_ANSWER, AST_CONTROL_CONNECTED_LINE, AST_CONTROL_END_OF_Q, AST_CONTROL_FLASH, AST_CONTROL_HANGUP, AST_CONTROL_READ_ACTION, AST_CONTROL_STREAM_TOPOLOGY_CHANGED, AST_CONTROL_STREAM_TOPOLOGY_REQUEST_CHANGE, AST_CONTROL_WINK, ast_deactivate_generator(), ast_debug, AST_DEFAULT_EMULATE_DTMF_DURATION, AST_FLAG_DEFER_DTMF, AST_FLAG_EMULATE_DTMF, AST_FLAG_END_DTMF_ONLY, AST_FLAG_EXCEPTION, AST_FLAG_IN_DTMF, AST_FLAG_TIMINGDATA_IS_AO2_OBJ, AST_FLAG_ZOMBIE, ast_format_cache_is_slinear(), ast_format_cmp(), AST_FORMAT_CMP_EQUAL, ast_format_get_type(), AST_FRAME_CONTROL, AST_FRAME_DTMF_BEGIN, AST_FRAME_DTMF_END, ast_frame_dump(), AST_FRAME_NULL, AST_FRAME_READ_ACTION_CONNECTED_LINE_MACRO, AST_FRAME_READ_ACTION_SEND_TEXT, AST_FRAME_READ_ACTION_SEND_TEXT_DATA, AST_FRAME_RTCP, AST_FRAME_VIDEO, AST_FRAME_VOICE, ast_framehook_list_read_event(), AST_FRFLAG_REQUEUED, ast_frfree, AST_GENERATOR_FD, ast_indicate_data(), AST_JITTERBUFFER_FD, AST_LIST_EMPTY, AST_LIST_FIRST, AST_LIST_LAST, AST_LIST_NEXT, AST_LIST_REMOVE_CURRENT, AST_LIST_TRAVERSE_SAFE_BEGIN, AST_LIST_TRAVERSE_SAFE_END, ast_log, AST_MIN_DTMF_GAP, ast_null_frame, ast_party_connected_line_copy(), ast_party_connected_line_free(), ast_party_connected_line_init(), ast_queue_control(), ast_queue_frame(), ast_queue_frame_head(), ast_read_generator_actions(), ast_sendtext(), ast_sendtext_data(), ast_set_flag, ast_set_read_format_path(), ast_setstate(), AST_SOFTHANGUP_DEV, AST_STATE_UP, ast_stream_get_position(), ast_stream_topology_get_stream(), ast_test_flag, ast_timer_ack(), ast_timer_disable_continuous(), ast_timer_get_event(), ast_timer_set_rate(), AST_TIMING_EVENT_CONTINUOUS, AST_TIMING_EVENT_EXPIRED, AST_TIMING_FD, ast_translate(), ast_tvdiff_ms(), ast_tvnow(), ast_tvzero(), connected, ast_frame::data, DEBUGCHAN_FLAG, digit, ast_generator::digit, done, DTMF_RECEIVED, ast_channel_tech::exception, ast_frame_subclass::format, FRAMECOUNT_INC, ast_frame::frametype, ast_generator::generate, ast_frame_subclass::integer, ast_frame::len, LOG_DTMF, LOG_ERROR, LOG_WARNING, NULL, option_dtmfminduration, ast_control_read_action_payload::payload, ast_control_read_action_payload::payload_size, ast_frame::ptr, queue_dtmf_readq(), ast_channel_tech::read, ast_channel_tech::read_stream, send_dtmf_begin_event(), send_dtmf_end_event(), send_flash_event(), send_wink_event(), set_channel_answer_time(), should_skip_dtmf(), should_trigger_dtmf_emulating(), ast_frame::stream_num, ast_frame::subclass, tmp(), and ast_frame::uint32.

Referenced by ast_read(), ast_read_noaudio(), ast_read_stream(), and ast_read_stream_noaudio().

◆ __ast_request_and_dial()

struct ast_channel * __ast_request_and_dial ( const char *  type,
struct ast_format_cap cap,
const struct ast_assigned_ids assignedids,
const struct ast_channel requestor,
const char *  addr,
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.

Parameters
typetype of channel to request
capformat capabilities for requested channel
assignedidsUnique Id to assign to channel
requestorchannel requesting data
addrdestination of the call
timeoutmaximum amount of time to wait for an answer
reasonwhy unsuccessful (if unsuccessful)
cid_numCaller-ID Number
cid_nameCaller-ID Name (ascii)
ohOutgoing helper
Returns
Returns an ast_channel on success or no answer, NULL on failure. Check the value of chan->_state to know if the call was answered or not.

Definition at line 5995 of file channel.c.

5996{
5997 int dummy_outstate;
5998 int cause = 0;
5999 struct ast_channel *chan;
6000 int res = 0;
6001 int last_subclass = 0;
6003
6004 if (outstate)
6005 *outstate = 0;
6006 else
6007 outstate = &dummy_outstate; /* make outstate always a valid pointer */
6008
6009 chan = ast_request(type, cap, assignedids, requestor, addr, &cause);
6010 if (!chan) {
6011 ast_log(LOG_NOTICE, "Unable to request channel %s/%s\n", type, addr);
6012 handle_cause(cause, outstate);
6013 return NULL;
6014 }
6015
6016 if (oh) {
6017 if (oh->vars) {
6018 ast_channel_lock(chan);
6019 ast_set_variables(chan, oh->vars);
6020 ast_channel_unlock(chan);
6021 }
6022 if (!ast_strlen_zero(oh->cid_num) && !ast_strlen_zero(oh->cid_name)) {
6023 /*
6024 * Use the oh values instead of the function parameters for the
6025 * outgoing CallerID.
6026 */
6027 cid_num = oh->cid_num;
6028 cid_name = oh->cid_name;
6029 }
6030 if (oh->parent_channel) {
6031 /* Safely inherit variables and datastores from the parent channel. */
6037 ast_channel_unlock(chan);
6038 }
6039 if (!ast_strlen_zero(oh->account)) {
6040 ast_channel_lock(chan);
6042 ast_channel_accountcode_set(chan, oh->account);
6043 ast_channel_peeraccount_set(chan, oh->account);
6045 ast_channel_unlock(chan);
6046 }
6047 }
6048
6049 /*
6050 * It seems strange to set the CallerID on an outgoing call leg
6051 * to whom we are calling, but this function's callers are doing
6052 * various Originate methods. This call leg goes to the local
6053 * user. Once the local user answers, the dialplan needs to be
6054 * able to access the CallerID from the CALLERID function as if
6055 * the local user had placed this call.
6056 */
6057 ast_set_callerid(chan, cid_num, cid_name, cid_num);
6058
6059 ast_channel_lock(chan);
6061 ast_channel_unlock(chan);
6063 if (cid_num) {
6064 connected.id.number.valid = 1;
6065 connected.id.number.str = (char *) cid_num;
6067 }
6068 if (cid_name) {
6069 connected.id.name.valid = 1;
6070 connected.id.name.str = (char *) cid_name;
6072 }
6074 if (requestor) {
6075 ast_channel_lock_both(chan, (struct ast_channel *) requestor);
6077 ast_channel_unlock(chan);
6078 ast_channel_unlock((struct ast_channel *) requestor);
6079 }
6080
6081 if (ast_call(chan, addr, 0)) { /* ast_call failed... */
6082 ast_log(LOG_NOTICE, "Unable to call channel %s/%s\n", type, addr);
6083 } else {
6084 struct timeval start = ast_tvnow();
6085 res = 1; /* mark success in case chan->_state is already AST_STATE_UP */
6086 while (timeout && ast_channel_state(chan) != AST_STATE_UP) {
6087 struct ast_frame *f;
6088 int ms = ast_remaining_ms(start, timeout);
6089
6090 res = ast_waitfor(chan, ms);
6091 if (res == 0) { /* timeout, treat it like ringing */
6092 *outstate = AST_CONTROL_RINGING;
6093 break;
6094 }
6095 if (res < 0) /* error or done */
6096 break;
6098 if (!(chan = ast_call_forward(NULL, chan, NULL, cap, oh, outstate))) {
6099 return NULL;
6100 }
6101 continue;
6102 }
6103
6104 f = ast_read(chan);
6105 if (!f) {
6106 *outstate = AST_CONTROL_HANGUP;
6107 res = 0;
6108 break;
6109 }
6110 if (f->frametype == AST_FRAME_CONTROL) {
6111 switch (f->subclass.integer) {
6112 case AST_CONTROL_RINGING: /* record but keep going */
6113 *outstate = f->subclass.integer;
6114 break;
6115
6116 case AST_CONTROL_BUSY:
6117 *outstate = f->subclass.integer;
6118 timeout = 0;
6119 break;
6120
6122 *outstate = AST_CONTROL_CONGESTION;
6123 timeout = 0;
6124 break;
6125
6127 *outstate = f->subclass.integer;
6128 timeout = 0;
6129 break;
6130
6131 case AST_CONTROL_ANSWER:
6132 *outstate = f->subclass.integer;
6133 timeout = 0; /* trick to force exit from the while() */
6134 break;
6135
6138 break;
6139
6141 if (oh && oh->connect_on_early_media) {
6142 *outstate = f->subclass.integer;
6143 timeout = 0; /* trick to force exit from the while() */
6144 break;
6145 }
6146 /* Fallthrough */
6147 /* Ignore these */
6149 case AST_CONTROL_HOLD:
6150 case AST_CONTROL_UNHOLD:
6156 case AST_CONTROL_CC:
6157 case -1: /* Ignore -- just stopping indications */
6158 break;
6159
6160 default:
6161 ast_log(LOG_NOTICE, "Don't know what to do with control frame %d\n", f->subclass.integer);
6162 }
6163 last_subclass = f->subclass.integer;
6164 }
6165 ast_frfree(f);
6166 }
6167 }
6168
6169 /* Final fixups */
6170 if (oh) {
6171 if (!ast_strlen_zero(oh->context))
6173 if (!ast_strlen_zero(oh->exten))
6174 ast_channel_exten_set(chan, oh->exten);
6175 if (oh->priority)
6177 }
6178 if (ast_channel_state(chan) == AST_STATE_UP)
6179 *outstate = AST_CONTROL_ANSWER;
6180
6181 if (res <= 0) {
6182 ast_channel_lock(chan);
6183 if (AST_CONTROL_RINGING == last_subclass) {
6185 }
6186 ast_channel_unlock(chan);
6187 ast_hangup(chan);
6188 chan = NULL;
6189 }
6190 return chan;
6191}
#define AST_PRES_ALLOWED_USER_NUMBER_NOT_SCREENED
Definition: callerid.h:437
#define AST_CAUSE_NO_ANSWER
Definition: causes.h:109
static const char type[]
Definition: chan_ooh323.c:109
int ast_call(struct ast_channel *chan, const char *addr, int timeout)
Make a call.
Definition: channel.c:6480
static void handle_cause(int cause, int *outstate)
Definition: channel.c:5868
struct ast_channel * ast_call_forward(struct ast_channel *caller, struct ast_channel *orig, int *timeout, struct ast_format_cap *cap, struct outgoing_helper *oh, int *outstate)
Forwards a call to a new channel specified by the original channel's call_forward str....
Definition: channel.c:5917
void ast_hangup(struct ast_channel *chan)
Hangup a channel.
Definition: channel.c:2560
void ast_channel_set_connected_line(struct ast_channel *chan, const struct ast_party_connected_line *connected, const struct ast_set_party_connected_line *update)
Set the connected line information in the Asterisk channel.
Definition: channel.c:8330
void ast_set_variables(struct ast_channel *chan, struct ast_variable *vars)
adds a list of channel variables to a channel
Definition: channel.c:8137
int ast_channel_datastore_inherit(struct ast_channel *from, struct ast_channel *to)
Inherit datastores from a parent to a child.
Definition: channel.c:2387
void ast_channel_req_accountcodes(struct ast_channel *chan, const struct ast_channel *requestor, enum ast_channel_requestor_relationship relationship)
Setup new channel accountcodes from the requestor channel after ast_request().
Definition: channel.c:6453
void ast_set_callerid(struct ast_channel *chan, const char *cid_num, const char *cid_name, const char *cid_ani)
Set caller ID number, name and ANI and generate AMI event.
Definition: channel.c:7356
void ast_channel_inherit_variables(const struct ast_channel *parent, struct ast_channel *child)
Inherits channel variable from parent to child channel.
Definition: channel.c:6790
void ast_channel_hangupcause_hash_set(struct ast_channel *chan, const struct ast_control_pvt_cause_code *cause_code, int datalen)
Sets the HANGUPCAUSE hash and optionally the SIP_CAUSE hash on the given channel.
Definition: channel.c:4365
void ast_party_connected_line_set_init(struct ast_party_connected_line *init, const struct ast_party_connected_line *guide)
Initialize the given connected line structure using the given guide for a set update operation.
Definition: channel.c:2064
struct ast_channel * ast_request(const char *type, struct ast_format_cap *request_cap, const struct ast_assigned_ids *assignedids, const struct ast_channel *requestor, const char *addr, int *cause)
Requests a channel.
Definition: channel.c:6373
@ AST_CHANNEL_REQUESTOR_BRIDGE_PEER
Definition: channel.h:1523
#define ast_channel_lock_both(chan1, chan2)
Lock two channels.
Definition: channel.h:2975
const char * ast_channel_call_forward(const struct ast_channel *chan)
@ AST_FLAG_ORIGINATED
Definition: channel.h:1059
@ AST_CONTROL_SRCUPDATE
@ AST_CONTROL_PROGRESS
@ AST_CONTROL_BUSY
@ AST_CONTROL_VIDUPDATE
@ AST_CONTROL_PROCEEDING
@ AST_CONTROL_REDIRECTING
@ AST_CONTROL_CONGESTION
@ AST_CONTROL_CC
@ AST_CONTROL_RINGING
@ AST_CONTROL_HOLD
@ AST_CONTROL_SRCCHANGE
@ AST_CONTROL_INCOMPLETE
@ AST_CONTROL_PVT_CAUSE_CODE
#define LOG_NOTICE
int ast_max_forwards_decrement(struct ast_channel *chan)
Decrement the max forwards count for a particular channel.
Definition: max_forwards.c:135
const char * cid_num
Definition: channel.h:1129
struct ast_variable * vars
Definition: channel.h:1132
int connect_on_early_media
Definition: channel.h:1128
const char * account
Definition: channel.h:1131
const char * cid_name
Definition: channel.h:1130
const char * exten
Definition: channel.h:1126
const char * context
Definition: channel.h:1125
struct ast_channel * parent_channel
Definition: channel.h:1133

References outgoing_helper::account, ast_call(), ast_call_forward(), AST_CAUSE_NO_ANSWER, ast_channel_call_forward(), ast_channel_connected(), ast_channel_context_set(), ast_channel_datastore_inherit(), ast_channel_exten_set(), ast_channel_flags(), ast_channel_hangupcause_hash_set(), ast_channel_hangupcause_set(), ast_channel_inherit_variables(), ast_channel_lock, ast_channel_lock_both, ast_channel_priority_set(), ast_channel_req_accountcodes(), AST_CHANNEL_REQUESTOR_BRIDGE_PEER, ast_channel_set_connected_line(), ast_channel_stage_snapshot(), ast_channel_stage_snapshot_done(), ast_channel_unlock, AST_CONTROL_ANSWER, AST_CONTROL_BUSY, AST_CONTROL_CC, AST_CONTROL_CONGESTION, AST_CONTROL_CONNECTED_LINE, AST_CONTROL_HANGUP, AST_CONTROL_HOLD, AST_CONTROL_INCOMPLETE, AST_CONTROL_PROCEEDING, AST_CONTROL_PROGRESS, AST_CONTROL_PVT_CAUSE_CODE, AST_CONTROL_REDIRECTING, AST_CONTROL_RINGING, AST_CONTROL_SRCCHANGE, AST_CONTROL_SRCUPDATE, AST_CONTROL_UNHOLD, AST_CONTROL_VIDUPDATE, AST_FLAG_ORIGINATED, AST_FRAME_CONTROL, ast_frfree, ast_hangup(), ast_log, ast_max_forwards_decrement(), ast_party_connected_line_set_init(), AST_PRES_ALLOWED_USER_NUMBER_NOT_SCREENED, ast_read(), ast_remaining_ms(), ast_request(), ast_set_callerid(), ast_set_flag, ast_set_variables(), AST_STATE_UP, ast_strlen_zero(), ast_tvnow(), ast_waitfor(), outgoing_helper::cid_name, outgoing_helper::cid_num, outgoing_helper::connect_on_early_media, connected, outgoing_helper::context, ast_frame::data, ast_frame::datalen, outgoing_helper::exten, ast_frame::frametype, handle_cause(), ast_frame_subclass::integer, LOG_NOTICE, NULL, outgoing_helper::parent_channel, outgoing_helper::priority, ast_frame::ptr, ast_frame::subclass, type, and outgoing_helper::vars.

Referenced by announce_to_dial(), and ast_request_and_dial().

◆ __init_state2str_threadbuf()

static void __init_state2str_threadbuf ( void  )
static

Definition at line 97 of file channel.c.

115{

◆ adjust_frame_for_plc()

static void adjust_frame_for_plc ( struct ast_channel chan,
struct ast_frame frame,
struct ast_datastore datastore 
)
static

Definition at line 5072 of file channel.c.

5073{
5074 int num_new_samples = frame->samples;
5075 struct plc_ds *plc = datastore->data;
5076
5077 /* As a general note, let me explain the somewhat odd calculations used when taking
5078 * the frame offset into account here. According to documentation in frame.h, the frame's
5079 * offset field indicates the number of bytes that the audio is offset. The plc->samples_buf
5080 * is not an array of bytes, but rather an array of 16-bit integers since it holds SLIN
5081 * samples. So I had two choices to make here with the offset.
5082 *
5083 * 1. Make the offset AST_FRIENDLY_OFFSET bytes. The main downside for this is that
5084 * I can't just add AST_FRIENDLY_OFFSET to the plc->samples_buf and have the pointer
5085 * arithmetic come out right. I would have to do some odd casting or division for this to
5086 * work as I wanted.
5087 * 2. Make the offset AST_FRIENDLY_OFFSET * 2 bytes. This allows the pointer arithmetic
5088 * to work out better with the plc->samples_buf. The downside here is that the buffer's
5089 * allocation contains an extra 64 bytes of unused space.
5090 *
5091 * I decided to go with option 2. This is why in the calloc statement and the statement that
5092 * sets the frame's offset, AST_FRIENDLY_OFFSET is multiplied by 2.
5093 */
5094
5095 /* If this audio frame has no samples to fill in, ignore it */
5096 if (!num_new_samples) {
5097 return;
5098 }
5099
5100 /* First, we need to be sure that our buffer is large enough to accomodate
5101 * the samples we need to fill in. This will likely only occur on the first
5102 * frame we write.
5103 */
5104 if (plc->num_samples < num_new_samples) {
5105 ast_free(plc->samples_buf);
5106 plc->samples_buf = ast_calloc(1, (num_new_samples * sizeof(*plc->samples_buf)) + (AST_FRIENDLY_OFFSET * 2));
5107 if (!plc->samples_buf) {
5108 ast_channel_datastore_remove(chan, datastore);
5109 ast_datastore_free(datastore);
5110 return;
5111 }
5112 plc->num_samples = num_new_samples;
5113 }
5114
5115 if (frame->datalen == 0) {
5117 frame->data.ptr = plc->samples_buf + AST_FRIENDLY_OFFSET;
5118 frame->datalen = num_new_samples * 2;
5119 frame->offset = AST_FRIENDLY_OFFSET * 2;
5120 } else {
5121 plc_rx(&plc->plc_state, frame->data.ptr, frame->samples);
5122 }
5123}
#define ast_free(a)
Definition: astmm.h:180
#define ast_calloc(num, len)
A wrapper for calloc()
Definition: astmm.h:202
int ast_channel_datastore_remove(struct ast_channel *chan, struct ast_datastore *datastore)
Remove a datastore from a channel.
Definition: channel.c:2413
int ast_datastore_free(struct ast_datastore *datastore)
Free a data store object.
Definition: datastore.c:68
#define AST_FRIENDLY_OFFSET
Offset into a frame's data buffer.
int plc_fillin(plc_state_t *s, int16_t amp[], int len)
Fill-in a block of missing audio samples.
Definition: plc.c:175
int plc_rx(plc_state_t *s, int16_t amp[], int len)
Process a block of received audio samples.
Definition: plc.c:132
void * data
Definition: datastore.h:66
int16_t * samples_buf
Definition: channel.c:5052
size_t num_samples
Definition: channel.c:5056
plc_state_t plc_state
Definition: channel.c:5057

References ast_calloc, ast_channel_datastore_remove(), ast_datastore_free(), ast_free, AST_FRIENDLY_OFFSET, ast_datastore::data, ast_frame::data, ast_frame::datalen, plc_ds::num_samples, ast_frame::offset, plc_fillin(), plc_rx(), plc_ds::plc_state, ast_frame::ptr, ast_frame::samples, and plc_ds::samples_buf.

Referenced by apply_plc().

◆ apply_plc()

static void apply_plc ( struct ast_channel chan,
struct ast_frame frame 
)
static

Definition at line 5125 of file channel.c.

5126{
5127 struct ast_datastore *datastore;
5128 struct plc_ds *plc;
5129
5130 datastore = ast_channel_datastore_find(chan, &plc_ds_info, NULL);
5131 if (datastore) {
5132 plc = datastore->data;
5133 adjust_frame_for_plc(chan, frame, datastore);
5134 return;
5135 }
5136
5137 datastore = ast_datastore_alloc(&plc_ds_info, NULL);
5138 if (!datastore) {
5139 return;
5140 }
5141 plc = ast_calloc(1, sizeof(*plc));
5142 if (!plc) {
5143 ast_datastore_free(datastore);
5144 return;
5145 }
5146 datastore->data = plc;
5147 ast_channel_datastore_add(chan, datastore);
5148 adjust_frame_for_plc(chan, frame, datastore);
5149}
int ast_channel_datastore_add(struct ast_channel *chan, struct ast_datastore *datastore)
Add a datastore to a channel.
Definition: channel.c:2404
static const struct ast_datastore_info plc_ds_info
Definition: channel.c:5067
static void adjust_frame_for_plc(struct ast_channel *chan, struct ast_frame *frame, struct ast_datastore *datastore)
Definition: channel.c:5072
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.
Definition: channel.c:2418
#define ast_datastore_alloc(info, uid)
Definition: datastore.h:85
Structure for a data store object.
Definition: datastore.h:64

References adjust_frame_for_plc(), ast_calloc, ast_channel_datastore_add(), ast_channel_datastore_find(), ast_datastore_alloc, ast_datastore_free(), ast_datastore::data, NULL, and plc_ds_info.

Referenced by ast_write_stream().

◆ ast_activate_generator()

int ast_activate_generator ( struct ast_channel chan,
struct ast_generator gen,
void *  params 
)

Activate a given generator

Definition at line 2970 of file channel.c.

2971{
2972 int res = 0;
2973 void *generatordata = NULL;
2974
2975 ast_channel_lock(chan);
2976 if (ast_channel_generatordata(chan)) {
2977 struct ast_generator *generator_old = ast_channel_generator(chan);
2978
2979 if (generator_old && generator_old->release) {
2980 generator_old->release(chan, ast_channel_generatordata(chan));
2981 }
2982 }
2983 if (gen->alloc && !(generatordata = gen->alloc(chan, params))) {
2984 res = -1;
2985 }
2986 ast_channel_generatordata_set(chan, generatordata);
2987 if (!res) {
2988 ast_settimeout(chan, 50, generator_force, chan);
2990 }
2991 ast_channel_unlock(chan);
2992
2993 ast_prod(chan);
2994
2995 return res;
2996}
static struct ast_generator gen
int ast_prod(struct ast_channel *chan)
Send empty audio to prime a channel driver.
Definition: channel.c:5019
static int generator_force(const void *data)
Definition: channel.c:2935
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.
Definition: channel.c:3199
void ast_channel_generator_set(struct ast_channel *chan, struct ast_generator *value)
void *(* alloc)(struct ast_channel *chan, void *params)
Definition: channel.h:228
void(* release)(struct ast_channel *chan, void *data)
Definition: channel.h:230

References ast_generator::alloc, ast_channel_generator(), ast_channel_generator_set(), ast_channel_generatordata(), ast_channel_generatordata_set(), ast_channel_lock, ast_channel_unlock, ast_prod(), ast_settimeout(), gen, generator_force(), ast_channel::generatordata, NULL, and ast_generator::release.

Referenced by app_exec(), ast_channel_start_silence_generator(), ast_linear_stream(), ast_playtones_start(), ast_tonepair_start(), channel_spy(), do_broadcast(), eivr_comm(), local_ast_moh_start(), old_milliwatt_exec(), and spandsp_fax_gateway_start().

◆ ast_active_channels()

int ast_active_channels ( void  )

returns number of active/allocated channels

Returns
number of channels available for lookup

Definition at line 499 of file channel.c.

500{
502}
int ao2_container_count(struct ao2_container *c)
Returns the number of elements in a container.

References ao2_container_count(), and channels.

Referenced by action_corestatus(), ast_var_channels(), ast_var_channels_table(), dahdi_restart(), handle_chanlist(), handle_show_settings(), and really_quit().

◆ ast_answer()

int ast_answer ( struct ast_channel chan)

Answer a channel.

Parameters
chanchannel to answer

This function answers a channel and handles all necessary call setup functions.

Note
The channel passed does not need to be locked, but is locked by the function when needed.
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.
Return values
0on success
non-zeroon failure

Definition at line 2824 of file channel.c.

2825{
2826 SCOPE_TRACE(1, "%s\n", ast_channel_name(chan));
2827 return __ast_answer(chan, 0);
2828}
int __ast_answer(struct ast_channel *chan, unsigned int delay)
Answer a channel, with a selectable delay before returning.
Definition: channel.c:2714

References __ast_answer(), ast_channel_name(), and SCOPE_TRACE.

Referenced by agent_login_exec(), agi_exec_full(), alarmreceiver_exec(), announce_request(), app_exec(),