Sat Apr 26 2014 22:02:44

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 7389 of file channel.c.

References ast_channel_caller(), ast_channel_connected(), ast_channel_flags(), AST_CHANNEL_NAME, ast_channel_name(), ast_channel_state_set(), ast_channel_uniqueid(), 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_test_flag, EVENT_FLAG_CALL, name, and S_COR.

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_request_invite(), handle_response_invite(), iax2_call(), jingle_action_session_info(), jingle_action_session_initiate(), 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(), setsubstate(), sig_pri_answer(), sig_pri_call(), sig_pri_indicate(), sig_ss7_call(), sig_ss7_indicate(), sip_answer(), skinny_answer(), skinny_newcall(), ss7_linkset(), unistim_answer(), unistim_call(), unistim_new(), unistim_ss(), and update_state().

{
   int oldstate = ast_channel_state(chan);
   char name[AST_CHANNEL_NAME], *dashptr;

   if (oldstate == state)
      return 0;

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

   ast_channel_state_set(chan, 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, (ast_test_flag(ast_channel_flags(chan), AST_FLAG_DISABLE_DEVSTATE_CACHE) ? AST_DEVSTATE_NOT_CACHABLE : AST_DEVSTATE_CACHABLE), name);

   /* setstate used to conditionally report Newchannel; this is no more */
   /*** DOCUMENTATION
      <managerEventInstance>
         <synopsis>Raised when a channel's state changes.</synopsis>
         <syntax>
            <parameter name="ChannelState">
               <para>A numeric code for the channel's current state, related to ChannelStateDesc</para>
            </parameter>
            <parameter name="ChannelStateDesc">
               <enumlist>
                  <enum name="Down"/>
                  <enum name="Rsrvd"/>
                  <enum name="OffHook"/>
                  <enum name="Dialing"/>
                  <enum name="Ring"/>
                  <enum name="Ringing"/>
                  <enum name="Up"/>
                  <enum name="Busy"/>
                  <enum name="Dialing Offhook"/>
                  <enum name="Pre-ring"/>
                  <enum name="Unknown"/>
               </enumlist>
            </parameter>
         </syntax>
      </managerEventInstance>
   ***/
   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",
      ast_channel_name(chan), ast_channel_state(chan), ast_state2str(ast_channel_state(chan)),
      S_COR(ast_channel_caller(chan)->id.number.valid, ast_channel_caller(chan)->id.number.str, ""),
      S_COR(ast_channel_caller(chan)->id.name.valid, ast_channel_caller(chan)->id.name.str, ""),
      S_COR(ast_channel_connected(chan)->id.number.valid, ast_channel_connected(chan)->id.number.str, ""),
      S_COR(ast_channel_connected(chan)->id.name.valid, ast_channel_connected(chan)->id.name.str, ""),
      ast_channel_uniqueid(chan));

   return 0;
}