⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 channel.h

📁 Astercon2 开源软交换 2.2.0
💻 H
📖 第 1 页 / 共 3 页
字号:
 * Send a DTMF digit to a channel. * Returns 0 on success, -1 on failure */int ast_senddigit(struct ast_channel *chan, char digit);/*! Receives a text string from a channel *//*!  * \param chan channel to act upon * \param timeout timeout in milliseconds (0 for infinite wait) * \return the received text, or NULL to signify failure. * Read a string of text from a channel */char *ast_recvtext(struct ast_channel *chan, int timeout);/*! Browse channels in use *//*!  * \param prev where you want to start in the channel list * Browse the channels currently in use  * Returns the next channel in the list, NULL on end. * If it returns a channel, that channel *has been locked*! */struct ast_channel *ast_channel_walk_locked(const struct ast_channel *prev);/*! Get channel by name (locks channel) */struct ast_channel *ast_get_channel_by_name_locked(const char *chan);/*! Get channel by name prefix (locks channel) */struct ast_channel *ast_get_channel_by_name_prefix_locked(const char *name, const int namelen);/*! Get channel by name prefix (locks channel) */struct ast_channel *ast_walk_channel_by_name_prefix_locked(struct ast_channel *chan, const char *name, const int namelen);/*--- ast_get_channel_by_exten_locked: Get channel by exten (and optionally context) and lock it */struct ast_channel *ast_get_channel_by_exten_locked(const char *exten, const char *context);/*! Waits for a digit *//*!  * \param c channel to wait for a digit on * \param ms how many milliseconds to wait * Wait for a digit.  Returns <0 on error, 0 on no entry, and the digit on success. */int ast_waitfordigit(struct ast_channel *c, int ms);/* Same as above with audio fd for outputing read audio and ctrlfd to monitor for   reading. Returns 1 if ctrlfd becomes available */int ast_waitfordigit_full(struct ast_channel *c, int ms, int audiofd, int ctrlfd);/*! Reads multiple digits *//*!  * \param c channel to read from * \param s string to read in to.  Must be at least the size of your length * \param len how many digits to read (maximum) * \param timeout how long to timeout between digits * \param rtimeout timeout to wait on the first digit * \param enders digits to end the string * Read in a digit string "s", max length "len", maximum timeout between    digits "timeout" (-1 for none), terminated by anything in "enders".  Give them rtimeout   for the first digit.  Returns 0 on normal return, or 1 on a timeout.  In the case of   a timeout, any digits that were read before the timeout will still be available in s.     RETURNS 2 in full version when ctrlfd is available, NOT 1*/int ast_readstring(struct ast_channel *c, char *s, int len, int timeout, int rtimeout, char *enders);int ast_readstring_full(struct ast_channel *c, char *s, int len, int timeout, int rtimeout, char *enders, int audiofd, int ctrlfd);/*! Report DTMF on channel 0 */#define AST_BRIDGE_DTMF_CHANNEL_0		(1 << 0)		/*! Report DTMF on channel 1 */#define AST_BRIDGE_DTMF_CHANNEL_1		(1 << 1)		/*! Return all voice frames on channel 0 */#define AST_BRIDGE_REC_CHANNEL_0		(1 << 2)		/*! Return all voice frames on channel 1 */#define AST_BRIDGE_REC_CHANNEL_1		(1 << 3)		/*! Ignore all signal frames except NULL */#define AST_BRIDGE_IGNORE_SIGS			(1 << 4)		/*! Makes two channel formats compatible *//*!  * \param c0 first channel to make compatible * \param c1 other channel to make compatible * Set two channels to compatible formats -- call before ast_channel_bridge in general .  Returns 0 on success   and -1 if it could not be done */int ast_channel_make_compatible(struct ast_channel *c0, struct ast_channel *c1);/*! Bridge two channels together *//*!  * \param c0 first channel to bridge * \param c1 second channel to bridge * \param config config for the channels * \param fo destination frame(?) * \param rc destination channel(?) * Bridge two channels (c0 and c1) together.  If an important frame occurs, we return that frame in   *rf (remember, it could be NULL) and which channel (0 or 1) in rc *//* int ast_channel_bridge(struct ast_channel *c0, struct ast_channel *c1, int flags, struct ast_frame **fo, struct ast_channel **rc); */int ast_channel_bridge(struct ast_channel *c0,struct ast_channel *c1,struct ast_bridge_config *config, struct ast_frame **fo, struct ast_channel **rc);/*! Weird function made for call transfers *//*!  * \param original channel to make a copy of * \param clone copy of the original channel * This is a very strange and freaky function used primarily for transfer.  Suppose that   "original" and "clone" are two channels in random situations.  This function takes   the guts out of "clone" and puts them into the "original" channel, then alerts the   channel driver of the change, asking it to fixup any private information (like the   p->owner pointer) that is affected by the change.  The physical layer of the original   channel is hung up.  */int ast_channel_masquerade(struct ast_channel *original, struct ast_channel *clone);/*! Gives the string form of a given cause code *//*!  * \param state cause to get the description of * Give a name to a cause code * Returns the text form of the binary cause code given */const char *ast_cause2str(int state);/*! Gives the string form of a given channel state *//*!  * \param state state to get the name of * Give a name to a state  * Returns the text form of the binary state given */char *ast_state2str(int state);/*! Gives the string form of a given transfer capability *//*! * \param transfercapability transfercapabilty to get the name of * Give a name to a transfercapbility * See above * Returns the text form of the binary transfer capbility */char *ast_transfercapability2str(int transfercapability);/* Options: Some low-level drivers may implement "options" allowing fine tuning of the   low level channel.  See frame.h for options.  Note that many channel drivers may support   none or a subset of those features, and you should not count on this if you want your   asterisk application to be portable.  They're mainly useful for tweaking performance *//*! Sets an option on a channel *//*!  * \param channel channel to set options on * \param option option to change * \param data data specific to option * \param datalen length of the data * \param block blocking or not * Set an option on a channel (see frame.h), optionally blocking awaiting the reply  * Returns 0 on success and -1 on failure */int ast_channel_setoption(struct ast_channel *channel, int option, void *data, int datalen, int block);/*! Pick the best codec  *//* Choose the best codec...  Uhhh...   Yah. */extern int ast_best_codec(int fmts);/*! Checks the value of an option *//*!  * Query the value of an option, optionally blocking until a reply is received * Works similarly to setoption except only reads the options. */struct ast_frame *ast_channel_queryoption(struct ast_channel *channel, int option, void *data, int *datalen, int block);/*! Checks for HTML support on a channel *//*! Returns 0 if channel does not support HTML or non-zero if it does */int ast_channel_supports_html(struct ast_channel *channel);/*! Sends HTML on given channel *//*! Send HTML or URL on link.  Returns 0 on success or -1 on failure */int ast_channel_sendhtml(struct ast_channel *channel, int subclass, const char *data, int datalen);/*! Sends a URL on a given link *//*! Send URL on link.  Returns 0 on success or -1 on failure */int ast_channel_sendurl(struct ast_channel *channel, const char *url);/*! Defers DTMF *//*! Defer DTMF so that you only read things like hangups and audio.  Returns   non-zero if channel was already DTMF-deferred or 0 if channel is just now   being DTMF-deferred */int ast_channel_defer_dtmf(struct ast_channel *chan);/*! Undeos a defer *//*! Undo defer.  ast_read will return any dtmf characters that were queued */void ast_channel_undefer_dtmf(struct ast_channel *chan);/*! Initiate system shutdown -- prevents new channels from being allocated.    If "hangup" is non-zero, all existing channels will receive soft     hangups */void ast_begin_shutdown(int hangup);/*! Cancels an existing shutdown and returns to normal operation */void ast_cancel_shutdown(void);/*! Returns number of active/allocated channels */int ast_active_channels(void);/*! Returns non-zero if Asterisk is being shut down */int ast_shutting_down(void);/*! Activate a given generator */int ast_activate_generator(struct ast_channel *chan, struct ast_generator *gen, void *params);/*! Deactive an active generator */void ast_deactivate_generator(struct ast_channel *chan);void ast_set_callerid(struct ast_channel *chan, const char *cidnum, const char *cidname, const char *ani);/*! Start a tone going */int ast_tonepair_start(struct ast_channel *chan, int freq1, int freq2, int duration, int vol);/*! Stop a tone from playing */void ast_tonepair_stop(struct ast_channel *chan);/*! Play a tone pair for a given amount of time */int ast_tonepair(struct ast_channel *chan, int freq1, int freq2, int duration, int vol);/*! Automatically service a channel for us... */int ast_autoservice_start(struct ast_channel *chan);/*! Stop servicing a channel for us...  Returns -1 on error or if channel has been hungup */int ast_autoservice_stop(struct ast_channel *chan);/* If built with zaptel optimizations, force a scheduled expiration on the   timer fd, at which point we call the callback function / data */int ast_settimeout(struct ast_channel *c, int samples, int (*func)(void *data), void *data);/*!	\brief Transfer a channel (if supported).  Returns -1 on error, 0 if not supported   and 1 if supported and requested 	\param chan current channel	\param dest destination extension for transfer*/int ast_transfer(struct ast_channel *chan, char *dest);/*!	\brief  Start masquerading a channel	XXX This is a seriously wacked out operation.  We're essentially putting the guts of           the clone channel into the original channel.  Start by killing off the original           channel's backend.   I'm not sure we're going to keep this function, because           while the features are nice, the cost is very high in terms of pure nastiness. XXX	\param chan 	Channel to masquerade*/int ast_do_masquerade(struct ast_channel *chan);/*!	\brief Find bridged channel 	\param chan Current channel*/struct ast_channel *ast_bridged_channel(struct ast_channel *chan);/*!  \brief Inherits channel variable from parent to child channel  \param parent Parent channel  \param child Child channel  Scans all channel variables in the parent channel, looking for those  that should be copied into the child channel.  Variables whose names begin with a single '_' are copied into the  child channel with the prefix removed.  Variables whose names begin with '__' are copied into the child  channel with their names unchanged.*/void ast_channel_inherit_variables(const struct ast_channel *parent, struct ast_channel *child);/*!  \brief adds a list of channel variables to a channel  \param chan the channel  \param vars a linked list of variables  Variable names can be for a regular channel variable or a dialplan function  that has the ability to be written to.*/void ast_set_variables(struct ast_channel *chan, struct ast_variable *vars);/*!  \brief An opaque 'object' structure use by silence generators on channels. */struct ast_silence_generator;/*!  \brief Starts a silence generator on the given channel.  \param chan The channel to generate silence on  \return An ast_silence_generator pointer, or NULL if an error occurs  This function will cause SLINEAR silence to be generated on the supplied  channel until it is disabled; if the channel cannot be put into SLINEAR  mode then the function will fail.  The pointer returned by this function must be preserved and passed to  ast_channel_stop_silence_generator when you wish to stop the silence  generation. */struct ast_silence_generator *ast_channel_start_silence_generator(struct ast_channel *chan);/*!  \brief Stops a previously-started silence generator on the given channel.  \param chan The channel to operate on  \param state The ast_silence_generator pointer return by a previous call to  ast_channel_start_silence_generator.  \return nothing  This function will stop the operating silence generator and return the channel  to its previous write format. */void ast_channel_stop_silence_generator(struct ast_channel *chan, struct ast_silence_generator *state);/* Misc. functions below *//* Helper function for migrating select to poll */static inline int ast_fdisset(struct pollfd *pfds, int fd, int max, int *start){	int x;	for (x=start ? *start : 0;x<max;x++)		if (pfds[x].fd == fd) {			if (start) {				if (x==*start)					(*start)++;			}			return pfds[x].revents;		}	return 0;}#ifdef SOLARISstatic inline void timersub(struct timeval *tvend, struct timeval *tvstart, struct timeval *tvdiff){	tvdiff->tv_sec = tvend->tv_sec - tvstart->tv_sec;	tvdiff->tv_usec = tvend->tv_usec - tvstart->tv_usec;	if (tvdiff->tv_usec < 0) {		tvdiff->tv_sec --;		tvdiff->tv_usec += 1000000;	}}#endif/*! \brief Waits for activity on a group of channels  * \param nfds the maximum number of file descriptors in the sets * \param rfds file descriptors to check for read availability * \param wfds file descriptors to check for write availability * \param efds file descriptors to check for exceptions (OOB data) * \param tvp timeout while waiting for events * This is the same as a standard select(), except it guarantees the * behaviour where the passed struct timeval is updated with how much * time was not slept while waiting for the specified events */static inline int ast_select(int nfds, fd_set *rfds, fd_set *wfds, fd_set *efds, struct timeval *tvp){#ifdef __linux__	return select(nfds, rfds, wfds, efds, tvp);#else	if (tvp) {		struct timeval tv, tvstart, tvend, tvlen;		int res;		tv = *tvp;		gettimeofday(&tvstart, NULL);		res = select(nfds, rfds, wfds, efds, tvp);		gettimeofday(&tvend, NULL);		timersub(&tvend, &tvstart, &tvlen);		timersub(&tv, &tvlen, tvp);		if (tvp->tv_sec < 0 || (tvp->tv_sec == 0 && tvp->tv_usec < 0)) {			tvp->tv_sec = 0;			tvp->tv_usec = 0;		}		return res;	}	else		return select(nfds, rfds, wfds, efds, NULL);#endif}#if !defined(ast_strdupa) && defined(__GNUC__)# define ast_strdupa(s)									\  (__extension__										\    ({													\      __const char *__old = (s);						\      size_t __len = strlen (__old) + 1;				\      char *__new = (char *) __builtin_alloca (__len);	\      (char *) memcpy (__new, __old, __len);			\    }))#endif#ifdef DO_CRASH#define CRASH do { fprintf(stderr, "!! Forcing immediate crash a-la abort !!\n"); *((int *)0) = 0; } while(0)#else#define CRASH do { } while(0)#endif#define CHECK_BLOCKING(c) { 	 \							if (ast_test_flag(c, AST_FLAG_BLOCKING)) {\								ast_log(LOG_WARNING, "Thread %ld Blocking '%s', already blocked by thread %ld in procedure %s\n", (long) pthread_self(), (c)->name, (long) (c)->blocker, (c)->blockproc); \								CRASH; \							} else { \								(c)->blocker = pthread_self(); \								(c)->blockproc = __PRETTY_FUNCTION__; \									ast_set_flag(c, AST_FLAG_BLOCKING); \									} }extern ast_group_t ast_get_group(char *s);/* print call- and pickup groups into buffer */extern char *ast_print_group(char *buf, int buflen, ast_group_t group);#if defined(__cplusplus) || defined(c_plusplus)}#endif#endif /* _ASTERISK_CHANNEL_H */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -