Index: pjproject/trunk/pjsip-apps/src/samples/confsample.c
===================================================================
--- pjproject/trunk/pjsip-apps/src/samples/confsample.c	(revision 342)
+++ pjproject/trunk/pjsip-apps/src/samples/confsample.c	(revision 343)
@@ -20,32 +20,31 @@
 #include <pjmedia.h>
 
-/*
- * FILE:
- *
- *  confsample.c
- *
- * PURPOSE:
- *
- *  Demonstrate how to use conference bridge.
- *
- * USAGE:
- *
- *  confsample [file1.wav] [file2.wav] ...
- *
- * where:
- *  fileN.wav are optional WAV files to be connected to the conference
- *  bridge. The WAV files MUST have single channel (mono) and 16 bit PCM
- *  samples. It can have arbitrary sampling rate.
- *
- * DESCRIPTION:
- *
- *  Here we create a conference bridge, with at least one port (port zero
- *  is always created for the sound device).
- *
- *  If WAV files are specified, the WAV file player ports will be connected
- *  to slot starting from number one in the bridge. The WAV files can have 
- *  arbitrary sampling rate; the bridge will convert it to its clock rate. 
- *  However, the files MUST have a single audio channel only (i.e. mono).
- */
+static const char *desc = 
+ " FILE:								    \n"
+ "									    \n"
+ "  confsample.c							    \n"
+ "									    \n"
+ " PURPOSE:								    \n"
+ "									    \n"
+ "  Demonstrate how to use conference bridge.				    \n"
+ "									    \n"
+ " USAGE:								    \n"
+ "									    \n"
+ "  confsample [file1.wav] [file2.wav] ...				    \n"
+ "									    \n"
+ " where:								    \n"
+ "  fileN.wav are optional WAV files to be connected to the conference      \n"
+ "  bridge. The WAV files MUST have single channel (mono) and 16 bit PCM    \n"
+ "  samples. It can have arbitrary sampling rate.			    \n"
+ "									    \n"
+ " DESCRIPTION:								    \n"
+ "									    \n"
+ "  Here we create a conference bridge, with at least one port (port zero   \n"
+ "  is always created for the sound device).				    \n"
+ "									    \n"
+ "  If WAV files are specified, the WAV file player ports will be connected \n"
+ "  to slot starting from number one in the bridge. The WAV files can have  \n"
+ "  arbitrary sampling rate; the bridge will convert it to its clock rate.  \n"
+ "  However, the files MUST have a single audio channel only (i.e. mono).   \n";
 
 #include <pjmedia.h>
@@ -59,4 +58,11 @@
 #define THIS_FILE   "confsample.c"
 
+/* Constants */
+#define CLOCK_RATE	44100
+#define NSAMPLES	(CLOCK_RATE * 20 / 1000)
+#define NCHANNELS	1
+#define NBITS		16
+
+ 
 /* 
  * Prototypes: 
@@ -174,8 +180,8 @@
     status = pjmedia_conf_create( pool,	    /* pool to use	    */
 				  port_count,/* number of ports	    */
-				  16000,    /* sampling rate	    */
-				  1,	    /* # of channels.	    */
-				  320,	    /* samples per frame    */
-				  16,	    /* bits per sample	    */
+				  CLOCK_RATE,/* sampling rate	    */
+				  NCHANNELS,/* # of channels.	    */
+				  NSAMPLES, /* samples per frame    */
+				  NBITS,    /* bits per sample	    */
 				  0,	    /* options		    */
 				  &conf	    /* result		    */
Index: pjproject/trunk/pjsip/include/pjsua-lib/pjsua.h
===================================================================
--- pjproject/trunk/pjsip/include/pjsua-lib/pjsua.h	(revision 342)
+++ pjproject/trunk/pjsip/include/pjsua-lib/pjsua.h	(revision 343)
@@ -181,4 +181,6 @@
     pjmedia_endpt   *med_endpt;	    /**< Media endpoint.		*/
     unsigned	     clock_rate;    /**< Internal clock rate.		*/
+    pj_bool_t	     has_wb;	    /**< Include wideband codecs	*/
+    pj_bool_t	     has_uwb;	    /**< Include ultra-wideband codecs	*/
     pjmedia_conf    *mconf;	    /**< Media conference.		*/
     pj_bool_t	     null_audio;    /**< Null audio flag.		*/
Index: pjproject/trunk/pjsip/src/pjsua-lib/pjsua_core.c
===================================================================
--- pjproject/trunk/pjsip/src/pjsua-lib/pjsua_core.c	(revision 342)
+++ pjproject/trunk/pjsip/src/pjsua-lib/pjsua_core.c	(revision 343)
@@ -78,7 +78,13 @@
 
     /* Default for media: */
