Index: /pjproject/trunk/pjmedia/src/pjmedia-audiodev/bdimad_dev.c
===================================================================
--- /pjproject/trunk/pjmedia/src/pjmedia-audiodev/bdimad_dev.c	(revision 4747)
+++ /pjproject/trunk/pjmedia/src/pjmedia-audiodev/bdimad_dev.c	(revision 4748)
@@ -319,5 +319,5 @@
         wf->dev_info[captureDeviceCount+i].deviceId = captureDeviceCount+i;
         wf->dev_info[captureDeviceCount+i].info.caps = 
-				PJMEDIA_AUD_DEV_CAP_OUTPUT_VOLUME_SETTING;
+				PJMEDIA_AUD_DEV_CAP_OUTPUT_VOLUME_SETTING | PJMEDIA_AUD_DEV_CAP_OUTPUT_ROUTE;
         wf->dev_info[captureDeviceCount+i].info.default_samples_per_sec = 
 				BD_IMAD_DEFAULT_FREQ;
@@ -426,4 +426,8 @@
     }
 
+	if(di->info.caps & PJMEDIA_AUD_DEV_CAP_OUTPUT_ROUTE) {
+		param->output_route = PJMEDIA_AUD_DEV_ROUTE_LOUDSPEAKER;
+    }
+
     return PJ_SUCCESS;
 }
@@ -928,4 +932,16 @@
     }
 
+	if(cap == PJMEDIA_AUD_DEV_CAP_OUTPUT_ROUTE) {
+		pjmedia_aud_dev_route outputRoute = *(pjmedia_aud_dev_route*)pval;
+		if(strm->param.output_route!=outputRoute)
+			res = bdIMADpj_setRouteOutputDevice(strm->bdIMADpjInstance, (bdIMADpj_out_dev_route) outputRoute, &strm->bdIMADpjWarningPtr);
+		if(res == BD_PJ_OK) {
+			strm->param.output_route = outputRoute;
+            return PJ_SUCCESS;
+        } else {
+            return PJMEDIA_AUDIODEV_ERRNO_FROM_BDIMAD(res);
+        }
+	}
+
     return PJMEDIA_EAUD_INVCAP;
 }
@@ -1012,4 +1028,10 @@
     }
 
+    if(param->flags & PJMEDIA_AUD_DEV_CAP_OUTPUT_ROUTE) {
+		stream_set_capBDIMAD(&strm->base,
+				PJMEDIA_AUD_DEV_CAP_OUTPUT_ROUTE,
+				 &param->output_route);
+	}
+
     strm->base.op = &stream_op;
     *p_aud_strm = &strm->base;
@@ -1060,4 +1082,15 @@
     {
         pi->flags |= PJMEDIA_AUD_DEV_CAP_EC;
+    }
+	if(stream_get_cap(s, PJMEDIA_AUD_DEV_CAP_EC, &pi->ec_enabled) == PJ_SUCCESS)
+    {
+        pi->flags |= PJMEDIA_AUD_DEV_CAP_EC;
+    }
+    
+
+    // Get the Route Output Device setting
+    if(stream_get_cap(s, PJMEDIA_AUD_DEV_CAP_OUTPUT_ROUTE, &pi->output_route) == PJ_SUCCESS)
+    {
+        pi->flags |= PJMEDIA_AUD_DEV_CAP_OUTPUT_ROUTE;
     }
 
@@ -1114,4 +1147,14 @@
             return PJMEDIA_AUDIODEV_ERRNO_FROM_BDIMAD(res);
         }
