[Asterisk-Users] finding current codec?
Mike Tkachuk
tkachuk at gmail.com
Mon Jan 3 07:11:11 MST 2005
/*
* Asterisk -- A telephony toolkit for Linux.
*
* SET CODECUSED Channel variable to codec name.
*
* Mike Tkachuk <mike at ukr.net>
*
* This program is free software, distributed under the terms of
* the GNU General Public License
*
* Mark Spencer have original rights
*
* Should I mail something to digium? ;)
*/
#include <asterisk/lock.h>
#include <asterisk/file.h>
#include <asterisk/logger.h>
#include <asterisk/channel.h>
#include <asterisk/pbx.h>
#include <asterisk/module.h>
#include <asterisk/translate.h>
#include <asterisk/image.h>
#include <asterisk/callerid.h>
#include <asterisk/utils.h>
#include <string.h>
#include <stdlib.h>
static char *synopsis = "Sets CODECUSED variable Application";
static char *tdesc = "This application set's the codec used in current
channel to CODECUSED global vatriable";
static char *desc = " GetCodecName()\n"
"Sets CODECUSED Application. Always returns 0\n";
static char *app = "GetCodecName";
STANDARD_LOCAL_USER;
LOCAL_USER_DECL;
static int get_codec_name(struct ast_channel *chan, void *data)
{
struct localuser *u;
LOCAL_USER_ADD(u);
if (chan){
pbx_builtin_setvar_helper(chan, "CODECUSED",
ast_getformatname(chan ? chan->nativeformats : 0));
}
LOCAL_USER_REMOVE(u);
return 0;
}
int unload_module(void)
{
STANDARD_HANGUP_LOCALUSERS;
return ast_unregister_application(app);
}
int load_module(void)
{
return ast_register_application(app, get_codec_name, synopsis, desc);
}
char *description(void)
{
return tdesc;
}
int usecount(void)
{
int res;
STANDARD_USECOUNT(res);
return res;
}
char *key()
{
return ASTERISK_GPL_KEY;
}
// Save this to app_getcodecname.c, put it to apps directory, edit makefile....
// After calling this function you will get CODECUSED variable filled
with codec name
More information about the asterisk-users
mailing list