dont mix ptimes in the codec string lists, just discard conflicting ones
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@15797 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
parent
8faff0e076
commit
b8daa2dc99
|
@ -1414,7 +1414,7 @@ SWITCH_DECLARE(int) switch_loadable_module_get_codecs(const switch_codec_impleme
|
||||||
switch_hash_index_t *hi;
|
switch_hash_index_t *hi;
|
||||||
void *val;
|
void *val;
|
||||||
switch_codec_interface_t *codec_interface;
|
switch_codec_interface_t *codec_interface;
|
||||||
int i = 0;
|
int i = 0, lock = 0;
|
||||||
const switch_codec_implementation_t *imp;
|
const switch_codec_implementation_t *imp;
|
||||||
|
|
||||||
switch_mutex_lock(loadable_modules.mutex);
|
switch_mutex_lock(loadable_modules.mutex);
|
||||||
|
@ -1423,6 +1423,10 @@ SWITCH_DECLARE(int) switch_loadable_module_get_codecs(const switch_codec_impleme
|
||||||
codec_interface = (switch_codec_interface_t *) val;
|
codec_interface = (switch_codec_interface_t *) val;
|
||||||
/* Look for a 20ms implementation because it's the safest choice */
|
/* Look for a 20ms implementation because it's the safest choice */
|
||||||
for (imp = codec_interface->implementations; imp; imp = imp->next) {
|
for (imp = codec_interface->implementations; imp; imp = imp->next) {
|
||||||
|
if (lock && imp->microseconds_per_packet != lock) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (imp->microseconds_per_packet / 1000 == 20) {
|
if (imp->microseconds_per_packet / 1000 == 20) {
|
||||||
array[i++] = imp;
|
array[i++] = imp;
|
||||||
goto found;
|
goto found;
|
||||||
|
@ -1433,6 +1437,8 @@ SWITCH_DECLARE(int) switch_loadable_module_get_codecs(const switch_codec_impleme
|
||||||
|
|
||||||
found:
|
found:
|
||||||
|
|
||||||
|
if (!lock) lock = array[i-1]->microseconds_per_packet;
|
||||||
|
|
||||||
if (i > arraylen) {
|
if (i > arraylen) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1446,7 +1452,7 @@ 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)
|
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;
|
int x, i = 0, lock = 0;
|
||||||
switch_codec_interface_t *codec_interface;
|
switch_codec_interface_t *codec_interface;
|
||||||
const switch_codec_implementation_t *imp;
|
const switch_codec_implementation_t *imp;
|
||||||
|
|
||||||
|
@ -1482,49 +1488,56 @@ SWITCH_DECLARE(int) switch_loadable_module_get_codecs_sorted(const switch_codec_
|
||||||
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 20ms above all else because lots of stuff assumes it */
|
/* If no specific codec interval is requested opt for 20ms 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) {
|
||||||
uint8_t match = 1;
|
|
||||||
|
|
||||||
if (imp->codec_type != SWITCH_CODEC_TYPE_VIDEO) {
|
if (imp->codec_type != SWITCH_CODEC_TYPE_VIDEO) {
|
||||||
|
if (lock && imp->microseconds_per_packet != lock) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if ((!interval && (uint32_t) (imp->microseconds_per_packet / 1000) != 20) ||
|
if ((!interval && (uint32_t) (imp->microseconds_per_packet / 1000) != 20) ||
|
||||||
(interval && (uint32_t) (imp->microseconds_per_packet / 1000) != interval)) {
|
(interval && (uint32_t) (imp->microseconds_per_packet / 1000) != interval)) {
|
||||||
match = 0;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (match && ((!rate && (uint32_t) imp->samples_per_second != 8000) || (rate && (uint32_t) imp->samples_per_second != rate))) {
|
if (((!rate && (uint32_t) imp->samples_per_second != 8000) || (rate && (uint32_t) imp->samples_per_second != rate))) {
|
||||||
match = 0;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (match) {
|
|
||||||
array[i++] = imp;
|
array[i++] = imp;
|
||||||
goto found;
|
goto found;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Either looking for a specific interval or there was no interval specified and there wasn't one @20ms available */
|
/* Either looking for a specific interval or there was no interval specified and there wasn't one @20ms available */
|
||||||
for (imp = codec_interface->implementations; imp; imp = imp->next) {
|
for (imp = codec_interface->implementations; imp; imp = imp->next) {
|
||||||
uint8_t match = 1;
|
|
||||||
|
|
||||||
if (imp->codec_type != SWITCH_CODEC_TYPE_VIDEO) {
|
if (imp->codec_type != SWITCH_CODEC_TYPE_VIDEO) {
|
||||||
|
|
||||||
|
if (lock && imp->microseconds_per_packet != lock) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (interval && (uint32_t) (imp->microseconds_per_packet / 1000) != interval) {
|
if (interval && (uint32_t) (imp->microseconds_per_packet / 1000) != interval) {
|
||||||
match = 0;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (match && rate && (uint32_t) imp->samples_per_second != rate) {
|
if (rate && (uint32_t) imp->samples_per_second != rate) {
|
||||||
match = 0;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (match) {
|
array[i++] = imp;
|
||||||
array[i++] = imp;
|
goto found;
|
||||||
goto found;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
found:
|
found:
|
||||||
|
|
||||||
|
if (!lock) {
|
||||||
|
lock = array[i-1]->microseconds_per_packet;
|
||||||
|
}
|
||||||
|
|
||||||
UNPROTECT_INTERFACE(codec_interface);
|
UNPROTECT_INTERFACE(codec_interface);
|
||||||
|
|
||||||
if (i > arraylen) {
|
if (i > arraylen) {
|
||||||
|
|
Loading…
Reference in New Issue