Hello, it looks like SRTP-transport (pjmedia/src/pjmedia/transport_srtp.c) copies the whole outgoing communication (video+audio) in RAM from location A to B without any easily apparent purpose; e.g. for video this is cir 32 Kbyte/sec traffic if ffmpeg-encoder bitrate is set to 256Kbit. Is it feasible to avoid this overhead? (In contrast, incoming communication is not copied, "srtp_unprotect()" operates directly on packet-buffer 'pkt'.) Eeri Kask -------------- next part -------------- --- pjmedia/src/pjmedia/transport_srtp.c.orig 2014-05-14 15:24:39.000000000 +0200 +++ pjmedia/src/pjmedia/transport_srtp.c 2014-05-14 15:57:50.000000000 +0200 @@ -94,8 +94,6 @@ pjmedia_transport base; /**< Base transport interface. */ pj_pool_t *pool; /**< Pool for transport SRTP. */ pj_lock_t *mutex; /**< Mutex for libsrtp contexts.*/ - char rtp_tx_buffer[MAX_RTP_BUFFER_LEN]; - char rtcp_tx_buffer[MAX_RTCP_BUFFER_LEN]; pjmedia_srtp_setting setting; unsigned media_option; @@ -824,22 +822,20 @@ if (srtp->bypass_srtp) return pjmedia_transport_send_rtp(srtp->member_tp, pkt, size); - if (size > sizeof(srtp->rtp_tx_buffer) - 10) + if (size > MAX_RTP_BUFFER_LEN - 10) return PJ_ETOOBIG; - pj_memcpy(srtp->rtp_tx_buffer, pkt, size); - pj_lock_acquire(srtp->mutex); if (!srtp->session_inited) { pj_lock_release(srtp->mutex); return PJ_EINVALIDOP; } - err = srtp_protect(srtp->srtp_tx_ctx, srtp->rtp_tx_buffer, &len); + err = srtp_protect(srtp->srtp_tx_ctx, pkt, &len); pj_lock_release(srtp->mutex); if (err == err_status_ok) { status = pjmedia_transport_send_rtp(srtp->member_tp, - srtp->rtp_tx_buffer, len); + pkt, len); } else { status = PJMEDIA_ERRNO_FROM_LIBSRTP(err); } @@ -870,22 +866,20 @@ pkt, size); } - if (size > sizeof(srtp->rtcp_tx_buffer) - 10) + if (size > MAX_RTCP_BUFFER_LEN - 10) return PJ_ETOOBIG; - pj_memcpy(srtp->rtcp_tx_buffer, pkt, size); - pj_lock_acquire(srtp->mutex); if (!srtp->session_inited) { pj_lock_release(srtp->mutex); return PJ_EINVALIDOP; } - err = srtp_protect_rtcp(srtp->srtp_tx_ctx, srtp->rtcp_tx_buffer, &len); + err = srtp_protect_rtcp(srtp->srtp_tx_ctx, pkt, &len); pj_lock_release(srtp->mutex); if (err == err_status_ok) { status = pjmedia_transport_send_rtcp2(srtp->member_tp, addr, addr_len, - srtp->rtcp_tx_buffer, len); + pkt, len); } else { status = PJMEDIA_ERRNO_FROM_LIBSRTP(err); }