| 258 | === How can I disable multi-threading throughout the libraries? === #no-thread |
| 259 | |
| 260 | Below are some information about where threads are used in the libraries in most platforms except Symbian^1)^: |
| 261 | - the worker thread(s) for signaling (i.e. SIP and pjnath including STUN, TURN, ICE, etc.) created by PJSUA-LIB according to {{{pjsua_config.thread_cnt}}} setting (default is 1). |
| 262 | - the worker thread(s) for polling incoming RTP/RTCP packets, created by {{{pjsua_media_config.thread_cnt}}} setting (default is 1) |
| 263 | - sound device's worker thread(s) which drives the audio flow. Each sound device implementation has its own threading strategy, and usually it will create at least one thread. |
| 264 | - worker thread(s) to drive video flows (such as from capture device to encoder, and from decoder to renderer). |
| 265 | |
| 266 | Below are the strategies to disable multithreading: |
| 267 | 1. Use the following settings to disable PJSUA-LIB worker threads: |
| 268 | {{{ |
| 269 | pjsua_config cfg; |
| 270 | pjsua_media_config med_cfg; |
| 271 | |
| 272 | pjsua_config_default(&cfg); |
| 273 | cfg.thread_cnt = 0; |
| 274 | |
| 275 | pjsua_media_config_default(&med_cfg); |
| 276 | med_cfg.thread_cnt = 0; |
| 277 | med_cfg.has_ioqueue = PJ_FALSE; |
| 278 | |
| 279 | .. |
| 280 | pjsua_init(&cfg, .. &med_cfg); |
| 281 | }}} |
| 282 | Once PJSUA-LIB worker threads have been disabled as above, remember that you'd have to poll for events timely and periodically by calling {{{pjsua_handle_events()}}}. |
| 283 | 2. Currently the only way to disable threading in the sound device is by using sound device implementation that doesn't use threading. |
| 284 | 3. And currently threading is needed for video, thus you need to disable video if you want to disable multithreading. Set {{{PJMEDIA_HAS_VIDEO}}} to 0 in {{{config_site.h}}}. |
| 285 | 4. Lastly, we can now disable threading altogether at compile time, by setting {{{PJ_HAS_THREADS}}} to 0 in {{{config_site.h}}}. |
| 286 | |
| 287 | Note: |
| 288 | ^1)^ multithreading is not used by pjsip in Symbian |