diff options
author | mannol <eniz_vukovic@hotmail.com> | 2015-06-27 01:55:28 +0200 |
---|---|---|
committer | mannol <eniz_vukovic@hotmail.com> | 2015-06-27 01:55:28 +0200 |
commit | 08bc4eb0e09cb4d4d9724f7bfeae5f4feb3aaf29 (patch) | |
tree | 5cbdbf48806abd4a12bb94ac1dd5397e3ce4ae47 /toxav/toxav.c | |
parent | 9aba4ec273b782fd34a869a902cc2a0b8275dbff (diff) |
Added payload turning off by setting bit rate to 0
Diffstat (limited to 'toxav/toxav.c')
-rw-r--r-- | toxav/toxav.c | 83 |
1 files changed, 71 insertions, 12 deletions
diff --git a/toxav/toxav.c b/toxav/toxav.c index c7012cb4..59afe654 100644 --- a/toxav/toxav.c +++ b/toxav/toxav.c | |||
@@ -596,6 +596,8 @@ void toxav_callback_audio_bit_rate_status(ToxAV* av, toxav_audio_bit_rate_status | |||
596 | 596 | ||
597 | bool toxav_audio_bit_rate_set(ToxAV* av, uint32_t friend_number, uint32_t audio_bit_rate, bool force, TOXAV_ERR_SET_BIT_RATE* error) | 597 | bool toxav_audio_bit_rate_set(ToxAV* av, uint32_t friend_number, uint32_t audio_bit_rate, bool force, TOXAV_ERR_SET_BIT_RATE* error) |
598 | { | 598 | { |
599 | LOGGER_DEBUG("Setting new audio bitrate to: %d", audio_bit_rate); | ||
600 | |||
599 | TOXAV_ERR_SET_BIT_RATE rc = TOXAV_ERR_SET_BIT_RATE_OK; | 601 | TOXAV_ERR_SET_BIT_RATE rc = TOXAV_ERR_SET_BIT_RATE_OK; |
600 | ToxAVCall* call; | 602 | ToxAVCall* call; |
601 | 603 | ||
@@ -604,7 +606,7 @@ bool toxav_audio_bit_rate_set(ToxAV* av, uint32_t friend_number, uint32_t audio_ | |||
604 | goto END; | 606 | goto END; |
605 | } | 607 | } |
606 | 608 | ||
607 | if (audio_bit_rate_invalid(audio_bit_rate)) { | 609 | if (audio_bit_rate && audio_bit_rate_invalid(audio_bit_rate)) { |
608 | rc = TOXAV_ERR_SET_BIT_RATE_INVALID; | 610 | rc = TOXAV_ERR_SET_BIT_RATE_INVALID; |
609 | goto END; | 611 | goto END; |
610 | } | 612 | } |
@@ -622,18 +624,39 @@ bool toxav_audio_bit_rate_set(ToxAV* av, uint32_t friend_number, uint32_t audio_ | |||
622 | goto END; | 624 | goto END; |
623 | } | 625 | } |
624 | 626 | ||
627 | /* Video sending is turned off; notify peer */ | ||
628 | if (audio_bit_rate == 0) { | ||
629 | call->audio_bit_rate = 0; | ||
630 | |||
631 | msi_change_capabilities(call->msi_call, call->msi_call-> | ||
632 | self_capabilities ^ msi_CapSAudio); | ||
633 | pthread_mutex_unlock(av->mutex); | ||
634 | goto END; | ||
635 | } | ||
625 | 636 | ||
626 | pthread_mutex_lock(call->mutex); | 637 | pthread_mutex_lock(call->mutex); |
627 | 638 | ||
628 | if (audio_bit_rate > call->audio_bit_rate && !force) | 639 | if (call->audio_bit_rate == 0) { |
629 | ba_set(&call->aba, audio_bit_rate); | 640 | /* The audio has been turned off before this */ |
630 | else { | ||
631 | /* Cancel any previous non forceful bitrate change request */ | ||
632 | memset(&call->aba, 0, sizeof(call->aba)); | ||
633 | call->audio_bit_rate = audio_bit_rate; | 641 | call->audio_bit_rate = audio_bit_rate; |
634 | 642 | ||
643 | msi_change_capabilities(call->msi_call, call-> | ||
644 | msi_call->self_capabilities | msi_CapSAudio); | ||
645 | |||
635 | if (!force && av->abcb.first) | 646 | if (!force && av->abcb.first) |
636 | av->abcb.first (av, call->friend_number, true, audio_bit_rate, av->abcb.second); | 647 | av->abcb.first (av, call->friend_number, true, audio_bit_rate, av->abcb.second); |
648 | } else { | ||
649 | /* The audio was active before this */ | ||
650 | if (audio_bit_rate > call->audio_bit_rate && !force) | ||
651 | ba_set(&call->aba, audio_bit_rate); | ||
652 | else { | ||
653 | /* Cancel any previous non forceful bitrate change request */ | ||
654 | memset(&call->aba, 0, sizeof(call->aba)); | ||
655 | call->audio_bit_rate = audio_bit_rate; | ||
656 | |||
657 | if (!force && av->abcb.first) | ||
658 | av->abcb.first (av, call->friend_number, true, audio_bit_rate, av->abcb.second); | ||
659 | } | ||
637 | } | 660 | } |
638 | 661 | ||
639 | pthread_mutex_unlock(call->mutex); | 662 | pthread_mutex_unlock(call->mutex); |
@@ -656,6 +679,8 @@ void toxav_callback_video_bit_rate_status(ToxAV* av, toxav_video_bit_rate_status | |||
656 | 679 | ||
657 | bool toxav_video_bit_rate_set(ToxAV* av, uint32_t friend_number, uint32_t video_bit_rate, bool force, TOXAV_ERR_SET_BIT_RATE* error) | 680 | bool toxav_video_bit_rate_set(ToxAV* av, uint32_t friend_number, uint32_t video_bit_rate, bool force, TOXAV_ERR_SET_BIT_RATE* error) |
658 | { | 681 | { |
682 | LOGGER_DEBUG("Setting new video bitrate to: %d", video_bit_rate); | ||
683 | |||
659 | TOXAV_ERR_SET_BIT_RATE rc = TOXAV_ERR_SET_BIT_RATE_OK; | 684 | TOXAV_ERR_SET_BIT_RATE rc = TOXAV_ERR_SET_BIT_RATE_OK; |
660 | ToxAVCall* call; | 685 | ToxAVCall* call; |
661 | 686 | ||
@@ -664,7 +689,7 @@ bool toxav_video_bit_rate_set(ToxAV* av, uint32_t friend_number, uint32_t video_ | |||
664 | goto END; | 689 | goto END; |
665 | } | 690 | } |
666 | 691 | ||
667 | if (video_bit_rate_invalid(video_bit_rate)) { | 692 | if (video_bit_rate && video_bit_rate_invalid(video_bit_rate)) { |
668 | rc = TOXAV_ERR_SET_BIT_RATE_INVALID; | 693 | rc = TOXAV_ERR_SET_BIT_RATE_INVALID; |
669 | goto END; | 694 | goto END; |
670 | } | 695 | } |
@@ -682,17 +707,39 @@ bool toxav_video_bit_rate_set(ToxAV* av, uint32_t friend_number, uint32_t video_ | |||
682 | goto END; | 707 | goto END; |
683 | } | 708 | } |
684 | 709 | ||
710 | /* Video sending is turned off; notify peer */ | ||
711 | if (video_bit_rate == 0) { | ||
712 | call->video_bit_rate = 0; | ||
713 | |||
714 | msi_change_capabilities(call->msi_call, call->msi_call-> | ||
715 | self_capabilities ^ msi_CapSVideo); | ||
716 | pthread_mutex_unlock(av->mutex); | ||
717 | goto END; | ||
718 | } | ||
719 | |||
685 | pthread_mutex_lock(call->mutex); | 720 | pthread_mutex_lock(call->mutex); |
686 | 721 | ||
687 | if (video_bit_rate > call->video_bit_rate && !force) | 722 | if (call->video_bit_rate == 0) { |
688 | ba_set(&call->vba, video_bit_rate); | 723 | /* The video has been turned off before this */ |
689 | else { | ||
690 | /* Cancel any previous non forceful bitrate change request */ | ||
691 | memset(&call->vba, 0, sizeof(call->vba)); | ||
692 | call->video_bit_rate = video_bit_rate; | 724 | call->video_bit_rate = video_bit_rate; |
693 | 725 | ||
726 | msi_change_capabilities(call->msi_call, call-> | ||
727 | msi_call->self_capabilities | msi_CapSVideo); | ||
728 | |||
694 | if (!force && av->vbcb.first) | 729 | if (!force && av->vbcb.first) |
695 | av->vbcb.first (av, call->friend_number, true, video_bit_rate, av->vbcb.second); | 730 | av->vbcb.first (av, call->friend_number, true, video_bit_rate, av->vbcb.second); |
731 | } else { | ||
732 | /* The video was active before this */ | ||
733 | if (video_bit_rate > call->video_bit_rate && !force) | ||
734 | ba_set(&call->vba, video_bit_rate); | ||
735 | else { | ||
736 | /* Cancel any previous non forceful bitrate change request */ | ||
737 | memset(&call->vba, 0, sizeof(call->vba)); | ||
738 | call->video_bit_rate = video_bit_rate; | ||
739 | |||
740 | if (!force && av->vbcb.first) | ||
741 | av->vbcb.first (av, call->friend_number, true, video_bit_rate, av->vbcb.second); | ||
742 | } | ||
696 | } | 743 | } |
697 | 744 | ||
698 | pthread_mutex_unlock(call->mutex); | 745 | pthread_mutex_unlock(call->mutex); |
@@ -723,6 +770,12 @@ bool toxav_audio_send_frame(ToxAV* av, uint32_t friend_number, const int16_t* pc | |||
723 | goto END; | 770 | goto END; |
724 | } | 771 | } |
725 | 772 | ||
773 | if (call->audio_bit_rate == 0) { | ||
774 | pthread_mutex_unlock(av->mutex); | ||
775 | rc = TOXAV_ERR_SEND_FRAME_BIT_RATE_NOT_SET; | ||
776 | goto END; | ||
777 | } | ||
778 | |||
726 | pthread_mutex_lock(call->mutex_audio); | 779 | pthread_mutex_lock(call->mutex_audio); |
727 | pthread_mutex_unlock(av->mutex); | 780 | pthread_mutex_unlock(av->mutex); |
728 | 781 | ||
@@ -825,6 +878,12 @@ bool toxav_video_send_frame(ToxAV* av, uint32_t friend_number, uint16_t width, u | |||
825 | goto END; | 878 | goto END; |
826 | } | 879 | } |
827 | 880 | ||
881 | if (call->video_bit_rate == 0) { | ||
882 | pthread_mutex_unlock(av->mutex); | ||
883 | rc = TOXAV_ERR_SEND_FRAME_BIT_RATE_NOT_SET; | ||
884 | goto END; | ||
885 | } | ||
886 | |||
828 | pthread_mutex_lock(call->mutex_video); | 887 | pthread_mutex_lock(call->mutex_video); |
829 | pthread_mutex_unlock(av->mutex); | 888 | pthread_mutex_unlock(av->mutex); |
830 | 889 | ||