diff options
author | irungentoo <irungentoo@gmail.com> | 2014-07-29 11:03:15 -0400 |
---|---|---|
committer | irungentoo <irungentoo@gmail.com> | 2014-07-29 11:03:15 -0400 |
commit | 8be8d846860d9fd8ad6dd4e2735b5cb57b64d5a0 (patch) | |
tree | 0d1a22aebce7a64022a8b11874e3eebd3a1e9a44 | |
parent | df6e6dfd6bbffec9b63ee5b246b452f429b02e6d (diff) |
Size parameter is now checked in toxav_send_audio().
Cleaned up code a bit.
-rw-r--r-- | toxav/toxav.c | 25 | ||||
-rw-r--r-- | toxav/toxav.h | 9 |
2 files changed, 18 insertions, 16 deletions
diff --git a/toxav/toxav.c b/toxav/toxav.c index 1a25a82f..0aa88919 100644 --- a/toxav/toxav.c +++ b/toxav/toxav.c | |||
@@ -535,8 +535,8 @@ int toxav_kill_transmission ( ToxAv *av, int32_t call_index ) | |||
535 | * @retval 0 Success. | 535 | * @retval 0 Success. |
536 | * @retval -1 Failure. | 536 | * @retval -1 Failure. |
537 | */ | 537 | */ |
538 | inline__ int toxav_send_rtp_payload ( ToxAv *av, int32_t call_index, ToxAvCallType type, const uint8_t *payload, | 538 | static int toxav_send_rtp_payload(ToxAv *av, int32_t call_index, ToxAvCallType type, const uint8_t *payload, |
539 | unsigned int length ) | 539 | unsigned int length) |
540 | { | 540 | { |
541 | CallSpecific *call = &av->calls[call_index]; | 541 | CallSpecific *call = &av->calls[call_index]; |
542 | 542 | ||
@@ -592,8 +592,9 @@ inline__ int toxav_send_rtp_payload ( ToxAv *av, int32_t call_index, ToxAvCallTy | |||
592 | * @retval 0 Success. | 592 | * @retval 0 Success. |
593 | * @retval ToxAvError On error. | 593 | * @retval ToxAvError On error. |
594 | */ | 594 | */ |
595 | inline__ int toxav_send_video ( ToxAv *av, int32_t call_index, const uint8_t *frame, int frame_size) | 595 | int toxav_send_video ( ToxAv *av, int32_t call_index, const uint8_t *frame, unsigned int frame_size) |
596 | { | 596 | { |
597 | |||
597 | if (cii(call_index, av->msi_session)) { | 598 | if (cii(call_index, av->msi_session)) { |
598 | LOGGER_WARNING("Invalid call index: %d", call_index); | 599 | LOGGER_WARNING("Invalid call index: %d", call_index); |
599 | return ErrorNoCall; | 600 | return ErrorNoCall; |
@@ -626,7 +627,7 @@ inline__ int toxav_send_video ( ToxAv *av, int32_t call_index, const uint8_t *fr | |||
626 | * @retval ToxAvError On error. | 627 | * @retval ToxAvError On error. |
627 | * @retval >0 On success | 628 | * @retval >0 On success |
628 | */ | 629 | */ |
629 | inline__ int toxav_prepare_video_frame(ToxAv *av, int32_t call_index, uint8_t *dest, int dest_max, vpx_image_t *input) | 630 | int toxav_prepare_video_frame(ToxAv *av, int32_t call_index, uint8_t *dest, int dest_max, vpx_image_t *input) |
630 | { | 631 | { |
631 | if (cii(call_index, av->msi_session)) { | 632 | if (cii(call_index, av->msi_session)) { |
632 | LOGGER_WARNING("Invalid call index: %d", call_index); | 633 | LOGGER_WARNING("Invalid call index: %d", call_index); |
@@ -682,15 +683,17 @@ inline__ int toxav_prepare_video_frame(ToxAv *av, int32_t call_index, uint8_t *d | |||
682 | * @brief Send audio frame. | 683 | * @brief Send audio frame. |
683 | * | 684 | * |
684 | * @param av Handler. | 685 | * @param av Handler. |
685 | * @param frame The frame (raw 16 bit signed pcm with AUDIO_CHANNELS channels audio.) | 686 | * @param data The audio data encoded with toxav_prepare_audio_frame(). |
686 | * @param frame_size Its size in number of frames/samples (one frame/sample is 16 bits or 2 bytes) | 687 | * @param size Its size in number of bytes. |
687 | * frame size should be AUDIO_FRAME_SIZE. | ||
688 | * @return int | 688 | * @return int |
689 | * @retval 0 Success. | 689 | * @retval 0 Success. |
690 | * @retval ToxAvError On error. | 690 | * @retval ToxAvError On error. |
691 | */ | 691 | */ |
692 | inline__ int toxav_send_audio ( ToxAv *av, int32_t call_index, const uint8_t *frame, int frame_size) | 692 | int toxav_send_audio ( ToxAv *av, int32_t call_index, const uint8_t *data, unsigned int size) |
693 | { | 693 | { |
694 | if (size > MAX_CRYPTO_DATA_SIZE) | ||
695 | return ErrorInternal; | ||
696 | |||
694 | if (cii(call_index, av->msi_session) || !av->calls[call_index].call_active) { | 697 | if (cii(call_index, av->msi_session) || !av->calls[call_index].call_active) { |
695 | LOGGER_WARNING("Action on inactive call: %d", call_index); | 698 | LOGGER_WARNING("Action on inactive call: %d", call_index); |
696 | return ErrorNoCall; | 699 | return ErrorNoCall; |
@@ -706,7 +709,7 @@ inline__ int toxav_send_audio ( ToxAv *av, int32_t call_index, const uint8_t *fr | |||
706 | return ErrorNoCall; | 709 | return ErrorNoCall; |
707 | } | 710 | } |
708 | 711 | ||
709 | int rc = toxav_send_rtp_payload(av, call_index, TypeAudio, frame, frame_size); | 712 | int rc = toxav_send_rtp_payload(av, call_index, TypeAudio, data, size); |
710 | pthread_mutex_unlock(&call->mutex); | 713 | pthread_mutex_unlock(&call->mutex); |
711 | 714 | ||
712 | return rc; | 715 | return rc; |
@@ -724,8 +727,8 @@ inline__ int toxav_send_audio ( ToxAv *av, int32_t call_index, const uint8_t *fr | |||
724 | * @retval ToxAvError On error. | 727 | * @retval ToxAvError On error. |
725 | * @retval >0 On success | 728 | * @retval >0 On success |
726 | */ | 729 | */ |
727 | inline__ int toxav_prepare_audio_frame ( ToxAv *av, int32_t call_index, uint8_t *dest, int dest_max, | 730 | int toxav_prepare_audio_frame ( ToxAv *av, int32_t call_index, uint8_t *dest, int dest_max, const int16_t *frame, |
728 | const int16_t *frame, int frame_size) | 731 | int frame_size) |
729 | { | 732 | { |
730 | if (cii(call_index, av->msi_session) || !av->calls[call_index].call_active) { | 733 | if (cii(call_index, av->msi_session) || !av->calls[call_index].call_active) { |
731 | LOGGER_WARNING("Action on inactive call: %d", call_index); | 734 | LOGGER_WARNING("Action on inactive call: %d", call_index); |
diff --git a/toxav/toxav.h b/toxav/toxav.h index 593f3a2a..4dddc9b5 100644 --- a/toxav/toxav.h +++ b/toxav/toxav.h | |||
@@ -293,20 +293,19 @@ int toxav_kill_transmission(ToxAv *av, int32_t call_index); | |||
293 | * @retval 0 Success. | 293 | * @retval 0 Success. |
294 | * @retval ToxAvError On error. | 294 | * @retval ToxAvError On error. |
295 | */ | 295 | */ |
296 | int toxav_send_video ( ToxAv *av, int32_t call_index, const uint8_t *frame, int frame_size); | 296 | int toxav_send_video ( ToxAv *av, int32_t call_index, const uint8_t *frame, unsigned int frame_size); |
297 | 297 | ||
298 | /** | 298 | /** |
299 | * @brief Send audio frame. | 299 | * @brief Send audio frame. |
300 | * | 300 | * |
301 | * @param av Handler. | 301 | * @param av Handler. |
302 | * @param frame The frame (raw 16 bit signed pcm with AUDIO_CHANNELS channels audio.) | 302 | * @param data The audio data encoded with toxav_prepare_audio_frame(). |
303 | * @param frame_size Its size in number of frames/samples (one frame/sample is 16 bits or 2 bytes) | 303 | * @param size Its size in number of bytes. |
304 | * frame size should be AUDIO_FRAME_SIZE. | ||
305 | * @return int | 304 | * @return int |
306 | * @retval 0 Success. | 305 | * @retval 0 Success. |
307 | * @retval ToxAvError On error. | 306 | * @retval ToxAvError On error. |
308 | */ | 307 | */ |
309 | int toxav_send_audio ( ToxAv *av, int32_t call_index, const uint8_t *frame, int frame_size); | 308 | int toxav_send_audio ( ToxAv *av, int32_t call_index, const uint8_t *frame, unsigned int size); |
310 | 309 | ||
311 | /** | 310 | /** |
312 | * @brief Encode video frame | 311 | * @brief Encode video frame |