Changeset 4638


Ignore:
Timestamp:
Oct 25, 2013 10:34:38 AM (11 years ago)
Author:
bennylp
Message:

Re #1519: Implementation of Account API, with inheritance approach:

  • With small demo app (samples/pjsua2_demo.cpp)
  • Endpoint changed to use inheritance approach too
  • Simple account registration demo and callback works
  • Further tests will be done in high level app (Python GUI?)
  • Temporary build setting fixes (Makefile) to allow linking with pjsua2 and libstdc++
  • Temporary hacks in Makefile to ignore other build targets to speed up build. This should be fixed during integration.

Issues:

  • incomplete Endpoint::on_incoming_subscribe() implementation. There is no Account::presNotify() yet.
  • incomplete Endpoint::on_pager2(), on_pager_status2(), to handle call's pager rather than account's pager
  • some SWIGTYPE (unknown type by Swig) still unresolved
Location:
pjproject/branches/projects/pjsua2
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • pjproject/branches/projects/pjsua2/build.mak.in

    r4631 r4638  
    145145        $(APP_THIRD_PARTY_EXT)\ 
    146146        -lpj-$(TARGET_NAME)\ 
    147         @LIBS@ 
     147        @LIBS@ \ 
     148        -lstdc++ 
    148149#  x   x  x  x  x  x  x   x  x  x  x  x  x   x  x  x  x  x  x   x  x  x  x  x 
    149150# 
  • pjproject/branches/projects/pjsua2/pjsip-apps/src/samples/pjsua2_demo.cpp

    r4631 r4638  
    2323using namespace pj; 
    2424 
    25 class MyAccountCallback : public AccountCallback 
     25class MyAccount : public Account 
    2626{ 
    2727public: 
    28     MyAccountCallback() 
    29     : AccountCallback() 
     28    MyAccount() 
    3029    {} 
    3130 
    3231    virtual void onRegState(OnRegStateParam &prm) 
    3332    { 
    34         AccountInfo ai = account()->getInfo(); 
     33        AccountInfo ai = getInfo(); 
    3534        std::cout << (ai.regIsActive? "*** Register: code=" : "*** Unregister: code=") 
    3635                  << prm.code << std::endl; 
     
    4039static void mainProg() throw(Error) 
    4140{ 
    42     Endpoint & ep = Endpoint::instance(); 
     41    Endpoint ep; 
    4342 
    4443    // Create library 
     
    4645 
    4746    // Init library 
    48     ep.libInit( EpConfig() ); 
     47    EpConfig ep_cfg; 
     48    ep_cfg.logConfig.level = 4; 
     49    ep.libInit( ep_cfg ); 
    4950 
    5051    // Transport 
     
    6364    acc_cfg.sipConfig.authCreds.push_back( AuthCredInfo("digest", "*", 
    6465                                                        "test1", 0, "test1") ); 
    65     std::auto_ptr<Account> acc(new Account(new MyAccountCallback, NULL)); 
     66    std::auto_ptr<Account> acc(new MyAccount); 
    6667    acc->create(acc_cfg); 
    6768 
     
    7071    // Destroy library 
    7172    std::cout << "*** PJSUA2 SHUTTING DOWN ***" << std::endl; 
    72     ep.libDestroy(); 
    7373} 
    7474 
     
    8484    } 
    8585 
    86     Endpoint::instance().libDestroy(); 
    87  
    8886    return ret; 
    8987} 
  • pjproject/branches/projects/pjsua2/pjsip-apps/src/swig/java/Makefile

    r4619 r4638  
    4343MY_LDFLAGS       = $(PJ_LDFLAGS) -lpjsua2-$(TARGET_NAME) $(PJ_LDLIBS) $(MY_JNI_LDFLAGS) -static-libstdc++ 
    4444 
     45.PHONY: all java 
     46 
    4547all: $(LIBPJSUA2_SO) java 
    4648 
     
    5759        rm -rf $(OUT_DIR)/pjsua2_wrap.cpp $(OUT_DIR)/pjsua2_wrap.o $(LIBPJSUA2_SO) $(OUT_DIR)/*.java $(OUT_DIR)/*.class 
    5860 
    59 java: 
     61java: output/Error.class output/test.class 
     62 
     63output/Error.class: output/Error.java 
    6064        $(MY_JAVAC) -d $(OUT_DIR) $(OUT_DIR)/*.java 
     65 
     66output/test.class: test.java 
    6167        $(MY_JAVAC) -d $(OUT_DIR) -classpath "$(OUT_DIR)" test.java 
    6268 
  • pjproject/branches/projects/pjsua2/pjsip-apps/src/swig/pjsua2.i

    r4608 r4638  
    1010// 
    1111%{ 
    12 #include "pjsua2/endpoint.hpp" 
     12#include "pjsua2.hpp" 
    1313using namespace std; 
    1414using namespace pj; 
     
    167167%rename("%s", regexmatch$name="PJSUA_CALL_HOLD_TYPE_.*") "";// Unignore this 
    168168%rename("%s") pjsua_acc_id;                             // Unignore this 
     169%rename("%s") pjsua_destroy_flag;                       // Unignore this 
     170%rename("%s", regexmatch$name="PJSUA_DESTROY_.*") "";   // Unignore this 
    169171%include "pjsua-lib/pjsua.h" 
    170172 
     
    175177 
    176178// 
     179// Ignore stuffs in pjsua2 itself 
     180// 
     181%ignore fromPj; 
     182%ignore toPj; 
     183 
     184// 
    177185// Now include the API itself. 
    178186// 
    179187%include "pjsua2/types.hpp" 
    180188%include "pjsua2/endpoint.hpp" 
     189#include "pjsua2/account.hpp" 
    181190 
  • pjproject/branches/projects/pjsua2/pjsip-apps/src/swig/python/helper.mak

    r4619 r4638  
    1717 
    1818target_name: 
    19         $(TARGET_NAME) 
     19        @echo $(TARGET_NAME) 
    2020         
  • pjproject/branches/projects/pjsua2/pjsip/include/pjsua2/account.hpp

    r4631 r4638  
    878878{ 
    879879    /** 
    880      * The library call index allocated for the new call. 
    881      */ 
    882     int                 callIndex; 
     880     * The library call ID allocated for the new call. 
     881     */ 
     882    int                 callId; 
    883883 
    884884    /** 
     
    917917     * SIP reason phrase received. 
    918918     */ 
    919     pj_str_t            reason; 
     919    string              reason; 
    920920 
    921921    /** 
     
    10851085}; 
    10861086 
    1087 /** 
    1088  * Account callback 
    1089  */ 
    1090 class AccountCallback 
     1087 
     1088/** 
     1089 * @}  // PJSUA2_Acc_Data_Structure 
     1090 */ 
     1091 
     1092/** 
     1093 * @addtogroup PJSUA2_ACC 
     1094 * @{ 
     1095 */ 
     1096 
     1097 
     1098/** 
     1099 * Account. 
     1100 */ 
     1101class Account 
    10911102{ 
    10921103public: 
    1093     /** Virtual destructor */ 
    1094     virtual ~AccountCallback() {} 
    1095  
    1096     /** 
    1097      * Get the account associated with this callback. 
    1098      */ 
    1099     Account *account() 
    1100     { return acc; } 
    1101  
     1104    /** 
     1105     * Constructor. 
     1106     */ 
     1107    Account(); 
     1108 
     1109    /** 
     1110     * Destructor. Note that if the account is deleted, it will also delete 
     1111     * the corresponding account in the PJSUA-LIB. 
     1112     */ 
     1113    virtual ~Account(); 
     1114 
     1115    /** 
     1116     * Create the account. 
     1117     * 
     1118     * @param cfg               The account config. 
     1119     * @param make_default      Make this the default account. 
     1120     */ 
     1121    void create(const AccountConfig &cfg, 
     1122                bool make_default=false) throw(Error); 
     1123 
     1124    /** 
     1125     * Modify the account to use the specified account configuration. 
     1126     * Depending on the changes, this may cause unregistration or 
     1127     * reregistration on the account. 
     1128     * 
     1129     * @param cfg               New account config to be applied to the account. 
     1130     */ 
     1131    void modify(const AccountConfig &acc) throw(Error); 
     1132 
     1133    /** 
     1134     * Check if this account is still valid. 
     1135     * 
     1136     * @return                  True if it is. 
     1137     */ 
     1138    bool isValid() const; 
     1139 
     1140    /** 
     1141     * Set this as default account to be used when incoming and outgoing 
     1142     * requests don't match any accounts. 
     1143     * 
     1144     * @return                  PJ_SUCCESS on success. 
     1145     */ 
     1146    void setDefault() throw(Error); 
     1147 
     1148    /** 
     1149     * Check if this account is the default account. Default account will be 
     1150     * used for incoming and outgoing requests that don't match any other 
     1151     * accounts. 
     1152     * 
     1153     * @return                  True if this is the default account. 
     1154     */ 
     1155    bool isDefault() const; 
     1156 
     1157    /** 
     1158     * Get PJSUA-LIB account ID or index associated with this account. 
     1159     * 
     1160     * @return                  Integer greater than or equal to zero. 
     1161     */ 
     1162    int getId() const; 
     1163 
     1164    /** 
     1165     * Get the Account class for the specified account Id. 
     1166     * 
     1167     * @param acc_id            The account ID to lookup 
     1168     * 
     1169     * @return                  The Account instance or NULL if not found. 
     1170     */ 
     1171    static Account *lookup(int acc_id); 
     1172 
     1173    /** 
     1174     * Get account info. 
     1175     * 
     1176     * @return                  Account info. 
     1177     */ 
     1178    AccountInfo getInfo() const throw(Error); 
     1179 
     1180    /** 
     1181     * Update registration or perform unregistration. Application normally 
     1182     * only needs to call this function if it wants to manually update the 
     1183     * registration or to unregister from the server. 
     1184     * 
     1185     * @param renew             If False, this will start unregistration 
     1186     *                          process. 
     1187     */ 
     1188    void setRegistration(bool renew) throw(Error); 
     1189 
     1190    /** 
     1191     * Set or modify account's presence online status to be advertised to 
     1192     * remote/presence subscribers. This would trigger the sending of 
     1193     * outgoing NOTIFY request if there are server side presence subscription 
     1194     * for this account, and/or outgoing PUBLISH if presence publication is 
     1195     * enabled for this account. 
     1196     * 
     1197     * @param pres_st           Presence online status. 
     1198     */ 
     1199    void setOnlineStatus(const AccountPresenceStatus &pres_st) throw(Error); 
     1200 
     1201    /** 
     1202     * Lock/bind this account to a specific transport/listener. Normally 
     1203     * application shouldn't need to do this, as transports will be selected 
     1204     * automatically by the library according to the destination. 
     1205     * 
     1206     * When account is locked/bound to a specific transport, all outgoing 
     1207     * requests from this account will use the specified transport (this 
     1208     * includes SIP registration, dialog (call and event subscription), and 
     1209     * out-of-dialog requests such as MESSAGE). 
     1210     * 
     1211     * Note that transport id may be specified in AccountConfig too. 
     1212     * 
     1213     * @param tp_id             The transport ID. 
     1214     */ 
     1215    void setTransport(TransportId tp_id) throw(Error); 
     1216 
     1217public: 
     1218    /* 
     1219     * Callbacks 
     1220     */ 
    11021221    /** 
    11031222     * Notify application on incoming call. 
     
    12021321 
    12031322protected: 
    1204     AccountCallback() 
    1205     : acc(NULL) 
    1206     {} 
    1207  
    1208 private: 
    1209     Account *acc; 
    1210  
    1211     /** Set the account. Must only be called by Account class */ 
    1212     void setAccount(Account *the_acc) 
    1213     { acc = the_acc; } 
    1214  
    1215     friend class Account; 
    1216 }; 
    1217  
    1218  
    1219 /** 
    1220  * @}  // PJSUA2_Acc_Data_Structure 
    1221  */ 
    1222  
    1223 /** 
    1224  * @addtogroup PJSUA2_ACC 
    1225  * @{ 
    1226  */ 
    1227  
    1228  
    1229 /** 
    1230  * Account. 
    1231  */ 
    1232 class Account 
    1233 { 
    1234 public: 
    1235     /** 
    1236      * Constructor. 
    1237      */ 
    1238     Account(AccountCallback *cb, Token user_data); 
    1239  
    1240     /** 
    1241      * Destructor. 
    1242      */ 
    1243     ~Account(); 
    1244  
    1245     /** 
    1246      * Create the account. 
    1247      * 
    1248      * @param cfg               The account config. 
    1249      * @param make_default      Make this the default account. 
    1250      */ 
    1251     void create(const AccountConfig &cfg, 
    1252                 bool make_default=false) throw(Error); 
    1253  
    1254     /** 
    1255      * Modify the account to use the specified account configuration. 
    1256      * Depending on the changes, this may cause unregistration or 
    1257      * reregistration on the account. 
    1258      * 
    1259      * @param cfg               New account config to be applied to the account. 
    1260      */ 
    1261     void modify(const AccountConfig &acc) throw(Error); 
    1262  
    1263     /** 
    1264      * Check if this account is still valid. 
    1265      * 
    1266      * @return                  True if it is. 
    1267      */ 
    1268     bool isValid() const; 
    1269  
    1270     /** 
    1271      * Set this as default account to be used when incoming and outgoing 
    1272      * requests don't match any accounts. 
    1273      * 
    1274      * @return                  PJ_SUCCESS on success. 
    1275      */ 
    1276     void setDefault() throw(Error); 
    1277  
    1278     /** 
    1279      * Check if this account is the default account. Default account will be 
    1280      * used for incoming and outgoing requests that don't match any other 
    1281      * accounts. 
    1282      * 
    1283      * @return                  True if this is the default account. 
    1284      */ 
    1285     bool isDefault() const; 
    1286  
    1287     /** 
    1288      * Get PJSUA-LIB account ID or index associated with this account. 
    1289      * 
    1290      * @return                  Integer greater than or equal to zero. 
    1291      */ 
    1292     int getIndex() const; 
    1293  
    1294     /** 
    1295      * Set arbitrary data to be associated with the account. 
    1296      * 
    1297      * @param user_data         User/application data. 
    1298      */ 
    1299     void setUserData(Token user_data); 
    1300  
    1301     /** 
    1302      * Get the user data that was associated with the account. 
    1303      * 
    1304      * @return                  The user data. 
    1305      */ 
    1306     Token getUserData() const; 
    1307  
    1308     /** 
    1309      * Get account info. 
    1310      * 
    1311      * @return                  Account info. 
    1312      */ 
    1313     AccountInfo getInfo() const throw(Error); 
    1314  
    1315     /** 
    1316      * Update registration or perform unregistration. Application normally 
    1317      * only needs to call this function if it wants to manually update the 
    1318      * registration or to unregister from the server. 
    1319      * 
    1320      * @param renew             If False, this will start unregistration 
    1321      *                          process. 
    1322      */ 
    1323     void setRegistration(bool renew) throw(Error); 
    1324  
    1325     /** 
    1326      * Set or modify account's presence online status to be advertised to 
    1327      * remote/presence subscribers. This would trigger the sending of 
    1328      * outgoing NOTIFY request if there are server side presence subscription 
    1329      * for this account, and/or outgoing PUBLISH if presence publication is 
    1330      * enabled for this account. 
    1331      * 
    1332      * @param pres_st           Presence online status. 
    1333      */ 
    1334     void setOnlineStatus(const AccountPresenceStatus &pres_st) throw(Error); 
    1335  
    1336     /** 
    1337      * Lock/bind this account to a specific transport/listener. Normally 
    1338      * application shouldn't need to do this, as transports will be selected 
    1339      * automatically by the library according to the destination. 
    1340      * 
    1341      * When account is locked/bound to a specific transport, all outgoing 
    1342      * requests from this account will use the specified transport (this 
    1343      * includes SIP registration, dialog (call and event subscription), and 
    1344      * out-of-dialog requests such as MESSAGE). 
    1345      * 
    1346      * Note that transport id may be specified in AccountConfig too. 
    1347      * 
    1348      * @param tp_id             The transport ID. 
    1349      */ 
    1350     void setTransport(TransportId tp_id) throw(Error); 
    1351  
    1352 protected: 
    13531323    friend class Endpoint; 
    13541324 
    13551325private: 
    13561326    pjsua_acc_id         id; 
    1357     AccountCallback     *cb; 
    1358     Token                userData; 
     1327    string               tmpReason;     // for saving response's reason 
    13591328}; 
    13601329 
  • pjproject/branches/projects/pjsua2/pjsip/include/pjsua2/endpoint.hpp

    r4608 r4638  
    4343 
    4444/** 
    45  * Argument to EpCallback::onNatDetectionComplete() callback. 
     45 * Argument to Endpoint::onNatDetectionComplete() callback. 
    4646 */ 
    4747struct OnNatDetectionCompleteParam 
     
    7373 
    7474/** 
    75  * Argument to EpCallback::onNatCheckStunServersComplete() callback. 
     75 * Argument to Endpoint::onNatCheckStunServersComplete() callback. 
    7676 */ 
    7777struct OnNatCheckStunServersCompleteParam 
     
    104104 
    105105/** 
    106  * Parameter of EpCallback::OnTimer() callback. 
     106 * Parameter of Endpoint::onTimer() callback. 
    107107 */ 
    108108struct OnTimerParam 
     
    121121 
    122122/** 
    123  * Parameter of EpCallback::onTransportState() callback. 
     123 * Parameter of Endpoint::onTransportState() callback. 
    124124 */ 
    125125struct OnTransportStateParam 
     
    142142 
    143143/** 
    144  * Parameter of EpCallback::onSelectAccount() callback. 
     144 * Parameter of Endpoint::onSelectAccount() callback. 
    145145 */ 
    146146struct OnSelectAccountParam 
     
    159159    int                 accountIndex; 
    160160}; 
    161  
    162 ////////////////////////////////////////////////////////////////////////////// 
    163  
    164 /** 
    165  * Interface for receiving callbacks from the library. Application inherits 
    166  * this class and specify the instance when calling Endpoint::libInit(). 
    167  */ 
    168 class EpCallback 
    169 { 
    170 public: 
    171     /** Virtual destructor */ 
    172     virtual ~EpCallback() {} 
    173  
    174     /** 
    175      * Callback when the Endpoint has finished performing NAT type 
    176      * detection that is initiated with Endpoint::natDetectType(). 
    177      * 
    178      * @param prm       Callback parameters containing the detection 
    179      *                  result. 
    180      */ 
    181     virtual void onNatDetectionComplete( 
    182                         const OnNatDetectionCompleteParam &prm) 
    183     {} 
    184  
    185     /** 
    186      * Callback when the Endpoint has finished performing STUN server 
    187      * checking that is initiated with Endpoint::natCheckStunServers(). 
    188      * 
    189      * @param prm       Callback parameters. 
    190      */ 
    191     virtual void onNatCheckStunServersComplete( 
    192                         const OnNatCheckStunServersCompleteParam &prm) 
    193     {} 
    194  
    195     /** 
    196      * This callback is called when transport state has changed. 
    197      * 
    198      * @param prm       Callback parameters. 
    199      */ 
    200     virtual void onTransportState( 
    201                         const OnTransportStateParam &prm) 
    202     {} 
    203  
    204     /** 
    205      * Callback when a timer has fired. The timer was scheduled by 
    206      * Endpoint::utilTimerSchedule(). 
    207      * 
    208      * @param prm       Callback parameters. 
    209      */ 
    210     virtual void onTimer(const OnTimerParam &prm) 
    211     {} 
    212  
    213     /** 
    214      * This callback can be used by application to override the account 
    215      * to be used to handle an incoming message. Initially, the account to 
    216      * be used will be calculated automatically by the library. This initial 
    217      * account will be used if application does not implement this callback, 
    218      * or application sets an invalid account upon returning from this 
    219      * callback. 
    220      * 
    221      * Note that currently the incoming messages requiring account assignment 
    222      * are INVITE, MESSAGE, SUBSCRIBE, and unsolicited NOTIFY. This callback 
    223      * may be called before the callback of the SIP event itself, i.e: 
    224      * incoming call, pager, subscription, or unsolicited-event. 
    225      * 
    226      * @param prm       Callback parameters. 
    227      */ 
    228     virtual void onSelectAccount(OnSelectAccountParam &prm) 
    229     {} 
    230 }; 
    231  
    232161 
    233162////////////////////////////////////////////////////////////////////////////// 
     
    313242     * 
    314243     * If this is enabled, the library will respond 200/OK to the NOTIFY 
    315      * request and forward the request to EpCallback.onMwiInfo() callback. 
     244     * request and forward the request to Endpoint::onMwiInfo() callback. 
    316245     * 
    317246     * See also AccountMwiConfig.enabled. 
     
    407336 
    408337    /** 
    409      * Custom log writer, if required. If specified, the instance of LogWriter 
    410      * must be kept alive througout the duration of the application. 
     338     * Custom log writer, if required. This instance will be destroyed 
     339     * by the endpoint when the endpoint is destroyed. 
    411340     */ 
    412341    LogWriter           *writer; 
     
    655584public: 
    656585    /** Retrieve the singleton instance of the endpoint */ 
    657     static Endpoint &instance(); 
    658  
    659     /* For testing */ 
    660     void testException() throw(Error); 
     586    static Endpoint &instance() throw(Error); 
     587 
     588    /** Default constructor */ 
     589    Endpoint(); 
     590 
     591    /** Virtual destructor */ 
     592    virtual ~Endpoint(); 
    661593 
    662594 
     
    688620     * 
    689621     * @param prmEpConfig       Endpoint configurations 
    690      * @param prmCb             Optional callback to receive events from the 
    691      *                          library. If specified, this instance must be 
    692      *                          kept alive throughout the lifetime of the 
    693      *                          library. 
    694      */ 
    695     void libInit( const EpConfig &prmEpConfig, 
    696                   EpCallback *prmCb = NULL) throw(Error); 
     622     */ 
     623    void libInit( const EpConfig &prmEpConfig) throw(Error); 
    697624 
    698625    /** 
     
    770697    /** 
    771698     * Schedule a timer with the specified interval and user data. When the 
    772      * interval elapsed, EpCallback::OnTimer() callback will be 
     699     * interval elapsed, Endpoint::onTimer() callback will be 
    773700     * called. Note that the callback may be executed by different thread, 
    774701     * depending on whether worker thread is enabled or not. 
     
    803730     * This is a utility function to detect NAT type in front of this endpoint. 
    804731     * Once invoked successfully, this function will complete asynchronously 
    805      * and report the result in EpCallback::onNatDetectionComplete(). 
     732     * and report the result in Endpoint::onNatDetectionComplete(). 
    806733     * 
    807734     * After NAT has been detected and the callback is called, application can 
     
    817744     * Get the NAT type as detected by #natDetectType() function. This 
    818745     * function will only return useful NAT type after #natDetectType() 
    819      * has completed successfully and EpCallback::onNatDetectionComplete() 
     746     * has completed successfully and Endpoint::onNatDetectionComplete() 
    820747     * callback has been called. 
    821748     * 
     
    926853    void transportClose(TransportId id) throw(Error); 
    927854 
     855public: 
     856    /* 
     857     * Overrideables callbacks 
     858     */ 
     859 
     860    /** 
     861     * Callback when the Endpoint has finished performing NAT type 
     862     * detection that is initiated with Endpoint::natDetectType(). 
     863     * 
     864     * @param prm       Callback parameters containing the detection 
     865     *                  result. 
     866     */ 
     867    virtual void onNatDetectionComplete( 
     868                        const OnNatDetectionCompleteParam &prm) 
     869    {} 
     870 
     871    /** 
     872     * Callback when the Endpoint has finished performing STUN server 
     873     * checking that is initiated with Endpoint::natCheckStunServers(). 
     874     * 
     875     * @param prm       Callback parameters. 
     876     */ 
     877    virtual void onNatCheckStunServersComplete( 
     878                        const OnNatCheckStunServersCompleteParam &prm) 
     879    {} 
     880 
     881    /** 
     882     * This callback is called when transport state has changed. 
     883     * 
     884     * @param prm       Callback parameters. 
     885     */ 
     886    virtual void onTransportState( 
     887                        const OnTransportStateParam &prm) 
     888    {} 
     889 
     890    /** 
     891     * Callback when a timer has fired. The timer was scheduled by 
     892     * Endpoint::utilTimerSchedule(). 
     893     * 
     894     * @param prm       Callback parameters. 
     895     */ 
     896    virtual void onTimer(const OnTimerParam &prm) 
     897    {} 
     898 
     899    /** 
     900     * This callback can be used by application to override the account 
     901     * to be used to handle an incoming message. Initially, the account to 
     902     * be used will be calculated automatically by the library. This initial 
     903     * account will be used if application does not implement this callback, 
     904     * or application sets an invalid account upon returning from this 
     905     * callback. 
     906     * 
     907     * Note that currently the incoming messages requiring account assignment 
     908     * are INVITE, MESSAGE, SUBSCRIBE, and unsolicited NOTIFY. This callback 
     909     * may be called before the callback of the SIP event itself, i.e: 
     910     * incoming call, pager, subscription, or unsolicited-event. 
     911     * 
     912     * @param prm       Callback parameters. 
     913     */ 
     914    virtual void onSelectAccount(OnSelectAccountParam &prm) 
     915    {} 
     916 
    928917 
    929918private: 
    930     /* Anybody else can't instantiate Endpoint */ 
    931     Endpoint(); 
    932  
    933 private: 
    934     /* Custom writer, if any */ 
    935     LogWriter   *writer; 
    936     EpCallback  *epCallback; 
    937  
    938     /* 
    939      * Callbacks (static) 
    940      */ 
     919    static Endpoint     *instance_;     // static instance 
     920    LogWriter           *writer;        // Custom writer, if any 
     921 
     922    /* Endpoint static callbacks */ 
    941923    static void logFunc(int level, const char *data, int len); 
    942924    static void stun_resolve_cb(const pj_stun_resolve_result *result); 
     
    947929                                   pjsip_transport_state state, 
    948930                                   const pjsip_transport_state_info *info); 
     931 
     932private: 
     933    /* 
     934     * Account 
     935     */ 
     936    static Account      *lookupAcc(int acc_id, const char *op); 
     937 
     938    /* static callbacks */ 
     939    static void on_incoming_call(pjsua_acc_id acc_id, 
     940                                 pjsua_call_id call_id, 
     941                                 pjsip_rx_data *rdata); 
     942    static void on_reg_started(pjsua_acc_id acc_id, 
     943                               pj_bool_t renew); 
     944    static void on_reg_state2(pjsua_acc_id acc_id, 
     945                              pjsua_reg_info *info); 
     946    static void on_incoming_subscribe(pjsua_acc_id acc_id, 
     947                                      pjsua_srv_pres *srv_pres, 
     948                                      pjsua_buddy_id buddy_id, 
     949                                      const pj_str_t *from, 
     950                                      pjsip_rx_data *rdata, 
     951                                      pjsip_status_code *code, 
     952                                      pj_str_t *reason, 
     953                                      pjsua_msg_data *msg_data); 
     954    static void on_pager2(pjsua_call_id call_id, 
     955                          const pj_str_t *from, 
     956                          const pj_str_t *to, 
     957                          const pj_str_t *contact, 
     958                          const pj_str_t *mime_type, 
     959                          const pj_str_t *body, 
     960                          pjsip_rx_data *rdata, 
     961                          pjsua_acc_id acc_id); 
     962    static void on_pager_status2(pjsua_call_id call_id, 
     963                                 const pj_str_t *to, 
     964                                 const pj_str_t *body, 
     965                                 void *user_data, 
     966                                 pjsip_status_code status, 
     967                                 const pj_str_t *reason, 
     968                                 pjsip_tx_data *tdata, 
     969                                 pjsip_rx_data *rdata, 
     970                                 pjsua_acc_id acc_id); 
     971    static void on_typing2(pjsua_call_id call_id, 
     972                           const pj_str_t *from, 
     973                           const pj_str_t *to, 
     974                           const pj_str_t *contact, 
     975                           pj_bool_t is_typing, 
     976                           pjsip_rx_data *rdata, 
     977                           pjsua_acc_id acc_id); 
     978    static void on_mwi_info(pjsua_acc_id acc_id, 
     979                            pjsua_mwi_info *mwi_info); 
    949980}; 
    950981 
  • pjproject/branches/projects/pjsua2/pjsip/include/pjsua2/types.hpp

    r4631 r4638  
    7171 
    7272/* 
    73  * Forward declaration of Account, AccountCallback, AccountConfig, to be used 
     73 * Forward declaration of Account, AccountConfig, to be used 
    7474 * by Endpoint. 
    7575 */ 
    7676class Account; 
    77 class AccountCallback; 
    7877class AccountConfig; 
    7978 
     
    522521     */ 
    523522    unsigned            srcPort; 
     523 
     524    /** 
     525     * Construct from PJSIP's pjsip_rx_data 
     526     */ 
     527    void fromPj(pjsip_rx_data &rdata); 
    524528}; 
    525529 
  • pjproject/branches/projects/pjsua2/pjsip/src/pjsua2/account.cpp

    r4631 r4638  
    351351/////////////////////////////////////////////////////////////////////////////// 
    352352 
    353 Account::Account(AccountCallback *param_cb, Token user_data) 
    354 : id(PJSUA_INVALID_ID), cb(param_cb), userData(user_data) 
    355 { 
    356     cb->setAccount(this); 
     353Account::Account() 
     354: id(PJSUA_INVALID_ID) 
     355{ 
    357356} 
    358357 
    359358Account::~Account() 
    360359{ 
    361     delete cb; 
     360    /* If this instance is deleted, also delete the corresponding account in 
     361     * PJSUA library. 
     362     */ 
     363    if (isValid() && pjsua_get_state() < PJSUA_STATE_CLOSING) { 
     364        PJSUA2_CHECK_EXPR( pjsua_acc_set_user_data(id, NULL) ); 
     365        PJSUA2_CHECK_EXPR( pjsua_acc_del(id) ); 
     366    } 
    362367} 
    363368 
     
    367372    pjsua_acc_config pj_acc_cfg = acc_cfg.toPj(); 
    368373 
     374    pj_acc_cfg.user_data = (void*)this; 
    369375    PJSUA2_CHECK_EXPR( pjsua_acc_add(&pj_acc_cfg, make_default, &id) ); 
    370376} 
     
    392398} 
    393399 
    394 int Account::getIndex() const 
     400int Account::getId() const 
    395401{ 
    396402    return id; 
    397403} 
    398404 
    399 void Account::setUserData(Token user_data) 
    400 { 
    401     userData = user_data; 
    402 } 
    403  
    404 Token Account::getUserData() const 
    405 { 
    406     return userData; 
     405Account *Account::lookup(int acc_id) 
     406{ 
     407    return (Account*)pjsua_acc_get_user_data(acc_id); 
    407408} 
    408409 
  • pjproject/branches/projects/pjsua2/pjsip/src/pjsua2/endpoint.cpp

    r4631 r4638  
    1818 */ 
    1919#include <pjsua2/endpoint.hpp> 
     20#include <pjsua2/account.hpp> 
    2021#include "util.hpp" 
    2122 
     
    3435}; 
    3536 
     37Endpoint *Endpoint::instance_; 
    3638 
    3739/////////////////////////////////////////////////////////////////////////////// 
     
    210212 */ 
    211213Endpoint::Endpoint() 
    212 : writer(NULL), epCallback(NULL) 
    213 { 
    214 } 
    215  
    216 Endpoint& Endpoint::instance() 
    217 { 
    218     static Endpoint lib_; 
    219     return lib_; 
    220 } 
    221  
    222 void Endpoint::testException() throw(Error) 
    223 { 
    224     PJSUA2_CHECK_RAISE_ERROR(PJ_EINVALIDOP); 
    225 } 
    226  
     214: writer(NULL) 
     215{ 
     216    if (instance_) { 
     217        PJSUA2_RAISE_ERROR(PJ_EEXISTS); 
     218    } 
     219 
     220    instance_ = this; 
     221} 
     222 
     223Endpoint& Endpoint::instance() throw(Error) 
     224{ 
     225    if (!instance_) { 
     226        PJSUA2_RAISE_ERROR(PJ_ENOTFOUND); 
     227    } 
     228    return *instance_; 
     229} 
     230 
     231Endpoint::~Endpoint() 
     232{ 
     233    try { 
     234        libDestroy(); 
     235    } catch (Error &err) { 
     236        // Ignore 
     237    } 
     238    delete writer; 
     239    instance_ = NULL; 
     240} 
    227241 
    228242/////////////////////////////////////////////////////////////////////////////// 
     
    250264    Endpoint &ep = Endpoint::instance(); 
    251265 
    252     if (!ep.epCallback || !res) 
     266    if (!res) 
    253267        return; 
    254268 
     
    265279    } 
    266280 
    267     ep.epCallback->onNatCheckStunServersComplete(prm); 
     281    ep.onNatCheckStunServersComplete(prm); 
    268282} 
    269283 
     
    274288    UserTimer *ut = (UserTimer*) entry->user_data; 
    275289 
    276     if (!ep.epCallback || ut->signature != TIMER_SIGNATURE) 
    277         return; 
    278  
    279     ep.epCallback->onTimer(ut->prm); 
     290    if (ut->signature != TIMER_SIGNATURE) 
     291        return; 
     292 
     293    ep.onTimer(ut->prm); 
    280294} 
    281295 
     
    284298    Endpoint &ep = Endpoint::instance(); 
    285299 
    286     if (!ep.epCallback || !res) 
     300    if (!res) 
    287301        return; 
    288302 
     
    294308    prm.natTypeName = res->nat_type_name; 
    295309 
    296     ep.epCallback->onNatDetectionComplete(prm); 
     310    ep.onNatDetectionComplete(prm); 
    297311} 
    298312 
     
    303317    Endpoint &ep = Endpoint::instance(); 
    304318 
    305     if (!ep.epCallback) 
    306         return; 
    307  
    308319    OnTransportStateParam prm; 
    309320 
     
    312323    prm.lastError = info ? info->status : PJ_SUCCESS; 
    313324 
    314     ep.epCallback->onTransportState(prm); 
    315 } 
     325    ep.onTransportState(prm); 
     326} 
     327 
     328/////////////////////////////////////////////////////////////////////////////// 
     329/* 
     330 * Account static callbacks 
     331 */ 
     332 
     333Account *Endpoint::lookupAcc(int acc_id, const char *op) 
     334{ 
     335    Account *acc = Account::lookup(acc_id); 
     336    if (!acc) { 
     337        PJ_LOG(1,(THIS_FILE, 
     338                  "Error: cannot find Account instance for account id %d in " 
     339                  "%s", acc_id, op)); 
     340    } 
     341 
     342    return acc; 
     343} 
     344 
     345void Endpoint::on_incoming_call(pjsua_acc_id acc_id, pjsua_call_id call_id, 
     346                                pjsip_rx_data *rdata) 
     347{ 
     348    Account *acc = lookupAcc(acc_id, "on_incoming_call()"); 
     349    if (!acc) { 
     350        pjsua_call_hangup(call_id, PJSIP_SC_INTERNAL_SERVER_ERROR, NULL, NULL); 
     351        return; 
     352    } 
     353 
     354    /* call callback */ 
     355    OnIncomingCallParam prm; 
     356    prm.callId = call_id; 
     357    prm.rdata.fromPj(*rdata); 
     358 
     359    acc->onIncomingCall(prm); 
     360 
     361    /* disconnect if callback doesn't handle the call */ 
     362    pjsua_call_info ci; 
     363 
     364    pjsua_call_get_info(call_id, &ci); 
     365    if (!pjsua_call_get_user_data(call_id) && 
     366        ci.state != PJSIP_INV_STATE_DISCONNECTED) 
     367    { 
     368        pjsua_call_hangup(call_id, PJSIP_SC_INTERNAL_SERVER_ERROR, NULL, NULL); 
     369    } 
     370} 
     371 
     372void Endpoint::on_reg_started(pjsua_acc_id acc_id, pj_bool_t renew) 
     373{ 
     374    Account *acc = lookupAcc(acc_id, "on_reg_started()"); 
     375    if (!acc) { 
     376        return; 
     377    } 
     378 
     379    OnRegStartedParam prm; 
     380    prm.renew = renew; 
     381    acc->onRegStarted(prm); 
     382} 
     383 
     384void Endpoint::on_reg_state2(pjsua_acc_id acc_id, pjsua_reg_info *info) 
     385{ 
     386    Account *acc = lookupAcc(acc_id, "on_reg_state2()"); 
     387    if (!acc) { 
     388        return; 
     389    } 
     390 
     391    OnRegStateParam prm; 
     392    prm.status          = info->cbparam->status; 
     393    prm.code            = (pjsip_status_code) info->cbparam->code; 
     394    prm.reason          = pj2Str(info->cbparam->reason); 
     395    if (info->cbparam->rdata) 
     396        prm.rdata.fromPj(*info->cbparam->rdata); 
     397    prm.expiration      = info->cbparam->expiration; 
     398 
     399    acc->onRegState(prm); 
     400} 
     401 
     402void Endpoint::on_incoming_subscribe(pjsua_acc_id acc_id, 
     403                                     pjsua_srv_pres *srv_pres, 
     404                                     pjsua_buddy_id buddy_id, 
     405                                     const pj_str_t *from, 
     406                                     pjsip_rx_data *rdata, 
     407                                     pjsip_status_code *code, 
     408                                     pj_str_t *reason, 
     409                                     pjsua_msg_data *msg_data) 
     410{ 
     411    Account *acc = lookupAcc(acc_id, "on_incoming_subscribe()"); 
     412    if (!acc) { 
     413        /* default behavior should apply */ 
     414        return; 
     415    } 
     416 
     417    OnIncomingSubscribeParam prm; 
     418    prm.fromUri         = pj2Str(*from); 
     419    prm.rdata.fromPj(*rdata); 
     420    prm.code            = *code; 
     421    prm.reason          = pj2Str(*reason); 
     422 
     423    acc->onIncomingSubscribe(prm); 
     424 
     425    *code = prm.code; 
     426    acc->tmpReason = prm.reason; 
     427    *reason = str2Pj(acc->tmpReason); 
     428    // TODO: 
     429    //  apply msg_data 
     430} 
     431 
     432void Endpoint::on_pager2(pjsua_call_id call_id, 
     433                         const pj_str_t *from, 
     434                         const pj_str_t *to, 
     435                         const pj_str_t *contact, 
     436                         const pj_str_t *mime_type, 
     437                         const pj_str_t *body, 
     438                         pjsip_rx_data *rdata, 
     439                         pjsua_acc_id acc_id) 
     440{ 
     441    OnInstantMessageParam prm; 
     442    prm.fromUri         = pj2Str(*from); 
     443    prm.toUri           = pj2Str(*to); 
     444    prm.contactUri      = pj2Str(*contact); 
     445    prm.contentType     = pj2Str(*mime_type); 
     446    prm.msgBody         = pj2Str(*body); 
     447    prm.rdata.fromPj(*rdata); 
     448 
     449    if (call_id != PJSUA_INVALID_ID) { 
     450        // TODO: 
     451        //      handle call pager 
     452        return; 
     453    } else { 
     454        Account *acc = lookupAcc(acc_id, "on_pager2()"); 
     455        if (!acc) { 
     456            /* Ignored */ 
     457            return; 
     458        } 
     459 
     460        acc->onInstantMessage(prm); 
     461    } 
     462} 
     463 
     464void Endpoint::on_pager_status2( pjsua_call_id call_id, 
     465                                 const pj_str_t *to, 
     466                                 const pj_str_t *body, 
     467                                 void *user_data, 
     468                                 pjsip_status_code status, 
     469                                 const pj_str_t *reason, 
     470                                 pjsip_tx_data *tdata, 
     471                                 pjsip_rx_data *rdata, 
     472                                 pjsua_acc_id acc_id) 
     473{ 
     474    OnInstantMessageStatusParam prm; 
     475    prm.userData        = user_data; 
     476    prm.toUri           = pj2Str(*to); 
     477    prm.msgBody         = pj2Str(*body); 
     478    prm.status          = status; 
     479    prm.reason          = pj2Str(*reason); 
     480    if (rdata) 
     481        prm.rdata.fromPj(*rdata); 
     482 
     483    if (call_id != PJSUA_INVALID_ID) { 
     484        // TODO: 
     485        //      handle call pager 
     486    } else { 
     487        Account *acc = lookupAcc(acc_id, "on_pager_status2()"); 
     488        if (!acc) { 
     489            /* Ignored */ 
     490            return; 
     491        } 
     492 
     493        acc->onInstantMessageStatus(prm); 
     494    } 
     495} 
     496 
     497void Endpoint::on_typing2( pjsua_call_id call_id, 
     498                           const pj_str_t *from, 
     499                           const pj_str_t *to, 
     500                           const pj_str_t *contact, 
     501                           pj_bool_t is_typing, 
     502                           pjsip_rx_data *rdata, 
     503                           pjsua_acc_id acc_id) 
     504{ 
     505    OnTypingIndicationParam prm; 
     506    prm.fromUri         = pj2Str(*from); 
     507    prm.toUri           = pj2Str(*to); 
     508    prm.contactUri      = pj2Str(*contact); 
     509    prm.isTyping        = is_typing != 0; 
     510    prm.rdata.fromPj(*rdata); 
     511 
     512    if (call_id != PJSUA_INVALID_ID) { 
     513        // TODO: 
     514        //      handle call indication 
     515    } else { 
     516        Account *acc = lookupAcc(acc_id, "on_typing2()"); 
     517        if (!acc) { 
     518            /* Ignored */ 
     519            return; 
     520        } 
     521 
     522        acc->onTypingIndication(prm); 
     523    } 
     524} 
     525 
     526void Endpoint::on_mwi_info(pjsua_acc_id acc_id, 
     527                           pjsua_mwi_info *mwi_info) 
     528{ 
     529    OnMwiInfoParam prm; 
     530    prm.state   = pjsip_evsub_get_state(mwi_info->evsub); 
     531    prm.rdata.fromPj(*mwi_info->rdata); 
     532 
     533    Account *acc = lookupAcc(acc_id, "on_mwi_info()"); 
     534    if (!acc) { 
     535        /* Ignored */ 
     536        return; 
     537    } 
     538 
     539    acc->onMwiInfo(prm); 
     540} 
     541 
    316542 
    317543/////////////////////////////////////////////////////////////////////////////// 
     
    321547void Endpoint::libCreate() throw(Error) 
    322548{ 
    323     pj_status_t status; 
    324  
    325     status = pjsua_create(); 
    326     PJSUA2_CHECK_RAISE_ERROR(status); 
     549    PJSUA2_CHECK_EXPR( pjsua_create() ); 
    327550} 
    328551 
     
    332555} 
    333556 
    334 void Endpoint::libInit( const EpConfig &prmEpConfig, 
    335                         EpCallback *prmCb) throw(Error) 
     557void Endpoint::libInit(const EpConfig &prmEpConfig) throw(Error) 
    336558{ 
    337559    pjsua_config ua_cfg; 
    338560    pjsua_logging_config log_cfg; 
    339561    pjsua_media_config med_cfg; 
    340     pj_status_t status; 
    341562 
    342563    ua_cfg = prmEpConfig.uaConfig.toPj(); 
     
    352573    /* Setup UA callbacks */ 
    353574    pj_bzero(&ua_cfg.cb, sizeof(ua_cfg.cb)); 
    354     ua_cfg.cb.on_nat_detect = &Endpoint::on_nat_detect; 
     575    ua_cfg.cb.on_nat_detect     = &Endpoint::on_nat_detect; 
    355576    ua_cfg.cb.on_transport_state = &Endpoint::on_transport_state; 
    356577 
     578    ua_cfg.cb.on_incoming_call  = &Endpoint::on_incoming_call; 
     579    ua_cfg.cb.on_reg_started    = &Endpoint::on_reg_started; 
     580    ua_cfg.cb.on_reg_state2     = &Endpoint::on_reg_state2; 
     581    ua_cfg.cb.on_incoming_subscribe = &Endpoint::on_incoming_subscribe; 
     582    ua_cfg.cb.on_pager2         = &Endpoint::on_pager2; 
     583    ua_cfg.cb.on_pager_status2  = &Endpoint::on_pager_status2; 
     584    ua_cfg.cb.on_typing2        = &Endpoint::on_typing2; 
     585    ua_cfg.cb.on_mwi_info       = &Endpoint::on_mwi_info; 
     586 
    357587    /* Init! */ 
    358     status = pjsua_init(&ua_cfg, &log_cfg, &med_cfg); 
    359     PJSUA2_CHECK_RAISE_ERROR(status); 
     588    PJSUA2_CHECK_EXPR( pjsua_init(&ua_cfg, &log_cfg, &med_cfg) ); 
    360589} 
    361590 
    362591void Endpoint::libStart() throw(Error) 
    363592{ 
     593    PJSUA2_CHECK_EXPR(pjsua_start()); 
     594} 
     595 
     596void Endpoint::libDestroy(unsigned flags) throw(Error) 
     597{ 
    364598    pj_status_t status; 
    365599 
    366     status = pjsua_start(); 
    367     PJSUA2_CHECK_RAISE_ERROR(status); 
    368 } 
    369  
    370 void Endpoint::libDestroy(unsigned flags) throw(Error) 
    371 { 
    372     pj_status_t status; 
    373  
    374600    status = pjsua_destroy2(flags); 
    375601 
     602    delete this->writer; 
    376603    this->writer = NULL; 
    377     this->epCallback = NULL; 
    378604 
    379605    if (pj_log_get_log_func() == &Endpoint::logFunc) { 
     
    469695    pj_ssl_cipher ciphers[64]; 
    470696    unsigned count = PJ_ARRAY_SIZE(ciphers); 
    471     pj_status_t status; 
    472  
    473     status = pj_ssl_cipher_get_availables(ciphers, &count); 
    474     PJSUA2_CHECK_RAISE_ERROR(status); 
     697 
     698    PJSUA2_CHECK_EXPR( pj_ssl_cipher_get_availables(ciphers, &count) ); 
    475699 
    476700    return IntVector(ciphers, ciphers + count); 
     
    486710void Endpoint::natDetectType(void) throw(Error) 
    487711{ 
    488     pj_status_t status; 
    489  
    490     status = pjsua_detect_nat_type(); 
    491     PJSUA2_CHECK_RAISE_ERROR(status); 
     712    PJSUA2_CHECK_EXPR( pjsua_detect_nat_type() ); 
    492713} 
    493714 
     
    495716{ 
    496717    pj_stun_nat_type type; 
    497     pj_status_t status; 
    498  
    499     status = pjsua_get_nat_type(&type); 
    500     PJSUA2_CHECK_RAISE_ERROR(status); 
     718 
     719    PJSUA2_CHECK_EXPR( pjsua_get_nat_type(&type) ); 
    501720 
    502721    return type; 
     
    509728    pj_str_t srv[MAX_STUN_SERVERS]; 
    510729    unsigned i, count = 0; 
    511     pj_status_t status; 
    512730 
    513731    for (i=0; i<servers.size() && i<MAX_STUN_SERVERS; ++i) { 
     
    517735    } 
    518736 
    519     status = pjsua_resolve_stun_servers(count, srv, wait, token, 
    520                                         &Endpoint::stun_resolve_cb); 
    521     PJSUA2_CHECK_RAISE_ERROR(status); 
     737    PJSUA2_CHECK_EXPR(pjsua_resolve_stun_servers(count, srv, wait, token, 
     738                                                 &Endpoint::stun_resolve_cb) ); 
    522739} 
    523740 
     
    525742                                         bool notify_cb) throw(Error) 
    526743{ 
    527     pj_status_t status; 
    528  
    529     status = pjsua_cancel_stun_resolution(token, notify_cb); 
    530     PJSUA2_CHECK_RAISE_ERROR(status); 
     744    PJSUA2_CHECK_EXPR( pjsua_cancel_stun_resolution(token, notify_cb) ); 
    531745} 
    532746 
     
    540754    pjsua_transport_config tcfg; 
    541755    pjsua_transport_id tid; 
    542     pj_status_t status; 
    543756 
    544757    tcfg = cfg.toPj(); 
    545     status = pjsua_transport_create(type, &tcfg, &tid); 
    546     PJSUA2_CHECK_RAISE_ERROR(status); 
     758    PJSUA2_CHECK_EXPR( pjsua_transport_create(type, &tcfg, &tid) ); 
    547759 
    548760    return tid; 
     
    553765    pjsua_transport_id tids[32]; 
    554766    unsigned count = PJ_ARRAY_SIZE(tids); 
    555     pj_status_t status; 
    556  
    557     status = pjsua_enum_transports(tids, &count); 
    558     PJSUA2_CHECK_RAISE_ERROR(status); 
     767 
     768    PJSUA2_CHECK_EXPR( pjsua_enum_transports(tids, &count) ); 
    559769 
    560770    return IntVector(tids, tids+count); 
     
    564774{ 
    565775    pjsua_transport_info tinfo; 
    566     pj_status_t status; 
    567  
    568     status = pjsua_transport_get_info(id, &tinfo); 
    569     PJSUA2_CHECK_RAISE_ERROR(status); 
     776 
     777    PJSUA2_CHECK_EXPR( pjsua_transport_get_info(id, &tinfo) ); 
    570778 
    571779    return TransportInfo(tinfo); 
     
    574782void Endpoint::transportSetEnable(TransportId id, bool enabled) throw(Error) 
    575783{ 
    576     pj_status_t status; 
    577  
    578     status = pjsua_transport_set_enable(id, enabled); 
    579     PJSUA2_CHECK_RAISE_ERROR(status); 
     784    PJSUA2_CHECK_EXPR( pjsua_transport_set_enable(id, enabled) ); 
    580785} 
    581786 
    582787void Endpoint::transportClose(TransportId id) throw(Error) 
    583788{ 
    584     pj_status_t status; 
    585  
    586     status = pjsua_transport_close(id, PJ_FALSE); 
    587     PJSUA2_CHECK_RAISE_ERROR(status); 
    588 } 
    589  
    590 /////////////////////////////////////////////////////////////////////////////// 
    591  
     789    PJSUA2_CHECK_EXPR( pjsua_transport_close(id, PJ_FALSE) ); 
     790} 
     791 
     792/////////////////////////////////////////////////////////////////////////////// 
     793 
  • pjproject/branches/projects/pjsua2/pjsip/src/pjsua2/types.cpp

    r4631 r4638  
    214214/////////////////////////////////////////////////////////////////////////////// 
    215215 
     216void SipRxData::fromPj(pjsip_rx_data &rdata) 
     217{ 
     218    info        = pjsip_rx_data_get_info(&rdata); 
     219    wholeMsg    = string(rdata.msg_info.msg_buf, rdata.msg_info.len); 
     220    srcIp       = rdata.pkt_info.src_name; 
     221    srcPort     = rdata.pkt_info.src_port; 
     222} 
     223 
     224/////////////////////////////////////////////////////////////////////////////// 
     225 
    216226void SipHeader::fromPj(const pjsip_hdr *hdr) throw(Error) 
    217227{ 
Note: See TracChangeset for help on using the changeset viewer.