[Asterisk-Dev] Changing Asterisk's module invocation
Juan Jose Comellas
juanjo at comellas.com.ar
Tue Sep 14 14:56:23 MST 2004
I am writing Java bindings for the Asterisk API using SWIG
(http://www.swig.org) so that I can create Asterisk modules written in Java.
The main problem I'm having is that in order to make this process efficient I
need to have more than one application per module (I load only one instance
of the JVM). To be able to build a generic solution (where I don't have to
add one entry point in C per Java application), I need to make a slight
change to the ast_register_application() function and to the code that
invokes each application's callback function. Currently all application
callbacks follow the following prototype:
int (*execute)(struct ast_channel *, void *data);
The problem is that when building Java modules this function acts as a bridge
to the Java invocation and I need extra data to be able to map the call into
a Java class/method. To solve this problem I need to make the following
changes to Asterisk's public interface:
1) Add one argument to the application callback to be able to pass the
"cookie" that will let me map to the Java class/method:
int (*execute)(struct ast_channel *, void *data, void *cookie);
2) Change the ast_app struct to be able to store the "cookie". With my changes
it looks like this:
struct ast_app {
char name[AST_MAX_APP]; /* Name of the application */
int (*execute)(struct ast_channel *chan, void *data, void *cookie);
char *synopsis; /* Synopsis text for 'show applications' */
char *description; /* Description (help text) for 'show application <name>'
*/
void *cookie; /* Data used to map the call when using Java modules */
struct ast_app *next; /* Next app in list */
};
3) Change the ast_register_application() function to pass the cookie to the
ast_app struct:
int ast_register_application(char *app, int (*execute)(struct ast_channel *,
void *data, void *cookie), char *synopsis, char *description, void *cookie);
Do these modifications have any chance of being accepted into Asterisk?
--
Juan Jose Comellas
(juanjo at comellas.com.ar)
More information about the asterisk-dev
mailing list