[svn-commits] dvossel: branch dvossel/awesomehooks r287550 - in /team/dvossel/awesomehooks:...
SVN commits to the Digium repositories
svn-commits at lists.digium.com
Mon Sep 20 09:07:30 CDT 2010
Author: dvossel
Date: Mon Sep 20 09:07:25 2010
New Revision: 287550
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=287550
Log:
sigh... AwesomeHooks are now down graded to just being FrameHooks :(
Added:
team/dvossel/awesomehooks/funcs/func_frame_trace.c
- copied, changed from r287549, team/dvossel/awesomehooks/funcs/func_awesome_trace.c
team/dvossel/awesomehooks/include/asterisk/framehook.h
- copied, changed from r287549, team/dvossel/awesomehooks/include/asterisk/awesomehook.h
team/dvossel/awesomehooks/main/framehook.c
- copied, changed from r287549, team/dvossel/awesomehooks/main/awesomehook.c
Removed:
team/dvossel/awesomehooks/funcs/func_awesome_trace.c
team/dvossel/awesomehooks/include/asterisk/awesomehook.h
team/dvossel/awesomehooks/main/awesomehook.c
Modified:
team/dvossel/awesomehooks/include/asterisk/channel.h
team/dvossel/awesomehooks/main/channel.c
Copied: team/dvossel/awesomehooks/funcs/func_frame_trace.c (from r287549, team/dvossel/awesomehooks/funcs/func_awesome_trace.c)
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/awesomehooks/funcs/func_frame_trace.c?view=diff&rev=287550&p1=team/dvossel/awesomehooks/funcs/func_awesome_trace.c&r1=287549&p2=team/dvossel/awesomehooks/funcs/func_frame_trace.c&r2=287550
==============================================================================
--- team/dvossel/awesomehooks/funcs/func_awesome_trace.c (original)
+++ team/dvossel/awesomehooks/funcs/func_frame_trace.c Mon Sep 20 09:07:25 2010
@@ -32,10 +32,10 @@
#include "asterisk/module.h"
#include "asterisk/channel.h"
#include "asterisk/pbx.h"
-#include "asterisk/awesomehook.h"
+#include "asterisk/framehook.h"
/*** DOCUMENTATION
- <function name="AWESOME_TRACE" language="en_US">
+ <function name="FRAME_TRACE" language="en_US">
<synopsis>
View internal ast_frames as they are read and written on a channel.
</synopsis>
@@ -66,9 +66,9 @@
</syntax>
<description>
<para>Examples:</para>
- <para>exten => 1,1,Set(AWESOME_TRACE(white)=DTMF_BEGIN,DTMF_END); view only DTMF frames. </para>
- <para>exten => 1,1,Set(AWESOME_TRACE()=DTMF_BEGIN,DTMF_END); view only DTMF frames. </para>
- <para>exten => 1,1,Set(AWESOME_TRACE(black)=DTMF_BEGIN,DTMF_END); view everything except DTMF frames. </para>
+ <para>exten => 1,1,Set(FRAME_TRACE(white)=DTMF_BEGIN,DTMF_END); view only DTMF frames. </para>
+ <para>exten => 1,1,Set(FRAME_TRACE()=DTMF_BEGIN,DTMF_END); view only DTMF frames. </para>
+ <para>exten => 1,1,Set(FRAME_TRACE(black)=DTMF_BEGIN,DTMF_END); view everything except DTMF frames. </para>
</description>
</function>
***/
@@ -111,7 +111,7 @@
ast_free(awesomedata);
}
-static struct ast_frame *hook_event_cb(struct ast_channel *chan, struct ast_frame *frame, enum ast_awesomehook_event event, void *datastore)
+static struct ast_frame *hook_event_cb(struct ast_channel *chan, struct ast_frame *frame, enum ast_frame_hook_event event, void *datastore)
{
int i;
int show_frame = 0;
@@ -120,7 +120,7 @@
return frame;
}
- if ((event != AST_AWESOMEHOOK_EVENT_WRITE) && (event != AST_AWESOMEHOOK_EVENT_READ)) {
+ if ((event != AST_FRAMEHOOK_EVENT_WRITE) && (event != AST_FRAMEHOOK_EVENT_READ)) {
return frame;
}
@@ -136,7 +136,7 @@
}
if (show_frame) {
- ast_verbose("%s on Channel %s\n", event == AST_AWESOMEHOOK_EVENT_READ ? "<--Read" : "--> Write", chan->name);
+ ast_verbose("%s on Channel %s\n", event == AST_FRAMEHOOK_EVENT_READ ? "<--Read" : "--> Write", chan->name);
print_frame(frame);
}
return frame;
@@ -162,24 +162,24 @@
}
ast_channel_lock(chan);
- i = ast_awesomehook_attach(chan, hook_event_cb, hook_destroy_cb, awesomedata);
+ i = ast_frame_hook_attach(chan, hook_event_cb, hook_destroy_cb, awesomedata);
if (i >= 0) {
int *id;
if ((datastore = ast_channel_datastore_find(chan, &awesome_trace_datastore, NULL))) {
id = datastore->data;
- ast_awesomehook_detach(chan, *id);
+ ast_frame_hook_detach(chan, *id);
ast_channel_datastore_remove(chan, datastore);
}
if (!(datastore = ast_datastore_alloc(&awesome_trace_datastore, NULL))) {
- ast_awesomehook_detach(chan, i);
+ ast_frame_hook_detach(chan, i);
ast_channel_unlock(chan);
return 0;
}
if (!(id = ast_calloc(1, sizeof(int)))) {
ast_datastore_free(datastore);
- ast_awesomehook_detach(chan, i);
+ ast_frame_hook_detach(chan, i);
ast_channel_unlock(chan);
return 0;
}
@@ -339,7 +339,7 @@
}
static struct ast_custom_function awesome_trace_function = {
- .name = "AWESOME_TRACE",
+ .name = "FRAME_TRACE",
.write = awesome_trace_helper,
};
@@ -354,5 +354,5 @@
return res ? AST_MODULE_LOAD_DECLINE : AST_MODULE_LOAD_SUCCESS;
}
-AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Awesome Trace for internal ast_frame debugging.");
-
+AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Frame Trace for internal ast_frame debugging.");
+
Modified: team/dvossel/awesomehooks/include/asterisk/channel.h
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/awesomehooks/include/asterisk/channel.h?view=diff&rev=287550&r1=287549&r2=287550
==============================================================================
--- team/dvossel/awesomehooks/include/asterisk/channel.h (original)
+++ team/dvossel/awesomehooks/include/asterisk/channel.h Mon Sep 20 09:07:25 2010
@@ -151,7 +151,7 @@
#include "asterisk/data.h"
#include "asterisk/channelstate.h"
#include "asterisk/ccss.h"
-#include "asterisk/awesomehook.h"
+#include "asterisk/framehook.h"
#define DATASTORE_INHERIT_FOREVER INT_MAX
@@ -753,7 +753,7 @@
struct ast_trans_pvt *writetrans; /*!< Write translation path */
struct ast_trans_pvt *readtrans; /*!< Read translation path */
struct ast_audiohook_list *audiohooks;
- struct ast_awesomehook_list awesomehooks;
+ struct ast_frame_hook_list frame_hooks;
struct ast_cdr *cdr; /*!< Call Detail Record */
struct ast_tone_zone *zone; /*!< Tone zone as set in indications.conf or
* in the CHANNEL dialplan function */
Copied: team/dvossel/awesomehooks/include/asterisk/framehook.h (from r287549, team/dvossel/awesomehooks/include/asterisk/awesomehook.h)
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/awesomehooks/include/asterisk/framehook.h?view=diff&rev=287550&p1=team/dvossel/awesomehooks/include/asterisk/awesomehook.h&r1=287549&p2=team/dvossel/awesomehooks/include/asterisk/framehook.h&r2=287550
==============================================================================
--- team/dvossel/awesomehooks/include/asterisk/awesomehook.h (original)
+++ team/dvossel/awesomehooks/include/asterisk/framehook.h Mon Sep 20 09:07:25 2010
@@ -17,7 +17,7 @@
*/
/*! \file
- * \brief AwesomeHook Architecture
+ * \brief FrameHook Architecture
*/
/*!
@@ -31,16 +31,16 @@
\section AwesomeHookAPIUsage How to Use an AwesomeHook
Attaching and detaching an AwesomeHook to a channel is very simple. There are only
- two functions involved, ast_awesomehook_attach() which will return an id representing
- the new AwesomeHook on the channel, and ast_awesomehook_detach() which signals the
+ two functions involved, ast_frame_hook_attach() which will return an id representing
+ the new AwesomeHook on the channel, and ast_frame_hook_detach() which signals the
AwesomeHook for detachment and destruction. Below is detailed information each of these
functions and their usage.
\code
- int id = ast_awesomehook_attach(channel, event_callback, destroy_callback, datastore);
+ int id = ast_frame_hook_attach(channel, event_callback, destroy_callback, datastore);
\endcode
- The ast_awesomehook_attach() function creates and attaches a new AwesomeHook onto
+ The ast_frame_hook_attach() function creates and attaches a new AwesomeHook onto
a channel. Once attached to the channel, the AwesomeHook will call the event_callback
function each time a frame is written or read on the channel. A custom datastore
pointer can be provided to this function to store on the AwesomeHook as well. This
@@ -50,14 +50,14 @@
the Awesomehook if destroyed.
\code
- ast_awesomehook_detach(channel, id);
+ ast_frame_hook_detach(channel, id);
\endcode
- The ast_awesomehook_detach() function signals the AwesomeHook represented by an id to
+ The ast_frame_hook_detach() function signals the AwesomeHook represented by an id to
be detached and destroyed on a channel. Since it is possible this function may be called
during the AwesomeHook's event callback, it is impossible to synchronously detach the
AwesomeHook from the channel during this function call. It is guaranteed that the next
- event proceeding the ast_awesomehook_detach() will be of type AST_AWESOMEHOOK_EVENT_DETACH,
+ event proceeding the ast_frame_hook_detach() will be of type AST_FRAMEHOOK_EVENT_DETACH,
and that after that event occurs no other event will ever be issued for that AwesomeHook.
Once the AwesomeHook is destroyed, the destroy callback function will be called if it was
provided. Note that if this function is never called, the AwesomeHook will be detached
@@ -75,7 +75,7 @@
static struct ast_frame *event_cb(struct ast_channel *chan,
struct ast_frame *frame,
- enum ast_awesomehook_event event,
+ enum ast_frame_hook_event event,
void *datastore) {
int *id = datastore;
@@ -84,12 +84,12 @@
return frame;
}
- if (event == AST_AWESOMEHOOK_EVENT_WRITE) {
+ if (event == AST_FRAMEHOOK_EVENT_WRITE) {
ast_log(LOG_NOTICE, "YAY we received a frame in the write direction, Type: %d\n", frame->frametype)
- ast_awesomehook_detach(chan, id); // the channel is guaranteed to be locked during this function call.
- } else if (event == AST_AWESOMEHOOK_EVENT_READ) {
+ ast_frame_hook_detach(chan, id); // the channel is guaranteed to be locked during this function call.
+ } else if (event == AST_FRAMEHOOK_EVENT_READ) {
ast_log(LOG_NOTICE, "YAY we received a frame in the read direction: Type: %d\n", frame->frametype);
- ast_awesomehook_detach(chan, id); // the channel is guaranteed to be locked during this function call.
+ ast_frame_hook_detach(chan, id); // the channel is guaranteed to be locked during this function call.
}
return frame;
@@ -103,11 +103,11 @@
}
ast_channel_lock(chan);
- *id = ast_awesomehook_attach(chan, event_cb, destroy_cb, id);
+ *id = ast_frame_hook_attach(chan, event_cb, destroy_cb, id);
ast_channel_unlock(chan);
if (*id < 0) {
- // awesomehook attach failed, free data
+ // frame_hook attach failed, free data
ast_free(id);
return -1;
}
@@ -116,36 +116,36 @@
\endcode
*/
-#ifndef _AST_AWESOMEHOOK_H_
-#define _AST_AWESOMEHOOK_H_
+#ifndef _AST_FRAMEHOOK_H_
+#define _AST_FRAMEHOOK_H_
#include "asterisk/linkedlists.h"
#include "asterisk/frame.h"
#include "asterisk/channel.h"
-struct ast_awesomehook;
-
-struct ast_awesomehook_list {
+struct ast_frame_hook;
+
+struct ast_frame_hook_list {
unsigned int id_count;
- AST_LIST_HEAD_NOLOCK(, ast_awesomehook) list;
+ AST_LIST_HEAD_NOLOCK(, ast_frame_hook) list;
};
/*!
- * \brief These are the types of events that the awesomehook's event callback can receive
- */
-enum ast_awesomehook_event {
- AST_AWESOMEHOOK_EVENT_READ, /*!< frame is intercepted in the read direction on the channel. */
- AST_AWESOMEHOOK_EVENT_WRITE, /*!< frame is intercepted on the write direction on the channel. */
- AST_AWESOMEHOOK_EVENT_ATTACHED, /*!< awesomehook is attached and running on the channel, the first message sent to event_cb. */
- AST_AWESOMEHOOK_EVENT_DETACHED /*!< awesomehook is detached from the channel, last message sent to event_cb. */
+ * \brief These are the types of events that the frame_hook's event callback can receive
+ */
+enum ast_frame_hook_event {
+ AST_FRAMEHOOK_EVENT_READ, /*!< frame is intercepted in the read direction on the channel. */
+ AST_FRAMEHOOK_EVENT_WRITE, /*!< frame is intercepted on the write direction on the channel. */
+ AST_FRAMEHOOK_EVENT_ATTACHED, /*!< frame_hook is attached and running on the channel, the first message sent to event_cb. */
+ AST_FRAMEHOOK_EVENT_DETACHED /*!< frame_hook is detached from the channel, last message sent to event_cb. */
};
/*!
- * \brief This callback is called every time an event occurs on the awesomehook.
- *
- * \details Two events are guaranteed to occur once the ast_awesomehook_attach()
- * function is called. These events are AST_AWESOMEHOOK_EVENT_ATTACHED, which occurs
- * immediately after the awesomehook is attached to a channel, and
- * AST_AWESOMEHOOK_EVENT_DETACHED, which occurs right after the awesomehook is
+ * \brief This callback is called every time an event occurs on the frame_hook.
+ *
+ * \details Two events are guaranteed to occur once the ast_frame_hook_attach()
+ * function is called. These events are AST_FRAMEHOOK_EVENT_ATTACHED, which occurs
+ * immediately after the frame_hook is attached to a channel, and
+ * AST_FRAMEHOOK_EVENT_DETACHED, which occurs right after the frame_hook is
* detached.
*
* It is completely valid for the frame variable to be set to NULL. Always do a NULL
@@ -157,126 +157,126 @@
* The ast_channel will always be locked during this callback. Never attempt to unlock the
* channel for any reason.
*
- * \param channel, The ast_channel this awesomehook is attached to
+ * \param channel, The ast_channel this frame_hook is attached to
* \param frame, The ast_frame being intercepted for viewing and manipulation
* \param event, The type of event which is occurring
- * \param datastore, The datastore pointer provided at awesomehook initilization.
+ * \param datastore, The datastore pointer provided at frame_hook initilization.
*
* \retval the resulting frame.
*/
-typedef struct ast_frame *(*ast_awesomehook_event_callback)(
+typedef struct ast_frame *(*ast_frame_hook_event_callback)(
struct ast_channel *chan,
struct ast_frame *frame,
- enum ast_awesomehook_event event,
+ enum ast_frame_hook_event event,
void *datastore);
/*!
- * \brief This callback is called immediately before the awesomehook is destroyed.
+ * \brief This callback is called immediately before the frame_hook is destroyed.
* \note This function should be used to clean up any pointers pointing to the
- * awesomehook structure as the awesomehook will be freed immediately afterwards.
- *
- * \param datastore, The datastore pointer provided at awesomehook initialization. This
- * is a good place to clean up any state data allocated for the awesomehook stored in this
+ * frame_hook structure as the frame_hook will be freed immediately afterwards.
+ *
+ * \param datastore, The datastore pointer provided at frame_hook initialization. This
+ * is a good place to clean up any state data allocated for the frame_hook stored in this
* pointer.
*/
-typedef void (*ast_awesomehook_destroy_callback)(void *datastore);
-
-/*!
- * \brief Attach an awesomehook onto a channel for frame interception.
+typedef void (*ast_frame_hook_destroy_callback)(void *datastore);
+
+/*!
+ * \brief Attach an frame_hook onto a channel for frame interception.
*
* \param ast_channel, The channel to attach the hook on to.
* \param event_cb represents the function that will be called everytime an
- * event occurs on the awesomehook.
+ * event occurs on the frame_hook.
* \param destroy_cb is optional. This function is called immediately before the
- * awesomehook is destroyed to allow for datastore cleanup.
- * \param Any custom data to be stored on the awesomehook. This data pointer will
- * be provided during each event callback which allows the awesomehook to store any
+ * frame_hook is destroyed to allow for datastore cleanup.
+ * \param Any custom data to be stored on the frame_hook. This data pointer will
+ * be provided during each event callback which allows the frame_hook to store any
* stateful data associated with the application using the hook.
*
* \note XXX The Channel must be locked during this function all.
*
- * \note The datastore pointer is never touched by the awesomehook API except to
+ * \note The datastore pointer is never touched by the frame_hook API except to
* provide it during the event and destruction callbacks. It is entirely up to the
* application using this API to manage the memory associated with the datastore pointer.
*
* \retval On success, positive id representing this hook on the channel
* \retval On failure, -1
*/
-int ast_awesomehook_attach(
+int ast_frame_hook_attach(
struct ast_channel *chan,
- ast_awesomehook_event_callback event_cb,
- ast_awesomehook_destroy_callback destroy_cb,
+ ast_frame_hook_event_callback event_cb,
+ ast_frame_hook_destroy_callback destroy_cb,
void *datastore);
/*!
- * \brief Detach an awesomehook from a channel.
+ * \brief Detach an frame_hook from a channel.
*
* \note XXX The Channel must be locked during this function all.
- * If this function is never called after attaching an awesomehook,
- * the awesomehook will be detached and destroyed during channel
+ * If this function is never called after attaching an frame_hook,
+ * the frame_hook will be detached and destroyed during channel
* destruction.
*
- * \param The channel the awesomehook is attached to
- * \param The awesomehook's id
+ * \param The channel the frame_hook is attached to
+ * \param The frame_hook's id
*
* \retval 0 success
- * \retval -1 awesomehook did not exist on the channel. This means the
- * awesomehook either never existed on the channel, or was already detached.
- */
-int ast_awesomehook_detach(struct ast_channel *chan, int awesomehook_id);
+ * \retval -1 frame_hook did not exist on the channel. This means the
+ * frame_hook either never existed on the channel, or was already detached.
+ */
+int ast_frame_hook_detach(struct ast_channel *chan, int frame_hook_id);
/*!
* \brief This is used by the channel API to detach and destroy all
- * awesomehooks on a channel during channel destruction.
+ * frame_hooks on a channel during channel destruction.
*
* \note XXX The Channel must be locked during this function all.
*
- * \param awesomehook list to destroy
+ * \param frame_hook list to destroy
* \retval 0 success
* \retval -1 failure
*/
-int ast_awesomehook_list_destroy(struct ast_awesomehook_list *awesomehooks);
-
-/*!
- * \brief This is used by the channel API push a frame read event to a channel's awesomehook list.
+int ast_frame_hook_list_destroy(struct ast_frame_hook_list *frame_hooks);
+
+/*!
+ * \brief This is used by the channel API push a frame read event to a channel's frame_hook list.
*
* \details After this function completes, the resulting frame that is returned could be anything,
* even NULL. There is nothing to keep up with after this function. If the frame is modified, the
- * awesomehook callback is in charge of any memory management associated with that modification.
- *
- * \note XXX The Channel must be locked during this function all.
- *
- * \param awesomehook list to push event to.
- * \param frame being pushed to the awesomehook list.
- *
- * \return The resulting frame after being viewed and modified by the awesomehook callbacks.
- */
-struct ast_frame *ast_awesomehook_list_read_event(struct ast_awesomehook_list *awesomehooks, struct ast_frame *frame);
-
-/*!
- * \brief This is used by the channel API push a frame write event to a channel's awesomehook list.
+ * frame_hook callback is in charge of any memory management associated with that modification.
+ *
+ * \note XXX The Channel must be locked during this function all.
+ *
+ * \param frame_hook list to push event to.
+ * \param frame being pushed to the frame_hook list.
+ *
+ * \return The resulting frame after being viewed and modified by the frame_hook callbacks.
+ */
+struct ast_frame *ast_frame_hook_list_read_event(struct ast_frame_hook_list *frame_hooks, struct ast_frame *frame);
+
+/*!
+ * \brief This is used by the channel API push a frame write event to a channel's frame_hook list.
*
* \details After this function completes, the resulting frame that is returned could be anything,
* even NULL. There is nothing to keep up with after this function. If the frame is modified, the
- * awesomehook callback is in charge of any memory management associated with that modification.
- *
- * \note XXX The Channel must be locked during this function all.
- *
- * \param awesomehook list to push event to.
- * \param frame being pushed to the awesomehook list.
- *
- * \return The resulting frame after being viewed and modified by the awesomehook callbacks.
- */
-struct ast_frame *ast_awesomehook_list_write_event(struct ast_awesomehook_list *awesomehooks, struct ast_frame *frame);
-
-/*!
- * \brief Determine if an awesomehook list is empty or not
- *
- * \note XXX The Channel must be locked during this function all.
- *
- * \param the awesomehook list
+ * frame_hook callback is in charge of any memory management associated with that modification.
+ *
+ * \note XXX The Channel must be locked during this function all.
+ *
+ * \param frame_hook list to push event to.
+ * \param frame being pushed to the frame_hook list.
+ *
+ * \return The resulting frame after being viewed and modified by the frame_hook callbacks.
+ */
+struct ast_frame *ast_frame_hook_list_write_event(struct ast_frame_hook_list *frame_hooks, struct ast_frame *frame);
+
+/*!
+ * \brief Determine if an frame_hook list is empty or not
+ *
+ * \note XXX The Channel must be locked during this function all.
+ *
+ * \param the frame_hook list
* \retval 0, not empty
* \retval 1, is empty
*/
-int ast_awesomehook_list_is_empty(struct ast_awesomehook_list *awesomehooks);
-#endif /* _AST_AWESOMEHOOK_H */
+int ast_frame_hook_list_is_empty(struct ast_frame_hook_list *frame_hooks);
+#endif /* _AST_FRAMEHOOK_H */
Modified: team/dvossel/awesomehooks/main/channel.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/awesomehooks/main/channel.c?view=diff&rev=287550&r1=287549&r2=287550
==============================================================================
--- team/dvossel/awesomehooks/main/channel.c (original)
+++ team/dvossel/awesomehooks/main/channel.c Mon Sep 20 09:07:25 2010
@@ -62,6 +62,7 @@
#include "asterisk/threadstorage.h"
#include "asterisk/slinfactory.h"
#include "asterisk/audiohook.h"
+#include "asterisk/framehook.h"
#include "asterisk/timing.h"
#include "asterisk/autochan.h"
#include "asterisk/stringfields.h"
@@ -2633,7 +2634,7 @@
chan->audiohooks = NULL;
}
- ast_awesomehook_list_destroy(&chan->awesomehooks);
+ ast_frame_hook_list_destroy(&chan->frame_hooks);
ast_autoservice_stop(chan);
@@ -3752,9 +3753,9 @@
*/
chan->fdno = -1;
- /* Perform the awesomehook read event here. After the frame enters the awesomehook list
+ /* Perform the frame_hook read event here. After the frame enters the frame_hook list
* there is no telling what will happen, <insert mad scientist laugh here>!!! */
- f = ast_awesomehook_list_read_event(&chan->awesomehooks, f);
+ f = ast_frame_hook_list_read_event(&chan->frame_hooks, f);
if (f) {
struct ast_frame *readq_tail = AST_LIST_LAST(&chan->readq);
@@ -4149,7 +4150,7 @@
enum ast_control_frame_type condition = _condition;
struct ast_tone_zone_sound *ts = NULL;
int res;
- /* this frame is used by awesomehooks. if it is set, we must free it at the end of this function */
+ /* this frame is used by frame_hooks. if it is set, we must free it at the end of this function */
struct ast_frame *awesome_frame = NULL;
ast_channel_lock(chan);
@@ -4161,8 +4162,8 @@
goto indicate_cleanup;
}
- if (!ast_awesomehook_list_is_empty(&chan->awesomehooks)) {
- /* Do awesomehooks now, do it, go, go now */
+ if (!ast_frame_hook_list_is_empty(&chan->frame_hooks)) {
+ /* Do frame_hooks now, do it, go, go now */
struct ast_frame frame = {
.frametype = AST_FRAME_CONTROL,
.subclass.integer = condition,
@@ -4174,7 +4175,7 @@
awesome_frame = ast_frdup(&frame);
/* who knows what we will get back! the anticipation is killing me. */
- if (!(awesome_frame = ast_awesomehook_list_read_event(&chan->awesomehooks, &frame))) {
+ if (!(awesome_frame = ast_frame_hook_list_read_event(&chan->frame_hooks, &frame))) {
ast_channel_unlock(chan);
res = 0;
goto indicate_cleanup;
@@ -4615,9 +4616,9 @@
goto done;
}
- /* Perform the awesomehook write event here. After the frame enters the awesomehook list
+ /* Perform the frame_hook write event here. After the frame enters the frame_hook list
* there is no telling what will happen, how awesome is that!!! */
- if (!(fr = ast_awesomehook_list_write_event(&chan->awesomehooks, fr))) {
+ if (!(fr = ast_frame_hook_list_write_event(&chan->frame_hooks, fr))) {
res = 0;
goto done;
}
Copied: team/dvossel/awesomehooks/main/framehook.c (from r287549, team/dvossel/awesomehooks/main/awesomehook.c)
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/awesomehooks/main/framehook.c?view=diff&rev=287550&p1=team/dvossel/awesomehooks/main/awesomehook.c&r1=287549&p2=team/dvossel/awesomehooks/main/framehook.c&r2=287550
==============================================================================
--- team/dvossel/awesomehooks/main/awesomehook.c (original)
+++ team/dvossel/awesomehooks/main/framehook.c Mon Sep 20 09:07:25 2010
@@ -18,7 +18,7 @@
/*! \file
*
- * \brief AwesomeHooks Architecture
+ * \brief FrameHooks Architecture
*
* \author David Vossel <dvossel at digium.com>
*/
@@ -29,76 +29,76 @@
#include "asterisk/channel.h"
#include "asterisk/linkedlists.h"
-#include "asterisk/awesomehook.h"
+#include "asterisk/framehook.h"
#include "asterisk/frame.h"
-struct ast_awesomehook {
+struct ast_frame_hook {
/*! This pointer holds any stateful data an application wishes to store. */
void *datastore;
- /*! This pointer to ast_channel the awesomehook is attached to. */
+ /*! This pointer to ast_channel the frame_hook is attached to. */
struct ast_channel *chan;
- /*! the id representing this awesomehook on a channel */
+ /*! the id representing this frame_hook on a channel */
unsigned int id;
/* when set, this signals the read and write function to detach the hook */
int detach_and_destroy_me;
/*! Pointer to the registered event callback function. */
- ast_awesomehook_event_callback event_cb;
+ ast_frame_hook_event_callback event_cb;
/*! Pointer to the registered destruction callback function. */
- ast_awesomehook_destroy_callback destroy_cb;
- /*! list entry for ast_awesomehook_list object */
- AST_LIST_ENTRY(ast_awesomehook) list;
+ ast_frame_hook_destroy_callback destroy_cb;
+ /*! list entry for ast_frame_hook_list object */
+ AST_LIST_ENTRY(ast_frame_hook) list;
};
-static void awesomehook_detach_and_destroy(struct ast_awesomehook *awesomehook)
+static void frame_hook_detach_and_destroy(struct ast_frame_hook *frame_hook)
{
struct ast_frame *frame;
- frame = awesomehook->event_cb(awesomehook->chan, NULL, AST_AWESOMEHOOK_EVENT_DETACHED, awesomehook->datastore);
+ frame = frame_hook->event_cb(frame_hook->chan, NULL, AST_FRAMEHOOK_EVENT_DETACHED, frame_hook->datastore);
/* never assume anything about this function. If you can return a frame during
* the detached event, then assume someone will. */
if (frame) {
ast_frfree(frame);
}
- awesomehook->chan = NULL;
+ frame_hook->chan = NULL;
- if (awesomehook->destroy_cb) {
- awesomehook->destroy_cb(awesomehook->datastore);
+ if (frame_hook->destroy_cb) {
+ frame_hook->destroy_cb(frame_hook->datastore);
}
- ast_free(awesomehook);
+ ast_free(frame_hook);
}
-static struct ast_frame *awesomehook_list_push_event(struct ast_awesomehook_list *awesomehooks, struct ast_frame *frame, enum ast_awesomehook_event event)
+static struct ast_frame *frame_hook_list_push_event(struct ast_frame_hook_list *frame_hooks, struct ast_frame *frame, enum ast_frame_hook_event event)
{
- struct ast_awesomehook *awesomehook;
- AST_LIST_TRAVERSE_SAFE_BEGIN(&awesomehooks->list, awesomehook, list) {
- if (awesomehook->detach_and_destroy_me) {
+ struct ast_frame_hook *frame_hook;
+ AST_LIST_TRAVERSE_SAFE_BEGIN(&frame_hooks->list, frame_hook, list) {
+ if (frame_hook->detach_and_destroy_me) {
/* this guy is signaled for destruction */
AST_LIST_REMOVE_CURRENT(list);
- awesomehook_detach_and_destroy(awesomehook);
+ frame_hook_detach_and_destroy(frame_hook);
} else {
- frame = awesomehook->event_cb(awesomehook->chan, frame, event, awesomehook->datastore);
+ frame = frame_hook->event_cb(frame_hook->chan, frame, event, frame_hook->datastore);
}
}
AST_LIST_TRAVERSE_SAFE_END;
return frame;
}
-int ast_awesomehook_attach(struct ast_channel *chan, ast_awesomehook_event_callback event_cb, ast_awesomehook_destroy_callback destroy_cb, void *data)
+int ast_frame_hook_attach(struct ast_channel *chan, ast_frame_hook_event_callback event_cb, ast_frame_hook_destroy_callback destroy_cb, void *data)
{
- struct ast_awesomehook *awesomehook;
+ struct ast_frame_hook *frame_hook;
struct ast_frame *frame;
- if (!event_cb || !(awesomehook = ast_calloc(1, sizeof(*awesomehook)))) {
+ if (!event_cb || !(frame_hook = ast_calloc(1, sizeof(*frame_hook)))) {
return -1;
}
- awesomehook->event_cb = event_cb;
- awesomehook->destroy_cb = destroy_cb;
- awesomehook->datastore = data;
- awesomehook->chan = chan;
- awesomehook->id = ++chan->awesomehooks.id_count;
+ frame_hook->event_cb = event_cb;
+ frame_hook->destroy_cb = destroy_cb;
+ frame_hook->datastore = data;
+ frame_hook->chan = chan;
+ frame_hook->id = ++chan->frame_hooks.id_count;
- AST_LIST_INSERT_TAIL(&chan->awesomehooks.list, awesomehook, list);
+ AST_LIST_INSERT_TAIL(&chan->frame_hooks.list, frame_hook, list);
/* Tell the event callback we're live and rocking */
- frame = awesomehook->event_cb(awesomehook->chan, NULL, AST_AWESOMEHOOK_EVENT_ATTACHED, awesomehook->datastore);
+ frame = frame_hook->event_cb(frame_hook->chan, NULL, AST_FRAMEHOOK_EVENT_ATTACHED, frame_hook->datastore);
/* Never assume anything about this function. If you can return a frame during
* the attached event, then assume someone will. */
@@ -106,21 +106,21 @@
ast_frfree(frame);
}
- return awesomehook->id;
+ return frame_hook->id;
}
-int ast_awesomehook_detach(struct ast_channel *chan, int id)
+int ast_frame_hook_detach(struct ast_channel *chan, int id)
{
- struct ast_awesomehook *awesomehook;
+ struct ast_frame_hook *frame_hook;
int res = -1;
- AST_LIST_TRAVERSE_SAFE_BEGIN(&chan->awesomehooks.list, awesomehook, list) {
- if (awesomehook->id == id) {
+ AST_LIST_TRAVERSE_SAFE_BEGIN(&chan->frame_hooks.list, frame_hook, list) {
+ if (frame_hook->id == id) {
/* we mark for detachment rather than doing explicitly here because
* it needs to be safe for this function to be called within the
* event callback. If we allowed the hook to actually be destroyed
* immediately here, the event callback would crash on exit. */
- awesomehook->detach_and_destroy_me = 1;
+ frame_hook->detach_and_destroy_me = 1;
res = 0;
break;
}
@@ -130,30 +130,30 @@
return res;
}
-int ast_awesomehook_list_destroy(struct ast_awesomehook_list *awesomehooks)
+int ast_frame_hook_list_destroy(struct ast_frame_hook_list *frame_hooks)
{
- struct ast_awesomehook *awesomehook;
+ struct ast_frame_hook *frame_hook;
- AST_LIST_TRAVERSE_SAFE_BEGIN(&awesomehooks->list, awesomehook, list) {
+ AST_LIST_TRAVERSE_SAFE_BEGIN(&frame_hooks->list, frame_hook, list) {
AST_LIST_REMOVE_CURRENT(list);
- awesomehook_detach_and_destroy(awesomehook);
+ frame_hook_detach_and_destroy(frame_hook);
}
AST_LIST_TRAVERSE_SAFE_END;
return 0;
}
-int ast_awesomehook_list_is_empty(struct ast_awesomehook_list *awesomehooks)
+int ast_frame_hook_list_is_empty(struct ast_frame_hook_list *frame_hooks)
{
- return AST_LIST_EMPTY(&awesomehooks->list) ? 1 : 0;
+ return AST_LIST_EMPTY(&frame_hooks->list) ? 1 : 0;
}
-struct ast_frame *ast_awesomehook_list_write_event(struct ast_awesomehook_list *awesomehooks, struct ast_frame *frame)
+struct ast_frame *ast_frame_hook_list_write_event(struct ast_frame_hook_list *frame_hooks, struct ast_frame *frame)
{
- return awesomehook_list_push_event(awesomehooks, frame, AST_AWESOMEHOOK_EVENT_WRITE);
+ return frame_hook_list_push_event(frame_hooks, frame, AST_FRAMEHOOK_EVENT_WRITE);
}
-struct ast_frame *ast_awesomehook_list_read_event(struct ast_awesomehook_list *awesomehooks, struct ast_frame *frame)
+struct ast_frame *ast_frame_hook_list_read_event(struct ast_frame_hook_list *frame_hooks, struct ast_frame *frame)
{
- return awesomehook_list_push_event(awesomehooks, frame, AST_AWESOMEHOOK_EVENT_READ);
+ return frame_hook_list_push_event(frame_hooks, frame, AST_FRAMEHOOK_EVENT_READ);
}
More information about the svn-commits
mailing list