1 /*
2  * Copyright (c) 2004-2006 Maxim Sobolev <sobomax@FreeBSD.org>
3  * Copyright (c) 2006-2015 Sippy Software, Inc., http://www.sippysoft.com
4  * All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
9  * 1. Redistributions of source code must retain the above copyright
10  *    notice, this list of conditions and the following disclaimer.
11  * 2. Redistributions in binary form must reproduce the above copyright
12  *    notice, this list of conditions and the following disclaimer in the
13  *    documentation and/or other materials provided with the distribution.
14  *
15  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25  * SUCH DAMAGE.
26  *
27  */
28 
29 #ifndef _RTP_PACKET_H_
30 #define _RTP_PACKET_H_
31 
32 struct rtp_info;
33 struct rtpp_wi;
34 
35 struct rtp_packet {
36     size_t      size;
37 
38     struct sockaddr_storage raddr;
39     struct sockaddr_storage _laddr;
40     struct sockaddr *laddr;
41     int         lport;
42 
43     socklen_t   rlen;
44     double      rtime;
45 
46     struct rtp_packet *next;
47     struct rtp_packet *prev;
48 
49     struct rtp_info *parsed;
50     rtp_parser_err_t parse_result;
51 
52     struct rtpp_wi *wi;
53 
54     /*
55      * The packet, keep it the last member so that we can use
56      * memcpy() only on portion that it's actually being
57      * utilized.
58      */
59     union {
60         rtp_hdr_t       header;
61         unsigned char   buf[8192];
62     } data;
63 };
64 
65 struct rtp_packet *rtp_packet_alloc();
66 void rtp_packet_free(struct rtp_packet *);
67 void rtp_packet_set_seq(struct rtp_packet *, uint16_t seq);
68 void rtp_packet_set_ts(struct rtp_packet *, uint32_t ts);
69 
70 #define RTPP_DUP_HDRONLY 0x1    /* Do not copy payload, only headers, requires packet to be parsed */
71 void rtp_packet_dup(struct rtp_packet *, struct rtp_packet *, int);
72 
73 #endif
74