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

📄 channel.h

📁 Astercon2 开源软交换 2.2.0
💻 H
📖 第 1 页 / 共 3 页
字号:
/* * Asterisk -- An open source telephony toolkit. * * Copyright (C) 1999 - 2005, 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 \ref channel_drivers - Implemented channel drivers	\arg \ref Def_Frame Asterisk Multimedia Frames*/#ifndef _ASTERISK_CHANNEL_H#define _ASTERISK_CHANNEL_H#include <unistd.h>#include <setjmp.h>#ifdef POLLCOMPAT #include "asterisk/poll-compat.h"#else#include <sys/poll.h>#endif#if defined(__cplusplus) || defined(c_plusplus)extern "C" {#endif/*! Max length of an extension */#define AST_MAX_EXTENSION	80#define AST_MAX_CONTEXT		80#define AST_CHANNEL_NAME	80#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"#define MAX_LANGUAGE		20#define MAX_MUSICCLASS		20#define AST_MAX_FDS		8enum 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);};/*! Structure for all kinds of caller ID identifications */struct ast_callerid {	/*! Malloc'd Dialed Number Identifier */	char *cid_dnid;					/*! Malloc'd Caller Number */	char *cid_num;	/*! Malloc'd Caller Name */	char *cid_name;	/*! Malloc'd ANI */	char *cid_ani;				/*! Malloc'd RDNIS */	char *cid_rdnis;	/*! Callerid presentation/screening */	int cid_pres;	/*! Callerid ANI 2 (Info digits) */	int cid_ani2;	/*! Callerid Type of Number */	int cid_ton;	/*! Callerid Transit Network Select */	int cid_tns;};/*! Structure to describe a channel "technology", ie a channel driver 	See	\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;	/*! Bitmap of formats this channel can handle */	int capabilities;	/*! Technology Properties */	int properties;	/*! Requester - to set up call data structures (pvt's) */	struct ast_channel *(* const requester)(const char *type, int format, void *data, int *cause);	/*! Devicestate call back */	int (* const devicestate)(void *data);	/*! Send a literal DTMF digit */	int (* const send_digit)(struct ast_channel *chan, char digit);	/*! 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);	/*! Hangup (and possibly destroy) the channel */	int (* const hangup)(struct ast_channel *chan);	/*! Answer the channel */	int (* const answer)(struct ast_channel *chan);	/*! Read a frame, in standard format (see frame.h) */	struct ast_frame * (* const read)(struct ast_channel *chan);	/*! Write a frame, in standard format (see frame.h) */	int (* const write)(struct ast_channel *chan, struct ast_frame *frame);	/*! Display or transmit text */	int (* const send_text)(struct ast_channel *chan, const char *text);	/*! Display or send an image */	int (* const send_image)(struct ast_channel *chan, struct ast_frame *frame);	/*! Send HTML data */	int (* const send_html)(struct ast_channel *chan, int subclass, const char *data, int len);	/*! Handle an exception, reading a frame */	struct ast_frame * (* const exception)(struct ast_channel *chan);	/*! 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);	/*! 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);	/*! 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);	/*! Set a given option */	int (* const setoption)(struct ast_channel *chan, int option, void *data, int datalen);	/*! Query a given option */	int (* const queryoption)(struct ast_channel *chan, int option, void *data, int *datalen);	/*! Blind transfer other side (see app_transfer.c and ast_transfer() */	int (* const transfer)(struct ast_channel *chan, const char *newdest);	/*! Write a frame, in standard format */	int (* const write_video)(struct ast_channel *chan, struct ast_frame *frame);	/*! Find bridged channel */	struct ast_channel *(* const bridged_channel)(struct ast_channel *chan, struct ast_channel *bridge);};struct ast_channel_spy_list;/*! Main Channel structure associated with a channel.  * This is the side of it mostly used by the pbx and call management. */struct ast_channel {	/*! ASCII unique channel name */	char name[AST_CHANNEL_NAME];		/*! Technology (point to channel driver) */	const struct ast_channel_tech *tech;	/*! Private data used by the technology driver */	void *tech_pvt;	/*! Language requested for voice prompts */	char language[MAX_LANGUAGE];			/*! Type of channel */	const char *type;					/*! File descriptor for channel -- Drivers will poll on these file descriptors, so at least one must be non -1.  */	int fds[AST_MAX_FDS];				/*! Default music class */	char musicclass[MAX_MUSICCLASS];	/*! Music State*/	void *music_state;	/*! Current generator data if there is any */	void *generatordata;	/*! Current active data generator */	struct ast_generator *generator;	/*! Who are we bridged to, if we're bridged. Who is proxying for us,	  if we are proxied (i.e. chan_agent).	  Do not access directly, use ast_bridged_channel(chan) */	struct ast_channel *_bridge;	/*! Channel that will masquerade as us */	struct ast_channel *masq;			/*! Who we are masquerading as */	struct ast_channel *masqr;			/*! Call Detail Record Flags */	int cdrflags;										   	/*! Whether or not we have been hung up...  Do not set this value	    directly, use ast_softhangup */	int _softhangup;	/*! Non-zero, set to actual time when channel is to be hung up */	time_t	whentohangup;	/*! If anyone is blocking, this is them */	pthread_t blocker;				/*! Lock, can be used to lock a channel for some operations */	ast_mutex_t lock;				/*! Procedure causing blocking */	const char *blockproc;				/*! Current application */	char *appl;					/*! Data passed to current application */	char *data;						/*! Which fd had an event detected on */	int fdno;					/*! Schedule context */	struct sched_context *sched;			/*! For streaming playback, the schedule ID */	int streamid;					/*! Stream itself. */	struct ast_filestream *stream;			/*! For streaming video playback, the schedule ID */	int vstreamid;					/*! Video Stream itself. */	struct ast_filestream *vstream;			/*! Original writer format */	int oldwriteformat;					/*! Timing fd */	int timingfd;	int (*timingfunc)(void *data);	void *timingdata;	/*! State of line -- Don't write directly, use ast_setstate */	int _state;					/*! Number of rings so far */	int rings;					/*! Kinds of data this channel can natively handle */	int nativeformats;				/*! Requested read format */	int readformat;					/*! Requested write format */	int writeformat;				struct ast_callerid cid;			/*! Current extension context */	char context[AST_MAX_CONTEXT];	/*! Current non-macro context */	char macrocontext[AST_MAX_CONTEXT];		/*! Current non-macro extension */	char macroexten[AST_MAX_EXTENSION];	/*! Current non-macro priority */	int macropriority;	/*! Current extension number */	char exten[AST_MAX_EXTENSION];			/* Current extension priority */	int priority;							/*! Any/all queued DTMF characters */	char dtmfq[AST_MAX_EXTENSION];			/*! DTMF frame */	struct ast_frame dtmff;				/*! PBX private structure */	struct ast_pbx *pbx;	/*! Set BEFORE PBX is started to determine AMA flags */	int amaflags;				/*! Account code for billing */	char accountcode[AST_MAX_ACCOUNT_CODE];			/*! Call Detail Record */	struct ast_cdr *cdr;				/*! Whether or not ADSI is detected on CPE */	int adsicpe;	/*! Where to forward to if asked to dial on this interface */	char call_forward[AST_MAX_EXTENSION];	/*! Tone zone as set in indications.conf */	struct tone_zone *zone;	/* Channel monitoring */	struct ast_channel_monitor *monitor;	/*! Track the read/written samples for monitor use */	unsigned long insmpl;	unsigned long outsmpl;	/* Frames in/out counters */	unsigned int fin;	unsigned int fout;	/* Unique Channel Identifier */	char uniqueid[32];	/* Why is the channel hanged up */	int hangupcause;		/* A linked list for variables */	struct varshead varshead;	ast_group_t callgroup;	ast_group_t pickupgroup;	/*! channel flags of AST_FLAG_ type */	unsigned int flags;		/*! ISDN Transfer Capbility - AST_FLAG_DIGITAL is not enough */	unsigned short transfercapability;	struct ast_frame *readq;	int alertpipe[2];	/*! Write translation path */	struct ast_trans_pvt *writetrans;

⌨️ 快捷键说明

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