diff options
author | Nanang Izzuddin <nanang@teluu.com> | 2009-06-30 15:02:06 +0000 |
---|---|---|
committer | Nanang Izzuddin <nanang@teluu.com> | 2009-06-30 15:02:06 +0000 |
commit | 5b976613819b6e2eb8c84fcf419633b33709f9ed (patch) | |
tree | 3cbffcb9761e36284f6575edbc1f4341038a0eea /pjsip/src/pjsua-lib | |
parent | aa4f1f0840c92cc5af96be965099a6b7b1b1448b (diff) |
Ticket #910:
- Added a new API pjmedia_codec_passthrough_init2().
- Updated the initialization steps of passthrough codec in pjsua_media.c, to configure the codecs (of passthrough codec) to be enabled based on audio device extended/encoded formats.
- Minor update: added passthrough.h into pjmedia_codec.vcproj.
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@2825 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'pjsip/src/pjsua-lib')
-rw-r--r-- | pjsip/src/pjsua-lib/pjsua_media.c | 54 |
1 files changed, 49 insertions, 5 deletions
diff --git a/pjsip/src/pjsua-lib/pjsua_media.c b/pjsip/src/pjsua-lib/pjsua_media.c index 5496df9f..edf13ba3 100644 --- a/pjsip/src/pjsua-lib/pjsua_media.c +++ b/pjsip/src/pjsua-lib/pjsua_media.c @@ -194,11 +194,55 @@ pj_status_t pjsua_media_subsys_init(const pjsua_media_config *cfg) #if PJMEDIA_HAS_PASSTHROUGH_CODECS /* Register passthrough codecs */ - status = pjmedia_codec_passthrough_init(pjsua_var.med_endpt); - if (status != PJ_SUCCESS) { - pjsua_perror(THIS_FILE, "Error initializing passthrough codecs", - status); - return status; + { + unsigned aud_idx; + unsigned ext_fmt_cnt = 0; + pjmedia_format ext_fmts[32]; + pjmedia_codec_passthrough_setting setting; + + /* List extended formats supported by audio devices */ + for (aud_idx = 0; aud_idx < pjmedia_aud_dev_count(); ++aud_idx) { + pjmedia_aud_dev_info aud_info; + unsigned i; + + status = pjmedia_aud_dev_get_info(aud_idx, &aud_info); + if (status != PJ_SUCCESS) { + pjsua_perror(THIS_FILE, "Error querying audio device info", + status); + return status; + } + + /* Collect extended formats supported by this audio device */ + for (i = 0; i < aud_info.ext_fmt_cnt; ++i) { + unsigned j; + pj_bool_t is_listed = PJ_FALSE; + + /* See if this extended format is already in the list */ + for (j = 0; j < ext_fmt_cnt && !is_listed; ++j) { + if (ext_fmts[j].id == aud_info.ext_fmt[i].id && + ext_fmts[j].bitrate == aud_info.ext_fmt[i].bitrate) + { + is_listed = PJ_TRUE; + } + } + + /* Put this format into the list, if it is not in the list */ + if (!is_listed) + ext_fmts[ext_fmt_cnt++] = aud_info.ext_fmt[i]; + + pj_assert(ext_fmt_cnt <= PJ_ARRAY_SIZE(ext_fmts)); + } + } + + /* Init the passthrough codec with supported formats only */ + setting.fmt_cnt = ext_fmt_cnt; + setting.fmts = ext_fmts; + status = pjmedia_codec_passthrough_init2(pjsua_var.med_endpt, &setting); + if (status != PJ_SUCCESS) { + pjsua_perror(THIS_FILE, "Error initializing passthrough codecs", + status); + return status; + } } #endif /* PJMEDIA_HAS_PASSTHROUGH_CODECS */ |