📄 channel.h
字号:
/*! Read translation path */ struct ast_trans_pvt *readtrans; /*! Raw read format */ int rawreadformat; /*! Raw write format */ int rawwriteformat; /*! Chan Spy stuff */ struct ast_channel_spy_list *spies; /*! For easy linking */ struct ast_channel *next;};/* \defgroup chanprop Channel tech properties: \brief Channels have this property if they can accept input with jitter; i.e. most VoIP channels *//* @{ */#define AST_CHAN_TP_WANTSJITTER (1 << 0) /* This flag has been deprecated by the transfercapbilty data member in struct ast_channel *//* #define AST_FLAG_DIGITAL (1 << 0) */ /* if the call is a digital ISDN call */#define AST_FLAG_DEFER_DTMF (1 << 1) /*!< if dtmf should be deferred */#define AST_FLAG_WRITE_INT (1 << 2) /*!< if write should be interrupt generator */#define AST_FLAG_BLOCKING (1 << 3) /*!< if we are blocking */#define AST_FLAG_ZOMBIE (1 << 4) /*!< if we are a zombie */#define AST_FLAG_EXCEPTION (1 << 5) /*!< if there is a pending exception */#define AST_FLAG_MOH (1 << 6) /*!< XXX anthm promises me this will disappear XXX listening to moh */#define AST_FLAG_SPYING (1 << 7) /*!< XXX might also go away XXX is spying on someone */#define AST_FLAG_NBRIDGE (1 << 8) /*!< is it in a native bridge */#define AST_FLAG_IN_AUTOLOOP (1 << 9) /*!< the channel is in an auto-incrementing dialplan processor, so when ->priority is set, it will get incremented before finding the next priority to run */#define AST_FLAG_NOTNEW (1 << 10) /*!< see bug:7855 incorrect Newchannel event generation *//* @} */#define AST_FEATURE_PLAY_WARNING (1 << 0)#define AST_FEATURE_REDIRECT (1 << 1)#define AST_FEATURE_DISCONNECT (1 << 2)#define AST_FEATURE_ATXFER (1 << 3)#define AST_FEATURE_AUTOMON (1 << 4)#define AST_FEATURE_FLAG_NEEDSDTMF (1 << 0)#define AST_FEATURE_FLAG_CALLEE (1 << 1)#define AST_FEATURE_FLAG_CALLER (1 << 2)struct ast_bridge_config { struct ast_flags features_caller; struct ast_flags features_callee; struct timeval start_time; long feature_timer; long timelimit; long play_warning; long warning_freq; char *warning_sound; char *end_sound; char *start_sound; int firstpass; unsigned int flags;};struct chanmon;#define LOAD_OH(oh) { \ oh.context = context; \ oh.exten = exten; \ oh.priority = priority; \ oh.cid_num = cid_num; \ oh.cid_name = cid_name; \ oh.account = account; \ oh.vars = vars; \ oh.parent_channel = NULL; \} struct outgoing_helper { const char *context; const char *exten; int priority; const char *cid_num; const char *cid_name; const char *account; struct ast_variable *vars; struct ast_channel *parent_channel;};#define AST_CDR_TRANSFER (1 << 0)#define AST_CDR_FORWARD (1 << 1)#define AST_CDR_CALLWAIT (1 << 2)#define AST_CDR_CONFERENCE (1 << 3)#define AST_ADSI_UNKNOWN (0)#define AST_ADSI_AVAILABLE (1)#define AST_ADSI_UNAVAILABLE (2)#define AST_ADSI_OFFHOOKONLY (3)#define AST_SOFTHANGUP_DEV (1 << 0) /*!< Soft hangup by device */#define AST_SOFTHANGUP_ASYNCGOTO (1 << 1) /*!< Soft hangup for async goto */#define AST_SOFTHANGUP_SHUTDOWN (1 << 2)#define AST_SOFTHANGUP_TIMEOUT (1 << 3)#define AST_SOFTHANGUP_APPUNLOAD (1 << 4)#define AST_SOFTHANGUP_EXPLICIT (1 << 5)#define AST_SOFTHANGUP_UNBRIDGE (1 << 6)/*! \defgroup ChanState Channel states\brief Bits 0-15 of state are reserved for the state (up/down) of the line *//*! @{ *//*! Channel is down and available */#define AST_STATE_DOWN 0 /*! Channel is down, but reserved */#define AST_STATE_RESERVED 1 /*! Channel is off hook */#define AST_STATE_OFFHOOK 2 /*! Digits (or equivalent) have been dialed */#define AST_STATE_DIALING 3 /*! Line is ringing */#define AST_STATE_RING 4 /*! Remote end is ringing */#define AST_STATE_RINGING 5 /*! Line is up */#define AST_STATE_UP 6 /*! Line is busy */#define AST_STATE_BUSY 7 /*! Digits (or equivalent) have been dialed while offhook */#define AST_STATE_DIALING_OFFHOOK 8/*! Channel has detected an incoming call and is waiting for ring */#define AST_STATE_PRERING 9/* Bits 16-32 of state are reserved for flags (See \ref ChanState ) *//*! Do not transmit voice data */#define AST_STATE_MUTE (1 << 16) /*! @} *//*! \brief Change the state of a channel */int ast_setstate(struct ast_channel *chan, int state);/*! \brief Create a channel structure \return Returns NULL on failure to allocate. \note New channels are by default set to the "default" context and extension "s" */struct ast_channel *ast_channel_alloc(int needalertpipe);/*! \brief Queue an outgoing frame */int ast_queue_frame(struct ast_channel *chan, struct ast_frame *f);/*! \brief Queue a hangup frame */int ast_queue_hangup(struct ast_channel *chan);/*! \brief Queue a control frame */int ast_queue_control(struct ast_channel *chan, int control);/*! \brief Change channel name */void ast_change_name(struct ast_channel *chan, char *newname);/*! \brief Free a channel structure */void ast_channel_free(struct ast_channel *);/*! \brief Requests a channel * \param type type of channel to request * \param format requested channel format * \param data data to pass to the channel requester * \param status status * Request a channel of a given type, with data as optional information used * by the low level module * \return Returns an ast_channel on success, NULL on failure. */struct ast_channel *ast_request(const char *type, int format, void *data, int *status);/*! * \brief Request a channel of a given type, with data as optional information used * by the low level module and attempt to place a call on it * \param type type of channel to request * \param format requested channel format * \param data data to pass to the channel requester * \param timeout maximum amount of time to wait for an answer * \param reason why unsuccessful (if unsuceessful) * \param cidnum Caller-ID Number * \param cidname Caller-ID Name * \return Returns an ast_channel on success or no answer, NULL on failure. Check the value of chan->_state * to know if the call was answered or not. */struct ast_channel *ast_request_and_dial(const char *type, int format, void *data, int timeout, int *reason, const char *cidnum, const char *cidname);struct ast_channel *__ast_request_and_dial(const char *type, int format, void *data, int timeout, int *reason, const char *cidnum, const char *cidname, struct outgoing_helper *oh);/*!\brief Register a channel technology (a new channel driver) * Called by a channel module to register the kind of channels it supports. * \param tech Structure defining channel technology or "type" * \return Returns 0 on success, -1 on failure. */int ast_channel_register(const struct ast_channel_tech *tech);/*! \brief Unregister a channel technology * \param tech Structure defining channel technology or "type" that was previously registered * \return No return value. */void ast_channel_unregister(const struct ast_channel_tech *tech);/*! \brief Get a channel technology structure by name * \param name name of technology to find * \return a pointer to the structure, or NULL if no matching technology found */const struct ast_channel_tech *ast_get_channel_tech(const char *name);/*! \brief Hang up a channel * \note This function performs a hard hangup on a channel. Unlike the soft-hangup, this function * performs all stream stopping, etc, on the channel that needs to end. * chan is no longer valid after this call. * \param chan channel to hang up * \return Returns 0 on success, -1 on failure. */int ast_hangup(struct ast_channel *chan);/*! \brief Softly hangup up a channel * \param chan channel to be soft-hung-up * Call the protocol layer, but don't destroy the channel structure (use this if you are trying to * safely hangup a channel managed by another thread. * \param cause Ast hangupcause for hangup * \return Returns 0 regardless */int ast_softhangup(struct ast_channel *chan, int cause);/*! \brief Softly hangup up a channel (no channel lock) * \param chan channel to be soft-hung-up * \param cause Ast hangupcause for hangup (see cause.h) */int ast_softhangup_nolock(struct ast_channel *chan, int cause);/*! \brief Check to see if a channel is needing hang up * \param chan channel on which to check for hang up * This function determines if the channel is being requested to be hung up. * \return Returns 0 if not, or 1 if hang up is requested (including time-out). */int ast_check_hangup(struct ast_channel *chan);/*! \brief Compare a offset with the settings of when to hang a channel up * \param chan channel on which to check for hang up * \param offset offset in seconds from current time * \return 1, 0, or -1 * This function compares a offset from current time with the absolute time * out on a channel (when to hang up). If the absolute time out on a channel * is earlier than current time plus the offset, it returns 1, if the two * time values are equal, it return 0, otherwise, it retturn -1. */int ast_channel_cmpwhentohangup(struct ast_channel *chan, time_t offset);/*! \brief Set when to hang a channel up * \param chan channel on which to check for hang up * \param offset offset in seconds from current time of when to hang up * This function sets the absolute time out on a channel (when to hang up). */void ast_channel_setwhentohangup(struct ast_channel *chan, time_t offset);/*! \brief Answer a ringing call * \param chan channel to answer * This function answers a channel and handles all necessary call * setup functions. * \return Returns 0 on success, -1 on failure */int ast_answer(struct ast_channel *chan);/*! \brief Make a call * \param chan which channel to make the call on * \param addr destination of the call * \param timeout time to wait on for connect * Place a call, take no longer than timeout ms. \return Returns -1 on failure, 0 on not enough time (does not automatically stop ringing), and the number of seconds the connect took otherwise. */int ast_call(struct ast_channel *chan, char *addr, int timeout);/*! \brief Indicates condition of channel * \note Indicate a condition such as AST_CONTROL_BUSY, AST_CONTROL_RINGING, or AST_CONTROL_CONGESTION on a channel * \param chan channel to change the indication * \param condition which condition to indicate on the channel * \return Returns 0 on success, -1 on failure */int ast_indicate(struct ast_channel *chan, int condition);/* Misc stuff ------------------------------------------------ *//*! \brief Wait for input on a channel * \param chan channel to wait on * \param ms length of time to wait on the channel * Wait for input on a channel for a given # of milliseconds (<0 for indefinite). \return Returns < 0 on failure, 0 if nothing ever arrived, and the # of ms remaining otherwise */int ast_waitfor(struct ast_channel *chan, int ms);/*! \brief Wait for a specied amount of time, looking for hangups * \param chan channel to wait for * \param ms length of time in milliseconds to sleep * Waits for a specified amount of time, servicing the channel as required. * \return returns -1 on hangup, otherwise 0. */int ast_safe_sleep(struct ast_channel *chan, int ms);/*! \brief Wait for a specied amount of time, looking for hangups and a condition argument * \param chan channel to wait for * \param ms length of time in milliseconds to sleep * \param cond a function pointer for testing continue condition * \param data argument to be passed to the condition test function * \return returns -1 on hangup, otherwise 0. * Waits for a specified amount of time, servicing the channel as required. If cond * returns 0, this function returns. */int ast_safe_sleep_conditional(struct ast_channel *chan, int ms, int (*cond)(void*), void *data );/*! \brief Waits for activity on a group of channels * \param chan an array of pointers to channels * \param n number of channels that are to be waited upon * \param fds an array of fds to wait upon * \param nfds the number of fds to wait upon * \param exception exception flag * \param outfd fd that had activity on it * \param ms how long the wait was * Big momma function here. Wait for activity on any of the n channels, or any of the nfds file descriptors. \return Returns the channel with activity, or NULL on error or if an FD came first. If the FD came first, it will be returned in outfd, otherwise, outfd will be -1 */struct ast_channel *ast_waitfor_nandfds(struct ast_channel **chan, int n, int *fds, int nfds, int *exception, int *outfd, int *ms);/*! Waits for input on a group of channels *//*! Wait for input on an array of channels for a given # of milliseconds. Return channel with activity, or NULL if none has activity. time "ms" is modified in-place, if applicable */struct ast_channel *ast_waitfor_n(struct ast_channel **chan, int n, int *ms);/*! Waits for input on an fd *//*! This version works on fd's only. Be careful with it. */int ast_waitfor_n_fd(int *fds, int n, int *ms, int *exception);/*! Reads a frame *//*! * \param chan channel to read a frame from * Read a frame. Returns a frame, or NULL on error. If it returns NULL, you best just stop reading frames and assume the channel has been disconnected. */struct ast_frame *ast_read(struct ast_channel *chan);/*! Write a frame to a channel *//*! * \param chan destination channel of the frame * \param frame frame that will be written * This function writes the given frame to the indicated channel. * It returns 0 on success, -1 on failure. */int ast_write(struct ast_channel *chan, struct ast_frame *frame);/*! Write video frame to a channel *//*! * \param chan destination channel of the frame * \param frame frame that will be written * This function writes the given frame to the indicated channel. * It returns 1 on success, 0 if not implemented, and -1 on failure. */int ast_write_video(struct ast_channel *chan, struct ast_frame *frame);/* Send empty audio to prime a channel driver */int ast_prod(struct ast_channel *chan);/*! Sets read format on channel chan *//*! * \param chan channel to change * \param format format to change to * Set read format for channel to whichever component of "format" is best. * Returns 0 on success, -1 on failure */int ast_set_read_format(struct ast_channel *chan, int format);/*! Sets write format on channel chan *//*! * \param chan channel to change * \param format new format for writing * Set write format for channel to whichever compoent of "format" is best. * Returns 0 on success, -1 on failure */int ast_set_write_format(struct ast_channel *chan, int format);/*! Sends text to a channel *//*! * \param chan channel to act upon * \param text string of text to send on the channel * Write text to a display on a channel * Returns 0 on success, -1 on failure */int ast_sendtext(struct ast_channel *chan, const char *text);/*! Receives a text character from a channel *//*! * \param chan channel to act upon * \param timeout timeout in milliseconds (0 for infinite wait) * Read a char of text from a channel * Returns 0 on success, -1 on failure */int ast_recvchar(struct ast_channel *chan, int timeout);/*! Send a DTMF digit to a channel *//*! * \param chan channel to act upon * \param digit the DTMF digit to send, encoded in ASCII
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -