mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-05-01 22:33:48 +00:00
FS-4135 --resolve
This commit is contained in:
parent
845639025c
commit
c6aaa281f1
@ -2075,25 +2075,10 @@ SWITCH_DECLARE(int) switch_loadable_module_get_codecs(const switch_codec_impleme
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SWITCH_DECLARE(int) switch_loadable_module_get_codecs_sorted(const switch_codec_implementation_t **array, int arraylen, char **prefs, int preflen)
|
char *parse_codec_buf(char *buf, uint32_t *interval, uint32_t *rate, uint32_t *bit)
|
||||||
{
|
{
|
||||||
int x, i = 0, j = 0;
|
char *cur, *next = NULL, *name, *p;
|
||||||
switch_codec_interface_t *codec_interface;
|
|
||||||
const switch_codec_implementation_t *imp;
|
|
||||||
|
|
||||||
switch_mutex_lock(loadable_modules.mutex);
|
|
||||||
|
|
||||||
for (x = 0; x < preflen; x++) {
|
|
||||||
char *cur, *next = NULL, *name, *p, buf[256];
|
|
||||||
uint32_t interval = 0, rate = 0, bit = 0;
|
|
||||||
|
|
||||||
for(j = 0; j < x; j++) {
|
|
||||||
if (!strcasecmp(prefs[j], prefs[x])) {
|
|
||||||
goto next_x;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
switch_copy_string(buf, prefs[x], sizeof(buf));
|
|
||||||
name = next = cur = buf;
|
name = next = cur = buf;
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
@ -2108,16 +2093,63 @@ SWITCH_DECLARE(int) switch_loadable_module_get_codecs_sorted(const switch_codec_
|
|||||||
|
|
||||||
if (cur != name) {
|
if (cur != name) {
|
||||||
if (strchr(cur, 'i')) {
|
if (strchr(cur, 'i')) {
|
||||||
interval = atoi(cur);
|
*interval = atoi(cur);
|
||||||
} else if ((strchr(cur, 'k') || strchr(cur, 'h'))) {
|
} else if ((strchr(cur, 'k') || strchr(cur, 'h'))) {
|
||||||
rate = atoi(cur);
|
*rate = atoi(cur);
|
||||||
} else if (strchr(cur, 'b')) {
|
} else if (strchr(cur, 'b')) {
|
||||||
bit = atoi(cur);
|
*bit = atoi(cur);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
cur = next;
|
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)
|
||||||
|
{
|
||||||
|
int x, i = 0, j = 0;
|
||||||
|
switch_codec_interface_t *codec_interface;
|
||||||
|
const switch_codec_implementation_t *imp;
|
||||||
|
|
||||||
|
switch_mutex_lock(loadable_modules.mutex);
|
||||||
|
|
||||||
|
for (x = 0; x < preflen; x++) {
|
||||||
|
char *name, buf[256], jbuf[256];
|
||||||
|
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++) {
|
||||||
|
char *jname;
|
||||||
|
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(jbuf, prefs[j], sizeof(jbuf));
|
||||||
|
jname = parse_codec_buf(jbuf, &jinterval, &jrate, &jbit);
|
||||||
|
|
||||||
|
if (jinterval == 0) {
|
||||||
|
jinterval = switch_default_ptime(jname, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (jrate == 0) {
|
||||||
|
jrate = 8000;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!strcasecmp(name, jname) && ointerval == jinterval && orate == jrate) {
|
||||||
|
goto next_x;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ((codec_interface = switch_loadable_module_get_codec_interface(name)) != 0) {
|
if ((codec_interface = switch_loadable_module_get_codec_interface(name)) != 0) {
|
||||||
/* If no specific codec interval is requested opt for the default above all else because lots of stuff assumes it */
|
/* If no specific codec interval is requested opt for the default above all else because lots of stuff assumes it */
|
||||||
for (imp = codec_interface->implementations; imp; imp = imp->next) {
|
for (imp = codec_interface->implementations; imp; imp = imp->next) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user