- Timestamp:
- Mar 17, 2011 4:34:43 AM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/branches/projects/2.0-dev/pjsip/src/pjsua-lib/pjsua_call.c
r3374 r3457 102 102 { 103 103 pjsua_call *call = &pjsua_var.calls[id]; 104 104 unsigned i; 105 106 pj_bzero(call, sizeof(*call)); 105 107 call->index = id; 106 call->inv = NULL;107 call->user_data = NULL;108 call->session = NULL;109 call->audio_idx = -1;110 call->ssrc = pj_rand();111 call->rtp_tx_seq = 0;112 call->rtp_tx_ts = 0;113 call->rtp_tx_seq_ts_set = 0;114 call->xfer_sub = NULL;115 call->last_code = (pjsip_status_code) 0;116 call->conf_slot = PJSUA_INVALID_ID;117 108 call->last_text.ptr = call->last_text_buf_; 118 call->last_text.slen = 0; 119 call->conn_time.sec = 0; 120 call->conn_time.msec = 0; 121 call->res_time.sec = 0; 122 call->res_time.msec = 0; 123 call->rem_nat_type = PJ_STUN_NAT_TYPE_UNKNOWN; 124 call->rem_srtp_use = PJMEDIA_SRTP_DISABLED; 125 call->local_hold = PJ_FALSE; 126 pj_bzero(&call->lock_codec, sizeof(call->lock_codec)); 109 for (i=0; i<PJ_ARRAY_SIZE(call->media); ++i) { 110 pjsua_call_media *call_med = &call->media[i]; 111 call_med->ssrc = pj_rand(); 112 call_med->strm.a.conf_slot = PJSUA_INVALID_ID; 113 call_med->call = call; 114 call_med->idx = i; 115 call_med->tp_auto_del = PJ_TRUE; 116 } 127 117 } 128 118 … … 824 814 status = pjsua_media_channel_init(call->index, PJSIP_ROLE_UAS, 825 815 call->secure_level, 826 rdata->tp_info.pool, offer, 816 rdata->tp_info.pool, 817 offer, 827 818 &sip_err_code); 828 819 if (status != PJ_SUCCESS) { … … 1119 1110 PJ_DEF(pj_bool_t) pjsua_call_has_media(pjsua_call_id call_id) 1120 1111 { 1112 pjsua_call *call = &pjsua_var.calls[call_id]; 1121 1113 PJ_ASSERT_RETURN(call_id>=0 && call_id<(int)pjsua_var.ua_cfg.max_calls, 1122 1114 PJ_EINVAL); 1123 return pjsua_var.calls[call_id].session != NULL; 1124 } 1125 1126 1115 return call->audio_idx >= 0 && call->media[call->audio_idx].strm.a.stream; 1116 } 1117 1118 1119 #if DISABLED_FOR_TICKET_1185 1127 1120 /* 1128 1121 * Retrieve the media session associated with this call. … … 1143 1136 PJ_ASSERT_RETURN(cid>=0 && cid<(int)pjsua_var.ua_cfg.max_calls, 1144 1137 NULL); 1145 return pjsua_var.calls[cid]. med_tp;1146 } 1147 1138 return pjsua_var.calls[cid].tp; 1139 } 1140 #endif /* Removed in 2.0 */ 1148 1141 1149 1142 /* Acquire lock to the specified call_id */ … … 1239 1232 return PJSUA_INVALID_ID; 1240 1233 1241 port_id = call-> conf_slot;1234 port_id = call->media[call->audio_idx].strm.a.conf_slot; 1242 1235 1243 1236 pjsip_dlg_dec_lock(dlg); … … 1256 1249 pjsua_call *call; 1257 1250 pjsip_dialog *dlg; 1251 unsigned mi; 1258 1252 pj_status_t status; 1259 1253 … … 1330 1324 } 1331 1325 1332 /* media status and dir */ 1333 info->media_status = call->media_st; 1334 info->media_dir = call->media_dir; 1335 1326 /* Build array of media status and dir */ 1327 info->audio_cnt = 0; 1328 for (mi=0; mi < call->med_cnt && 1329 info->audio_cnt < PJ_ARRAY_SIZE(info->audio); ++mi) 1330 { 1331 pjsua_call_media *call_med = &call->media[mi]; 1332 if (call_med->type != PJMEDIA_TYPE_AUDIO) 1333 continue; 1334 info->audio[info->audio_cnt].index = mi; 1335 info->audio[info->audio_cnt].media_status = call_med->state; 1336 info->audio[info->audio_cnt].media_dir = call_med->dir; 1337 info->audio[info->audio_cnt].conf_slot = call_med->strm.a.conf_slot; 1338 ++info->audio_cnt; 1339 } 1340 1341 if (info->audio_cnt) { 1342 info->media_status = info->audio[0].media_status; 1343 info->media_dir = info->audio[0].media_dir; 1344 } 1336 1345 1337 1346 /* conference slot number */ 1338 info->conf_slot = call-> conf_slot;1347 info->conf_slot = call->media[call->audio_idx].strm.a.conf_slot; 1339 1348 1340 1349 /* calculate duration */ … … 1960 1969 return status; 1961 1970 1962 if (! call->session) {1971 if (!pjsua_call_has_media(call_id)) { 1963 1972 PJ_LOG(3,(THIS_FILE, "Media is not established yet!")); 1964 1973 pjsip_dlg_dec_lock(dlg); … … 1966 1975 } 1967 1976 1968 status = pjmedia_session_dial_dtmf( call->session, 0, digits); 1977 status = pjmedia_stream_dial_dtmf( 1978 call->media[call->audio_idx].strm.a.stream, digits); 1969 1979 1970 1980 pjsip_dlg_dec_lock(dlg); … … 2191 2201 char *p = buf, *end = buf+maxlen; 2192 2202 int len; 2193 pjmedia_session_info info; 2194 pjmedia_session *session = call->session; 2195 pjmedia_transport_info tp_info; 2196 2197 pjmedia_transport_info_init(&tp_info); 2198 2199 pjmedia_transport_get_info(call->med_tp, &tp_info); 2200 pjmedia_session_get_info(session, &info); 2201 2202 for (i=0; i<info.stream_cnt; ++i) { 2203 2204 for (i=0; i<call->med_cnt; ++i) { 2205 pjsua_call_media *call_med = &call->media[i]; 2206 pjmedia_stream_info info; 2207 pjmedia_stream *stream = call_med->strm.a.stream; 2208 pjmedia_transport_info tp_info; 2203 2209 pjmedia_rtcp_stat stat; 2204 2210 char rem_addr_buf[80]; … … 2209 2215 pj_time_val media_duration, now; 2210 2216 2211 pjmedia_session_get_stream_stat(session, i, &stat); 2217 /* Check if the stream is deactivated */ 2218 if (call_med->tp == NULL || stream == NULL) { 2219 const char *media_type_str; 2220 2221 switch (call_med->type) { 2222 case PJMEDIA_TYPE_AUDIO: 2223 media_type_str = "audio"; 2224 break; 2225 case PJMEDIA_TYPE_VIDEO: 2226 media_type_str = "video"; 2227 break; 2228 case PJMEDIA_TYPE_APPLICATION: 2229 media_type_str = "application"; 2230 break; 2231 default: 2232 media_type_str = "unknown"; 2233 break; 2234 } 2235 len = pj_ansi_snprintf(p, end-p, 2236 "%s #%d m=%s deactivated\n", 2237 indent, i, media_type_str); 2238 if (len < 1 || len > end-p) { 2239 *p = '\0'; 2240 return; 2241 } 2242 2243 p += len; 2244 continue; 2245 } 2246 2247 pjmedia_transport_info_init(&tp_info); 2248 pjmedia_transport_get_info(call_med->tp, &tp_info); 2249 2250 pjmedia_stream_get_info(stream, &info); 2251 pjmedia_stream_get_stat(stream, &stat); 2252 2212 2253 // rem_addr will contain actual address of RTP originator, instead of 2213 2254 // remote RTP address specified by stream which is fetched from the SDP. … … 2223 2264 } 2224 2265 2225 if (call ->media_dir == PJMEDIA_DIR_NONE) {2266 if (call_med->dir == PJMEDIA_DIR_NONE) { 2226 2267 /* To handle when the stream that is currently being paused 2227 2268 * (http://trac.pjsip.org/repos/ticket/1079) 2228 2269 */ 2229 2270 dir = "inactive"; 2230 } else if (info. stream_info[i].dir == PJMEDIA_DIR_ENCODING)2271 } else if (info.dir == PJMEDIA_DIR_ENCODING) 2231 2272 dir = "sendonly"; 2232 else if (info. stream_info[i].dir == PJMEDIA_DIR_DECODING)2273 else if (info.dir == PJMEDIA_DIR_DECODING) 2233 2274 dir = "recvonly"; 2234 else if (info. stream_info[i].dir == PJMEDIA_DIR_ENCODING_DECODING)2275 else if (info.dir == PJMEDIA_DIR_ENCODING_DECODING) 2235 2276 dir = "sendrecv"; 2236 2277 else … … 2238 2279 2239 2280 2240 len = pj_ansi_snprintf( buf, end-p,2281 len = pj_ansi_snprintf(p, end-p, 2241 2282 "%s #%d %.*s @%dKHz, %s, peer=%s", 2242 2283 indent, i, 2243 (int)info. stream_info[i].fmt.encoding_name.slen,2244 info. stream_info[i].fmt.encoding_name.ptr,2245 info. stream_info[i].fmt.clock_rate / 1000,2284 (int)info.fmt.encoding_name.slen, 2285 info.fmt.encoding_name.ptr, 2286 info.fmt.clock_rate / 1000, 2246 2287 dir, 2247 2288 rem_addr); … … 2294 2335 #endif 2295 2336 "%s", 2296 indent, info. stream_info[i].fmt.pt,2337 indent, info.fmt.pt, 2297 2338 last_update, 2298 2339 indent, … … 2371 2412 "%s jitter : %7.3f %7.3f %7.3f %7.3f %7.3f%s", 2372 2413 indent, 2373 info.stream_info[i].tx_pt, 2374 info.stream_info[i].param->info.frm_ptime * 2375 info.stream_info[i].param->setting.frm_per_pkt, 2414 info.tx_pt, 2415 info.param->info.frm_ptime * info.param->setting.frm_per_pkt, 2376 2416 last_update, 2377 2417 … … 2416 2456 2417 2457 len = pj_ansi_snprintf(p, end-p, 2418 "%s RTT msec : %7.3f %7.3f %7.3f %7.3f %7.3f",2458 "%s RTT msec : %7.3f %7.3f %7.3f %7.3f %7.3f", 2419 2459 indent, 2420 2460 stat.rtt.min / 1000.0, … … 2471 2511 } 2472 2512 2473 clock_rate = info. stream_info[i].fmt.clock_rate;2513 clock_rate = info.fmt.clock_rate; 2474 2514 2475 2515 len = pj_ansi_snprintf(p, end-p, "\n%s Extended reports:", indent); … … 2944 2984 2945 2985 /* Get and ICE SRTP status */ 2986 #if DISABLED_FOR_TICKET_1185 2946 2987 pjmedia_transport_info_init(&tp_info); 2947 pjmedia_transport_get_info(call-> med_tp, &tp_info);2988 pjmedia_transport_get_info(call->tp, &tp_info); 2948 2989 if (tp_info.specific_info_cnt > 0) { 2949 2990 unsigned i; … … 2984 3025 } 2985 3026 } 3027 #endif /* DISABLED_FOR_TICKET_1185 */ 2986 3028 2987 3029 /* Dump session statistics */ 2988 if (with_media && call->session)3030 if (with_media && pjsua_call_has_media(call_id)) 2989 3031 dump_media_session(indent, p, end-p, call); 2990 3032 … … 3064 3106 const pjmedia_sdp_media *ref_m; 3065 3107 pjmedia_sdp_media *m; 3108 pjsua_call_media *call_med = &call->media[call->audio_idx]; 3066 3109 unsigned i, codec_cnt = 0; 3067 3110 pj_bool_t rem_can_update; … … 3098 3141 3099 3142 /* Verify if media is deactivated */ 3100 if (call ->media_st== PJSUA_CALL_MEDIA_NONE ||3101 call->media_st== PJSUA_CALL_MEDIA_ERROR ||3102 call->media_dir == PJMEDIA_DIR_NONE)3143 if (call_med->state == PJSUA_CALL_MEDIA_NONE || 3144 call_med->state == PJSUA_CALL_MEDIA_ERROR || 3145 call_med->dir == PJMEDIA_DIR_NONE) 3103 3146 { 3104 3147 return PJ_EINVALIDOP; … … 3190 3233 const pjmedia_sdp_media *rem_m, *loc_m; 3191 3234 unsigned codec_cnt=0, i; 3235 pjsua_call_media *call_med = &call->media[call->audio_idx]; 3192 3236 pj_time_val delay = {0, 0}; 3193 3237 const pj_str_t st_update = {"UPDATE", 6}; … … 3207 3251 3208 3252 /* Skip this if the media is inactive or error */ 3209 if (call ->media_st== PJSUA_CALL_MEDIA_NONE ||3210 call->media_st== PJSUA_CALL_MEDIA_ERROR ||3211 call->media_dir == PJMEDIA_DIR_NONE)3253 if (call_med->state == PJSUA_CALL_MEDIA_NONE || 3254 call_med->state == PJSUA_CALL_MEDIA_ERROR || 3255 call_med->dir == PJMEDIA_DIR_NONE) 3212 3256 { 3213 3257 return PJ_SUCCESS; … … 3525 3569 3526 3570 /* Add SDP in 488 status */ 3527 if (call && call->med_tp && tdata->msg->type==PJSIP_RESPONSE_MSG && 3571 #if DISABLED_FOR_TICKET_1185 3572 if (call && call->tp && tdata->msg->type==PJSIP_RESPONSE_MSG && 3528 3573 code==PJSIP_SC_NOT_ACCEPTABLE_HERE) 3529 3574 { … … 3540 3585 } 3541 3586 } 3587 #endif 3542 3588 3543 3589 pjsip_inv_send_msg(inv, tdata); … … 3655 3701 */ 3656 3702 /* http://trac.pjsip.org/repos/ticket/880 3657 if (call-> media_dir != PJMEDIA_DIR_ENCODING) {3703 if (call->dir != PJMEDIA_DIR_ENCODING) { 3658 3704 */ 3659 3705 /* https://trac.pjsip.org/repos/ticket/1142: … … 3695 3741 pjmedia_sdp_media_remove_all_attr(m, "inactive"); 3696 3742 3697 if (call->media _dir & PJMEDIA_DIR_ENCODING) {3743 if (call->media[call->audio_idx].dir & PJMEDIA_DIR_ENCODING) { 3698 3744 /* Add sendonly attribute */ 3699 3745 attr = pjmedia_sdp_attr_create(pool, "sendonly", NULL);
Note: See TracChangeset
for help on using the changeset viewer.