summaryrefslogtreecommitdiff
path: root/pjsip
diff options
context:
space:
mode:
authorBenny Prijono <bennylp@teluu.com>2006-10-11 21:56:16 +0000
committerBenny Prijono <bennylp@teluu.com>2006-10-11 21:56:16 +0000
commitec897ae3d61a3bc9b524c35a8f4cc427e6c4b79e (patch)
tree47888a79546bc01a457fc76ee8a9b133a3c6c60b /pjsip
parent9cd36ebc6af0b60926882769b8d5ee3bc455a562 (diff)
Fixed bug in pjsua_media.c: when sound device is created with different sampling rate than the clock rate configuration, resampling port needs to be created.
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@765 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'pjsip')
-rw-r--r--pjsip/src/pjsua-lib/pjsua_media.c24
1 files changed, 22 insertions, 2 deletions
diff --git a/pjsip/src/pjsua-lib/pjsua_media.c b/pjsip/src/pjsua-lib/pjsua_media.c
index fabd08ca..63527f71 100644
--- a/pjsip/src/pjsua-lib/pjsua_media.c
+++ b/pjsip/src/pjsua-lib/pjsua_media.c
@@ -970,6 +970,7 @@ PJ_DEF(pj_status_t) pjsua_set_snd_dev( int capture_dev,
pjmedia_port *conf_port;
const pjmedia_snd_dev_info *cap_info, *play_info;
unsigned clock_rates[] = { 0, 22050, 44100, 48000, 11025, 32000, 8000};
+ unsigned selected_clock_rate = 0;
unsigned i;
pj_status_t status = -1;
@@ -998,11 +999,13 @@ PJ_DEF(pj_status_t) pjsua_set_snd_dev( int capture_dev,
clock_rates[i]/FPS,
16, 0, &pjsua_var.snd_port);
- if (status == PJ_SUCCESS)
+ if (status == PJ_SUCCESS) {
+ selected_clock_rate = clock_rates[i];
break;
+ }
pj_strerror(status, errmsg, sizeof(errmsg));
- PJ_LOG(4, ("..failed: %s", errmsg));
+ PJ_LOG(4, (THIS_FILE, "..failed: %s", errmsg));
}
if (status != PJ_SUCCESS) {
@@ -1019,6 +1022,23 @@ PJ_DEF(pj_status_t) pjsua_set_snd_dev( int capture_dev,
pjsua_var.media_cfg.ec_tail_len,
pjsua_var.media_cfg.ec_options);
+ /* If there's mismatch between sound port and conference's port,
+ * create a resample port to bridge them.
+ */
+ if (selected_clock_rate != pjsua_var.media_cfg.clock_rate) {
+ pjmedia_port *resample_port;
+
+ status = pjmedia_resample_port_create(pjsua_var.pool, conf_port,
+ selected_clock_rate, 0,
+ &resample_port);
+ if (status != PJ_SUCCESS) {
+ pjsua_perror("Error creating resample port", THIS_FILE, status);
+ return status;
+ }
+
+ conf_port = resample_port;
+ }
+
/* Connect sound port to the bridge */
status = pjmedia_snd_port_connect(pjsua_var.snd_port,
conf_port );