add configuration to mod_shout to resolve some crazyness, also commit #10,000 if I only had a dollar for each one.....
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@10000 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
parent
4c44541e40
commit
493bd6a5ba
|
@ -0,0 +1,8 @@
|
||||||
|
<configuration name="shout.conf" description="mod shout config">
|
||||||
|
<settings>
|
||||||
|
<!-- Don't change these unless you are insane -->
|
||||||
|
<!--<param name="decoder" value="i586"/>-->
|
||||||
|
<!--<param name="volume" value=".1"/>-->
|
||||||
|
<!--<param name="outscale" value="8192"/>-->
|
||||||
|
</settings>
|
||||||
|
</configuration>
|
|
@ -47,12 +47,32 @@ SWITCH_MODULE_DEFINITION(mod_shout, mod_shout_load, mod_shout_shutdown, NULL);
|
||||||
|
|
||||||
static char *supported_formats[SWITCH_MAX_CODECS] = { 0 };
|
static char *supported_formats[SWITCH_MAX_CODECS] = { 0 };
|
||||||
|
|
||||||
|
static struct {
|
||||||
|
char decoder[256];
|
||||||
|
float vol;
|
||||||
|
uint32_t outscale;
|
||||||
|
} globals;
|
||||||
|
|
||||||
mpg123_handle *our_mpg123_new(const char* decoder, int *error)
|
mpg123_handle *our_mpg123_new(const char* decoder, int *error)
|
||||||
{
|
{
|
||||||
mpg123_handle *mh;
|
mpg123_handle *mh;
|
||||||
const char *arch = "auto";
|
const char *arch = "auto";
|
||||||
int x64 = 0;
|
int x64 = 0;
|
||||||
|
|
||||||
|
if (*globals.decoder || globals.outscale || globals.vol) {
|
||||||
|
if (*globals.decoder) {
|
||||||
|
arch = globals.decoder;
|
||||||
|
}
|
||||||
|
if ((mh = mpg123_new(arch, NULL))) {
|
||||||
|
if (globals.outscale) {
|
||||||
|
mpg123_param(mh, MPG123_OUTSCALE, globals.outscale, 0);
|
||||||
|
}
|
||||||
|
if (globals.vol) {
|
||||||
|
mpg123_volume(mh, globals.vol);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
|
||||||
if (sizeof(void *) == 4) {
|
if (sizeof(void *) == 4) {
|
||||||
arch = "i586";
|
arch = "i586";
|
||||||
} else {
|
} else {
|
||||||
|
@ -64,6 +84,7 @@ mpg123_handle *our_mpg123_new(const char* decoder, int *error)
|
||||||
mpg123_param(mh, MPG123_OUTSCALE, 8192, 0);
|
mpg123_param(mh, MPG123_OUTSCALE, 8192, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return mh;
|
return mh;
|
||||||
}
|
}
|
||||||
|
@ -1391,6 +1412,42 @@ SWITCH_STANDARD_API(telecast_api_function)
|
||||||
return SWITCH_STATUS_SUCCESS;
|
return SWITCH_STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static switch_status_t load_config(void)
|
||||||
|
{
|
||||||
|
char *cf = "shout.conf";
|
||||||
|
switch_xml_t cfg, xml, settings, param;
|
||||||
|
|
||||||
|
memset(&globals, 0, sizeof(globals));
|
||||||
|
|
||||||
|
if (!(xml = switch_xml_open_cfg(cf, &cfg, NULL))) {
|
||||||
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Open of %s failed\n", cf);
|
||||||
|
return SWITCH_STATUS_TERM;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((settings = switch_xml_child(cfg, "settings"))) {
|
||||||
|
for (param = switch_xml_child(settings, "param"); param; param = param->next) {
|
||||||
|
char *var = (char *) switch_xml_attr_soft(param, "name");
|
||||||
|
char *val = (char *) switch_xml_attr_soft(param, "value");
|
||||||
|
|
||||||
|
if (!strcmp(var, "decoder")) {
|
||||||
|
switch_set_string(globals.decoder, val);
|
||||||
|
} else if (!strcmp(var, "volume")) {
|
||||||
|
globals.vol = atof(val);
|
||||||
|
} else if (!strcmp(var, "outscale")) {
|
||||||
|
int tmp = atoi(val);
|
||||||
|
if (tmp > 0) {
|
||||||
|
globals.outscale = tmp;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
switch_xml_free(xml);
|
||||||
|
|
||||||
|
return SWITCH_STATUS_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
SWITCH_MODULE_LOAD_FUNCTION(mod_shout_load)
|
SWITCH_MODULE_LOAD_FUNCTION(mod_shout_load)
|
||||||
{
|
{
|
||||||
switch_api_interface_t *shout_api_interface;
|
switch_api_interface_t *shout_api_interface;
|
||||||
|
@ -1421,6 +1478,8 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_shout_load)
|
||||||
|
|
||||||
SWITCH_ADD_API(shout_api_interface, "telecast", "telecast", telecast_api_function, TELECAST_SYNTAX);
|
SWITCH_ADD_API(shout_api_interface, "telecast", "telecast", telecast_api_function, TELECAST_SYNTAX);
|
||||||
|
|
||||||
|
load_config();
|
||||||
|
|
||||||
/* indicate that the module should continue to be loaded */
|
/* indicate that the module should continue to be loaded */
|
||||||
return SWITCH_STATUS_SUCCESS;
|
return SWITCH_STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue