diff options
author | Mark Spencer <markster@digium.com> | 2001-05-07 00:43:32 +0000 |
---|---|---|
committer | Mark Spencer <markster@digium.com> | 2001-05-07 00:43:32 +0000 |
commit | 48c30eaca2a6dfaedcf92bbfff81b5acea907b73 (patch) | |
tree | 19785e87a52fa74ecc72b19cf04b901d677f228b /include | |
parent | 677e22cd2c3dbe08a8a7ffc652df843677367a7a (diff) |
Version 0.1.8 from FTP
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@314 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'include')
-rwxr-xr-x | include/asterisk/channel.h | 99 | ||||
-rwxr-xr-x | include/asterisk/channel_pvt.h | 10 |
2 files changed, 106 insertions, 3 deletions
diff --git a/include/asterisk/channel.h b/include/asterisk/channel.h index 3f7d5e744..3d0a30277 100755 --- a/include/asterisk/channel.h +++ b/include/asterisk/channel.h @@ -25,6 +25,60 @@ extern "C" { #include <pthread.h> +#ifdef DEBUG_THREADS + +#define TRIES 500 + +#include <errno.h> +#include <string.h> +#include <stdio.h> +#include <unistd.h> + +struct mutex_info { + pthread_mutex_t *mutex; + char *file; + int lineno; + char *func; + struct mutex_info *next; +}; + +static inline int __ast_pthread_mutex_lock(char *filename, int lineno, char *func, pthread_mutex_t *t) { + int res; + int tries = TRIES; + do { + res = pthread_mutex_trylock(t); + /* If we can't run, yield */ + if (res) { + sched_yield(); + usleep(1); + } + } while(res && tries--); + if (res) { + fprintf(stderr, "%s line %d (%s): Error obtaining mutex: %s\n", + filename, lineno, func, strerror(res)); + res = pthread_mutex_lock(t); + fprintf(stderr, "%s line %d (%s): Got it eventually...\n", + filename, lineno, func); + } + return res; +} + +#define ast_pthread_mutex_lock(a) __ast_pthread_mutex_lock(__FILE__, __LINE__, __PRETTY_FUNCTION__, a) + +static inline int __ast_pthread_mutex_unlock(char *filename, int lineno, char *func, pthread_mutex_t *t) { + int res; + res = pthread_mutex_unlock(t); + if (res) + fprintf(stderr, "%s line %d (%s): Error releasing mutex: %s\n", + filename, lineno, func, strerror(res)); + return res; +} +#define ast_pthread_mutex_unlock(a) __ast_pthread_mutex_unlock(__FILE__, __LINE__, __PRETTY_FUNCTION__, a) +#else +#define ast_pthread_mutex_lock pthread_mutex_lock +#define ast_pthread_mutex_unlock pthread_mutex_unlock +#endif + #define AST_CHANNEL_NAME 80 #define AST_CHANNEL_MAX_STACK 32 @@ -33,14 +87,24 @@ extern "C" { /* Max length an extension can be (unique) is this number */ #define AST_MAX_EXTENSION 80 +#define AST_MAX_FDS 4 + struct ast_channel { char name[AST_CHANNEL_NAME]; /* ASCII Description of channel name */ char language[MAX_LANGUAGE]; /* Language requested */ char *type; /* Type of channel */ - int fd; /* File descriptor for channel -- all must have - a file descriptor! */ + int fds[AST_MAX_FDS]; /* File descriptor for channel -- Drivers will poll + on these file descriptors, so at least one must be + non -1. */ + struct ast_channel *bridge; /* Who are we bridged to, if we're bridged */ + 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 */ + int blocking; /* Whether or not we're blocking */ + int softhangup; /* Whether or not we have been hung up */ + int zombie; /* Non-zero if this is a zombie channel */ pthread_t blocker; /* If anyone is blocking, this is them */ pthread_mutex_t lock; /* Lock, can be used to lock a channel for some operations */ char *blockproc; /* Procedure causing blocking */ @@ -49,6 +113,7 @@ struct ast_channel { char *data; /* Data passed to current application */ int exception; /* Has an exception been detected */ + int fdno; /* Which fd had an event detected on */ struct sched_context *sched; /* Schedule context */ int streamid; /* For streaming playback, the schedule ID */ @@ -79,6 +144,11 @@ struct ast_channel { }; +#define AST_CDR_TRANSFER (1 << 0) +#define AST_CDR_FORWARD (1 << 1) +#define AST_CDR_CALLWAIT (1 << 2) +#define AST_CDR_CONFERENCE (1 << 3) + /* Bits 0-15 of state are reserved for the state (up/down) of the line */ #define AST_STATE_DOWN 0 /* Channel is down and available */ @@ -123,6 +193,9 @@ int ast_answer(struct ast_channel *chan); the number of seconds the connect took otherwise. */ int ast_call(struct ast_channel *chan, char *addr, int timeout); +/* Indicate a condition such as AST_CONTROL_BUSY, AST_CONTROL_RINGING, or AST_CONTROL_CONGESTION on a channel */ +int ast_indicate(struct ast_channel *chan, int condition); + /* Misc stuff */ /* Wait for input on a channel for a given # of milliseconds (<0 for indefinite). @@ -180,6 +253,28 @@ int ast_channel_make_compatible(struct ast_channel *c0, struct ast_channel *c1); *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); +/* 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); + +/* Give a name to a state */ +char *ast_state2str(int state); + +/* 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 */ + +/* Set an option on a channel (see frame.h), optionally blocking awaiting the reply */ +int ast_channel_setoption(struct ast_channel *channel, int option, void *data, int datalen, int block); + +/* Query the value of an option, optionally blocking until a reply is received */ +struct ast_frame *ast_channel_queryoption(struct ast_channel *channel, int option, void *data, int *datalen, int block); + #ifdef DO_CRASH #define CRASH do { *((int *)0) = 0; } while(0) #else diff --git a/include/asterisk/channel_pvt.h b/include/asterisk/channel_pvt.h index 7fc464ebb..a8a2e654d 100755 --- a/include/asterisk/channel_pvt.h +++ b/include/asterisk/channel_pvt.h @@ -23,7 +23,7 @@ extern "C" { struct ast_channel_pvt { /* Private data used by channel backend */ - void *pvt; + void *pvt; /* Write translation path */ struct ast_trans_pvt *writetrans; /* Read translation path */ @@ -51,6 +51,14 @@ struct ast_channel_pvt { struct ast_frame * (*exception)(struct ast_channel *chan); /* Bridge two channels of the same type together */ int (*bridge)(struct ast_channel *c0, struct ast_channel *c1, int flags, struct ast_frame **fo, struct ast_channel **rc); + /* Indicate a particular condition (e.g. AST_CONTROL_BUSY or AST_CONTROL_RINGING or AST_CONTROL_CONGESTION */ + int (*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 (*fixup)(struct ast_channel *oldchan, struct ast_channel *newchan); + /* Set a given option */ + int (*setoption)(struct ast_channel *chan, int option, void *data, int datalen); + /* Query a given option */ + int (*queryoption)(struct ast_channel *chan, int option, void *data, int *datalen); }; /* Create a channel structure */ |