Index: /pjproject/trunk/pjsip/include/pjsua2/account.hpp
===================================================================
--- /pjproject/trunk/pjsip/include/pjsua2/account.hpp	(revision 6073)
+++ /pjproject/trunk/pjsip/include/pjsua2/account.hpp	(revision 6074)
@@ -1799,4 +1799,5 @@
     void presNotify(const PresNotifyParam &prm) PJSUA2_THROW(Error);
     
+#if !DEPRECATED_FOR_TICKET_2232
     /**
      * Warning: deprecated, use enumBuddies2() instead. This function is not
@@ -1808,4 +1809,5 @@
      */
     const BuddyVector& enumBuddies() const PJSUA2_THROW(Error);
+#endif
 
     /**
@@ -1816,4 +1818,5 @@
     BuddyVector2 enumBuddies2() const PJSUA2_THROW(Error);
 
+#if !DEPRECATED_FOR_TICKET_2232
     /**
      * Warning: deprecated, use findBuddy2 instead. This function is not
@@ -1831,4 +1834,5 @@
     Buddy* findBuddy(string uri, FindBuddyMatch *buddy_match = NULL) const
 		    PJSUA2_THROW(Error);
+#endif
 
     /**
@@ -1969,5 +1973,7 @@
     pjsua_acc_id 	 id;
     string		 tmpReason;	// for saving response's reason
+#if !DEPRECATED_FOR_TICKET_2232
     BuddyVector		 buddyList;
+#endif
 };
 
Index: /pjproject/trunk/pjsip/include/pjsua2/config.hpp
===================================================================
--- /pjproject/trunk/pjsip/include/pjsua2/config.hpp	(revision 6073)
+++ /pjproject/trunk/pjsip/include/pjsua2/config.hpp	(revision 6074)
@@ -48,4 +48,13 @@
 #endif
 
+/**
+ * Ticket #2189 described some lists of objects which is not thread safe.
+ * The ticket deprecated some APIs which uses those lists and introduce new one
+ * to replace them. This settings will disable the deprecated API all together.
+ * See also https://trac.pjsip.org/repos/ticket/2232
+ */
+#ifndef DEPRECATED_FOR_TICKET_2232
+#   define DEPRECATED_FOR_TICKET_2232		1
+#endif
 
 /*
Index: /pjproject/trunk/pjsip/include/pjsua2/endpoint.hpp
===================================================================
--- /pjproject/trunk/pjsip/include/pjsua2/endpoint.hpp	(revision 6073)
+++ /pjproject/trunk/pjsip/include/pjsua2/endpoint.hpp	(revision 6074)
@@ -1389,4 +1389,5 @@
     unsigned mediaActivePorts() const;
 
+#if !DEPRECATED_FOR_TICKET_2232
     /**
      * Warning: deprecated, use mediaEnumPorts2() instead. This function is
@@ -1398,4 +1399,5 @@
      */
     const AudioMediaVector &mediaEnumPorts() const PJSUA2_THROW(Error);
+#endif
 
     /**
@@ -1431,4 +1433,5 @@
      */
 
+#if !DEPRECATED_FOR_TICKET_2232
     /**
      * Warning: deprecated, use codecEnum2() instead. This function is not
@@ -1440,4 +1443,5 @@
      */
     const CodecInfoVector &codecEnum() PJSUA2_THROW(Error);
+#endif
 
     /**
@@ -1482,4 +1486,5 @@
 		       const CodecParam param) PJSUA2_THROW(Error);
 
+#if !DEPRECATED_FOR_TICKET_2232
     /**
      * Warning: deprecated, use videoCodecEnum2() instead. This function is
@@ -1491,4 +1496,5 @@
      */
     const CodecInfoVector &videoCodecEnum() PJSUA2_THROW(Error);
+#endif
 
     /**
@@ -1662,12 +1668,16 @@
     static Endpoint		*instance_;	// static instance
     LogWriter			*writer;	// Custom writer, if any
-    AudioMediaVector 	 	 mediaList;
     AudDevManager		 audioDevMgr;
     VidDevManager		 videoDevMgr;
+#if !DEPRECATED_FOR_TICKET_2232
     CodecInfoVector		 codecInfoList;
     CodecInfoVector		 videoCodecInfoList;
+#endif
     std::map<pj_thread_t*, pj_thread_desc*> threadDescMap;
     pj_mutex_t			*threadDescMutex;
+#if !DEPRECATED_FOR_TICKET_2232
+    AudioMediaVector 	 	 mediaList;
     pj_mutex_t			*mediaListMutex;
+#endif
 
     /* Pending logging */
