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