diff options
Diffstat (limited to 'toxav')
-rw-r--r-- | toxav/codec.c | 4 | ||||
-rw-r--r-- | toxav/codec.h | 4 | ||||
-rw-r--r-- | toxav/msi.c | 70 | ||||
-rw-r--r-- | toxav/rtp.c | 2 | ||||
-rw-r--r-- | toxav/toxav.c | 2 |
5 files changed, 49 insertions, 33 deletions
diff --git a/toxav/codec.c b/toxav/codec.c index f1cd437a..10dc4f53 100644 --- a/toxav/codec.c +++ b/toxav/codec.c | |||
@@ -83,7 +83,7 @@ void queue(JitterBuffer *q, RTPMessage *pk) | |||
83 | 83 | ||
84 | unsigned int num = sequnum % q->size; | 84 | unsigned int num = sequnum % q->size; |
85 | 85 | ||
86 | if (sequnum - q->bottom > q->size) { | 86 | if ((uint32_t)(sequnum - q->bottom) > q->size) { |
87 | clear_queue(q); | 87 | clear_queue(q); |
88 | q->bottom = sequnum; | 88 | q->bottom = sequnum; |
89 | q->queue[num] = pk; | 89 | q->queue[num] = pk; |
@@ -118,7 +118,7 @@ RTPMessage *dequeue(JitterBuffer *q, int *success) | |||
118 | return ret; | 118 | return ret; |
119 | } | 119 | } |
120 | 120 | ||
121 | if (q->top - q->bottom > q->capacity) { | 121 | if ((uint32_t)(q->top - q->bottom) > q->capacity) { |
122 | ++q->bottom; | 122 | ++q->bottom; |
123 | *success = 2; | 123 | *success = 2; |
124 | return NULL; | 124 | return NULL; |
diff --git a/toxav/codec.h b/toxav/codec.h index dceeea7a..db4fbea0 100644 --- a/toxav/codec.h +++ b/toxav/codec.h | |||
@@ -80,8 +80,8 @@ typedef struct _CodecState { | |||
80 | 80 | ||
81 | typedef struct _JitterBuffer { | 81 | typedef struct _JitterBuffer { |
82 | RTPMessage **queue; | 82 | RTPMessage **queue; |
83 | unsigned int size; | 83 | uint32_t size; |
84 | unsigned int capacity; | 84 | uint32_t capacity; |
85 | uint16_t bottom; | 85 | uint16_t bottom; |
86 | uint16_t top; | 86 | uint16_t top; |
87 | } JitterBuffer; | 87 | } JitterBuffer; |
diff --git a/toxav/msi.c b/toxav/msi.c index 02864e56..36a76880 100644 --- a/toxav/msi.c +++ b/toxav/msi.c | |||
@@ -139,7 +139,7 @@ static int parse_raw_data ( MSIMessage *msg, const uint8_t *data, uint16_t lengt | |||
139 | 139 | ||
140 | #define FAIL_CONSTRAINT(constraint, wanted) if ((constraint -= wanted) < 1) { LOGGER_ERROR("Read over length!"); return -1; } | 140 | #define FAIL_CONSTRAINT(constraint, wanted) if ((constraint -= wanted) < 1) { LOGGER_ERROR("Read over length!"); return -1; } |
141 | #define FAIL_SIZE(byte, valid) if ( byte != valid ) { LOGGER_ERROR("Invalid data size!"); return -1; } | 141 | #define FAIL_SIZE(byte, valid) if ( byte != valid ) { LOGGER_ERROR("Invalid data size!"); return -1; } |
142 | #define FAIL_LIMITS(byte, low, high) if ( byte < low || byte > high ) { LOGGER_ERROR("Invalid data!"); return -1; } | 142 | #define FAIL_LIMITS(byte, high) if ( byte > high ) { LOGGER_ERROR("Failed limit!"); return -1; } |
143 | 143 | ||
144 | if ( msg == NULL ) { | 144 | if ( msg == NULL ) { |
145 | LOGGER_ERROR("Could not parse message: no storage!"); | 145 | LOGGER_ERROR("Could not parse message: no storage!"); |
@@ -159,7 +159,8 @@ static int parse_raw_data ( MSIMessage *msg, const uint8_t *data, uint16_t lengt | |||
159 | case IDRequest: | 159 | case IDRequest: |
160 | FAIL_CONSTRAINT(size_constraint, 3); | 160 | FAIL_CONSTRAINT(size_constraint, 3); |
161 | FAIL_SIZE(it[1], 1); | 161 | FAIL_SIZE(it[1], 1); |
162 | FAIL_LIMITS(it[2], invite, end); | 162 | // FAIL_LIMITS(it[2], invite, end); |
163 | FAIL_LIMITS(it[2], end); | ||
163 | msg->request.value = it[2]; | 164 | msg->request.value = it[2]; |
164 | it += 3; | 165 | it += 3; |
165 | msg->request.exists = 1; | 166 | msg->request.exists = 1; |
@@ -168,7 +169,8 @@ static int parse_raw_data ( MSIMessage *msg, const uint8_t *data, uint16_t lengt | |||
168 | case IDResponse: | 169 | case IDResponse: |
169 | FAIL_CONSTRAINT(size_constraint, 3); | 170 | FAIL_CONSTRAINT(size_constraint, 3); |
170 | FAIL_SIZE(it[1], 1); | 171 | FAIL_SIZE(it[1], 1); |
171 | FAIL_LIMITS(it[2], ringing, error); | 172 | // FAIL_LIMITS(it[2], ringing, error); |
173 | FAIL_LIMITS(it[2], error); | ||
172 | msg->response.value = it[2]; | 174 | msg->response.value = it[2]; |
173 | it += 3; | 175 | it += 3; |
174 | msg->response.exists = 1; | 176 | msg->response.exists = 1; |
@@ -454,7 +456,7 @@ typedef struct _Timer { | |||
454 | void *func_arg1; | 456 | void *func_arg1; |
455 | int func_arg2; | 457 | int func_arg2; |
456 | uint64_t timeout; | 458 | uint64_t timeout; |
457 | size_t idx; | 459 | int idx; |
458 | 460 | ||
459 | } Timer; | 461 | } Timer; |
460 | 462 | ||
@@ -462,8 +464,8 @@ typedef struct _TimerHandler { | |||
462 | Timer **timers; | 464 | Timer **timers; |
463 | pthread_mutex_t mutex; | 465 | pthread_mutex_t mutex; |
464 | 466 | ||
465 | size_t max_capacity; | 467 | uint32_t max_capacity; |
466 | size_t size; | 468 | uint32_t size; |
467 | uint64_t resolution; | 469 | uint64_t resolution; |
468 | 470 | ||
469 | _Bool running; | 471 | _Bool running; |
@@ -484,12 +486,12 @@ struct timer_function_args { | |||
484 | * @param timeout Timeout in ms | 486 | * @param timeout Timeout in ms |
485 | * @return int | 487 | * @return int |
486 | */ | 488 | */ |
487 | static int timer_alloc ( TimerHandler *timers_container, void *(func)(void *), void *arg1, int arg2, unsigned timeout) | 489 | static int timer_alloc ( TimerHandler *timers_container, void *(func)(void *), void *arg1, int arg2, uint32_t timeout) |
488 | { | 490 | { |
489 | static int timer_id; | 491 | static int timer_id; |
490 | pthread_mutex_lock(&timers_container->mutex); | 492 | pthread_mutex_lock(&timers_container->mutex); |
491 | 493 | ||
492 | int i = 0; | 494 | uint32_t i = 0; |
493 | 495 | ||
494 | for (; i < timers_container->max_capacity && timers_container->timers[i]; i ++); | 496 | for (; i < timers_container->max_capacity && timers_container->timers[i]; i ++); |
495 | 497 | ||
@@ -518,7 +520,7 @@ static int timer_alloc ( TimerHandler *timers_container, void *(func)(void *), v | |||
518 | 520 | ||
519 | /* reorder */ | 521 | /* reorder */ |
520 | if (i) { | 522 | if (i) { |
521 | int j = i - 1; | 523 | int64_t j = i - 1; |
522 | 524 | ||
523 | for (; j >= 0 && timeout < timers_container->timers[j]->timeout; j--) { | 525 | for (; j >= 0 && timeout < timers_container->timers[j]->timeout; j--) { |
524 | Timer *tmp = timers_container->timers[j]; | 526 | Timer *tmp = timers_container->timers[j]; |
@@ -529,7 +531,7 @@ static int timer_alloc ( TimerHandler *timers_container, void *(func)(void *), v | |||
529 | 531 | ||
530 | pthread_mutex_unlock(&timers_container->mutex); | 532 | pthread_mutex_unlock(&timers_container->mutex); |
531 | 533 | ||
532 | LOGGER_DEBUG("Allocated timer index: %d timeout: %d, current size: %d", i, timeout, timers_container->size); | 534 | LOGGER_DEBUG("Allocated timer index: %ull timeout: %ull, current size: %ull", i, timeout, timers_container->size); |
533 | return timer->idx; | 535 | return timer->idx; |
534 | } | 536 | } |
535 | 537 | ||
@@ -548,16 +550,17 @@ static int timer_release ( TimerHandler *timers_container, int idx , int lock_mu | |||
548 | 550 | ||
549 | Timer **timed_events = timers_container->timers; | 551 | Timer **timed_events = timers_container->timers; |
550 | 552 | ||
551 | int i, res = -1; | 553 | size_t i; |
554 | int rc = -1; | ||
552 | 555 | ||
553 | for (i = 0; i < timers_container->max_capacity; ++i) { | 556 | for (i = 0; i < timers_container->max_capacity; ++i) { |
554 | if (timed_events[i] && timed_events[i]->idx == idx) { | 557 | if (timed_events[i] && timed_events[i]->idx == idx) { |
555 | res = i; | 558 | rc = i; |
556 | break; | 559 | break; |
557 | } | 560 | } |
558 | } | 561 | } |
559 | 562 | ||
560 | if (res == -1) { | 563 | if (rc == -1) { |
561 | LOGGER_WARNING("No event with id: %d", idx); | 564 | LOGGER_WARNING("No event with id: %d", idx); |
562 | 565 | ||
563 | if (lock_mutex) pthread_mutex_unlock(&timers_container->mutex); | 566 | if (lock_mutex) pthread_mutex_unlock(&timers_container->mutex); |
@@ -565,11 +568,11 @@ static int timer_release ( TimerHandler *timers_container, int idx , int lock_mu | |||
565 | return -1; | 568 | return -1; |
566 | } | 569 | } |
567 | 570 | ||
568 | free(timed_events[res]); | 571 | free(timed_events[rc]); |
569 | 572 | ||
570 | timed_events[res] = NULL; | 573 | timed_events[rc] = NULL; |
571 | 574 | ||
572 | i = res + 1; | 575 | i = rc + 1; |
573 | 576 | ||
574 | for (; i < timers_container->max_capacity && timed_events[i]; i ++) { | 577 | for (; i < timers_container->max_capacity && timed_events[i]; i ++) { |
575 | timed_events[i - 1] = timed_events[i]; | 578 | timed_events[i - 1] = timed_events[i]; |
@@ -578,7 +581,7 @@ static int timer_release ( TimerHandler *timers_container, int idx , int lock_mu | |||
578 | 581 | ||
579 | timers_container->size--; | 582 | timers_container->size--; |
580 | 583 | ||
581 | LOGGER_DEBUG("Popped id: %d, current size: %d ", idx, timers_container->size); | 584 | LOGGER_DEBUG("Popped id: %d, current size: %ull ", idx, timers_container->size); |
582 | 585 | ||
583 | if (lock_mutex) pthread_mutex_unlock(&timers_container->mutex); | 586 | if (lock_mutex) pthread_mutex_unlock(&timers_container->mutex); |
584 | 587 | ||
@@ -688,7 +691,7 @@ static void timer_terminate_session(TimerHandler *handler) | |||
688 | 691 | ||
689 | pthread_mutex_unlock(&handler->mutex); | 692 | pthread_mutex_unlock(&handler->mutex); |
690 | 693 | ||
691 | int i = 0; | 694 | size_t i = 0; |
692 | 695 | ||
693 | for (; i < handler->max_capacity; i ++) | 696 | for (; i < handler->max_capacity; i ++) |
694 | free(handler->timers[i]); | 697 | free(handler->timers[i]); |
@@ -855,20 +858,21 @@ static int terminate_call ( MSISession *session, MSICall *call ); | |||
855 | 858 | ||
856 | static void handle_remote_connection_change(Messenger *messenger, int friend_num, uint8_t status, void *session_p) | 859 | static void handle_remote_connection_change(Messenger *messenger, int friend_num, uint8_t status, void *session_p) |
857 | { | 860 | { |
861 | (void)messenger; | ||
858 | MSISession *session = session_p; | 862 | MSISession *session = session_p; |
859 | 863 | ||
860 | switch ( status ) { | 864 | switch ( status ) { |
861 | case 0: { /* Went offline */ | 865 | case 0: { /* Went offline */ |
862 | uint32_t j = 0; | 866 | int32_t j = 0; |
863 | 867 | ||
864 | for ( ; j < session->max_calls; j ++ ) { | 868 | for ( ; j < session->max_calls; j ++ ) { |
865 | 869 | ||
866 | if ( !session->calls[j] ) continue; | 870 | if ( !session->calls[j] ) continue; |
867 | 871 | ||
868 | int i = 0; | 872 | uint16_t i = 0; |
869 | 873 | ||
870 | for ( ; i < session->calls[j]->peer_count; i ++ ) | 874 | for ( ; i < session->calls[j]->peer_count; i ++ ) |
871 | if ( session->calls[j]->peers[i] == friend_num ) { | 875 | if ( session->calls[j]->peers[i] == (uint32_t)friend_num ) { |
872 | invoke_callback(session, j, MSI_OnPeerTimeout); | 876 | invoke_callback(session, j, MSI_OnPeerTimeout); |
873 | terminate_call(session, session->calls[j]); | 877 | terminate_call(session, session->calls[j]); |
874 | LOGGER_DEBUG("Remote: %d timed out!", friend_num); | 878 | LOGGER_DEBUG("Remote: %d timed out!", friend_num); |
@@ -887,7 +891,7 @@ static MSICall *find_call ( MSISession *session, uint8_t *call_id ) | |||
887 | { | 891 | { |
888 | if ( call_id == NULL ) return NULL; | 892 | if ( call_id == NULL ) return NULL; |
889 | 893 | ||
890 | uint32_t i = 0; | 894 | int32_t i = 0; |
891 | 895 | ||
892 | for (; i < session->max_calls; i ++ ) | 896 | for (; i < session->max_calls; i ++ ) |
893 | if ( session->calls[i] && memcmp(session->calls[i]->id, call_id, sizeof(session->calls[i]->id)) == 0 ) { | 897 | if ( session->calls[i] && memcmp(session->calls[i]->id, call_id, sizeof(session->calls[i]->id)) == 0 ) { |
@@ -1105,7 +1109,7 @@ static int handle_recv_invite ( MSISession *session, MSICall *call, MSIMessage * | |||
1105 | } | 1109 | } |
1106 | 1110 | ||
1107 | if ( call ) { | 1111 | if ( call ) { |
1108 | if ( call->peers[0] == msg->friend_id ) { | 1112 | if ( call->peers[0] == (uint32_t)msg->friend_id ) { |
1109 | if (call->state == call_inviting) { | 1113 | if (call->state == call_inviting) { |
1110 | /* The glare case. A calls B when at the same time | 1114 | /* The glare case. A calls B when at the same time |
1111 | * B calls A. Who has advantage is set bey calculating | 1115 | * B calls A. Who has advantage is set bey calculating |
@@ -1193,6 +1197,8 @@ static int handle_recv_start ( MSISession *session, MSICall *call, MSIMessage *m | |||
1193 | return 0; | 1197 | return 0; |
1194 | } | 1198 | } |
1195 | 1199 | ||
1200 | (void)msg; | ||
1201 | |||
1196 | LOGGER_DEBUG("Session: %p Handling 'start' on call: %d, friend id: %d", session, call->call_idx, msg->friend_id ); | 1202 | LOGGER_DEBUG("Session: %p Handling 'start' on call: %d, friend id: %d", session, call->call_idx, msg->friend_id ); |
1197 | 1203 | ||
1198 | pthread_mutex_lock(&session->mutex); | 1204 | pthread_mutex_lock(&session->mutex); |
@@ -1232,7 +1238,9 @@ static int handle_recv_cancel ( MSISession *session, MSICall *call, MSIMessage * | |||
1232 | LOGGER_WARNING("Session: %p Handling 'start' on no call"); | 1238 | LOGGER_WARNING("Session: %p Handling 'start' on no call"); |
1233 | return 0; | 1239 | return 0; |
1234 | } | 1240 | } |
1235 | 1241 | ||
1242 | (void)msg; | ||
1243 | |||
1236 | LOGGER_DEBUG("Session: %p Handling 'cancel' on call: %u", session, call->call_idx); | 1244 | LOGGER_DEBUG("Session: %p Handling 'cancel' on call: %u", session, call->call_idx); |
1237 | 1245 | ||
1238 | invoke_callback(session, call->call_idx, MSI_OnCancel); | 1246 | invoke_callback(session, call->call_idx, MSI_OnCancel); |
@@ -1274,7 +1282,9 @@ static int handle_recv_ringing ( MSISession *session, MSICall *call, MSIMessage | |||
1274 | LOGGER_WARNING("Session: %p Handling 'start' on no call"); | 1282 | LOGGER_WARNING("Session: %p Handling 'start' on no call"); |
1275 | return 0; | 1283 | return 0; |
1276 | } | 1284 | } |
1277 | 1285 | ||
1286 | (void)msg; | ||
1287 | |||
1278 | pthread_mutex_lock(&session->mutex); | 1288 | pthread_mutex_lock(&session->mutex); |
1279 | 1289 | ||
1280 | if ( call->ringing_timer_id ) { | 1290 | if ( call->ringing_timer_id ) { |
@@ -1342,7 +1352,9 @@ static int handle_recv_ending ( MSISession *session, MSICall *call, MSIMessage * | |||
1342 | LOGGER_WARNING("Session: %p Handling 'start' on no call"); | 1352 | LOGGER_WARNING("Session: %p Handling 'start' on no call"); |
1343 | return 0; | 1353 | return 0; |
1344 | } | 1354 | } |
1345 | 1355 | ||
1356 | (void)msg; | ||
1357 | |||
1346 | LOGGER_DEBUG("Session: %p Handling 'ending' on call: %d", session, call->call_idx ); | 1358 | LOGGER_DEBUG("Session: %p Handling 'ending' on call: %d", session, call->call_idx ); |
1347 | 1359 | ||
1348 | invoke_callback(session, call->call_idx, MSI_OnEnding); | 1360 | invoke_callback(session, call->call_idx, MSI_OnEnding); |
@@ -1591,7 +1603,7 @@ int msi_terminate_session ( MSISession *session ) | |||
1591 | int _status = 0; | 1603 | int _status = 0; |
1592 | 1604 | ||
1593 | /* If have calls, cancel them */ | 1605 | /* If have calls, cancel them */ |
1594 | uint32_t idx = 0; | 1606 | int32_t idx = 0; |
1595 | 1607 | ||
1596 | for (; idx < session->max_calls; idx ++) if ( session->calls[idx] ) { | 1608 | for (; idx < session->max_calls; idx ++) if ( session->calls[idx] ) { |
1597 | /* Cancel all? */ | 1609 | /* Cancel all? */ |
@@ -1783,6 +1795,8 @@ int msi_cancel ( MSISession *session, int32_t call_index, uint32_t peer, const c | |||
1783 | memcpy(reason_cast, reason, strlen(reason)); | 1795 | memcpy(reason_cast, reason, strlen(reason)); |
1784 | msi_msg_set_reason(msg_cancel, reason_cast); | 1796 | msi_msg_set_reason(msg_cancel, reason_cast); |
1785 | } | 1797 | } |
1798 | #else | ||
1799 | (void)reason; | ||
1786 | 1800 | ||
1787 | #endif | 1801 | #endif |
1788 | 1802 | ||
@@ -1825,6 +1839,8 @@ int msi_reject ( MSISession *session, int32_t call_index, const char *reason ) | |||
1825 | memcpy(reason_cast, reason, strlen(reason)); | 1839 | memcpy(reason_cast, reason, strlen(reason)); |
1826 | msi_msg_set_reason(msg_reject, reason_cast); | 1840 | msi_msg_set_reason(msg_reject, reason_cast); |
1827 | } | 1841 | } |
1842 | #else | ||
1843 | (void)reason; | ||
1828 | 1844 | ||
1829 | #endif | 1845 | #endif |
1830 | 1846 | ||
diff --git a/toxav/rtp.c b/toxav/rtp.c index 595c58cc..de6c9c41 100644 --- a/toxav/rtp.c +++ b/toxav/rtp.c | |||
@@ -112,7 +112,7 @@ RTPHeader *extract_header ( const uint8_t *payload, int length ) | |||
112 | * I don't need to parse the other stuff if it's bad | 112 | * I don't need to parse the other stuff if it's bad |
113 | */ | 113 | */ |
114 | uint8_t _cc = GET_FLAG_CSRCC ( _retu ); | 114 | uint8_t _cc = GET_FLAG_CSRCC ( _retu ); |
115 | uint32_t _length = 12 /* Minimum header len */ + ( _cc * 4 ); | 115 | int _length = 12 /* Minimum header len */ + ( _cc * 4 ); |
116 | 116 | ||
117 | if ( length < _length ) { | 117 | if ( length < _length ) { |
118 | /* Deallocate */ | 118 | /* Deallocate */ |
diff --git a/toxav/toxav.c b/toxav/toxav.c index 870dd111..0c3a1c8f 100644 --- a/toxav/toxav.c +++ b/toxav/toxav.c | |||
@@ -200,7 +200,7 @@ ToxAv *toxav_new( Tox *messenger, int32_t max_calls) | |||
200 | */ | 200 | */ |
201 | void toxav_kill ( ToxAv *av ) | 201 | void toxav_kill ( ToxAv *av ) |
202 | { | 202 | { |
203 | int i; | 203 | uint32_t i; |
204 | DECODE_PACKET *p; | 204 | DECODE_PACKET *p; |
205 | 205 | ||
206 | av->exit = 1; | 206 | av->exit = 1; |