Ignore:
Timestamp:
Jan 22, 2008 10:31:13 PM (16 years ago)
Author:
nanang
Message:

Ticket #452:

  • added part to test specific key, only for testing purpose
  • replaced pool instance for parsing SDP and generating key (from suplied pool param of media_create/start to internal srtp pool)
  • bug fixed in send rtcp callback
  • changed mutex type from null mutex to recursive mutex
  • changed srtp transport destroy: using mutex and reordering step.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/branches/users/nanang/pjmedia/src/pjmedia/transport_srtp.c

    r1724 r1726  
    182182}; 
    183183 
    184 char * octet_string_hex_string(const void *s, int length); 
    185  
    186  
    187184const char* get_libsrtp_errstr(int err) 
    188185{ 
     
    344341    } 
    345342 
    346     status = pj_lock_create_null_mutex(pool, pool->obj_name, &srtp->mutex); 
     343    status = pj_lock_create_recursive_mutex(pool, pool->obj_name, &srtp->mutex); 
    347344    if (status != PJ_SUCCESS) { 
    348345        pj_pool_release(pool); 
     
    634631 
    635632    if (srtp->bypass_srtp) 
    636         return pjmedia_transport_send_rtp(srtp->real_tp, pkt, size); 
     633        return pjmedia_transport_send_rtcp(srtp->real_tp, pkt, size); 
    637634 
    638635    if (!srtp->session_inited) 
     
    673670    pj_status_t status; 
    674671 
    675     pj_lock_destroy(srtp->mutex); 
     672    pj_lock_acquire(srtp->mutex); 
    676673 
    677674    pjmedia_transport_detach(tp, NULL); 
     
    683680    status = pjmedia_transport_srtp_stop(tp); 
    684681 
     682    pj_lock_release(srtp->mutex); 
     683 
     684    pj_lock_destroy(srtp->mutex); 
    685685    pj_pool_release(srtp->pool); 
    686686 
     
    714714        srtp->rtp_cb(srtp->user_data, srtp->rx_buffer, len); 
    715715    } else { 
    716         PJ_LOG(5, (THIS_FILE, "Failed to unprotect SRTP")); 
     716        PJ_LOG(5, (THIS_FILE, "Failed to unprotect SRTP size=%d, err=%d",  
     717                   size, err)); 
    717718    } 
    718719 
     
    746747        srtp->rtcp_cb(srtp->user_data, srtp->rx_buffer, len); 
    747748    } else { 
    748         PJ_LOG(5, (THIS_FILE, "Failed to unprotect SRTCP")); 
     749        PJ_LOG(5, (THIS_FILE, "Failed to unprotect SRTCP size=%d, err=%d", 
     750                   size, err)); 
    749751    } 
    750752     
     
    798800 
    799801        } while (!key_ok); 
    800         key[crypto_suites[cs_idx].cipher_key_len] = '\0'; 
    801         pj_strdup2(pool, &crypto->key, key); 
     802        crypto->key.ptr = pj_pool_zalloc(pool,  
     803                                         crypto_suites[cs_idx].cipher_key_len); 
     804        pj_memcpy(crypto->key.ptr, key, crypto_suites[cs_idx].cipher_key_len); 
     805        crypto->key.slen = crypto_suites[cs_idx].cipher_key_len; 
    802806    } 
    803807 
     
    965969            /* Offer crypto-suites based on setting. */ 
    966970            buffer_len = MAXLEN; 
    967             status = generate_crypto_attr_value(pool, buffer, &buffer_len, 
     971            status = generate_crypto_attr_value(srtp->pool, buffer, &buffer_len, 
    968972                                                &srtp->setting.crypto[i], 
    969973                                                i+1); 
     
    974978            if (buffer_len) { 
    975979                pj_strset(&attr_value, buffer, buffer_len); 
    976                 attr = pjmedia_sdp_attr_create(pool, ID_CRYPTO.ptr,  
     980                attr = pjmedia_sdp_attr_create(srtp->pool, ID_CRYPTO.ptr,  
    977981                                               &attr_value); 
    978982                m_loc->attr[m_loc->attr_count++] = attr; 
     
    10021006            has_crypto_attr = PJ_TRUE; 
    10031007 
    1004             status = parse_attr_crypto(pool, m_rem->attr[i],  
     1008            status = parse_attr_crypto(srtp->pool, m_rem->attr[i],  
    10051009                                       &tmp_rx_crypto, &tags[cr_attr_count]); 
    10061010            if (status != PJ_SUCCESS) 
     
    10221026                    { 
    10231027                        int cs_idx = get_crypto_idx(&tmp_rx_crypto.name); 
     1028 
     1029                        /* Force to use test key */ 
     1030                        //char *hex_test_key = "58b29c5c8f42308120ce857e439f2d" 
     1031                        //                   "7810a8b10ad0b1446be5470faea496"; 
     1032                        //pj_str_t* test_key = &srtp->setting.crypto[j].key; 
     1033                        //char  *raw_test_key = pj_pool_zalloc(srtp->pool, 64); 
     1034                        //hex_string_to_octet_string( 
     1035                        //              raw_test_key, 
     1036                        //              hex_test_key, 
     1037                        //              strlen(hex_test_key)); 
     1038                        //pj_strset(test_key, raw_test_key,  
     1039                        //        crypto_suites[cs_idx].cipher_key_len); 
    10241040 
    10251041                        if (tmp_rx_crypto.key.slen !=  
     
    10701086         */ 
    10711087        buffer_len = MAXLEN; 
    1072         status = generate_crypto_attr_value(pool, buffer, &buffer_len, 
     1088        status = generate_crypto_attr_value(srtp->pool, buffer, &buffer_len, 
    10731089                                            &srtp->tx_policy, 
    10741090                                            chosen_tag); 
     
    10791095        if (buffer_len) { 
    10801096            pj_strset(&attr_value, buffer, buffer_len); 
    1081             attr = pjmedia_sdp_attr_create(pool, ID_CRYPTO.ptr, &attr_value); 
     1097            attr = pjmedia_sdp_attr_create(srtp->pool, ID_CRYPTO.ptr,  
     1098                                           &attr_value); 
    10821099            m_loc->attr[m_loc->attr_count++] = attr; 
    10831100        } 
     
    11621179            has_crypto_attr = PJ_TRUE; 
    11631180 
    1164             status = parse_attr_crypto(pool, m_rem->attr[i],  
     1181            status = parse_attr_crypto(srtp->pool, m_rem->attr[i],  
    11651182                                       &tmp_tx_crypto, &rem_tag); 
    11661183            if (status != PJ_SUCCESS) 
Note: See TracChangeset for help on using the changeset viewer.