diff options
author | iphydf <iphydf@users.noreply.github.com> | 2018-08-12 12:53:12 +0000 |
---|---|---|
committer | iphydf <iphydf@users.noreply.github.com> | 2018-08-12 20:07:18 +0000 |
commit | 4ed6e5999226f9061f546108c5be72fe6f21a775 (patch) | |
tree | e716af08ec232c8d01b526d7b88c5ed502cd6a77 | |
parent | 767ccbb387a462c9bc21aaf22d2c3d3358c147b8 (diff) |
Fix enumerator names to comply with toxcore naming standards.
-rw-r--r-- | toxav/audio.c | 4 | ||||
-rw-r--r-- | toxav/msi.c | 120 | ||||
-rw-r--r-- | toxav/msi.h | 44 | ||||
-rw-r--r-- | toxav/rtp.c | 8 | ||||
-rw-r--r-- | toxav/rtp.h | 4 | ||||
-rw-r--r-- | toxav/toxav.c | 84 | ||||
-rw-r--r-- | toxav/video.c | 6 |
7 files changed, 135 insertions, 135 deletions
diff --git a/toxav/audio.c b/toxav/audio.c index 99bb7c97..729a4922 100644 --- a/toxav/audio.c +++ b/toxav/audio.c | |||
@@ -222,13 +222,13 @@ int ac_queue_message(void *acp, struct RTPMessage *msg) | |||
222 | 222 | ||
223 | ACSession *ac = (ACSession *)acp; | 223 | ACSession *ac = (ACSession *)acp; |
224 | 224 | ||
225 | if ((msg->header.pt & 0x7f) == (rtp_TypeAudio + 2) % 128) { | 225 | if ((msg->header.pt & 0x7f) == (RTP_TYPE_AUDIO + 2) % 128) { |
226 | LOGGER_WARNING(ac->log, "Got dummy!"); | 226 | LOGGER_WARNING(ac->log, "Got dummy!"); |
227 | free(msg); | 227 | free(msg); |
228 | return 0; | 228 | return 0; |
229 | } | 229 | } |
230 | 230 | ||
231 | if ((msg->header.pt & 0x7f) != rtp_TypeAudio % 128) { | 231 | if ((msg->header.pt & 0x7f) != RTP_TYPE_AUDIO % 128) { |
232 | LOGGER_WARNING(ac->log, "Invalid payload type!"); | 232 | LOGGER_WARNING(ac->log, "Invalid payload type!"); |
233 | free(msg); | 233 | free(msg); |
234 | return -1; | 234 | return -1; |
diff --git a/toxav/msi.c b/toxav/msi.c index f1242228..dd9f5fba 100644 --- a/toxav/msi.c +++ b/toxav/msi.c | |||
@@ -41,16 +41,16 @@ | |||
41 | */ | 41 | */ |
42 | 42 | ||
43 | typedef enum { | 43 | typedef enum { |
44 | IDRequest = 1, | 44 | ID_REQUEST = 1, |
45 | IDError, | 45 | ID_ERROR, |
46 | IDCapabilities, | 46 | ID_CAPABILITIES, |
47 | } MSIHeaderID; | 47 | } MSIHeaderID; |
48 | 48 | ||
49 | 49 | ||
50 | typedef enum { | 50 | typedef enum { |
51 | requ_init, | 51 | REQU_INIT, |
52 | requ_push, | 52 | REQU_PUSH, |
53 | requ_pop, | 53 | REQU_POP, |
54 | } MSIRequest; | 54 | } MSIRequest; |
55 | 55 | ||
56 | 56 | ||
@@ -147,7 +147,7 @@ int msi_kill(MSISession *session, const Logger *log) | |||
147 | 147 | ||
148 | if (session->calls) { | 148 | if (session->calls) { |
149 | MSIMessage msg; | 149 | MSIMessage msg; |
150 | msg_init(&msg, requ_pop); | 150 | msg_init(&msg, REQU_POP); |
151 | 151 | ||
152 | MSICall *it = get_call(session, session->calls_head); | 152 | MSICall *it = get_call(session, session->calls_head); |
153 | 153 | ||
@@ -195,14 +195,14 @@ int msi_invite(MSISession *session, MSICall **call, uint32_t friend_number, uint | |||
195 | (*call)->self_capabilities = capabilities; | 195 | (*call)->self_capabilities = capabilities; |
196 | 196 | ||
197 | MSIMessage msg; | 197 | MSIMessage msg; |
198 | msg_init(&msg, requ_init); | 198 | msg_init(&msg, REQU_INIT); |
199 | 199 | ||
200 | msg.capabilities.exists = true; | 200 | msg.capabilities.exists = true; |
201 | msg.capabilities.value = capabilities; | 201 | msg.capabilities.value = capabilities; |
202 | 202 | ||
203 | send_message((*call)->session->messenger, (*call)->friend_number, &msg); | 203 | send_message((*call)->session->messenger, (*call)->friend_number, &msg); |
204 | 204 | ||
205 | (*call)->state = msi_CallRequesting; | 205 | (*call)->state = MSI_CALL_REQUESTING; |
206 | 206 | ||
207 | LOGGER_DEBUG(session->messenger->log, "Invite sent"); | 207 | LOGGER_DEBUG(session->messenger->log, "Invite sent"); |
208 | pthread_mutex_unlock(session->mutex); | 208 | pthread_mutex_unlock(session->mutex); |
@@ -224,14 +224,14 @@ int msi_hangup(MSICall *call) | |||
224 | return -1; | 224 | return -1; |
225 | } | 225 | } |
226 | 226 | ||
227 | if (call->state == msi_CallInactive) { | 227 | if (call->state == MSI_CALL_INACTIVE) { |
228 | LOGGER_ERROR(session->messenger->log, "Call is in invalid state!"); | 228 | LOGGER_ERROR(session->messenger->log, "Call is in invalid state!"); |
229 | pthread_mutex_unlock(session->mutex); | 229 | pthread_mutex_unlock(session->mutex); |
230 | return -1; | 230 | return -1; |
231 | } | 231 | } |
232 | 232 | ||
233 | MSIMessage msg; | 233 | MSIMessage msg; |
234 | msg_init(&msg, requ_pop); | 234 | msg_init(&msg, REQU_POP); |
235 | 235 | ||
236 | send_message(session->messenger, call->friend_number, &msg); | 236 | send_message(session->messenger, call->friend_number, &msg); |
237 | 237 | ||
@@ -255,7 +255,7 @@ int msi_answer(MSICall *call, uint8_t capabilities) | |||
255 | return -1; | 255 | return -1; |
256 | } | 256 | } |
257 | 257 | ||
258 | if (call->state != msi_CallRequested) { | 258 | if (call->state != MSI_CALL_REQUESTED) { |
259 | /* Though sending in invalid state will not cause anything weird | 259 | /* Though sending in invalid state will not cause anything weird |
260 | * Its better to not do it like a maniac */ | 260 | * Its better to not do it like a maniac */ |
261 | LOGGER_ERROR(session->messenger->log, "Call is in invalid state!"); | 261 | LOGGER_ERROR(session->messenger->log, "Call is in invalid state!"); |
@@ -266,14 +266,14 @@ int msi_answer(MSICall *call, uint8_t capabilities) | |||
266 | call->self_capabilities = capabilities; | 266 | call->self_capabilities = capabilities; |
267 | 267 | ||
268 | MSIMessage msg; | 268 | MSIMessage msg; |
269 | msg_init(&msg, requ_push); | 269 | msg_init(&msg, REQU_PUSH); |
270 | 270 | ||
271 | msg.capabilities.exists = true; | 271 | msg.capabilities.exists = true; |
272 | msg.capabilities.value = capabilities; | 272 | msg.capabilities.value = capabilities; |
273 | 273 | ||
274 | send_message(session->messenger, call->friend_number, &msg); | 274 | send_message(session->messenger, call->friend_number, &msg); |
275 | 275 | ||
276 | call->state = msi_CallActive; | 276 | call->state = MSI_CALL_ACTIVE; |
277 | pthread_mutex_unlock(session->mutex); | 277 | pthread_mutex_unlock(session->mutex); |
278 | 278 | ||
279 | return 0; | 279 | return 0; |
@@ -294,7 +294,7 @@ int msi_change_capabilities(MSICall *call, uint8_t capabilities) | |||
294 | return -1; | 294 | return -1; |
295 | } | 295 | } |
296 | 296 | ||
297 | if (call->state != msi_CallActive) { | 297 | if (call->state != MSI_CALL_ACTIVE) { |
298 | LOGGER_ERROR(session->messenger->log, "Call is in invalid state!"); | 298 | LOGGER_ERROR(session->messenger->log, "Call is in invalid state!"); |
299 | pthread_mutex_unlock(session->mutex); | 299 | pthread_mutex_unlock(session->mutex); |
300 | return -1; | 300 | return -1; |
@@ -303,7 +303,7 @@ int msi_change_capabilities(MSICall *call, uint8_t capabilities) | |||
303 | call->self_capabilities = capabilities; | 303 | call->self_capabilities = capabilities; |
304 | 304 | ||
305 | MSIMessage msg; | 305 | MSIMessage msg; |
306 | msg_init(&msg, requ_push); | 306 | msg_init(&msg, REQU_PUSH); |
307 | 307 | ||
308 | msg.capabilities.exists = true; | 308 | msg.capabilities.exists = true; |
309 | msg.capabilities.value = capabilities; | 309 | msg.capabilities.value = capabilities; |
@@ -355,19 +355,19 @@ int msg_parse_in(const Logger *log, MSIMessage *dest, const uint8_t *data, uint1 | |||
355 | 355 | ||
356 | while (*it) {/* until end byte is hit */ | 356 | while (*it) {/* until end byte is hit */ |
357 | switch (*it) { | 357 | switch (*it) { |
358 | case IDRequest: | 358 | case ID_REQUEST: |
359 | CHECK_SIZE(it, size_constraint, 1); | 359 | CHECK_SIZE(it, size_constraint, 1); |
360 | CHECK_ENUM_HIGH(it, requ_pop); | 360 | CHECK_ENUM_HIGH(it, REQU_POP); |
361 | SET_UINT8(MSIRequest, it, dest->request); | 361 | SET_UINT8(MSIRequest, it, dest->request); |
362 | break; | 362 | break; |
363 | 363 | ||
364 | case IDError: | 364 | case ID_ERROR: |
365 | CHECK_SIZE(it, size_constraint, 1); | 365 | CHECK_SIZE(it, size_constraint, 1); |
366 | CHECK_ENUM_HIGH(it, msi_EUndisclosed); | 366 | CHECK_ENUM_HIGH(it, MSI_E_UNDISCLOSED); |
367 | SET_UINT8(MSIError, it, dest->error); | 367 | SET_UINT8(MSIError, it, dest->error); |
368 | break; | 368 | break; |
369 | 369 | ||
370 | case IDCapabilities: | 370 | case ID_CAPABILITIES: |
371 | CHECK_SIZE(it, size_constraint, 1); | 371 | CHECK_SIZE(it, size_constraint, 1); |
372 | SET_UINT8(uint8_t, it, dest->capabilities); | 372 | SET_UINT8(uint8_t, it, dest->capabilities); |
373 | break; | 373 | break; |
@@ -419,7 +419,7 @@ int send_message(Messenger *m, uint32_t friend_number, const MSIMessage *msg) | |||
419 | 419 | ||
420 | if (msg->request.exists) { | 420 | if (msg->request.exists) { |
421 | uint8_t cast = msg->request.value; | 421 | uint8_t cast = msg->request.value; |
422 | it = msg_parse_header_out(IDRequest, it, &cast, | 422 | it = msg_parse_header_out(ID_REQUEST, it, &cast, |
423 | sizeof(cast), &size); | 423 | sizeof(cast), &size); |
424 | } else { | 424 | } else { |
425 | LOGGER_DEBUG(m->log, "Must have request field"); | 425 | LOGGER_DEBUG(m->log, "Must have request field"); |
@@ -428,12 +428,12 @@ int send_message(Messenger *m, uint32_t friend_number, const MSIMessage *msg) | |||
428 | 428 | ||
429 | if (msg->error.exists) { | 429 | if (msg->error.exists) { |
430 | uint8_t cast = msg->error.value; | 430 | uint8_t cast = msg->error.value; |
431 | it = msg_parse_header_out(IDError, it, &cast, | 431 | it = msg_parse_header_out(ID_ERROR, it, &cast, |
432 | sizeof(cast), &size); | 432 | sizeof(cast), &size); |
433 | } | 433 | } |
434 | 434 | ||
435 | if (msg->capabilities.exists) { | 435 | if (msg->capabilities.exists) { |
436 | it = msg_parse_header_out(IDCapabilities, it, &msg->capabilities.value, | 436 | it = msg_parse_header_out(ID_CAPABILITIES, it, &msg->capabilities.value, |
437 | sizeof(msg->capabilities.value), &size); | 437 | sizeof(msg->capabilities.value), &size); |
438 | } | 438 | } |
439 | 439 | ||
@@ -460,7 +460,7 @@ int send_error(Messenger *m, uint32_t friend_number, MSIError error) | |||
460 | LOGGER_DEBUG(m->log, "Sending error: %d to friend: %d", error, friend_number); | 460 | LOGGER_DEBUG(m->log, "Sending error: %d to friend: %d", error, friend_number); |
461 | 461 | ||
462 | MSIMessage msg; | 462 | MSIMessage msg; |
463 | msg_init(&msg, requ_pop); | 463 | msg_init(&msg, REQU_POP); |
464 | 464 | ||
465 | msg.error.exists = true; | 465 | msg.error.exists = true; |
466 | msg.error.value = error; | 466 | msg.error.value = error; |
@@ -489,8 +489,8 @@ FAILURE: | |||
489 | * an error message will be sent to friend | 489 | * an error message will be sent to friend |
490 | */ | 490 | */ |
491 | 491 | ||
492 | if (call->error == msi_ENone) { | 492 | if (call->error == MSI_E_NONE) { |
493 | call->error = msi_EHandle; | 493 | call->error = MSI_E_HANDLE; |
494 | } | 494 | } |
495 | 495 | ||
496 | return -1; | 496 | return -1; |
@@ -614,7 +614,7 @@ void on_peer_status(Messenger *m, uint32_t friend_number, uint8_t status, void * | |||
614 | return; | 614 | return; |
615 | } | 615 | } |
616 | 616 | ||
617 | invoke_callback(call, msi_OnPeerTimeout); /* Failure is ignored */ | 617 | invoke_callback(call, MSI_ON_PEERTIMEOUT); /* Failure is ignored */ |
618 | kill_call(call); | 618 | kill_call(call); |
619 | pthread_mutex_unlock(session->mutex); | 619 | pthread_mutex_unlock(session->mutex); |
620 | } | 620 | } |
@@ -632,23 +632,23 @@ void handle_init(MSICall *call, const MSIMessage *msg) | |||
632 | 632 | ||
633 | if (!msg->capabilities.exists) { | 633 | if (!msg->capabilities.exists) { |
634 | LOGGER_WARNING(call->session->messenger->log, "Session: %p Invalid capabilities on 'init'", (void *)call->session); | 634 | LOGGER_WARNING(call->session->messenger->log, "Session: %p Invalid capabilities on 'init'", (void *)call->session); |
635 | call->error = msi_EInvalidMessage; | 635 | call->error = MSI_E_INVALID_MESSAGE; |
636 | goto FAILURE; | 636 | goto FAILURE; |
637 | } | 637 | } |
638 | 638 | ||
639 | switch (call->state) { | 639 | switch (call->state) { |
640 | case msi_CallInactive: { | 640 | case MSI_CALL_INACTIVE: { |
641 | /* Call requested */ | 641 | /* Call requested */ |
642 | call->peer_capabilities = msg->capabilities.value; | 642 | call->peer_capabilities = msg->capabilities.value; |
643 | call->state = msi_CallRequested; | 643 | call->state = MSI_CALL_REQUESTED; |
644 | 644 | ||
645 | if (invoke_callback(call, msi_OnInvite) == -1) { | 645 | if (invoke_callback(call, MSI_ON_INVITE) == -1) { |
646 | goto FAILURE; | 646 | goto FAILURE; |
647 | } | 647 | } |
648 | } | 648 | } |
649 | break; | 649 | break; |
650 | 650 | ||
651 | case msi_CallActive: { | 651 | case MSI_CALL_ACTIVE: { |
652 | /* If peer sent init while the call is already | 652 | /* If peer sent init while the call is already |
653 | * active it's probable that he is trying to | 653 | * active it's probable that he is trying to |
654 | * re-call us while the call is not terminated | 654 | * re-call us while the call is not terminated |
@@ -659,7 +659,7 @@ void handle_init(MSICall *call, const MSIMessage *msg) | |||
659 | LOGGER_INFO(call->session->messenger->log, "Friend is recalling us"); | 659 | LOGGER_INFO(call->session->messenger->log, "Friend is recalling us"); |
660 | 660 | ||
661 | MSIMessage out_msg; | 661 | MSIMessage out_msg; |
662 | msg_init(&out_msg, requ_push); | 662 | msg_init(&out_msg, REQU_PUSH); |
663 | 663 | ||
664 | out_msg.capabilities.exists = true; | 664 | out_msg.capabilities.exists = true; |
665 | out_msg.capabilities.value = call->self_capabilities; | 665 | out_msg.capabilities.value = call->self_capabilities; |
@@ -672,10 +672,10 @@ void handle_init(MSICall *call, const MSIMessage *msg) | |||
672 | } | 672 | } |
673 | break; | 673 | break; |
674 | 674 | ||
675 | case msi_CallRequested: // fall-through | 675 | case MSI_CALL_REQUESTED: // fall-through |
676 | case msi_CallRequesting: { | 676 | case MSI_CALL_REQUESTING: { |
677 | LOGGER_WARNING(call->session->messenger->log, "Session: %p Invalid state on 'init'", (void *)call->session); | 677 | LOGGER_WARNING(call->session->messenger->log, "Session: %p Invalid state on 'init'", (void *)call->session); |
678 | call->error = msi_EInvalidState; | 678 | call->error = MSI_E_INVALID_STATE; |
679 | goto FAILURE; | 679 | goto FAILURE; |
680 | } | 680 | } |
681 | } | 681 | } |
@@ -694,41 +694,41 @@ void handle_push(MSICall *call, const MSIMessage *msg) | |||
694 | 694 | ||
695 | if (!msg->capabilities.exists) { | 695 | if (!msg->capabilities.exists) { |
696 | LOGGER_WARNING(call->session->messenger->log, "Session: %p Invalid capabilities on 'push'", (void *)call->session); | 696 | LOGGER_WARNING(call->session->messenger->log, "Session: %p Invalid capabilities on 'push'", (void *)call->session); |
697 | call->error = msi_EInvalidMessage; | 697 | call->error = MSI_E_INVALID_MESSAGE; |
698 | goto FAILURE; | 698 | goto FAILURE; |
699 | } | 699 | } |
700 | 700 | ||
701 | switch (call->state) { | 701 | switch (call->state) { |
702 | case msi_CallActive: { | 702 | case MSI_CALL_ACTIVE: { |
703 | /* Only act if capabilities changed */ | 703 | /* Only act if capabilities changed */ |
704 | if (call->peer_capabilities != msg->capabilities.value) { | 704 | if (call->peer_capabilities != msg->capabilities.value) { |
705 | LOGGER_INFO(call->session->messenger->log, "Friend is changing capabilities to: %u", msg->capabilities.value); | 705 | LOGGER_INFO(call->session->messenger->log, "Friend is changing capabilities to: %u", msg->capabilities.value); |
706 | 706 | ||
707 | call->peer_capabilities = msg->capabilities.value; | 707 | call->peer_capabilities = msg->capabilities.value; |
708 | 708 | ||
709 | if (invoke_callback(call, msi_OnCapabilities) == -1) { | 709 | if (invoke_callback(call, MSI_ON_CAPABILITIES) == -1) { |
710 | goto FAILURE; | 710 | goto FAILURE; |
711 | } | 711 | } |
712 | } | 712 | } |
713 | } | 713 | } |
714 | break; | 714 | break; |
715 | 715 | ||
716 | case msi_CallRequesting: { | 716 | case MSI_CALL_REQUESTING: { |
717 | LOGGER_INFO(call->session->messenger->log, "Friend answered our call"); | 717 | LOGGER_INFO(call->session->messenger->log, "Friend answered our call"); |
718 | 718 | ||
719 | /* Call started */ | 719 | /* Call started */ |
720 | call->peer_capabilities = msg->capabilities.value; | 720 | call->peer_capabilities = msg->capabilities.value; |
721 | call->state = msi_CallActive; | 721 | call->state = MSI_CALL_ACTIVE; |
722 | 722 | ||
723 | if (invoke_callback(call, msi_OnStart) == -1) { | 723 | if (invoke_callback(call, MSI_ON_START) == -1) { |
724 | goto FAILURE; | 724 | goto FAILURE; |
725 | } | 725 | } |
726 | } | 726 | } |
727 | break; | 727 | break; |
728 | 728 | ||
729 | /* Pushes during initialization state are ignored */ | 729 | /* Pushes during initialization state are ignored */ |
730 | case msi_CallInactive: // fall-through | 730 | case MSI_CALL_INACTIVE: // fall-through |
731 | case msi_CallRequested: { | 731 | case MSI_CALL_REQUESTED: { |
732 | LOGGER_WARNING(call->session->messenger->log, "Ignoring invalid push"); | 732 | LOGGER_WARNING(call->session->messenger->log, "Ignoring invalid push"); |
733 | } | 733 | } |
734 | break; | 734 | break; |
@@ -752,32 +752,32 @@ void handle_pop(MSICall *call, const MSIMessage *msg) | |||
752 | if (msg->error.exists) { | 752 | if (msg->error.exists) { |
753 | LOGGER_WARNING(call->session->messenger->log, "Friend detected an error: %d", msg->error.value); | 753 | LOGGER_WARNING(call->session->messenger->log, "Friend detected an error: %d", msg->error.value); |
754 | call->error = msg->error.value; | 754 | call->error = msg->error.value; |
755 | invoke_callback(call, msi_OnError); | 755 | invoke_callback(call, MSI_ON_ERROR); |
756 | } else { | 756 | } else { |
757 | switch (call->state) { | 757 | switch (call->state) { |
758 | case msi_CallInactive: { | 758 | case MSI_CALL_INACTIVE: { |
759 | LOGGER_ERROR(call->session->messenger->log, "Handling what should be impossible case"); | 759 | LOGGER_ERROR(call->session->messenger->log, "Handling what should be impossible case"); |
760 | abort(); | 760 | abort(); |
761 | } | 761 | } |
762 | 762 | ||
763 | case msi_CallActive: { | 763 | case MSI_CALL_ACTIVE: { |
764 | /* Hangup */ | 764 | /* Hangup */ |
765 | LOGGER_INFO(call->session->messenger->log, "Friend hung up on us"); | 765 | LOGGER_INFO(call->session->messenger->log, "Friend hung up on us"); |
766 | invoke_callback(call, msi_OnEnd); | 766 | invoke_callback(call, MSI_ON_END); |
767 | } | 767 | } |
768 | break; | 768 | break; |
769 | 769 | ||
770 | case msi_CallRequesting: { | 770 | case MSI_CALL_REQUESTING: { |
771 | /* Reject */ | 771 | /* Reject */ |
772 | LOGGER_INFO(call->session->messenger->log, "Friend rejected our call"); | 772 | LOGGER_INFO(call->session->messenger->log, "Friend rejected our call"); |
773 | invoke_callback(call, msi_OnEnd); | 773 | invoke_callback(call, MSI_ON_END); |
774 | } | 774 | } |
775 | break; | 775 | break; |
776 | 776 | ||
777 | case msi_CallRequested: { | 777 | case MSI_CALL_REQUESTED: { |
778 | /* Cancel */ | 778 | /* Cancel */ |
779 | LOGGER_INFO(call->session->messenger->log, "Friend canceled call invite"); | 779 | LOGGER_INFO(call->session->messenger->log, "Friend canceled call invite"); |
780 | invoke_callback(call, msi_OnEnd); | 780 | invoke_callback(call, MSI_ON_END); |
781 | } | 781 | } |
782 | break; | 782 | break; |
783 | } | 783 | } |
@@ -794,7 +794,7 @@ void handle_msi_packet(Messenger *m, uint32_t friend_number, const uint8_t *data | |||
794 | 794 | ||
795 | if (msg_parse_in(m->log, &msg, data, length) == -1) { | 795 | if (msg_parse_in(m->log, &msg, data, length) == -1) { |
796 | LOGGER_WARNING(m->log, "Error parsing message"); | 796 | LOGGER_WARNING(m->log, "Error parsing message"); |
797 | send_error(m, friend_number, msi_EInvalidMessage); | 797 | send_error(m, friend_number, MSI_E_INVALID_MESSAGE); |
798 | return; | 798 | return; |
799 | } | 799 | } |
800 | 800 | ||
@@ -804,8 +804,8 @@ void handle_msi_packet(Messenger *m, uint32_t friend_number, const uint8_t *data | |||
804 | MSICall *call = get_call(session, friend_number); | 804 | MSICall *call = get_call(session, friend_number); |
805 | 805 | ||
806 | if (call == nullptr) { | 806 | if (call == nullptr) { |
807 | if (msg.request.value != requ_init) { | 807 | if (msg.request.value != REQU_INIT) { |
808 | send_error(m, friend_number, msi_EStrayMessage); | 808 | send_error(m, friend_number, MSI_E_STRAY_MESSAGE); |
809 | pthread_mutex_unlock(session->mutex); | 809 | pthread_mutex_unlock(session->mutex); |
810 | return; | 810 | return; |
811 | } | 811 | } |
@@ -813,22 +813,22 @@ void handle_msi_packet(Messenger *m, uint32_t friend_number, const uint8_t *data | |||
813 | call = new_call(session, friend_number); | 813 | call = new_call(session, friend_number); |
814 | 814 | ||
815 | if (call == nullptr) { | 815 | if (call == nullptr) { |
816 | send_error(m, friend_number, msi_ESystem); | 816 | send_error(m, friend_number, MSI_E_SYSTEM); |
817 | pthread_mutex_unlock(session->mutex); | 817 | pthread_mutex_unlock(session->mutex); |
818 | return; | 818 | return; |
819 | } | 819 | } |
820 | } | 820 | } |
821 | 821 | ||
822 | switch (msg.request.value) { | 822 | switch (msg.request.value) { |
823 | case requ_init: | 823 | case REQU_INIT: |
824 | handle_init(call, &msg); | 824 | handle_init(call, &msg); |
825 | break; | 825 | break; |
826 | 826 | ||
827 | case requ_push: | 827 | case REQU_PUSH: |
828 | handle_push(call, &msg); | 828 | handle_push(call, &msg); |
829 | break; | 829 | break; |
830 | 830 | ||
831 | case requ_pop: | 831 | case REQU_POP: |
832 | handle_pop(call, &msg); /* always kills the call */ | 832 | handle_pop(call, &msg); /* always kills the call */ |
833 | break; | 833 | break; |
834 | } | 834 | } |
diff --git a/toxav/msi.h b/toxav/msi.h index b2c15567..bf3218e0 100644 --- a/toxav/msi.h +++ b/toxav/msi.h | |||
@@ -33,24 +33,24 @@ | |||
33 | * Error codes. | 33 | * Error codes. |
34 | */ | 34 | */ |
35 | typedef enum { | 35 | typedef enum { |
36 | msi_ENone, | 36 | MSI_E_NONE, |
37 | msi_EInvalidMessage, | 37 | MSI_E_INVALID_MESSAGE, |
38 | msi_EInvalidParam, | 38 | MSI_E_INVALID_PARAM, |
39 | msi_EInvalidState, | 39 | MSI_E_INVALID_STATE, |
40 | msi_EStrayMessage, | 40 | MSI_E_STRAY_MESSAGE, |
41 | msi_ESystem, | 41 | MSI_E_SYSTEM, |
42 | msi_EHandle, | 42 | MSI_E_HANDLE, |
43 | msi_EUndisclosed, /* NOTE: must be last enum otherwise parsing will not work */ | 43 | MSI_E_UNDISCLOSED, /* NOTE: must be last enum otherwise parsing will not work */ |
44 | } MSIError; | 44 | } MSIError; |
45 | 45 | ||
46 | /** | 46 | /** |
47 | * Supported capabilities | 47 | * Supported capabilities |
48 | */ | 48 | */ |
49 | typedef enum { | 49 | typedef enum { |
50 | msi_CapSAudio = 4, /* sending audio */ | 50 | MSI_CAP_S_AUDIO = 4, /* sending audio */ |
51 | msi_CapSVideo = 8, /* sending video */ | 51 | MSI_CAP_S_VIDEO = 8, /* sending video */ |
52 | msi_CapRAudio = 16, /* receiving audio */ | 52 | MSI_CAP_R_AUDIO = 16, /* receiving audio */ |
53 | msi_CapRVideo = 32, /* receiving video */ | 53 | MSI_CAP_R_VIDEO = 32, /* receiving video */ |
54 | } MSICapabilities; | 54 | } MSICapabilities; |
55 | 55 | ||
56 | 56 | ||
@@ -58,22 +58,22 @@ typedef enum { | |||
58 | * Call state identifiers. | 58 | * Call state identifiers. |
59 | */ | 59 | */ |
60 | typedef enum { | 60 | typedef enum { |
61 | msi_CallInactive, /* Default */ | 61 | MSI_CALL_INACTIVE, /* Default */ |
62 | msi_CallActive, | 62 | MSI_CALL_ACTIVE, |
63 | msi_CallRequesting, /* when sending call invite */ | 63 | MSI_CALL_REQUESTING, /* when sending call invite */ |
64 | msi_CallRequested, /* when getting call invite */ | 64 | MSI_CALL_REQUESTED, /* when getting call invite */ |
65 | } MSICallState; | 65 | } MSICallState; |
66 | 66 | ||
67 | /** | 67 | /** |
68 | * Callbacks ids that handle the states | 68 | * Callbacks ids that handle the states |
69 | */ | 69 | */ |
70 | typedef enum { | 70 | typedef enum { |
71 | msi_OnInvite, /* Incoming call */ | 71 | MSI_ON_INVITE, /* Incoming call */ |
72 | msi_OnStart, /* Call (RTP transmission) started */ | 72 | MSI_ON_START, /* Call (RTP transmission) started */ |
73 | msi_OnEnd, /* Call that was active ended */ | 73 | MSI_ON_END, /* Call that was active ended */ |
74 | msi_OnError, /* On protocol error */ | 74 | MSI_ON_ERROR, /* On protocol error */ |
75 | msi_OnPeerTimeout, /* Peer timed out; stop the call */ | 75 | MSI_ON_PEERTIMEOUT, /* Peer timed out; stop the call */ |
76 | msi_OnCapabilities, /* Peer requested capabilities change */ | 76 | MSI_ON_CAPABILITIES, /* Peer requested capabilities change */ |
77 | } MSICallbackID; | 77 | } MSICallbackID; |
78 | 78 | ||
79 | /** | 79 | /** |
diff --git a/toxav/rtp.c b/toxav/rtp.c index 3d563a1f..ca4a4a7b 100644 --- a/toxav/rtp.c +++ b/toxav/rtp.c | |||
@@ -482,11 +482,11 @@ static int handle_rtp_packet(Messenger *m, uint32_t friendnumber, const uint8_t | |||
482 | return -1; | 482 | return -1; |
483 | } | 483 | } |
484 | 484 | ||
485 | LOGGER_DEBUG(m->log, "header.pt %d, video %d", (uint8_t)header.pt, (rtp_TypeVideo % 128)); | 485 | LOGGER_DEBUG(m->log, "header.pt %d, video %d", (uint8_t)header.pt, (RTP_TYPE_VIDEO % 128)); |
486 | 486 | ||
487 | // The sender uses the new large-frame capable protocol and is sending a | 487 | // The sender uses the new large-frame capable protocol and is sending a |
488 | // video packet. | 488 | // video packet. |
489 | if ((header.flags & RTP_LARGE_FRAME) && header.pt == (rtp_TypeVideo % 128)) { | 489 | if ((header.flags & RTP_LARGE_FRAME) && header.pt == (RTP_TYPE_VIDEO % 128)) { |
490 | return handle_video_packet(session, &header, data + RTP_HEADER_SIZE, length - RTP_HEADER_SIZE, m->log); | 490 | return handle_video_packet(session, &header, data + RTP_HEADER_SIZE, length - RTP_HEADER_SIZE, m->log); |
491 | } | 491 | } |
492 | 492 | ||
@@ -667,7 +667,7 @@ RTPSession *rtp_new(int payload_type, Messenger *m, uint32_t friendnumber, | |||
667 | // First entry is free. | 667 | // First entry is free. |
668 | session->work_buffer_list->next_free_entry = 0; | 668 | session->work_buffer_list->next_free_entry = 0; |
669 | 669 | ||
670 | session->ssrc = payload_type == rtp_TypeVideo ? 0 : random_u32(); | 670 | session->ssrc = payload_type == RTP_TYPE_VIDEO ? 0 : random_u32(); |
671 | session->payload_type = payload_type; | 671 | session->payload_type = payload_type; |
672 | session->m = m; | 672 | session->m = m; |
673 | session->friend_number = friendnumber; | 673 | session->friend_number = friendnumber; |
@@ -772,7 +772,7 @@ int rtp_send_data(RTPSession *session, const uint8_t *data, uint32_t length, | |||
772 | // here the highest bits gets stripped anyway, no need to do keyframe bit magic here! | 772 | // here the highest bits gets stripped anyway, no need to do keyframe bit magic here! |
773 | header.data_length_lower = length; | 773 | header.data_length_lower = length; |
774 | 774 | ||
775 | if (session->payload_type == rtp_TypeVideo) { | 775 | if (session->payload_type == RTP_TYPE_VIDEO) { |
776 | header.flags = RTP_LARGE_FRAME; | 776 | header.flags = RTP_LARGE_FRAME; |
777 | } | 777 | } |
778 | 778 | ||
diff --git a/toxav/rtp.h b/toxav/rtp.h index d7fc5560..e1cf7950 100644 --- a/toxav/rtp.h +++ b/toxav/rtp.h | |||
@@ -46,8 +46,8 @@ extern "C" { | |||
46 | * Payload type identifier. Also used as rtp callback prefix. | 46 | * Payload type identifier. Also used as rtp callback prefix. |
47 | */ | 47 | */ |
48 | enum { | 48 | enum { |
49 | rtp_TypeAudio = 192, | 49 | RTP_TYPE_AUDIO = 192, |
50 | rtp_TypeVideo = 193, | 50 | RTP_TYPE_VIDEO = 193, |
51 | }; | 51 | }; |
52 | 52 | ||
53 | /** | 53 | /** |
diff --git a/toxav/toxav.c b/toxav/toxav.c index 302657ce..ad2976d6 100644 --- a/toxav/toxav.c +++ b/toxav/toxav.c | |||
@@ -178,12 +178,12 @@ ToxAV *toxav_new(Tox *tox, TOXAV_ERR_NEW *error) | |||
178 | av->interval = 200; | 178 | av->interval = 200; |
179 | av->msi->av = av; | 179 | av->msi->av = av; |
180 | 180 | ||
181 | msi_register_callback(av->msi, callback_invite, msi_OnInvite); | 181 | msi_register_callback(av->msi, callback_invite, MSI_ON_INVITE); |
182 | msi_register_callback(av->msi, callback_start, msi_OnStart); | 182 | msi_register_callback(av->msi, callback_start, MSI_ON_START); |
183 | msi_register_callback(av->msi, callback_end, msi_OnEnd); | 183 | msi_register_callback(av->msi, callback_end, MSI_ON_END); |
184 | msi_register_callback(av->msi, callback_error, msi_OnError); | 184 | msi_register_callback(av->msi, callback_error, MSI_ON_ERROR); |
185 | msi_register_callback(av->msi, callback_error, msi_OnPeerTimeout); | 185 | msi_register_callback(av->msi, callback_error, MSI_ON_PEERTIMEOUT); |
186 | msi_register_callback(av->msi, callback_capabilites, msi_OnCapabilities); | 186 | msi_register_callback(av->msi, callback_capabilites, MSI_ON_CAPABILITIES); |
187 | 187 | ||
188 | END: | 188 | END: |
189 | 189 | ||
@@ -259,13 +259,13 @@ void toxav_iterate(ToxAV *av) | |||
259 | ac_iterate(i->audio); | 259 | ac_iterate(i->audio); |
260 | vc_iterate(i->video); | 260 | vc_iterate(i->video); |
261 | 261 | ||
262 | if (i->msi_call->self_capabilities & msi_CapRAudio && | 262 | if (i->msi_call->self_capabilities & MSI_CAP_R_AUDIO && |
263 | i->msi_call->peer_capabilities & msi_CapSAudio) { | 263 | i->msi_call->peer_capabilities & MSI_CAP_S_AUDIO) { |
264 | rc = min_s32(i->audio->lp_frame_duration, rc); | 264 | rc = min_s32(i->audio->lp_frame_duration, rc); |
265 | } | 265 | } |
266 | 266 | ||
267 | if (i->msi_call->self_capabilities & msi_CapRVideo && | 267 | if (i->msi_call->self_capabilities & MSI_CAP_R_VIDEO && |
268 | i->msi_call->peer_capabilities & msi_CapSVideo) { | 268 | i->msi_call->peer_capabilities & MSI_CAP_S_VIDEO) { |
269 | rc = min_u32(i->video->lcfd, (uint32_t) rc); | 269 | rc = min_u32(i->video->lcfd, (uint32_t) rc); |
270 | } | 270 | } |
271 | 271 | ||
@@ -315,10 +315,10 @@ bool toxav_call(ToxAV *av, uint32_t friend_number, uint32_t audio_bit_rate, uint | |||
315 | call->audio_bit_rate = audio_bit_rate; | 315 | call->audio_bit_rate = audio_bit_rate; |
316 | call->video_bit_rate = video_bit_rate; | 316 | call->video_bit_rate = video_bit_rate; |
317 | 317 | ||
318 | call->previous_self_capabilities = msi_CapRAudio | msi_CapRVideo; | 318 | call->previous_self_capabilities = MSI_CAP_R_AUDIO | MSI_CAP_R_VIDEO; |
319 | 319 | ||
320 | call->previous_self_capabilities |= audio_bit_rate > 0 ? msi_CapSAudio : 0; | 320 | call->previous_self_capabilities |= audio_bit_rate > 0 ? MSI_CAP_S_AUDIO : 0; |
321 | call->previous_self_capabilities |= video_bit_rate > 0 ? msi_CapSVideo : 0; | 321 | call->previous_self_capabilities |= video_bit_rate > 0 ? MSI_CAP_S_VIDEO : 0; |
322 | 322 | ||
323 | if (msi_invite(av->msi, &call->msi_call, friend_number, call->previous_self_capabilities) != 0) { | 323 | if (msi_invite(av->msi, &call->msi_call, friend_number, call->previous_self_capabilities) != 0) { |
324 | call_remove(call); | 324 | call_remove(call); |
@@ -379,10 +379,10 @@ bool toxav_answer(ToxAV *av, uint32_t friend_number, uint32_t audio_bit_rate, ui | |||
379 | call->audio_bit_rate = audio_bit_rate; | 379 | call->audio_bit_rate = audio_bit_rate; |
380 | call->video_bit_rate = video_bit_rate; | 380 | call->video_bit_rate = video_bit_rate; |
381 | 381 | ||
382 | call->previous_self_capabilities = msi_CapRAudio | msi_CapRVideo; | 382 | call->previous_self_capabilities = MSI_CAP_R_AUDIO | MSI_CAP_R_VIDEO; |
383 | 383 | ||
384 | call->previous_self_capabilities |= audio_bit_rate > 0 ? msi_CapSAudio : 0; | 384 | call->previous_self_capabilities |= audio_bit_rate > 0 ? MSI_CAP_S_AUDIO : 0; |
385 | call->previous_self_capabilities |= video_bit_rate > 0 ? msi_CapSVideo : 0; | 385 | call->previous_self_capabilities |= video_bit_rate > 0 ? MSI_CAP_S_VIDEO : 0; |
386 | 386 | ||
387 | if (msi_answer(call->msi_call, call->previous_self_capabilities) != 0) { | 387 | if (msi_answer(call->msi_call, call->previous_self_capabilities) != 0) { |
388 | rc = TOXAV_ERR_ANSWER_SYNC; | 388 | rc = TOXAV_ERR_ANSWER_SYNC; |
@@ -482,9 +482,9 @@ bool toxav_call_control(ToxAV *av, uint32_t friend_number, TOXAV_CALL_CONTROL co | |||
482 | break; | 482 | break; |
483 | 483 | ||
484 | case TOXAV_CALL_CONTROL_MUTE_AUDIO: { | 484 | case TOXAV_CALL_CONTROL_MUTE_AUDIO: { |
485 | if (call->msi_call->self_capabilities & msi_CapRAudio) { | 485 | if (call->msi_call->self_capabilities & MSI_CAP_R_AUDIO) { |
486 | if (msi_change_capabilities(call->msi_call, call-> | 486 | if (msi_change_capabilities(call->msi_call, call-> |
487 | msi_call->self_capabilities ^ msi_CapRAudio) == -1) { | 487 | msi_call->self_capabilities ^ MSI_CAP_R_AUDIO) == -1) { |
488 | rc = TOXAV_ERR_CALL_CONTROL_SYNC; | 488 | rc = TOXAV_ERR_CALL_CONTROL_SYNC; |
489 | goto END; | 489 | goto END; |
490 | } | 490 | } |
@@ -498,9 +498,9 @@ bool toxav_call_control(ToxAV *av, uint32_t friend_number, TOXAV_CALL_CONTROL co | |||
498 | break; | 498 | break; |
499 | 499 | ||
500 | case TOXAV_CALL_CONTROL_UNMUTE_AUDIO: { | 500 | case TOXAV_CALL_CONTROL_UNMUTE_AUDIO: { |
501 | if (call->msi_call->self_capabilities ^ msi_CapRAudio) { | 501 | if (call->msi_call->self_capabilities ^ MSI_CAP_R_AUDIO) { |
502 | if (msi_change_capabilities(call->msi_call, call-> | 502 | if (msi_change_capabilities(call->msi_call, call-> |
503 | msi_call->self_capabilities | msi_CapRAudio) == -1) { | 503 | msi_call->self_capabilities | MSI_CAP_R_AUDIO) == -1) { |
504 | rc = TOXAV_ERR_CALL_CONTROL_SYNC; | 504 | rc = TOXAV_ERR_CALL_CONTROL_SYNC; |
505 | goto END; | 505 | goto END; |
506 | } | 506 | } |
@@ -514,9 +514,9 @@ bool toxav_call_control(ToxAV *av, uint32_t friend_number, TOXAV_CALL_CONTROL co | |||
514 | break; | 514 | break; |
515 | 515 | ||
516 | case TOXAV_CALL_CONTROL_HIDE_VIDEO: { | 516 | case TOXAV_CALL_CONTROL_HIDE_VIDEO: { |
517 | if (call->msi_call->self_capabilities & msi_CapRVideo) { | 517 | if (call->msi_call->self_capabilities & MSI_CAP_R_VIDEO) { |
518 | if (msi_change_capabilities(call->msi_call, call-> | 518 | if (msi_change_capabilities(call->msi_call, call-> |
519 | msi_call->self_capabilities ^ msi_CapRVideo) == -1) { | 519 | msi_call->self_capabilities ^ MSI_CAP_R_VIDEO) == -1) { |
520 | rc = TOXAV_ERR_CALL_CONTROL_SYNC; | 520 | rc = TOXAV_ERR_CALL_CONTROL_SYNC; |
521 | goto END; | 521 | goto END; |
522 | } | 522 | } |
@@ -530,9 +530,9 @@ bool toxav_call_control(ToxAV *av, uint32_t friend_number, TOXAV_CALL_CONTROL co | |||
530 | break; | 530 | break; |
531 | 531 | ||
532 | case TOXAV_CALL_CONTROL_SHOW_VIDEO: { | 532 | case TOXAV_CALL_CONTROL_SHOW_VIDEO: { |
533 | if (call->msi_call->self_capabilities ^ msi_CapRVideo) { | 533 | if (call->msi_call->self_capabilities ^ MSI_CAP_R_VIDEO) { |
534 | if (msi_change_capabilities(call->msi_call, call-> | 534 | if (msi_change_capabilities(call->msi_call, call-> |
535 | msi_call->self_capabilities | msi_CapRVideo) == -1) { | 535 | msi_call->self_capabilities | MSI_CAP_R_VIDEO) == -1) { |
536 | rc = TOXAV_ERR_CALL_CONTROL_SYNC; | 536 | rc = TOXAV_ERR_CALL_CONTROL_SYNC; |
537 | goto END; | 537 | goto END; |
538 | } | 538 | } |
@@ -574,7 +574,7 @@ bool toxav_audio_set_bit_rate(ToxAV *av, uint32_t friend_number, uint32_t audio_ | |||
574 | pthread_mutex_lock(av->mutex); | 574 | pthread_mutex_lock(av->mutex); |
575 | call = call_get(av, friend_number); | 575 | call = call_get(av, friend_number); |
576 | 576 | ||
577 | if (call == nullptr || !call->active || call->msi_call->state != msi_CallActive) { | 577 | if (call == nullptr || !call->active || call->msi_call->state != MSI_CALL_ACTIVE) { |
578 | pthread_mutex_unlock(av->mutex); | 578 | pthread_mutex_unlock(av->mutex); |
579 | rc = TOXAV_ERR_BIT_RATE_SET_FRIEND_NOT_IN_CALL; | 579 | rc = TOXAV_ERR_BIT_RATE_SET_FRIEND_NOT_IN_CALL; |
580 | goto END; | 580 | goto END; |
@@ -588,7 +588,7 @@ bool toxav_audio_set_bit_rate(ToxAV *av, uint32_t friend_number, uint32_t audio_ | |||
588 | LOGGER_DEBUG(av->m->log, "Turned off audio sending"); | 588 | LOGGER_DEBUG(av->m->log, "Turned off audio sending"); |
589 | 589 | ||
590 | if (msi_change_capabilities(call->msi_call, call->msi_call-> | 590 | if (msi_change_capabilities(call->msi_call, call->msi_call-> |
591 | self_capabilities ^ msi_CapSAudio) != 0) { | 591 | self_capabilities ^ MSI_CAP_S_AUDIO) != 0) { |
592 | pthread_mutex_unlock(av->mutex); | 592 | pthread_mutex_unlock(av->mutex); |
593 | rc = TOXAV_ERR_BIT_RATE_SET_SYNC; | 593 | rc = TOXAV_ERR_BIT_RATE_SET_SYNC; |
594 | goto END; | 594 | goto END; |
@@ -604,7 +604,7 @@ bool toxav_audio_set_bit_rate(ToxAV *av, uint32_t friend_number, uint32_t audio_ | |||
604 | 604 | ||
605 | /* The audio has been turned off before this */ | 605 | /* The audio has been turned off before this */ |
606 | if (msi_change_capabilities(call->msi_call, call-> | 606 | if (msi_change_capabilities(call->msi_call, call-> |
607 | msi_call->self_capabilities | msi_CapSAudio) != 0) { | 607 | msi_call->self_capabilities | MSI_CAP_S_AUDIO) != 0) { |
608 | pthread_mutex_unlock(call->mutex); | 608 | pthread_mutex_unlock(call->mutex); |
609 | pthread_mutex_unlock(av->mutex); | 609 | pthread_mutex_unlock(av->mutex); |
610 | rc = TOXAV_ERR_BIT_RATE_SET_SYNC; | 610 | rc = TOXAV_ERR_BIT_RATE_SET_SYNC; |
@@ -646,7 +646,7 @@ bool toxav_video_set_bit_rate(ToxAV *av, uint32_t friend_number, uint32_t video_ | |||
646 | pthread_mutex_lock(av->mutex); | 646 | pthread_mutex_lock(av->mutex); |
647 | call = call_get(av, friend_number); | 647 | call = call_get(av, friend_number); |
648 | 648 | ||
649 | if (call == nullptr || !call->active || call->msi_call->state != msi_CallActive) { | 649 | if (call == nullptr || !call->active || call->msi_call->state != MSI_CALL_ACTIVE) { |
650 | pthread_mutex_unlock(av->mutex); | 650 | pthread_mutex_unlock(av->mutex); |
651 | rc = TOXAV_ERR_BIT_RATE_SET_FRIEND_NOT_IN_CALL; | 651 | rc = TOXAV_ERR_BIT_RATE_SET_FRIEND_NOT_IN_CALL; |
652 | goto END; | 652 | goto END; |
@@ -661,7 +661,7 @@ bool toxav_video_set_bit_rate(ToxAV *av, uint32_t friend_number, uint32_t video_ | |||
661 | 661 | ||
662 | /* Video sending is turned off; notify peer */ | 662 | /* Video sending is turned off; notify peer */ |
663 | if (msi_change_capabilities(call->msi_call, call->msi_call-> | 663 | if (msi_change_capabilities(call->msi_call, call->msi_call-> |
664 | self_capabilities ^ msi_CapSVideo) != 0) { | 664 | self_capabilities ^ MSI_CAP_S_VIDEO) != 0) { |
665 | pthread_mutex_unlock(av->mutex); | 665 | pthread_mutex_unlock(av->mutex); |
666 | rc = TOXAV_ERR_BIT_RATE_SET_SYNC; | 666 | rc = TOXAV_ERR_BIT_RATE_SET_SYNC; |
667 | goto END; | 667 | goto END; |
@@ -676,7 +676,7 @@ bool toxav_video_set_bit_rate(ToxAV *av, uint32_t friend_number, uint32_t video_ | |||
676 | 676 | ||
677 | /* The video has been turned off before this */ | 677 | /* The video has been turned off before this */ |
678 | if (msi_change_capabilities(call->msi_call, call-> | 678 | if (msi_change_capabilities(call->msi_call, call-> |
679 | msi_call->self_capabilities | msi_CapSVideo) != 0) { | 679 | msi_call->self_capabilities | MSI_CAP_S_VIDEO) != 0) { |
680 | pthread_mutex_unlock(call->mutex); | 680 | pthread_mutex_unlock(call->mutex); |
681 | pthread_mutex_unlock(av->mutex); | 681 | pthread_mutex_unlock(av->mutex); |
682 | rc = TOXAV_ERR_BIT_RATE_SET_SYNC; | 682 | rc = TOXAV_ERR_BIT_RATE_SET_SYNC; |
@@ -731,15 +731,15 @@ bool toxav_audio_send_frame(ToxAV *av, uint32_t friend_number, const int16_t *pc | |||
731 | 731 | ||
732 | call = call_get(av, friend_number); | 732 | call = call_get(av, friend_number); |
733 | 733 | ||
734 | if (call == nullptr || !call->active || call->msi_call->state != msi_CallActive) { | 734 | if (call == nullptr || !call->active || call->msi_call->state != MSI_CALL_ACTIVE) { |
735 | pthread_mutex_unlock(av->mutex); | 735 | pthread_mutex_unlock(av->mutex); |
736 | rc = TOXAV_ERR_SEND_FRAME_FRIEND_NOT_IN_CALL; | 736 | rc = TOXAV_ERR_SEND_FRAME_FRIEND_NOT_IN_CALL; |
737 | goto END; | 737 | goto END; |
738 | } | 738 | } |
739 | 739 | ||
740 | if (call->audio_bit_rate == 0 || | 740 | if (call->audio_bit_rate == 0 || |
741 | !(call->msi_call->self_capabilities & msi_CapSAudio) || | 741 | !(call->msi_call->self_capabilities & MSI_CAP_S_AUDIO) || |
742 | !(call->msi_call->peer_capabilities & msi_CapRAudio)) { | 742 | !(call->msi_call->peer_capabilities & MSI_CAP_R_AUDIO)) { |
743 | pthread_mutex_unlock(av->mutex); | 743 | pthread_mutex_unlock(av->mutex); |
744 | rc = TOXAV_ERR_SEND_FRAME_PAYLOAD_TYPE_DISABLED; | 744 | rc = TOXAV_ERR_SEND_FRAME_PAYLOAD_TYPE_DISABLED; |
745 | goto END; | 745 | goto END; |
@@ -818,15 +818,15 @@ bool toxav_video_send_frame(ToxAV *av, uint32_t friend_number, uint16_t width, u | |||
818 | 818 | ||
819 | call = call_get(av, friend_number); | 819 | call = call_get(av, friend_number); |
820 | 820 | ||
821 | if (call == nullptr || !call->active || call->msi_call->state != msi_CallActive) { | 821 | if (call == nullptr || !call->active || call->msi_call->state != MSI_CALL_ACTIVE) { |
822 | pthread_mutex_unlock(av->mutex); | 822 | pthread_mutex_unlock(av->mutex); |
823 | rc = TOXAV_ERR_SEND_FRAME_FRIEND_NOT_IN_CALL; | 823 | rc = TOXAV_ERR_SEND_FRAME_FRIEND_NOT_IN_CALL; |
824 | goto END; | 824 | goto END; |
825 | } | 825 | } |
826 | 826 | ||
827 | if (call->video_bit_rate == 0 || | 827 | if (call->video_bit_rate == 0 || |
828 | !(call->msi_call->self_capabilities & msi_CapSVideo) || | 828 | !(call->msi_call->self_capabilities & MSI_CAP_S_VIDEO) || |
829 | !(call->msi_call->peer_capabilities & msi_CapRVideo)) { | 829 | !(call->msi_call->peer_capabilities & MSI_CAP_R_VIDEO)) { |
830 | pthread_mutex_unlock(av->mutex); | 830 | pthread_mutex_unlock(av->mutex); |
831 | rc = TOXAV_ERR_SEND_FRAME_PAYLOAD_TYPE_DISABLED; | 831 | rc = TOXAV_ERR_SEND_FRAME_PAYLOAD_TYPE_DISABLED; |
832 | goto END; | 832 | goto END; |
@@ -1018,8 +1018,8 @@ int callback_invite(void *toxav_inst, MSICall *call) | |||
1018 | av_call->msi_call = call; | 1018 | av_call->msi_call = call; |
1019 | 1019 | ||
1020 | if (toxav->ccb) { | 1020 | if (toxav->ccb) { |
1021 | toxav->ccb(toxav, call->friend_number, call->peer_capabilities & msi_CapSAudio, | 1021 | toxav->ccb(toxav, call->friend_number, call->peer_capabilities & MSI_CAP_S_AUDIO, |
1022 | call->peer_capabilities & msi_CapSVideo, toxav->ccb_user_data); | 1022 | call->peer_capabilities & MSI_CAP_S_VIDEO, toxav->ccb_user_data); |
1023 | } else { | 1023 | } else { |
1024 | /* No handler to capture the call request, send failure */ | 1024 | /* No handler to capture the call request, send failure */ |
1025 | pthread_mutex_unlock(toxav->mutex); | 1025 | pthread_mutex_unlock(toxav->mutex); |
@@ -1092,13 +1092,13 @@ int callback_capabilites(void *toxav_inst, MSICall *call) | |||
1092 | ToxAV *toxav = (ToxAV *)toxav_inst; | 1092 | ToxAV *toxav = (ToxAV *)toxav_inst; |
1093 | pthread_mutex_lock(toxav->mutex); | 1093 | pthread_mutex_lock(toxav->mutex); |
1094 | 1094 | ||
1095 | if (call->peer_capabilities & msi_CapSAudio) { | 1095 | if (call->peer_capabilities & MSI_CAP_S_AUDIO) { |
1096 | rtp_allow_receiving(((ToxAVCall *)call->av_call)->audio_rtp); | 1096 | rtp_allow_receiving(((ToxAVCall *)call->av_call)->audio_rtp); |
1097 | } else { | 1097 | } else { |
1098 | rtp_stop_receiving(((ToxAVCall *)call->av_call)->audio_rtp); | 1098 | rtp_stop_receiving(((ToxAVCall *)call->av_call)->audio_rtp); |
1099 | } | 1099 | } |
1100 | 1100 | ||
1101 | if (call->peer_capabilities & msi_CapSVideo) { | 1101 | if (call->peer_capabilities & MSI_CAP_S_VIDEO) { |
1102 | rtp_allow_receiving(((ToxAVCall *)call->av_call)->video_rtp); | 1102 | rtp_allow_receiving(((ToxAVCall *)call->av_call)->video_rtp); |
1103 | } else { | 1103 | } else { |
1104 | rtp_stop_receiving(((ToxAVCall *)call->av_call)->video_rtp); | 1104 | rtp_stop_receiving(((ToxAVCall *)call->av_call)->video_rtp); |
@@ -1321,7 +1321,7 @@ bool call_prepare_transmission(ToxAVCall *call) | |||
1321 | goto FAILURE; | 1321 | goto FAILURE; |
1322 | } | 1322 | } |
1323 | 1323 | ||
1324 | call->audio_rtp = rtp_new(rtp_TypeAudio, av->m, call->friend_number, call->bwc, | 1324 | call->audio_rtp = rtp_new(RTP_TYPE_AUDIO, av->m, call->friend_number, call->bwc, |
1325 | call->audio, ac_queue_message); | 1325 | call->audio, ac_queue_message); |
1326 | 1326 | ||
1327 | if (!call->audio_rtp) { | 1327 | if (!call->audio_rtp) { |
@@ -1337,7 +1337,7 @@ bool call_prepare_transmission(ToxAVCall *call) | |||
1337 | goto FAILURE; | 1337 | goto FAILURE; |
1338 | } | 1338 | } |
1339 | 1339 | ||
1340 | call->video_rtp = rtp_new(rtp_TypeVideo, av->m, call->friend_number, call->bwc, | 1340 | call->video_rtp = rtp_new(RTP_TYPE_VIDEO, av->m, call->friend_number, call->bwc, |
1341 | call->video, vc_queue_message); | 1341 | call->video, vc_queue_message); |
1342 | 1342 | ||
1343 | if (!call->video_rtp) { | 1343 | if (!call->video_rtp) { |
diff --git a/toxav/video.c b/toxav/video.c index 034a8b56..d31df42b 100644 --- a/toxav/video.c +++ b/toxav/video.c | |||
@@ -360,13 +360,13 @@ int vc_queue_message(void *vcp, struct RTPMessage *msg) | |||
360 | VCSession *vc = (VCSession *)vcp; | 360 | VCSession *vc = (VCSession *)vcp; |
361 | const struct RTPHeader *const header = &msg->header; | 361 | const struct RTPHeader *const header = &msg->header; |
362 | 362 | ||
363 | if (msg->header.pt == (rtp_TypeVideo + 2) % 128) { | 363 | if (msg->header.pt == (RTP_TYPE_VIDEO + 2) % 128) { |
364 | LOGGER_WARNING(vc->log, "Got dummy!"); | 364 | LOGGER_WARNING(vc->log, "Got dummy!"); |
365 | free(msg); | 365 | free(msg); |
366 | return 0; | 366 | return 0; |
367 | } | 367 | } |
368 | 368 | ||
369 | if (msg->header.pt != rtp_TypeVideo % 128) { | 369 | if (msg->header.pt != RTP_TYPE_VIDEO % 128) { |
370 | LOGGER_WARNING(vc->log, "Invalid payload type! pt=%d", (int)msg->header.pt); | 370 | LOGGER_WARNING(vc->log, "Invalid payload type! pt=%d", (int)msg->header.pt); |
371 | free(msg); | 371 | free(msg); |
372 | return -1; | 372 | return -1; |
@@ -374,7 +374,7 @@ int vc_queue_message(void *vcp, struct RTPMessage *msg) | |||
374 | 374 | ||
375 | pthread_mutex_lock(vc->queue_mutex); | 375 | pthread_mutex_lock(vc->queue_mutex); |
376 | 376 | ||
377 | if ((header->flags & RTP_LARGE_FRAME) && header->pt == rtp_TypeVideo % 128) { | 377 | if ((header->flags & RTP_LARGE_FRAME) && header->pt == RTP_TYPE_VIDEO % 128) { |
378 | LOGGER_DEBUG(vc->log, "rb_write msg->len=%d b0=%d b1=%d", (int)msg->len, (int)msg->data[0], (int)msg->data[1]); | 378 | LOGGER_DEBUG(vc->log, "rb_write msg->len=%d b0=%d b1=%d", (int)msg->len, (int)msg->data[0], (int)msg->data[1]); |
379 | } | 379 | } |
380 | 380 | ||