Index: /pjproject/trunk/pjsip/include/pjsua2/media.hpp
===================================================================
--- /pjproject/trunk/pjsip/include/pjsua2/media.hpp	(revision 6073)
+++ /pjproject/trunk/pjsip/include/pjsua2/media.hpp	(revision 6074)
@@ -911,4 +911,5 @@
     void setPlaybackDev(int playback_dev) const PJSUA2_THROW(Error);
 
+#if !DEPRECATED_FOR_TICKET_2232
     /**
      * Warning: deprecated, use enumDev2 instead. This function is not
@@ -921,4 +922,5 @@
      */
     const AudioDevInfoVector &enumDev() PJSUA2_THROW(Error);
+#endif
 
     /**
@@ -1466,5 +1468,7 @@
 
 private:
+#if !DEPRECATED_FOR_TICKET_2232
     AudioDevInfoVector		 audioDevList;
+#endif
     AudioMedia			*devMedia;
 
@@ -2069,4 +2073,5 @@
     VideoDevInfo getDevInfo(int dev_id) const PJSUA2_THROW(Error);
 
+#if !DEPRECATED_FOR_TICKET_2232
     /**
      * Warning: deprecated, use enumDev2() instead. This function is not
@@ -2078,4 +2083,5 @@
      */
     const VideoDevInfoVector &enumDev() PJSUA2_THROW(Error);
+#endif
 
     /**
@@ -2276,5 +2282,7 @@
 
 private:
+#if !DEPRECATED_FOR_TICKET_2232
     VideoDevInfoVector videoDevList;
+#endif
 
     void clearVideoDevList();
Index: /pjproject/trunk/pjsip/src/pjsua2/account.cpp
===================================================================
--- /pjproject/trunk/pjsip/src/pjsua2/account.cpp	(revision 6073)
+++ /pjproject/trunk/pjsip/src/pjsua2/account.cpp	(revision 6074)
@@ -968,4 +968,5 @@
 {
     if (isValid() && pjsua_get_state() < PJSUA_STATE_CLOSING) {
+#if !DEPRECATED_FOR_TICKET_2232
         // Cleanup buddies in the buddy list
 	while(buddyList.size() > 0) {
@@ -973,4 +974,5 @@
 	    delete b; /* this will remove itself from the list */
 	}
+#endif
 
 	// This caused error message of "Error: cannot find Account.."
@@ -1065,8 +1067,10 @@
 }
 
+#if !DEPRECATED_FOR_TICKET_2232
 const BuddyVector& Account::enumBuddies() const PJSUA2_THROW(Error)
 {
     return buddyList;
 }
+#endif
 
 BuddyVector2 Account::enumBuddies2() const PJSUA2_THROW(Error)
@@ -1084,4 +1088,5 @@
 }
 
+#if !DEPRECATED_FOR_TICKET_2232
 Buddy* Account::findBuddy(string uri, FindBuddyMatch *buddy_match) const
 		PJSUA2_THROW(Error)
@@ -1098,4 +1103,5 @@
     PJSUA2_RAISE_ERROR(PJ_ENOTFOUND);
 }
+#endif
 
 Buddy Account::findBuddy2(string uri) const PJSUA2_THROW(Error)
@@ -1117,11 +1123,16 @@
 void Account::addBuddy(Buddy *buddy)
 {
+#if !DEPRECATED_FOR_TICKET_2232
     pj_assert(buddy);
 
     buddyList.push_back(buddy);
+#else
+    PJ_UNUSED_ARG(buddy);
+#endif
 }
 
 void Account::removeBuddy(Buddy *buddy)
 {
+#if !DEPRECATED_FOR_TICKET_2232
     pj_assert(buddy);
 
@@ -1135,3 +1146,6 @@
 
     pj_assert(!"Bug! Buddy to be removed is not in the buddy list!");
-}
+#else
+    PJ_UNUSED_ARG(buddy);
+#endif
+}
Index: /pjproject/trunk/pjsip/src/pjsua2/endpoint.cpp
===================================================================
--- /pjproject/trunk/pjsip/src/pjsua2/endpoint.cpp	(revision 6073)
+++ /pjproject/trunk/pjsip/src/pjsua2/endpoint.cpp	(revision 6074)
@@ -479,7 +479,10 @@
  * Endpoint instance
  */
-Endpoint::Endpoint()
-: writer(NULL), threadDescMutex(NULL), mediaListMutex(NULL), 
-  mainThreadOnly(false), mainThread(NULL), pendingJobSize(0)
+Endpoint::Endpoint():
+#if !DEPRECATED_FOR_TICKET_2232
+mediaListMutex(NULL),
+#endif
+writer(NULL), threadDescMutex(NULL), mainThreadOnly(false),
+mainThread(NULL), pendingJobSize(0)
 {
     if (instance_) {
@@ -505,6 +508,8 @@
     }
 
+#if !DEPRECATED_FOR_TICKET_2232
     clearCodecInfoList(codecInfoList);
     clearCodecInfoList(videoCodecInfoList);
+#endif
 
     try {
@@ -1714,6 +1719,8 @@
     				    	      &threadDescMutex) );
 
