SWITCH_RTP_FLAG_NOBLOCK - Do not block
SWITCH_RTP_FLAG_IO - IO is ready
SWITCH_RTP_FLAG_USE_TIMER - Timeout Reads and replace with a CNG Frame
+ SWITCH_RTP_FLAG_SECURE - Secure RTP
</pre>
*/
typedef enum {
SWITCH_RTP_FLAG_NOBLOCK = ( 1 << 0),
SWITCH_RTP_FLAG_IO = (1 << 1),
- SWITCH_RTP_FLAG_USE_TIMER = (1 << 2)
+ SWITCH_RTP_FLAG_USE_TIMER = (1 << 2),
+ SWITCH_RTP_FLAG_SECURE = (1 << 3)
} switch_rtp_flag_t;
/*!
if (crypto_key) {
int len;
+ switch_set_flag(rtp_session, SWITCH_RTP_FLAG_SECURE);
crypto_policy_set_rtp_default(&policy.rtp);
crypto_policy_set_rtcp_default(&policy.rtcp);
policy.ssrc.type = ssrc_specific;
for(;;) {
bytes = sizeof(rtp_msg_t);
status = switch_socket_recvfrom(rtp_session->from_addr, rtp_session->sock, 0, (void *)&rtp_session->recv_msg, &bytes);
+ if (switch_test_flag(rtp_session, SWITCH_RTP_FLAG_SECURE)) {
+ int sbytes = (int)bytes;
+ srtp_unprotect(rtp_session->recv_ctx, &rtp_session->send_msg, &sbytes);
+ bytes = sbytes;
+ }
if (switch_test_flag(rtp_session, SWITCH_RTP_FLAG_USE_TIMER)) {
if (!switch_test_flag(rtp_session, SWITCH_RTP_FLAG_IO)) {
}
bytes = datalen + rtp_header_len;
+ if (switch_test_flag(rtp_session, SWITCH_RTP_FLAG_SECURE)) {
+ int sbytes = (int)bytes;
+ srtp_protect(rtp_session->send_ctx, &rtp_session->send_msg, &sbytes);
+ bytes = sbytes;
+ }
+
switch_socket_sendto(rtp_session->sock, rtp_session->remote_addr, 0, (void*)&rtp_session->send_msg, &bytes);
if (rtp_session->ice_user) {