Ignore:
Timestamp:
Nov 1, 2013 7:11:48 AM (11 years ago)
Author:
bennylp
Message:

Re #1519: Major change in pjsua2.i and etc after actual test in Python:

  • Major changes in SWIG interface file (pjsua2.i).
    • The "ignore" and "unignore" approach caused link error with vector (duplicate symbols because SWIG generates two identical vector functions in the wrapper) so it cannot be used (tried with many combinations and still doesn't work).
    • So scrap that, and now we use "importing" approach, where needed symbols must be listed in symbols.lst file, then use importsym.py to import the symbol declarations to symbols.i. Then include symbols.i in pjsua.i
    • Due to the way importsym.py work, some macros and naked constants need to be placed into a named enumeration, for example:
      • #define PJ_SUCCESS 0 ==> enum pj_constants_ { PJ_SUCCESS=0 }; [types.h]
      • enum { PJMEDIA_VID_DEFAULT_CAPTURE_DEV = -1 } ==> enum pjmedia_vid_dev_std_index { PJMEDIA_VID_DEFAULT_CAPTURE_DEV = -1 }; [videodev.h]
    • Makefile was changed so that symbols.i would be generated if symbols.lst has changed
  • Added "make install" and "make uninstall" targets for swig. Only implemented on Python. This will install to user's lib dir so doesn't need sudo.
  • Deleted approachX.hpp files
  • Added libVersion() method to Endpoint along with Version struct.
  • Fix pjsua2.i to make exception (or redirection?) works in Python
  • Add polling and worker thread related API:
    • PJSUA-LIB: pjsua_register_worker_thread(), pjsua_stop_worker_threads()
    • Endpoint: libRegisterWorkerThread(), libStopWorkerThreads(), libHandleEvents();
File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/branches/projects/pjsua2/pjsip/src/pjsua-lib/pjsua_core.c

    r4555 r4639  
    687687} 
    688688 
     689PJ_DEF(pj_status_t) pjsua_register_worker_thread(const char *name) 
     690{ 
     691    pj_thread_desc desc; 
     692    pj_thread_t *thread; 
     693    pj_status_t status; 
     694 
     695    if (pjsua_var.thread_quit_flag) 
     696        return PJ_EGONE; 
     697 
     698    status = pj_thread_register(NULL, desc, &thread); 
     699    if (status != PJ_SUCCESS) 
     700        return status; 
     701 
     702    if (name) 
     703        PJ_LOG(4,(THIS_FILE, "Worker thread %s started", name)); 
     704 
     705    worker_thread(NULL); 
     706 
     707    if (name) 
     708        PJ_LOG(4,(THIS_FILE, "Worker thread %s stopped", name)); 
     709 
     710    return PJ_SUCCESS; 
     711} 
     712 
     713PJ_DEF(void) pjsua_stop_worker_threads(void) 
     714{ 
     715    unsigned i; 
     716 
     717    pjsua_var.thread_quit_flag = 1; 
     718 
     719    /* Wait worker threads to quit: */ 
     720    for (i=0; i<(int)pjsua_var.ua_cfg.thread_cnt; ++i) { 
     721        if (pjsua_var.thread[i]) { 
     722            pj_status_t status; 
     723            status = pj_thread_join(pjsua_var.thread[i]); 
     724            if (status != PJ_SUCCESS) { 
     725                PJ_PERROR(4,(THIS_FILE, status, "Error joining worker thread")); 
     726                pj_thread_sleep(1000); 
     727            } 
     728            pj_thread_destroy(pjsua_var.thread[i]); 
     729            pjsua_var.thread[i] = NULL; 
     730        } 
     731    } 
     732} 
    689733 
    690734/* Init random seed */ 
     
    14661510 
    14671511    /* Signal threads to quit: */ 
    1468     pjsua_var.thread_quit_flag = 1; 
    1469  
    1470     /* Wait worker threads to quit: */ 
    1471     for (i=0; i<(int)pjsua_var.ua_cfg.thread_cnt; ++i) { 
    1472         if (pjsua_var.thread[i]) { 
    1473             pj_status_t status; 
    1474             status = pj_thread_join(pjsua_var.thread[i]); 
    1475             if (status != PJ_SUCCESS) { 
    1476                 PJ_PERROR(4,(THIS_FILE, status, "Error joining worker thread")); 
    1477                 pj_thread_sleep(1000); 
    1478             } 
    1479             pj_thread_destroy(pjsua_var.thread[i]); 
    1480             pjsua_var.thread[i] = NULL; 
    1481         } 
    1482     } 
     1512    pjsua_stop_worker_threads(); 
    14831513     
    14841514    if (pjsua_var.endpt) { 
Note: See TracChangeset for help on using the changeset viewer.