Wed Jan 8 2020 09:50:10

Asterisk developer's documentation


channelstate.h File Reference

Channel states. More...

#include "asterisk.h"

Go to the source code of this file.

Enumerations

enum  ast_channel_state {
  AST_STATE_DOWN, AST_STATE_RESERVED, AST_STATE_OFFHOOK, AST_STATE_DIALING,
  AST_STATE_RING, AST_STATE_RINGING, AST_STATE_UP, AST_STATE_BUSY,
  AST_STATE_DIALING_OFFHOOK, AST_STATE_PRERING, AST_STATE_MUTE = (1 << 16)
}
 ast_channel states More...
 

Functions

int ast_setstate (struct ast_channel *chan, enum ast_channel_state)
 Change the state of a channel. More...
 

Detailed Description

Channel states.

See also:

Definition in file channelstate.h.

Enumeration Type Documentation

ast_channel states

Note
Bits 0-15 of state are reserved for the state (up/down) of the line Bits 16-32 of state are reserved for flags
Enumerator
AST_STATE_DOWN 

Channel is down and available

AST_STATE_RESERVED 

Channel is down, but reserved

AST_STATE_OFFHOOK 

Channel is off hook

AST_STATE_DIALING 

Digits (or equivalent) have been dialed

AST_STATE_RING 

Line is ringing

AST_STATE_RINGING 

Remote end is ringing

AST_STATE_UP 

Line is up

AST_STATE_BUSY 

Line is busy

AST_STATE_DIALING_OFFHOOK 

Digits (or equivalent) have been dialed while offhook

AST_STATE_PRERING 

Channel has detected an incoming call and is waiting for ring

AST_STATE_MUTE 

Do not transmit voice data

Definition at line 35 of file channelstate.h.

35  {
36  AST_STATE_DOWN, /*!< Channel is down and available */
37  AST_STATE_RESERVED, /*!< Channel is down, but reserved */
38  AST_STATE_OFFHOOK, /*!< Channel is off hook */
39  AST_STATE_DIALING, /*!< Digits (or equivalent) have been dialed */
40  AST_STATE_RING, /*!< Line is ringing */
41  AST_STATE_RINGING, /*!< Remote end is ringing */
42  AST_STATE_UP, /*!< Line is up */
43  AST_STATE_BUSY, /*!< Line is busy */
44  AST_STATE_DIALING_OFFHOOK, /*!< Digits (or equivalent) have been dialed while offhook */
45  AST_STATE_PRERING, /*!< Channel has detected an incoming call and is waiting for ring */
46 
47  AST_STATE_MUTE = (1 << 16), /*!< Do not transmit voice data */
48 };

Function Documentation

int ast_setstate ( struct ast_channel chan,
enum  ast_channel_state 
)

Change the state of a channel.

Definition at line 7119 of file channel.c.

References ast_channel::_state, AST_CHANNEL_NAME, ast_copy_string(), AST_DEVICE_UNKNOWN, AST_DEVSTATE_CACHABLE, ast_devstate_changed_literal(), AST_DEVSTATE_NOT_CACHABLE, AST_FLAG_DISABLE_DEVSTATE_CACHE, ast_manager_event, ast_state2str(), ast_channel::caller, ast_channel::connected, EVENT_FLAG_CALL, ast_channel::flags, ast_party_caller::id, ast_party_connected_line::id, name, ast_party_id::name, ast_channel::name, ast_party_id::number, S_COR, state, ast_party_name::str, ast_party_number::str, ast_channel::uniqueid, ast_party_name::valid, and ast_party_number::valid.

