Major modification in conference bridge to allow ports with different ptime and sampling rate. Also introduced sampling rate converter

git-svn-id: https://svn.pjsip.org/repos/pjproject/trunk@277 74dad513-b988-da41-8d7b-12977e46ad98
diff --git a/pjsip/include/pjsua-lib/pjsua.h b/pjsip/include/pjsua-lib/pjsua.h
index d120a06..1ed8f3a 100644
--- a/pjsip/include/pjsua-lib/pjsua.h
+++ b/pjsip/include/pjsua-lib/pjsua.h
@@ -177,6 +177,7 @@
     /* Media:  */
     int		     start_rtp_port;/**< Start of RTP port to try.	*/
     pjmedia_endpt   *med_endpt;	    /**< Media endpoint.		*/
+    unsigned	     clock_rate;    /**< Internal clock rate.		*/
     pjmedia_conf    *mconf;	    /**< Media conference.		*/
     pj_bool_t	     null_audio;    /**< Null audio flag.		*/
     char	    *wav_file;	    /**< WAV file name to play.		*/
diff --git a/pjsip/src/pjsua-lib/pjsua_core.c b/pjsip/src/pjsua-lib/pjsua_core.c
index 081a3a8..e944ea4 100644
--- a/pjsip/src/pjsua-lib/pjsua_core.c
+++ b/pjsip/src/pjsua-lib/pjsua_core.c
@@ -72,6 +72,9 @@
     /* Default: do not use STUN: */
     pjsua.stun_port1 = pjsua.stun_port2 = 0;
 
+    /* Default: sampling rate is 8000 */
+    pjsua.clock_rate = 8000;
+
     /* Init accounts: */
     pjsua.acc_cnt = 1;
     for (i=0; i<PJ_ARRAY_SIZE(pjsua.acc); ++i) {
@@ -618,7 +621,9 @@
 
     status = pjmedia_conf_create(pjsua.pool, 
 				 pjsua.max_calls+PJSUA_CONF_MORE_PORTS, 
-				 8000, 160, 16, &pjsua.mconf);
+				 pjsua.clock_rate, 
+				 pjsua.clock_rate * 20 / 1000, 16, 
+				 &pjsua.mconf);
     if (status != PJ_SUCCESS) {
 	pj_caching_pool_destroy(&pjsua.cp);
 	pjsua_perror(THIS_FILE, 
diff --git a/pjsip/src/pjsua-lib/pjsua_settings.c b/pjsip/src/pjsua-lib/pjsua_settings.c
index e861f5c..9e1d3ff 100644
--- a/pjsip/src/pjsua-lib/pjsua_settings.c
+++ b/pjsip/src/pjsua-lib/pjsua_settings.c
@@ -83,6 +83,8 @@
     puts("  --use-stun2=host[:port]  Resolve local IP with the specified STUN servers");
     puts("");
     puts("Media Options:");
+    puts("  --wb                Enable wideband codecs (16KHz)");
+    puts("  --uwb               Enable ultra-wideband codecs (32KHz)");
     puts("  --null-audio        Use NULL audio device");
     puts("  --play-file=file    Play WAV file in conference bridge");
     puts("  --auto-play         Automatically play the file (to incoming calls only)");
@@ -218,7 +220,7 @@
 	   OPT_ADD_BUDDY, OPT_OFFER_X_MS_MSG, OPT_NO_PRESENCE,
 	   OPT_AUTO_ANSWER, OPT_AUTO_HANGUP, OPT_AUTO_PLAY, OPT_AUTO_LOOP,
 	   OPT_AUTO_CONF,
-	   OPT_PLAY_FILE, OPT_RTP_PORT,
+	   OPT_PLAY_FILE, OPT_WB, OPT_UWB, OPT_RTP_PORT,
 	   OPT_NEXT_ACCOUNT, OPT_NEXT_CRED, OPT_MAX_CALLS,
     };
     struct option long_options[] = {
@@ -228,6 +230,8 @@
 	{ "app-log-level",1,0,OPT_APP_LOG_LEVEL},
 	{ "help",	0, 0, OPT_HELP},
 	{ "version",	0, 0, OPT_VERSION},
+	{ "wb",		0, 0, OPT_WB},
+	{ "uwb",	0, 0, OPT_UWB},
 	{ "null-audio", 0, 0, OPT_NULL_AUDIO},
 	{ "local-port", 1, 0, OPT_LOCAL_PORT},
 	{ "proxy",	1, 0, OPT_PROXY},
@@ -327,6 +331,14 @@
 	    pjsua.null_audio = 1;
 	    break;
 
+	case OPT_WB:
+	    pjsua.clock_rate = 16000;
+	    break;
+
+	case OPT_UWB:
+	    pjsua.clock_rate = 32000;
+	    break;
+
 	case OPT_LOCAL_PORT:   /* local-port */
 	    lval = pj_strtoul(pj_cstr(&tmp, optarg));
 	    if (lval < 1 || lval > 65535) {