Changeset 5686
- Timestamp:
- Nov 9, 2017 1:49:06 AM (7 years ago)
- Location:
- pjproject/trunk/pjsip
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjsip/include/pjsua-lib/pjsua.h
r5677 r5686 2761 2761 2762 2762 /** 2763 * Register transport factory that has been created by application. 2764 * This function is useful if application wants to implement custom SIP 2765 * transport and use it with pjsua. 2766 * 2767 * @param tf Transport factory instance. 2768 * @param p_id Optional pointer to receive transport ID. 2769 * 2770 * @return PJ_SUCCESS on success, or the appropriate error code. 2771 */ 2772 PJ_DEF(pj_status_t) pjsua_tpfactory_register( pjsip_tpfactory *tf, 2773 pjsua_transport_id *p_id); 2774 2775 /** 2763 2776 * Enumerate all transports currently created in the system. This function 2764 2777 * will return all transport IDs, and application may then call -
pjproject/trunk/pjsip/src/pjsua-lib/pjsua_core.c
r5649 r5686 2069 2069 } 2070 2070 pjsua_acc_on_tp_state_changed(tp, state, info); 2071 } 2072 2073 /* Set transport state callback */ 2074 static void set_tp_state_cb() 2075 { 2076 pjsip_tp_state_callback tpcb; 2077 pjsip_tpmgr *tpmgr; 2078 2079 tpmgr = pjsip_endpt_get_tpmgr(pjsua_var.endpt); 2080 tpcb = pjsip_tpmgr_get_state_cb(tpmgr); 2081 2082 if (tpcb != &on_tp_state_callback) { 2083 pjsua_var.old_tp_cb = tpcb; 2084 pjsip_tpmgr_set_state_cb(tpmgr, &on_tp_state_callback); 2085 } 2071 2086 } 2072 2087 … … 2452 2467 2453 2468 /* Set transport state callback */ 2454 { 2455 pjsip_tp_state_callback tpcb; 2456 pjsip_tpmgr *tpmgr; 2457 2458 tpmgr = pjsip_endpt_get_tpmgr(pjsua_var.endpt); 2459 tpcb = pjsip_tpmgr_get_state_cb(tpmgr); 2460 2461 if (tpcb != &on_tp_state_callback) { 2462 pjsua_var.old_tp_cb = tpcb; 2463 pjsip_tpmgr_set_state_cb(tpmgr, &on_tp_state_callback); 2464 } 2465 } 2469 set_tp_state_cb(); 2466 2470 2467 2471 /* Return the ID */ … … 2504 2508 pjsua_var.tpdata[id].local_name = tp->local_name; 2505 2509 pjsua_var.tpdata[id].data.tp = tp; 2510 2511 /* Set transport state callback */ 2512 set_tp_state_cb(); 2513 2514 /* Return the ID */ 2515 if (p_id) *p_id = id; 2516 2517 PJSUA_UNLOCK(); 2518 2519 return PJ_SUCCESS; 2520 } 2521 2522 2523 /* 2524 * Register transport factory that has been created by application. 2525 */ 2526 PJ_DEF(pj_status_t) pjsua_tpfactory_register( pjsip_tpfactory *tf, 2527 pjsua_transport_id *p_id) 2528 { 2529 unsigned id; 2530 2531 PJSUA_LOCK(); 2532 2533 /* Find empty transport slot */ 2534 for (id=0; id < PJ_ARRAY_SIZE(pjsua_var.tpdata); ++id) { 2535 if (pjsua_var.tpdata[id].data.ptr == NULL) 2536 break; 2537 } 2538 2539 if (id == PJ_ARRAY_SIZE(pjsua_var.tpdata)) { 2540 pjsua_perror(THIS_FILE, "Error creating transport", PJ_ETOOMANY); 2541 PJSUA_UNLOCK(); 2542 return PJ_ETOOMANY; 2543 } 2544 2545 /* Save the transport */ 2546 pjsua_var.tpdata[id].type = (pjsip_transport_type_e) tf->type; 2547 pjsua_var.tpdata[id].local_name = tf->addr_name; 2548 pjsua_var.tpdata[id].data.factory = tf; 2549 2550 /* Set transport state callback */ 2551 set_tp_state_cb(); 2506 2552 2507 2553 /* Return the ID */
Note: See TracChangeset
for help on using the changeset viewer.