Changeset 3999 for pjproject/trunk/pjmedia/src/pjmedia/transport_srtp.c
- Timestamp:
- Mar 30, 2012 7:10:13 AM (12 years ago)
- Location:
- pjproject/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk
-
pjproject/trunk/pjmedia/src/pjmedia/transport_srtp.c
r3553 r3999 271 271 272 272 static pj_bool_t libsrtp_initialized; 273 static void pjmedia_srtp_deinit_lib( void);274 275 PJ_DEF(pj_status_t) pjmedia_srtp_init_lib( void)273 static void pjmedia_srtp_deinit_lib(pjmedia_endpt *endpt); 274 275 PJ_DEF(pj_status_t) pjmedia_srtp_init_lib(pjmedia_endpt *endpt) 276 276 { 277 277 if (libsrtp_initialized == PJ_FALSE) { … … 285 285 } 286 286 287 if (pj_atexit(pjmedia_srtp_deinit_lib) != PJ_SUCCESS) { 287 if (pjmedia_endpt_atexit(endpt, pjmedia_srtp_deinit_lib) != PJ_SUCCESS) 288 { 288 289 /* There will be memory leak when it fails to schedule libsrtp 289 290 * deinitialization, however the memory leak could be harmless, … … 300 301 } 301 302 302 static void pjmedia_srtp_deinit_lib( void)303 static void pjmedia_srtp_deinit_lib(pjmedia_endpt *endpt) 303 304 { 304 305 err_status_t err; 306 307 /* Note that currently this SRTP init/deinit is not equipped with 308 * reference counter, it should be safe as normally there is only 309 * one single instance of media endpoint and even if it isn't, the 310 * pjmedia_transport_srtp_create() will invoke SRTP init (the only 311 * drawback should be the delay described by #788). 312 */ 313 314 PJ_UNUSED_ARG(endpt); 305 315 306 316 err = srtp_deinit(); … … 411 421 412 422 /* Init libsrtp. */ 413 status = pjmedia_srtp_init_lib( );423 status = pjmedia_srtp_init_lib(endpt); 414 424 if (status != PJ_SUCCESS) 415 425 return status; … … 908 918 { 909 919 /* Handle such condition that stream is updated (RTP seq is reinited 910 * & SRTP is restarted), but some old packets are still coming 911 * so SRTP is learning wrong RTP seq. While the newly inited RTP seq 912 * comes, SRTP thinks the RTP seq is replayed, so srtp_unprotect() 913 * will returning err_status_replay_*. Restarting SRTP can resolve 914 * this. 915 */ 916 if (pjmedia_transport_srtp_start((pjmedia_transport*)srtp, 917 &srtp->tx_policy, &srtp->rx_policy) 918 != PJ_SUCCESS) 919 { 920 * & SRTP is restarted), but some old packets are still coming 921 * so SRTP is learning wrong RTP seq. While the newly inited RTP seq 922 * comes, SRTP thinks the RTP seq is replayed, so srtp_unprotect() 923 * will return err_status_replay_*. Restarting SRTP can resolve this. 924 */ 925 pjmedia_srtp_crypto tx, rx; 926 pj_status_t status; 927 928 tx = srtp->tx_policy; 929 rx = srtp->rx_policy; 930 status = pjmedia_transport_srtp_start((pjmedia_transport*)srtp, 931 &tx, &rx); 932 if (status != PJ_SUCCESS) { 920 933 PJ_LOG(5,(srtp->pool->obj_name, "Failed to restart SRTP, err=%s", 921 934 get_libsrtp_errstr(err))); 922 } else {935 } else if (!srtp->bypass_srtp) { 923 936 err = srtp_unprotect(srtp->srtp_rx_ctx, (pj_uint8_t*)pkt, &len); 924 937 }
Note: See TracChangeset
for help on using the changeset viewer.