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

📄 channel.h

📁 Asterisk-1.4.4最新内核源代码
💻 H
📖 第 1 页 / 共 4 页
字号:
/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 1999 - 2006, Digium, Inc. * * Mark Spencer <markster@digium.com> * * See http://www.asterisk.org for more information about * the Asterisk project. Please do not directly contact * any of the maintainers of this project for assistance; * the project provides a web site, mailing lists and IRC * channels for your use. * * This program is free software, distributed under the terms of * the GNU General Public License Version 2. See the LICENSE file * at the top of the source tree. *//*! \file * \brief General Asterisk PBX channel definitions. * \par See also: *  \arg \ref Def_Channel *  \arg \ref channel_drivers *//*! \page Def_Channel Asterisk Channels	\par What is a Channel?	A phone call through Asterisk consists of an incoming	connection and an outbound connection. Each call comes	in through a channel driver that supports one technology,	like SIP, ZAP, IAX2 etc. 	\par	Each channel driver, technology, has it's own private	channel or dialog structure, that is technology-dependent.	Each private structure is "owned" by a generic Asterisk	channel structure, defined in channel.h and handled by	channel.c .	\par Call scenario	This happens when an incoming call arrives to Asterisk	-# Call arrives on a channel driver interface	-# Channel driver creates a PBX channel and starts a 	   pbx thread on the channel	-# The dial plan is executed	-# At this point at least two things can happen:		-# The call is answered by Asterisk and 		   Asterisk plays a media stream or reads media		-# The dial plan forces Asterisk to create an outbound 		   call somewhere with the dial (see \ref app_dial.c)		   application	.	\par Bridging channels	If Asterisk dials out this happens:	-# Dial creates an outbound PBX channel and asks one of the	   channel drivers to create a call	-# When the call is answered, Asterisk bridges the media streams	   so the caller on the first channel can speak with the callee	   on the second, outbound channel	-# In some cases where we have the same technology on both	   channels and compatible codecs, a native bridge is used.	   In a native bridge, the channel driver handles forwarding	   of incoming audio to the outbound stream internally, without	   sending audio frames through the PBX.	-# In SIP, theres an "external native bridge" where Asterisk	   redirects the endpoint, so audio flows directly between the	   caller's phone and the callee's phone. Signalling stays in	   Asterisk in order to be able to provide a proper CDR record	   for the call.		\par Masquerading channels	In some cases, a channel can masquerade itself into another	channel. This happens frequently in call transfers, where 	a new channel takes over a channel that is already involved	in a call. The new channel sneaks in and takes over the bridge	and the old channel, now a zombie, is hung up.		\par Reference	\arg channel.c - generic functions 	\arg channel.h - declarations of functions, flags and structures	\arg translate.h - Transcoding support functions	\arg \ref channel_drivers - Implemented channel drivers	\arg \ref Def_Frame Asterisk Multimedia Frames*/#ifndef _ASTERISK_CHANNEL_H#define _ASTERISK_CHANNEL_H#include "asterisk/abstract_jb.h"#include <unistd.h>#ifdef POLLCOMPAT #include "asterisk/poll-compat.h"#else#include <sys/poll.h>#endif#if defined(__cplusplus) || defined(c_plusplus)extern "C" {#endif#define AST_MAX_EXTENSION	80	/*!< Max length of an extension */#define AST_MAX_CONTEXT		80	/*!< Max length of a context */#define AST_CHANNEL_NAME	80	/*!< Max length of an ast_channel name */#define MAX_LANGUAGE		20	/*!< Max length of the language setting */#define MAX_MUSICCLASS		80	/*!< Max length of the music class setting */#include "asterisk/compat.h"#include "asterisk/frame.h"#include "asterisk/sched.h"#include "asterisk/chanvars.h"#include "asterisk/config.h"#include "asterisk/lock.h"#include "asterisk/cdr.h"#include "asterisk/utils.h"#include "asterisk/linkedlists.h"#include "asterisk/stringfields.h"#include "asterisk/compiler.h"#define AST_MAX_FDS		8/* * We have AST_MAX_FDS file descriptors in a channel. * Some of them have a fixed use: */#define AST_ALERT_FD	(AST_MAX_FDS-1)		/*!< used for alertpipe */#define AST_TIMING_FD	(AST_MAX_FDS-2)		/*!< used for timingfd */#define AST_AGENT_FD	(AST_MAX_FDS-3)		/*!< used by agents for pass through */#define AST_GENERATOR_FD	(AST_MAX_FDS-4)	/*!< used by generator */enum ast_bridge_result {	AST_BRIDGE_COMPLETE = 0,	AST_BRIDGE_FAILED = -1,	AST_BRIDGE_FAILED_NOWARN = -2,	AST_BRIDGE_RETRY = -3,};typedef unsigned long long ast_group_t;struct ast_generator {	void *(*alloc)(struct ast_channel *chan, void *params);	void (*release)(struct ast_channel *chan, void *data);	int (*generate)(struct ast_channel *chan, void *data, int len, int samples);};/*! \brief Structure for a data store type */struct ast_datastore_info {	const char *type;		/*!< Type of data store */	void (*destroy)(void *data);	/*!< Destroy function */};/*! \brief Structure for a channel data store */struct ast_datastore {	char *uid;		/*!< Unique data store identifier */	void *data;		/*!< Contained data */	const struct ast_datastore_info *info;	/*!< Data store type information */	AST_LIST_ENTRY(ast_datastore) entry; /*!< Used for easy linking */};/*! \brief Structure for all kinds of caller ID identifications. * \note All string fields here are malloc'ed, so they need to be * freed when the structure is deleted. * Also, NULL and "" must be considered equivalent. */struct ast_callerid {	char *cid_dnid;		/*!< Malloc'd Dialed Number Identifier */	char *cid_num;		/*!< Malloc'd Caller Number */	char *cid_name;		/*!< Malloc'd Caller Name */	char *cid_ani;		/*!< Malloc'd ANI */	char *cid_rdnis;	/*!< Malloc'd RDNIS */	int cid_pres;		/*!< Callerid presentation/screening */	int cid_ani2;		/*!< Callerid ANI 2 (Info digits) */	int cid_ton;		/*!< Callerid Type of Number */	int cid_tns;		/*!< Callerid Transit Network Select */};/*! \brief 	Structure to describe a channel "technology", ie a channel driver 	See for examples:	\arg chan_iax2.c - The Inter-Asterisk exchange protocol	\arg chan_sip.c - The SIP channel driver	\arg chan_zap.c - PSTN connectivity (TDM, PRI, T1/E1, FXO, FXS)	If you develop your own channel driver, this is where you	tell the PBX at registration of your driver what properties	this driver supports and where different callbacks are 	implemented.*/struct ast_channel_tech {	const char * const type;	const char * const description;	int capabilities;		/*!< Bitmap of formats this channel can handle */	int properties;			/*!< Technology Properties */	/*! \brief Requester - to set up call data structures (pvt's) */	struct ast_channel *(* const requester)(const char *type, int format, void *data, int *cause);	int (* const devicestate)(void *data);	/*!< Devicestate call back */	/*! \brief Start sending a literal DTMF digit */	int (* const send_digit_begin)(struct ast_channel *chan, char digit);	/*! \brief Stop sending a literal DTMF digit */	int (* const send_digit_end)(struct ast_channel *chan, char digit, unsigned int duration);	/*! \brief Call a given phone number (address, etc), but don't	   take longer than timeout seconds to do so.  */	int (* const call)(struct ast_channel *chan, char *addr, int timeout);	/*! \brief Hangup (and possibly destroy) the channel */	int (* const hangup)(struct ast_channel *chan);	/*! \brief Answer the channel */	int (* const answer)(struct ast_channel *chan);	/*! \brief Read a frame, in standard format (see frame.h) */	struct ast_frame * (* const read)(struct ast_channel *chan);	/*! \brief Write a frame, in standard format (see frame.h) */	int (* const write)(struct ast_channel *chan, struct ast_frame *frame);	/*! \brief Display or transmit text */	int (* const send_text)(struct ast_channel *chan, const char *text);	/*! \brief Display or send an image */	int (* const send_image)(struct ast_channel *chan, struct ast_frame *frame);	/*! \brief Send HTML data */	int (* const send_html)(struct ast_channel *chan, int subclass, const char *data, int len);	/*! \brief Handle an exception, reading a frame */	struct ast_frame * (* const exception)(struct ast_channel *chan);	/*! \brief Bridge two channels of the same type together */	enum ast_bridge_result (* const bridge)(struct ast_channel *c0, struct ast_channel *c1, int flags,						struct ast_frame **fo, struct ast_channel **rc, int timeoutms);	/*! \brief Indicate a particular condition (e.g. AST_CONTROL_BUSY or AST_CONTROL_RINGING or AST_CONTROL_CONGESTION */	int (* const indicate)(struct ast_channel *c, int condition, const void *data, size_t datalen);	/*! \brief Fix up a channel:  If a channel is consumed, this is called.  Basically update any ->owner links */	int (* const fixup)(struct ast_channel *oldchan, struct ast_channel *newchan);	/*! \brief Set a given option */	int (* const setoption)(struct ast_channel *chan, int option, void *data, int datalen);	/*! \brief Query a given option */	int (* const queryoption)(struct ast_channel *chan, int option, void *data, int *datalen);	/*! \brief Blind transfer other side (see app_transfer.c and ast_transfer() */	int (* const transfer)(struct ast_channel *chan, const char *newdest);	/*! \brief Write a frame, in standard format */	int (* const write_video)(struct ast_channel *chan, struct ast_frame *frame);	/*! \brief Find bridged channel */	struct ast_channel *(* const bridged_channel)(struct ast_channel *chan, struct ast_channel *bridge);	/*! \brief Provide additional read items for CHANNEL() dialplan function */	int (* func_channel_read)(struct ast_channel *chan, char *function, char *data, char *buf, size_t len);	/*! \brief Provide additional write items for CHANNEL() dialplan function */	int (* func_channel_write)(struct ast_channel *chan, char *function, char *data, const char *value);};struct ast_channel_spy_list;struct ast_channel_whisper_buffer;#define	DEBUGCHAN_FLAG  0x80000000#define	FRAMECOUNT_INC(x)	( ((x) & DEBUGCHAN_FLAG) | (((x)+1) & ~DEBUGCHAN_FLAG) )enum ast_channel_adsicpe {	AST_ADSI_UNKNOWN,	AST_ADSI_AVAILABLE,	AST_ADSI_UNAVAILABLE,	AST_ADSI_OFFHOOKONLY,};/*!  * \brief 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 */enum ast_channel_state {	/*! Channel is down and available */	AST_STATE_DOWN,	/*! Channel is down, but reserved */	AST_STATE_RESERVED,	/*! Channel is off hook */	AST_STATE_OFFHOOK,	/*! Digits (or equivalent) have been dialed */	AST_STATE_DIALING,	/*! Line is ringing */	AST_STATE_RING,	/*! Remote end is ringing */	AST_STATE_RINGING,	/*! Line is up */	AST_STATE_UP,	/*! Line is busy */	AST_STATE_BUSY,	/*! Digits (or equivalent) have been dialed while offhook */	AST_STATE_DIALING_OFFHOOK,	/*! Channel has detected an incoming call and is waiting for ring */	AST_STATE_PRERING,	/*! Do not transmit voice data */	AST_STATE_MUTE = (1 << 16),};/*! \brief Main Channel structure associated with a channel.  * This is the side of it mostly used by the pbx and call management. * * \note XXX It is important to remember to increment .cleancount each time *       this structure is changed. XXX */struct ast_channel {	/*! \brief Technology (point to channel driver) */	const struct ast_channel_tech *tech;	/*! \brief Private data used by the technology driver */	void *tech_pvt;	AST_DECLARE_STRING_FIELDS(		AST_STRING_FIELD(name);			/*!< ASCII unique channel name */		AST_STRING_FIELD(language);		/*!< Language requested for voice prompts */		AST_STRING_FIELD(musicclass);		/*!< Default music class */		AST_STRING_FIELD(accountcode);		/*!< Account code for billing */		AST_STRING_FIELD(call_forward);		/*!< Where to forward to if asked to dial on this interface */		AST_STRING_FIELD(uniqueid);		/*!< Unique Channel Identifier */	);		/*! \brief File descriptor for channel -- Drivers will poll on these file descriptors, so at least one must be non -1.  */	int fds[AST_MAX_FDS];				void *music_state;				/*!< Music State*/	void *generatordata;				/*!< Current generator data if there is any */	struct ast_generator *generator;		/*!< Current active data generator */	/*! \brief Who are we bridged to, if we're bridged. Who is proxying for us,	  if we are proxied (i.e. chan_agent).

⌨️ 快捷键说明

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