From 3297b62ad4e51bceecbadafa2a80c3871b100437 Mon Sep 17 00:00:00 2001 From: Green Sky Date: Fri, 20 Sep 2024 08:59:48 +0200 Subject: [PATCH] address some of my review 1 --- toxav/audio.c | 2 +- toxav/audio.h | 8 +------- toxav/rtp.c | 5 +---- toxav/toxav.c | 2 +- toxav/video.h | 5 ----- 5 files changed, 4 insertions(+), 18 deletions(-) diff --git a/toxav/audio.c b/toxav/audio.c index 2d89355b2a..ab11cc0d6b 100644 --- a/toxav/audio.c +++ b/toxav/audio.c @@ -28,7 +28,7 @@ static bool reconfigure_audio_decoder(ACSession *ac, uint32_t sampling_rate, uin -ACSession *ac_new(Mono_Time *mono_time, const Logger *log, Tox *tox, ToxAV *av, uint32_t friend_number, +ACSession *ac_new(Mono_Time *mono_time, const Logger *log, ToxAV *av, uint32_t friend_number, toxav_audio_receive_frame_cb *cb, void *cb_data) { ACSession *ac = (ACSession *)calloc(1, sizeof(ACSession)); diff --git a/toxav/audio.h b/toxav/audio.h index d7d8fd8b1a..3ae4251137 100644 --- a/toxav/audio.h +++ b/toxav/audio.h @@ -34,11 +34,6 @@ #define AUDIO_MAX_BUFFER_SIZE_PCM16 ((AUDIO_MAX_SAMPLE_RATE * AUDIO_MAX_FRAME_DURATION_MS) / 1000) #define AUDIO_MAX_BUFFER_SIZE_BYTES (AUDIO_MAX_BUFFER_SIZE_PCM16 * 2) -#ifndef TOX_DEFINED -#define TOX_DEFINED -typedef struct Tox Tox; -#endif /* TOX_DEFINED */ - typedef struct ACSession { Mono_Time *mono_time; const Logger *log; @@ -66,10 +61,9 @@ typedef struct ACSession { /* Audio frame receive callback */ toxav_audio_receive_frame_cb *acb; void *acb_user_data; - Tox *tox; } ACSession; -ACSession *ac_new(Mono_Time *mono_time, const Logger *log, Tox *tox, ToxAV *av, uint32_t friend_number, +ACSession *ac_new(Mono_Time *mono_time, const Logger *log, ToxAV *av, uint32_t friend_number, toxav_audio_receive_frame_cb *cb, void *cb_data); void ac_kill(ACSession *ac); void ac_iterate(ACSession *ac); diff --git a/toxav/rtp.c b/toxav/rtp.c index bb3fa14fe1..32b2545d84 100644 --- a/toxav/rtp.c +++ b/toxav/rtp.c @@ -19,7 +19,6 @@ #include "../toxcore/mono_time.h" #include "../toxcore/net_crypto.h" #include "../toxcore/tox_private.h" -#include "../toxcore/tox_struct.h" #include "../toxcore/util.h" /** @@ -676,10 +675,8 @@ size_t rtp_header_unpack(const uint8_t *data, struct RTPHeader *header) static uint32_t rtp_random_u32(void) { - uint32_t randnum; // HINT: uses libsodium function - randombytes((uint8_t *)&randnum, sizeof(randnum)); - return randnum; + return randombytes_random(); } RTPSession *rtp_new(const Logger *log, int payload_type, Tox *tox, ToxAV *toxav, uint32_t friendnumber, diff --git a/toxav/toxav.c b/toxav/toxav.c index c5daca451d..413b643a32 100644 --- a/toxav/toxav.c +++ b/toxav/toxav.c @@ -1501,7 +1501,7 @@ static bool call_prepare_transmission(ToxAVCall *call) call->bwc = bwc_new(av->log, av->tox, call->friend_number, callback_bwc, call, av->toxav_mono_time); { /* Prepare audio */ - call->audio = ac_new(av->toxav_mono_time, av->log, av->tox, av, call->friend_number, av->acb, av->acb_user_data); + call->audio = ac_new(av->toxav_mono_time, av->log, av, call->friend_number, av->acb, av->acb_user_data); if (call->audio == nullptr) { LOGGER_ERROR(av->log, "Failed to create audio codec session"); diff --git a/toxav/video.h b/toxav/video.h index 98e937d984..7bd54fa631 100644 --- a/toxav/video.h +++ b/toxav/video.h @@ -21,11 +21,6 @@ #include "ring_buffer.h" #include "rtp.h" -#ifndef TOX_DEFINED -#define TOX_DEFINED -typedef struct Tox Tox; -#endif /* TOX_DEFINED */ - typedef struct VCSession { /* encoding */ vpx_codec_ctx_t encoder[1];