Asterisk - The Open Source Telephony Project  18.5.0
Enumerations | Functions
channelstate.h File Reference

Channel states. More...

#include "asterisk.h"
Include dependency graph for channelstate.h:
This graph shows which files directly or indirectly include this file:

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_state

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

◆ ast_setstate()

int ast_setstate ( struct ast_channel chan,
enum  ast_channel_state 
)

Change the state of a channel.

Precondition
chan is locked

Definition at line 7486 of file channel.c.

References ast_channel_flags(), AST_CHANNEL_NAME, ast_channel_name(), ast_channel_publish_snapshot(), ast_channel_state_set(), ast_copy_string(), AST_DEVICE_UNKNOWN, AST_DEVSTATE_CACHABLE, ast_devstate_changed_literal(), AST_DEVSTATE_NOT_CACHABLE, AST_FLAG_DISABLE_DEVSTATE_CACHE, ast_test_flag, and name.

Referenced by __analog_handle_event(), __analog_ss_thread(), __ast_read(), __dahdi_exception(), alsa_answer(), analog_answer(), analog_call(), analog_exception(), analog_ss_thread(), ast_raw_answer_with_stream_topology(), AST_TEST_DEFINE(), cb_events(), chan_pjsip_answer(), chan_pjsip_incoming_response(), console_answer(), dahdi_answer(), dahdi_call(), dahdi_handle_event(), dahdi_indicate(), dahdi_read(), handle_invite_replaces(), handle_request_invite(), handle_response_ciev(), handle_response_invite(), iax2_call(), indicate_busy(), indicate_congestion(), jingle_action_session_info(), jingle_action_session_initiate(), jingle_call(), mbl_hangup(), mgcp_answer(), mgcp_call(), mgcp_ss(), misdn_call(), misdn_indication(), my_set_waitingfordt(), nbs_call(), nbs_hangup(), onAlerting(), onProgress(), ooh323_answer(), ooh323_new(), oss_answer(), phone_answer(), phone_call(), phone_exception(), phone_hangup(), phone_write(), refer_incoming_invite_request(), release_chan(), release_chan_early(), setsubstate(), sip_answer(), skinny_newcall(), unistim_answer(), unistim_call(), unistim_new(), unistim_ss(), and unreal_queue_frame().

7487 {
7488  int oldstate = ast_channel_state(chan);
7489  char name[AST_CHANNEL_NAME], *dashptr;
7490 
7491  if (oldstate == state)
7492  return 0;
7493 
7494  ast_copy_string(name, ast_channel_name(chan), sizeof(name));
7495  if ((dashptr = strrchr(name, '-'))) {
7496  *dashptr = '\0';
7497  }
7498 
7500 
7502 
7503  /* We have to pass AST_DEVICE_UNKNOWN here because it is entirely possible that the channel driver
7504  * for this channel is using the callback method for device state. If we pass in an actual state here
7505  * we override what they are saying the state is and things go amuck. */
7507 
7508  return 0;
7509 }
#define ast_test_flag(p, flag)
Definition: utils.h:63
ast_channel_state
ast_channel states
Definition: channelstate.h:35
static const char name[]
Definition: cdr_mysql.c:74
#define AST_CHANNEL_NAME
Definition: channel.h:172
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Definition: strings.h:401
const char * ast_channel_name(const struct ast_channel *chan)
void ast_channel_state_set(struct ast_channel *chan, enum ast_channel_state)
void ast_channel_publish_snapshot(struct ast_channel *chan)
Publish a ast_channel_snapshot for a channel.
struct ast_flags * ast_channel_flags(struct ast_channel *chan)
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:471