Changeset 1700
- Timestamp:
- Jan 17, 2008 8:37:38 PM (17 years ago)
- Location:
- pjproject/branches/users/nanang
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/branches/users/nanang/pjmedia/include/pjmedia/errno.h
r1639 r1700 527 527 528 528 529 /************************************************************ 530 * SRTP TRANSPORT ERRORS 531 ***********************************************************/ 532 /** 533 * @hideinitializer 534 * Secure transport required in SDP media descriptor. 535 */ 536 #define PJMEDIA_SRTP_ESDPREQSECTP (PJMEDIA_ERRNO_START+220) /* 220220 */ 537 /** 538 * @hideinitializer 539 * SDP contains ambigue answer. 540 */ 541 #define PJMEDIA_SRTP_ESDPAMBIGUEANS (PJMEDIA_ERRNO_START+221) /* 220221 */ 542 543 544 529 545 /** 530 546 * Get error message for the specified error code. Note that this -
pjproject/branches/users/nanang/pjmedia/src/pjmedia/errno.c
r1639 r1700 142 142 PJ_BUILD_ERR( PJMEDIA_ESNDINDEVID, "Invalid sound device ID" ), 143 143 PJ_BUILD_ERR( PJMEDIA_ESNDINSAMPLEFMT, "Invalid sample format for sound device" ), 144 145 /* SRTP transport errors: */ 146 PJ_BUILD_ERR( PJMEDIA_SRTP_ESDPREQSECTP, "Secure transport required in SDP media descriptor" ), 147 PJ_BUILD_ERR( PJMEDIA_SRTP_ESDPAMBIGUEANS, "SDP contains ambigue answer" ), 148 144 149 }; 145 150 -
pjproject/branches/users/nanang/pjmedia/src/pjmedia/transport_srtp.c
r1698 r1700 22 22 #include <pjlib-util/base64.h> 23 23 #include <pj/assert.h> 24 #include <pj/lock.h> 24 25 #include <pj/log.h> 25 26 #include <pj/os.h> … … 72 73 pjmedia_transport base; /**< Base transport interface. */ 73 74 pj_pool_t *pool; 74 pj_ mutex_t *mutex;75 pj_lock_t *mutex; 75 76 char tx_buffer[MAX_BUFFER_LEN]; 76 77 char rx_buffer[MAX_BUFFER_LEN]; … … 174 175 static pj_status_t pjmedia_srtp_init_lib(void) 175 176 { 176 err_status_t err;177 177 static pj_bool_t initialized = PJ_FALSE; 178 178 179 179 if (initialized == PJ_FALSE) { 180 err_status_t err; 180 181 err = srtp_init(); 181 182 if (err != err_status_ok) { 183 PJ_LOG(4, (THIS_FILE, "Failed to init libsrtp.")); 182 184 return SRTP_ERROR(err); 183 185 } … … 208 210 /* Init libsrtp. */ 209 211 status = pjmedia_srtp_init_lib(); 210 if (status != PJ_SUCCESS) {212 if (status != PJ_SUCCESS) 211 213 return status; 212 }213 214 214 215 pool = pjmedia_endpt_create_pool(endpt, "srtp%p", 1000, 1000); … … 220 221 srtp->options = options; 221 222 222 status = pj_ mutex_create_recursive(pool, pool->obj_name, &srtp->mutex);223 status = pj_lock_create_null_mutex(pool, pool->obj_name, &srtp->mutex); 223 224 if (status != PJ_SUCCESS) { 224 225 pj_pool_release(pool); … … 259 260 260 261 if (p_srtp->session_inited) { 261 return PJ_EEXISTS; 262 PJ_LOG(4, (THIS_FILE, "SRTP could not be re-init'd before deinit'd")); 263 return PJ_EINVALIDOP; 262 264 } 263 265 … … 276 278 277 279 if ((cs_tx_idx == -1) || (cs_rx_idx == -1)) { 280 PJ_LOG(4, (THIS_FILE, "Crypto-suite specified is not supported.")); 278 281 return PJ_ENOTSUP; 279 282 } … … 330 333 p_srtp->session_inited = PJ_TRUE; 331 334 332 PJ_LOG( 3, (THIS_FILE, "TX %s key=%s", crypto_suites[cs_tx_idx].name,335 PJ_LOG(5, (THIS_FILE, "TX %s key=%s", crypto_suites[cs_tx_idx].name, 333 336 octet_string_hex_string(policy_tx->key.ptr, policy_tx->key.slen))); 334 PJ_LOG( 3, (THIS_FILE, "RX %s key=%s", crypto_suites[cs_rx_idx].name,337 PJ_LOG(5, (THIS_FILE, "RX %s key=%s", crypto_suites[cs_rx_idx].name, 335 338 octet_string_hex_string(policy_rx->key.ptr, policy_rx->key.slen))); 336 339 … … 352 355 err = srtp_dealloc(p_srtp->srtp_rx_ctx); 353 356 if (err != err_status_ok) { 354 PJ_TODO(LOG_ERROR_DEALLOC_RX); 355 //return SRTP_ERROR(err); 357 PJ_LOG(4, (THIS_FILE, "Failed to dealloc RX SRTP context")); 356 358 } 357 359 err = srtp_dealloc(p_srtp->srtp_tx_ctx); 358 360 if (err != err_status_ok) { 359 PJ_TODO(LOG_ERROR_DEALLOC_TX); 360 //return SRTP_ERROR(err); 361 PJ_LOG(4, (THIS_FILE, "Failed to dealloc TX SRTP context")); 361 362 } 362 363 … … 402 403 status = pjmedia_transport_attach(srtp->real_tp, srtp, rem_addr, rem_rtcp, 403 404 addr_len, &srtp_rtp_cb, &srtp_rtcp_cb); 404 if (status != PJ_SUCCESS) { 405 PJ_TODO(HANDLE_FAILURE); 406 } 405 if (status != PJ_SUCCESS) 406 return status; 407 407 408 408 /* Save the callbacks */ … … 443 443 PJ_ASSERT_RETURN(size < sizeof(srtp->tx_buffer), PJ_ETOOBIG); 444 444 445 pj_ mutex_lock(srtp->mutex);445 pj_lock_acquire(srtp->mutex); 446 446 pj_memcpy(srtp->tx_buffer, pkt, size); 447 447 … … 453 453 } 454 454 455 pj_ mutex_unlock(srtp->mutex);455 pj_lock_release(srtp->mutex); 456 456 457 457 return status; … … 472 472 PJ_ASSERT_RETURN((size) < sizeof(srtp->tx_buffer), PJ_ETOOBIG); 473 473 474 pj_ mutex_lock(srtp->mutex);474 pj_lock_acquire(srtp->mutex); 475 475 pj_memcpy(srtp->tx_buffer, pkt, size); 476 476 … … 483 483 } 484 484 485 pj_ mutex_unlock(srtp->mutex);485 pj_lock_release(srtp->mutex); 486 486 487 487 return status; … … 501 501 transport_srtp *srtp = (transport_srtp *) tp; 502 502 pj_status_t status; 503 504 pj_lock_destroy(srtp->mutex); 503 505 504 506 pjmedia_transport_detach(tp, NULL); … … 509 511 510 512 status = pjmedia_transport_srtp_deinit_session(tp); 511 if (status != PJ_SUCCESS) 512 return status; 513 514 pj_mutex_destroy(srtp->mutex); 513 515 514 pj_pool_release(srtp->pool); 516 515 517 return PJ_SUCCESS;516 return status; 518 517 } 519 518 … … 531 530 } 532 531 533 pj_ mutex_lock(srtp->mutex);532 pj_lock_acquire(srtp->mutex); 534 533 pj_memcpy(srtp->rx_buffer, pkt, size); 535 534 536 535 err = srtp_unprotect(srtp->srtp_rx_ctx, srtp->rx_buffer, &len); 537 536 538 /* unprotect should returns less (or same, if auth disabled) size */539 PJ_TODO(CHECK_SIZE_AFTER_UNPROTECT);540 541 537 if (err == err_status_ok) { 542 538 srtp->rtp_cb(srtp->user_data, srtp->rx_buffer, len); 543 539 } else { 544 PJ_ TODO(LOG_ERROR_UNPROTECT);545 } 546 547 pj_ mutex_unlock(srtp->mutex);540 PJ_LOG(5, (THIS_FILE, "Failed to unprotect SRTP")); 541 } 542 543 pj_lock_release(srtp->mutex); 548 544 } 549 545 … … 561 557 } 562 558 563 pj_ mutex_lock(srtp->mutex);559 pj_lock_acquire(srtp->mutex); 564 560 pj_memcpy(srtp->rx_buffer, pkt, size); 565 561 566 562 err = srtp_unprotect_rtcp(srtp->srtp_rx_ctx, srtp->rx_buffer, &len); 567 568 /* unprotect should returns less (or same, if auth disabled) size */569 PJ_TODO(CHECK_SIZE_AFTER_UNPROTECT);570 563 571 564 if (err == err_status_ok) { 572 565 srtp->rtcp_cb(srtp->user_data, srtp->rx_buffer, len); 573 566 } else { 574 PJ_ TODO(LOG_ERROR_UNPROTECT);567 PJ_LOG(5, (THIS_FILE, "Failed to unprotect SRTCP")); 575 568 } 576 569 577 pj_ mutex_unlock(srtp->mutex);570 pj_lock_release(srtp->mutex); 578 571 } 579 572 … … 780 773 pj_stricmp(&media_remote->desc.transport, &ID_RTP_SAVP)) 781 774 { 782 return PJMEDIA_S DP_EINPROTO;775 return PJMEDIA_SRTP_ESDPREQSECTP; 783 776 } 784 777 … … 800 793 for (i=0; i<media_remote->attr_count; ++i) { 801 794 if (!pj_stricmp2(&media_local->attr[i]->name, "crypto")) { 802 if (attr) 803 return PJMEDIA_ERROR; 795 if (attr) { 796 PJ_LOG(5,(THIS_FILE, "More than one crypto attr in " \ 797 "the SDP answer.")); 798 return PJMEDIA_SRTP_ESDPAMBIGUEANS; 799 } 804 800 805 801 attr = media_local->attr[i]; … … 990 986 991 987 status = pjmedia_transport_srtp_deinit_session(tp); 992 if (status != PJ_SUCCESS) { 993 PJ_TODO(LOG_ERROR_DEINIT_SRTP); 994 } 988 if (status != PJ_SUCCESS) 989 PJ_LOG(4, (THIS_FILE, "Failed deinit session.")); 995 990 996 991 return pjmedia_transport_media_stop(srtp->real_tp); -
pjproject/branches/users/nanang/pjsip/src/pjsua-lib/pjsua_media.c
r1698 r1700 538 538 if (pjsua_var.media_cfg.enable_srtp) { 539 539 pjmedia_transport *tp; 540 unsigned srtp_options = 541 PJMEDIA_SRTP_AUTO_CLOSE_UNDERLYING_TRANSPORT; 540 unsigned srtp_options = 0; 542 541 543 542 status = pjmedia_transport_udp_attach(pjsua_var.med_endpt, NULL, … … 928 927 for (i=0; i < sess_info.stream_cnt; ++i) { 929 928 if (sess_info.stream_info[i].type == PJMEDIA_TYPE_AUDIO && 930 sess_info.stream_info[i].proto == PJMEDIA_TP_PROTO_RTP_AVP) 929 (sess_info.stream_info[i].proto == PJMEDIA_TP_PROTO_RTP_AVP || 930 sess_info.stream_info[i].proto == PJMEDIA_TP_PROTO_RTP_SAVP)) 931 931 { 932 932 si = &sess_info.stream_info[i]; -
pjproject/branches/users/nanang/third_party/srtp/crypto/rng/rand_source.c
r1697 r1700 109 109 if (read(dev_random_fdes, dest, len) != len) 110 110 return err_status_fail; 111 #elif (_MSC_VER >= 1400)111 #elif 0 && (_MSC_VER >= 1400) 112 112 unsigned int *dst = dest; 113 113 while (len)
Note: See TracChangeset
for help on using the changeset viewer.