diff options
Diffstat (limited to 'toxav')
-rw-r--r-- | toxav/msi.c | 3 | ||||
-rw-r--r-- | toxav/rtp.c | 22 | ||||
-rw-r--r-- | toxav/rtp.h | 15 |
3 files changed, 13 insertions, 27 deletions
diff --git a/toxav/msi.c b/toxav/msi.c index ec2f4bf2..b262e9a0 100644 --- a/toxav/msi.c +++ b/toxav/msi.c | |||
@@ -24,11 +24,10 @@ | |||
24 | #include "config.h" | 24 | #include "config.h" |
25 | #endif /* HAVE_CONFIG_H */ | 25 | #endif /* HAVE_CONFIG_H */ |
26 | 26 | ||
27 | #include "msi.h" | ||
27 | #include "../toxcore/logger.h" | 28 | #include "../toxcore/logger.h" |
28 | #include "../toxcore/util.h" | 29 | #include "../toxcore/util.h" |
29 | 30 | ||
30 | #include "msi.h" | ||
31 | |||
32 | #include <unistd.h> | 31 | #include <unistd.h> |
33 | #include <string.h> | 32 | #include <string.h> |
34 | #include <stdlib.h> | 33 | #include <stdlib.h> |
diff --git a/toxav/rtp.c b/toxav/rtp.c index 7a20877f..4df2e2d5 100644 --- a/toxav/rtp.c +++ b/toxav/rtp.c | |||
@@ -23,16 +23,16 @@ | |||
23 | #include "config.h" | 23 | #include "config.h" |
24 | #endif /* HAVE_CONFIG_H */ | 24 | #endif /* HAVE_CONFIG_H */ |
25 | 25 | ||
26 | #include "rtp.h" | ||
26 | #include "../toxcore/logger.h" | 27 | #include "../toxcore/logger.h" |
27 | #include "../toxcore/util.h" | 28 | #include "../toxcore/util.h" |
28 | #include "../toxcore/Messenger.h" | 29 | #include "../toxcore/Messenger.h" |
29 | 30 | ||
30 | #include "rtp.h" | ||
31 | #include <stdlib.h> | 31 | #include <stdlib.h> |
32 | #include <assert.h> | 32 | #include <assert.h> |
33 | 33 | ||
34 | #define size_32 4 | ||
35 | #define RTCP_REPORT_INTERVAL_MS 500 | 34 | #define RTCP_REPORT_INTERVAL_MS 500 |
35 | #define RTP_MAX_SIZE 1500 | ||
36 | 36 | ||
37 | #define ADD_FLAG_VERSION(_h, _v) do { ( _h->flags ) &= 0x3F; ( _h->flags ) |= ( ( ( _v ) << 6 ) & 0xC0 ); } while(0) | 37 | #define ADD_FLAG_VERSION(_h, _v) do { ( _h->flags ) &= 0x3F; ( _h->flags ) |= ( ( ( _v ) << 6 ) & 0xC0 ); } while(0) |
38 | #define ADD_FLAG_PADDING(_h, _v) do { if ( _v > 0 ) _v = 1; ( _h->flags ) &= 0xDF; ( _h->flags ) |= ( ( ( _v ) << 5 ) & 0x20 ); } while(0) | 38 | #define ADD_FLAG_PADDING(_h, _v) do { if ( _v > 0 ) _v = 1; ( _h->flags ) &= 0xDF; ( _h->flags ) |= ( ( ( _v ) << 5 ) & 0x20 ); } while(0) |
@@ -243,7 +243,7 @@ int rtp_send_data ( RTPSession *session, const uint8_t *data, uint16_t length, b | |||
243 | return -1; | 243 | return -1; |
244 | } | 244 | } |
245 | 245 | ||
246 | uint8_t parsed[MAX_RTP_SIZE]; | 246 | uint8_t parsed[RTP_MAX_SIZE]; |
247 | uint8_t *it; | 247 | uint8_t *it; |
248 | 248 | ||
249 | RTPHeader header[1]; | 249 | RTPHeader header[1]; |
@@ -268,16 +268,16 @@ int rtp_send_data ( RTPSession *session, const uint8_t *data, uint16_t length, b | |||
268 | for ( i = 0; i < session->cc; i++ ) | 268 | for ( i = 0; i < session->cc; i++ ) |
269 | header->csrc[i] = session->csrc[i]; | 269 | header->csrc[i] = session->csrc[i]; |
270 | 270 | ||
271 | header->length = 12 /* Minimum header len */ + ( session->cc * size_32 ); | 271 | header->length = 12 /* Minimum header len */ + ( session->cc * 4 ); |
272 | 272 | ||
273 | uint32_t parsed_len = length + header->length + 1; | 273 | uint32_t parsed_len = length + header->length + 1; |
274 | assert(parsed_len + (session->ext_header ? session->ext_header->length * size_32 : 0) < MAX_RTP_SIZE ); | 274 | assert(parsed_len + (session->ext_header ? session->ext_header->length * 4 : 0) < RTP_MAX_SIZE ); |
275 | 275 | ||
276 | parsed[0] = session->prefix; | 276 | parsed[0] = session->prefix; |
277 | it = parse_header_out ( header, parsed + 1 ); | 277 | it = parse_header_out ( header, parsed + 1 ); |
278 | 278 | ||
279 | if ( session->ext_header ) { | 279 | if ( session->ext_header ) { |
280 | parsed_len += ( 4 /* Minimum ext header len */ + session->ext_header->length * size_32 ); | 280 | parsed_len += ( 4 /* Minimum ext header len */ + session->ext_header->length * 4 ); |
281 | it = parse_ext_header_out ( session->ext_header, it ); | 281 | it = parse_ext_header_out ( session->ext_header, it ); |
282 | } | 282 | } |
283 | 283 | ||
@@ -472,7 +472,7 @@ int handle_rtp_packet ( Messenger* m, uint32_t friendnumber, const uint8_t* data | |||
472 | 472 | ||
473 | RTPSession *session = object; | 473 | RTPSession *session = object; |
474 | 474 | ||
475 | if ( !session || length < 13 || length > MAX_RTP_SIZE ) { | 475 | if ( !session || length < 13 || length > RTP_MAX_SIZE ) { |
476 | LOGGER_WARNING("No session or invalid length of received buffer!"); | 476 | LOGGER_WARNING("No session or invalid length of received buffer!"); |
477 | return -1; | 477 | return -1; |
478 | } | 478 | } |
@@ -493,8 +493,8 @@ int handle_rtp_packet ( Messenger* m, uint32_t friendnumber, const uint8_t* data | |||
493 | ext_header = parse_ext_header_in ( data + from_pos, length ); | 493 | ext_header = parse_ext_header_in ( data + from_pos, length ); |
494 | 494 | ||
495 | if ( ext_header ) { | 495 | if ( ext_header ) { |
496 | msg_length -= ( 4 /* Minimum ext header len */ + ext_header->length * size_32 ); | 496 | msg_length -= ( 4 /* Minimum ext header len */ + ext_header->length * 4 ); |
497 | from_pos += ( 4 /* Minimum ext header len */ + ext_header->length * size_32 ); | 497 | from_pos += ( 4 /* Minimum ext header len */ + ext_header->length * 4 ); |
498 | } else { /* Error */ | 498 | } else { /* Error */ |
499 | LOGGER_WARNING("Could not parse message: Ext Header failed to extract!"); | 499 | LOGGER_WARNING("Could not parse message: Ext Header failed to extract!"); |
500 | free(header); | 500 | free(header); |
@@ -502,7 +502,7 @@ int handle_rtp_packet ( Messenger* m, uint32_t friendnumber, const uint8_t* data | |||
502 | } | 502 | } |
503 | } | 503 | } |
504 | 504 | ||
505 | if (msg_length > MAX_RTP_SIZE) { | 505 | if (msg_length > RTP_MAX_SIZE) { |
506 | LOGGER_WARNING("Could not parse message: Invalid length!"); | 506 | LOGGER_WARNING("Could not parse message: Invalid length!"); |
507 | free(header); | 507 | free(header); |
508 | free(ext_header); | 508 | free(ext_header); |
@@ -611,4 +611,4 @@ void send_rtcp_report(RTCPSession* session, Messenger* m, uint32_t friendnumber) | |||
611 | session->last_expected_packets = 0; | 611 | session->last_expected_packets = 0; |
612 | session->last_sent_report_ts = current_time_monotonic(); | 612 | session->last_sent_report_ts = current_time_monotonic(); |
613 | } | 613 | } |
614 | } \ No newline at end of file | 614 | } |
diff --git a/toxav/rtp.h b/toxav/rtp.h index b18d6f8d..9c5cf07d 100644 --- a/toxav/rtp.h +++ b/toxav/rtp.h | |||
@@ -25,20 +25,7 @@ | |||
25 | #define RTP_VERSION 2 | 25 | #define RTP_VERSION 2 |
26 | 26 | ||
27 | #include "../toxcore/Messenger.h" | 27 | #include "../toxcore/Messenger.h" |
28 | 28 | #include "stdbool.h" | |
29 | #define LOGGED_LOCK(mutex) do { \ | ||
30 | /*LOGGER_DEBUG("Locking mutex: %p", mutex);*/\ | ||
31 | pthread_mutex_lock(mutex);\ | ||
32 | /*LOGGER_DEBUG("Locked mutex: %p", mutex);*/\ | ||
33 | } while(0) | ||
34 | |||
35 | #define LOGGED_UNLOCK(mutex) do { \ | ||
36 | /*LOGGER_DEBUG("Unlocking mutex: %p", mutex);*/\ | ||
37 | pthread_mutex_unlock(mutex);\ | ||
38 | /*LOGGER_DEBUG("Unlocked mutex: %p", mutex);*/\ | ||
39 | } while(0) | ||
40 | |||
41 | #define MAX_RTP_SIZE 1500 | ||
42 | 29 | ||
43 | /** | 30 | /** |
44 | * Payload type identifier. Also used as rtp callback prefix. (Not dummies) | 31 | * Payload type identifier. Also used as rtp callback prefix. (Not dummies) |