Index: pjproject/trunk/pjmedia/include/pjmedia-codec/opencore_amr.h
===================================================================
--- pjproject/trunk/pjmedia/include/pjmedia-codec/opencore_amr.h	(revision 4334)
+++ pjproject/trunk/pjmedia/include/pjmedia-codec/opencore_amr.h	(revision 4335)
@@ -33,4 +33,13 @@
 
 /**
+ * Bitmask options to be passed during AMR codec factory initialization.
+ */
+enum pjmedia_amr_options
+{
+    PJMEDIA_AMR_NO_NB	    = 1,    /**< Disable narrowband mode.	*/
+    PJMEDIA_AMR_NO_WB	    = 2,    /**< Disable wideband mode.		*/
+};
+
+/**
  * Settings. Use #pjmedia_codec_opencore_amrnb/wb_set_config() to
  * activate.
@@ -54,5 +63,40 @@
 
 /**
- * Initialize and register AMR-NB codec factory to pjmedia endpoint.
+ * Initialize and register AMR codec factory to pjmedia endpoint.
+ *
+ * @param endpt     The pjmedia endpoint.
+ * @param options   Bitmask of pjmedia_amr_options (default=0).
+ *
+ * @return          PJ_SUCCESS on success.
+ */
+PJ_DECL(pj_status_t) pjmedia_codec_opencore_amr_init(pjmedia_endpt* endpt,
+                                                     unsigned options);
+
+/**
+ * Initialize and register AMR codec factory using default settings to
+ * pjmedia endpoint.
+ *
+ * @param endpt The pjmedia endpoint.
+ *
+ * @return	PJ_SUCCESS on success.
+ */
+PJ_DECL(pj_status_t)
+pjmedia_codec_opencore_amr_init_default(pjmedia_endpt* endpt);
+
+/**
+ * Unregister AMR codec factory from pjmedia endpoint and deinitialize
+ * the OpenCORE codec library.
+ *
+ * @return	PJ_SUCCESS on success.
+ */
+PJ_DECL(pj_status_t) pjmedia_codec_opencore_amr_deinit(void);
+
+/**
+ * Initialize and register AMR-NB codec factory to pjmedia endpoint. Calling
+ * this function will automatically initialize AMR codec factory without
+ * the wideband mode (i.e. it is equivalent to calling
+ * #pjmedia_codec_opencore_amr_init() with PJMEDIA_AMR_NO_WB). Application
+ * should call #pjmedia_codec_opencore_amr_init() instead if wishing to use
+ * both modes.
  *
  * @param endpt	The pjmedia endpoint.
@@ -81,21 +125,4 @@
 				const pjmedia_codec_amrnb_config* cfg);
 
-/**
- * Initialize and register AMR-WB codec factory to pjmedia endpoint.
- *
- * @param endpt	The pjmedia endpoint.
- *
- * @return	PJ_SUCCESS on success.
- */
-PJ_DECL(pj_status_t) pjmedia_codec_opencore_amrwb_init(pjmedia_endpt* endpt);
-
-/**
- * Unregister AMR-WB codec factory from pjmedia endpoint and deinitialize
- * the OpenCORE codec library.
- *
- * @return	PJ_SUCCESS on success.
- */
-PJ_DECL(pj_status_t) pjmedia_codec_opencore_amrwb_deinit(void);
-
 
 /**
Index: pjproject/trunk/pjmedia/src/pjmedia-codec/audio_codecs.c
===================================================================
--- pjproject/trunk/pjmedia/src/pjmedia-codec/audio_codecs.c	(revision 4334)
+++ pjproject/trunk/pjmedia/src/pjmedia-codec/audio_codecs.c	(revision 4335)
@@ -108,14 +108,7 @@
 #endif	/* PJMEDIA_HAS_L16_CODEC */
 
-#if PJMEDIA_HAS_OPENCORE_AMRNB_CODEC
-    /* Register OpenCORE AMR-NB */
-    status = pjmedia_codec_opencore_amrnb_init(endpt);
-    if (status != PJ_SUCCESS)
-	return status;
-#endif
-    
-#if PJMEDIA_HAS_OPENCORE_AMRWB_CODEC
-    /* Register OpenCORE AMR-WB */
-    status = pjmedia_codec_opencore_amrwb_init(endpt);
+#if PJMEDIA_HAS_OPENCORE_AMRNB_CODEC || PJMEDIA_HAS_OPENCORE_AMRWB_CODEC
+    /* Register OpenCORE AMR */
+    status = pjmedia_codec_opencore_amr_init(endpt, 0);
     if (status != PJ_SUCCESS)
 	return status;
Index: pjproject/trunk/pjmedia/src/pjmedia-codec/opencore_amr.c
===================================================================
--- pjproject/trunk/pjmedia/src/pjmedia-codec/opencore_amr.c	(revision 4334)
+++ pjproject/trunk/pjmedia/src/pjmedia-codec/opencore_amr.c	(revision 4335)
@@ -199,5 +199,6 @@
  * Initialize and register AMR codec factory to pjmedia endpoint.
  */
