summaryrefslogtreecommitdiff
path: root/toxav/toxav.c
diff options
context:
space:
mode:
authoriphydf <iphydf@users.noreply.github.com>2018-08-12 12:53:12 +0000
committeriphydf <iphydf@users.noreply.github.com>2018-08-12 20:07:18 +0000
commit4ed6e5999226f9061f546108c5be72fe6f21a775 (patch)
treee716af08ec232c8d01b526d7b88c5ed502cd6a77 /toxav/toxav.c
parent767ccbb387a462c9bc21aaf22d2c3d3358c147b8 (diff)
Fix enumerator names to comply with toxcore naming standards.
Diffstat (limited to 'toxav/toxav.c')
-rw-r--r--toxav/toxav.c84
1 files changed, 42 insertions, 42 deletions
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
188END: 188END:
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) {