📄 channel.h
字号:
CHANNEL_MANAGER_RELOAD,};/*! * \brief Create a channel datastore structure * * \note None of the datastore API calls lock the ast_channel they are using. * So, the channel should be locked before calling the functions that * take a channel argument. */struct ast_datastore *ast_channel_datastore_alloc(const struct ast_datastore_info *info, const char *uid);/*! \brief Free a channel datastore structure */int ast_channel_datastore_free(struct ast_datastore *datastore);/*! \brief Inherit datastores from a parent to a child. */int ast_channel_datastore_inherit(struct ast_channel *from, struct ast_channel *to);/*! * \brief Add a datastore to a channel * * \note The channel should be locked before calling this function. * * \retval 0 success * \retval non-zero failure */int ast_channel_datastore_add(struct ast_channel *chan, struct ast_datastore *datastore);/*! * \brief Remove a datastore from a channel * * \note The channel should be locked before calling this function. * * \retval 0 success * \retval non-zero failure */int ast_channel_datastore_remove(struct ast_channel *chan, struct ast_datastore *datastore);/*! * \brief Find a datastore on a channel * * \note The channel should be locked before calling this function. * * \note The datastore returned from this function must not be used if the * reference to the channel is released. */struct ast_datastore *ast_channel_datastore_find(struct ast_channel *chan, const struct ast_datastore_info *info, const char *uid);/*! \brief Change the state of a channel */int ast_setstate(struct ast_channel *chan, enum ast_channel_state);/*! * \brief Create a channel structure * * \retval NULL failure * \retval non-NULL successfully allocated channel * * \note By default, new channels are set to the "s" extension * and "default" context. */struct ast_channel *ast_channel_alloc(int needqueue, int state, const char *cid_num, const char *cid_name, const char *acctcode, const char *exten, const char *context, const int amaflag, const char *name_fmt, ...) __attribute__((format(printf, 9, 10)));/*! * \brief Queue an outgoing frame * * \note The channel does not need to be locked before calling this function. */int ast_queue_frame(struct ast_channel *chan, struct ast_frame *f);/*! * \brief Queue an outgoing frame to the head of the frame queue * * \param chan the channel to queue the frame on * \param f the frame to queue. Note that this frame will be duplicated by * this function. It is the responsibility of the caller to handle * freeing the memory associated with the frame being passed if * necessary. * * \retval 0 success * \retval non-zero failure */int ast_queue_frame_head(struct ast_channel *chan, struct ast_frame *f);/*! * \brief Queue a hangup frame * * \note The channel does not need to be locked before calling this function. */int ast_queue_hangup(struct ast_channel *chan);/*! * \brief Queue a control frame with payload * * \param chan channel to queue frame onto * \param control type of control frame * * \note The channel does not need to be locked before calling this function. * * \retval zero on success * \retval non-zero on failure */int ast_queue_control(struct ast_channel *chan, enum ast_control_frame_type control);/*! * \brief Queue a control frame with payload * * \param chan channel to queue frame onto * \param control type of control frame * \param data pointer to payload data to be included in frame * \param datalen number of bytes of payload data * * \retval 0 success * \retval non-zero failure * * The supplied payload data is copied into the frame, so the caller's copy * is not modified nor freed, and the resulting frame will retain a copy of * the data even if the caller frees their local copy. * * \note This method should be treated as a 'network transport'; in other * words, your frames may be transferred across an IAX2 channel to another * system, which may be a different endianness than yours. Because of this, * you should ensure that either your frames will never be expected to work * across systems, or that you always put your payload data into 'network byte * order' before calling this function. * * \note The channel does not need to be locked before calling this function. */int ast_queue_control_data(struct ast_channel *chan, enum ast_control_frame_type control, const void *data, size_t datalen);/*! * \brief Change channel name * * \note The channel must be locked before calling this function. */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 (codec) * \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 * * \retval NULL failure * \retval non-NULL channel on success */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 unsuccessful) * \param cid_num Caller-ID Number * \param cid_name Caller-ID Name (ascii) * * \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 *cid_num, const char *cid_name);/*! * \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 unsuccessful) * \param cid_num Caller-ID Number * \param cid_name Caller-ID Name (ascii) * \param oh Outgoing helper * \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 *cid_num, const char *cid_name, 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);#ifdef CHANNEL_TRACE/*! \brief Update the context backtrace if tracing is enabled * \return Returns 0 on success, -1 on failure */int ast_channel_trace_update(struct ast_channel *chan);/*! \brief Enable context tracing in the channel * \return Returns 0 on success, -1 on failure */int ast_channel_trace_enable(struct ast_channel *chan);/*! \brief Disable context tracing in the channel. * \note Does not remove current trace entries * \return Returns 0 on success, -1 on failure */int ast_channel_trace_disable(struct ast_channel *chan);/*! \brief Whether or not context tracing is enabled * \return Returns -1 when the trace is enabled. 0 if not. */int ast_channel_trace_is_enabled(struct ast_channel *chan);/*! \brief Put the channel backtrace in a string * \return Returns the amount of lines in the backtrace. -1 on error. */int ast_channel_trace_serialize(struct ast_channel *chan, struct ast_str **out);#endif/*! \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 * \param cause Ast hangupcause for hangup * * 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. * * \note The channel passed to this function does not need to be locked. * * \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 return -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). * * \note This function does not require that the channel is locked before * calling it. * * \return Nothing */void ast_channel_setwhentohangup(struct ast_channel *chan, time_t offset);/*! * \brief Answer a channel * * \param chan channel to answer * * This function answers a channel and handles all necessary call * setup functions. * * \note The channel passed does not need to be locked. * * \retval 0 on success * \retval non-zero on failure */int ast_answer(struct ast_channel *chan);int __ast_answer(struct ast_channel *chan, unsigned int delay, int cdr_answer);/*! \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);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -