* switch_rtp.c -- RTP
*
*/
-#define USEC_RATE (5e5)
-#define MAX_WORD_LEN 128
-#define ADDR_IS_MULTICAST(a) IN_MULTICAST(htonl(a))
-#define MAX_KEY_LEN 64
-#define MASTER_KEY_LEN 30
#include <switch.h>
#undef PACKAGE_NAME
#include <datatypes.h>
#include <srtp.h>
+#define MAX_KEY_LEN 64
#define rtp_header_len 12
+#define RTP_MAX_BUF_LEN 16384
typedef srtp_hdr_t rtp_hdr_t;
-#define RTP_MAX_BUF_LEN 16384
-
typedef struct {
srtp_hdr_t header;
char body[RTP_MAX_BUF_LEN];
srtp_init();
global_init = 1;
-
}
SWITCH_DECLARE(switch_rtp *)switch_rtp_new(char *rx_ip,
policy.rtcp.sec_serv = sec_serv_none;
policy.next = NULL;
-
rtp_session->send_msg.header.ssrc = htonl(ssrc);
rtp_session->send_msg.header.ts = 0;
rtp_session->send_msg.header.seq = (uint16_t) rand();
rtp_session->send_msg.header.x = 0;
rtp_session->send_msg.header.cc = 0;
-
rtp_session->recv_msg.header.ssrc = htonl(ssrc);
rtp_session->recv_msg.header.ts = 0;
rtp_session->recv_msg.header.seq = 0;
{
apr_socket_shutdown(rtp_session->sock, APR_SHUTDOWN_READWRITE);
switch_clear_flag(rtp_session, SWITCH_RTP_FLAG_IO);
-
}
SWITCH_DECLARE(void) switch_rtp_destroy(switch_rtp **rtp_session)
{
-
switch_rtp_killread(*rtp_session);
switch_socket_close((*rtp_session)->sock);
*rtp_session = NULL;
}
bytes = sizeof(rtp_msg_t);
-
switch_socket_recvfrom(rtp_session->from_addr, rtp_session->sock, 0, (void *)&rtp_session->recv_msg, &bytes);
if (bytes <= 0) {
memcpy(data, rtp_session->recv_msg.body, bytes);
*payload_type = rtp_session->recv_msg.header.pt;
return (int)(bytes - rtp_header_len);
-
}
SWITCH_DECLARE(int) switch_rtp_zerocopy_read(switch_rtp *rtp_session, void **data, int *payload_type)