mirror of
https://github.com/signalwire/freeswitch.git
synced 2026-10-30 07:04:17 +00:00
refactor export code and add new bridge_export app which is like export but exports across when one channel bridges another
This commit is contained in:
1 parent
ecf4e9abcc
commit
4aa9a83898
6 files changed
+147
-96
No files matched your search
@@ -909,48 +909,42 @@ SWITCH_STANDARD_APP(set_profile_var_function)
|
||||
SWITCH_STANDARD_APP(export_function)
|
||||
{
|
||||
switch_channel_t *channel = switch_core_session_get_channel(session);
|
||||
const char *exports;
|
||||
char *new_exports = NULL, *new_exports_d = NULL, *var, *val = NULL, *var_name = NULL;
|
||||
int local = 1;
|
||||
char *var, *val = NULL;
|
||||
|
||||
if (zstr(data)) {
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "No variable name specified.\n");
|
||||
} else {
|
||||
exports = switch_channel_get_variable(channel, SWITCH_EXPORT_VARS_VARIABLE);
|
||||
var = switch_core_session_strdup(session, data);
|
||||
if (var) {
|
||||
val = strchr(var, '=');
|
||||
if (!strncasecmp(var, "nolocal:", 8)) {
|
||||
var_name = var + 8;
|
||||
local = 0;
|
||||
} else {
|
||||
var_name = var;
|
||||
}
|
||||
}
|
||||
|
||||
if (val) {
|
||||
if ((val = strchr(var, '='))) {
|
||||
*val++ = '\0';
|
||||
if (zstr(val)) {
|
||||
val = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "EXPORT %s[%s]=[%s]\n", local ? "" : "(REMOTE ONLY) ",
|
||||
var_name ? var_name : "", val ? val : "UNDEF");
|
||||
switch_channel_set_variable(channel, var, val);
|
||||
switch_channel_export_variable(channel, var, val, SWITCH_EXPORT_VARS_VARIABLE);
|
||||
}
|
||||
}
|
||||
|
||||
if (var && val) {
|
||||
if (exports) {
|
||||
new_exports_d = switch_mprintf("%s,%s", exports, var);
|
||||
new_exports = new_exports_d;
|
||||
} else {
|
||||
new_exports = var;
|
||||
SWITCH_STANDARD_APP(bridge_export_function)
|
||||
{
|
||||
switch_channel_t *channel = switch_core_session_get_channel(session);
|
||||
char *var, *val = NULL;
|
||||
|
||||
if (zstr(data)) {
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "No variable name specified.\n");
|
||||
} else {
|
||||
var = switch_core_session_strdup(session, data);
|
||||
|
||||
if ((val = strchr(var, '='))) {
|
||||
*val++ = '\0';
|
||||
if (zstr(val)) {
|
||||
val = NULL;
|
||||
}
|
||||
|
||||
switch_channel_set_variable(channel, SWITCH_EXPORT_VARS_VARIABLE, new_exports);
|
||||
|
||||
switch_safe_free(new_exports_d);
|
||||
}
|
||||
|
||||
switch_channel_export_variable(channel, var, val, SWITCH_BRIDGE_EXPORT_VARS_VARIABLE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3317,6 +3311,8 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_dptools_load)
|
||||
SWITCH_ADD_APP(app_interface, "sound_test", "Analyze Audio", "Analyze Audio", sound_test_function, "", SAF_NONE);
|
||||
SWITCH_ADD_APP(app_interface, "export", "Export a channel variable across a bridge", EXPORT_LONG_DESC, export_function, "<varname>=<value>",
|
||||
SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC);
|
||||
SWITCH_ADD_APP(app_interface, "bridge_export", "Export a channel variable across a bridge", EXPORT_LONG_DESC, bridge_export_function, "<varname>=<value>",
|
||||
SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC);
|
||||
SWITCH_ADD_APP(app_interface, "set", "Set a channel variable", SET_LONG_DESC, set_function, "<varname>=<value>",
|
||||
SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC);
|
||||
SWITCH_ADD_APP(app_interface, "set_global", "Set a global variable", SET_GLOBAL_LONG_DESC, set_global_function, "<varname>=<value>",
|
||||
|
||||
Reference in new issue
Block a user