Ignore:
Timestamp:
Nov 1, 2013 7:11:48 AM (10 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-apps/src/swig/pjsua2.i

    r4638 r4639  
    1515%} 
    1616 
     17#ifdef SWIGPYTHON 
     18  %feature("director:except") { 
     19    if( $error != NULL ) { 
     20      PyObject *ptype, *pvalue, *ptraceback; 
     21      PyErr_Fetch( &ptype, &pvalue, &ptraceback ); 
     22      PyErr_Restore( ptype, pvalue, ptraceback ); 
     23      PyErr_Print(); 
     24      //Py_Exit(1); 
     25    } 
     26  } 
     27#endif 
     28 
     29// Constants from PJSIP libraries 
     30%include "symbols.i" 
     31 
     32 
     33// 
     34// Classes that can be extended in the target language 
     35// 
     36%feature("director") LogWriter; 
     37%feature("director") Endpoint;  
     38%feature("director") Account; 
     39 
     40 
    1741// 
    1842// STL stuff. 
     
    2145%include "std_vector.i" 
    2246 
    23 namespace std 
    24 { 
    25         %template(StringVector) std::vector<std::string>; 
    26         %template(IntVector) std::vector<int>; 
    27         %template(AuthCredInfoVector) std::vector<AuthCredInfo>; 
    28         %template(SipMultipartPartVector) std::vector<SipMultipartPart>; 
    29         %template(SipHeaderVector) std::vector<SipHeader>; 
    30 } 
     47 
     48%template(StringVector)                 std::vector<std::string>; 
     49%template(IntVector)                    std::vector<int>; 
    3150 
    3251// 
    33 // Classes that can be extended in the target language 
    34 // 
    35 %feature("director") LogWriter;  
    36 %feature("director") EpCallback; 
    37  
    38 // 
    39 // And include supporting constants etc. Here we don't want to export 
    40 // the whole file, so we start with ignoring everything and then enable 
    41 // selected symbols   
    42 // 
    43 #define PJ_BEGIN_DECL 
    44 #define PJ_END_DECL 
    45 #define PJ_DECL(type)           type 
    46 #define PJ_INLINE(type)         type 
    47 #define PJ_DECL_DATA(type)      extern type 
    48  
    49 // 
    50 // Start with ignoring everything 
    51 // 
    52 %ignore ""; 
    53  
    54 // Process the files. Keep them sorted. 
    55  
    56 // 
    57 // 
    58 %rename("%s") pj_file_access;                           // Unignore this 
    59 %rename("%s", regexmatch$name="PJ_O_.*") "";            // Unignore this 
    60 %include "pj/file_io.h" 
    61  
    62 // 
    63 // 
    64 %rename("%s") pj_log_decoration;                        // Unignore this 
    65 %rename("%s", regexmatch$name="PJ_LOG_HAS_.*") "";      // Unignore this 
    66 %include "pj/log.h" 
    67  
    68 // 
    69 // 
    70 %rename("%s") pj_qos_type;                              // Unignore this 
    71 %rename("%s", regexmatch$name="PJ_QOS_TYPE_.*") "";     // Unignore this 
    72 %rename("%s") pj_qos_flag;                              // Unignore this 
    73 %rename("%s", regexmatch$name="PJ_QOS_PARAM_HAS_.*") "";// Unignore this 
    74 %rename("%s") pj_qos_wmm_prio;                          // Unignore this 
    75 %rename("%s", regexmatch$name="PJ_QOS_WMM_PRIO_.*") ""; // Unignore this 
    76 // TODO: 
    77 //  Wish there is a better way to unignore a struct than 
    78 //  listing the fields one by one like below. Using regex 
    79 //  doesn't seem to work? 
    80 %rename("%s") pj_qos_params;                            // Unignore this 
    81 %rename("%s") pj_qos_params::flags;                     // Unignore this 
    82 %rename("%s") pj_qos_params::dscp_val;                  // Unignore this 
    83 %rename("%s") pj_qos_params::so_prio;                   // Unignore this 
    84 %rename("%s") pj_qos_params::wmm_prio;                  // Unignore this 
    85 %include "pj/sock_qos.h" 
    86  
    87 // 
    88 // 
    89 %rename("%s") pj_ssl_cipher;                            // Unignore this 
    90 %rename("%s", regexmatch$name="PJ_O_.*") "";            // Unignore this 
    91 %include "pj/ssl_sock.h" 
    92  
    93 // 
    94 // 
    95 %rename("%s") pj_status_t;                              // Unignore this 
    96 %rename("%s") PJ_SUCCESS;                               // Unignore this 
    97 %include "pj/types.h" 
    98  
    99 // 
    100 // 
    101 %rename("%s") pj_stun_nat_type;                         // Unignore this 
    102 %rename("%s", regexmatch$name="PJ_STUN_NAT_TYPE_.*") "";// Unignore this 
    103 %include "pjnath/nat_detect.h" 
    104  
    105 // 
    106 // 
    107 %rename("%s") pj_turn_tp_type;                          // Unignore this 
    108 %rename("%s", regexmatch$name="PJ_TURN_TP_.*") "";      // Unignore this 
    109 %include "pjnath/turn_session.h" 
    110  
    111 // 
    112 // 
    113 %rename("%s") pjmedia_vid_stream_rc_method;             // Unignore this 
    114 %rename("%s", regexmatch$name="PJMEDIA_VID_STREAM_RC_.*") "";// Unignore this 
    115 %include "pjmedia/vid_stream.h" 
    116  
    117 // 
    118 // 
    119 %rename("%s") pjmedia_srtp_use;                         // Unignore this 
    120 %rename("%s", regexmatch$name="PJMEDIA_SRTP_.*") "";    // Unignore this 
    121 %include "pjmedia/transport_srtp.h" 
    122  
    123 // 
    124 // 
    125 %rename("%s") pjmedia_vid_dev_index;                    // Unignore this 
    126 %rename("%s") PJMEDIA_VID_DEFAULT_CAPTURE_DEV;          // Unignore this 
    127 %rename("%s") PJMEDIA_VID_DEFAULT_RENDER_DEV;           // Unignore this 
    128 %rename("%s") PJMEDIA_VID_INVALID_DEV;                  // Unignore this 
    129 %include "pjmedia-videodev/videodev.h" 
    130  
    131 // 
    132 // 
    133 %rename("%s") pjsip_cred_data_type;                     // Unignore this 
    134 %rename("%s", regexmatch$name="PJSIP_CRED_DATA_.*") ""; // Unignore this 
    135 %include "pjsip/sip_auth.h" 
    136  
    137 // 
    138 // 
    139 %rename("%s") pjsip_status_code;                        // Unignore this 
    140 %rename("%s", regexmatch$name="PJSIP_SC_.*") "";        // Unignore this 
    141 %include "pjsip/sip_msg.h" 
    142  
    143 // 
    144 // 
    145 %rename("%s") pjsip_transport_type_e;                   // Unignore this 
    146 %rename("%s") pjsip_transport_flags_e;                  // Unignore this 
    147 %rename("%s") pjsip_transport_state;                    // Unignore this 
    148 %rename("%s", regexmatch$name="PJSIP_TRANSPORT_.*") ""; // Unignore this 
    149 %rename("%s", regexmatch$name="PJSIP_TP_STATE_.*") "";  // Unignore this 
    150 %include "pjsip/sip_transport.h" 
    151  
    152 // 
    153 // 
    154 %rename("%s") pjsip_ssl_method;                         // Unignore this 
    155 %rename("%s", regexmatch$name="PJSIP_TLS.*_METHOD") ""; // Unignore this 
    156 %rename("%s", regexmatch$name="PJSIP_SSL.*_METHOD") ""; // Unignore this 
    157 %include "pjsip/sip_transport_tls.h" 
    158  
    159 // 
    160 // 
    161 %rename("%s") PJSUA_INVALID_ID;                         // Unignore this 
    162 %rename("%s") pjsua_state;                              // Unignore this 
    163 %rename("%s", regexmatch$name="PJSUA_STATE_.*") "";     // Unignore this 
    164 %rename("%s") pjsua_stun_use;                           // Unignore this 
    165 %rename("%s", regexmatch$name="PJSUA_STUN_USE_.*") "";  // Unignore this 
    166 %rename("%s") pjsua_call_hold_type;                     // Unignore this 
    167 %rename("%s", regexmatch$name="PJSUA_CALL_HOLD_TYPE_.*") "";// Unignore this 
    168 %rename("%s") pjsua_acc_id;                             // Unignore this 
    169 %rename("%s") pjsua_destroy_flag;                       // Unignore this 
    170 %rename("%s", regexmatch$name="PJSUA_DESTROY_.*") "";   // Unignore this 
    171 %include "pjsua-lib/pjsua.h" 
    172  
    173 // 
    174 // Back to unignore everything 
    175 // 
    176 %rename("%s") ""; 
    177  
    178 // 
    179 // Ignore stuffs in pjsua2 itself 
     52// Ignore stuffs in pjsua2 
    18053// 
    18154%ignore fromPj; 
     
    18659// 
    18760%include "pjsua2/types.hpp" 
     61%template(SipHeaderVector)              std::vector<pj::SipHeader>; 
     62%template(AuthCredInfoVector)           std::vector<pj::AuthCredInfo>; 
     63%template(SipMultipartPartVector)       std::vector<pj::SipMultipartPart>; 
     64 
    18865%include "pjsua2/endpoint.hpp" 
    189 #include "pjsua2/account.hpp" 
     66%include "pjsua2/account.hpp" 
    19067 
Note: See TracChangeset for help on using the changeset viewer.