Referenced by __analog_handle_event(), __analog_ss_thread(), __ast_read(), __dahdi_exception(), __oh323_update_info(), agent_call(), alsa_answer(), analog_answer(), analog_call(), analog_exception(), analog_ss_thread(), ast_raw_answer(), cb_events(), check_availability(), console_answer(), dahdi_answer(), dahdi_call(), dahdi_handle_event(), dahdi_indicate(), dahdi_read(), do_bridge_masquerade(), gtalk_call(), gtalk_newcall(), handle_invite_replaces(), handle_offhook_message(), handle_request_invite(), handle_response_invite(), handle_soft_key_event_message(), handle_stimulus_message(), iax2_call(), jingle_call(), jingle_newcall(), local_queue_frame(), mgcp_answer(), mgcp_call(), mgcp_ss(), misdn_call(), misdn_indication(), my_set_waitingfordt(), nbs_call(), nbs_hangup(), oh323_answer(), oss_answer(), pbx_builtin_busy(), pbx_builtin_congestion(), phone_answer(), phone_call(), phone_exception(), phone_hangup(), phone_write(), pri_dchannel(), pri_ss_thread(), release_chan(), release_chan_early(), sig_pri_answer(), sig_pri_call(), sig_pri_indicate(), sip_answer(), skinny_answer(), skinny_call(), skinny_newcall(), unistim_answer(), unistim_call(), unistim_new(), unistim_ss(), and update_state().

7120 {
7121  int oldstate = chan->_state;
7122  char name[AST_CHANNEL_NAME], *dashptr;
7123 
7124  if (oldstate == state)
7125  return 0;
7126 
7127  ast_copy_string(name, chan->name, sizeof(name));
7128  if ((dashptr = strrchr(name, '-'))) {
7129  *dashptr = '\0';
7130  }
7131 
7132  chan->_state = state;
7133 
7134  /* We have to pass AST_DEVICE_UNKNOWN here because it is entirely possible that the channel driver
7135  * for this channel is using the callback method for device state. If we pass in an actual state here
7136  * we override what they are saying the state is and things go amuck. */
7138 
7139  /* setstate used to conditionally report Newchannel; this is no more */
7140  ast_manager_event(chan, EVENT_FLAG_CALL, "Newstate",
7141  "Channel: %s\r\n"
7142  "ChannelState: %u\r\n"
7143  "ChannelStateDesc: %s\r\n"
7144  "CallerIDNum: %s\r\n"
7145  "CallerIDName: %s\r\n"
7146  "ConnectedLineNum: %s\r\n"
7147  "ConnectedLineName: %s\r\n"
7148  "Uniqueid: %s\r\n",
7149  chan->name, chan->_state, ast_state2str(chan->_state),
7150  S_COR(chan->caller.id.number.valid, chan->caller.id.number.str, ""),
7151  S_COR(chan->caller.id.name.valid, chan->caller.id.name.str, ""),
7152  S_COR(chan->connected.id.number.valid, chan->connected.id.number.str, ""),
7153  S_COR(chan->connected.id.name.valid, chan->connected.id.name.str, ""),
7154  chan->uniqueid);
7155 
7156  return 0;
7157 }
enum sip_cc_notify_state state
Definition: chan_sip.c:842
char * str
Subscriber phone number (Malloced)
Definition: channel.h:241
struct ast_party_connected_line connected
Channel Connected Line ID information.
Definition: channel.h:811
struct ast_party_caller caller
Channel Caller ID information.
Definition: channel.h:804
const ast_string_field uniqueid
Definition: channel.h:787
struct ast_party_id id
Connected party ID.
Definition: channel.h:403
struct ast_party_name name
Subscriber name.
Definition: channel.h:290
#define EVENT_FLAG_CALL
Definition: manager.h:72
char * str
Subscriber name (Malloced)
Definition: channel.h:214
const char * ast_state2str(enum ast_channel_state)
Gives the string form of a given channel state.
Definition: channel.c:1007
#define ast_manager_event(chan, category, event, contents,...)
Definition: manager.h:221
unsigned int flags
Definition: channel.h:850
struct ast_party_id id
Caller party ID.
Definition: channel.h:370
#define S_COR(a, b, c)
returns the equivalent of logic or for strings, with an additional boolean check: second one if not e...
Definition: strings.h:83
enum ast_channel_state _state
Definition: channel.h:839
const ast_string_field name
Definition: channel.h:787
static const char name[]
#define AST_CHANNEL_NAME
Definition: channel.h:137
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Definition: strings.h:223
unsigned char valid
TRUE if the name information is valid/present.
Definition: channel.h:229
int ast_devstate_changed_literal(enum ast_device_state state, enum ast_devstate_cache cachable, const char *device)
Tells Asterisk the State for Device is changed.
Definition: devicestate.c:472
unsigned char valid
TRUE if the number information is valid/present.
Definition: channel.h:247
struct ast_party_number number
Subscriber phone number.
Definition: channel.h:292