fix default ptime for iLBC and make new configurable global map in switch.conf.xml
This commit is contained in:
parent
fdba0e07fa
commit
e3c427ad28
|
@ -15,6 +15,11 @@
|
|||
<key name="12" value="version"/>
|
||||
</cli-keybindings>
|
||||
|
||||
<default-ptimes>
|
||||
<!-- set this to overide the 20ms assumption of various codecs in the sdp with no ptime defined -->
|
||||
<!--<codec name="G729" ptime="40"/>-->
|
||||
</default-ptimes>
|
||||
|
||||
<settings>
|
||||
<!--Colorize the Console -->
|
||||
<param name="colorize-console" value="true"/>
|
||||
|
|
|
@ -199,6 +199,7 @@ struct switch_runtime {
|
|||
int64_t offset;
|
||||
switch_event_t *global_vars;
|
||||
switch_hash_t *mime_types;
|
||||
switch_hash_t *ptimes;
|
||||
switch_memory_pool_t *memory_pool;
|
||||
const switch_state_handler_table_t *state_handlers[SWITCH_MAX_STATE_HANDLERS];
|
||||
int state_handler_index;
|
||||
|
|
|
@ -2168,6 +2168,7 @@ SWITCH_DECLARE(uint32_t) switch_core_debug_level(void);
|
|||
SWITCH_DECLARE(void) switch_cache_db_flush_handles(void);
|
||||
SWITCH_DECLARE(const char *) switch_core_banner(void);
|
||||
SWITCH_DECLARE(switch_bool_t) switch_core_session_in_thread(switch_core_session_t *session);
|
||||
SWITCH_DECLARE(uint32_t) switch_default_ptime(const char *name, uint32_t number);
|
||||
|
||||
SWITCH_END_EXTERN_C
|
||||
#endif
|
||||
|
|
|
@ -376,15 +376,6 @@ switch_mutex_unlock(obj->flag_mutex);
|
|||
#define switch_set_string(_dst, _src) switch_copy_string(_dst, _src, sizeof(_dst))
|
||||
|
||||
|
||||
static inline uint32_t switch_default_ptime(const char *name, uint32_t number)
|
||||
{
|
||||
if (!strcasecmp(name, "G723")) {
|
||||
return 30;
|
||||
}
|
||||
|
||||
return 20;
|
||||
}
|
||||
|
||||
static inline char *switch_sanitize_number(char *number)
|
||||
{
|
||||
char *p = number, *q;
|
||||
|
|
|
@ -1275,6 +1275,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_init(switch_core_flag_t flags, switc
|
|||
switch_core_session_init(runtime.memory_pool);
|
||||
switch_event_create_plain(&runtime.global_vars, SWITCH_EVENT_CHANNEL_DATA);
|
||||
switch_core_hash_init(&runtime.mime_types, runtime.memory_pool);
|
||||
switch_core_hash_init_case(&runtime.ptimes, runtime.memory_pool, SWITCH_FALSE);
|
||||
load_mime_types();
|
||||
runtime.flags |= flags;
|
||||
runtime.sps_total = 30;
|
||||
|
@ -1405,13 +1406,58 @@ static void handle_SIGHUP(int sig)
|
|||
}
|
||||
|
||||
|
||||
SWITCH_DECLARE(uint32_t) switch_default_ptime(const char *name, uint32_t number)
|
||||
{
|
||||
uint32_t *p;
|
||||
|
||||
if ((p = switch_core_hash_find(runtime.ptimes, name))) {
|
||||
return *p;
|
||||
}
|
||||
|
||||
return 20;
|
||||
}
|
||||
|
||||
static uint32_t d_30 = 30;
|
||||
|
||||
static void switch_load_core_config(const char *file)
|
||||
{
|
||||
switch_xml_t xml = NULL, cfg = NULL;
|
||||
|
||||
switch_core_hash_insert(runtime.ptimes, "ilbc", &d_30);
|
||||
switch_core_hash_insert(runtime.ptimes, "G723", &d_30);
|
||||
|
||||
|
||||
|
||||
if ((xml = switch_xml_open_cfg(file, &cfg, NULL))) {
|
||||
switch_xml_t settings, param;
|
||||
|
||||
if ((settings = switch_xml_child(cfg, "default-ptimes"))) {
|
||||
for (param = switch_xml_child(settings, "codec"); param; param = param->next) {
|
||||
const char *var = switch_xml_attr_soft(param, "name");
|
||||
const char *val = switch_xml_attr_soft(param, "ptime");
|
||||
|
||||
if (!zstr(var) && !zstr(val)) {
|
||||
uint32_t *p;
|
||||
uint32_t v = (unsigned long) atol(val);
|
||||
|
||||
if (!strcasecmp(var, "G723") || !strcasecmp(var, "iLBC")) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Error adding %s, defaults cannot be changed\n", var);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (v < 0) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Error adding %s, invalid ptime\n", var);
|
||||
continue;
|
||||
}
|
||||
|
||||
p = switch_core_alloc(runtime.memory_pool, sizeof(*p));
|
||||
*p = v;
|
||||
switch_core_hash_insert(runtime.ptimes, var, p);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if ((settings = switch_xml_child(cfg, "settings"))) {
|
||||
for (param = switch_xml_child(settings, "param"); param; param = param->next) {
|
||||
const char *var = switch_xml_attr_soft(param, "name");
|
||||
|
@ -1973,6 +2019,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_destroy(void)
|
|||
switch_safe_free(SWITCH_GLOBAL_dirs.temp_dir);
|
||||
|
||||
switch_event_destroy(&runtime.global_vars);
|
||||
switch_core_hash_destroy(&runtime.ptimes);
|
||||
switch_core_hash_destroy(&runtime.mime_types);
|
||||
|
||||
if (IP_LIST.hash) {
|
||||
|
|
Loading…
Reference in New Issue