From f4c66a4c77e5818ca9703f59a80ea92e27ed45c6 Mon Sep 17 00:00:00 2001 From: kartofen Date: Sat, 22 Oct 2022 21:08:08 +0300 Subject: abstract messages for easier use --- src/typedef.h | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) (limited to 'src/typedef.h') diff --git a/src/typedef.h b/src/typedef.h index c585f7a..b6b2b29 100644 --- a/src/typedef.h +++ b/src/typedef.h @@ -12,7 +12,27 @@ #define info(...) fprintf(stdout, __GREEN__"[INFO]"__RESET__" "__FILE__":"stringize(__LINE__)": "__VA_ARGS__) #define err(...) fprintf(stderr, __RED__"[ERR]"__RESET__" "__FILE__":"stringize(__LINE__)": "__VA_ARGS__) -#define BUF_CAP 65536 // max datagram size -#define REC_CAP 5880 // 30th of a second of audio +// ----- MESSAGE ----- // + +#define BUF_CAP 65500 // max datagram size with some bytes left for the headers and things + +#define FRAMES 32 +#define BITRATE 16 +#define SAMPLING_RATE 44100 +#define CHANNELS 2 + +#define TEMP_BUF_SZ (FRAMES * CHANNELS * 2) // 2 bytes per sample +#define REC_CAP ((BITRATE * SAMPLING_RATE * CHANNELS)/240) // 30th of a second of audio + +#define VID_CAP (BUF_CAP - ((2*(sizeof(int))) + REC_CAP)) + +typedef struct message { + char audio[REC_CAP]; + unsigned int WIDTH; + unsigned int HEIGHT; + char video[VID_CAP]; +} message; + +#define MESSAGE_SZ sizeof(message) #endif -- cgit v1.2.3