Changeset 3804
- Timestamp:
- Oct 9, 2011 10:58:38 AM (13 years ago)
- Location:
- pjproject/branches/1.x
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/branches/1.x/pjmedia/include/pjmedia/transport_adapter_sample.h
r3553 r3804 50 50 * @param name Optional name to identify this media transport 51 51 * for logging purposes. 52 * @param transport The underlying media transport to send and receive 53 * RTP/RTCP packets. 52 * @param base_tp The base/underlying media transport to send and 53 * receive RTP/RTCP packets. 54 * @param del_base Specify whether the base transport should also be 55 * destroyed when destroy() is called upon us. 54 56 * @param p_tp Pointer to receive the media transport instance. 55 57 * … … 58 60 PJ_DECL(pj_status_t) pjmedia_tp_adapter_create( pjmedia_endpt *endpt, 59 61 const char *name, 60 pjmedia_transport *transport, 62 pjmedia_transport *base_tp, 63 pj_bool_t del_base, 61 64 pjmedia_transport **p_tp); 62 65 -
pjproject/branches/1.x/pjmedia/src/pjmedia/transport_adapter_sample.c
r3553 r3804 95 95 { 96 96 pjmedia_transport base; 97 pj_bool_t del_base; 97 98 98 99 pj_pool_t *pool; … … 119 120 const char *name, 120 121 pjmedia_transport *transport, 122 pj_bool_t del_base, 121 123 pjmedia_transport **p_tp) 122 124 { … … 139 141 /* Save the transport as the slave transport */ 140 142 adapter->slave_tp = transport; 143 adapter->del_base = del_base; 141 144 142 145 /* Done */ … … 422 425 423 426 /* Close the slave transport */ 424 pjmedia_transport_close(adapter->slave_tp); 427 if (adapter->del_base) { 428 pjmedia_transport_close(adapter->slave_tp); 429 } 425 430 426 431 /* Self destruct.. */ -
pjproject/branches/1.x/pjsip-apps/src/pjsua/pjsua_app.c
r3570 r3804 141 141 #ifdef STEREO_DEMO 142 142 static void stereo_demo(); 143 #endif144 #ifdef TRANSPORT_ADAPTER_SAMPLE145 static pj_status_t transport_adapter_sample(void);146 143 #endif 147 144 static pj_status_t create_ipv6_media_transports(void); … … 3052 3049 } 3053 3050 3051 #ifdef TRANSPORT_ADAPTER_SAMPLE 3052 /* 3053 * This callback is called when media transport needs to be created. 3054 */ 3055 static pjmedia_transport* on_create_media_transport(pjsua_call_id call_id, 3056 unsigned media_idx, 3057 pjmedia_transport *base_tp, 3058 unsigned flags) 3059 { 3060 pjmedia_transport *adapter; 3061 pj_status_t status; 3062 3063 /* Create the adapter */ 3064 status = pjmedia_tp_adapter_create(pjsua_get_pjmedia_endpt(), 3065 NULL, base_tp, 3066 (flags & PJSUA_MED_TP_CLOSE_MEMBER), 3067 &adapter); 3068 if (status != PJ_SUCCESS) { 3069 PJ_PERROR(1,(THIS_FILE, status, "Error creating adapter")); 3070 return NULL; 3071 } 3072 3073 PJ_LOG(3,(THIS_FILE, "Media transport is created for call %d media %d", 3074 call_id, media_idx)); 3075 3076 return adapter; 3077 } 3078 #endif 3079 3054 3080 /* 3055 3081 * Print buddy list. … … 4652 4678 app_config.cfg.cb.on_transport_state = &on_transport_state; 4653 4679 app_config.cfg.cb.on_ice_transport_error = &on_ice_transport_error; 4680 #ifdef TRANSPORT_ADAPTER_SAMPLE 4681 app_config.cfg.cb.on_create_media_transport = &on_create_media_transport; 4682 #endif 4654 4683 app_config.log_cfg.cb = log_cb; 4655 4684 … … 4930 4959 /* Add accounts */ 4931 4960 for (i=0; i<app_config.acc_cnt; ++i) { 4961 app_config.acc_cfg[i].reg_retry_interval = 300; 4962 app_config.acc_cfg[i].reg_first_retry_interval = 60; 4963 4932 4964 status = pjsua_acc_add(&app_config.acc_cfg[i], PJ_TRUE, NULL); 4933 4965 if (status != PJ_SUCCESS) … … 4955 4987 4956 4988 /* Add RTP transports */ 4957 #ifdef TRANSPORT_ADAPTER_SAMPLE4958 status = transport_adapter_sample();4959 4960 #else4961 4989 if (app_config.ipv6) 4962 4990 status = create_ipv6_media_transports(); 4963 4991 else 4964 4992 status = pjsua_media_transports_create(&app_config.rtp_cfg); 4965 #endif 4993 4966 4994 if (status != PJ_SUCCESS) 4967 4995 goto on_error; … … 5172 5200 #endif 5173 5201 5174 #ifdef TRANSPORT_ADAPTER_SAMPLE5175 static pj_status_t create_transport_adapter(pjmedia_endpt *med_endpt, int port,5176 pjmedia_transport **p_tp)5177 {5178 pjmedia_transport *udp;5179 pj_status_t status;5180 5181 /* Create the UDP media transport */5182 status = pjmedia_transport_udp_create(med_endpt, NULL, port, 0, &udp);5183 if (status != PJ_SUCCESS)5184 return status;5185 5186 /* Create the adapter */5187 status = pjmedia_tp_adapter_create(med_endpt, NULL, udp, p_tp);5188 if (status != PJ_SUCCESS) {5189 pjmedia_transport_close(udp);5190 return status;5191 }5192 5193 return PJ_SUCCESS;5194 }5195 5196 static pj_status_t transport_adapter_sample(void)5197 {5198 pjsua_media_transport tp[PJSUA_MAX_CALLS];5199 pj_status_t status;5200 int port = 7000;5201 unsigned i;5202 5203 for (i=0; i<app_config.cfg.max_calls; ++i) {5204 status = create_transport_adapter(pjsua_get_pjmedia_endpt(),5205 port + i*10,5206 &tp[i].transport);5207 if (status != PJ_SUCCESS)5208 return status;5209 }5210 5211 return pjsua_media_transports_attach(tp, i, PJ_TRUE);5212 }5213 #endif5214 5215 5202 static pj_status_t create_ipv6_media_transports(void) 5216 5203 {
Note: See TracChangeset
for help on using the changeset viewer.