+#if !DEPRECATED_FOR_TICKET_2232
     PJSUA2_CHECK_EXPR( pj_mutex_create_recursive(pjsua_var.pool, "mediaList",
     				    		 &mediaListMutex) );
+#endif
 }
 
@@ -1783,4 +1790,5 @@
     }
 
+#if !DEPRECATED_FOR_TICKET_2232
     while(mediaList.size() > 0) {
 	AudioMedia *cur_media = mediaList[0];
@@ -1792,4 +1800,5 @@
     	mediaListMutex = NULL;
     }
+#endif
 
     status = pjsua_destroy2(flags);
@@ -2047,8 +2056,10 @@
 }
 
+#if !DEPRECATED_FOR_TICKET_2232
 const AudioMediaVector &Endpoint::mediaEnumPorts() const PJSUA2_THROW(Error)
 {
     return mediaList;
 }
+#endif
 
 AudioMediaVector2 Endpoint::mediaEnumPorts2() const PJSUA2_THROW(Error)
@@ -2090,4 +2101,5 @@
 void Endpoint::mediaAdd(AudioMedia &media)
 {
+#if !DEPRECATED_FOR_TICKET_2232
     /* mediaList serves mediaEnumPorts() only, once mediaEnumPorts()
      * is removed, this function implementation should be no-op.
@@ -2102,8 +2114,12 @@
     	mediaList.push_back(&media);
     pj_mutex_unlock(mediaListMutex);
+#else
+    PJ_UNUSED_ARG(media);
+#endif
 }
 
 void Endpoint::mediaRemove(AudioMedia &media)
 {
+#if !DEPRECATED_FOR_TICKET_2232
     /* mediaList serves mediaEnumPorts() only, once mediaEnumPorts()
      * is removed, this function implementation should be no-op.
@@ -2117,4 +2133,7 @@
 	mediaList.erase(it);
     pj_mutex_unlock(mediaListMutex);
+#else
+    PJ_UNUSED_ARG(media);
+#endif
 }
 
@@ -2142,4 +2161,6 @@
  * Codec operations.
  */
+
+#if !DEPRECATED_FOR_TICKET_2232
 const CodecInfoVector &Endpoint::codecEnum() PJSUA2_THROW(Error)
 {
@@ -2152,4 +2173,5 @@
     return codecInfoList;
 }
+#endif
 
 CodecInfoVector2 Endpoint::codecEnum2() const PJSUA2_THROW(Error)
@@ -2220,4 +2242,5 @@
 }
 
+#if !DEPRECATED_FOR_TICKET_2232
 const CodecInfoVector &Endpoint::videoCodecEnum() PJSUA2_THROW(Error)
 {
@@ -2232,4 +2255,5 @@
     return videoCodecInfoList;
 }
+#endif
 
 CodecInfoVector2 Endpoint::videoCodecEnum2() const PJSUA2_THROW(Error)
Index: /pjproject/trunk/pjsip/src/pjsua2/media.cpp
===================================================================
--- /pjproject/trunk/pjsip/src/pjsua2/media.cpp	(revision 6073)
+++ /pjproject/trunk/pjsip/src/pjsua2/media.cpp	(revision 6074)
@@ -749,4 +749,5 @@
 }
 
+#if !DEPRECATED_FOR_TICKET_2232
 const AudioDevInfoVector &AudDevManager::enumDev() PJSUA2_THROW(Error)
 {
@@ -766,4 +767,5 @@
     return audioDevList;
 }
+#endif
 
 AudioDevInfoVector2 AudDevManager::enumDev2() const PJSUA2_THROW(Error)
@@ -1084,8 +1086,10 @@
 void AudDevManager::clearAudioDevList()
 {
+#if !DEPRECATED_FOR_TICKET_2232
     for(unsigned i=0;i<audioDevList.size();++i) {
 	delete audioDevList[i];
     }
     audioDevList.clear();
+#endif
 }
 
@@ -1481,4 +1485,5 @@
 }
 
+#if !DEPRECATED_FOR_TICKET_2232
 const VideoDevInfoVector &VidDevManager::enumDev() PJSUA2_THROW(Error)
 {
@@ -1500,4 +1505,5 @@
     return videoDevList;
 }
+#endif
 
 VideoDevInfoVector2 VidDevManager::enumDev2() const PJSUA2_THROW(Error)
@@ -1666,5 +1672,5 @@
 void VidDevManager::clearVideoDevList()
 {
-#if PJSUA_HAS_VIDEO
+#if PJSUA_HAS_VIDEO && !DEPRECATED_FOR_TICKET_2232
     for (unsigned i = 0;i<videoDevList.size();++i) {
 	delete videoDevList[i];
