Changeset 3119


Ignore:
Timestamp:
Mar 10, 2010 1:33:25 PM (10 years ago)
Author:
bennylp
Message:

More #1032 (new SIP TCP/TLS transport callback):

  • PJSUA-LIB transport callback, if installed, will call the previously registered callback, to allow multiple transport callbacks to be installed
  • there seem to be a bug with the use of "pjsip_tp_state_callback" everywhere (the "pjsip_tp_state_callback" type is pointer, but most variables of this type are declared to pointer too)
Location:
pjproject/trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjsip-apps/src/pjsua/pjsua_app.c

    r3110 r3119  
    28052805    case PJSIP_TP_STATE_CONNECTED: 
    28062806        { 
    2807             PJ_LOG(3,(THIS_FILE, "SIP transport %s is connected to %s",  
     2807            PJ_LOG(3,(THIS_FILE, "SIP %s transport is connected to %s", 
    28082808                     tp->type_name, host_port)); 
    28092809        } 
     
    28142814            char buf[100]; 
    28152815 
    2816             snprintf(buf, sizeof(buf), "SIP transport %s is disconnected from %s", 
     2816            snprintf(buf, sizeof(buf), "SIP %s transport is disconnected from %s", 
    28172817                     tp->type_name, host_port); 
    28182818            pjsua_perror(THIS_FILE, buf, info->status); 
  • pjproject/trunk/pjsip/include/pjsip/sip_transport.h

    r3110 r3119  
    13131313 */ 
    13141314PJ_DECL(pj_status_t) pjsip_tpmgr_set_status_cb(pjsip_tpmgr *mgr, 
    1315                                                pjsip_tp_state_callback *cb); 
     1315                                               pjsip_tp_state_callback cb); 
    13161316 
    13171317 
     
    13231323 * @return          The transport state callback or NULL if it is not set. 
    13241324 */ 
    1325 PJ_DECL(pjsip_tp_state_callback*) pjsip_tpmgr_get_status_cb( 
     1325PJ_DECL(pjsip_tp_state_callback) pjsip_tpmgr_get_status_cb( 
    13261326                                               const pjsip_tpmgr *mgr); 
    13271327 
  • pjproject/trunk/pjsip/include/pjsua-lib/pjsua_internal.h

    r3096 r3119  
    253253    pjsip_module         mod;       /**< pjsua's PJSIP module.          */ 
    254254    pjsua_transport_data tpdata[8]; /**< Array of transports.           */ 
     255    pjsip_tp_state_callback old_tp_cb; /**< Old transport callback.     */ 
    255256 
    256257    /* Threading: */ 
  • pjproject/trunk/pjsip/src/pjsip/sip_transport.c

    r3110 r3119  
    9090    void           (*on_rx_msg)(pjsip_endpoint*, pj_status_t, pjsip_rx_data*); 
    9191    pj_status_t    (*on_tx_msg)(pjsip_endpoint*, pjsip_tx_data*); 
    92     pjsip_tp_state_callback *tp_state_cb; 
     92    pjsip_tp_state_callback tp_state_cb; 
    9393    void *tp_state_user_data; 
    9494}; 
     
    17391739 
    17401740PJ_DEF(pj_status_t) pjsip_tpmgr_set_status_cb(pjsip_tpmgr *mgr, 
    1741                                               pjsip_tp_state_callback *cb) 
     1741                                              pjsip_tp_state_callback cb) 
    17421742{ 
    17431743    PJ_ASSERT_RETURN(mgr, PJ_EINVAL); 
     
    17481748} 
    17491749 
    1750 PJ_DEF(pjsip_tp_state_callback*) pjsip_tpmgr_get_status_cb( 
     1750PJ_DEF(pjsip_tp_state_callback) pjsip_tpmgr_get_status_cb( 
    17511751                                              const pjsip_tpmgr *mgr) 
    17521752{ 
  • pjproject/trunk/pjsip/src/pjsip/sip_transport_tcp.c

    r3113 r3119  
    170170static void tcp_init_shutdown(struct tcp_transport *tcp, pj_status_t status) 
    171171{ 
    172     pjsip_tp_state_callback *state_cb; 
     172    pjsip_tp_state_callback state_cb; 
    173173 
    174174    if (tcp->close_reason == PJ_SUCCESS) 
     
    953953    struct tcp_transport *tcp; 
    954954    char addr[PJ_INET6_ADDRSTRLEN+10]; 
    955     pjsip_tp_state_callback *state_cb; 
     955    pjsip_tp_state_callback state_cb; 
    956956    pj_status_t status; 
    957957 
     
    12631263    pj_sockaddr_in addr; 
    12641264    int addrlen; 
    1265  
    1266     pjsip_tp_state_callback *state_cb; 
     1265    pjsip_tp_state_callback state_cb; 
    12671266 
    12681267    tcp = (struct tcp_transport*) pj_activesock_get_user_data(asock); 
  • pjproject/trunk/pjsip/src/pjsip/sip_transport_tls.c

    r3110 r3119  
    177177static void tls_init_shutdown(struct tls_transport *tls, pj_status_t status) 
    178178{ 
    179     pjsip_tp_state_callback *state_cb; 
     179    pjsip_tp_state_callback state_cb; 
    180180 
    181181    if (tls->close_reason == PJ_SUCCESS) 
     
    978978    pj_ssl_sock_info ssl_info; 
    979979    char addr[PJ_INET6_ADDRSTRLEN+10]; 
    980     pjsip_tp_state_callback *state_cb; 
     980    pjsip_tp_state_callback state_cb; 
    981981    pj_bool_t is_shutdown; 
    982982    pj_status_t status; 
     
    13381338    pj_ssl_sock_info ssl_info; 
    13391339    pj_sockaddr_in addr, *tp_addr; 
    1340     pjsip_tp_state_callback *state_cb; 
     1340    pjsip_tp_state_callback state_cb; 
    13411341    pj_bool_t is_shutdown; 
    13421342 
  • pjproject/trunk/pjsip/src/pjsua-lib/pjsua_core.c

    r3106 r3119  
    15261526} 
    15271527 
     1528/* Callback to receive transport state notifications */ 
     1529static void on_tp_state_callback(pjsip_transport *tp, 
     1530                                 pjsip_transport_state state, 
     1531                                 const pjsip_transport_state_info *info) 
     1532{ 
     1533    if (pjsua_var.ua_cfg.cb.on_transport_state) { 
     1534        (*pjsua_var.ua_cfg.cb.on_transport_state)(tp, state, info); 
     1535    } 
     1536    if (pjsua_var.old_tp_cb) { 
     1537        (*pjsua_var.old_tp_cb)(tp, state, info); 
     1538    } 
     1539} 
     1540 
    15281541/* 
    15291542 * Create and initialize SIP socket (and possibly resolve public 
     
    18671880    /* Set transport state callback */ 
    18681881    if (pjsua_var.ua_cfg.cb.on_transport_state) { 
    1869         pjsip_tpmgr_set_status_cb(pjsip_endpt_get_tpmgr(pjsua_var.endpt), 
    1870                                   &pjsua_var.ua_cfg.cb.on_transport_state); 
     1882        pjsip_tp_state_callback tpcb; 
     1883        pjsip_tpmgr *tpmgr; 
     1884 
     1885        tpmgr = pjsip_endpt_get_tpmgr(pjsua_var.endpt); 
     1886        tpcb = pjsip_tpmgr_get_status_cb(tpmgr); 
     1887 
     1888        if (tpcb != &on_tp_state_callback) { 
     1889            pjsua_var.old_tp_cb = tpcb; 
     1890            pjsip_tpmgr_set_status_cb(tpmgr, &on_tp_state_callback); 
     1891        } 
    18711892    } 
    18721893 
Note: See TracChangeset for help on using the changeset viewer.