-static pj_status_t amr_init( pjmedia_endpt *endpt )
+PJ_DEF(pj_status_t) pjmedia_codec_opencore_amr_init( pjmedia_endpt *endpt,
+                                                     unsigned options)
 {
     pjmedia_codec_mgr *codec_mgr;
@@ -212,6 +213,16 @@
     amr_codec_factory.base.factory_data = NULL;
     amr_codec_factory.endpt = endpt;
-
-    amr_codec_factory.pool = pjmedia_endpt_create_pool(endpt, "amr", 1000, 
+#ifdef USE_AMRNB
+    amr_codec_factory.init[IDX_AMR_NB] = ((options & PJMEDIA_AMR_NO_NB) == 0);
+#else
+    amr_codec_factory.init[IDX_AMR_NB] = PJ_FALSE;
+#endif
+#ifdef USE_AMRWB
+    amr_codec_factory.init[IDX_AMR_WB] = ((options & PJMEDIA_AMR_NO_WB) == 0);
+#else
+    amr_codec_factory.init[IDX_AMR_WB] = PJ_FALSE;
+#endif
+
+    amr_codec_factory.pool = pjmedia_endpt_create_pool(endpt, "amr", 1000,
 						       1000);
     if (!amr_codec_factory.pool)
@@ -248,16 +259,13 @@
 }
 
+PJ_DEF(pj_status_t)
+pjmedia_codec_opencore_amr_init_default( pjmedia_endpt *endpt )
+{
+    return pjmedia_codec_opencore_amr_init(endpt, 0);
+}
+
 PJ_DEF(pj_status_t) pjmedia_codec_opencore_amrnb_init( pjmedia_endpt *endpt )
 {
-    amr_codec_factory.init[IDX_AMR_NB] = PJ_TRUE;
-    
-    return amr_init(endpt);
-}
-
-PJ_DEF(pj_status_t) pjmedia_codec_opencore_amrwb_init( pjmedia_endpt *endpt )
-{
-    amr_codec_factory.init[IDX_AMR_WB] = PJ_TRUE;
-    
-    return amr_init(endpt);    
+    return pjmedia_codec_opencore_amr_init(endpt, PJMEDIA_AMR_NO_WB);
 }
 
@@ -267,14 +275,11 @@
  * the AMR codec library.
  */
-static pj_status_t amr_deinit(void)
+PJ_DEF(pj_status_t) pjmedia_codec_opencore_amr_deinit(void)
 {
     pjmedia_codec_mgr *codec_mgr;
     pj_status_t status;
 
-    if (amr_codec_factory.init[IDX_AMR_NB] ||
-        amr_codec_factory.init[IDX_AMR_WB])
-    {
-        return PJ_SUCCESS;
-    }
+    amr_codec_factory.init[IDX_AMR_NB] = PJ_FALSE;
+    amr_codec_factory.init[IDX_AMR_WB] = PJ_FALSE;
     
     if (amr_codec_factory.pool == NULL)
@@ -302,14 +307,14 @@
 PJ_DEF(pj_status_t) pjmedia_codec_opencore_amrnb_deinit(void)
 {
-    amr_codec_factory.init[IDX_AMR_NB] = PJ_FALSE;
+    if (amr_codec_factory.init[IDX_AMR_NB] &&
+        amr_codec_factory.init[IDX_AMR_WB])
+    {
+        PJ_LOG(4, (THIS_FILE, "Should call "
+                              "pjmedia_codec_opencore_amr_deinit() instead"));
+        
+        return PJ_EINVALIDOP;
+    }
     
-    return amr_deinit();
-}
-
-PJ_DEF(pj_status_t) pjmedia_codec_opencore_amrwb_deinit(void)
-{
-    amr_codec_factory.init[IDX_AMR_WB] = PJ_FALSE;
-    
-    return amr_deinit();
+    return pjmedia_codec_opencore_amr_deinit();
 }
 
@@ -448,5 +453,5 @@
     }
     
-    if (amr_codec_factory.init[IDX_AMR_NB]) {
+    if (amr_codec_factory.init[IDX_AMR_WB]) {
         pj_bzero(&codecs[*count], sizeof(pjmedia_codec_info));
         codecs[*count].encoding_name = pj_str("AMR-WB");
Index: pjproject/trunk/pjmedia/src/test/mips_test.c
===================================================================
--- pjproject/trunk/pjmedia/src/test/mips_test.c	(revision 4334)
+++ pjproject/trunk/pjmedia/src/test/mips_test.c	(revision 4335)
@@ -954,6 +954,6 @@
 {
     return codec_encode_decode(pool, "AMR/16000",
-			       &pjmedia_codec_opencore_amrwb_init,
-			       &pjmedia_codec_opencore_amrwb_deinit,
+			       &pjmedia_codec_opencore_amr_init_default,
+			       &pjmedia_codec_opencore_amr_deinit,
 			       clock_rate, channel_count,
 			       samples_per_frame, flags, te);
@@ -2053,6 +2053,7 @@
                                          struct test_entry *te)
 {
-    return create_stream(pool, "AMR/16000", &pjmedia_codec_opencore_amrwb_init,
-			 &pjmedia_codec_opencore_amrwb_deinit,
+    return create_stream(pool, "AMR/16000",
+                         &pjmedia_codec_opencore_amr_init_default,
+			 &pjmedia_codec_opencore_amr_deinit,
 			 PJ_FALSE, PJ_FALSE, PJ_FALSE,
 			 clock_rate, channel_count,
