[asterisk-commits] dvossel: branch dvossel/awesomehooks r287551 - in /team/dvossel/awesomehooks:...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Mon Sep 20 09:17:53 CDT 2010
Author: dvossel
Date: Mon Sep 20 09:17:49 2010
New Revision: 287551
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=287551
Log:
frame_hook is not framehook with no '_'
Modified:
team/dvossel/awesomehooks/funcs/func_frame_trace.c
team/dvossel/awesomehooks/include/asterisk/channel.h
team/dvossel/awesomehooks/include/asterisk/framehook.h
team/dvossel/awesomehooks/main/channel.c
team/dvossel/awesomehooks/main/framehook.c
Modified: team/dvossel/awesomehooks/funcs/func_frame_trace.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/awesomehooks/funcs/func_frame_trace.c?view=diff&rev=287551&r1=287550&r2=287551
==============================================================================
--- team/dvossel/awesomehooks/funcs/func_frame_trace.c (original)
+++ team/dvossel/awesomehooks/funcs/func_frame_trace.c Mon Sep 20 09:17:49 2010
@@ -111,7 +111,7 @@
ast_free(awesomedata);
}
-static struct ast_frame *hook_event_cb(struct ast_channel *chan, struct ast_frame *frame, enum ast_frame_hook_event event, void *datastore)
+static struct ast_frame *hook_event_cb(struct ast_channel *chan, struct ast_frame *frame, enum ast_framehook_event event, void *datastore)
{
int i;
int show_frame = 0;
@@ -162,24 +162,24 @@
}
ast_channel_lock(chan);
- i = ast_frame_hook_attach(chan, hook_event_cb, hook_destroy_cb, awesomedata);
+ i = ast_framehook_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_frame_hook_detach(chan, *id);
+ ast_framehook_detach(chan, *id);
ast_channel_datastore_remove(chan, datastore);
}
if (!(datastore = ast_datastore_alloc(&awesome_trace_datastore, NULL))) {
- ast_frame_hook_detach(chan, i);
+ ast_framehook_detach(chan, i);
ast_channel_unlock(chan);
return 0;
}
if (!(id = ast_calloc(1, sizeof(int)))) {
ast_datastore_free(datastore);
- ast_frame_hook_detach(chan, i);
+ ast_framehook_detach(chan, i);
ast_channel_unlock(chan);
return 0;
}
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=287551&r1=287550&r2=287551
==============================================================================
--- team/dvossel/awesomehooks/include/asterisk/channel.h (original)
+++ team/dvossel/awesomehooks/include/asterisk/channel.h Mon Sep 20 09:17:49 2010
@@ -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_frame_hook_list frame_hooks;
+ struct ast_framehook_list framehooks;
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 */
Modified: team/dvossel/awesomehooks/include/asterisk/framehook.h
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/awesomehooks/include/asterisk/framehook.h?view=diff&rev=287551&r1=287550&r2=287551
==============================================================================
--- team/dvossel/awesomehooks/include/asterisk/framehook.h (original)
+++ team/dvossel/awesomehooks/include/asterisk/framehook.h Mon Sep 20 09:17:49 2010
@@ -22,51 +22,51 @@
/*!
-\page AstAwesomeHookAPI Asterisk AwesomeHook API
-
-\section AwesomeHookFunctionality How AwesomeHooks Work
- AwesomeHooks work by intercepting all frames being written and read off
+\page AstFrameHookAPI Asterisk FrameHook API
+
+\section FrameHookFunctionality How FrameHooks Work
+ FrameHooks work by intercepting all frames being written and read off
a channel and allowing those frames to be viewed and manipulated within a
call back function.
-\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_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
+\section FrameHookAPIUsage How to Use an FrameHook
+ Attaching and detaching an FrameHook to a channel is very simple. There are only
+ two functions involved, ast_framehook_attach() which will return an id representing
+ the new FrameHook on the channel, and ast_framehook_detach() which signals the
+ FrameHook for detachment and destruction. Below is detailed information each of these
functions and their usage.
\code
- int id = ast_frame_hook_attach(channel, event_callback, destroy_callback, datastore);
+ int id = ast_framehook_attach(channel, event_callback, destroy_callback, datastore);
\endcode
- 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
+ The ast_framehook_attach() function creates and attaches a new FrameHook onto
+ a channel. Once attached to the channel, the FrameHook 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
- pointer can be used to keep up with any statefull information associated with the AwesomeHook
+ pointer can be provided to this function to store on the FrameHook as well. This
+ pointer can be used to keep up with any statefull information associated with the FrameHook
and is provided during the event_callback function. The destroy_callback function is optional.
- This function exists so any custom data stored on the AwesomeHook can be destroyed before
- the Awesomehook if destroyed.
+ This function exists so any custom data stored on the FrameHook can be destroyed before
+ the Framehook if destroyed.
\code
- ast_frame_hook_detach(channel, id);
+ ast_framehook_detach(channel, id);
\endcode
- The ast_frame_hook_detach() function signals the AwesomeHook represented by an id to
+ The ast_framehook_detach() function signals the FrameHook 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_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
+ during the FrameHook's event callback, it is impossible to synchronously detach the
+ FrameHook from the channel during this function call. It is guaranteed that the next
+ event proceeding the ast_framehook_detach() will be of type AST_FRAMEHOOK_EVENT_DETACH,
+ and that after that event occurs no other event will ever be issued for that FrameHook.
+ Once the FrameHook is destroyed, the destroy callback function will be called if it was
+ provided. Note that if this function is never called, the FrameHook will be detached
on channel destruction.
-\section AwesomeHookAPICodeExample AwesomeHook Example Code
- The example code below attaches an AwesomeHook on a channel, and then detachs it when
- the first ast_frame is read or written to the event callback function. The Awesomehook's id
- is stored on the AwesomeHook's data pointer so it can be detached within the callback.
+\section FrameHookAPICodeExample FrameHook Example Code
+ The example code below attaches an FrameHook on a channel, and then detachs it when
+ the first ast_frame is read or written to the event callback function. The Framehook's id
+ is stored on the FrameHook's data pointer so it can be detached within the callback.
\code
static void destroy_cb(void *datastore) {
@@ -75,7 +75,7 @@
static struct ast_frame *event_cb(struct ast_channel *chan,
struct ast_frame *frame,
- enum ast_frame_hook_event event,
+ enum ast_framehook_event event,
void *datastore) {
int *id = datastore;
@@ -86,10 +86,10 @@
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_frame_hook_detach(chan, id); // the channel is guaranteed to be locked during this function call.
+ ast_framehook_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_frame_hook_detach(chan, id); // the channel is guaranteed to be locked during this function call.
+ ast_framehook_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_frame_hook_attach(chan, event_cb, destroy_cb, id);
+ *id = ast_framehook_attach(chan, event_cb, destroy_cb, id);
ast_channel_unlock(chan);
if (*id < 0) {
- // frame_hook attach failed, free data
+ // framehook attach failed, free data
ast_free(id);
return -1;
}
@@ -120,32 +120,31 @@
#define _AST_FRAMEHOOK_H_
#include "asterisk/linkedlists.h"
#include "asterisk/frame.h"
-#include "asterisk/channel.h"
-
-struct ast_frame_hook;
-
-struct ast_frame_hook_list {
+
+struct ast_framehook;
+
+struct ast_framehook_list {
unsigned int id_count;
- AST_LIST_HEAD_NOLOCK(, ast_frame_hook) list;
+ AST_LIST_HEAD_NOLOCK(, ast_framehook) list;
};
/*!
- * \brief These are the types of events that the frame_hook's event callback can receive
- */
-enum ast_frame_hook_event {
+ * \brief These are the types of events that the framehook's event callback can receive
+ */
+enum ast_framehook_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. */
+ AST_FRAMEHOOK_EVENT_ATTACHED, /*!< framehook is attached and running on the channel, the first message sent to event_cb. */
+ AST_FRAMEHOOK_EVENT_DETACHED /*!< framehook is detached from the channel, last message sent to event_cb. */
};
/*!
- * \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()
+ * \brief This callback is called every time an event occurs on the framehook.
+ *
+ * \details Two events are guaranteed to occur once the ast_framehook_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
+ * immediately after the framehook is attached to a channel, and
+ * AST_FRAMEHOOK_EVENT_DETACHED, which occurs right after the framehook is
* detached.
*
* It is completely valid for the frame variable to be set to NULL. Always do a NULL
@@ -157,126 +156,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 frame_hook is attached to
+ * \param channel, The ast_channel this framehook 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 frame_hook initilization.
+ * \param datastore, The datastore pointer provided at framehook initilization.
*
* \retval the resulting frame.
*/
-typedef struct ast_frame *(*ast_frame_hook_event_callback)(
+typedef struct ast_frame *(*ast_framehook_event_callback)(
struct ast_channel *chan,
struct ast_frame *frame,
- enum ast_frame_hook_event event,
+ enum ast_framehook_event event,
void *datastore);
/*!
- * \brief This callback is called immediately before the frame_hook is destroyed.
+ * \brief This callback is called immediately before the framehook is destroyed.
* \note This function should be used to clean up any pointers pointing to the
- * 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
+ * framehook structure as the framehook will be freed immediately afterwards.
+ *
+ * \param datastore, The datastore pointer provided at framehook initialization. This
+ * is a good place to clean up any state data allocated for the framehook stored in this
* pointer.
*/
-typedef void (*ast_frame_hook_destroy_callback)(void *datastore);
-
-/*!
- * \brief Attach an frame_hook onto a channel for frame interception.
+typedef void (*ast_framehook_destroy_callback)(void *datastore);
+
+/*!
+ * \brief Attach an framehook 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 frame_hook.
+ * event occurs on the framehook.
* \param destroy_cb is optional. This function is called immediately before the
- * 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
+ * framehook is destroyed to allow for datastore cleanup.
+ * \param Any custom data to be stored on the framehook. This data pointer will
+ * be provided during each event callback which allows the framehook 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 frame_hook API except to
+ * \note The datastore pointer is never touched by the framehook 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_frame_hook_attach(
+int ast_framehook_attach(
struct ast_channel *chan,
- ast_frame_hook_event_callback event_cb,
- ast_frame_hook_destroy_callback destroy_cb,
+ ast_framehook_event_callback event_cb,
+ ast_framehook_destroy_callback destroy_cb,
void *datastore);
/*!
- * \brief Detach an frame_hook from a channel.
+ * \brief Detach an framehook from a channel.
*
* \note XXX The Channel must be locked during this function all.
- * If this function is never called after attaching an frame_hook,
- * the frame_hook will be detached and destroyed during channel
+ * If this function is never called after attaching an framehook,
+ * the framehook will be detached and destroyed during channel
* destruction.
*
- * \param The channel the frame_hook is attached to
- * \param The frame_hook's id
+ * \param The channel the framehook is attached to
+ * \param The framehook's id
*
* \retval 0 success
- * \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);
+ * \retval -1 framehook did not exist on the channel. This means the
+ * framehook either never existed on the channel, or was already detached.
+ */
+int ast_framehook_detach(struct ast_channel *chan, int framehook_id);
/*!
* \brief This is used by the channel API to detach and destroy all
- * frame_hooks on a channel during channel destruction.
+ * framehooks on a channel during channel destruction.
*
* \note XXX The Channel must be locked during this function all.
*
- * \param frame_hook list to destroy
+ * \param framehook list to destroy
* \retval 0 success
* \retval -1 failure
*/
-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.
+int ast_framehook_list_destroy(struct ast_framehook_list *framehooks);
+
+/*!
+ * \brief This is used by the channel API push a frame read event to a channel's framehook 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
- * 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.
+ * framehook callback is in charge of any memory management associated with that modification.
+ *
+ * \note XXX The Channel must be locked during this function all.
+ *
+ * \param framehook list to push event to.
+ * \param frame being pushed to the framehook list.
+ *
+ * \return The resulting frame after being viewed and modified by the framehook callbacks.
+ */
+struct ast_frame *ast_framehook_list_read_event(struct ast_framehook_list *framehooks, struct ast_frame *frame);
+
+/*!
+ * \brief This is used by the channel API push a frame write event to a channel's framehook 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
- * 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
+ * framehook callback is in charge of any memory management associated with that modification.
+ *
+ * \note XXX The Channel must be locked during this function all.
+ *
+ * \param framehook list to push event to.
+ * \param frame being pushed to the framehook list.
+ *
+ * \return The resulting frame after being viewed and modified by the framehook callbacks.
+ */
+struct ast_frame *ast_framehook_list_write_event(struct ast_framehook_list *framehooks, struct ast_frame *frame);
+
+/*!
+ * \brief Determine if an framehook list is empty or not
+ *
+ * \note XXX The Channel must be locked during this function all.
+ *
+ * \param the framehook list
* \retval 0, not empty
* \retval 1, is empty
*/
-int ast_frame_hook_list_is_empty(struct ast_frame_hook_list *frame_hooks);
+int ast_framehook_list_is_empty(struct ast_framehook_list *framehooks);
#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=287551&r1=287550&r2=287551
==============================================================================
--- team/dvossel/awesomehooks/main/channel.c (original)
+++ team/dvossel/awesomehooks/main/channel.c Mon Sep 20 09:17:49 2010
@@ -2634,7 +2634,7 @@
chan->audiohooks = NULL;
}
- ast_frame_hook_list_destroy(&chan->frame_hooks);
+ ast_framehook_list_destroy(&chan->framehooks);
ast_autoservice_stop(chan);
@@ -3753,9 +3753,9 @@
*/
chan->fdno = -1;
- /* Perform the frame_hook read event here. After the frame enters the frame_hook list
+ /* Perform the framehook read event here. After the frame enters the framehook list
* there is no telling what will happen, <insert mad scientist laugh here>!!! */
- f = ast_frame_hook_list_read_event(&chan->frame_hooks, f);
+ f = ast_framehook_list_read_event(&chan->framehooks, f);
if (f) {
struct ast_frame *readq_tail = AST_LIST_LAST(&chan->readq);
@@ -4150,7 +4150,7 @@
enum ast_control_frame_type condition = _condition;
struct ast_tone_zone_sound *ts = NULL;
int res;
- /* this frame is used by frame_hooks. if it is set, we must free it at the end of this function */
+ /* this frame is used by framehooks. if it is set, we must free it at the end of this function */
struct ast_frame *awesome_frame = NULL;
ast_channel_lock(chan);
@@ -4162,8 +4162,8 @@
goto indicate_cleanup;
}
- if (!ast_frame_hook_list_is_empty(&chan->frame_hooks)) {
- /* Do frame_hooks now, do it, go, go now */
+ if (!ast_framehook_list_is_empty(&chan->framehooks)) {
+ /* Do framehooks now, do it, go, go now */
struct ast_frame frame = {
.frametype = AST_FRAME_CONTROL,
.subclass.integer = condition,
@@ -4175,7 +4175,7 @@
awesome_frame = ast_frdup(&frame);
/* who knows what we will get back! the anticipation is killing me. */
- if (!(awesome_frame = ast_frame_hook_list_read_event(&chan->frame_hooks, &frame))) {
+ if (!(awesome_frame = ast_framehook_list_read_event(&chan->framehooks, &frame))) {
ast_channel_unlock(chan);
res = 0;
goto indicate_cleanup;
@@ -4616,9 +4616,9 @@
goto done;
}
- /* Perform the frame_hook write event here. After the frame enters the frame_hook list
+ /* Perform the framehook write event here. After the frame enters the framehook list
* there is no telling what will happen, how awesome is that!!! */
- if (!(fr = ast_frame_hook_list_write_event(&chan->frame_hooks, fr))) {
+ if (!(fr = ast_framehook_list_write_event(&chan->framehooks, fr))) {
res = 0;
goto done;
}
Modified: team/dvossel/awesomehooks/main/framehook.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/awesomehooks/main/framehook.c?view=diff&rev=287551&r1=287550&r2=287551
==============================================================================
--- team/dvossel/awesomehooks/main/framehook.c (original)
+++ team/dvossel/awesomehooks/main/framehook.c Mon Sep 20 09:17:49 2010
@@ -32,73 +32,73 @@
#include "asterisk/framehook.h"
#include "asterisk/frame.h"
-struct ast_frame_hook {
+struct ast_framehook {
/*! This pointer holds any stateful data an application wishes to store. */
void *datastore;
- /*! This pointer to ast_channel the frame_hook is attached to. */
+ /*! This pointer to ast_channel the framehook is attached to. */
struct ast_channel *chan;
- /*! the id representing this frame_hook on a channel */
+ /*! the id representing this framehook 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_frame_hook_event_callback event_cb;
+ ast_framehook_event_callback event_cb;
/*! Pointer to the registered destruction callback function. */
- ast_frame_hook_destroy_callback destroy_cb;
- /*! list entry for ast_frame_hook_list object */
- AST_LIST_ENTRY(ast_frame_hook) list;
+ ast_framehook_destroy_callback destroy_cb;
+ /*! list entry for ast_framehook_list object */
+ AST_LIST_ENTRY(ast_framehook) list;
};
-static void frame_hook_detach_and_destroy(struct ast_frame_hook *frame_hook)
+static void framehook_detach_and_destroy(struct ast_framehook *framehook)
{
struct ast_frame *frame;
- frame = frame_hook->event_cb(frame_hook->chan, NULL, AST_FRAMEHOOK_EVENT_DETACHED, frame_hook->datastore);
+ frame = framehook->event_cb(framehook->chan, NULL, AST_FRAMEHOOK_EVENT_DETACHED, framehook->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);
}
- frame_hook->chan = NULL;
+ framehook->chan = NULL;
- if (frame_hook->destroy_cb) {
- frame_hook->destroy_cb(frame_hook->datastore);
+ if (framehook->destroy_cb) {
+ framehook->destroy_cb(framehook->datastore);
}
- ast_free(frame_hook);
+ ast_free(framehook);
}
-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)
+static struct ast_frame *framehook_list_push_event(struct ast_framehook_list *framehooks, struct ast_frame *frame, enum ast_framehook_event event)
{
- struct ast_frame_hook *frame_hook;
- AST_LIST_TRAVERSE_SAFE_BEGIN(&frame_hooks->list, frame_hook, list) {
- if (frame_hook->detach_and_destroy_me) {
+ struct ast_framehook *framehook;
+ AST_LIST_TRAVERSE_SAFE_BEGIN(&framehooks->list, framehook, list) {
+ if (framehook->detach_and_destroy_me) {
/* this guy is signaled for destruction */
AST_LIST_REMOVE_CURRENT(list);
- frame_hook_detach_and_destroy(frame_hook);
+ framehook_detach_and_destroy(framehook);
} else {
- frame = frame_hook->event_cb(frame_hook->chan, frame, event, frame_hook->datastore);
+ frame = framehook->event_cb(framehook->chan, frame, event, framehook->datastore);
}
}
AST_LIST_TRAVERSE_SAFE_END;
return frame;
}
-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)
+int ast_framehook_attach(struct ast_channel *chan, ast_framehook_event_callback event_cb, ast_framehook_destroy_callback destroy_cb, void *data)
{
- struct ast_frame_hook *frame_hook;
+ struct ast_framehook *framehook;
struct ast_frame *frame;
- if (!event_cb || !(frame_hook = ast_calloc(1, sizeof(*frame_hook)))) {
+ if (!event_cb || !(framehook = ast_calloc(1, sizeof(*framehook)))) {
return -1;
}
- 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;
+ framehook->event_cb = event_cb;
+ framehook->destroy_cb = destroy_cb;
+ framehook->datastore = data;
+ framehook->chan = chan;
+ framehook->id = ++chan->framehooks.id_count;
- AST_LIST_INSERT_TAIL(&chan->frame_hooks.list, frame_hook, list);
+ AST_LIST_INSERT_TAIL(&chan->framehooks.list, framehook, list);
/* Tell the event callback we're live and rocking */
- frame = frame_hook->event_cb(frame_hook->chan, NULL, AST_FRAMEHOOK_EVENT_ATTACHED, frame_hook->datastore);
+ frame = framehook->event_cb(framehook->chan, NULL, AST_FRAMEHOOK_EVENT_ATTACHED, framehook->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 frame_hook->id;
+ return framehook->id;
}
-int ast_frame_hook_detach(struct ast_channel *chan, int id)
+int ast_framehook_detach(struct ast_channel *chan, int id)
{
- struct ast_frame_hook *frame_hook;
+ struct ast_framehook *framehook;
int res = -1;
- AST_LIST_TRAVERSE_SAFE_BEGIN(&chan->frame_hooks.list, frame_hook, list) {
- if (frame_hook->id == id) {
+ AST_LIST_TRAVERSE_SAFE_BEGIN(&chan->framehooks.list, framehook, list) {
+ if (framehook->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. */
- frame_hook->detach_and_destroy_me = 1;
+ framehook->detach_and_destroy_me = 1;
res = 0;
break;
}
@@ -130,30 +130,30 @@
return res;
}
-int ast_frame_hook_list_destroy(struct ast_frame_hook_list *frame_hooks)
+int ast_framehook_list_destroy(struct ast_framehook_list *framehooks)
{
- struct ast_frame_hook *frame_hook;
+ struct ast_framehook *framehook;
- AST_LIST_TRAVERSE_SAFE_BEGIN(&frame_hooks->list, frame_hook, list) {
+ AST_LIST_TRAVERSE_SAFE_BEGIN(&framehooks->list, framehook, list) {
AST_LIST_REMOVE_CURRENT(list);
- frame_hook_detach_and_destroy(frame_hook);
+ framehook_detach_and_destroy(framehook);
}
AST_LIST_TRAVERSE_SAFE_END;
return 0;
}
-int ast_frame_hook_list_is_empty(struct ast_frame_hook_list *frame_hooks)
+int ast_framehook_list_is_empty(struct ast_framehook_list *framehooks)
{
- return AST_LIST_EMPTY(&frame_hooks->list) ? 1 : 0;
+ return AST_LIST_EMPTY(&framehooks->list) ? 1 : 0;
}
-struct ast_frame *ast_frame_hook_list_write_event(struct ast_frame_hook_list *frame_hooks, struct ast_frame *frame)
+struct ast_frame *ast_framehook_list_write_event(struct ast_framehook_list *framehooks, struct ast_frame *frame)
{
- return frame_hook_list_push_event(frame_hooks, frame, AST_FRAMEHOOK_EVENT_WRITE);
+ return framehook_list_push_event(framehooks, frame, AST_FRAMEHOOK_EVENT_WRITE);
}
-struct ast_frame *ast_frame_hook_list_read_event(struct ast_frame_hook_list *frame_hooks, struct ast_frame *frame)
+struct ast_frame *ast_framehook_list_read_event(struct ast_framehook_list *framehooks, struct ast_frame *frame)
{
- return frame_hook_list_push_event(frame_hooks, frame, AST_FRAMEHOOK_EVENT_READ);
+ return framehook_list_push_event(framehooks, frame, AST_FRAMEHOOK_EVENT_READ);
}
More information about the asterisk-commits
mailing list