Mon Mar 12 2012 21:38:06

Asterisk developer's documentation


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.

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.

                       {
   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 = (1 << 16),   /*!< Do not transmit voice data */
};

Function Documentation

int ast_setstate ( struct ast_channel chan,
enum  ast_channel_state 
)

Change the state of a channel.

Definition at line 6869 of file channel.c.

References ast_channel::_state, AST_CHANNEL_NAME, ast_copy_string(), AST_DEVICE_UNKNOWN, ast_devstate_changed_literal(), ast_manager_event, ast_state2str(), ast_channel::caller, ast_channel::connected, EVENT_FLAG_CALL, 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(), sig_ss7_call(), sig_ss7_indicate(), sip_answer(), skinny_answer(), skinny_call(), skinny_newcall(), ss7_linkset(), unistim_answer(), unistim_call(), unistim_new(), unistim_ss(), update_state(), usbradio_answer(), and usbradio_call().

{
   int oldstate = chan->_state;
   char name[AST_CHANNEL_NAME], *dashptr;

   if (oldstate == state)
      return 0;

   ast_copy_string(name, chan->name, sizeof(name));
   if ((dashptr = strrchr(name, '-'))) {
      *dashptr = '\0';
   }

   chan->_state = state;

   /* We have to pass AST_DEVICE_UNKNOWN here because it is entirely possible that the channel driver
    * for this channel is using the callback method for device state. If we pass in an actual state here
    * we override what they are saying the state is and things go amuck. */
   ast_devstate_changed_literal(AST_DEVICE_UNKNOWN, name);

   /* setstate used to conditionally report Newchannel; this is no more */
   ast_manager_event(chan, EVENT_FLAG_CALL, "Newstate",
      "Channel: %s\r\n"
      "ChannelState: %d\r\n"
      "ChannelStateDesc: %s\r\n"
      "CallerIDNum: %s\r\n"
      "CallerIDName: %s\r\n"
      "ConnectedLineNum: %s\r\n"
      "ConnectedLineName: %s\r\n"
      "Uniqueid: %s\r\n",
      chan->name, chan->_state, ast_state2str(chan->_state),
      S_COR(chan->caller.id.number.valid, chan->caller.id.number.str, ""),
      S_COR(chan->caller.id.name.valid, chan->caller.id.name.str, ""),
      S_COR(chan->connected.id.number.valid, chan->connected.id.number.str, ""),
      S_COR(chan->connected.id.name.valid, chan->connected.id.name.str, ""),
      chan->uniqueid);

   return 0;
}