diff options
author | mannol <eniz_vukovic@hotmail.com> | 2014-05-16 19:56:40 +0200 |
---|---|---|
committer | mannol <eniz_vukovic@hotmail.com> | 2014-05-16 19:56:40 +0200 |
commit | 843171fbc8e0cb12c14fac39bef15e596f44bef1 (patch) | |
tree | df0bde9d85f41762d45473b60f3ede9912203982 | |
parent | 9bb910a370725696cc3169c795f903c24e7d126f (diff) |
This works.
-rw-r--r-- | auto_tests/toxav_basic_test.c | 20 | ||||
-rw-r--r-- | auto_tests/toxav_many_test.c | 20 | ||||
-rw-r--r-- | toxav/media.c | 5 | ||||
-rwxr-xr-x | toxav/msi.c | 156 | ||||
-rwxr-xr-x | toxav/msi.h | 20 | ||||
-rwxr-xr-x | toxav/rtp.c | 36 | ||||
-rwxr-xr-x | toxav/toxav.c | 72 | ||||
-rwxr-xr-x | toxav/toxav.h | 44 | ||||
-rw-r--r-- | toxcore/Messenger.c | 10 | ||||
-rw-r--r-- | toxcore/logger.c | 12 | ||||
-rw-r--r-- | toxcore/logger.h | 2 | ||||
-rw-r--r-- | toxcore/network.c | 2 |
12 files changed, 185 insertions, 214 deletions
diff --git a/auto_tests/toxav_basic_test.c b/auto_tests/toxav_basic_test.c index c8ebd497..c0162582 100644 --- a/auto_tests/toxav_basic_test.c +++ b/auto_tests/toxav_basic_test.c | |||
@@ -58,7 +58,7 @@ void accept_friend_request(Tox *m, uint8_t *public_key, uint8_t *data, uint16_t | |||
58 | 58 | ||
59 | 59 | ||
60 | /******************************************************************************/ | 60 | /******************************************************************************/ |
61 | void callback_recv_invite ( uint32_t call_index, void *_arg ) | 61 | void callback_recv_invite ( int32_t call_index, void *_arg ) |
62 | { | 62 | { |
63 | Status *cast = _arg; | 63 | Status *cast = _arg; |
64 | 64 | ||
@@ -66,14 +66,14 @@ void callback_recv_invite ( uint32_t call_index, void *_arg ) | |||
66 | cast->Bob.status = Ringing; | 66 | cast->Bob.status = Ringing; |
67 | cast->Bob.call_index = call_index; | 67 | cast->Bob.call_index = call_index; |
68 | } | 68 | } |
69 | void callback_recv_ringing ( uint32_t call_index, void *_arg ) | 69 | void callback_recv_ringing ( int32_t call_index, void *_arg ) |
70 | { | 70 | { |
71 | Status *cast = _arg; | 71 | Status *cast = _arg; |
72 | 72 | ||
73 | /* Alice always sends invite */ | 73 | /* Alice always sends invite */ |
74 | cast->Alice.status = Ringing; | 74 | cast->Alice.status = Ringing; |
75 | } | 75 | } |
76 | void callback_recv_starting ( uint32_t call_index, void *_arg ) | 76 | void callback_recv_starting ( int32_t call_index, void *_arg ) |
77 | { | 77 | { |
78 | Status *cast = _arg; | 78 | Status *cast = _arg; |
79 | 79 | ||
@@ -82,7 +82,7 @@ void callback_recv_starting ( uint32_t call_index, void *_arg ) | |||
82 | cast->Alice.status = InCall; | 82 | cast->Alice.status = InCall; |
83 | toxav_prepare_transmission(cast->Alice.av, call_index, &muhcaps, 1); | 83 | toxav_prepare_transmission(cast->Alice.av, call_index, &muhcaps, 1); |
84 | } | 84 | } |
85 | void callback_recv_ending ( uint32_t call_index, void *_arg ) | 85 | void callback_recv_ending ( int32_t call_index, void *_arg ) |
86 | { | 86 | { |
87 | Status *cast = _arg; | 87 | Status *cast = _arg; |
88 | 88 | ||
@@ -95,12 +95,12 @@ void callback_recv_ending ( uint32_t call_index, void *_arg ) | |||
95 | } | 95 | } |
96 | } | 96 | } |
97 | 97 | ||
98 | void callback_recv_error ( uint32_t call_index, void *_arg ) | 98 | void callback_recv_error ( int32_t call_index, void *_arg ) |
99 | { | 99 | { |
100 | ck_assert_msg(0, "AV internal error"); | 100 | ck_assert_msg(0, "AV internal error"); |
101 | } | 101 | } |
102 | 102 | ||
103 | void callback_call_started ( uint32_t call_index, void *_arg ) | 103 | void callback_call_started ( int32_t call_index, void *_arg ) |
104 | { | 104 | { |
105 | Status *cast = _arg; | 105 | Status *cast = _arg; |
106 | 106 | ||
@@ -109,14 +109,14 @@ void callback_call_started ( uint32_t call_index, void *_arg ) | |||
109 | cast->Bob.status = InCall; | 109 | cast->Bob.status = InCall; |
110 | toxav_prepare_transmission(cast->Bob.av, call_index, &muhcaps, 1); | 110 | toxav_prepare_transmission(cast->Bob.av, call_index, &muhcaps, 1); |
111 | } | 111 | } |
112 | void callback_call_canceled ( uint32_t call_index, void *_arg ) | 112 | void callback_call_canceled ( int32_t call_index, void *_arg ) |
113 | { | 113 | { |
114 | Status *cast = _arg; | 114 | Status *cast = _arg; |
115 | 115 | ||
116 | printf ( "Call Canceled for Bob!\n" ); | 116 | printf ( "Call Canceled for Bob!\n" ); |
117 | cast->Bob.status = Cancel; | 117 | cast->Bob.status = Cancel; |
118 | } | 118 | } |
119 | void callback_call_rejected ( uint32_t call_index, void *_arg ) | 119 | void callback_call_rejected ( int32_t call_index, void *_arg ) |
120 | { | 120 | { |
121 | Status *cast = _arg; | 121 | Status *cast = _arg; |
122 | 122 | ||
@@ -125,7 +125,7 @@ void callback_call_rejected ( uint32_t call_index, void *_arg ) | |||
125 | /* If Bob rejects, call is ended for alice and she sends ending */ | 125 | /* If Bob rejects, call is ended for alice and she sends ending */ |
126 | cast->Alice.status = Rejected; | 126 | cast->Alice.status = Rejected; |
127 | } | 127 | } |
128 | void callback_call_ended ( uint32_t call_index, void *_arg ) | 128 | void callback_call_ended ( int32_t call_index, void *_arg ) |
129 | { | 129 | { |
130 | Status *cast = _arg; | 130 | Status *cast = _arg; |
131 | 131 | ||
@@ -133,7 +133,7 @@ void callback_call_ended ( uint32_t call_index, void *_arg ) | |||
133 | cast->Bob.status = Ended; | 133 | cast->Bob.status = Ended; |
134 | } | 134 | } |
135 | 135 | ||
136 | void callback_requ_timeout ( uint32_t call_index, void *_arg ) | 136 | void callback_requ_timeout ( int32_t call_index, void *_arg ) |
137 | { | 137 | { |
138 | ck_assert_msg(0, "No answer!"); | 138 | ck_assert_msg(0, "No answer!"); |
139 | } | 139 | } |
diff --git a/auto_tests/toxav_many_test.c b/auto_tests/toxav_many_test.c index 77f3717e..b499b439 100644 --- a/auto_tests/toxav_many_test.c +++ b/auto_tests/toxav_many_test.c | |||
@@ -60,62 +60,62 @@ void accept_friend_request(Tox *m, uint8_t *public_key, uint8_t *data, uint16_t | |||
60 | 60 | ||
61 | 61 | ||
62 | /******************************************************************************/ | 62 | /******************************************************************************/ |
63 | void callback_recv_invite ( uint32_t call_index, void *_arg ) | 63 | void callback_recv_invite ( int32_t call_index, void *_arg ) |
64 | {/* | 64 | {/* |
65 | Status *cast = _arg; | 65 | Status *cast = _arg; |
66 | 66 | ||
67 | cast->calls[call_index].Callee.status = Ringing;*/ | 67 | cast->calls[call_index].Callee.status = Ringing;*/ |
68 | } | 68 | } |
69 | void callback_recv_ringing ( uint32_t call_index, void *_arg ) | 69 | void callback_recv_ringing ( int32_t call_index, void *_arg ) |
70 | { | 70 | { |
71 | Status *cast = _arg; | 71 | Status *cast = _arg; |
72 | 72 | ||
73 | cast->calls[call_index].Caller.status = Ringing; | 73 | cast->calls[call_index].Caller.status = Ringing; |
74 | } | 74 | } |
75 | void callback_recv_starting ( uint32_t call_index, void *_arg ) | 75 | void callback_recv_starting ( int32_t call_index, void *_arg ) |
76 | { | 76 | { |
77 | Status *cast = _arg; | 77 | Status *cast = _arg; |
78 | 78 | ||
79 | cast->calls[call_index].Caller.status = InCall; | 79 | cast->calls[call_index].Caller.status = InCall; |
80 | } | 80 | } |
81 | void callback_recv_ending ( uint32_t call_index, void *_arg ) | 81 | void callback_recv_ending ( int32_t call_index, void *_arg ) |
82 | { | 82 | { |
83 | Status *cast = _arg; | 83 | Status *cast = _arg; |
84 | 84 | ||
85 | cast->calls[call_index].Caller.status = Ended; | 85 | cast->calls[call_index].Caller.status = Ended; |
86 | } | 86 | } |
87 | 87 | ||
88 | void callback_recv_error ( uint32_t call_index, void *_arg ) | 88 | void callback_recv_error ( int32_t call_index, void *_arg ) |
89 | { | 89 | { |
90 | ck_assert_msg(0, "AV internal error"); | 90 | ck_assert_msg(0, "AV internal error"); |
91 | } | 91 | } |
92 | 92 | ||
93 | void callback_call_started ( uint32_t call_index, void *_arg ) | 93 | void callback_call_started ( int32_t call_index, void *_arg ) |
94 | {/* | 94 | {/* |
95 | Status *cast = _arg; | 95 | Status *cast = _arg; |
96 | 96 | ||
97 | cast->calls[call_index].Callee.status = InCall;*/ | 97 | cast->calls[call_index].Callee.status = InCall;*/ |
98 | } | 98 | } |
99 | void callback_call_canceled ( uint32_t call_index, void *_arg ) | 99 | void callback_call_canceled ( int32_t call_index, void *_arg ) |
100 | {/* | 100 | {/* |
101 | Status *cast = _arg; | 101 | Status *cast = _arg; |
102 | 102 | ||
103 | cast->calls[call_index].Callee.status = Cancel;*/ | 103 | cast->calls[call_index].Callee.status = Cancel;*/ |
104 | } | 104 | } |
105 | void callback_call_rejected ( uint32_t call_index, void *_arg ) | 105 | void callback_call_rejected ( int32_t call_index, void *_arg ) |
106 | { | 106 | { |
107 | Status *cast = _arg; | 107 | Status *cast = _arg; |
108 | 108 | ||
109 | cast->calls[call_index].Caller.status = Rejected; | 109 | cast->calls[call_index].Caller.status = Rejected; |
110 | } | 110 | } |
111 | void callback_call_ended ( uint32_t call_index, void *_arg ) | 111 | void callback_call_ended ( int32_t call_index, void *_arg ) |
112 | {/* | 112 | {/* |
113 | Status *cast = _arg; | 113 | Status *cast = _arg; |
114 | 114 | ||
115 | cast->calls[call_index].Callee.status = Ended;*/ | 115 | cast->calls[call_index].Callee.status = Ended;*/ |
116 | } | 116 | } |
117 | 117 | ||
118 | void callback_requ_timeout ( uint32_t call_index, void *_arg ) | 118 | void callback_requ_timeout ( int32_t call_index, void *_arg ) |
119 | { | 119 | { |
120 | ck_assert_msg(0, "No answer!"); | 120 | ck_assert_msg(0, "No answer!"); |
121 | } | 121 | } |
diff --git a/toxav/media.c b/toxav/media.c index 5700c2f2..a6590e00 100644 --- a/toxav/media.c +++ b/toxav/media.c | |||
@@ -71,10 +71,7 @@ JitterBuffer *create_queue(int capacity) | |||
71 | 71 | ||
72 | void terminate_queue(JitterBuffer* q) | 72 | void terminate_queue(JitterBuffer* q) |
73 | { | 73 | { |
74 | int i; | 74 | empty_queue(q); |
75 | for ( i = 0; i < q->capacity; i ++ ) { | ||
76 | rtp_free_msg(NULL, q->queue[i]); | ||
77 | } | ||
78 | free(q->queue); | 75 | free(q->queue); |
79 | free(q); | 76 | free(q); |
80 | } | 77 | } |
diff --git a/toxav/msi.c b/toxav/msi.c index 8d4e6964..c2d50302 100755 --- a/toxav/msi.c +++ b/toxav/msi.c | |||
@@ -122,7 +122,7 @@ static struct _Callbacks { | |||
122 | void* data; | 122 | void* data; |
123 | } callbacks[11] = {0}; | 123 | } callbacks[11] = {0}; |
124 | 124 | ||
125 | inline__ void invoke_callback(uint32_t call_index, MSICallbackID id) | 125 | inline__ void invoke_callback(int32_t call_index, MSICallbackID id) |
126 | { | 126 | { |
127 | /*if ( callbacks[id].function ) event.rise ( callbacks[id].function, callbacks[id].data );*/ | 127 | /*if ( callbacks[id].function ) event.rise ( callbacks[id].function, callbacks[id].data );*/ |
128 | if ( callbacks[id].function ) { | 128 | if ( callbacks[id].function ) { |
@@ -209,18 +209,7 @@ static inline__ const uint8_t *stringify_response ( MSIResponse response ) | |||
209 | } | 209 | } |
210 | 210 | ||
211 | 211 | ||
212 | #define ON_HEADER(iterator, header, descriptor, size_const) \ | 212 | |
213 | ( memcmp(iterator, descriptor, size_const) == 0){ /* Okay */ \ | ||
214 | iterator += size_const; /* Set iterator at begining of value part */ \ | ||
215 | if ( *iterator != value_byte ) { assert(0); return -1; }\ | ||
216 | iterator ++;\ | ||
217 | uint16_t _value_size = (uint16_t) *(iterator ) << 8 | \ | ||
218 | (uint16_t) *(iterator + 1); \ | ||
219 | header.header_value = calloc(sizeof(uint8_t), _value_size); \ | ||
220 | header.size = _value_size; \ | ||
221 | memcpy(header.header_value, iterator + 2, _value_size);\ | ||
222 | iterator = iterator + 2 + _value_size; /* set iterator at new header or end_byte */ \ | ||
223 | } | ||
224 | 213 | ||
225 | /** | 214 | /** |
226 | * @brief Parse raw 'data' received from socket into MSIMessage struct. | 215 | * @brief Parse raw 'data' received from socket into MSIMessage struct. |
@@ -235,6 +224,19 @@ static inline__ const uint8_t *stringify_response ( MSIResponse response ) | |||
235 | */ | 224 | */ |
236 | int parse_raw_data ( MSIMessage *msg, const uint8_t *data, uint16_t length ) | 225 | int parse_raw_data ( MSIMessage *msg, const uint8_t *data, uint16_t length ) |
237 | { | 226 | { |
227 | |||
228 | #define ON_HEADER(iterator, header, descriptor, size_const) \ | ||
229 | ( memcmp(iterator, descriptor, size_const) == 0){ /* Okay */ \ | ||
230 | iterator += size_const; /* Set iterator at begining of value part */ \ | ||
231 | if ( *iterator != value_byte ) { assert(0); return -1; }\ | ||
232 | iterator ++;\ | ||
233 | uint16_t _value_size = (uint16_t) *(iterator ) << 8 | \ | ||
234 | (uint16_t) *(iterator + 1); \ | ||
235 | header.header_value = calloc(sizeof(uint8_t), _value_size); \ | ||
236 | header.size = _value_size; \ | ||
237 | memcpy(header.header_value, iterator + 2, _value_size);\ | ||
238 | iterator = iterator + 2 + _value_size; /* set iterator at new header or end_byte */ } | ||
239 | |||
238 | if ( msg == NULL ) { | 240 | if ( msg == NULL ) { |
239 | LOGGER_ERROR("Could not parse message: no storage!"); | 241 | LOGGER_ERROR("Could not parse message: no storage!"); |
240 | } | 242 | } |
@@ -537,10 +539,6 @@ uint8_t *append_header_to_string ( | |||
537 | } | 539 | } |
538 | 540 | ||
539 | 541 | ||
540 | #define CLEAN_ASSIGN(added, var, field, header)\ | ||
541 | if ( header.header_value ) { var = append_header_to_string(var, (const uint8_t*)field, header.header_value, header.size, &added); } | ||
542 | |||
543 | |||
544 | /** | 542 | /** |
545 | * @brief Convert MSIMessage struct to _sendable_ string. | 543 | * @brief Convert MSIMessage struct to _sendable_ string. |
546 | * | 544 | * |
@@ -550,6 +548,9 @@ if ( header.header_value ) { var = append_header_to_string(var, (const uint8_t*) | |||
550 | */ | 548 | */ |
551 | uint16_t message_to_send ( MSIMessage *msg, uint8_t *dest ) | 549 | uint16_t message_to_send ( MSIMessage *msg, uint8_t *dest ) |
552 | { | 550 | { |
551 | #define CLEAN_ASSIGN(added, var, field, header)\ | ||
552 | if ( header.header_value ) { var = append_header_to_string(var, (const uint8_t*)field, header.header_value, header.size, &added); } | ||
553 | |||
553 | if (msg == NULL) { | 554 | if (msg == NULL) { |
554 | LOGGER_ERROR("Empty message!"); | 555 | LOGGER_ERROR("Empty message!"); |
555 | return 0; | 556 | return 0; |
@@ -857,35 +858,6 @@ int has_call_error ( MSISession *session, MSICall* call, MSIMessage *msg ) | |||
857 | 858 | ||
858 | 859 | ||
859 | /** | 860 | /** |
860 | * @brief Function called at request timeout. If not called in thread it might cause trouble | ||
861 | * | ||
862 | * @param arg Control session | ||
863 | * @return void* | ||
864 | */ | ||
865 | void *handle_timeout ( void *arg ) | ||
866 | { | ||
867 | /* TODO: Cancel might not arrive there; set up | ||
868 | * timers on these cancels and terminate call on | ||
869 | * their timeout | ||
870 | */ | ||
871 | MSICall *_call = arg; | ||
872 | |||
873 | LOGGER_DEBUG("[Call: %s] Request timed out!", _call->id); | ||
874 | |||
875 | invoke_callback(_call->call_idx, MSI_OnRequestTimeout); | ||
876 | |||
877 | if ( _call && _call->session ) { | ||
878 | |||
879 | /* TODO: Cancel all? */ | ||
880 | /* uint16_t _it = 0; | ||
881 | for ( ; _it < _session->call->peer_count; _it++ ) */ | ||
882 | msi_cancel ( _call->session, _call->call_idx, _call->peers [0], "Request timed out" ); | ||
883 | } | ||
884 | |||
885 | pthread_exit(NULL); | ||
886 | } | ||
887 | |||
888 | /** | ||
889 | * @brief Add peer to peer list. | 861 | * @brief Add peer to peer list. |
890 | * | 862 | * |
891 | * @param call What call. | 863 | * @param call What call. |
@@ -903,6 +875,8 @@ void add_peer( MSICall *call, int peer_id ) | |||
903 | } | 875 | } |
904 | 876 | ||
905 | call->peers[call->peer_count - 1] = peer_id; | 877 | call->peers[call->peer_count - 1] = peer_id; |
878 | |||
879 | LOGGER_DEBUG("Added peer: %d", peer_id); | ||
906 | } | 880 | } |
907 | 881 | ||
908 | 882 | ||
@@ -922,7 +896,7 @@ MSICall *init_call ( MSISession *session, int peers, int ringing_timeout ) | |||
922 | return NULL; | 896 | return NULL; |
923 | } | 897 | } |
924 | 898 | ||
925 | uint32_t _call_idx = 0; | 899 | int32_t _call_idx = 0; |
926 | for (; _call_idx < session->max_calls; _call_idx ++) { | 900 | for (; _call_idx < session->max_calls; _call_idx ++) { |
927 | if ( !session->calls[_call_idx] ) { | 901 | if ( !session->calls[_call_idx] ) { |
928 | session->calls[_call_idx] = calloc ( sizeof ( MSICall ), 1 ); | 902 | session->calls[_call_idx] = calloc ( sizeof ( MSICall ), 1 ); |
@@ -1015,6 +989,37 @@ int terminate_call ( MSISession *session, MSICall *call ) | |||
1015 | } | 989 | } |
1016 | 990 | ||
1017 | 991 | ||
992 | /** | ||
993 | * @brief Function called at request timeout. If not called in thread it might cause trouble | ||
994 | * | ||
995 | * @param arg Control session | ||
996 | * @return void* | ||
997 | */ | ||
998 | void *handle_timeout ( void *arg ) | ||
999 | { | ||
1000 | /* TODO: Cancel might not arrive there; set up | ||
1001 | * timers on these cancels and terminate call on | ||
1002 | * their timeout | ||
1003 | */ | ||
1004 | MSICall *_call = arg; | ||
1005 | |||
1006 | LOGGER_DEBUG("[Call: %s] Request timed out!", _call->id); | ||
1007 | |||
1008 | invoke_callback(_call->call_idx, MSI_OnRequestTimeout); | ||
1009 | |||
1010 | if ( _call && _call->session ) { | ||
1011 | |||
1012 | /* TODO: Cancel all? */ | ||
1013 | /* uint16_t _it = 0; | ||
1014 | * for ( ; _it < _session->call->peer_count; _it++ ) */ | ||
1015 | msi_cancel ( _call->session, _call->call_idx, _call->peers [0], "Request timed out" ); | ||
1016 | terminate_call(_call->session, _call); | ||
1017 | } | ||
1018 | |||
1019 | pthread_exit(NULL); | ||
1020 | } | ||
1021 | |||
1022 | |||
1018 | /********** Request handlers **********/ | 1023 | /********** Request handlers **********/ |
1019 | int handle_recv_invite ( MSISession *session, MSICall* call, MSIMessage *msg ) | 1024 | int handle_recv_invite ( MSISession *session, MSICall* call, MSIMessage *msg ) |
1020 | { | 1025 | { |
@@ -1072,7 +1077,7 @@ int handle_recv_invite ( MSISession *session, MSICall* call, MSIMessage *msg ) | |||
1072 | } | 1077 | } |
1073 | int handle_recv_start ( MSISession *session, MSICall* call, MSIMessage *msg ) | 1078 | int handle_recv_start ( MSISession *session, MSICall* call, MSIMessage *msg ) |
1074 | { | 1079 | { |
1075 | LOGGER_DEBUG("Session: %p Handling 'start' on call: %s", session, call->id ); | 1080 | LOGGER_DEBUG("Session: %p Handling 'start' on call: %s, friend id: %d", session, call->id, msg->friend_id ); |
1076 | 1081 | ||
1077 | if ( has_call_error ( session, call, msg ) == 0 ) | 1082 | if ( has_call_error ( session, call, msg ) == 0 ) |
1078 | return -1; | 1083 | return -1; |
@@ -1125,10 +1130,10 @@ int handle_recv_cancel ( MSISession *session, MSICall* call, MSIMessage *msg ) | |||
1125 | return 0; | 1130 | return 0; |
1126 | 1131 | ||
1127 | /* Act as end message */ | 1132 | /* Act as end message */ |
1128 | 1133 | /* | |
1129 | MSIMessage *_msg_ending = msi_new_message ( TYPE_RESPONSE, stringify_response ( ending ) ); | 1134 | MSIMessage *_msg_ending = msi_new_message ( TYPE_RESPONSE, stringify_response ( ending ) ); |
1130 | send_message ( session, call, _msg_ending, msg->friend_id ); | 1135 | send_message ( session, call, _msg_ending, msg->friend_id ); |
1131 | free_message ( _msg_ending ); | 1136 | free_message ( _msg_ending );*/ |
1132 | 1137 | ||
1133 | invoke_callback(call->call_idx, MSI_OnCancel); | 1138 | invoke_callback(call->call_idx, MSI_OnCancel); |
1134 | 1139 | ||
@@ -1383,31 +1388,6 @@ void msi_handle_packet ( Messenger *messenger, int source, uint8_t *data, uint16 | |||
1383 | } | 1388 | } |
1384 | 1389 | ||
1385 | 1390 | ||
1386 | /******************************************************************************************************************** | ||
1387 | * ******************************************************************************************************************* | ||
1388 | ******************************************************************************************************************** | ||
1389 | ******************************************************************************************************************** | ||
1390 | ******************************************************************************************************************** | ||
1391 | * | ||
1392 | * | ||
1393 | * | ||
1394 | * PUBLIC API FUNCTIONS IMPLEMENTATIONS | ||
1395 | * | ||
1396 | * | ||
1397 | * | ||
1398 | ******************************************************************************************************************** | ||
1399 | ******************************************************************************************************************** | ||
1400 | ******************************************************************************************************************** | ||
1401 | ******************************************************************************************************************** | ||
1402 | ********************************************************************************************************************/ | ||
1403 | |||
1404 | |||
1405 | |||
1406 | |||
1407 | |||
1408 | |||
1409 | |||
1410 | |||
1411 | /** | 1391 | /** |
1412 | * @brief Callback setter. | 1392 | * @brief Callback setter. |
1413 | * | 1393 | * |
@@ -1430,7 +1410,7 @@ void msi_register_callback ( MSICallback callback, MSICallbackID id, void* userd | |||
1430 | * @return MSISession* The created session. | 1410 | * @return MSISession* The created session. |
1431 | * @retval NULL Error occured. | 1411 | * @retval NULL Error occured. |
1432 | */ | 1412 | */ |
1433 | MSISession *msi_init_session ( Messenger* messenger, uint32_t max_calls ) | 1413 | MSISession *msi_init_session ( Messenger* messenger, int32_t max_calls ) |
1434 | { | 1414 | { |
1435 | if (messenger == NULL) { | 1415 | if (messenger == NULL) { |
1436 | LOGGER_ERROR("Could not init session on empty messenger!"); | 1416 | LOGGER_ERROR("Could not init session on empty messenger!"); |
@@ -1507,13 +1487,13 @@ int msi_terminate_session ( MSISession *session ) | |||
1507 | * @param friend_id The friend. | 1487 | * @param friend_id The friend. |
1508 | * @return int | 1488 | * @return int |
1509 | */ | 1489 | */ |
1510 | int msi_invite ( MSISession* session, uint32_t* call_index, MSICallType call_type, uint32_t rngsec, uint32_t friend_id ) | 1490 | int msi_invite ( MSISession* session, int32_t* call_index, MSICallType call_type, uint32_t rngsec, uint32_t friend_id ) |
1511 | { | 1491 | { |
1512 | LOGGER_DEBUG("Session: %p Inviting friend: %u", session, friend_id); | 1492 | LOGGER_DEBUG("Session: %p Inviting friend: %u", session, friend_id); |
1513 | 1493 | ||
1514 | MSIMessage *_msg_invite = msi_new_message ( TYPE_REQUEST, stringify_request ( invite ) ); | 1494 | MSIMessage *_msg_invite = msi_new_message ( TYPE_REQUEST, stringify_request ( invite ) ); |
1515 | 1495 | ||
1516 | MSICall* _call = init_call ( session, 1, rngsec ); /* Just one for now */ | 1496 | MSICall* _call = init_call ( session, 1, rngsec ); /* Just one peer for now */ |
1517 | if ( !_call ) return -1; /* Cannot handle more calls */ | 1497 | if ( !_call ) return -1; /* Cannot handle more calls */ |
1518 | 1498 | ||
1519 | *call_index = _call->call_idx; | 1499 | *call_index = _call->call_idx; |
@@ -1553,11 +1533,11 @@ int msi_invite ( MSISession* session, uint32_t* call_index, MSICallType call_typ | |||
1553 | * @retval -1 Error occured. | 1533 | * @retval -1 Error occured. |
1554 | * @retval 0 Success. | 1534 | * @retval 0 Success. |
1555 | */ | 1535 | */ |
1556 | int msi_hangup ( MSISession* session, uint32_t call_index ) | 1536 | int msi_hangup ( MSISession* session, int32_t call_index ) |
1557 | { | 1537 | { |
1558 | LOGGER_DEBUG("Session: %p Hanging up call: %u", session, call_index); | 1538 | LOGGER_DEBUG("Session: %p Hanging up call: %u", session, call_index); |
1559 | 1539 | ||
1560 | if ( call_index >= session->max_calls || !session->calls[call_index] ) { | 1540 | if ( call_index < 0 || call_index >= session->max_calls || !session->calls[call_index] ) { |
1561 | LOGGER_ERROR("Invalid call index!"); | 1541 | LOGGER_ERROR("Invalid call index!"); |
1562 | return -1; | 1542 | return -1; |
1563 | } | 1543 | } |
@@ -1592,11 +1572,11 @@ int msi_hangup ( MSISession* session, uint32_t call_index ) | |||
1592 | * @param call_type Answer with Audio or Video(both). | 1572 | * @param call_type Answer with Audio or Video(both). |
1593 | * @return int | 1573 | * @return int |
1594 | */ | 1574 | */ |
1595 | int msi_answer ( MSISession* session, uint32_t call_index, MSICallType call_type ) | 1575 | int msi_answer ( MSISession* session, int32_t call_index, MSICallType call_type ) |
1596 | { | 1576 | { |
1597 | LOGGER_DEBUG("Session: %p Answering call: %u", session, call_index); | 1577 | LOGGER_DEBUG("Session: %p Answering call: %u", session, call_index); |
1598 | 1578 | ||
1599 | if ( call_index >= session->max_calls || !session->calls[call_index] ){ | 1579 | if ( call_index < 0 || call_index >= session->max_calls || !session->calls[call_index] ){ |
1600 | LOGGER_ERROR("Invalid call index!"); | 1580 | LOGGER_ERROR("Invalid call index!"); |
1601 | return -1; | 1581 | return -1; |
1602 | } | 1582 | } |
@@ -1641,11 +1621,11 @@ int msi_answer ( MSISession* session, uint32_t call_index, MSICallType call_type | |||
1641 | * @param reason Set optional reason header. Pass NULL if none. | 1621 | * @param reason Set optional reason header. Pass NULL if none. |
1642 | * @return int | 1622 | * @return int |
1643 | */ | 1623 | */ |
1644 | int msi_cancel ( MSISession *session, uint32_t call_index, uint32_t peer, const char *reason ) | 1624 | int msi_cancel ( MSISession* session, int32_t call_index, uint32_t peer, const char* reason ) |
1645 | { | 1625 | { |
1646 | LOGGER_DEBUG("Session: %p Canceling call: %u; reason:", session, call_index, reason? reason : "Unknown"); | 1626 | LOGGER_DEBUG("Session: %p Canceling call: %u; reason:", session, call_index, reason? reason : "Unknown"); |
1647 | 1627 | ||
1648 | if ( call_index >= session->max_calls || !session->calls[call_index] ){ | 1628 | if ( call_index < 0 || call_index >= session->max_calls || !session->calls[call_index] ){ |
1649 | LOGGER_ERROR("Invalid call index!"); | 1629 | LOGGER_ERROR("Invalid call index!"); |
1650 | return -1; | 1630 | return -1; |
1651 | } | 1631 | } |
@@ -1670,11 +1650,11 @@ int msi_cancel ( MSISession *session, uint32_t call_index, uint32_t peer, const | |||
1670 | * @param call_id To which call is this action handled. | 1650 | * @param call_id To which call is this action handled. |
1671 | * @return int | 1651 | * @return int |
1672 | */ | 1652 | */ |
1673 | int msi_reject ( MSISession *session, uint32_t call_index, const uint8_t *reason ) | 1653 | int msi_reject ( MSISession* session, int32_t call_index, const uint8_t* reason ) |
1674 | { | 1654 | { |
1675 | LOGGER_DEBUG("Session: %p Rejecting call: %u; reason:", session, call_index, reason? (char*)reason : "Unknown"); | 1655 | LOGGER_DEBUG("Session: %p Rejecting call: %u; reason:", session, call_index, reason? (char*)reason : "Unknown"); |
1676 | 1656 | ||
1677 | if ( call_index >= session->max_calls || !session->calls[call_index] ){ | 1657 | if ( call_index < 0 || call_index >= session->max_calls || !session->calls[call_index] ){ |
1678 | LOGGER_ERROR("Invalid call index!"); | 1658 | LOGGER_ERROR("Invalid call index!"); |
1679 | return -1; | 1659 | return -1; |
1680 | } | 1660 | } |
@@ -1699,11 +1679,11 @@ int msi_reject ( MSISession *session, uint32_t call_index, const uint8_t *reason | |||
1699 | * @param call_id To which call is this action handled. | 1679 | * @param call_id To which call is this action handled. |
1700 | * @return int | 1680 | * @return int |
1701 | */ | 1681 | */ |
1702 | int msi_stopcall ( MSISession *session, uint32_t call_index ) | 1682 | int msi_stopcall ( MSISession* session, int32_t call_index ) |
1703 | { | 1683 | { |
1704 | LOGGER_DEBUG("Session: %p Stopping call index: %u", session, call_index); | 1684 | LOGGER_DEBUG("Session: %p Stopping call index: %u", session, call_index); |
1705 | 1685 | ||
1706 | if ( call_index >= session->max_calls || !session->calls[call_index] ) | 1686 | if ( call_index < 0 || call_index >= session->max_calls || !session->calls[call_index] ) |
1707 | return -1; | 1687 | return -1; |
1708 | 1688 | ||
1709 | /* just terminate it */ | 1689 | /* just terminate it */ |
diff --git a/toxav/msi.h b/toxav/msi.h index c74f9f11..2a7c5ba8 100755 --- a/toxav/msi.h +++ b/toxav/msi.h | |||
@@ -33,7 +33,7 @@ | |||
33 | #define CALL_ID_LEN 12 | 33 | #define CALL_ID_LEN 12 |
34 | 34 | ||
35 | 35 | ||
36 | typedef void ( *MSICallback ) ( uint32_t, void *arg ); | 36 | typedef void ( *MSICallback ) ( int32_t, void *arg ); |
37 | 37 | ||
38 | 38 | ||
39 | /** | 39 | /** |
@@ -89,7 +89,7 @@ typedef struct _MSICall { /* Call info structure */ | |||
89 | uint32_t *peers; | 89 | uint32_t *peers; |
90 | uint16_t peer_count; | 90 | uint16_t peer_count; |
91 | 91 | ||
92 | uint32_t call_idx; /* Index of this call in MSISession */ | 92 | int32_t call_idx; /* Index of this call in MSISession */ |
93 | } MSICall; | 93 | } MSICall; |
94 | 94 | ||
95 | 95 | ||
@@ -101,7 +101,7 @@ typedef struct _MSISession { | |||
101 | 101 | ||
102 | /* Call handlers */ | 102 | /* Call handlers */ |
103 | struct _MSICall **calls; | 103 | struct _MSICall **calls; |
104 | uint32_t max_calls; | 104 | int32_t max_calls; |
105 | 105 | ||
106 | int last_error_id; /* Determine the last error */ | 106 | int last_error_id; /* Determine the last error */ |
107 | const uint8_t *last_error_str; | 107 | const uint8_t *last_error_str; |
@@ -158,7 +158,7 @@ void msi_register_callback(MSICallback callback, MSICallbackID id, void* userdat | |||
158 | * @return MSISession* The created session. | 158 | * @return MSISession* The created session. |
159 | * @retval NULL Error occured. | 159 | * @retval NULL Error occured. |
160 | */ | 160 | */ |
161 | MSISession *msi_init_session ( Messenger *messenger, uint32_t max_calls ); | 161 | MSISession *msi_init_session ( Messenger *messenger, int32_t max_calls ); |
162 | 162 | ||
163 | 163 | ||
164 | /** | 164 | /** |
@@ -180,7 +180,7 @@ int msi_terminate_session ( MSISession *session ); | |||
180 | * @param friend_id The friend. | 180 | * @param friend_id The friend. |
181 | * @return int | 181 | * @return int |
182 | */ | 182 | */ |
183 | int msi_invite ( MSISession *session, uint32_t* call_index, MSICallType call_type, uint32_t rngsec, uint32_t friend_id ); | 183 | int msi_invite ( MSISession *session, int32_t* call_index, MSICallType call_type, uint32_t rngsec, uint32_t friend_id ); |
184 | 184 | ||
185 | 185 | ||
186 | /** | 186 | /** |
@@ -192,7 +192,7 @@ int msi_invite ( MSISession *session, uint32_t* call_index, MSICallType call_typ | |||
192 | * @retval -1 Error occured. | 192 | * @retval -1 Error occured. |
193 | * @retval 0 Success. | 193 | * @retval 0 Success. |
194 | */ | 194 | */ |
195 | int msi_hangup ( MSISession *session, uint32_t call_index ); | 195 | int msi_hangup ( MSISession *session, int32_t call_index ); |
196 | 196 | ||
197 | 197 | ||
198 | /** | 198 | /** |
@@ -203,7 +203,7 @@ int msi_hangup ( MSISession *session, uint32_t call_index ); | |||
203 | * @param call_type Answer with Audio or Video(both). | 203 | * @param call_type Answer with Audio or Video(both). |
204 | * @return int | 204 | * @return int |
205 | */ | 205 | */ |
206 | int msi_answer ( MSISession *session, uint32_t call_index, MSICallType call_type ); | 206 | int msi_answer ( MSISession *session, int32_t call_index, MSICallType call_type ); |
207 | 207 | ||
208 | 208 | ||
209 | /** | 209 | /** |
@@ -215,7 +215,7 @@ int msi_answer ( MSISession *session, uint32_t call_index, MSICallType call_type | |||
215 | * @param reason Set optional reason header. Pass NULL if none. | 215 | * @param reason Set optional reason header. Pass NULL if none. |
216 | * @return int | 216 | * @return int |
217 | */ | 217 | */ |
218 | int msi_cancel ( MSISession* session, uint32_t call_index, uint32_t peer, const char* reason ); | 218 | int msi_cancel ( MSISession* session, int32_t call_index, uint32_t peer, const char* reason ); |
219 | 219 | ||
220 | 220 | ||
221 | /** | 221 | /** |
@@ -226,7 +226,7 @@ int msi_cancel ( MSISession* session, uint32_t call_index, uint32_t peer, const | |||
226 | * @param reason Set optional reason header. Pass NULL if none. | 226 | * @param reason Set optional reason header. Pass NULL if none. |
227 | * @return int | 227 | * @return int |
228 | */ | 228 | */ |
229 | int msi_reject ( MSISession *session, uint32_t call_index, const uint8_t *reason ); | 229 | int msi_reject ( MSISession *session, int32_t call_index, const uint8_t *reason ); |
230 | 230 | ||
231 | 231 | ||
232 | /** | 232 | /** |
@@ -236,6 +236,6 @@ int msi_reject ( MSISession *session, uint32_t call_index, const uint8_t *reason | |||
236 | * @param call_index To which call is this action handled. | 236 | * @param call_index To which call is this action handled. |
237 | * @return int | 237 | * @return int |
238 | */ | 238 | */ |
239 | int msi_stopcall ( MSISession *session, uint32_t call_index ); | 239 | int msi_stopcall ( MSISession *session, int32_t call_index ); |
240 | 240 | ||
241 | #endif /* __TOXMSI */ | 241 | #endif /* __TOXMSI */ |
diff --git a/toxav/rtp.c b/toxav/rtp.c index 1e6296b0..8b2768f1 100755 --- a/toxav/rtp.c +++ b/toxav/rtp.c | |||
@@ -652,36 +652,6 @@ RTPMessage *rtp_new_message ( RTPSession *session, const uint8_t *data, uint32_t | |||
652 | 652 | ||
653 | 653 | ||
654 | 654 | ||
655 | |||
656 | |||
657 | |||
658 | |||
659 | /******************************************************************************************************************** | ||
660 | ******************************************************************************************************************** | ||
661 | ******************************************************************************************************************** | ||
662 | ******************************************************************************************************************** | ||
663 | ******************************************************************************************************************** | ||
664 | * | ||
665 | * | ||
666 | * | ||
667 | * PUBLIC API FUNCTIONS IMPLEMENTATIONS | ||
668 | * | ||
669 | * | ||
670 | * | ||
671 | ******************************************************************************************************************** | ||
672 | ******************************************************************************************************************** | ||
673 | ******************************************************************************************************************** | ||
674 | ******************************************************************************************************************** | ||
675 | ********************************************************************************************************************/ | ||
676 | |||
677 | |||
678 | |||
679 | |||
680 | |||
681 | |||
682 | |||
683 | |||
684 | |||
685 | /** | 655 | /** |
686 | * @brief Release all messages held by session. | 656 | * @brief Release all messages held by session. |
687 | * | 657 | * |
@@ -757,6 +727,7 @@ RTPMessage *rtp_recv_msg ( RTPSession *session ) | |||
757 | pthread_mutex_lock(&session->mutex); | 727 | pthread_mutex_lock(&session->mutex); |
758 | 728 | ||
759 | if ( session->queue_size == 0 ) { | 729 | if ( session->queue_size == 0 ) { |
730 | pthread_mutex_unlock(&session->mutex); | ||
760 | return NULL; | 731 | return NULL; |
761 | } | 732 | } |
762 | 733 | ||
@@ -890,12 +861,13 @@ RTPSession *rtp_init_session ( int payload_type, | |||
890 | assert(_retu); | 861 | assert(_retu); |
891 | 862 | ||
892 | if ( -1 == custom_user_packet_registerhandler(messenger, friend_num, payload_type, rtp_handle_packet, _retu) || | 863 | if ( -1 == custom_user_packet_registerhandler(messenger, friend_num, payload_type, rtp_handle_packet, _retu) || |
893 | !encrypt_key, !decrypt_key, !encrypt_nonce, !decrypt_nonce | 864 | !encrypt_key || !decrypt_key || !encrypt_nonce || !decrypt_nonce) { |
894 | ) { | ||
895 | LOGGER_ERROR("Error setting custom register handler for rtp session"); | 865 | LOGGER_ERROR("Error setting custom register handler for rtp session"); |
896 | free(_retu); | 866 | free(_retu); |
897 | return NULL; | 867 | return NULL; |
898 | } | 868 | } |
869 | |||
870 | LOGGER_DEBUG("Registered packet handler: pt: %d; fid: %d", payload_type, friend_num); | ||
899 | 871 | ||
900 | _retu->version = RTP_VERSION; /* It's always 2 */ | 872 | _retu->version = RTP_VERSION; /* It's always 2 */ |
901 | _retu->padding = 0; /* If some additional data is needed about the packet */ | 873 | _retu->padding = 0; /* If some additional data is needed about the packet */ |
diff --git a/toxav/toxav.c b/toxav/toxav.c index 3a41754a..015c6565 100755 --- a/toxav/toxav.c +++ b/toxav/toxav.c | |||
@@ -92,7 +92,7 @@ const ToxAvCodecSettings av_DefaultSettings = { | |||
92 | * @return ToxAv* | 92 | * @return ToxAv* |
93 | * @retval NULL On error. | 93 | * @retval NULL On error. |
94 | */ | 94 | */ |
95 | ToxAv *toxav_new( Tox* messenger, uint32_t max_calls) | 95 | ToxAv *toxav_new( Tox* messenger, int32_t max_calls) |
96 | { | 96 | { |
97 | ToxAv *av = calloc ( sizeof(ToxAv), 1); | 97 | ToxAv *av = calloc ( sizeof(ToxAv), 1); |
98 | 98 | ||
@@ -171,7 +171,7 @@ void toxav_register_callstate_callback ( ToxAVCallback callback, ToxAvCallbackID | |||
171 | * @retval 0 Success. | 171 | * @retval 0 Success. |
172 | * @retval ToxAvError On error. | 172 | * @retval ToxAvError On error. |
173 | */ | 173 | */ |
174 | int toxav_call (ToxAv* av, uint32_t* call_index, int user, ToxAvCallType call_type, int ringing_seconds ) | 174 | int toxav_call (ToxAv* av, int32_t* call_index, int user, ToxAvCallType call_type, int ringing_seconds ) |
175 | { | 175 | { |
176 | return msi_invite(av->msi_session, call_index, call_type, ringing_seconds * 1000, user); | 176 | return msi_invite(av->msi_session, call_index, call_type, ringing_seconds * 1000, user); |
177 | } | 177 | } |
@@ -184,7 +184,7 @@ int toxav_call (ToxAv* av, uint32_t* call_index, int user, ToxAvCallType call_ty | |||
184 | * @retval 0 Success. | 184 | * @retval 0 Success. |
185 | * @retval ToxAvError On error. | 185 | * @retval ToxAvError On error. |
186 | */ | 186 | */ |
187 | int toxav_hangup ( ToxAv* av, uint32_t call_index ) | 187 | int toxav_hangup ( ToxAv* av, int32_t call_index ) |
188 | { | 188 | { |
189 | if ( !av->msi_session->calls[call_index] ) { | 189 | if ( !av->msi_session->calls[call_index] ) { |
190 | return ErrorNoCall; | 190 | return ErrorNoCall; |
@@ -206,7 +206,7 @@ int toxav_hangup ( ToxAv* av, uint32_t call_index ) | |||
206 | * @retval 0 Success. | 206 | * @retval 0 Success. |
207 | * @retval ToxAvError On error. | 207 | * @retval ToxAvError On error. |
208 | */ | 208 | */ |
209 | int toxav_answer ( ToxAv* av, uint32_t call_index, ToxAvCallType call_type ) | 209 | int toxav_answer ( ToxAv* av, int32_t call_index, ToxAvCallType call_type ) |
210 | { | 210 | { |
211 | if ( !av->msi_session->calls[call_index] ) { | 211 | if ( !av->msi_session->calls[call_index] ) { |
212 | return ErrorNoCall; | 212 | return ErrorNoCall; |
@@ -228,7 +228,7 @@ int toxav_answer ( ToxAv* av, uint32_t call_index, ToxAvCallType call_type ) | |||
228 | * @retval 0 Success. | 228 | * @retval 0 Success. |
229 | * @retval ToxAvError On error. | 229 | * @retval ToxAvError On error. |
230 | */ | 230 | */ |
231 | int toxav_reject ( ToxAv* av, uint32_t call_index, const char* reason ) | 231 | int toxav_reject ( ToxAv* av, int32_t call_index, const char* reason ) |
232 | { | 232 | { |
233 | if ( !av->msi_session->calls[call_index] ) { | 233 | if ( !av->msi_session->calls[call_index] ) { |
234 | return ErrorNoCall; | 234 | return ErrorNoCall; |
@@ -251,7 +251,7 @@ int toxav_reject ( ToxAv* av, uint32_t call_index, const char* reason ) | |||
251 | * @retval 0 Success. | 251 | * @retval 0 Success. |
252 | * @retval ToxAvError On error. | 252 | * @retval ToxAvError On error. |
253 | */ | 253 | */ |
254 | int toxav_cancel ( ToxAv* av, uint32_t call_index, int peer_id, const char* reason ) | 254 | int toxav_cancel ( ToxAv* av, int32_t call_index, int peer_id, const char* reason ) |
255 | { | 255 | { |
256 | if ( !av->msi_session->calls[call_index] ) { | 256 | if ( !av->msi_session->calls[call_index] ) { |
257 | return ErrorNoCall; | 257 | return ErrorNoCall; |
@@ -268,7 +268,7 @@ int toxav_cancel ( ToxAv* av, uint32_t call_index, int peer_id, const char* reas | |||
268 | * @retval 0 Success. | 268 | * @retval 0 Success. |
269 | * @retval ToxAvError On error. | 269 | * @retval ToxAvError On error. |
270 | */ | 270 | */ |
271 | int toxav_stop_call ( ToxAv* av, uint32_t call_index ) | 271 | int toxav_stop_call ( ToxAv* av, int32_t call_index ) |
272 | { | 272 | { |
273 | if ( !av->msi_session->calls[call_index] ) { | 273 | if ( !av->msi_session->calls[call_index] ) { |
274 | return ErrorNoCall; | 274 | return ErrorNoCall; |
@@ -285,7 +285,7 @@ int toxav_stop_call ( ToxAv* av, uint32_t call_index ) | |||
285 | * @retval 0 Success. | 285 | * @retval 0 Success. |
286 | * @retval ToxAvError On error. | 286 | * @retval ToxAvError On error. |
287 | */ | 287 | */ |
288 | int toxav_prepare_transmission ( ToxAv* av, uint32_t call_index, ToxAvCodecSettings* codec_settings, int support_video ) | 288 | int toxav_prepare_transmission ( ToxAv* av, int32_t call_index, ToxAvCodecSettings* codec_settings, int support_video ) |
289 | { | 289 | { |
290 | if ( !av->msi_session || av->msi_session->max_calls <= call_index || !av->msi_session->calls[call_index] ) { | 290 | if ( !av->msi_session || av->msi_session->max_calls <= call_index || !av->msi_session->calls[call_index] ) { |
291 | /*fprintf(stderr, "Error while starting audio RTP session: invalid call!\n");*/ | 291 | /*fprintf(stderr, "Error while starting audio RTP session: invalid call!\n");*/ |
@@ -350,7 +350,7 @@ int toxav_prepare_transmission ( ToxAv* av, uint32_t call_index, ToxAvCodecSetti | |||
350 | * @retval 0 Success. | 350 | * @retval 0 Success. |
351 | * @retval ToxAvError On error. | 351 | * @retval ToxAvError On error. |
352 | */ | 352 | */ |
353 | int toxav_kill_transmission ( ToxAv *av, uint32_t call_index ) | 353 | int toxav_kill_transmission ( ToxAv *av, int32_t call_index ) |
354 | { | 354 | { |
355 | CallSpecific* call = &av->calls[call_index]; | 355 | CallSpecific* call = &av->calls[call_index]; |
356 | 356 | ||
@@ -370,12 +370,16 @@ int toxav_kill_transmission ( ToxAv *av, uint32_t call_index ) | |||
370 | if ( call->j_buf ) { | 370 | if ( call->j_buf ) { |
371 | terminate_queue(call->j_buf); | 371 | terminate_queue(call->j_buf); |
372 | call->j_buf = NULL; | 372 | call->j_buf = NULL; |
373 | LOGGER_DEBUG("Terminated j queue"); | ||
373 | } | 374 | } |
375 | else LOGGER_DEBUG("No j queue"); | ||
374 | 376 | ||
375 | if ( call->cs ) { | 377 | if ( call->cs ) { |
376 | codec_terminate_session(call->cs); | 378 | codec_terminate_session(call->cs); |
377 | call->cs = NULL; | 379 | call->cs = NULL; |
380 | LOGGER_DEBUG("Terminated codec session"); | ||
378 | } | 381 | } |
382 | else LOGGER_DEBUG("No codec session"); | ||
379 | 383 | ||
380 | return ErrorNone; | 384 | return ErrorNone; |
381 | } | 385 | } |
@@ -392,7 +396,7 @@ int toxav_kill_transmission ( ToxAv *av, uint32_t call_index ) | |||
392 | * @retval 0 Success. | 396 | * @retval 0 Success. |
393 | * @retval -1 Failure. | 397 | * @retval -1 Failure. |
394 | */ | 398 | */ |
395 | inline__ int toxav_send_rtp_payload ( ToxAv *av, uint32_t call_index, ToxAvCallType type, const uint8_t *payload, uint16_t length ) | 399 | inline__ int toxav_send_rtp_payload ( ToxAv *av, int32_t call_index, ToxAvCallType type, const uint8_t *payload, uint16_t length ) |
396 | { | 400 | { |
397 | if ( av->calls[call_index].crtps[type - TypeAudio] ) | 401 | if ( av->calls[call_index].crtps[type - TypeAudio] ) |
398 | return rtp_send_msg ( av->calls[call_index].crtps[type - TypeAudio], av->msi_session->messenger_handle, payload, length ); | 402 | return rtp_send_msg ( av->calls[call_index].crtps[type - TypeAudio], av->msi_session->messenger_handle, payload, length ); |
@@ -409,7 +413,7 @@ inline__ int toxav_send_rtp_payload ( ToxAv *av, uint32_t call_index, ToxAvCallT | |||
409 | * @retval ToxAvError On Error. | 413 | * @retval ToxAvError On Error. |
410 | * @retval >=0 Size of received payload. | 414 | * @retval >=0 Size of received payload. |
411 | */ | 415 | */ |
412 | inline__ int toxav_recv_rtp_payload ( ToxAv *av, uint32_t call_index, ToxAvCallType type, uint8_t *dest ) | 416 | inline__ int toxav_recv_rtp_payload ( ToxAv *av, int32_t call_index, ToxAvCallType type, uint8_t *dest ) |
413 | { | 417 | { |
414 | if ( !dest ) return ErrorInternal; | 418 | if ( !dest ) return ErrorInternal; |
415 | 419 | ||
@@ -460,7 +464,7 @@ inline__ int toxav_recv_rtp_payload ( ToxAv *av, uint32_t call_index, ToxAvCallT | |||
460 | * @retval 0 Success. | 464 | * @retval 0 Success. |
461 | * @retval ToxAvError On Error. | 465 | * @retval ToxAvError On Error. |
462 | */ | 466 | */ |
463 | inline__ int toxav_recv_video ( ToxAv *av, uint32_t call_index, vpx_image_t **output) | 467 | inline__ int toxav_recv_video ( ToxAv *av, int32_t call_index, vpx_image_t **output) |
464 | { | 468 | { |
465 | if ( !output ) return ErrorInternal; | 469 | if ( !output ) return ErrorInternal; |
466 | 470 | ||
@@ -496,7 +500,7 @@ inline__ int toxav_recv_video ( ToxAv *av, uint32_t call_index, vpx_image_t **ou | |||
496 | * @retval 0 Success. | 500 | * @retval 0 Success. |
497 | * @retval ToxAvError On error. | 501 | * @retval ToxAvError On error. |
498 | */ | 502 | */ |
499 | inline__ int toxav_send_video ( ToxAv *av, uint32_t call_index, const uint8_t* frame, int frame_size) | 503 | inline__ int toxav_send_video ( ToxAv *av, int32_t call_index, const uint8_t* frame, int frame_size) |
500 | { | 504 | { |
501 | return toxav_send_rtp_payload(av, call_index, TypeVideo, frame, frame_size); | 505 | return toxav_send_rtp_payload(av, call_index, TypeVideo, frame, frame_size); |
502 | } | 506 | } |
@@ -512,7 +516,7 @@ inline__ int toxav_send_video ( ToxAv *av, uint32_t call_index, const uint8_t* f | |||
512 | * @retval ToxAvError On error. | 516 | * @retval ToxAvError On error. |
513 | * @retval >0 On success | 517 | * @retval >0 On success |
514 | */ | 518 | */ |
515 | inline__ int toxav_prepare_video_frame(ToxAv* av, uint32_t call_index, uint8_t* dest, int dest_max, vpx_image_t* input) | 519 | inline__ int toxav_prepare_video_frame(ToxAv* av, int32_t call_index, uint8_t* dest, int dest_max, vpx_image_t* input) |
516 | { | 520 | { |
517 | CallSpecific* call = &av->calls[call_index]; | 521 | CallSpecific* call = &av->calls[call_index]; |
518 | 522 | ||
@@ -551,7 +555,7 @@ inline__ int toxav_prepare_video_frame(ToxAv* av, uint32_t call_index, uint8_t* | |||
551 | * @retval >=0 Size of received data in frames/samples. | 555 | * @retval >=0 Size of received data in frames/samples. |
552 | * @retval ToxAvError On error. | 556 | * @retval ToxAvError On error. |
553 | */ | 557 | */ |
554 | inline__ int toxav_recv_audio ( ToxAv *av, uint32_t call_index, int frame_size, int16_t *dest ) | 558 | inline__ int toxav_recv_audio ( ToxAv *av, int32_t call_index, int frame_size, int16_t *dest ) |
555 | { | 559 | { |
556 | if ( !dest ) return ErrorInternal; | 560 | if ( !dest ) return ErrorInternal; |
557 | 561 | ||
@@ -592,7 +596,7 @@ inline__ int toxav_recv_audio ( ToxAv *av, uint32_t call_index, int frame_size, | |||
592 | * @retval 0 Success. | 596 | * @retval 0 Success. |
593 | * @retval ToxAvError On error. | 597 | * @retval ToxAvError On error. |
594 | */ | 598 | */ |
595 | inline__ int toxav_send_audio ( ToxAv *av, uint32_t call_index, const uint8_t *frame, int frame_size) | 599 | inline__ int toxav_send_audio ( ToxAv *av, int32_t call_index, const uint8_t *frame, int frame_size) |
596 | { | 600 | { |
597 | return toxav_send_rtp_payload(av, call_index, TypeAudio, frame, frame_size); | 601 | return toxav_send_rtp_payload(av, call_index, TypeAudio, frame, frame_size); |
598 | } | 602 | } |
@@ -609,7 +613,7 @@ inline__ int toxav_send_audio ( ToxAv *av, uint32_t call_index, const uint8_t *f | |||
609 | * @retval ToxAvError On error. | 613 | * @retval ToxAvError On error. |
610 | * @retval >0 On success | 614 | * @retval >0 On success |
611 | */ | 615 | */ |
612 | inline__ int toxav_prepare_audio_frame ( ToxAv* av, uint32_t call_index, uint8_t* dest, int dest_max, const int16_t* frame, int frame_size) | 616 | inline__ int toxav_prepare_audio_frame ( ToxAv* av, int32_t call_index, uint8_t* dest, int dest_max, const int16_t* frame, int frame_size) |
613 | { | 617 | { |
614 | int32_t rc = opus_encode(av->calls[call_index].cs->audio_encoder, frame, frame_size, dest, dest_max); | 618 | int32_t rc = opus_encode(av->calls[call_index].cs->audio_encoder, frame, frame_size, dest, dest_max); |
615 | 619 | ||
@@ -629,7 +633,7 @@ inline__ int toxav_prepare_audio_frame ( ToxAv* av, uint32_t call_index, uint8_t | |||
629 | * @retval ToxAvCallType On success. | 633 | * @retval ToxAvCallType On success. |
630 | * @retval ToxAvError On error. | 634 | * @retval ToxAvError On error. |
631 | */ | 635 | */ |
632 | int toxav_get_peer_transmission_type ( ToxAv *av, uint32_t call_index, int peer ) | 636 | int toxav_get_peer_transmission_type ( ToxAv *av, int32_t call_index, int peer ) |
633 | { | 637 | { |
634 | assert(av->msi_session); | 638 | assert(av->msi_session); |
635 | 639 | ||
@@ -647,7 +651,7 @@ int toxav_get_peer_transmission_type ( ToxAv *av, uint32_t call_index, int peer | |||
647 | * @return int | 651 | * @return int |
648 | * @retval ToxAvError No peer id | 652 | * @retval ToxAvError No peer id |
649 | */ | 653 | */ |
650 | int toxav_get_peer_id ( ToxAv* av, uint32_t call_index, int peer ) | 654 | int toxav_get_peer_id ( ToxAv* av, int32_t call_index, int peer ) |
651 | { | 655 | { |
652 | assert(av->msi_session); | 656 | assert(av->msi_session); |
653 | 657 | ||
@@ -665,9 +669,10 @@ int toxav_get_peer_id ( ToxAv* av, uint32_t call_index, int peer ) | |||
665 | * @retval 1 Yes. | 669 | * @retval 1 Yes. |
666 | * @retval 0 No. | 670 | * @retval 0 No. |
667 | */ | 671 | */ |
668 | inline__ int toxav_capability_supported ( ToxAv* av, uint32_t call_index, ToxAvCapabilities capability ) | 672 | inline__ int toxav_capability_supported ( ToxAv* av, int32_t call_index, ToxAvCapabilities capability ) |
669 | { | 673 | { |
670 | return av->calls[call_index].cs->capabilities & (Capabilities) capability; | 674 | return av->calls[call_index].cs ? av->calls[call_index].cs->capabilities & (Capabilities) capability : 0; |
675 | /* 0 is error here */ | ||
671 | } | 676 | } |
672 | 677 | ||
673 | /** | 678 | /** |
@@ -678,9 +683,14 @@ inline__ int toxav_capability_supported ( ToxAv* av, uint32_t call_index, ToxAvC | |||
678 | * @param limit the limit | 683 | * @param limit the limit |
679 | * @return void | 684 | * @return void |
680 | */ | 685 | */ |
681 | void toxav_set_audio_queue_limit(ToxAv* av, uint32_t call_index, uint64_t limit) | 686 | inline__ int toxav_set_audio_queue_limit(ToxAv* av, int32_t call_index, uint64_t limit) |
682 | { | 687 | { |
683 | rtp_queue_adjust_limit(av->calls[call_index].crtps[audio_index], limit); | 688 | if ( av->calls[call_index].crtps[audio_index] ) |
689 | rtp_queue_adjust_limit(av->calls[call_index].crtps[audio_index], limit); | ||
690 | else | ||
691 | return ErrorNoRtpSession; | ||
692 | |||
693 | return ErrorNone; | ||
684 | } | 694 | } |
685 | 695 | ||
686 | /** | 696 | /** |
@@ -691,7 +701,17 @@ void toxav_set_audio_queue_limit(ToxAv* av, uint32_t call_index, uint64_t limit) | |||
691 | * @param limit the limit | 701 | * @param limit the limit |
692 | * @return void | 702 | * @return void |
693 | */ | 703 | */ |
694 | void toxav_set_video_queue_limit(ToxAv* av, uint32_t call_index, uint64_t limit) | 704 | inline__ int toxav_set_video_queue_limit(ToxAv* av, int32_t call_index, uint64_t limit) |
695 | { | 705 | { |
696 | rtp_queue_adjust_limit(av->calls[call_index].crtps[video_index], limit); | 706 | if ( av->calls[call_index].crtps[video_index] ) |
707 | rtp_queue_adjust_limit(av->calls[call_index].crtps[video_index], limit); | ||
708 | else | ||
709 | return ErrorNoRtpSession; | ||
710 | |||
711 | return ErrorNone; | ||
697 | } | 712 | } |
713 | |||
714 | inline__ Tox* toxav_get_tox(ToxAv* av) | ||
715 | { | ||
716 | return (Tox*)av->messenger; | ||
717 | } \ No newline at end of file | ||
diff --git a/toxav/toxav.h b/toxav/toxav.h index 6dac966b..74f2333b 100755 --- a/toxav/toxav.h +++ b/toxav/toxav.h | |||
@@ -29,7 +29,7 @@ | |||
29 | /* vpx_image_t */ | 29 | /* vpx_image_t */ |
30 | #include <vpx/vpx_image.h> | 30 | #include <vpx/vpx_image.h> |
31 | 31 | ||
32 | typedef void ( *ToxAVCallback ) ( uint32_t, void *arg ); | 32 | typedef void ( *ToxAVCallback ) ( int32_t, void *arg ); |
33 | typedef struct _ToxAv ToxAv; | 33 | typedef struct _ToxAv ToxAv; |
34 | 34 | ||
35 | #ifndef __TOX_DEFINED__ | 35 | #ifndef __TOX_DEFINED__ |
@@ -133,7 +133,7 @@ extern const ToxAvCodecSettings av_DefaultSettings; | |||
133 | * @return ToxAv* | 133 | * @return ToxAv* |
134 | * @retval NULL On error. | 134 | * @retval NULL On error. |
135 | */ | 135 | */ |
136 | ToxAv *toxav_new(Tox *messenger, uint32_t max_calls); | 136 | ToxAv *toxav_new(Tox *messenger, int32_t max_calls); |
137 | 137 | ||
138 | /** | 138 | /** |
139 | * @brief Remove A/V session. | 139 | * @brief Remove A/V session. |
@@ -163,7 +163,7 @@ void toxav_register_callstate_callback (ToxAVCallback callback, ToxAvCallbackID | |||
163 | * @retval 0 Success. | 163 | * @retval 0 Success. |
164 | * @retval ToxAvError On error. | 164 | * @retval ToxAvError On error. |
165 | */ | 165 | */ |
166 | int toxav_call(ToxAv *av, uint32_t* call_index, int user, ToxAvCallType call_type, int ringing_seconds); | 166 | int toxav_call(ToxAv *av, int32_t* call_index, int user, ToxAvCallType call_type, int ringing_seconds); |
167 | 167 | ||
168 | /** | 168 | /** |
169 | * @brief Hangup active call. | 169 | * @brief Hangup active call. |
@@ -173,7 +173,7 @@ int toxav_call(ToxAv *av, uint32_t* call_index, int user, ToxAvCallType call_typ | |||
173 | * @retval 0 Success. | 173 | * @retval 0 Success. |
174 | * @retval ToxAvError On error. | 174 | * @retval ToxAvError On error. |
175 | */ | 175 | */ |
176 | int toxav_hangup(ToxAv *av, uint32_t call_index); | 176 | int toxav_hangup(ToxAv *av, int32_t call_index); |
177 | 177 | ||
178 | /** | 178 | /** |
179 | * @brief Answer incomming call. | 179 | * @brief Answer incomming call. |
@@ -184,7 +184,7 @@ int toxav_hangup(ToxAv *av, uint32_t call_index); | |||
184 | * @retval 0 Success. | 184 | * @retval 0 Success. |
185 | * @retval ToxAvError On error. | 185 | * @retval ToxAvError On error. |
186 | */ | 186 | */ |
187 | int toxav_answer(ToxAv *av, uint32_t call_index, ToxAvCallType call_type ); | 187 | int toxav_answer(ToxAv *av, int32_t call_index, ToxAvCallType call_type ); |
188 | 188 | ||
189 | /** | 189 | /** |
190 | * @brief Reject incomming call. | 190 | * @brief Reject incomming call. |
@@ -195,7 +195,7 @@ int toxav_answer(ToxAv *av, uint32_t call_index, ToxAvCallType call_type ); | |||
195 | * @retval 0 Success. | 195 | * @retval 0 Success. |
196 | * @retval ToxAvError On error. | 196 | * @retval ToxAvError On error. |
197 | */ | 197 | */ |
198 | int toxav_reject(ToxAv *av, uint32_t call_index, const char *reason); | 198 | int toxav_reject(ToxAv *av, int32_t call_index, const char *reason); |
199 | 199 | ||
200 | /** | 200 | /** |
201 | * @brief Cancel outgoing request. | 201 | * @brief Cancel outgoing request. |
@@ -207,7 +207,7 @@ int toxav_reject(ToxAv *av, uint32_t call_index, const char *reason); | |||
207 | * @retval 0 Success. | 207 | * @retval 0 Success. |
208 | * @retval ToxAvError On error. | 208 | * @retval ToxAvError On error. |
209 | */ | 209 | */ |
210 | int toxav_cancel(ToxAv* av, uint32_t call_index, int peer_id, const char* reason); | 210 | int toxav_cancel(ToxAv* av, int32_t call_index, int peer_id, const char* reason); |
211 | 211 | ||
212 | /** | 212 | /** |
213 | * @brief Terminate transmission. Note that transmission will be terminated without informing remote peer. | 213 | * @brief Terminate transmission. Note that transmission will be terminated without informing remote peer. |
@@ -217,7 +217,7 @@ int toxav_cancel(ToxAv* av, uint32_t call_index, int peer_id, const char* reason | |||
217 | * @retval 0 Success. | 217 | * @retval 0 Success. |
218 | * @retval ToxAvError On error. | 218 | * @retval ToxAvError On error. |
219 | */ | 219 | */ |
220 | int toxav_stop_call(ToxAv *av, uint32_t call_index); | 220 | int toxav_stop_call(ToxAv *av, int32_t call_index); |
221 | 221 | ||
222 | /** | 222 | /** |
223 | * @brief Must be call before any RTP transmission occurs. | 223 | * @brief Must be call before any RTP transmission occurs. |
@@ -228,7 +228,7 @@ int toxav_stop_call(ToxAv *av, uint32_t call_index); | |||
228 | * @retval 0 Success. | 228 | * @retval 0 Success. |
229 | * @retval ToxAvError On error. | 229 | * @retval ToxAvError On error. |
230 | */ | 230 | */ |
231 | int toxav_prepare_transmission(ToxAv* av, uint32_t call_index, ToxAvCodecSettings* codec_settings, int support_video); | 231 | int toxav_prepare_transmission(ToxAv* av, int32_t call_index, ToxAvCodecSettings* codec_settings, int support_video); |
232 | 232 | ||
233 | /** | 233 | /** |
234 | * @brief Call this at the end of the transmission. | 234 | * @brief Call this at the end of the transmission. |
@@ -238,7 +238,7 @@ int toxav_prepare_transmission(ToxAv* av, uint32_t call_index, ToxAvCodecSetting | |||
238 | * @retval 0 Success. | 238 | * @retval 0 Success. |
239 | * @retval ToxAvError On error. | 239 | * @retval ToxAvError On error. |
240 | */ | 240 | */ |
241 | int toxav_kill_transmission(ToxAv *av, uint32_t call_index); | 241 | int toxav_kill_transmission(ToxAv* av, int32_t call_index); |
242 | 242 | ||
243 | /** | 243 | /** |
244 | * @brief Receive decoded video packet. | 244 | * @brief Receive decoded video packet. |
@@ -249,7 +249,7 @@ int toxav_kill_transmission(ToxAv *av, uint32_t call_index); | |||
249 | * @retval 0 Success. | 249 | * @retval 0 Success. |
250 | * @retval ToxAvError On Error. | 250 | * @retval ToxAvError On Error. |
251 | */ | 251 | */ |
252 | int toxav_recv_video ( ToxAv* av, uint32_t call_index, vpx_image_t** output); | 252 | int toxav_recv_video ( ToxAv* av, int32_t call_index, vpx_image_t** output); |
253 | 253 | ||
254 | /** | 254 | /** |
255 | * @brief Receive decoded audio frame. | 255 | * @brief Receive decoded audio frame. |
@@ -263,7 +263,7 @@ int toxav_recv_video ( ToxAv* av, uint32_t call_index, vpx_image_t** output); | |||
263 | * @retval >=0 Size of received data in frames/samples. | 263 | * @retval >=0 Size of received data in frames/samples. |
264 | * @retval ToxAvError On error. | 264 | * @retval ToxAvError On error. |
265 | */ | 265 | */ |
266 | int toxav_recv_audio( ToxAv* av, uint32_t call_index, int frame_size, int16_t* dest ); | 266 | int toxav_recv_audio( ToxAv* av, int32_t call_index, int frame_size, int16_t* dest ); |
267 | 267 | ||
268 | /** | 268 | /** |
269 | * @brief Encode and send video packet. | 269 | * @brief Encode and send video packet. |
@@ -275,7 +275,7 @@ int toxav_recv_audio( ToxAv* av, uint32_t call_index, int frame_size, int16_t* d | |||
275 | * @retval 0 Success. | 275 | * @retval 0 Success. |
276 | * @retval ToxAvError On error. | 276 | * @retval ToxAvError On error. |
277 | */ | 277 | */ |
278 | int toxav_send_video ( ToxAv* av, uint32_t call_index, const uint8_t* frame, int frame_size); | 278 | int toxav_send_video ( ToxAv* av, int32_t call_index, const uint8_t* frame, int frame_size); |
279 | 279 | ||
280 | /** | 280 | /** |
281 | * @brief Send audio frame. | 281 | * @brief Send audio frame. |
@@ -288,7 +288,7 @@ int toxav_send_video ( ToxAv* av, uint32_t call_index, const uint8_t* frame, int | |||
288 | * @retval 0 Success. | 288 | * @retval 0 Success. |
289 | * @retval ToxAvError On error. | 289 | * @retval ToxAvError On error. |
290 | */ | 290 | */ |
291 | int toxav_send_audio ( ToxAv* av, uint32_t call_index, const uint8_t* frame, int frame_size); | 291 | int toxav_send_audio ( ToxAv* av, int32_t call_index, const uint8_t* frame, int frame_size); |
292 | 292 | ||
293 | /** | 293 | /** |
294 | * @brief Encode video frame | 294 | * @brief Encode video frame |
@@ -301,7 +301,7 @@ int toxav_send_audio ( ToxAv* av, uint32_t call_index, const uint8_t* frame, int | |||
301 | * @retval ToxAvError On error. | 301 | * @retval ToxAvError On error. |
302 | * @retval >0 On success | 302 | * @retval >0 On success |
303 | */ | 303 | */ |
304 | int toxav_prepare_video_frame ( ToxAv* av, uint32_t call_index, uint8_t* dest, int dest_max, vpx_image_t* input ); | 304 | int toxav_prepare_video_frame ( ToxAv* av, int32_t call_index, uint8_t* dest, int dest_max, vpx_image_t* input ); |
305 | 305 | ||
306 | /** | 306 | /** |
307 | * @brief Encode audio frame | 307 | * @brief Encode audio frame |
@@ -315,7 +315,7 @@ int toxav_prepare_video_frame ( ToxAv* av, uint32_t call_index, uint8_t* dest, i | |||
315 | * @retval ToxAvError On error. | 315 | * @retval ToxAvError On error. |
316 | * @retval >0 On success | 316 | * @retval >0 On success |
317 | */ | 317 | */ |
318 | int toxav_prepare_audio_frame ( ToxAv* av, uint32_t call_index, uint8_t* dest, int dest_max, const int16_t* frame, int frame_size); | 318 | int toxav_prepare_audio_frame ( ToxAv* av, int32_t call_index, uint8_t* dest, int dest_max, const int16_t* frame, int frame_size); |
319 | 319 | ||
320 | /** | 320 | /** |
321 | * @brief Get peer transmission type. It can either be audio or video. | 321 | * @brief Get peer transmission type. It can either be audio or video. |
@@ -326,7 +326,7 @@ int toxav_prepare_audio_frame ( ToxAv* av, uint32_t call_index, uint8_t* dest, i | |||
326 | * @retval ToxAvCallType On success. | 326 | * @retval ToxAvCallType On success. |
327 | * @retval ToxAvError On error. | 327 | * @retval ToxAvError On error. |
328 | */ | 328 | */ |
329 | int toxav_get_peer_transmission_type ( ToxAv *av, uint32_t call_index, int peer ); | 329 | int toxav_get_peer_transmission_type ( ToxAv* av, int32_t call_index, int peer ); |
330 | 330 | ||
331 | /** | 331 | /** |
332 | * @brief Get id of peer participating in conversation | 332 | * @brief Get id of peer participating in conversation |
@@ -336,7 +336,7 @@ int toxav_get_peer_transmission_type ( ToxAv *av, uint32_t call_index, int peer | |||
336 | * @return int | 336 | * @return int |
337 | * @retval ToxAvError No peer id | 337 | * @retval ToxAvError No peer id |
338 | */ | 338 | */ |
339 | int toxav_get_peer_id ( ToxAv* av, uint32_t call_index, int peer ); | 339 | int toxav_get_peer_id ( ToxAv* av, int32_t call_index, int peer ); |
340 | 340 | ||
341 | /** | 341 | /** |
342 | * @brief Is certain capability supported | 342 | * @brief Is certain capability supported |
@@ -346,7 +346,7 @@ int toxav_get_peer_id ( ToxAv* av, uint32_t call_index, int peer ); | |||
346 | * @retval 1 Yes. | 346 | * @retval 1 Yes. |
347 | * @retval 0 No. | 347 | * @retval 0 No. |
348 | */ | 348 | */ |
349 | int toxav_capability_supported ( ToxAv* av, uint32_t call_index, ToxAvCapabilities capability ); | 349 | int toxav_capability_supported ( ToxAv* av, int32_t call_index, ToxAvCapabilities capability ); |
350 | 350 | ||
351 | /** | 351 | /** |
352 | * @brief Set queue limit | 352 | * @brief Set queue limit |
@@ -356,7 +356,7 @@ int toxav_capability_supported ( ToxAv* av, uint32_t call_index, ToxAvCapabiliti | |||
356 | * @param limit the limit | 356 | * @param limit the limit |
357 | * @return void | 357 | * @return void |
358 | */ | 358 | */ |
359 | void toxav_set_audio_queue_limit ( ToxAv* av, uint32_t call_index, uint64_t limit ); | 359 | int toxav_set_audio_queue_limit ( ToxAv* av, int32_t call_index, uint64_t limit ); |
360 | 360 | ||
361 | /** | 361 | /** |
362 | * @brief Set queue limit | 362 | * @brief Set queue limit |
@@ -366,6 +366,8 @@ void toxav_set_audio_queue_limit ( ToxAv* av, uint32_t call_index, uint64_t limi | |||
366 | * @param limit the limit | 366 | * @param limit the limit |
367 | * @return void | 367 | * @return void |
368 | */ | 368 | */ |
369 | void toxav_set_video_queue_limit ( ToxAv* av, uint32_t call_index, uint64_t limit ); | 369 | int toxav_set_video_queue_limit ( ToxAv* av, int32_t call_index, uint64_t limit ); |
370 | 370 | ||
371 | |||
372 | Tox* toxav_get_tox(ToxAv* av); | ||
371 | #endif /* __TOXAV */ \ No newline at end of file | 373 | #endif /* __TOXAV */ \ No newline at end of file |
diff --git a/toxcore/Messenger.c b/toxcore/Messenger.c index 2033e6a9..f5ed14b1 100644 --- a/toxcore/Messenger.c +++ b/toxcore/Messenger.c | |||
@@ -2275,7 +2275,7 @@ void do_messenger(Messenger *m) | |||
2275 | if (last_pinged > 999) | 2275 | if (last_pinged > 999) |
2276 | last_pinged = 999; | 2276 | last_pinged = 999; |
2277 | 2277 | ||
2278 | LOGGER_DEBUG("C[%2u] %s:%u [%3u] %s", | 2278 | LOGGER_INFO("C[%2u] %s:%u [%3u] %s", |
2279 | client, ip_ntoa(&assoc->ip_port.ip), ntohs(assoc->ip_port.port), | 2279 | client, ip_ntoa(&assoc->ip_port.ip), ntohs(assoc->ip_port.port), |
2280 | last_pinged, ID2String(cptr->client_id)); | 2280 | last_pinged, ID2String(cptr->client_id)); |
2281 | } | 2281 | } |
@@ -2308,7 +2308,7 @@ void do_messenger(Messenger *m) | |||
2308 | dht2m[m2dht[friend]] = friend; | 2308 | dht2m[m2dht[friend]] = friend; |
2309 | 2309 | ||
2310 | if (m->numfriends != m->dht->num_friends) { | 2310 | if (m->numfriends != m->dht->num_friends) { |
2311 | LOGGER_DEBUG("Friend num in DHT %u != friend num in msger %u\n", m->dht->num_friends, m->numfriends); | 2311 | LOGGER_INFO("Friend num in DHT %u != friend num in msger %u\n", m->dht->num_friends, m->numfriends); |
2312 | } | 2312 | } |
2313 | 2313 | ||
2314 | uint32_t ping_lastrecv; | 2314 | uint32_t ping_lastrecv; |
@@ -2329,11 +2329,11 @@ void do_messenger(Messenger *m) | |||
2329 | if (ping_lastrecv > 999) | 2329 | if (ping_lastrecv > 999) |
2330 | ping_lastrecv = 999; | 2330 | ping_lastrecv = 999; |
2331 | 2331 | ||
2332 | LOGGER_DEBUG("F[%2u:%2u] <%s> %02i [%03u] %s", | 2332 | LOGGER_INFO("F[%2u:%2u] <%s> %02i [%03u] %s", |
2333 | dht2m[friend], friend, msgfptr->name, msgfptr->crypt_connection_id, | 2333 | dht2m[friend], friend, msgfptr->name, msgfptr->crypt_connection_id, |
2334 | ping_lastrecv, ID2String(msgfptr->client_id)); | 2334 | ping_lastrecv, ID2String(msgfptr->client_id)); |
2335 | } else { | 2335 | } else { |
2336 | LOGGER_DEBUG("F[--:%2u] %s", friend, ID2String(dhtfptr->client_id)); | 2336 | LOGGER_INFO("F[--:%2u] %s", friend, ID2String(dhtfptr->client_id)); |
2337 | } | 2337 | } |
2338 | 2338 | ||
2339 | for (client = 0; client < MAX_FRIEND_CLIENTS; client++) { | 2339 | for (client = 0; client < MAX_FRIEND_CLIENTS; client++) { |
@@ -2348,7 +2348,7 @@ void do_messenger(Messenger *m) | |||
2348 | if (last_pinged > 999) | 2348 | if (last_pinged > 999) |
2349 | last_pinged = 999; | 2349 | last_pinged = 999; |
2350 | 2350 | ||
2351 | LOGGER_DEBUG("F[%2u] => C[%2u] %s:%u [%3u] %s", | 2351 | LOGGER_INFO("F[%2u] => C[%2u] %s:%u [%3u] %s", |
2352 | friend, client, ip_ntoa(&assoc->ip_port.ip), | 2352 | friend, client, ip_ntoa(&assoc->ip_port.ip), |
2353 | ntohs(assoc->ip_port.port), last_pinged, | 2353 | ntohs(assoc->ip_port.port), last_pinged, |
2354 | ID2String(cptr->client_id)); | 2354 | ID2String(cptr->client_id)); |
diff --git a/toxcore/logger.c b/toxcore/logger.c index e700fe71..ff9146d4 100644 --- a/toxcore/logger.c +++ b/toxcore/logger.c | |||
@@ -60,8 +60,8 @@ void __attribute__((destructor)) terminate_logger() | |||
60 | 60 | ||
61 | time_t tim = time(NULL); | 61 | time_t tim = time(NULL); |
62 | 62 | ||
63 | logger_write(ERROR, "============== Closing logger ==============\n" | 63 | logger_write(ERROR, "\n============== Closing logger [%u] ==============\n" |
64 | "Time: %s", asctime(localtime(&tim))); | 64 | "Time: %s", logger_get_pid(), asctime(localtime(&tim))); |
65 | 65 | ||
66 | fclose(logger.log_file); | 66 | fclose(logger.log_file); |
67 | } | 67 | } |
@@ -96,12 +96,12 @@ int logger_init(const char* file_name, LoggerLevel level) | |||
96 | sprintf(final_l, "%s"/*.%u"*/, file_name, logger_get_pid()); | 96 | sprintf(final_l, "%s"/*.%u"*/, file_name, logger_get_pid()); |
97 | 97 | ||
98 | if ( logger.log_file ) { | 98 | if ( logger.log_file ) { |
99 | fprintf(stderr, "Error opening logger name: %s with level %d: already opened!\n", final_l, level); | 99 | fprintf(stderr, "Error opening logger name: %s with level %d: %s!\n", final_l, level, strerror(errno)); |
100 | free (final_l); | 100 | free (final_l); |
101 | return -1; | 101 | return -1; |
102 | } | 102 | } |
103 | 103 | ||
104 | logger.log_file = fopen(final_l, "wb"); | 104 | logger.log_file = fopen(final_l, "ab"); |
105 | 105 | ||
106 | if ( logger.log_file == NULL ) { | 106 | if ( logger.log_file == NULL ) { |
107 | char error[1000]; | 107 | char error[1000]; |
@@ -120,8 +120,8 @@ int logger_init(const char* file_name, LoggerLevel level) | |||
120 | 120 | ||
121 | 121 | ||
122 | time_t tim = time(NULL); | 122 | time_t tim = time(NULL); |
123 | logger_write(ERROR, "============== Starting logger ==============\n" | 123 | logger_write(ERROR, "\n============== Starting logger [%u] ==============\n" |
124 | "Time: %s", asctime(localtime(&tim))); | 124 | "Time: %s", logger_get_pid(), asctime(localtime(&tim))); |
125 | 125 | ||
126 | 126 | ||
127 | 127 | ||
diff --git a/toxcore/logger.h b/toxcore/logger.h index abef4b84..d8292f31 100644 --- a/toxcore/logger.h +++ b/toxcore/logger.h | |||
@@ -53,7 +53,7 @@ char* logger_timestr (char* dest); | |||
53 | #define _SFILE (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__) | 53 | #define _SFILE (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__) |
54 | #endif | 54 | #endif |
55 | 55 | ||
56 | #define WRITE_FORMAT(__LEVEL__, format) char* the_str = calloc(sizeof(char), strlen(format)+ 500); sprintf(the_str, "[%u] [%s] [%s] [%s:%d %s()] %s\n", \ | 56 | #define WRITE_FORMAT(__LEVEL__, format) char* the_str = calloc(sizeof(char), strlen(format)+ 500); sprintf(the_str, "\n[%u] [%s] [%s] [%s:%d %s()] %s", \ |
57 | logger_get_pid(), logger_stringify_level(__LEVEL__), logger_timestr(__time__), _SFILE, __LINE__, __func__, format) | 57 | logger_get_pid(), logger_stringify_level(__LEVEL__), logger_timestr(__time__), _SFILE, __LINE__, __func__, format) |
58 | 58 | ||
59 | /* Use these macros */ | 59 | /* Use these macros */ |
diff --git a/toxcore/network.c b/toxcore/network.c index 7262f352..5980abe3 100644 --- a/toxcore/network.c +++ b/toxcore/network.c | |||
@@ -374,7 +374,7 @@ void networking_poll(Networking_Core *net) | |||
374 | if (length < 1) continue; | 374 | if (length < 1) continue; |
375 | 375 | ||
376 | if (!(net->packethandlers[data[0]].function)) { | 376 | if (!(net->packethandlers[data[0]].function)) { |
377 | LOGGER_WARNING("[%02u] -- Packet has no handler.\n", data[0]); | 377 | LOGGER_WARNING("[%02u] -- Packet has no handler", data[0]); |
378 | continue; | 378 | continue; |
379 | } | 379 | } |
380 | 380 | ||