📄 channel.h
字号:
Do not access directly, use ast_bridged_channel(chan) */ struct ast_channel *_bridge; struct ast_channel *masq; /*!< Channel that will masquerade as us */ struct ast_channel *masqr; /*!< Who we are masquerading as */ int cdrflags; /*!< Call Detail Record Flags */ /*! \brief Whether or not we have been hung up... Do not set this value directly, use ast_softhangup */ int _softhangup; time_t whentohangup; /*!< Non-zero, set to actual time when channel is to be hung up */ pthread_t blocker; /*!< If anyone is blocking, this is them */ ast_mutex_t lock; /*!< Lock, can be used to lock a channel for some operations */ const char *blockproc; /*!< Procedure causing blocking */ const char *appl; /*!< Current application */ const char *data; /*!< Data passed to current application */ int fdno; /*!< Which fd had an event detected on */ struct sched_context *sched; /*!< Schedule context */ int streamid; /*!< For streaming playback, the schedule ID */ struct ast_filestream *stream; /*!< Stream itself. */ int vstreamid; /*!< For streaming video playback, the schedule ID */ struct ast_filestream *vstream; /*!< Video Stream itself. */ int oldwriteformat; /*!< Original writer format */ int timingfd; /*!< Timing fd */ int (*timingfunc)(void *data); void *timingdata; enum ast_channel_state _state; /*!< State of line -- Don't write directly, use ast_setstate */ int rings; /*!< Number of rings so far */ struct ast_callerid cid; /*!< Caller ID, name, presentation etc */ char dtmfq[AST_MAX_EXTENSION]; /*!< Any/all queued DTMF characters */ struct ast_frame dtmff; /*!< DTMF frame */ char context[AST_MAX_CONTEXT]; /*!< Dialplan: Current extension context */ char exten[AST_MAX_EXTENSION]; /*!< Dialplan: Current extension number */ int priority; /*!< Dialplan: Current extension priority */ char macrocontext[AST_MAX_CONTEXT]; /*!< Macro: Current non-macro context. See app_macro.c */ char macroexten[AST_MAX_EXTENSION]; /*!< Macro: Current non-macro extension. See app_macro.c */ int macropriority; /*!< Macro: Current non-macro priority. See app_macro.c */ char dialcontext[AST_MAX_CONTEXT]; /*!< Dial: Extension context that we were called from */ struct ast_pbx *pbx; /*!< PBX private structure for this channel */ int amaflags; /*!< Set BEFORE PBX is started to determine AMA flags */ struct ast_cdr *cdr; /*!< Call Detail Record */ enum ast_channel_adsicpe adsicpe; /*!< Whether or not ADSI is detected on CPE */ struct tone_zone *zone; /*!< Tone zone as set in indications.conf or in the CHANNEL dialplan function */ struct ast_channel_monitor *monitor; /*!< Channel monitoring */ /*! Track the read/written samples for monitor use */ unsigned long insmpl; unsigned long outsmpl; /* Frames in/out counters. The high bit is a debug mask, so * the counter is only in the remaining bits */ unsigned int fin; unsigned int fout; int hangupcause; /*!< Why is the channel hanged up. See causes.h */ struct varshead varshead; /*!< A linked list for channel variables */ ast_group_t callgroup; /*!< Call group for call pickups */ ast_group_t pickupgroup; /*!< Pickup group - which calls groups can be picked up? */ unsigned int flags; /*!< channel flags of AST_FLAG_ type */ unsigned short transfercapability; /*!< ISDN Transfer Capbility - AST_FLAG_DIGITAL is not enough */ AST_LIST_HEAD_NOLOCK(, ast_frame) readq; int alertpipe[2]; int nativeformats; /*!< Kinds of data this channel can natively handle */ int readformat; /*!< Requested read format */ int writeformat; /*!< Requested write format */ struct ast_trans_pvt *writetrans; /*!< Write translation path */ struct ast_trans_pvt *readtrans; /*!< Read translation path */ int rawreadformat; /*!< Raw read format */ int rawwriteformat; /*!< Raw write format */ struct ast_channel_spy_list *spies; /*!< Chan Spy stuff */ struct ast_channel_whisper_buffer *whisper; /*!< Whisper Paging buffer */ AST_LIST_ENTRY(ast_channel) chan_list; /*!< For easy linking */ struct ast_jb jb; /*!< The jitterbuffer state */ char emulate_dtmf_digit; /*!< Digit being emulated */ unsigned int emulate_dtmf_duration; /*!< Number of ms left to emulate DTMF for */ struct timeval dtmf_tv; /*!< The time that an in process digit began, or the last digit ended */ /*! \brief Data stores on the channel */ AST_LIST_HEAD_NOLOCK(datastores, ast_datastore) datastores;};/*! \brief ast_channel_tech Properties */enum { /*! \brief Channels have this property if they can accept input with jitter; * i.e. most VoIP channels */ AST_CHAN_TP_WANTSJITTER = (1 << 0), /*! \brief Channels have this property if they can create jitter; * i.e. most VoIP channels */ AST_CHAN_TP_CREATESJITTER = (1 << 1),};/*! \brief ast_channel flags */enum { /*! Queue incoming dtmf, to be released when this flag is turned off */ AST_FLAG_DEFER_DTMF = (1 << 1), /*! write should be interrupt generator */ AST_FLAG_WRITE_INT = (1 << 2), /*! a thread is blocking on this channel */ AST_FLAG_BLOCKING = (1 << 3), /*! This is a zombie channel */ AST_FLAG_ZOMBIE = (1 << 4), /*! There is an exception pending */ AST_FLAG_EXCEPTION = (1 << 5), /*! Listening to moh XXX anthm promises me this will disappear XXX */ AST_FLAG_MOH = (1 << 6), /*! This channel is spying on another channel */ AST_FLAG_SPYING = (1 << 7), /*! This channel is in a native bridge */ AST_FLAG_NBRIDGE = (1 << 8), /*! 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 */ AST_FLAG_IN_AUTOLOOP = (1 << 9), /*! This is an outgoing call */ AST_FLAG_OUTGOING = (1 << 10), /*! This channel is being whispered on */ AST_FLAG_WHISPER = (1 << 11), /*! A DTMF_BEGIN frame has been read from this channel, but not yet an END */ AST_FLAG_IN_DTMF = (1 << 12), /*! A DTMF_END was received when not IN_DTMF, so the length of the digit is * currently being emulated */ AST_FLAG_EMULATE_DTMF = (1 << 13), /*! This is set to tell the channel not to generate DTMF begin frames, and * to instead only generate END frames. */ AST_FLAG_END_DTMF_ONLY = (1 << 14),};/*! \brief ast_bridge_config flags */enum { AST_FEATURE_PLAY_WARNING = (1 << 0), AST_FEATURE_REDIRECT = (1 << 1), AST_FEATURE_DISCONNECT = (1 << 2), AST_FEATURE_ATXFER = (1 << 3), AST_FEATURE_AUTOMON = (1 << 4), AST_FEATURE_PARKCALL = (1 << 5),};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; const char *warning_sound; const char *end_sound; const 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;};enum { AST_CDR_TRANSFER = (1 << 0), AST_CDR_FORWARD = (1 << 1), AST_CDR_CALLWAIT = (1 << 2), AST_CDR_CONFERENCE = (1 << 3),};enum { /*! Soft hangup by device */ AST_SOFTHANGUP_DEV = (1 << 0), /*! Soft hangup for async goto */ AST_SOFTHANGUP_ASYNCGOTO = (1 << 1), AST_SOFTHANGUP_SHUTDOWN = (1 << 2), AST_SOFTHANGUP_TIMEOUT = (1 << 3), AST_SOFTHANGUP_APPUNLOAD = (1 << 4), AST_SOFTHANGUP_EXPLICIT = (1 << 5), AST_SOFTHANGUP_UNBRIDGE = (1 << 6),};/*! \brief Channel reload reasons for manager events at load or reload of configuration */enum channelreloadreason { CHANNEL_MODULE_LOAD, CHANNEL_MODULE_RELOAD, CHANNEL_CLI_RELOAD, CHANNEL_MANAGER_RELOAD,};/*! \brief Create a channel datastore structure */struct ast_datastore *ast_channel_datastore_alloc(const struct ast_datastore_info *info, char *uid);/*! \brief Free a channel datastore structure */int ast_channel_datastore_free(struct ast_datastore *datastore);/*! \brief Add a datastore to a channel */int ast_channel_datastore_add(struct ast_channel *chan, struct ast_datastore *datastore);/*! \brief Remove a datastore from a channel */int ast_channel_datastore_remove(struct ast_channel *chan, struct ast_datastore *datastore);/*! \brief Find a datastore on a channel */struct ast_datastore *ast_channel_datastore_find(struct ast_channel *chan, const struct ast_datastore_info *info, 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 \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 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, ...);/*! \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 with payload \param chan channel to queue frame onto \param control type of control frame \return zero on success, 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 \return zero on success, non-zero on 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.*/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 */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 * \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
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -