1 /* 2 * rtp.h 3 * 4 * rtp interface for srtp reference implementation 5 * 6 * David A. McGrew 7 * Cisco Systems, Inc. 8 * 9 * data types: 10 * 11 * rtp_msg_t an rtp message (the data that goes on the wire) 12 * rtp_sender_t sender side socket and rtp info 13 * rtp_receiver_t receiver side socket and rtp info 14 * 15 */ 16 17 /* 18 * 19 * Copyright (c) 2001-2006, Cisco Systems, Inc. 20 * All rights reserved. 21 * 22 * Redistribution and use in source and binary forms, with or without 23 * modification, are permitted provided that the following conditions 24 * are met: 25 * 26 * Redistributions of source code must retain the above copyright 27 * notice, this list of conditions and the following disclaimer. 28 * 29 * Redistributions in binary form must reproduce the above 30 * copyright notice, this list of conditions and the following 31 * disclaimer in the documentation and/or other materials provided 32 * with the distribution. 33 * 34 * Neither the name of the Cisco Systems, Inc. nor the names of its 35 * contributors may be used to endorse or promote products derived 36 * from this software without specific prior written permission. 37 * 38 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 39 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 40 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 41 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 42 * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 43 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 44 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 45 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 46 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 47 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 48 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 49 * OF THE POSSIBILITY OF SUCH DAMAGE. 50 * 51 */ 52 53 54 #ifndef RTP_H 55 #define RTP_H 56 57 #ifdef HAVE_NETINET_IN_H 58 # include <netinet/in.h> 59 #elif defined HAVE_WINSOCK2_H 60 # include <winsock2.h> 61 #endif 62 63 #include "srtp.h" 64 65 typedef struct rtp_sender_ctx_t *rtp_sender_t; 66 67 typedef struct rtp_receiver_ctx_t *rtp_receiver_t; 68 69 unsigned int 70 rtp_sendto(rtp_sender_t sender, const void* msg, int len); 71 72 unsigned int 73 rtp_recvfrom(rtp_receiver_t receiver, void *msg, int *len); 74 75 int 76 rtp_receiver_init(rtp_receiver_t rcvr, int socket, 77 struct sockaddr_in addr, unsigned int ssrc); 78 79 int 80 rtp_sender_init(rtp_sender_t sender, int socket, 81 struct sockaddr_in addr, unsigned int ssrc); 82 83 /* 84 * srtp_sender_init(...) initializes an rtp_sender_t 85 */ 86 87 int 88 srtp_sender_init(rtp_sender_t rtp_ctx, /* structure to be init'ed */ 89 struct sockaddr_in name, /* socket name */ 90 sec_serv_t security_services, /* sec. servs. to be used */ 91 unsigned char *input_key /* master key/salt in hex */ 92 ); 93 94 int 95 srtp_receiver_init(rtp_receiver_t rtp_ctx, /* structure to be init'ed */ 96 struct sockaddr_in name, /* socket name */ 97 sec_serv_t security_services, /* sec. servs. to be used */ 98 unsigned char *input_key /* master key/salt in hex */ 99 ); 100 101 102 int 103 rtp_sender_init_srtp(rtp_sender_t sender, const srtp_policy_t *policy); 104 105 int 106 rtp_receiver_init_srtp(rtp_receiver_t sender, const srtp_policy_t *policy); 107 108 109 rtp_sender_t 110 rtp_sender_alloc(); 111 112 rtp_receiver_t 113 rtp_receiver_alloc(); 114 115 116 /* 117 * RTP_HEADER_LEN indicates the size of an RTP header 118 */ 119 #define RTP_HEADER_LEN 12 120 121 /* 122 * RTP_MAX_BUF_LEN defines the largest RTP packet in the rtp.c implementation 123 */ 124 #define RTP_MAX_BUF_LEN 16384 125 126 127 #endif /* RTP_H */ 128