[asterisk-commits] kpfleming: trunk r135680 - in /trunk: apps/ channels/ funcs/ include/asterisk...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Tue Aug 5 11:56:16 CDT 2008
Author: kpfleming
Date: Tue Aug 5 11:56:11 2008
New Revision: 135680
URL: http://svn.digium.com/view/asterisk?view=rev&rev=135680
Log:
make datastore creation and destruction a generic API since it is not really channel related, and add the ability to add/find/remove datastores to manager sessions
Added:
trunk/include/asterisk/datastore.h
- copied, changed from r135647, trunk/include/asterisk/channel.h
trunk/main/datastore.c
- copied, changed from r135647, trunk/main/channel.c
Modified:
trunk/apps/app_chanspy.c
trunk/apps/app_dial.c
trunk/apps/app_queue.c
trunk/apps/app_speech_utils.c
trunk/apps/app_stack.c
trunk/channels/chan_iax2.c
trunk/funcs/func_enum.c
trunk/funcs/func_global.c
trunk/funcs/func_lock.c
trunk/funcs/func_odbc.c
trunk/funcs/func_speex.c
trunk/funcs/func_volume.c
trunk/include/asterisk/channel.h
trunk/include/asterisk/manager.h
trunk/main/Makefile
trunk/main/audiohook.c
trunk/main/channel.c
trunk/main/manager.c
trunk/main/pbx.c
trunk/pbx/pbx_dundi.c
trunk/pbx/pbx_lua.c
trunk/res/res_agi.c
trunk/res/res_smdi.c
Modified: trunk/apps/app_chanspy.c
URL: http://svn.digium.com/view/asterisk/trunk/apps/app_chanspy.c?view=diff&rev=135680&r1=135679&r2=135680
==============================================================================
--- trunk/apps/app_chanspy.c (original)
+++ trunk/apps/app_chanspy.c Tue Aug 5 11:56:11 2008
@@ -560,7 +560,7 @@
/* chanspy_ds->chan is NULL after this call */
chanspy_ds_destroy(datastore->data);
datastore->data = NULL;
- ast_channel_datastore_free(datastore);
+ ast_datastore_free(datastore);
}
ast_channel_unlock(chan);
}
@@ -576,7 +576,7 @@
ast_mutex_lock(&chanspy_ds->lock);
- if (!(datastore = ast_channel_datastore_alloc(&chanspy_ds_info, chanspy_ds->unique_id))) {
+ if (!(datastore = ast_datastore_alloc(&chanspy_ds_info, chanspy_ds->unique_id))) {
ast_mutex_unlock(&chanspy_ds->lock);
chanspy_ds = chanspy_ds_free(chanspy_ds);
ast_channel_unlock(chan);
Modified: trunk/apps/app_dial.c
URL: http://svn.digium.com/view/asterisk/trunk/apps/app_dial.c?view=diff&rev=135680&r1=135679&r2=135680
==============================================================================
--- trunk/apps/app_dial.c (original)
+++ trunk/apps/app_dial.c Tue Aug 5 11:56:11 2008
@@ -1354,7 +1354,7 @@
ast_copy_flags64(peerflags, &opts, OPT_DTMF_EXIT | OPT_GO_ON | OPT_ORIGINAL_CLID | OPT_CALLER_HANGUP | OPT_IGNORE_FORWARDING);
/* Create datastore for channel dial features for caller */
- if (!(ds_caller_features = ast_channel_datastore_alloc(&dial_features_info, NULL))) {
+ if (!(ds_caller_features = ast_datastore_alloc(&dial_features_info, NULL))) {
ast_log(LOG_WARNING, "Unable to create channel datastore for dial features. Aborting!\n");
goto out;
}
@@ -1416,7 +1416,7 @@
if (datastore)
dialed_interfaces = datastore->data;
else {
- if (!(datastore = ast_channel_datastore_alloc(&dialed_interface_info, NULL))) {
+ if (!(datastore = ast_datastore_alloc(&dialed_interface_info, NULL))) {
ast_log(LOG_WARNING, "Unable to create channel datastore for dialed interfaces. Aborting!\n");
ast_free(tmp);
goto out;
@@ -1522,7 +1522,7 @@
ast_copy_string(tc->exten, chan->exten, sizeof(tc->exten));
/* Save callee features */
- if (!(ds_callee_features = ast_channel_datastore_alloc(&dial_features_info, NULL))) {
+ if (!(ds_callee_features = ast_datastore_alloc(&dial_features_info, NULL))) {
ast_log(LOG_WARNING, "Unable to create channel datastore for dial features. Aborting!\n");
ast_free(tmp);
goto out;
@@ -1624,7 +1624,7 @@
* datastore again, causing a crash
*/
if (!ast_channel_datastore_remove(chan, datastore))
- ast_channel_datastore_free(datastore);
+ ast_datastore_free(datastore);
if (!peer) {
if (result) {
res = result;
Modified: trunk/apps/app_queue.c
URL: http://svn.digium.com/view/asterisk/trunk/apps/app_queue.c?view=diff&rev=135680&r1=135679&r2=135680
==============================================================================
--- trunk/apps/app_queue.c (original)
+++ trunk/apps/app_queue.c Tue Aug 5 11:56:11 2008
@@ -3120,7 +3120,7 @@
}
ast_channel_datastore_remove(new_chan, datastore);
- ast_channel_datastore_free(datastore);
+ ast_datastore_free(datastore);
}
/*! \brief mechanism to tell if a queue caller was atxferred by a queue member.
@@ -3147,7 +3147,7 @@
}
ast_channel_lock(qe->chan);
- if (!(ds = ast_channel_datastore_alloc(&queue_transfer_info, NULL))) {
+ if (!(ds = ast_datastore_alloc(&queue_transfer_info, NULL))) {
ast_channel_unlock(qe->chan);
ast_log(LOG_WARNING, "Unable to create transfer datastore. queue_log will not show attended transfer\n");
return;
@@ -3321,7 +3321,7 @@
goto out;
}
if (!datastore) {
- if (!(datastore = ast_channel_datastore_alloc(&dialed_interface_info, NULL))) {
+ if (!(datastore = ast_datastore_alloc(&dialed_interface_info, NULL))) {
ao2_ref(cur, -1);
ao2_unlock(qe->parent);
if (use_weight)
@@ -3423,7 +3423,7 @@
* datastore again, causing a crash
*/
if (datastore && !ast_channel_datastore_remove(qe->chan, datastore)) {
- ast_channel_datastore_free(datastore);
+ ast_datastore_free(datastore);
}
ao2_lock(qe->parent);
if (qe->parent->strategy == QUEUE_STRATEGY_RRMEMORY) {
@@ -3845,7 +3845,7 @@
transfer_ds = ast_channel_datastore_find(qe->chan, &queue_transfer_info, NULL);
if (transfer_ds) {
ast_channel_datastore_remove(qe->chan, transfer_ds);
- ast_channel_datastore_free(transfer_ds);
+ ast_datastore_free(transfer_ds);
}
ast_channel_unlock(qe->chan);
}
Modified: trunk/apps/app_speech_utils.c
URL: http://svn.digium.com/view/asterisk/trunk/apps/app_speech_utils.c?view=diff&rev=135680&r1=135679&r2=135680
==============================================================================
--- trunk/apps/app_speech_utils.c (original)
+++ trunk/apps/app_speech_utils.c Tue Aug 5 11:56:11 2008
@@ -364,7 +364,7 @@
return 0;
}
- datastore = ast_channel_datastore_alloc(&speech_datastore, NULL);
+ datastore = ast_datastore_alloc(&speech_datastore, NULL);
if (datastore == NULL) {
ast_speech_destroy(speech);
pbx_builtin_setvar_helper(chan, "ERROR", "1");
Modified: trunk/apps/app_stack.c
URL: http://svn.digium.com/view/asterisk/trunk/apps/app_stack.c?view=diff&rev=135680&r1=135679&r2=135680
==============================================================================
--- trunk/apps/app_stack.c (original)
+++ trunk/apps/app_stack.c Tue Aug 5 11:56:11 2008
@@ -242,7 +242,7 @@
if (!stack_store) {
ast_debug(1, "Channel %s has no datastore, so we're allocating one.\n", chan->name);
- stack_store = ast_channel_datastore_alloc(&stack_info, NULL);
+ stack_store = ast_datastore_alloc(&stack_info, NULL);
if (!stack_store) {
ast_log(LOG_ERROR, "Unable to allocate new datastore. Gosub will fail.\n");
return -1;
@@ -251,7 +251,7 @@
oldlist = ast_calloc(1, sizeof(*oldlist));
if (!oldlist) {
ast_log(LOG_ERROR, "Unable to allocate datastore list head. Gosub will fail.\n");
- ast_channel_datastore_free(stack_store);
+ ast_datastore_free(stack_store);
return -1;
}
Modified: trunk/channels/chan_iax2.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_iax2.c?view=diff&rev=135680&r1=135679&r2=135680
==============================================================================
--- trunk/channels/chan_iax2.c (original)
+++ trunk/channels/chan_iax2.c Tue Aug 5 11:56:11 2008
@@ -6474,7 +6474,7 @@
struct ast_variable *var, *prev = NULL;
AST_LIST_HEAD(, ast_var_t) *varlist;
varlist = ast_calloc(1, sizeof(*varlist));
- variablestore = ast_channel_datastore_alloc(&iax2_variable_datastore_info, NULL);
+ variablestore = ast_datastore_alloc(&iax2_variable_datastore_info, NULL);
if (variablestore && varlist && p->owner) {
variablestore->data = varlist;
variablestore->inheritance = DATASTORE_INHERIT_FOREVER;
@@ -6499,7 +6499,7 @@
if (p->owner)
ast_log(LOG_ERROR, "Memory allocation error while processing IAX2 variables\n");
if (variablestore)
- ast_channel_datastore_free(variablestore);
+ ast_datastore_free(variablestore);
if (varlist)
ast_free(varlist);
}
@@ -7967,7 +7967,7 @@
struct ast_var_t *var;
if (!variablestore) {
- variablestore = ast_channel_datastore_alloc(&iax2_variable_datastore_info, NULL);
+ variablestore = ast_datastore_alloc(&iax2_variable_datastore_info, NULL);
if (!variablestore) {
ast_log(LOG_ERROR, "Memory allocation error\n");
return -1;
@@ -8362,7 +8362,7 @@
struct ast_variable *var, *prev = NULL;
AST_LIST_HEAD(, ast_var_t) *varlist;
varlist = ast_calloc(1, sizeof(*varlist));
- variablestore = ast_channel_datastore_alloc(&iax2_variable_datastore_info, NULL);
+ variablestore = ast_datastore_alloc(&iax2_variable_datastore_info, NULL);
if (variablestore && varlist) {
variablestore->data = varlist;
variablestore->inheritance = DATASTORE_INHERIT_FOREVER;
@@ -8386,7 +8386,7 @@
} else {
ast_log(LOG_ERROR, "Memory allocation error while processing IAX2 variables\n");
if (variablestore)
- ast_channel_datastore_free(variablestore);
+ ast_datastore_free(variablestore);
if (varlist)
ast_free(varlist);
}
@@ -9139,7 +9139,7 @@
struct ast_variable *var, *prev = NULL;
AST_LIST_HEAD(, ast_var_t) *varlist;
varlist = ast_calloc(1, sizeof(*varlist));
- variablestore = ast_channel_datastore_alloc(&iax2_variable_datastore_info, NULL);
+ variablestore = ast_datastore_alloc(&iax2_variable_datastore_info, NULL);
if (variablestore && varlist) {
variablestore->data = varlist;
variablestore->inheritance = DATASTORE_INHERIT_FOREVER;
@@ -9163,7 +9163,7 @@
} else {
ast_log(LOG_ERROR, "Memory allocation error while processing IAX2 variables\n");
if (variablestore)
- ast_channel_datastore_free(variablestore);
+ ast_datastore_free(variablestore);
if (varlist)
ast_free(varlist);
}
@@ -9203,7 +9203,7 @@
struct ast_variable *var, *prev = NULL;
AST_LIST_HEAD(, ast_var_t) *varlist;
varlist = ast_calloc(1, sizeof(*varlist));
- variablestore = ast_channel_datastore_alloc(&iax2_variable_datastore_info, NULL);
+ variablestore = ast_datastore_alloc(&iax2_variable_datastore_info, NULL);
if (variablestore && varlist) {
variablestore->data = varlist;
variablestore->inheritance = DATASTORE_INHERIT_FOREVER;
@@ -9227,7 +9227,7 @@
} else {
ast_log(LOG_ERROR, "Memory allocation error while processing IAX2 variables\n");
if (variablestore)
- ast_channel_datastore_free(variablestore);
+ ast_datastore_free(variablestore);
if (varlist)
ast_free(varlist);
}
Modified: trunk/funcs/func_enum.c
URL: http://svn.digium.com/view/asterisk/trunk/funcs/func_enum.c?view=diff&rev=135680&r1=135679&r2=135680
==============================================================================
--- trunk/funcs/func_enum.c (original)
+++ trunk/funcs/func_enum.c Tue Aug 5 11:56:11 2008
@@ -189,7 +189,7 @@
snprintf(buf, len, "%u", erds->id);
- if (!(datastore = ast_channel_datastore_alloc(&enum_result_datastore_info, buf))) {
+ if (!(datastore = ast_datastore_alloc(&enum_result_datastore_info, buf))) {
ast_free(erds->context);
ast_free(erds);
goto finish;
Modified: trunk/funcs/func_global.c
URL: http://svn.digium.com/view/asterisk/trunk/funcs/func_global.c?view=diff&rev=135680&r1=135679&r2=135680
==============================================================================
--- trunk/funcs/func_global.c (original)
+++ trunk/funcs/func_global.c Tue Aug 5 11:56:11 2008
@@ -158,7 +158,7 @@
ast_channel_lock(chan);
if (!(varstore = ast_channel_datastore_find(chan, &shared_variable_info, NULL))) {
- if (!(varstore = ast_channel_datastore_alloc(&shared_variable_info, NULL))) {
+ if (!(varstore = ast_datastore_alloc(&shared_variable_info, NULL))) {
ast_log(LOG_ERROR, "Unable to allocate new datastore. Shared variable not set.\n");
ast_channel_unlock(chan);
return -1;
@@ -166,7 +166,7 @@
if (!(varshead = ast_calloc(1, sizeof(*varshead)))) {
ast_log(LOG_ERROR, "Unable to allocate variable structure. Shared variable not set.\n");
- ast_channel_datastore_free(varstore);
+ ast_datastore_free(varstore);
ast_channel_unlock(chan);
return -1;
}
Modified: trunk/funcs/func_lock.c
URL: http://svn.digium.com/view/asterisk/trunk/funcs/func_lock.c?view=diff&rev=135680&r1=135679&r2=135680
==============================================================================
--- trunk/funcs/func_lock.c (original)
+++ trunk/funcs/func_lock.c Tue Aug 5 11:56:11 2008
@@ -96,7 +96,7 @@
if (!lock_store) {
ast_debug(1, "Channel %s has no lock datastore, so we're allocating one.\n", chan->name);
- lock_store = ast_channel_datastore_alloc(&lock_info, NULL);
+ lock_store = ast_datastore_alloc(&lock_info, NULL);
if (!lock_store) {
ast_log(LOG_ERROR, "Unable to allocate new datastore. No locks will be obtained.\n");
return -1;
@@ -105,7 +105,7 @@
list = ast_calloc(1, sizeof(*list));
if (!list) {
ast_log(LOG_ERROR, "Unable to allocate datastore list head. %sLOCK will fail.\n", try ? "TRY" : "");
- ast_channel_datastore_free(lock_store);
+ ast_datastore_free(lock_store);
return -1;
}
Modified: trunk/funcs/func_odbc.c
URL: http://svn.digium.com/view/asterisk/trunk/funcs/func_odbc.c?view=diff&rev=135680&r1=135679&r2=135680
==============================================================================
--- trunk/funcs/func_odbc.c (original)
+++ trunk/funcs/func_odbc.c Tue Aug 5 11:56:11 2008
@@ -480,7 +480,7 @@
struct ast_datastore *odbc_store;
uid = ast_atomic_fetchadd_int(&resultcount, +1) + 1;
snprintf(buf, len, "%d", uid);
- odbc_store = ast_channel_datastore_alloc(&odbc_info, buf);
+ odbc_store = ast_datastore_alloc(&odbc_info, buf);
if (!odbc_store) {
ast_log(LOG_ERROR, "Rows retrieved, but unable to store it in the channel. Results fail.\n");
odbc_datastore_free(resultset);
@@ -550,7 +550,7 @@
if (!row) {
/* Cleanup datastore */
ast_channel_datastore_remove(chan, store);
- ast_channel_datastore_free(store);
+ ast_datastore_free(store);
return -1;
}
pbx_builtin_setvar_helper(chan, "~ODBCFIELDS~", resultset->names);
@@ -584,7 +584,7 @@
if (!store) /* Already freed; no big deal. */
return 0;
ast_channel_datastore_remove(chan, store);
- ast_channel_datastore_free(store);
+ ast_datastore_free(store);
return 0;
}
Modified: trunk/funcs/func_speex.c
URL: http://svn.digium.com/view/asterisk/trunk/funcs/func_speex.c?view=diff&rev=135680&r1=135679&r2=135680
==============================================================================
--- trunk/funcs/func_speex.c (original)
+++ trunk/funcs/func_speex.c Tue Aug 5 11:56:11 2008
@@ -151,12 +151,12 @@
if (!(datastore = ast_channel_datastore_find(chan, &speex_datastore, NULL))) {
ast_channel_unlock(chan);
- if (!(datastore = ast_channel_datastore_alloc(&speex_datastore, NULL))) {
+ if (!(datastore = ast_datastore_alloc(&speex_datastore, NULL))) {
return 0;
}
if (!(si = ast_calloc(1, sizeof(*si)))) {
- ast_channel_datastore_free(datastore);
+ ast_datastore_free(datastore);
return 0;
}
@@ -177,7 +177,7 @@
ast_log(LOG_ERROR, "Invalid argument provided to the %s function\n", cmd);
if (is_new) {
- ast_channel_datastore_free(datastore);
+ ast_datastore_free(datastore);
return -1;
}
}
@@ -237,7 +237,7 @@
ast_audiohook_detach(&si->audiohook);
}
- ast_channel_datastore_free(datastore);
+ ast_datastore_free(datastore);
}
if (is_new) {
Modified: trunk/funcs/func_volume.c
URL: http://svn.digium.com/view/asterisk/trunk/funcs/func_volume.c?view=diff&rev=135680&r1=135679&r2=135680
==============================================================================
--- trunk/funcs/func_volume.c (original)
+++ trunk/funcs/func_volume.c Tue Aug 5 11:56:11 2008
@@ -106,10 +106,10 @@
if (!(datastore = ast_channel_datastore_find(chan, &volume_datastore, NULL))) {
/* Allocate a new datastore to hold the reference to this volume and audiohook information */
- if (!(datastore = ast_channel_datastore_alloc(&volume_datastore, NULL)))
+ if (!(datastore = ast_datastore_alloc(&volume_datastore, NULL)))
return 0;
if (!(vi = ast_calloc(1, sizeof(*vi)))) {
- ast_channel_datastore_free(datastore);
+ ast_datastore_free(datastore);
return 0;
}
ast_audiohook_init(&vi->audiohook, AST_AUDIOHOOK_TYPE_MANIPULATE, "Volume");
Modified: trunk/include/asterisk/channel.h
URL: http://svn.digium.com/view/asterisk/trunk/include/asterisk/channel.h?view=diff&rev=135680&r1=135679&r2=135680
==============================================================================
--- trunk/include/asterisk/channel.h (original)
+++ trunk/include/asterisk/channel.h Tue Aug 5 11:56:11 2008
@@ -150,8 +150,7 @@
#include "asterisk/utils.h"
#include "asterisk/linkedlists.h"
#include "asterisk/stringfields.h"
-
-#define DATASTORE_INHERIT_FOREVER INT_MAX
+#include "asterisk/datastore.h"
#define AST_MAX_FDS 10
/*
@@ -184,37 +183,6 @@
int (*generate)(struct ast_channel *chan, void *data, int len, int samples);
/*! This gets called when DTMF_END frames are read from the channel */
void (*digit)(struct ast_channel *chan, char digit);
-};
-
-/*! \brief Structure for a data store type */
-struct ast_datastore_info {
- const char *type; /*!< Type of data store */
- void *(*duplicate)(void *data); /*!< Duplicate item data (used for inheritance) */
- void (*destroy)(void *data); /*!< Destroy function */
- /*!
- * \brief Fix up channel references
- *
- * \arg data The datastore data
- * \arg old_chan The old channel owning the datastore
- * \arg new_chan The new channel owning the datastore
- *
- * This is exactly like the fixup callback of the channel technology interface.
- * It allows a datastore to fix any pointers it saved to the owning channel
- * in case that the owning channel has changed. Generally, this would happen
- * when the datastore is set to be inherited, and a masquerade occurs.
- *
- * \return nothing.
- */
- void (*chan_fixup)(void *data, struct ast_channel *old_chan, struct ast_channel *new_chan);
-};
-
-/*! \brief Structure for a channel data store */
-struct ast_datastore {
- const char *uid; /*!< Unique data store identifier */
- void *data; /*!< Contained data */
- const struct ast_datastore_info *info; /*!< Data store type information */
- unsigned int inheritance; /*!< Number of levels this item will continue to be inherited */
- AST_LIST_ENTRY(ast_datastore) entry; /*!< Used for easy linking */
};
/*! \brief Structure for all kinds of caller ID identifications.
@@ -653,16 +621,24 @@
};
/*!
- * \brief Create a channel datastore structure
- *
* \note None of the datastore API calls lock the ast_channel they are using.
* So, the channel should be locked before calling the functions that
* take a channel argument.
*/
-struct ast_datastore *ast_channel_datastore_alloc(const struct ast_datastore_info *info, const char *uid);
-
-/*! \brief Free a channel datastore structure */
-int ast_channel_datastore_free(struct ast_datastore *datastore);
+
+/*!
+ * \brief Create a channel data store object
+ * \deprecated You should use the ast_datastore_alloc() generic function instead.
+ */
+struct ast_datastore *ast_channel_datastore_alloc(const struct ast_datastore_info *info, const char *uid)
+ __attribute__ ((deprecated));
+
+/*!
+ * \brief Free a channel data store object
+ * \deprecated You should use the ast_datastore_free() generic function instead.
+ */
+int ast_channel_datastore_free(struct ast_datastore *datastore)
+ __attribute__ ((deprecated));
/*! \brief Inherit datastores from a parent to a child. */
int ast_channel_datastore_inherit(struct ast_channel *from, struct ast_channel *to);
@@ -695,6 +671,9 @@
*
* \note The datastore returned from this function must not be used if the
* reference to the channel is released.
+ *
+ * \retval pointer to the datastore if found
+ * \retval NULL if not found
*/
struct ast_datastore *ast_channel_datastore_find(struct ast_channel *chan, const struct ast_datastore_info *info, const char *uid);
Copied: trunk/include/asterisk/datastore.h (from r135647, trunk/include/asterisk/channel.h)
URL: http://svn.digium.com/view/asterisk/trunk/include/asterisk/datastore.h?view=diff&rev=135680&p1=trunk/include/asterisk/channel.h&r1=135647&p2=trunk/include/asterisk/datastore.h&r2=135680
==============================================================================
--- trunk/include/asterisk/channel.h (original)
+++ trunk/include/asterisk/datastore.h Tue Aug 5 11:56:11 2008
@@ -1,9 +1,7 @@
/*
* Asterisk -- An open source telephony toolkit.
*
- * Copyright (C) 1999 - 2006, Digium, Inc.
- *
- * Mark Spencer <markster at digium.com>
+ * Copyright (C) 2007 - 2008, Digium, Inc.
*
* See http://www.asterisk.org for more information about
* the Asterisk project. Please do not directly contact
@@ -17,180 +15,26 @@
*/
/*! \file
- * \brief General Asterisk PBX channel definitions.
- * \par See also:
- * \arg \ref Def_Channel
- * \arg \ref channel_drivers
+ * \brief Asterisk datastore objects
*/
-/*! \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, DAHDI, 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
- \arg \ref Def_Bridge
-
-*/
-/*! \page Def_Bridge Asterisk Channel Bridges
-
- In Asterisk, there's several media bridges.
-
- The Core bridge handles two channels (a "phone call") and bridge
- them together.
-
- The conference bridge (meetme) handles several channels simultaneously
- with the support of an external timer (DAHDI timer). This is used
- not only by the Conference application (meetme) but also by the
- page application and the SLA system introduced in 1.4.
- The conference bridge does not handle video.
-
- When two channels of the same type connect, the channel driver
- or the media subsystem used by the channel driver (i.e. RTP)
- can create a native bridge without sending media through the
- core.
-
- Native briding can be disabled by a number of reasons,
- like DTMF being needed by the core or codecs being incompatible
- so a transcoding module is needed.
-
-References:
- \li \see ast_channel_early_bridge()
- \li \see ast_channel_bridge()
- \li \see app_meetme.c
- \li \ref AstRTPbridge
- \li \see ast_rtp_bridge()
- \li \ref Def_Channel
-*/
-
-/*! \page AstFileDesc File descriptors
- Asterisk File descriptors are connected to each channel (see \ref Def_Channel)
- in the \ref ast_channel structure.
-*/
-
-#ifndef _ASTERISK_CHANNEL_H
-#define _ASTERISK_CHANNEL_H
-
-#include "asterisk/abstract_jb.h"
-
-#ifdef HAVE_SYS_POLL_H
-#include <sys/poll.h>
-#else
-#include "asterisk/poll-compat.h"
-#endif
+#ifndef _ASTERISK_DATASTORE_H
+#define _ASTERISK_DATASTORE_H
#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/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"
#define DATASTORE_INHERIT_FOREVER INT_MAX
-#define AST_MAX_FDS 10
-/*
- * 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;
-
-/*! \todo Add an explanation of an Asterisk generator
-*/
-struct ast_generator {
- void *(*alloc)(struct ast_channel *chan, void *params);
- void (*release)(struct ast_channel *chan, void *data);
- /*! This function gets called with the channel unlocked, but is called in
- * the context of the channel thread so we know the channel is not going
- * to disappear. This callback is responsible for locking the channel as
- * necessary. */
- int (*generate)(struct ast_channel *chan, void *data, int len, int samples);
- /*! This gets called when DTMF_END frames are read from the channel */
- void (*digit)(struct ast_channel *chan, char digit);
-};
-
/*! \brief Structure for a data store type */
struct ast_datastore_info {
- const char *type; /*!< Type of data store */
- void *(*duplicate)(void *data); /*!< Duplicate item data (used for inheritance) */
- void (*destroy)(void *data); /*!< Destroy function */
+ const char *type; /*!< Type of data store */
+ void *(*duplicate)(void *data); /*!< Duplicate item data (used for inheritance) */
+ void (*destroy)(void *data); /*!< Destroy function */
+
/*!
* \brief Fix up channel references
*
@@ -208,1447 +52,27 @@
void (*chan_fixup)(void *data, struct ast_channel *old_chan, struct ast_channel *new_chan);
};
-/*! \brief Structure for a channel data store */
+/*! \brief Structure for a data store object */
struct ast_datastore {
- const char *uid; /*!< Unique data store identifier */
- void *data; /*!< Contained data */
+ const char *uid; /*!< Unique data store identifier */
+ void *data; /*!< Contained data */
const struct ast_datastore_info *info; /*!< Data store type information */
- unsigned int inheritance; /*!< Number of levels this item will continue to be inherited */
- 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.
- *
- * SIP and IAX2 has utf8 encoded Unicode caller ID names.
- * In some cases, we also have an alternative (RPID) E.164 number that can be used
- * as caller ID on numeric E.164 phone networks (DAHDI or SIP/IAX2 to pstn gateway).
- *
- * \todo Implement settings for transliteration between UTF8 caller ID names in
- * to Ascii Caller ID's (DAHDI). Östen Åsklund might be transliterated into
- * Osten Asklund or Oesten Aasklund depending upon language and person...
- * We need automatic routines for incoming calls and static settings for
- * our own accounts.
- */
-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 (ASCII) */
- 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_dahdi.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
- *
- * \note The channel is not locked when this function gets called.
- */
- int (* const send_digit_begin)(struct ast_channel *chan, char digit);
-
- /*!
- * \brief Stop sending a literal DTMF digit
- *
- * \note The channel is not locked when this function gets called.
- */
- 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 Bridge two channels of the same type together (early) */
- enum ast_bridge_result (* const early_bridge)(struct ast_channel *c0, struct ast_channel *c1);
-
- /*! \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 Write a text frame, in standard format */
- int (* const write_text)(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, const 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, const char *function, char *data, const char *value);
-
- /*! \brief Retrieve base channel (agent and local) */
- struct ast_channel* (* get_base_channel)(struct ast_channel *chan);
-
- /*! \brief Set base channel (agent and local) */
- int (* set_base_channel)(struct ast_channel *chan, struct ast_channel *base);
-
- /*! \brief Get the unique identifier for the PVT, i.e. SIP call-ID for SIP */
- const char * (* get_pvt_uniqueid)(struct ast_channel *chan);
-};
-
-struct ast_epoll_data;
-
-/*!
- * The high bit of the frame count is used as a debug marker, so
- * increments of the counters must be done with care.
- * Please use c->fin = FRAMECOUNT_INC(c->fin) and the same for c->fout.
- */
-#define DEBUGCHAN_FLAG 0x80000000
-
-/* XXX not ideal to evaluate x twice... */
-#define FRAMECOUNT_INC(x) ( ((x) & DEBUGCHAN_FLAG) | (((x)+1) & ~DEBUGCHAN_FLAG) )
-
-/*!
- * The current value of the debug flags is stored in the two
- * variables global_fin and global_fout (declared in main/channel.c)
- */
-extern unsigned long global_fin, global_fout;
-
-enum ast_channel_adsicpe {
- AST_ADSI_UNKNOWN,
- AST_ADSI_AVAILABLE,
- AST_ADSI_UNAVAILABLE,
- AST_ADSI_OFFHOOKONLY,
+ unsigned int inheritance; /*!< Number of levels this item will continue to be inherited */
+ AST_LIST_ENTRY(ast_datastore) entry; /*!< Used for easy linking */
};
/*!
- * \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
+ * \brief Create a data store object
*/
-enum ast_channel_state {
- AST_STATE_DOWN, /*!< Channel is down and available */
- AST_STATE_RESERVED, /*!< Channel is down, but reserved */
- AST_STATE_OFFHOOK, /*!< Channel is off hook */
- AST_STATE_DIALING, /*!< Digits (or equivalent) have been dialed */
- AST_STATE_RING, /*!< Line is ringing */
- AST_STATE_RINGING, /*!< Remote end is ringing */
- AST_STATE_UP, /*!< Line is up */
- AST_STATE_BUSY, /*!< Line is busy */
- AST_STATE_DIALING_OFFHOOK, /*!< Digits (or equivalent) have been dialed while offhook */
- AST_STATE_PRERING, /*!< Channel has detected an incoming call and is waiting for ring */
-
- AST_STATE_MUTE = (1 << 16), /*!< Do not transmit voice data */
-};
+struct ast_datastore *ast_datastore_alloc(const struct ast_datastore_info *info, const char *uid);
/*!
- * \brief Possible T38 states on channels
+ * \brief Free a data store object
*/
-enum ast_t38_state {
- T38_STATE_UNAVAILABLE, /*!< T38 is unavailable on this channel or disabled by configuration */
- T38_STATE_UNKNOWN, /*!< The channel supports T38 but the current status is unknown */
- T38_STATE_NEGOTIATING, /*!< T38 is being negotiated */
- T38_STATE_REJECTED, /*!< Remote side has rejected our offer */
- T38_STATE_NEGOTIATED, /*!< T38 established */
-};
-
-/*! \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
- *
- * \note When adding fields to this structure, it is important to add the field
- * 'in position' with like-aligned fields, so as to keep the compiler from
- * having to add padding to align fields. The structure's fields are sorted
- * in this order: pointers, structures, long, int/enum, short, char. This
- * is especially important on 64-bit architectures, where mixing 4-byte
- * and 8-byte fields causes 4 bytes of padding to be added before many
- * 8-byte fields.
- */
-
-struct ast_channel {
- const struct ast_channel_tech *tech; /*!< Technology (point to channel driver) */
- void *tech_pvt; /*!< Private data used by the technology driver */
- void *music_state; /*!< Music State*/
- void *generatordata; /*!< Current generator data if there is any */
- struct ast_generator *generator; /*!< Current active data generator */
- struct ast_channel *_bridge; /*!< 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 *masq; /*!< Channel that will masquerade as us */
- struct ast_channel *masqr; /*!< Who we are masquerading as */
- const char *blockproc; /*!< Procedure causing blocking */
- const char *appl; /*!< Current application */
- const char *data; /*!< Data passed to current application */
- struct sched_context *sched; /*!< Schedule context */
- struct ast_filestream *stream; /*!< Stream itself. */
- struct ast_filestream *vstream; /*!< Video Stream itself. */
- int (*timingfunc)(const void *data);
- void *timingdata;
- struct ast_pbx *pbx; /*!< PBX private structure for this channel */
- struct ast_trans_pvt *writetrans; /*!< Write translation path */
- struct ast_trans_pvt *readtrans; /*!< Read translation path */
- struct ast_audiohook_list *audiohooks;
- struct ast_cdr *cdr; /*!< Call Detail Record */
- struct ind_tone_zone *zone; /*!< Tone zone as set in indications.conf or
- in the CHANNEL dialplan function */
- struct ast_channel_monitor *monitor; /*!< Channel monitoring */
[... 6745 lines stripped ...]
More information about the asterisk-commits
mailing list