Changeset 3777


Ignore:
Timestamp:
Oct 3, 2011 2:04:36 AM (12 years ago)
Author:
ming
Message:

Closed #1266:
Handle incoming calls when media transport is created asynchronously.

Location:
pjproject/trunk/pjsip
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjsip/include/pjsip-ua/sip_inv.h

    r3553 r3777  
    546546 
    547547/** 
     548 * Variant of #pjsip_inv_verify_request() which allows application not to 
     549 * specify the rdata (i.e. pass NULL as the rdata parameter) and specify 
     550 * the parsed SDP in the \a offer argument and a temporary pool in the 
     551 * \a tmp_pool argument. 
     552 * This is useful if application no longer has access to the rdata. 
     553 * 
     554 * @see pjsip_inv_verify_request() 
     555 */ 
     556PJ_DECL(pj_status_t) pjsip_inv_verify_request3( pjsip_rx_data *rdata, 
     557                                                pj_pool_t *tmp_pool, 
     558                                                unsigned *options, 
     559                                                const pjmedia_sdp_session *offer, 
     560                                                const pjmedia_sdp_session *answer, 
     561                                                pjsip_dialog *dlg, 
     562                                                pjsip_endpoint *endpt, 
     563                                                pjsip_tx_data **tdata); 
     564 
     565 
     566/** 
    548567 * Create UAS invite session for the specified dialog in dlg. Application  
    549568 * SHOULD call the verification function before calling this function,  
     
    712731 
    713732/** 
     733 * Set local offer or answer depending on negotiator state (it may also 
     734 * create a negotiator if it doesn't exist yet). 
     735 * 
     736 * @param inv           The invite session. 
     737 * @param sdp           The SDP description which will be set as 
     738 *                      an offer/answer to remote. 
     739 * 
     740 * @return              PJ_SUCCESS if local offer/answer can be accepted by 
     741 *                      SDP negotiator. 
     742 */ 
     743PJ_DECL(pj_status_t) pjsip_inv_set_local_sdp(pjsip_inv_session *inv, 
     744                                             const pjmedia_sdp_session *sdp ); 
     745 
     746 
     747/** 
    714748 * Set local answer to respond to remote SDP offer, to be carried by  
    715749 * subsequent response (or request). 
  • pjproject/trunk/pjsip/include/pjsua-lib/pjsua_internal.h

    r3767 r3777  
    101101#define PJSUA_MAX_CALL_MEDIA            PJMEDIA_MAX_SDP_MEDIA 
    102102 
     103/* Call answer's list. */ 
     104typedef struct call_answer 
     105{ 
     106    PJ_DECL_LIST_MEMBER(struct call_answer); 
     107    pjsua_msg_data  *msg_data;      /**< Answer's headers list.       */ 
     108    pj_str_t        *reason;        /**< Answer's reason phrase.      */ 
     109    unsigned         code;          /**< Answer's status code.        */ 
     110} call_answer; 
     111 
     112 
    103113/**  
    104114 * Structure to be attached to invite dialog.  
     
    152162                pjsua_msg_data  *msg_data;/**< Headers for outgoing INVITE. */ 
    153163            } out_call; 
     164            struct { 
     165                call_answer      answers;/**< A list of call answers.       */ 
     166            } inc_call; 
    154167        } call_var; 
    155168    } async_call;                      /**< Temporary storage for async 
  • pjproject/trunk/pjsip/src/pjsip-ua/sip_inv.c

    r3753 r3777  
    812812 * Verify incoming INVITE request. 
    813813 */ 
    814 PJ_DEF(pj_status_t) pjsip_inv_verify_request2(pjsip_rx_data *rdata, 
     814PJ_DEF(pj_status_t) pjsip_inv_verify_request3(pjsip_rx_data *rdata, 
     815                                              pj_pool_t *tmp_pool, 
    815816                                              unsigned *options, 
    816817                                              const pjmedia_sdp_session *r_sdp, 
     
    820821                                              pjsip_tx_data **p_tdata) 
    821822{ 
    822     pjsip_msg *msg; 
    823     pjsip_allow_hdr *allow; 
    824     pjsip_supported_hdr *sup_hdr; 
    825     pjsip_require_hdr *req_hdr; 
    826     pjsip_contact_hdr *c_hdr; 
     823    pjsip_msg *msg = NULL; 
     824    pjsip_allow_hdr *allow = NULL; 
     825    pjsip_supported_hdr *sup_hdr = NULL; 
     826    pjsip_require_hdr *req_hdr = NULL; 
     827    pjsip_contact_hdr *c_hdr = NULL; 
    827828    int code = 200; 
    828829    unsigned rem_option = 0; 
     
    835836 
    836837    /* Verify arguments. */ 
    837     PJ_ASSERT_RETURN(rdata != NULL && options != NULL, PJ_EINVAL); 
     838    PJ_ASSERT_RETURN(tmp_pool != NULL && options != NULL, PJ_EINVAL); 
    838839 
    839840    /* Normalize options */ 
     
    845846        *options |= PJSIP_INV_SUPPORT_ICE; 
    846847 
    847     /* Get the message in rdata */ 
    848     msg = rdata->msg_info.msg; 
    849  
    850     /* Must be INVITE request. */ 
    851     PJ_ASSERT_RETURN(msg->type == PJSIP_REQUEST_MSG && 
    852                      msg->line.req.method.id == PJSIP_INVITE_METHOD, 
    853                      PJ_EINVAL); 
     848    if (rdata) { 
     849        /* Get the message in rdata */ 
     850        msg = rdata->msg_info.msg; 
     851     
     852        /* Must be INVITE request. */ 
     853        PJ_ASSERT_RETURN(msg && msg->type == PJSIP_REQUEST_MSG && 
     854                         msg->line.req.method.id == PJSIP_INVITE_METHOD, 
     855                         PJ_EINVAL); 
     856    } 
    854857 
    855858    /* If tdata is specified, then either dlg or endpt must be specified */ 
     
    863866 
    864867    /* Check the Contact header */ 
    865     c_hdr = (pjsip_contact_hdr*) 
    866             pjsip_msg_find_hdr(msg, PJSIP_H_CONTACT, NULL); 
    867     if (!c_hdr || !c_hdr->uri) { 
    868         /* Missing Contact header or Contact contains "*" */ 
     868    if (msg) { 
     869        c_hdr = (pjsip_contact_hdr*) 
     870                pjsip_msg_find_hdr(msg, PJSIP_H_CONTACT, NULL); 
     871    } 
     872    if (msg && (!c_hdr || !c_hdr->uri)) { 
     873        /* Missing Contact header or Contact contains "*" */ 
    869874        pjsip_warning_hdr *w; 
    870875        pj_str_t warn_text; 
    871876 
    872877        warn_text = pj_str("Bad/missing Contact header"); 
    873         w = pjsip_warning_hdr_create(rdata->tp_info.pool, 399, 
     878        w = pjsip_warning_hdr_create(tmp_pool, 399, 
    874879                                     pjsip_endpt_name(endpt), 
    875880                                     &warn_text); 
     
    886891     * only when the body hasn't been parsed before. 
    887892     */ 
    888     if (r_sdp == NULL) { 
     893    if (r_sdp == NULL && rdata) { 
    889894        sdp_info = pjsip_rdata_get_sdp_info(rdata); 
    890895    } else { 
     
    892897    } 
    893898 
    894     if (r_sdp==NULL && msg->body) { 
     899    if (r_sdp==NULL && msg && msg->body) { 
    895900 
    896901        /* Check if body really contains SDP. */ 
     
    904909                pjsip_accept_hdr *acc; 
    905910 
    906                 acc = pjsip_accept_hdr_create(rdata->tp_info.pool); 
     911                acc = pjsip_accept_hdr_create(tmp_pool); 
    907912                PJ_ASSERT_RETURN(acc, PJ_ENOMEM); 
    908913                acc->values[acc->count++] = pj_str("application/sdp"); 
     
    921926                pjsip_warning_hdr *w; 
    922927 
    923                 w = pjsip_warning_hdr_create_from_status(rdata->tp_info.pool, 
     928                w = pjsip_warning_hdr_create_from_status(tmp_pool, 
    924929                                                         pjsip_endpt_name(endpt), 
    925930                                                         sdp_info->sdp_err); 
     
    946951            /* Create SDP negotiator */ 
    947952            status = pjmedia_sdp_neg_create_w_remote_offer( 
    948                             rdata->tp_info.pool, l_sdp, r_sdp, &neg); 
     953                            tmp_pool, l_sdp, r_sdp, &neg); 
    949954            PJ_ASSERT_RETURN(status == PJ_SUCCESS, status); 
    950955 
    951956            /* Negotiate SDP */ 
    952             status = pjmedia_sdp_neg_negotiate(rdata->tp_info.pool, neg, 0); 
     957            status = pjmedia_sdp_neg_negotiate(tmp_pool, neg, 0); 
    953958            if (status != PJ_SUCCESS) { 
    954959 
     
    962967                    /* Add Warning header. */ 
    963968                    w = pjsip_warning_hdr_create_from_status( 
    964                                             rdata->tp_info.pool,  
     969                                            tmp_pool,  
    965970                                            pjsip_endpt_name(endpt), status); 
    966971                    PJ_ASSERT_RETURN(w, PJ_ENOMEM); 
     
    969974 
    970975                    /* Add Accept header to response */ 
    971                     acc = pjsip_accept_hdr_create(rdata->tp_info.pool); 
     976                    acc = pjsip_accept_hdr_create(tmp_pool); 
    972977                    PJ_ASSERT_RETURN(acc, PJ_ENOMEM); 
    973978                    acc->values[acc->count++] = pj_str("application/sdp"); 
     
    985990     * implicitly by sending this INVITE. 
    986991     */ 
    987     allow = (pjsip_allow_hdr*) pjsip_msg_find_hdr(msg, PJSIP_H_ALLOW, NULL); 
     992    if (msg) { 
     993        allow = (pjsip_allow_hdr*) pjsip_msg_find_hdr(msg, PJSIP_H_ALLOW, 
     994                                                      NULL); 
     995    } 
    988996    if (allow) { 
    989997        unsigned i; 
     
    10031011 
    10041012    /* Check Supported header */ 
    1005     sup_hdr = (pjsip_supported_hdr*) 
    1006               pjsip_msg_find_hdr(msg, PJSIP_H_SUPPORTED, NULL); 
     1013    if (msg) { 
     1014        sup_hdr = (pjsip_supported_hdr*) 
     1015                  pjsip_msg_find_hdr(msg, PJSIP_H_SUPPORTED, NULL); 
     1016    } 
    10071017    if (sup_hdr) { 
    10081018        unsigned i; 
     
    10221032 
    10231033    /* Check Require header */ 
    1024     req_hdr = (pjsip_require_hdr*) 
    1025               pjsip_msg_find_hdr(msg, PJSIP_H_REQUIRE, NULL); 
     1034    if (msg) { 
     1035        req_hdr = (pjsip_require_hdr*) 
     1036                  pjsip_msg_find_hdr(msg, PJSIP_H_REQUIRE, NULL); 
     1037    } 
    10261038    if (req_hdr) { 
    10271039        unsigned i; 
     
    10751087 
    10761088                /* Add Unsupported header. */ 
    1077                 unsupp_hdr = pjsip_unsupported_hdr_create(rdata->tp_info.pool); 
     1089                unsupp_hdr = pjsip_unsupported_hdr_create(tmp_pool); 
    10781090                PJ_ASSERT_RETURN(unsupp_hdr != NULL, PJ_ENOMEM); 
    10791091 
     
    10901102                if (h) { 
    10911103                    sup_hdr = (pjsip_supported_hdr*) 
    1092                               pjsip_hdr_clone(rdata->tp_info.pool, h); 
     1104                              pjsip_hdr_clone(tmp_pool, h); 
    10931105                    pj_list_push_back(&res_hdr_list, sup_hdr); 
    10941106                } 
     
    11021114     * by peer. 
    11031115     */ 
    1104     if ( ((*options & PJSIP_INV_REQUIRE_100REL)!=0 &&  
     1116    if ( msg && (((*options & PJSIP_INV_REQUIRE_100REL)!=0 &&  
    11051117          (rem_option & PJSIP_INV_SUPPORT_100REL)==0) || 
    11061118         ((*options & PJSIP_INV_REQUIRE_TIMER)!=0 &&  
    1107           (rem_option & PJSIP_INV_SUPPORT_TIMER)==0)) 
     1119          (rem_option & PJSIP_INV_SUPPORT_TIMER)==0))) 
    11081120    { 
    11091121        code = PJSIP_SC_EXTENSION_REQUIRED; 
     
    11141126 
    11151127            /* Add Require header. */ 
    1116             req_hdr = pjsip_require_hdr_create(rdata->tp_info.pool); 
     1128            req_hdr = pjsip_require_hdr_create(tmp_pool); 
    11171129            PJ_ASSERT_RETURN(req_hdr != NULL, PJ_ENOMEM); 
    11181130 
     
    11301142            if (h) { 
    11311143                sup_hdr = (pjsip_supported_hdr*) 
    1132                           pjsip_hdr_clone(rdata->tp_info.pool, h); 
     1144                          pjsip_hdr_clone(tmp_pool, h); 
    11331145                pj_list_push_back(&res_hdr_list, sup_hdr); 
    11341146            } 
     
    11581170        const pjsip_hdr *h; 
    11591171 
     1172        if (!rdata) { 
     1173            return PJSIP_ERRNO_FROM_SIP_STATUS(code); 
     1174        } 
     1175 
    11601176        if (dlg) { 
    11611177            status = pjsip_dlg_create_response(dlg, rdata, code, NULL,  
     
    11991215 * Verify incoming INVITE request. 
    12001216 */ 
     1217PJ_DEF(pj_status_t) pjsip_inv_verify_request2(pjsip_rx_data *rdata, 
     1218                                              unsigned *options, 
     1219                                              const pjmedia_sdp_session *r_sdp, 
     1220                                              const pjmedia_sdp_session *l_sdp, 
     1221                                              pjsip_dialog *dlg, 
     1222                                              pjsip_endpoint *endpt, 
     1223                                              pjsip_tx_data **p_tdata) 
     1224{ 
     1225    return pjsip_inv_verify_request3(rdata, rdata->tp_info.pool, 
     1226                                     options, r_sdp, l_sdp, dlg,  
     1227                                     endpt, p_tdata); 
     1228} 
     1229 
     1230 
     1231/* 
     1232 * Verify incoming INVITE request. 
     1233 */ 
    12011234PJ_DEF(pj_status_t) pjsip_inv_verify_request( pjsip_rx_data *rdata, 
    12021235                                              unsigned *options, 
     
    12061239                                              pjsip_tx_data **p_tdata) 
    12071240{ 
    1208     return pjsip_inv_verify_request2(rdata, options, NULL, l_sdp, dlg,  
     1241    return pjsip_inv_verify_request3(rdata, rdata->tp_info.pool, 
     1242                                     options, NULL, l_sdp, dlg,  
    12091243                                     endpt, p_tdata); 
    12101244} 
     
    20232057    pjsip_dlg_dec_lock(inv->dlg); 
    20242058    pj_log_pop_indent(); 
     2059    return status; 
     2060} 
     2061 
     2062 
     2063/* 
     2064 * Set local SDP offer/answer. 
     2065 */ 
     2066PJ_DEF(pj_status_t) pjsip_inv_set_local_sdp(pjsip_inv_session *inv, 
     2067                                            const pjmedia_sdp_session *sdp ) 
     2068{ 
     2069    const pjmedia_sdp_session *offer; 
     2070    pj_status_t status; 
     2071 
     2072    PJ_ASSERT_RETURN(inv && sdp, PJ_EINVAL); 
     2073 
     2074    /* If we have remote SDP offer, set local answer to respond to the offer, 
     2075     * otherwise we set/modify our local offer (and create an SDP negotiator 
     2076     * if we don't have one yet). 
     2077     */ 
     2078    if (inv->neg) { 
     2079        pjmedia_sdp_neg_state neg_state = pjmedia_sdp_neg_get_state(inv->neg); 
     2080 
     2081        if ((neg_state == PJMEDIA_SDP_NEG_STATE_REMOTE_OFFER || 
     2082             neg_state == PJMEDIA_SDP_NEG_STATE_WAIT_NEGO) && 
     2083            pjmedia_sdp_neg_get_neg_remote(inv->neg, &offer) == PJ_SUCCESS) 
     2084        { 
     2085            status = pjsip_inv_set_sdp_answer(inv, sdp); 
     2086        }  else if (neg_state == PJMEDIA_SDP_NEG_STATE_DONE) { 
     2087            status = pjmedia_sdp_neg_modify_local_offer(inv->pool, 
     2088                                                        inv->neg, sdp); 
     2089        } else 
     2090            return PJMEDIA_SDPNEG_EINSTATE; 
     2091    } else { 
     2092        status = pjmedia_sdp_neg_create_w_local_offer(inv->pool,  
     2093                                                      sdp, &inv->neg); 
     2094    } 
     2095 
    20252096    return status; 
    20262097} 
  • pjproject/trunk/pjsip/src/pjsua-lib/pjsua_call.c

    r3775 r3777  
    332332*/ 
    333333 
     334/* Outgoing call callback when media transport creation is completed. */ 
    334335static pj_status_t 
    335336on_make_call_med_tp_complete(pjsua_call_id call_id, 
     
    612613    call->user_data = user_data; 
    613614     
     615    /* Store variables required for the callback after the async 
     616     * media transport creation is completed. 
     617     */ 
    614618    call->async_call.call_var.out_call.options = options; 
    615619    if (msg_data) { 
     
    686690 
    687691 
     692/* Incoming call callback when media transport creation is completed. */ 
     693static pj_status_t 
     694on_incoming_call_med_tp_complete(pjsua_call_id call_id, 
     695                                 const pjsua_med_tp_state_info *info) 
     696{ 
     697    pjsua_call *call = &pjsua_var.calls[call_id]; 
     698    const pjmedia_sdp_session *offer=NULL; 
     699    pjmedia_sdp_session *answer; 
     700    pjsip_tx_data *response = NULL; 
     701    unsigned options = 0; 
     702    int sip_err_code = (info? info->sip_err_code: 0); 
     703    pj_status_t status = (info? info->status: PJ_SUCCESS); 
     704 
     705    PJSUA_LOCK(); 
     706 
     707    if (status != PJ_SUCCESS) { 
     708        pjsua_perror(THIS_FILE, "Error initializing media channel", status); 
     709        goto on_return; 
     710    } 
     711     
     712    /* Get remote SDP offer (if any). */ 
     713    if (call->inv->neg) 
     714        pjmedia_sdp_neg_get_neg_remote(call->inv->neg, &offer); 
     715 
     716    status = pjsua_media_channel_create_sdp(call_id, 
     717                                            call->async_call.dlg->pool,  
     718                                            offer, &answer, &sip_err_code); 
     719    if (status != PJ_SUCCESS) { 
     720        pjsua_perror(THIS_FILE, "Error creating SDP answer", status); 
     721        goto on_return; 
     722    } 
     723 
     724    status = pjsip_inv_set_local_sdp(call->inv, answer); 
     725    if (status != PJ_SUCCESS) { 
     726        pjsua_perror(THIS_FILE, "Error setting local SDP", status); 
     727        sip_err_code = PJSIP_SC_NOT_ACCEPTABLE_HERE; 
     728        goto on_return; 
     729    } 
     730 
     731    /* Verify that we can handle the request. */ 
     732    status = pjsip_inv_verify_request3(NULL, 
     733                                       call->inv->pool_prov, &options, offer, 
     734                                       answer, NULL, pjsua_var.endpt, &response); 
     735    if (status != PJ_SUCCESS) { 
     736        /* 
     737         * No we can't handle the incoming INVITE request. 
     738         */ 
     739        goto on_return; 
     740    }  
     741 
     742on_return: 
     743    if (status != PJ_SUCCESS) { 
     744        pjsip_tx_data *tdata; 
     745        pj_status_t status_; 
     746 
     747        status_ = pjsip_inv_end_session(call->inv, sip_err_code, NULL, &tdata); 
     748        if (status_ == PJ_SUCCESS && tdata) 
     749            status_ = pjsip_inv_send_msg(call->inv, tdata); 
     750 
     751        pjsua_media_channel_deinit(call->index); 
     752    } 
     753 
     754    /* Set the callback to NULL to indicate that the async operation 
     755     * has completed. 
     756     */ 
     757    call->med_ch_cb = NULL; 
     758 
     759    if (status == PJ_SUCCESS && 
     760        !pj_list_empty(&call->async_call.call_var.inc_call.answers)) 
     761    { 
     762        struct call_answer *answer, *next; 
     763         
     764        answer = call->async_call.call_var.inc_call.answers.next; 
     765        while (answer != &call->async_call.call_var.inc_call.answers) { 
     766            next = answer->next; 
     767            pjsua_call_answer(call_id, answer->code, answer->reason, 
     768                              answer->msg_data); 
     769            pj_list_erase(answer); 
     770            answer = next; 
     771        } 
     772    } 
     773 
     774    PJSUA_UNLOCK(); 
     775    return status; 
     776} 
     777 
     778 
    688779/** 
    689780 * Handle incoming INVITE request. 
     
    704795    int call_id = -1; 
    705796    int sip_err_code; 
    706     pjmedia_sdp_session *offer=NULL, *answer; 
     797    pjmedia_sdp_session *offer=NULL; 
    707798    pj_status_t status; 
    708799 
     
    865956    } else { 
    866957        offer = NULL; 
    867     } 
    868  
    869     /* Init media channel */ 
    870     status = pjsua_media_channel_init(call->index, PJSIP_ROLE_UAS,  
    871                                       call->secure_level,  
    872                                       rdata->tp_info.pool, 
    873                                       offer, 
    874                                       &sip_err_code, PJ_FALSE, 
    875                                       NULL); 
    876     if (status != PJ_SUCCESS) { 
    877         pjsua_perror(THIS_FILE, "Error initializing media channel", status); 
    878         pjsip_endpt_respond(pjsua_var.endpt, NULL, rdata, 
    879                             sip_err_code, NULL, NULL, NULL, NULL); 
    880         goto on_return; 
    881     } 
    882  
    883     /* Create answer */ 
    884     status = pjsua_media_channel_create_sdp(call->index, rdata->tp_info.pool,  
    885                                             offer, &answer, &sip_err_code); 
    886     if (status != PJ_SUCCESS) { 
    887         pjsua_perror(THIS_FILE, "Error creating SDP answer", status); 
    888         pjsip_endpt_respond(pjsua_var.endpt, NULL, rdata, 
    889                             sip_err_code, NULL, NULL, NULL, NULL); 
    890         goto on_return; 
    891958    } 
    892959 
     
    903970        options |= PJSIP_INV_ALWAYS_USE_TIMER; 
    904971 
    905     status = pjsip_inv_verify_request2(rdata, &options, offer, answer, NULL, 
     972    status = pjsip_inv_verify_request2(rdata, &options, offer, NULL, NULL, 
    906973                                       pjsua_var.endpt, &response); 
    907974    if (status != PJ_SUCCESS) { 
     
    923990        } 
    924991 
    925         pjsua_media_channel_deinit(call->index); 
    926992        goto on_return; 
    927993    }  
    928  
    929994 
    930995    /* Get suitable Contact header */ 
     
    9391004            pjsip_endpt_respond_stateless(pjsua_var.endpt, rdata, 500, NULL, 
    9401005                                          NULL, NULL); 
    941             pjsua_media_channel_deinit(call->index); 
    9421006            goto on_return; 
    9431007        } 
     
    9501014        pjsip_endpt_respond_stateless(pjsua_var.endpt, rdata, 500, NULL, 
    9511015                                      NULL, NULL); 
    952         pjsua_media_channel_deinit(call->index); 
    9531016        goto on_return; 
    9541017    } 
     
    9751038 
    9761039    /* Create invite session: */ 
    977     status = pjsip_inv_create_uas( dlg, rdata, answer, options, &inv); 
     1040    status = pjsip_inv_create_uas( dlg, rdata, NULL, options, &inv); 
    9781041    if (status != PJ_SUCCESS) { 
    9791042        pjsip_hdr hdr_list; 
     
    9951058    } 
    9961059 
     1060    /* Create and attach pjsua_var data to the dialog: */ 
     1061    call->inv = inv; 
     1062    dlg->mod_data[pjsua_var.mod.id] = call; 
     1063    inv->mod_data[pjsua_var.mod.id] = call; 
     1064 
     1065    /* Store variables required for the callback after the async 
     1066     * media transport creation is completed. 
     1067     */ 
     1068    call->async_call.dlg = dlg; 
     1069    pj_list_init(&call->async_call.call_var.inc_call.answers); 
     1070 
     1071    /* Init media channel */ 
     1072    status = pjsua_media_channel_init(call->index, PJSIP_ROLE_UAS,  
     1073                                      call->secure_level,  
     1074                                      rdata->tp_info.pool, 
     1075                                      offer, 
     1076                                      &sip_err_code, PJ_TRUE, 
     1077                                      (pjsua_med_tp_state_cb) 
     1078                                      &on_incoming_call_med_tp_complete); 
     1079    if (status == PJ_SUCCESS) { 
     1080        status = on_incoming_call_med_tp_complete(call_id, NULL); 
     1081        if (status != PJ_SUCCESS) { 
     1082            sip_err_code = PJSIP_SC_NOT_ACCEPTABLE; 
     1083            pjsip_dlg_respond(dlg, rdata, sip_err_code, NULL, NULL, NULL); 
     1084            goto on_return; 
     1085        } 
     1086    } else if (status != PJ_EPENDING) { 
     1087        pjsua_perror(THIS_FILE, "Error initializing media channel", status); 
     1088        pjsip_dlg_respond(dlg, rdata, sip_err_code, NULL, NULL, NULL); 
     1089        goto on_return; 
     1090    } 
     1091 
     1092    /* Create answer */ 
     1093/*   
     1094    status = pjsua_media_channel_create_sdp(call->index, rdata->tp_info.pool,  
     1095                                            offer, &answer, &sip_err_code); 
     1096    if (status != PJ_SUCCESS) { 
     1097        pjsua_perror(THIS_FILE, "Error creating SDP answer", status); 
     1098        pjsip_endpt_respond(pjsua_var.endpt, NULL, rdata, 
     1099                            sip_err_code, NULL, NULL, NULL, NULL); 
     1100        goto on_return; 
     1101    } 
     1102*/ 
     1103 
    9971104    /* Init Session Timers */ 
    9981105    status = pjsip_timer_init_session(inv,  
     
    10131120     * incoming INVITE!  
    10141121     */ 
    1015     if (pjsua_var.ua_cfg.nat_type_in_sdp && 
     1122    if (pjsua_var.ua_cfg.nat_type_in_sdp && inv->neg && 
    10161123        pjmedia_sdp_neg_get_state(inv->neg) > PJMEDIA_SDP_NEG_STATE_LOCAL_OFFER)  
    10171124    { 
     
    10631170        } 
    10641171    } 
    1065  
    1066     /* Create and attach pjsua_var data to the dialog: */ 
    1067     call->inv = inv; 
    1068  
    1069     dlg->mod_data[pjsua_var.mod.id] = call; 
    1070     inv->mod_data[pjsua_var.mod.id] = call; 
    10711172 
    10721173    ++pjsua_var.call_cnt; 
     
    16371738    if (status != PJ_SUCCESS) 
    16381739        goto on_return; 
     1740 
     1741    PJSUA_LOCK(); 
     1742    /* If media transport creation is not yet completed, we will answer 
     1743     * the call in the media transport creation callback instead. 
     1744     */ 
     1745    if (call->med_ch_cb) { 
     1746        struct call_answer *answer; 
     1747         
     1748        PJ_LOG(4,(THIS_FILE, "Pending answering call %d upon completion " 
     1749                             "of media transport", call_id)); 
     1750 
     1751        answer = PJ_POOL_ZALLOC_T(call->inv->pool_prov, struct call_answer); 
     1752        answer->code = code; 
     1753        if (reason) { 
     1754            pj_strdup(call->inv->pool_prov, answer->reason, reason); 
     1755        } 
     1756        if (msg_data) { 
     1757            answer->msg_data = pjsua_msg_data_clone(call->inv->pool_prov, 
     1758                                                    msg_data); 
     1759        } 
     1760        pj_list_push_back(&call->async_call.call_var.inc_call.answers, 
     1761                          answer); 
     1762 
     1763        PJSUA_UNLOCK(); 
     1764        if (dlg) pjsip_dlg_dec_lock(dlg); 
     1765        pj_log_pop_indent(); 
     1766        return status; 
     1767    } 
     1768    PJSUA_UNLOCK(); 
    16391769 
    16401770    if (call->res_time.sec == 0) 
  • pjproject/trunk/pjsip/src/pjsua-lib/pjsua_media.c

    r3775 r3777  
    16571657        call->med_ch_cb = cb; 
    16581658        if (rem_sdp) { 
    1659             /* TODO: change rem_sdp to non-const parameter. */ 
    16601659            call->async_call.rem_sdp = 
    16611660                pjmedia_sdp_session_clone(call->inv->pool_prov, rem_sdp); 
     
    21132112    pjsua_call *call = &pjsua_var.calls[call_id]; 
    21142113    unsigned mi; 
     2114 
     2115    for (mi=0; mi<call->med_cnt; ++mi) { 
     2116        pjsua_call_media *call_med = &call->media[mi]; 
     2117 
     2118        if (call_med->tp_st == PJSUA_MED_TP_CREATING) 
     2119            return PJ_EBUSY; 
     2120    } 
    21152121 
    21162122    PJ_LOG(4,(THIS_FILE, "Call %d: deinitializing media..", call_id)); 
Note: See TracChangeset for help on using the changeset viewer.