diff options
author | mannol <eniz_vukovic@hotmail.com> | 2014-05-31 17:27:22 +0200 |
---|---|---|
committer | mannol <eniz_vukovic@hotmail.com> | 2014-05-31 17:27:22 +0200 |
commit | d7c11573751eea005d3b1938ae3298c265d48fd6 (patch) | |
tree | 5e24378192854d147e42fd2c44e0a7bd53685bc4 /toxav/rtp.c | |
parent | 2ebefb85b7f5ae28db1e8c11196467efd3c914cf (diff) |
Fixed byte order and removed log functions from misc_tools
Diffstat (limited to 'toxav/rtp.c')
-rw-r--r-- | toxav/rtp.c | 87 |
1 files changed, 1 insertions, 86 deletions
diff --git a/toxav/rtp.c b/toxav/rtp.c index f44b2bfe..d4fdf656 100644 --- a/toxav/rtp.c +++ b/toxav/rtp.c | |||
@@ -26,6 +26,7 @@ | |||
26 | #endif /* HAVE_CONFIG_H */ | 26 | #endif /* HAVE_CONFIG_H */ |
27 | 27 | ||
28 | #include "../toxcore/logger.h" | 28 | #include "../toxcore/logger.h" |
29 | #include "../toxcore/util.h" | ||
29 | 30 | ||
30 | #include "rtp.h" | 31 | #include "rtp.h" |
31 | #include <assert.h> | 32 | #include <assert.h> |
@@ -37,9 +38,6 @@ | |||
37 | 38 | ||
38 | #define size_32 4 | 39 | #define size_32 4 |
39 | 40 | ||
40 | #define inline__ inline __attribute__((always_inline)) | ||
41 | |||
42 | |||
43 | #define ADD_FLAG_VERSION(_h, _v) do { ( _h->flags ) &= 0x3F; ( _h->flags ) |= ( ( ( _v ) << 6 ) & 0xC0 ); } while(0) | 41 | #define ADD_FLAG_VERSION(_h, _v) do { ( _h->flags ) &= 0x3F; ( _h->flags ) |= ( ( ( _v ) << 6 ) & 0xC0 ); } while(0) |
44 | #define ADD_FLAG_PADDING(_h, _v) do { if ( _v > 0 ) _v = 1; ( _h->flags ) &= 0xDF; ( _h->flags ) |= ( ( ( _v ) << 5 ) & 0x20 ); } while(0) | 42 | #define ADD_FLAG_PADDING(_h, _v) do { if ( _v > 0 ) _v = 1; ( _h->flags ) &= 0xDF; ( _h->flags ) |= ( ( ( _v ) << 5 ) & 0x20 ); } while(0) |
45 | #define ADD_FLAG_EXTENSION(_h, _v) do { if ( _v > 0 ) _v = 1; ( _h->flags ) &= 0xEF;( _h->flags ) |= ( ( ( _v ) << 4 ) & 0x10 ); } while(0) | 43 | #define ADD_FLAG_EXTENSION(_h, _v) do { if ( _v > 0 ) _v = 1; ( _h->flags ) &= 0xEF;( _h->flags ) |= ( ( ( _v ) << 4 ) & 0x10 ); } while(0) |
@@ -56,89 +54,6 @@ | |||
56 | 54 | ||
57 | 55 | ||
58 | /** | 56 | /** |
59 | * @brief Converts 4 bytes to uint32_t | ||
60 | * | ||
61 | * @param dest Where to convert | ||
62 | * @param bytes What bytes | ||
63 | * @return void | ||
64 | */ | ||
65 | inline__ void bytes_to_U32(uint32_t *dest, const uint8_t *bytes) | ||
66 | { | ||
67 | *dest = | ||
68 | #ifdef WORDS_BIGENDIAN | ||
69 | ( ( uint32_t ) * bytes ) | | ||
70 | ( ( uint32_t ) * ( bytes + 1 ) << 8 ) | | ||
71 | ( ( uint32_t ) * ( bytes + 2 ) << 16 ) | | ||
72 | ( ( uint32_t ) * ( bytes + 3 ) << 24 ) ; | ||
73 | #else | ||
74 | ( ( uint32_t ) * bytes << 24 ) | | ||
75 | ( ( uint32_t ) * ( bytes + 1 ) << 16 ) | | ||
76 | ( ( uint32_t ) * ( bytes + 2 ) << 8 ) | | ||
77 | ( ( uint32_t ) * ( bytes + 3 ) ) ; | ||
78 | #endif | ||
79 | } | ||
80 | |||
81 | /** | ||
82 | * @brief Converts 2 bytes to uint16_t | ||
83 | * | ||
84 | * @param dest Where to convert | ||
85 | * @param bytes What bytes | ||
86 | * @return void | ||
87 | */ | ||
88 | inline__ void bytes_to_U16(uint16_t *dest, const uint8_t *bytes) | ||
89 | { | ||
90 | *dest = | ||
91 | #ifdef WORDS_BIGENDIAN | ||
92 | ( ( uint16_t ) * bytes ) | | ||
93 | ( ( uint16_t ) * ( bytes + 1 ) << 8 ); | ||
94 | #else | ||
95 | ( ( uint16_t ) * bytes << 8 ) | | ||
96 | ( ( uint16_t ) * ( bytes + 1 ) ); | ||
97 | #endif | ||
98 | } | ||
99 | |||
100 | /** | ||
101 | * @brief Convert uint32_t to byte string of size 4 | ||
102 | * | ||
103 | * @param dest Where to convert | ||
104 | * @param value The value | ||
105 | * @return void | ||
106 | */ | ||
107 | inline__ void U32_to_bytes(uint8_t *dest, uint32_t value) | ||
108 | { | ||
109 | #ifdef WORDS_BIGENDIAN | ||
110 | *(dest) = ( value ); | ||
111 | *(dest + 1) = ( value >> 8 ); | ||
112 | *(dest + 2) = ( value >> 16 ); | ||
113 | *(dest + 3) = ( value >> 24 ); | ||
114 | #else | ||
115 | *(dest) = ( value >> 24 ); | ||
116 | *(dest + 1) = ( value >> 16 ); | ||
117 | *(dest + 2) = ( value >> 8 ); | ||
118 | *(dest + 3) = ( value ); | ||
119 | #endif | ||
120 | } | ||
121 | |||
122 | /** | ||
123 | * @brief Convert uint16_t to byte string of size 2 | ||
124 | * | ||
125 | * @param dest Where to convert | ||
126 | * @param value The value | ||
127 | * @return void | ||
128 | */ | ||
129 | inline__ void U16_to_bytes(uint8_t *dest, uint16_t value) | ||
130 | { | ||
131 | #ifdef WORDS_BIGENDIAN | ||
132 | *(dest) = ( value ); | ||
133 | *(dest + 1) = ( value >> 8 ); | ||
134 | #else | ||
135 | *(dest) = ( value >> 8 ); | ||
136 | *(dest + 1) = ( value ); | ||
137 | #endif | ||
138 | } | ||
139 | |||
140 | |||
141 | /** | ||
142 | * @brief Checks if message came in late. | 57 | * @brief Checks if message came in late. |
143 | * | 58 | * |
144 | * @param session Control session. | 59 | * @param session Control session. |