Changeset 2191 for pjproject/trunk/pjsip/src/pjsua-lib/pjsua_call.c
- Timestamp:
- Aug 4, 2008 3:01:38 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjsip/src/pjsua-lib/pjsua_call.c
r2152 r2191 67 67 68 68 69 70 /* Create inactive SDP for call hold. */ 71 static pj_status_t create_inactive_sdp(pjsua_call *call, 72 pjmedia_sdp_session **p_answer); 69 /* Create SDP for call hold. */ 70 static pj_status_t create_sdp_of_call_hold(pjsua_call *call, 71 pjmedia_sdp_session **p_answer); 73 72 74 73 /* Update SDP version in the offer */ … … 118 117 call->rem_nat_type = PJ_STUN_NAT_TYPE_UNKNOWN; 119 118 call->rem_srtp_use = PJMEDIA_SRTP_DISABLED; 119 call->local_hold = PJ_FALSE; 120 120 } 121 121 … … 1427 1427 } 1428 1428 1429 status = create_ inactive_sdp(call, &sdp);1429 status = create_sdp_of_call_hold(call, &sdp); 1430 1430 if (status != PJ_SUCCESS) { 1431 1431 pjsip_dlg_dec_lock(dlg); … … 1453 1453 return status; 1454 1454 } 1455 1456 /* Set flag that local put the call on hold */ 1457 call->local_hold = PJ_TRUE; 1455 1458 1456 1459 pjsip_dlg_dec_lock(dlg); … … 1488 1491 1489 1492 /* Create SDP */ 1490 PJ_UNUSED_ARG(unhold); 1491 PJ_TODO(create_active_inactive_sdp_based_on_unhold_arg); 1492 status = pjsua_media_channel_create_sdp(call->index, call->inv->pool, 1493 NULL, &sdp, NULL); 1493 if (call->local_hold && !unhold) { 1494 status = create_sdp_of_call_hold(call, &sdp); 1495 } else { 1496 status = pjsua_media_channel_create_sdp(call->index, call->inv->pool, 1497 NULL, &sdp, NULL); 1498 call->local_hold = PJ_FALSE; 1499 } 1494 1500 if (status != PJ_SUCCESS) { 1495 1501 pjsua_perror(THIS_FILE, "Unable to get SDP from media endpoint", … … 1574 1580 status = pjsip_inv_send_msg( call->inv, tdata); 1575 1581 if (status != PJ_SUCCESS) { 1576 pjsua_perror(THIS_FILE, "Unable to send UPDAT Erequest", status);1582 pjsua_perror(THIS_FILE, "Unable to send UPDATE request", status); 1577 1583 pjsip_dlg_dec_lock(dlg); 1578 1584 return status; 1579 1585 } 1586 1587 call->local_hold = PJ_FALSE; 1580 1588 1581 1589 pjsip_dlg_dec_lock(dlg); … … 3013 3021 3014 3022 3015 /* 3016 * Create inactive SDP for call hold. 3017 */ 3018 static pj_status_t create_inactive_sdp(pjsua_call *call, 3019 pjmedia_sdp_session **p_answer) 3023 /* Create SDP for call hold. */ 3024 static pj_status_t create_sdp_of_call_hold(pjsua_call *call, 3025 pjmedia_sdp_session **p_answer) 3020 3026 { 3021 3027 pj_status_t status; 3022 3028 pj_pool_t *pool; 3023 pjmedia_sdp_conn *conn;3024 pjmedia_sdp_attr *attr;3025 pjmedia_transport_info tp_info;3026 3029 pjmedia_sdp_session *sdp; 3027 3030 … … 3029 3032 pool = call->inv->pool; 3030 3033 3031 /* Get media socket info */3032 pjmedia_transport_info_init(&tp_info);3033 pjmedia_transport_get_info(call->med_tp, &tp_info);3034 3035 3034 /* Create new offer */ 3036 status = pj media_endpt_create_sdp(pjsua_var.med_endpt, pool, 1,3037 &tp_info.sock_info, &sdp);3035 status = pjsua_media_channel_create_sdp(call->index, pool, NULL, &sdp, 3036 NULL); 3038 3037 if (status != PJ_SUCCESS) { 3039 3038 pjsua_perror(THIS_FILE, "Unable to create local SDP", status); … … 3041 3040 } 3042 3041 3043 /* Get SDP media connection line */ 3044 conn = sdp->media[0]->conn; 3045 if (!conn) 3046 conn = sdp->conn; 3047 3048 /* Modify address */ 3049 conn->addr = pj_str("0.0.0.0"); 3050 3051 /* Remove existing directions attributes */ 3052 pjmedia_sdp_media_remove_all_attr(sdp->media[0], "sendrecv"); 3053 pjmedia_sdp_media_remove_all_attr(sdp->media[0], "sendonly"); 3054 pjmedia_sdp_media_remove_all_attr(sdp->media[0], "recvonly"); 3055 pjmedia_sdp_media_remove_all_attr(sdp->media[0], "inactive"); 3056 3057 /* Add inactive attribute */ 3058 attr = pjmedia_sdp_attr_create(pool, "inactive", NULL); 3059 pjmedia_sdp_media_add_attr(sdp->media[0], attr); 3042 /* Call-hold is done by set the media direction to 'sendonly' 3043 * (PJMEDIA_DIR_ENCODING), except when current media direction is 3044 * 'inactive' (PJMEDIA_DIR_NONE). 3045 * (See RFC 3264 Section 8.4 and RFC 4317 Section 3.1) 3046 */ 3047 if (call->media_dir != PJMEDIA_DIR_ENCODING) { 3048 pjmedia_sdp_attr *attr; 3049 3050 /* Remove existing directions attributes */ 3051 pjmedia_sdp_media_remove_all_attr(sdp->media[0], "sendrecv"); 3052 pjmedia_sdp_media_remove_all_attr(sdp->media[0], "sendonly"); 3053 pjmedia_sdp_media_remove_all_attr(sdp->media[0], "recvonly"); 3054 pjmedia_sdp_media_remove_all_attr(sdp->media[0], "inactive"); 3055 3056 if (call->media_dir == PJMEDIA_DIR_ENCODING_DECODING) { 3057 /* Add sendonly attribute */ 3058 attr = pjmedia_sdp_attr_create(pool, "sendonly", NULL); 3059 pjmedia_sdp_media_add_attr(sdp->media[0], attr); 3060 } else { 3061 /* Add inactive attribute */ 3062 attr = pjmedia_sdp_attr_create(pool, "inactive", NULL); 3063 pjmedia_sdp_media_add_attr(sdp->media[0], attr); 3064 } 3065 } 3060 3066 3061 3067 *p_answer = sdp; … … 3063 3069 return status; 3064 3070 } 3065 3066 3071 3067 3072 /* … … 3071 3076 const pjmedia_sdp_session *offer) 3072 3077 { 3073 const char *remote_state;3074 3078 pjsua_call *call; 3075 3079 pjmedia_sdp_conn *conn; 3076 3080 pjmedia_sdp_session *answer; 3077 pj_bool_t is_remote_active;3078 3081 pj_status_t status; 3079 3082 … … 3081 3084 3082 3085 call = (pjsua_call*) inv->dlg->mod_data[pjsua_var.mod.id]; 3083 3084 /*3085 * See if remote is offering active media (i.e. not on-hold)3086 */3087 is_remote_active = PJ_TRUE;3088 3086 3089 3087 conn = offer->media[0]->conn; … … 3091 3089 conn = offer->conn; 3092 3090 3091 /* Supply candidate answer */ 3092 PJ_LOG(4,(THIS_FILE, "Call %d: received updated media offer", 3093 call->index)); 3094 3095 status = pjsua_media_channel_create_sdp(call->index, call->inv->pool, 3096 offer, &answer, NULL); 3097 if (status != PJ_SUCCESS) { 3098 pjsua_perror(THIS_FILE, "Unable to create local SDP", status); 3099 PJSUA_UNLOCK(); 3100 return; 3101 } 3102 3103 /* Check if offer's conn address is zero */ 3093 3104 if (pj_strcmp2(&conn->addr, "0.0.0.0")==0 || 3094 3105 pj_strcmp2(&conn->addr, "0")==0) 3095 3106 { 3096 is_remote_active = PJ_FALSE; 3097 3098 } 3099 else if (pjmedia_sdp_media_find_attr2(offer->media[0], "inactive", NULL) || 3100 pjmedia_sdp_media_find_attr2(offer->media[0], "sendonly", NULL)) 3101 { 3102 is_remote_active = PJ_FALSE; 3103 } 3104 3105 remote_state = (is_remote_active ? "active" : "inactive"); 3106 3107 /* Supply candidate answer */ 3108 if (call->media_st == PJSUA_CALL_MEDIA_LOCAL_HOLD || !is_remote_active) { 3109 PJ_LOG(4,(THIS_FILE, 3110 "Call %d: RX new media offer, creating inactive SDP " 3111 "(media in offer is %s)", call->index, remote_state)); 3112 status = create_inactive_sdp( call, &answer ); 3113 } else { 3114 PJ_LOG(4,(THIS_FILE, "Call %d: received updated media offer", 3115 call->index)); 3116 3117 status = pjsua_media_channel_create_sdp(call->index, call->inv->pool, 3118 offer, &answer, NULL); 3119 } 3120 3121 if (status != PJ_SUCCESS) { 3122 pjsua_perror(THIS_FILE, "Unable to create local SDP", status); 3123 PJSUA_UNLOCK(); 3124 return; 3107 /* Modify address */ 3108 answer->conn->addr = pj_str("0.0.0.0"); 3109 } 3110 3111 /* Check if call is on-hold */ 3112 if (call->local_hold) { 3113 pjmedia_sdp_attr *attr; 3114 3115 /* Remove existing directions attributes */ 3116 pjmedia_sdp_media_remove_all_attr(answer->media[0], "sendrecv"); 3117 pjmedia_sdp_media_remove_all_attr(answer->media[0], "sendonly"); 3118 pjmedia_sdp_media_remove_all_attr(answer->media[0], "recvonly"); 3119 pjmedia_sdp_media_remove_all_attr(answer->media[0], "inactive"); 3120 3121 /* Keep call on-hold by setting 'sendonly' attribute. 3122 * (See RFC 3264 Section 8.4 and RFC 4317 Section 3.1) 3123 */ 3124 attr = pjmedia_sdp_attr_create(call->inv->pool, "sendonly", NULL); 3125 pjmedia_sdp_media_add_attr(answer->media[0], attr); 3125 3126 } 3126 3127 … … 3150 3151 3151 3152 /* See if we've put call on hold. */ 3152 if (call-> media_st == PJSUA_CALL_MEDIA_LOCAL_HOLD) {3153 if (call->local_hold) { 3153 3154 PJ_LOG(4,(THIS_FILE, 3154 "Call %d: call is on-hold locally, creating inactiveSDP ",3155 "Call %d: call is on-hold locally, creating call-hold SDP ", 3155 3156 call->index)); 3156 status = create_ inactive_sdp( call, offer );3157 status = create_sdp_of_call_hold( call, offer ); 3157 3158 } else { 3158 3159 PJ_LOG(4,(THIS_FILE, "Call %d: asked to send a new offer",
Note: See TracChangeset
for help on using the changeset viewer.