usbmodeswitch: Updated to v.1.2.6 from shibby's branch.
[tomato.git] / release / src / router / udpxy / rtp.h
blob1209cf4f36df2b6f7fb104f86e523d9c1ef6b3ea
1 /* @(#) interface to RTP-protocol parsing functions for udpxy
3 * Copyright 2008-2011 Pavel V. Cherenkov (pcherenkov@gmail.com)
5 * This file is part of udpxy.
7 * udpxy is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
12 * udpxy is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with udpxy. If not, see <http://www.gnu.org/licenses/>.
21 #ifndef RTPH_UDPXY_021308
22 #define RTPH_UDPXY_021308
24 #include <sys/types.h>
26 static const int MPEG_TS_SIG = 0x47;
27 static const size_t RTP_MIN_SIZE = 4;
28 static const size_t RTP_HDR_SIZE = 12; /* RFC 3550 */
29 static const int RTP_VER2 = 0x02;
31 /* offset to header extension and extension length,
32 * as per RFC 3550 5.3.1 */
33 static const size_t XTLEN_OFFSET = 14;
34 static const size_t XTSIZE = 4;
36 /* minimum length to determine size of an extended RTP header
38 #define RTP_XTHDRLEN (XTLEN_OFFSET + XTSIZE)
40 static const size_t CSRC_SIZE = 4;
42 /* MPEG payload-type constants - adopted from VLC 0.8.6 */
43 #define P_MPGA 0x0E /* MPEG audio */
44 #define P_MPGV 0x20 /* MPEG video */
45 #define P_MPGTS 0x21 /* MPEG TS */
47 #ifdef __cplusplus
48 extern "C" {
49 #endif
52 /* check if the buffer is an RTP packet
54 * @param buf buffer to analyze
55 * @param len size of the buffer
56 * @param is_rtp variable to set to 1 if data is an RTP packet
57 * @param log log file
59 * @return 0 if there was no error, -1 otherwise
61 int RTP_check( const char* buf, const size_t len, int* is_rtp, FILE* log );
64 /* process RTP package to retrieve the payload: set
65 * pbuf to the start of the payload area; set len to
66 * be equal payload's length
68 * @param pbuf address of pointer to beginning of RTP packet
69 * @param len pointer to RTP packet's length
70 * @param verify verify that it is an RTP packet if != 0
71 * @param log log file
73 * @return 0 if there was no error, -1 otherwise;
74 * set pbuf to point to beginning of payload and len
75 * be payload size in bytes
77 int RTP_process( void** pbuf, size_t* len, int verify, FILE* log );
80 /* verify if buffer contains an RTP packet, 0 otherwise
82 * @param buf buffer to analyze
83 * @param len size of the buffer
84 * @param log error log
86 * @return 1 if buffer contains an RTP packet, 0 otherwise
88 int RTP_verify( const char* buf, const size_t len, FILE* log );
91 /* calculate length of an RTP header
93 * @param buf buffer to analyze
94 * @param len size of the buffer
95 * @param hdrlen pointer to header length variable
96 * @param log error log
98 * @return 0 if header length has been calculated,
99 * ENOMEM if buffer is not big enough
101 int RTP_hdrlen( const char* buf, const size_t len, size_t* hdrlen,
102 FILE* log );
104 #ifdef __cplusplus
106 #endif
108 #endif /* RTPH_UDPXY_021308 */
111 /* __EOF__ */