tweak codec lookup func

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@10797 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Anthony Minessale 2008-12-16 16:40:38 +00:00
parent 9780f13c39
commit e5b51e3712

View File

@ -1415,7 +1415,7 @@ SWITCH_DECLARE(int) switch_loadable_module_get_codecs_sorted(const switch_codec_
for (x = 0; x < preflen; x++) { for (x = 0; x < preflen; x++) {
char *cur, *last = NULL, *next = NULL, *name, *p, buf[256]; char *cur, *last = NULL, *next = NULL, *name, *p, buf[256];
uint32_t interval = 0, rate = 8000; uint32_t interval = 0, rate = 0;
switch_copy_string(buf, prefs[x], sizeof(buf)); switch_copy_string(buf, prefs[x], sizeof(buf));
last = name = next = cur = buf; last = name = next = cur = buf;
@ -1442,16 +1442,17 @@ 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 */
if (!interval) {
for (imp = codec_interface->implementations; imp; imp = imp->next) { for (imp = codec_interface->implementations; imp; imp = imp->next) {
uint8_t match = 1; uint8_t match = 1;
if (imp->codec_type != SWITCH_CODEC_TYPE_VIDEO) { if (imp->codec_type != SWITCH_CODEC_TYPE_VIDEO) {
if ((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)) {
match = 0; match = 0;
} }
if (match && rate && (uint32_t) imp->samples_per_second != rate) { if (match && ((!rate && (uint32_t) imp->samples_per_second != 8000) || (rate && (uint32_t) imp->samples_per_second != rate))) {
match = 0; match = 0;
} }
} }
@ -1461,13 +1462,13 @@ SWITCH_DECLARE(int) switch_loadable_module_get_codecs_sorted(const switch_codec_
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; uint8_t match = 1;
if (imp->codec_type != SWITCH_CODEC_TYPE_VIDEO) { if (imp->codec_type != SWITCH_CODEC_TYPE_VIDEO) {
if (interval && (uint32_t) (imp->microseconds_per_packet / 1000) != interval) { if (interval && (uint32_t) (imp->microseconds_per_packet / 1000) != interval) {
match = 0; match = 0;
} }