[svn-commits] dvossel: trunk r287648 - in /trunk: ./ funcs/ include/asterisk/ main/
SVN commits to the Digium repositories
svn-commits at lists.digium.com
Mon Sep 20 17:16:41 CDT 2010
Author: dvossel
Date: Mon Sep 20 17:16:37 2010
New Revision: 287648
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=287648
Log:
Merged revisions 287647 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.8
........
r287647 | dvossel | 2010-09-20 17:09:16 -0500 (Mon, 20 Sep 2010) | 21 lines
Addition of the FrameHook API (AKA AwesomeHooks)
So far all our tools for viewing and manipulating media streams
within Asterisk have been entirely focused on audio. That made
sense then, but is not scalable now. The FrameHook API lets us
tap into and manipulate _ANY_ type of media or signaling passed
on a channel present today or in the future. This tool is a step
in the direction of expanding Asterisk's boundaries and will help
generate some rather interesting applications in the future.
In addition to the FrameHook API, a simple dialplan function
exercising the api has been included as well. This function
is called FRAME_TRACE(). FRAME_TRACE() allows for the internal
ast_frames read and written to a channel to be output. Filters
can be placed on this function to debug only certain types of frames.
This function could be thought of as an internal way of doing
ast_frame packet captures.
Review: https://reviewboard.asterisk.org/r/925/
........
Added:
trunk/funcs/func_frame_trace.c
- copied unchanged from r287647, branches/1.8/funcs/func_frame_trace.c
trunk/include/asterisk/framehook.h
- copied unchanged from r287647, branches/1.8/include/asterisk/framehook.h
trunk/main/framehook.c
- copied unchanged from r287647, branches/1.8/main/framehook.c
Modified:
trunk/ (props changed)
trunk/CHANGES
trunk/include/asterisk/channel.h
trunk/main/channel.c
Propchange: trunk/
------------------------------------------------------------------------------
Binary property 'branch-1.8-merged' - no diff available.
Modified: trunk/CHANGES
URL: http://svnview.digium.com/svn/asterisk/trunk/CHANGES?view=diff&rev=287648&r1=287647&r2=287648
==============================================================================
--- trunk/CHANGES (original)
+++ trunk/CHANGES Mon Sep 20 17:16:37 2010
@@ -250,6 +250,7 @@
allows for high resolution times for billsec and duration fields.
* FILE() now supports line-mode and writing.
* Added FIELDNUM(), which returns the 1-based offset of a field in a list.
+ * FRAME_TRACE(), for tracking internal ast_frames on a channel.
Dialplan Variables
------------------
Modified: trunk/include/asterisk/channel.h
URL: http://svnview.digium.com/svn/asterisk/trunk/include/asterisk/channel.h?view=diff&rev=287648&r1=287647&r2=287648
==============================================================================
--- trunk/include/asterisk/channel.h (original)
+++ trunk/include/asterisk/channel.h Mon Sep 20 17:16:37 2010
@@ -151,6 +151,7 @@
#include "asterisk/data.h"
#include "asterisk/channelstate.h"
#include "asterisk/ccss.h"
+#include "asterisk/framehook.h"
#define DATASTORE_INHERIT_FOREVER INT_MAX
@@ -752,6 +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_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: trunk/main/channel.c
URL: http://svnview.digium.com/svn/asterisk/trunk/main/channel.c?view=diff&rev=287648&r1=287647&r2=287648
==============================================================================
--- trunk/main/channel.c (original)
+++ trunk/main/channel.c Mon Sep 20 17:16:37 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,6 +2634,8 @@
chan->audiohooks = NULL;
}
+ ast_framehook_list_destroy(chan);
+
ast_autoservice_stop(chan);
if (chan->masq) {
@@ -3749,6 +3752,10 @@
* easily detect when ast_read() is called without properly using ast_waitfor().
*/
chan->fdno = -1;
+
+ /* 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_framehook_list_read_event(chan->framehooks, f);
if (f) {
struct ast_frame *readq_tail = AST_LIST_LAST(&chan->readq);
@@ -4143,14 +4150,42 @@
enum ast_control_frame_type condition = _condition;
struct ast_tone_zone_sound *ts = NULL;
int res;
+ /* 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);
/* Don't bother if the channel is about to go away, anyway. */
if (ast_test_flag(chan, AST_FLAG_ZOMBIE) || ast_check_hangup(chan)) {
ast_channel_unlock(chan);
- return -1;
- }
+ res = -1;
+ goto indicate_cleanup;
+ }
+
+ 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,
+ .data.ptr = (void *) data, /* this cast from const is only okay because we do the ast_frdup below */
+ .datalen = datalen
+ };
+
+ /* we have now committed to freeing this frame */
+ awesome_frame = ast_frdup(&frame);
+
+ /* who knows what we will get back! the anticipation is killing me. */
+ if (!(awesome_frame = ast_framehook_list_read_event(chan->framehooks, &frame))) {
+ ast_channel_unlock(chan);
+ res = 0;
+ goto indicate_cleanup;
+ }
+
+ condition = awesome_frame->subclass.integer;
+ data = awesome_frame->data.ptr;
+ datalen = awesome_frame->datalen;
+ }
+
switch (condition) {
case AST_CONTROL_CONNECTED_LINE:
{
@@ -4196,7 +4231,8 @@
if (is_visible_indication(condition)) {
chan->visible_indication = condition;
}
- return 0;
+ res = 0;
+ goto indicate_cleanup;
}
/* The channel driver does not support this indication, let's fake
@@ -4208,14 +4244,16 @@
if (_condition < 0) {
/* Stop any tones that are playing */
ast_playtones_stop(chan);
- return 0;
+ res = 0;
+ goto indicate_cleanup;
}
/* Handle conditions that we have tones for. */
switch (condition) {
case _XXX_AST_CONTROL_T38:
/* deprecated T.38 control frame */
- return -1;
+ res = -1;
+ goto indicate_cleanup;
case AST_CONTROL_T38_PARAMETERS:
/* there is no way to provide 'default' behavior for these
* control frames, so we need to return failure, but there
@@ -4224,7 +4262,7 @@
* so just return right now. in addition, we want to return
* whatever value the channel driver returned, in case it
* has some meaning.*/
- return res;
+ goto indicate_cleanup;
case AST_CONTROL_RINGING:
ts = ast_get_indication_tone(chan->zone, "ring");
/* It is common practice for channel drivers to return -1 if trying
@@ -4286,6 +4324,11 @@
ast_log(LOG_WARNING, "Unable to handle indication %d for '%s'\n", condition, chan->name);
}
+indicate_cleanup:
+ if (awesome_frame) {
+ ast_frfree(awesome_frame);
+ }
+
return res;
}
@@ -4572,6 +4615,14 @@
res = 0; /* XXX explain, why 0 ? */
goto done;
}
+
+ /* 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_framehook_list_write_event(chan->framehooks, fr))) {
+ res = 0;
+ goto done;
+ }
+
if (chan->generatordata && (!fr->src || strcasecmp(fr->src, "ast_prod"))) {
if (ast_test_flag(chan, AST_FLAG_WRITE_INT)) {
ast_deactivate_generator(chan);
More information about the svn-commits
mailing list