+    }
+    else if(cap == PJMEDIA_AUD_DEV_CAP_OUTPUT_ROUTE) {
+    		pjmedia_aud_dev_route routeOutDev;
+    		res = bdIMADpj_getRouteOutputDevice(strm->bdIMADpjInstance,(bdIMADpj_out_dev_route*)&routeOutDev);
+            if(res == BD_PJ_OK) {
+                *(pjmedia_aud_dev_route*)pval = routeOutDev;
+                return PJ_SUCCESS;
+            } else {
+                return PJMEDIA_AUDIODEV_ERRNO_FROM_BDIMAD(res);
+            }
     } else {
         return PJMEDIA_EAUD_INVCAP;
@@ -1177,7 +1220,12 @@
 
 #if defined (_MSC_VER)
+#ifdef _DEBUG
+#pragma comment ( lib, "bdClientValidationd.lib" )
+#pragma comment ( lib, "bdIMADpjd.lib" )
+#else
 #pragma comment ( lib, "bdClientValidation.lib" )
 #pragma comment ( lib, "bdIMADpj.lib" )
 #endif
+#endif
 
 
Index: /pjproject/trunk/third_party/bdsound/include/bdimad.h
===================================================================
--- /pjproject/trunk/third_party/bdsound/include/bdimad.h	(revision 4747)
+++ /pjproject/trunk/third_party/bdsound/include/bdimad.h	(revision 4748)
@@ -52,5 +52,5 @@
  *    - <b>Usage</b>
  *    \n There are only a couple of things the customer have to pay attention on
- *    §when using bdIMAD library.
+ *    ï¿œwhen using bdIMAD library.
  *
  *       - <b>Initialization</b>
@@ -341,4 +341,20 @@
 } bdIMADpj_libVersion_t;
 
+
+/**
+ * @brief Audio output routing setting to pass to set and get route output device functions.
+ */
+typedef enum bdIMADpj_out_dev_route{
+    /** Default route. */
+    BD_AUD_DEV_ROUTE_DEFAULT = 0,
+
+    /** Route to loudspeaker */
+    BD_AUD_DEV_ROUTE_LOUDSPEAKER = 1,
+
+    /** Route to earpiece */
+    BD_AUD_DEV_ROUTE_EARPIECE = 2
+}bdIMADpj_out_dev_route;
+
+
 /**
  * @}
@@ -409,5 +425,5 @@
  *                                     is modified with the applied settings.
  * @param[out] **ppWarningMessages     Pointer to pointer to a
- * 				       ::bdIMADpj_Warnings_t sructure,
+ * 				       ::bdIMADpj_Warnings_t structure,
  * 				       which reports the warnings after the
  * 				       initialization.
@@ -514,5 +530,5 @@
  * 				       performed successfully, otherwise
  * 				       return an error (refer to
- * 				       §::bdIMADpj_Status).
+ * 				       ï¿œ::bdIMADpj_Status).
  */
 BDIMADPJ_API bdIMADpj_Status bdIMADpj_setParameter(bdIMADpj bdIMADInstance,
@@ -537,4 +553,29 @@
 				bdIMADpj_Parameter parameterName, void *pValue);
 
+/**
+ * @brief Is used to set the route of the output device of the bdIMAD object pointed by the
+ * <code>pBdIMADInstance</code>.
+ * @param[in] bdIMADInstance           bdIMAD object.
+ * @param[in] outputRoute	       Indicate the route of the output device to set.
+ * @param[out] **ppWarningMessages     Pointer to pointer to a
+ * 				       ::bdIMADpj_Warnings_t structure,
+ * 				       which reports the warnings after the
+ * 				       set function.
+ * @return                             ::BD_PJ_OK if the function has been
+ * 				       performed successfully, otherwise return
+ * 				       an error (refer to ::bdIMADpj_Status).
+ */
+BDIMADPJ_API bdIMADpj_Status bdIMADpj_setRouteOutputDevice(bdIMADpj bdIMADInstance, bdIMADpj_out_dev_route outputRoute, bdIMADpj_Warnings_t **ppWarningMessages);
+
+/**
+ * @brief Is used to get the route of the output device of the bdIMAD object pointed by the
+ * <code>pBdIMADInstance</code>.
+ * @param[in] bdIMADInstance           bdIMAD object.
+ * @param[out] *outputRoute            Is a pointer to the route of the output device currently setted.
+ * @return                             ::BD_PJ_OK if the function has been
+ * 				       performed successfully, otherwise return
+ * 				       an error (refer to ::bdIMADpj_Status).
+ */
+BDIMADPJ_API bdIMADpj_Status bdIMADpj_getRouteOutputDevice(bdIMADpj bdIMADInstance, bdIMADpj_out_dev_route *outputRoute);
 
 #ifdef __cplusplus
