]> sjero.net Git - linphone/blob - linphone/mediastreamer2/src/rfc2429.h
remote ortp and add it as a submodule instead.
[linphone] / linphone / mediastreamer2 / src / rfc2429.h
1 /*
2   The mediastreamer library aims at providing modular media processing and I/O
3         for linphone, but also for any telephony application.
4   Copyright (C) 2001  Simon MORLAT simon.morlat@linphone.org
5                                                                                 
6   This library is free software; you can redistribute it and/or
7   modify it under the terms of the GNU Lesser General Public
8   License as published by the Free Software Foundation; either
9   version 2.1 of the License, or (at your option) any later version.
10
11   This library is distributed in the hope that it will be useful,
12   but WITHOUT ANY WARRANTY; without even the implied warranty of
13   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14   Lesser General Public License for more details.
15
16   You should have received a copy of the GNU Lesser General Public
17   License along with this library; if not, write to the Free Software
18   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19 */
20
21
22 #ifndef rfc2429_h
23 #define rfc2429_h
24
25 #define MAKE_MASK(bits)         ( (1<<(bits)) -1 )
26
27 static inline unsigned int rfc2429_get_P(const uint8_t *header){
28         return (header[0]>>2) & 0x1;
29 }
30
31 static inline void rfc2429_set_P(uint8_t *header, bool_t val){
32         header[0]=header[0] | ( (val&0x1)<<2);
33 }
34
35 static inline unsigned int rfc2429_get_V(const uint8_t *header){
36         return (header[0]>>1) & 0x1;
37 }
38
39 static inline unsigned int rfc2429_get_PLEN(const uint8_t *header){
40         unsigned short *p=(unsigned short*)header;
41         return (ntohs(p[0])>>3) & MAKE_MASK(6);
42 }
43
44 static inline unsigned int rfc2429_get_PEBIT(const uint8_t *header){
45         unsigned short *p=(unsigned short*)header;
46         return ntohs(p[0]) & MAKE_MASK(3);
47 }
48
49
50 #endif