From 20c99d0540dbe7def829de5f2175276721953ee7 Mon Sep 17 00:00:00 2001 From: "Alexander \"Arav\" Andreev" Date: Thu, 21 Mar 2024 17:51:03 +0400 Subject: [PATCH] Last main.c. --- src/main.c | 53 +++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 45 insertions(+), 8 deletions(-) diff --git a/src/main.c b/src/main.c index 2724557..168bcaa 100644 --- a/src/main.c +++ b/src/main.c @@ -1,20 +1,57 @@ #include +#include +#include #include "audio.h" +#include "crypt.h" + +#define CHANNELS 1 +#define SAMPLE_RATE 48000 +#define FRAMES_PER_BUFFFER 480 + +#define BUF_SIZE (FRAMES_PER_BUFFFER * CHANNELS) int main(int argc, char **argv) { (void)argv; (void)argc; - - audio_t aud; - audio_init_default(&aud, 1, 48000, 480, audio_default_callback); + if (sodium_init() < 0) { + fprintf(stderr, "A Sodium cryptography library is failed to initialise!\n"); + return -1; + } - printf("Listening... "); - getchar(); - printf("Done!\n"); - - audio_destroy(&aud); + crypt_key_t own, remote; + + if (crypt_key_gen(&own) < 0) { + fprintf(stderr, "Failed to generate the keys."); + return -1; + } + + if (crypt_key_gen(&remote) < 0) { + fprintf(stderr, "Failed to generate the keys."); + return -1; + } + + crypt_session_t sess, sess_r; + + crypt_session_init(&sess, &own, &remote, true); + crypt_session_init(&sess_r, &remote, &own, false); + + // audio_t aud; + + // uint8_t buf[BUF_SIZE]; + // memset(buf, 0, BUF_SIZE); + + // audio_init(&aud, CHANNELS, SAMPLE_RATE, FRAMES_PER_BUFFFER); + + // printf("Listening... "); + // for (int i = 0; i < (2 * SAMPLE_RATE)/FRAMES_PER_BUFFFER; ++i) { + // audio_read(&aud, buf, BUF_SIZE); + // audio_write(&aud, buf, BUF_SIZE); + // } + // printf("Done!\n"); + + // audio_destroy(&aud); return 0; } \ No newline at end of file