Changeset 4887 for pjproject/trunk/pjsip/src/pjsua2/endpoint.cpp
- Timestamp:
- Aug 13, 2014 9:14:53 AM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjsip/src/pjsua2/endpoint.cpp
r4847 r4887 27 27 using namespace std; 28 28 29 #include <pjsua2/account.hpp> 30 #include <pjsua2/call.hpp> 29 #include <pjsua-lib/pjsua_internal.h> /* For retrieving pjsua threads */ 31 30 32 31 #define THIS_FILE "endpoint.cpp" … … 1218 1217 PJSUA2_CHECK_EXPR( pjsua_create() ); 1219 1218 mainThread = pj_thread_this(); 1219 1220 /* Register library main thread */ 1221 threadDescMap[pj_thread_this()] = NULL; 1220 1222 } 1221 1223 … … 1278 1280 /* Init! */ 1279 1281 PJSUA2_CHECK_EXPR( pjsua_init(&ua_cfg, &log_cfg, &med_cfg) ); 1282 1283 /* Register worker threads */ 1284 int i = pjsua_var.ua_cfg.thread_cnt; 1285 while (i) { 1286 pj_thread_t *t = pjsua_var.thread[--i]; 1287 if (t) 1288 threadDescMap[t] = NULL; 1289 } 1290 1291 /* Register media endpoint worker thread */ 1292 pjmedia_endpt *medept = pjsua_get_pjmedia_endpt(); 1293 i = pjmedia_endpt_get_thread_count(medept); 1294 while (i) { 1295 pj_thread_t *t = pjmedia_endpt_get_thread(medept, --i); 1296 if (t) 1297 threadDescMap[t] = NULL; 1298 } 1280 1299 } 1281 1300 … … 1285 1304 } 1286 1305 1287 void Endpoint::libRegisterWorkerThread(const string &name) throw(Error) 1288 { 1289 PJSUA2_CHECK_EXPR(pjsua_register_worker_thread(name.c_str())); 1306 void Endpoint::libRegisterThread(const string &name) throw(Error) 1307 { 1308 pj_thread_t *thread; 1309 pj_thread_desc *desc; 1310 pj_status_t status; 1311 1312 desc = (pj_thread_desc*)malloc(sizeof(pj_thread_desc)); 1313 status = pj_thread_register(name.c_str(), *desc, &thread); 1314 if (status == PJ_SUCCESS) { 1315 threadDescMap[thread] = desc; 1316 } else { 1317 free(desc); 1318 PJSUA2_RAISE_ERROR(status); 1319 } 1320 } 1321 1322 bool Endpoint::libIsThreadRegistered() 1323 { 1324 if (pj_thread_is_registered()) { 1325 /* Recheck again if it exists in the thread description map */ 1326 return (threadDescMap.find(pj_thread_this()) != threadDescMap.end()); 1327 } 1328 1329 return false; 1290 1330 } 1291 1331 … … 1315 1355 } 1316 1356 #endif 1357 1358 /* Clean up thread descriptors */ 1359 std::map<pj_thread_t*, pj_thread_desc*>::iterator i; 1360 for (i = threadDescMap.begin(); i != threadDescMap.end(); ++i) { 1361 pj_thread_desc* d = (*i).second; 1362 if (d != NULL) 1363 free(d); 1364 } 1365 threadDescMap.clear(); 1317 1366 1318 1367 PJSUA2_CHECK_RAISE_ERROR(status);
Note: See TracChangeset
for help on using the changeset viewer.