提交 c6aaa281 authored 作者: Anthony Minessale's avatar Anthony Minessale

FS-4135 --resolve

上级 84563902
...@@ -2075,6 +2075,37 @@ SWITCH_DECLARE(int) switch_loadable_module_get_codecs(const switch_codec_impleme ...@@ -2075,6 +2075,37 @@ SWITCH_DECLARE(int) switch_loadable_module_get_codecs(const switch_codec_impleme
} }
char *parse_codec_buf(char *buf, uint32_t *interval, uint32_t *rate, uint32_t *bit)
{
char *cur, *next = NULL, *name, *p;
name = next = cur = buf;
for (;;) {
if (!next) {
break;
}
if ((p = strchr(next, '@'))) {
*p++ = '\0';
}
next = p;
if (cur != name) {
if (strchr(cur, 'i')) {
*interval = atoi(cur);
} else if ((strchr(cur, 'k') || strchr(cur, 'h'))) {
*rate = atoi(cur);
} else if (strchr(cur, 'b')) {
*bit = atoi(cur);
}
}
cur = next;
}
return name;
}
SWITCH_DECLARE(int) switch_loadable_module_get_codecs_sorted(const switch_codec_implementation_t **array, int arraylen, char **prefs, int preflen) SWITCH_DECLARE(int) switch_loadable_module_get_codecs_sorted(const switch_codec_implementation_t **array, int arraylen, char **prefs, int preflen)
{ {
int x, i = 0, j = 0; int x, i = 0, j = 0;
...@@ -2084,38 +2115,39 @@ SWITCH_DECLARE(int) switch_loadable_module_get_codecs_sorted(const switch_codec_ ...@@ -2084,38 +2115,39 @@ SWITCH_DECLARE(int) switch_loadable_module_get_codecs_sorted(const switch_codec_
switch_mutex_lock(loadable_modules.mutex); switch_mutex_lock(loadable_modules.mutex);
for (x = 0; x < preflen; x++) { for (x = 0; x < preflen; x++) {
char *cur, *next = NULL, *name, *p, buf[256]; char *name, buf[256], jbuf[256];
uint32_t interval = 0, rate = 0, bit = 0; uint32_t interval = 0, rate = 0, bit = 0;
switch_copy_string(buf, prefs[x], sizeof(buf));
name = parse_codec_buf(buf, &interval, &rate, &bit);
for(j = 0; j < x; j++) { for(j = 0; j < x; j++) {
if (!strcasecmp(prefs[j], prefs[x])) { char *jname;
goto next_x; uint32_t jinterval = 0, jrate = 0, jbit = 0;
uint32_t ointerval = interval, orate = rate, obit = bit;
if (ointerval == 0) {
ointerval = switch_default_ptime(name, 0);
}
if (orate == 0) {
orate = 8000;
} }
}
switch_copy_string(buf, prefs[x], sizeof(buf)); switch_copy_string(jbuf, prefs[j], sizeof(jbuf));
name = next = cur = buf; jname = parse_codec_buf(jbuf, &jinterval, &jrate, &jbit);
for (;;) { if (jinterval == 0) {
if (!next) { jinterval = switch_default_ptime(jname, 0);
break;
} }
if ((p = strchr(next, '@'))) { if (jrate == 0) {
*p++ = '\0'; jrate = 8000;
} }
next = p;
if (!strcasecmp(name, jname) && ointerval == jinterval && orate == jrate) {
if (cur != name) { goto next_x;
if (strchr(cur, 'i')) {
interval = atoi(cur);
} else if ((strchr(cur, 'k') || strchr(cur, 'h'))) {
rate = atoi(cur);
} else if (strchr(cur, 'b')) {
bit = atoi(cur);
}
} }
cur = next;
} }
if ((codec_interface = switch_loadable_module_get_codec_interface(name)) != 0) { if ((codec_interface = switch_loadable_module_get_codec_interface(name)) != 0) {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论