[Asterisk-Dev] Channel module question - setstate vs queue_control
Tilghman Lesher
tilghman at mail.jeffandtilghman.com
Fri Feb 4 11:31:19 MST 2005
On Thursday 03 February 2005 20:19, Bob Carlson wrote:
> I'm building a channel module and am wondering about the behavior of
> the * channel code. I've looked at several channel modules and it
> seems common to this kind of thing:
>
> ast_setstate(ast, AST_STATE_RINGING);
> ast_queue_control(ast, AST_CONTROL_RINGING);
>
> Are these redundant? It would seem like sending the RINGING control
> would change the state to RINGING or vice versa. Are both actions
> necessary?
No, they're not redundant. Queuing a control is generally used when you
need to have the remote end recognize the state change, whereas you
would use setstate when you only need to change the status of the local
channel.
For example, see in chan_sip, where both are used within a few lines:
if (!strcasecmp(msg, "INVITE")) {
sip_cancel_destroy(p);
if (p->owner) {
ast_queue_control(p->owner, AST_CONTROL_RINGING);
if (p->owner->_state != AST_STATE_UP)
ast_setstate(p->owner, AST_STATE_RINGING);
}
}
--
Tilghman
More information about the asterisk-dev
mailing list