+#if defined(PJ_DARWINOS) && PJ_DARWINOS!=0
+    pjsua.clock_rate = 44100;
+#else
     pjsua.clock_rate = 8000;
+#endif
     pjsua.complexity = -1;
     pjsua.quality = 4;
+    pjsua.has_wb = 0;
+    pjsua.has_uwb = 0;
 
 
@@ -622,8 +628,8 @@
 
 	/* Register speex. */
-	if (pjsua.clock_rate >= 16000)
-	    option &= ~(PJMEDIA_SPEEX_NO_WB);
-	if (pjsua.clock_rate >= 32000)
-	    option &= ~(PJMEDIA_SPEEX_NO_UWB);
+	if (pjsua.has_wb)
+	    option &= ~PJMEDIA_SPEEX_NO_WB;
+	if (pjsua.has_uwb)
+	    option &= ~PJMEDIA_SPEEX_NO_UWB;
 
 	status = pjmedia_codec_speex_init(pjsua.med_endpt, option, 
@@ -690,7 +696,7 @@
 
 		/* Register speex. */
-		if (pjsua.clock_rate >= 16000)
+		if (pjsua.has_wb)
 		    option &= ~(PJMEDIA_SPEEX_NO_WB);
-		if (pjsua.clock_rate >= 32000)
+		if (pjsua.has_uwb)
 		    option &= ~(PJMEDIA_SPEEX_NO_UWB);
 
Index: pjproject/trunk/pjsip/src/pjsua-lib/pjsua_settings.c
===================================================================
--- pjproject/trunk/pjsip/src/pjsua-lib/pjsua_settings.c	(revision 342)
+++ pjproject/trunk/pjsip/src/pjsua-lib/pjsua_settings.c	(revision 343)
@@ -87,4 +87,5 @@
     puts  ("  --wb                Enable wideband codecs and set clock-rate to 16KHz");
     puts  ("  --uwb               Enable ultra-wideband codecs and set clock-rate to 32KHz");
+    puts  ("  --clock-rate=N      Override sound device clock rate");
     puts  ("  --null-audio        Use NULL audio device");
     puts  ("  --no-mic            Disable microphone device");
@@ -227,5 +228,5 @@
 	   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_AUTO_CONF, OPT_CLOCK_RATE,
 	   OPT_PLAY_FILE, OPT_WB, OPT_UWB, OPT_RTP_PORT, OPT_ADD_CODEC,
 	   OPT_COMPLEXITY, OPT_QUALITY,
@@ -242,4 +243,5 @@
 	{ "wb",		0, 0, OPT_WB},
 	{ "uwb",	0, 0, OPT_UWB},
+	{ "clock-rate",	1, 0, OPT_CLOCK_RATE},
 	{ "null-audio", 0, 0, OPT_NULL_AUDIO},
 	{ "no-mic",	0, 0, OPT_NO_MIC},
@@ -352,9 +354,18 @@
 
 	case OPT_WB:
-	    pjsua.clock_rate = 16000;
+	    pjsua.has_wb = 1;
 	    break;
 
 	case OPT_UWB:
-	    pjsua.clock_rate = 32000;
+	    pjsua.has_uwb = 1;
+	    break;
+
+	case OPT_CLOCK_RATE:
+	    lval = pj_strtoul(pj_cstr(&tmp, pj_optarg));
+	    if (lval < 8000 || lval > 48000) {
+		printf("Error: expecting value between 8000-48000 for clock rate\n");
+		return PJ_EINVAL;
+	    }
+	    pjsua.clock_rate = (int)lval; 
 	    break;
 
@@ -573,4 +584,10 @@
 	return PJ_EINVAL;
     }
+
+    /* Adjust clock rate */
+    if (pjsua.clock_rate == 8000 && pjsua.has_uwb)
+	pjsua.clock_rate = 32000;
+    else if (pjsua.clock_rate == 8000 && pjsua.has_wb)
+	pjsua.clock_rate = 16000;
 
     return PJ_SUCCESS;
@@ -906,8 +923,14 @@
     }
     /* Media clock rate. */
-    if (pjsua.clock_rate >= 32000)
+    if (pjsua.has_uwb)
 	pj_strcat2(&cfg, "--uwb\n");
-    else if (pjsua.clock_rate >= 16000)
+
+    if (pjsua.has_wb)
 	pj_strcat2(&cfg, "--wb\n");
+
+    pj_ansi_sprintf(line, "--clock-rate %d\n",
+		    pjsua.clock_rate);
+    pj_strcat2(&cfg, line);
+
 
     /* Encoding quality and complexity */
